Sonic the Hedgehog 2 (Master System)/Level Editing

From Sonic Retro

(Redirected from SCHG:Sonic 2 SMS/Level Editing)
SCHG: Sonic 2 (Master System)
Main Article
Art Editing
Editing Art
Uncompressed Art
Level Editing
Editing Levels
Level Headers
32x32 MetaTiles
Level Layout
Object Editing
Editing Objects
Object Layout
Object Types
Music Editing
Editing Music
Driver Technical Info
Module Format

Level headers

Each level header consists of 22 bytes:


  • AA = 32x32 mapping bank number
  • BBBB = 32x32 mappings pointer
  • CC = Level layout bank number
  • DDDD = Level layout pointer
  • EEEE = Level width in mapping blocks
  • FFFF = 2's complement level width in blocks
  • GGGG = Vertical offset into layout data. This is always 7 * EEEE.
  • HHHH = Minimum camera x coordinate
  • IIII = Minimum camera y coordinate
  • JJJJ = Maximum camera x coordinate
  • KKKK = Maximum camera y coordinate
  • LLLL = Pointer to table of multiples of level width.

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:

Offset Level
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
5803 Bad Ending
5819 Good Ending
582F Intro
5845 Title Screen

32x32 MetaTiles

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:

Value added Effect
$0000 Nothing (no flip, use BG palette, low priority)
$0200 Flip horizontally
$0400 Flip vertically
$0800 Use sprite palette
$1000 High priority

Level Layout & compression

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
---> Compressed:
FD06 20

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 CD (2011) | 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 the Hedgehog 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 Shuffle | 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 Colours | Sonic Generations | Sonic Lost World | Sonic Forces
Legacy Guides
The Nemesis Hacking Guides The Esrael Hacking Guides
ROM: Sonic 1 | Sonic 2 | Sonic 2 Beta | Sonic 3

Savestate: Sonic 1 | Sonic 2 Beta/Final | 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