This historical hacking document is preserved here for archival purposes.
Using a hex editor it is possible to modify Sonic 2 & Knuckles, editing it byte by byte. By knowing where each function is and modifying it correctly, it is possible to customize the game. You can draw another character in Knuckles' place, but it's not very easy, because it needs to be drawn pixel by pixel. You can change the level names in the level select menu and in the level title cards. But to program the game, it needs to be in the binary format. It isn't hard to convert the game to binary form. You can use a conversion program or the Genecyst emulator's DUMP ROM option, which does the conversion.
In spite of Sonic 2 & Knuckles being just Sonic 2 coupled with Sonic & Knuckles, this game can be considered a new version of Sonic 2, because Sonic & Knuckles, after identifying that the cartridge attached is Sonic 2, activates a memory that is at the end of the two games, and this memory contains all the game code, only using the Sonic 2 cartridge for the graphs and maps of the levels. In this guide, you will see that the information that's altered in most of the cases is above the address $300000, where the extra memory is stored, and a few things are in the addresses $200000 to $2FFFFF, where Sonic 2 is stored in memory. Because of this, Sonic 2 & Knuckles can be considered to be a completely new game, using Sonic 2's engine and data, and starring Knuckles.
Observe the table below with the levels and their respective IDs. These IDs are important because the game uses them for referencing the levels.
Note that some numbers are skipped, like 01, 03, 06 and 09. Although these do not have level names and are not in the level select, if you place these IDs, you can access lost levels (try it and see the results). The table below gives the location of the level IDs for each level in the level select menu. The first address in the table is for the zone byte, and the second for the act byte. For example, at the address $307916 you will see the byte 07 (Hill Top Zone) and at the address $307917 you will see the byte 00 (Act 1).
|Emerald Hill||Act 1||$307906-$307907|
|Chemical Plant||Act 1||$30790A-$30790B|
|Aquatic Ruin||Act 1||$30790E-$30790F|
|Casino Night||Act 1||$307912-$307913|
|Hill Top||Act 1||$307916-$307917|
|Mystic Cave||Act 1||$30791A-$30791B|
|Oil Ocean||Act 1||$30791E-$30791F|
You can change the music which plays in each level. The format is very simple: one byte per level, that byte being the ID of the music to play. To change what music plays, play the desired music in the sound test, write down the number of the music and place it in the byte that represents the chosen level. Note that the music ID is actually equal to the music number in the sound test + $80, so remember to add $80 before placing it in the playlist. The table below gives the address of the music ID for each level:
|Level||Music ID||Music number||Address|
You can also alter the objects in the levels such as badniks, monitors, obstacles, etc. The configuration of the objects in the levels uses 6 bytes in the format XX XX YY YY OO VV. XX XX is the horizontal position, YY YY is the vertical position, OO is the object to be placed, and VV is the object subtype. To obtain the exact location where you want to place your objects, enable debug mode and note the first line of coordinates on the HUD in the place of the score counter. These will be the coordinates that you should use for the object. The table below lists the locations of the object placement data for each level. Each level's data ends with FF FF 00 00 00 00, after which the next level's data begins.
|Emerald Hill||Act 1||$DF3FE|
|Hill Top||Act 1||$E1018|
|Oil Ocean||Act 1||$E1A4A|
|Mystic Cave||Act 1||$E23DA|
|Casino Night||Act 1||$33F06E|
|Chemical Plant||Act 1||$E2A88|
|Aquatic Ruin||Act 1||$E34D8|
You can change Knuckles' starting location for each level. To find out what coordinates to use, enable Debug Mode, go to your new starting location, and write down the coordinates (the top line in the HUD in place of the score counter). Refer to the table below to get the address you have to place your new coordinates at:
|Emerald Hill 1||$30A488||0060028F|
|Emerald Hill 2||$30A48C||006002AF|
|Wing Fortress 1||$30A4B8||006004CC|
|Wing Fortress 2||$30A4BC||01E004CC|
|Hill Top 1||$30A4C0||006003EF|
|Hill Top 2||$30A4C4||006006AF|
|Hidden Palace 1||$30A4C8||023001AC|
|Hidden Palace 2||$30A4CC||023001AC|
|Oil Ocean 1||$30A4D8||006006AC|
|Oil Ocean 2||$30A4DC||0060056C|
|Mystic Cave 1||$30A4E0||006006AC|
|Mystic Cave 2||$30A4E4||006005AC|
|Casino Night 1||$30A4E8||006002AC|
|Casino Night 2||$30A4EC||0060058C|
|Chemical Plant 1||$30A4F0||006001EC|
|Chemical Plant 2||$30A4F4||0060012C|
|Death Egg 1||$30A4F8||0060012D|
|Death Egg 2||$30A4FC||0060012D|
|Aquatic Ruin 1||$30A500||0060037E|
|Aquatic Ruin 2||$30A504||0060037E|
|Sky Chase 1||$30A508||01200070|
|Sky Chase 2||$30A50C||01400070|
In this game, the Sega logo, title screen, levels, special stages, etc. are different events and have IDs assigned to them. The table below lists the ID and starting code location of each event. The IDs go in units of 4, and by knowing the exact initialization place of the events you can reprogram them without affecting the operation of the game.
|Level Select Menu||18-1C||$3076C2|
|Level Select Menu||24||$3076C2|
You can alter the codes used in the game. The code for the Level Select Menu is , , , , , , , , , . In the ROM this code is stored in the Motorola key format, and you can simply alter it by placing new key values. The code is stored at the address $3038E2, and consists of the following bytes: 01 01 01 02 02 02 04 08 04 08 00 FF, where 01 is , 02 is , 04 is , 08 is , and 00 FF indicates the end of the code. You can modify this code as you wish, but remember to keep the bytes 00 FF at the end so the game knows the code has ended. Summary:
|Level Select Menu||$3038E2-$3038ED|
These codes are used from the level select menu and are inserted in the sound test by playing the respective music. They are easier to alter because they are stored in ROM in the same way they are typed in Sound Test. The only difference from the level select code is that FF is used to indicate the end of the code rather than 00 FF. The table below lists the locations of the codes:
|All Emeralds (Super Knuckles)||01,06,07,07,07,02,01,06||$307C83-$307C8A|
You will see the codes of Sonic 2 alone in this game. Even though they do not work, the Oil Ocean music bug (after entering the 14 continues cheat) has been fixed, because if you observe the address $307C4C you will see the bytes 10 3C 00 BF and not 10 3C 00 3F, which is what is present in the Sonic 2 ROM and causes the music lock. This bug is not even fixed in Sonic Jam. Many other bugs that happen in Sonic 2 don't happen in this version. For example, the bug where the game freezes if you enter object placement mode after dying and place an object does not occur in this game.
|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 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 Colours | Sonic Generations | Sonic Lost World | Sonic Forces|
|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|