Actions

SCHG

SCHG:Sonic the Hedgehog 3 & Knuckles/Level Editing

From Sonic Retro

(Redirected from SCHG:Sonic 3 & Knuckles/Level Editing)
SCHG: Sonic the Hedgehog 3 & Knuckles
Main Article
Art Editing
Editing Art
Uncompressed Art
Nemesis Format Art
Kosinski Format Art
Palette Editing
Palette Locations
Pattern Load Requests
Object Editing
Editing Objects
Object Pointers
Object Pointer List #1
Object Pointer List #2
Objects not in either list
Sprite Mappings
Dynamic PLCs
Level Editing
Editing Levels
Object Placement
Ring Placement
Level Layout
16x16 Block Mappings
128x128 Block Mappings
Music Editing
Editing Music
Pointer Format
Header Format
DAC Samples
Universal Voice Bank
Music Pointers (Sonic & Knuckles)
Music Pointers (Sonic 3)
RAM Editing
Editing RAM
Main System Memory Locations
Object Status Table Format
Sonic & Knuckles Collection
Sonic & Knuckles Collection
Music and sound effects

Level ID list

Zone/Act (Hex) Name/Description
00 00 Angel Island Zone, Act 1
00 01 Angel Island Zone, Act 2
01 00 Hydrocity Zone, Act 1
01 01 Hydrocity Zone, Act 2
02 00 Marble Garden Zone, Act 1
02 01 Marble Garden Zone, Act 2
03 00 Carnival Night Zone, Act 1
03 01 Carnival Night Zone, Act 2
04 00 Flying Battery Zone, Act 1
04 01 Flying Battery Zone, Act 2
05 00 Ice Cap Zone, Act 1
05 01 Ice Cap Zone, Act 2
06 00 Launch Base Zone, Act 1
06 01 Launch Base Zone, Act 2
07 00 Mushroom Hill Zone, Act 1
07 01 Mushroom Hill Zone, Act 2
08 00 Sandopolis Zone, Act 1
08 01 Sandopolis Zone, Act 2
09 00 Lava Reef Zone, Act 1
09 01 Lava Reef Zone, Act 2
0A 00 Sky Sanctuary Zone, Act 1
0A 01 Sky Sanctuary Zone, Act 2
0B 00 Death Egg Zone, Act 1
0B 01 Death Egg Zone, Act 2
0C The Doomsday Zone
0D Ending
0E Azure Lake Zone
0F Balloon Park Zone
10 Desert Palace Zone
11 Chrome Gadget Zone
12 Endless Mine Zone
13 Gumball machine bonus stage
14 Magnet ball bonus stage
15 Slot machine bonus stage
16 00 Lava Reef Zone, boss of Act 2
16 01 Hidden Palace Zone
17 00 Death Egg Zone, last two bosses of Act 2
17 01 Hidden Palace Zone, when entered from a giant ring

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 loaded whenever it is in X range regardless of its Y position, 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 the byte $2C of the status table of that object.

Ring placement

There are four bytes for every ring object. The first 2 bytes are X coordinates, and the next two are the Y coordinates. Sonic 3k uses individual rings, unlike Sonic 2, which uses ring groups that have to be expanded into RAM. The advantage of Sonic 3k's method is that ring position data can be read directly from ROM, meaning that only two bytes are used up in RAM per ring instead of six, saving on RAM space and allowing Sonic 3k levels to have a maximum of 511 rings, as compared to Sonic 2's 255, despite allocating $200 bytes less to the ring status table.

The ring placement data must start with 0000 0000, and must end with FFFF. These prevent the rings position checker subroutine from going over the bounds of the ring placement data, and are necessary for the correct functioning of the rings manager.

Level layout

Level layouts are stored uncompressed in the ROM, and the format they use differs significantly from the format used in Sonic 2, allowing much larger levels.

The layout starts with an 8 byte header describing the layout's size. The first word is the foreground width in chunks, the second word is the background width in chunks, the third word is the foreground height in chunks, and the fourth word is the background height in chunks.

Next is a list of 64 word-sized pointers in RAM. Each row of 128x128 tiles has two pointers - one for the foreground data and one for the background data. The maximum level height is thus (64 / 2 * 128) = $1000 pixels, double the maximum level height for Sonic 2. To convert these to ROM addresses, subtract $8000 and add the ROM address for the level layout data.

The actual rows data (beginning at byte $88) is very simple - there is one byte per 128x128 tile, and the blocks are put together from left to right.

16x16 block mappings

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

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.


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