Actions

SCHG

Sonic the Hedgehog 2 (16-bit)/Level Editing

From Sonic Retro

Revision as of 03:44, 25 March 2020 by Black Squirrel (talk | contribs) (Text replacement - "Genesis" to "Mega Drive")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Sonic Community Hacking Guide
Sonic the Hedgehog 2 (16-bit)
Art
Objects
Levels
Text
Music
RAM
Miscellaneous

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 ABC0 YYYY YYYY YYYY, where A is a flag which if set indicates that the object should be assigned an entry on the object respawn table, B is the vertical flip flag, C 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 (see above), 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. See the level specific hacking info for the locations of the object lists.

The 6th byte, the object subtype, is loaded in byte $28 of the status table of that object (see SCHG:Sonic the Hedgehog 2 (16-bit)/RAM Editing#Object Status Table Format for more info).

Ring placement

There are four bytes for every ring object. The first 2 bytes are X coordinates, after that there is one nibble to determine how many rings, then three nibbles (or one nibble and one byte) for the Y coordinates. After you are done adding all your rings for the level, "FF FF" will end the ring data. A format would look like this:

XX XX TY YY

Where X represents X position, Y represents Y position, and T represents type, as per the table below.

Example: 03 46 10 2B

If you see this, then you will get two horizontal rings at X = 0346 Y = 02B. The "1" determines how many rings there are, and in which direction they go (horizontal or vertical). For the "T" nybble, the entry will create a column of rings if the uppermost bit is set, otherwise it will create a row of rings. The number of rings created is the lower 3 bits plus one. Therefore, you can get one to eight rings in a row or column with one ring entry. Notice that types 0 and 8 are the same, as a row of one ring is the same as a column of one ring.

See the level specific hacking info for the locations of the ring data.

Level layout

Level layouts are compressed in Kosinski format, so to edit them you will need to decompress them first. (I recommend using TSDC for this)

Level layouts are pretty simple. There is one byte per 128x128 tile to place on the map. The blocks are put together from left to right, top to bottom. Each horizontal row is 128 bytes long ($80), and there are 16 rows each for foreground and background (32 total). The rows are interlaced between the foreground and the background, so that there are 128 bytes for the first row of the foreground, then 128 bytes for the first row of the background, then 128 bytes for the second row of the foreground, etc.

See the level specific hacking info for the locations of level layout data.

16x16 block mappings

This data is Kosinski 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.

128x128 block mappings

This data is Kosinski compressed.
128x128 block mappings consist of sixty-four 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

Each 16x16 tile has a two-byte value with the format SSTT YXII IIII IIII. SS is the solidity of the tile in the alternate collision layer - 00 means not solid, 01 means top solid, 10 means left/right/bottom solid, and 11 means all solid. TT is the solidity of the tile in the normal collision layer - 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.

Level specific info

See SCHG:Sonic the Hedgehog 2 (16-bit)/Level Specific


References


Sonic Community Hacking Guide
General
SonED2 Manual | Subroutine Equivalency List
Game-Specific
Sonic the Hedgehog (16-bit) | Sonic the Hedgehog (8-bit) | Sonic CD (prototype 510) | Sonic CD | Sonic CD (PC) | Sonic CD (2011) | Sonic 2 (Simon Wai prototype) | Sonic 2 (16-bit) | Sonic 2 (Master System) | Sonic 3 | Sonic 3 & Knuckles | Chaotix | Sonic Jam | Sonic Jam 6 | 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 | Sonic Riders | Sonic the Hedgehog (2006) | Sonic & Sega All-Stars Racing | Sonic Unleashed (Xbox 360/PS3) | Sonic Colours | Sonic Generations | Sonic Forces
Technical information
Sonic Eraser | Sonic 2 (Nick Arcade prototype) | Sonic CD (prototype; 1992-12-04) | Dr. Robotnik's Mean Bean Machine | Sonic Triple Trouble | Tails Adventures | Sonic Crackers | Sonic 3D: Flickies' Island | Sonic & Knuckles Collection | Sonic R | Sonic Shuffle | Sonic Advance | Sonic Advance 3 | Sonic Battle | Shadow the Hedgehog | Sonic Rush | Sonic Classic Collection | Sonic Free Riders | Sonic Lost World
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 | 68000 Instruction Set | 68000 ASM-to-Hex Code Reference | SMPS Music Hacking Guide | Mega Drive technical information