Actions

SCHG

Sonic the Hedgehog 2 (16-bit)

From Sonic Retro

(Redirected from SCHG:Sonic 2)


Sonic Community Hacking Guide
Sonic the Hedgehog 2 (16-bit)
Art
Objects
Levels
Text
Music
RAM
Miscellaneous

This is the Sonic Community Hacking Guide for Sonic the Hedgehog 2. Originally based on Nemesis and saxman's guides, this document has grown to outclass those two documents in most ways, and is now preferred over the original guides (which were written three or four years ago with limited knowledge of the game's code). This is due to the updating of those documents to give them a living, breathing nature.

Miscellaneous

Pieces of the guide not big enough for their own page should be left here.

Game Configuration

Offset Description
$3CD2 Enable level select
$3C79 Starting lives for player 1
$41CC How to determine how many rings to start with
$41D0 How to determine how much time starts on the timer
$142F8 Order that the levels come in
$1600C Object code pointers


Each of the object code pointers are in 32-bits. They locate where the code for the object starts in the ROM. It starts with object 01 (Sonic) and goes in order from there. You will find a total of 220 pointers. These are useful if you want to create your own object code, or if you want to make one object into another. Check out the object list to see what each object is.

Offset Description
$16398 Amount of gravity player has (16-bit)
$19FA2 Max speed (16-bit)
$19FA8 Acceleration (16-bit)
$19FAE Slow down speed (16-bit)
$1A0E8 Invincibility time (16-bit)
$1A122 Max speed after super sneakers wear off (16-bit)
$1A122 Acceleration after super sneakers wear off (16-bit)
$1A12E Slow down speed after super sneakers wear off (16-bit)
$1A1B8 Max speed under water (16-bit)
$1A1BE Acceleration under water (16-bit)
$1A1C4 Slow down speed under water (16-bit)
$1A5BD Use this animation when looking down
$1A5D5 How far to look down (player Y - input value) (16-bit)
$1AA5C Jump height (16-bit)
$1AC47 Do Spin Dash if this frame is shown
$1B1BE Flash time after hit (16-bit)
$1B8A4 Stop Tails from going to the left when end level sign is active (16-bit)
$1F1FC Rings needed for special stage (16-bit)
$4082F Specify the minute that causes "TIME" to flash red
$40DED Max minutes of timer
$40DF9 Max middle seconds of timer
$42594 Art/mapping pointers for levels


Each full level has 3 pointers. However, the pointers are 24-bits in size. The extra 8-bits in each pointer has a unique function. These are known as 'flags'. The pointers will define mapping sets, as well as art for a specific level. In total, 12 bytes are used per level. Here is what each flag/pointer does.

Flag 1 - Primary level PLC number
Pointer 1 - Level 8x8 art
Flag 2 - Secondary level PLC number
Pointer 2 - 16x16 mappings
Flag 3 - Palette number
Pointer 3 - 128x128 mappings.

Cheats editing

In this section, you can change any of the cheat codes to whatever you want them to be.

Offset Description
$3DEE Tails / Miles switch
$97B2 Level select / slow motion (example)
$97B7 14 continues (example)
$97BC Debug mode (example)
$97C5 Super Sonic (example)


These codes (except for the first one listed) use the regular sound 00-7F format, not the 80-FF format that the regular sound pointers use. Also, you can make these codes as long as you want. Simply use '00' to tell the game that the code ends there. If you make the very first sound to play in the code sequence a '00', it will then require you to play that sound along with the rest of the code.

The first code (Tails / Miles switch) is based on the output of Sega's standard 3-button controller input routine:

7 6 5 4 3 2 1 0 (this is a byte represented in bits)
S A C B R L D U (these are the bits translated to show what each key is)

If you want to relocate some of these cheat codes to another area of the ROM, just change these address pointers.

Offset Description
$3DB6 Tails / Miles switch cheat pointer
$9164 Level select / slow motion cheat pointer
$916A 14 continues cheat pointer
$9574 Debug mode cheat pointer
$957A Super Sonic cheat pointer

Debug Mode

This will allow you to change the objects available in each of level when using debug mode. Each object uses 8 bytes to reference it in debug mode. Here are the notes you need to modify these references.

FORMAT:
#1 #2 #3 #4 #5 #6 #7 #8

1 - Object value
2 - ??? (usually 01)
3 + 4 - Size of selection
5 - Object type
7 +8 - Sprites for selection

You can use #3, #4, #7, and #8 for porting a selection sprite. Now, you need to know how the game understands how many sprites to read for a level. Each set of objects has a 2 byte header. Together, both bytes define how many objects should be available in debug mode. The first byte should probably stay 00 unless you want more than 255 objects! Now, you just need to know where the section is that tells what sprite set is used for what level.

041D0C - 16-bit address pointers for each level

Here are some of the objects that are listed and their locations

Default
041D30 - Ring
041D38 - Warp Monitor

Emerald Hill
041D42 - Ring
041D4A - Warp Monitor
041D52 - Starpost

Demo Recording

To show off a game, developers record demos. Many other people like to record their own demos too when it's possible. This is one of the fun things you can do in the Sonic 2 ROM.

Offset Description
$3D4E Number of demos to play
$3DAC Levels that are played during demo sequence
$42AA Number of frames that a demo plays (16-bit)
$4948 32-bit address pointers for each level
$4CA8 Demo for EHZ (Sonic)
$4D08 Demo for EHZ (Tails)
$4D68 Demo for CNZ
$4DD8 Demo for CPZ
$4E38 Demo for ARZ


FORMAT: #1 #2

1 - Keys pressed
2 - Frame count

For keys pressed, you simply need to know the Motorola key format:

7 6 5 4 3 2 1 0 (this is a byte represented in bits)
S A C B R L D U (these are the bits translated to show what each key is)

With a 1, that means the button is being used (on) and with a 0, the button isn't being used.


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