Sonic the Hedgehog (16-bit)/Level Editing
From Sonic Retro
(Redirected from SCHG:Sonic the Hedgehog/Level Editing)
SCHG: Sonic the Hedgehog |
---|
|
Contents
Object placement
There are six bytes in one object definition. The first two bytes are the X position of the object. The next two bytes, broken down in bits, have the format AB00 YYYY YYYY YYYY, where A is the vertical flip flag, B is the horizontal flip flag and YYYY YYYY YYYY is the Y position of the object. The 5th byte is the reference number on the object pointer list, with the most significant bit if set indicating that the object should be assigned an entry on the object respawn table, and the 6th byte is an optional declaration to use for defining that object's behavior and/or animation. This will depend on the object.
The 6th byte, the object subtype, is loaded in byte $28 of the status table of that object (see SCHG:Sonic the Hedgehog/RAM Editing#Object Status Table Format for more info).
Level layout
Level layouts are pretty simple. There is a two byte header, with the first byte being width - 1, and the second being height - 1. After that, there is one byte per 256x256 tile to place on the map. The blocks are put together from left to right, top to bottom. Unlike Sonic 2 and 3, which have two solidity layers, Sonic 1 uses a special flag to mark loop tiles. If the most significant bit (0x80) of the byte is set, then that chunk will be marked as a loop tile, and will be switched with the tile following it in the list as Sonic passes through it.
Sonic 1 loads level layouts into RAM in a format that allows level sizes up to 64 by 8 chunks.
16x16 block mappings
This data is Enigma compressed.
16x16 block mappings consist of four 8x8 tiles, arranged in the shape:
0 | 1 |
2 | 3 |
Each 8x8 tile is represented by one word, which like all SEGA Mega Drive VDP pattern indices, is a bitmask of the form PCCY XAAA AAAA AAAA. P is the priority flag, CC is the palette line to use, X and Y indicate that the sprite should be flipped horizontally and vertically respectively, and AAA AAAA AAAA is the actual tile index, i.e. the VRAM offset of the pattern divided by $20.
256x256 block mappings
This data is Kosinski compressed.
256x256 block mappings consist of 256 16x16 tiles, arranged in the shape:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |
96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 |
112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 |
144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 |
160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 |
176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 |
192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 |
208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 |
224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 |
240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 |
Each 16x16 tile has a two-byte value with the format 0SSY X0II IIII IIII. SS is the solidity of the tile - 00 means not solid, 01 means top solid, 10 means left/right/bottom solid, and 11 means all solid. Y is the Y-flip flag, X is the X-flip flag, and II IIII IIII is the index of the 16x16 tile to use.
References