|SCHG: Sonic 2 (Master System)|
Each level header consists of 22 bytes:
AA BBBB CC DDDD EEEE FFFF GGGG HHHH IIII JJJJ KKKK LLLL
The EEEE and FFFF words are used by collision detection routines to move backwards and forwards in the level data array, whole rows at a time (e.g. for checking collisions above and below an object). The LLLL field is used to calculate the address of any given row of mappings in the level data array.
ROM addresses for the level headers:
|5635, 564B, 5661||GHZ1/2/3|
|5677, 568D, 56A3||SHZ1/2/3|
|56B9, 56CF, 56E5||ALZ1/2/3|
|56FB, 5711, 5727||UGZ1/2/3|
|573D, 5753, 5769||GMZ1/2/3|
|577F, 5795, 57AB||SEZ1/2/3|
|57C1, 57D7, 57ED||CEZ1/2/3|
First of all, the metatiles begin with an offset index containing 256 16-bit, little endian pointers. The pointers are relative to a fixed position in the ROM, which varies depending on which set of mappings you're looking at. Immediately after the offset index is the metatile data itself. Each 32x32 tile is composed of 16 8x8 tiles. A 16-bit, little endian value is used to define which 8x8 tile is pulled from VRAM, and also how that 8x8 tile is displayed. Adding certain amounts to the value cause the 8x8 tile to be flipped/mirrored:
|$0000||Nothing (no flip, use BG palette, low priority)|
|$0800||Use sprite palette|
Each byte in the level layout represents a 32x32 tile. The level is composed of many 32x32 tiles. In a savestate, the level is easy to edit because it's simple and uncompressed. However, in the ROM it's usually compressed.
2020 2020 2020
FD means compression has occurred. 06 is the number of times a byte has been repeated. 20 is the byte which has been repeated.
Strangely, 1515 (for example) appears in the ROM as FD02 15, which wastes space. Repeated strings of bytes can be used in the ROM, and will appear correctly in the game. Compression is entirely optional, given that there is enough space in the ROM for the data.
|Sonic Community Hacking Guide|
|Sonic Music Hacking Guide | SonED2 Manual|
|Sonic the Hedgehog (16-bit) | Sonic the Hedgehog (8-bit) | Sonic Eraser | Sonic CD (prototype 510) | Sonic CD | Sonic CD (PC) | Sonic 2 (Nick Arcade prototype) | Sonic 2 (Simon Wai prototype) | Sonic 2 (16-bit) | Sonic 2 (8-bit) | Sonic 2 & Knuckles | Dr. Robotnik's Mean Bean Machine | Sonic Triple Trouble | Sonic 3 | Sonic & Knuckles | Sonic 3 & Knuckles | Sonic & Knuckles Collection | Sonic Crackers | Sonic 3D: Flickies' Island | Chaotix | Sonic R PC | Sonic Jam 6 | Sonic Advance | Sonic Advance 2 | Sonic Advance 3 | Sonic Battle | Sonic Adventure | Sonic Adventure DX: Director's Cut | Sonic Adventure DX: PC | Sonic Adventure (2010) | Sonic Adventure 2 | Sonic Adventure 2: Battle | Sonic Adventure 2 (PC) | Sonic Heroes | Shadow the Hedgehog | Sonic Riders | Sonic the Hedgehog (2006) | Sonic & Sega All-Stars Racing | Sonic Unleashed (Xbox 360/PS3) | Sonic Generations|
|The Nemesis Hacking Guides||The Esrael Hacking Guides|
|ROM: Sonic 1 | Sonic 2 | Sonic 2 Beta | Sonic 3||Sonic 1 (English / Portuguese) | Sonic 2 Beta (English / Portuguese) | Sonic 2 and Knuckles (English / Portuguese)|
|Move to Sega Retro|
|Number Systems (or scrap) | Assembly Hacking Guide | Subroutine Equivalency List | 68000 Instruction Set | 68000 ASM-to-Hex Code Reference | VDP Documentation | Official Sega 32X Documentation | Official Mega-CD Documentation | Official Sega Mega Drive Documentation|