This is the Sonic Community Hacking Guide for Sonic the Hedgehog. The Guide is based on work by David Declerck, Kroc Camen and Penta Penguin. The Music Hacking Guide is based on notes by ValleyBell.
A great deal is not yet understood about the ROM. In order to help with the building of tools (such as level / sprite editors), here is a list of some of the things that need investigating:
If you have anything to contribute regarding these unknowns:
|$00000 – ?||Main Game Code|
|$0024B – $0026A||Labyrinth Act 1-2 Underwater Palette|
|$0026B – $0028A||Labyrinth Act 3 Underwater Palette|
|$00F0E – $00F2D||Map Screen 1 Palette|
|$00F2E – $00F4D||Map Screen 2 Palette|
|$01209 – $0122C||Zone Title Pointers:
|$0122D – $01286||Zone Titles: (Text Format)
|$013E1 – $01400||Title Screen Palette|
|$0197E – $019AD||Final Score Titles: (Text Format)|
The text used for the score bonuses given on the completion of the game
|$01F9D – $01FA8||Lightning Palette Control|
|$01B8D – $01BAC||"Sonic Has Passed" Screen Palette|
|$02905 – $02AD5||Credits Text (Text Format)|
|$02AD6 – $02AF5||Credits Screen Palette|
|$0626C – $0627B||End Sign Sprite Palette|
|$0627C – $0628B||Palette Pointers:
|$0628C – $0629D||Palette Cycle Pointers:
|$0629E – $065ED||Palettes:
|$0731C – $0732B||Boss Sprite Palette (including end capsule)|
|$0C7F0 – $0FFB0||Music, sounds, and other stuff|
|$0FFB1 – $0FFFF||EMPTY SPACE|
|$10000 – $14C9F||Block Mappings:
|$15180 – $1557F||Blinking Items Art (Box, etc...)|
|$15580 – $155C9||Level Header Pointers:
|$155CA – $15AB3||Level Headers:
|$15AB4 – $15FFF||Object Layout:
|$16000 – $16DE9||Misc Mappings: (RLE Compressed)
|$16DEA – $1FFFF||Level Layout: (RLE Compressed)
|$20000 – $25FFF||UNKNOWN|
|$26000 – $32FE5||Tile and Sprite Sets: (Compressed Art)
|$32FE6 – $3DA27||Level Art: (Compressed Art)
|$3DA28 – $3FF20||Contains sprite art and/or sprite mappings|
|$3FF21 – $40000||EMPTY SPACE|
|$00000 – $10000||Main Game Code, musics, sounds...|
|$10000 – $14D00||Block Mappings|
|$14D00 – $15200||Unknown|
|$15200 – $15600||Blinking Items Art (Box, etc...)|
|$15600 – $1564A||Level Headers Pointers|
|$1564A – $15B34||Level Headers|
|$15B34 – $16200||Object Layout:
|$16200 – $16738||UNKNOWN|
|$16738 – $17430||Misc Mappings|
|$17430 – $1F600||Level Layout|
|$1F600 – $20000||Sega Screen Art / Mappings|
|$20000 – $23440||Sonic Art / Mappings|
|$23400 – $23450||Palette Cycle Pointers:
|$23450 – $23C00||Palettes|
|$23C00 – $25500||'Sega' sound|
|$25500 – $30000||Art : Title Screen / Map / Levels / Stats / Sprites|
|$30000 – $40000||Art : Sega Screen / Map / Levels|
|$3DA28 – $40000||Contains sprite art and/or sprite mappings|
Some data (level layouts, misc. mappings) in the ROM is compressed using a form of Run-Length-Encoding, where bytes that repeat themselves many times in a row are reduced by specifying the number of times to repeat a byte.
In practice, the ROM stores this data normally byte-for-byte but indicates a value to repeat by a duplicate byte followed by another byte that specifies the number of successive bytes to repeat.
A bug / oversight made by the developers means that the byte that specifies the number of times to repeat is off-by-one (causing an overflow (255 → 0). This means that a repeating-value of 01 means zero repeats (therefore wasting space!), 02 means 1 repeat, FF means 255 repeats, but 00 actually means 256 repeats! Be keenly aware of this when de/compressing!
As you can see, this format wastes one byte of space if a byte is only repeated twice. If a byte is repeated three times, there is no size difference. Only when a byte is repeated four or more times is there a savings in space usage.
WARNING: Here comes the science bit! If you want to understand how this works then read very carefully. First, some background info: The Master System uses character-based graphics, that is, 8×8 pixel tiles arranged into a 32×24 grid. The screen is not drawn to directly, instead up to 448 tiles can be defined and images are crafted by arranging different tiles on the grid.
The graphics for a level consist of 256 tiles and sprite sets are 128 tiles. Each tile consists of 8 rows (of 8 pixels), each row is 4 bytes (more on that later). The graphic art is compressed in a very complex, but effective, manner. The rows of all the tiles are divided into unique rows and duplicate rows. The data is stored like this:
The 8-byte header is in the format of:
(Note that dual-byte values "DR", "AD" and "RC" are Little-Endian, the lowest byte first. e.g. "08 01" = "0108")
The list of unique rows is one byte for each tile we are defining (256 for tile sets, 128 for sprite sets). To process this data begin with the first byte of the unique rows list. Each bit in this byte refers to a row in the first tile of the tile set that we are decompressing.
Note that bits in a byte are ordered right to left, as such:
Therefore bit #1 (on the right), refers to the first row of the current tile we are decoding and bit #8 (on the left) refers to the 8th row of the tile.
When a bit value is 0, it means that the tile row it corresponds to is a unique row. Read in 4 bytes from the Art Data section and decode into the 8 pixels for that row (see the Art Data heading below). In the example above, rows 3, 4 & 6 and of the tile are unique, and 4 bytes would be read from the Art Data for each.
Walk through the whole unique rows list decoding in this way and you should have a partial tile set with all the unique rows filled in.
The list of duplicate rows "fills in the blanks" in the rows missed by the unique list. For each row in the tile set that was missed by the unique rows list the duplicate rows list will contain an index value to where in the Art Data the row is.
Begin by walking the unique rows list again in the same order as before, but this time when a bit value is 1 it means that row is a duplicate: read a byte from the duplicate rows list. This value is an index to where in the art data the row is located, i.e. a value of 80 (hex) means:
$30000 Base address (Master System) + 2FE6 "Level Art" pointer in the level header, Green Hill for example + 7C2 Art Data pointer in the level art header, again Green Hill + 80*4 Skip to the 128th, decimal, row in the art data
For values 00 to EF (0 to 239), there is only one byte, indicating the row index in the Art Data. However, for values after EF, there are two bytes. The first one starts with an F, so the actual line number is the two bytes number minus F0 00. E.g.: F3 A2 is for art data row number 3A2. Note that you can also write line numbers 00 to EF using two bytes numbers, but this is a waste of space (that's why they are stored with one byte!).
Once you've walked the unique rows list a second time, reading the duplicate row list for each bit-value of 1 you see, all the blank rows in the title set should be filled in and you should have a complete tile set — if you've understood everything correctly!
The SMS uses a palette of 16 colours for tiles, therefore the data that defines the tile graphics do not specify the actual R/G/B values, but just an index (0-15) to the palette colour to use. Therefore an 8-pixel row is stored as 4 bytes, where 4 bits (values 0-15) are assigned to each pixel.
However, instead of being stored as nybbles (4-bits in a row), the data is stored across 4 bit-planes. To understand what bit-planes are, imagine 4 bytes stacked on top of each other like layers in a cake. A bit plane would be a slice of the cake — 1 bit from each of the 4 bytes.
To decode the 4 bytes into 8 colour pixels, slice the bit-planes to get the index values (0-15) for each pixel and then look up the final colour from the palette.
In pseudo code, something like this:
input byte1, byte2, byte3, byte4 pixel = array (0 to 7) for bit = 0 to 7 if byte1 AND 2 ^ (7-bit) then pixel[bit] = pixel[bit] OR 1 if byte2 AND 2 ^ (7-bit) then pixel[bit] = pixel[bit] OR 2 if byte3 AND 2 ^ (7-bit) then pixel[bit] = pixel[bit] OR 4 if byte4 AND 2 ^ (7-bit) then pixel[bit] = pixel[bit] OR 8 pixel[bit] = palette-color-from-index: pixel[bit] next bit
Each level has a header. This header contains several pieces of data, such as starting position, music location, etc. Each level header is 37 bytes long and is referenced by a pointer.
There are 37 Level Headers in total. Some levels have more than one pointer because they can be accessed from different locations, and Sonic's starting position differs at level start. Also two invalid level pointers exist that act as dividers between the main sequence of levels and the out-of-sequence levels (Scrap Brain's sub-maps and the Special Stages). See the ROM map for the full list of level pointers.
Example:The two first bytes are 4A 00. So, at
Each level header use 37 bytes. Here is the format (partial):
This is a table of the complete level headers for the Master System version: (all values are hexadecimal)
|Green Hill Act 1||0||0100||0010||0040||C0||18||0020||40||01||08||0B||2DEA||083E||0000||2FE6||9||612A||0||A||3||0||0534||04||0||20||0||0|
|Green Hill Act 2||0080||0020||0001||A0||0C||0001||40||03||02||03||3628||0661||0580||04||20|
|Green Hill Act 3||0080||0020||0001||00||0A||00E8||40||03||07||16||3C89||032D||05C3||00||00|
|Bridge Act 1||1||0100||0010||0001||00||1F||0001||40||01||03||0C||7ED1||0694||0B80||4578||9||6C3D||1||8||3||1||05D6||04||0||20||0||1|
|Bridge Act 2||0080||0020||0F||0001||40||03||02||1C||A2A8||0499||061C||0C||20|
|Bridge Act 3||0080||0020||0F||0300||40||03||06||1B||B301||0140||0656||00||00|
|Jungle Act 1||2||0100||0010||0001||00||1F||0001||20||01||02||0B||3FB6||0AAC||1480||5B00||9||77CD||2||5||3||2||066C||04||0||20||0||2|
|Jungle Act 2||0010||0100||01||0001||20||1F||02||FA||4A62||08DB||06C4||84||20|
|Jungle Act 3||0080||0020||0F||0300||40||03||06||1B||B301||0140||0656||00||00|
|Labyrinth Act 1||3||0040||0040||0001||00||07||0001||40||07||02||05||8565||08C2||1E80||71BF||9||83B6||3||5||3||3||0723||04||80||20||0||3|
|Labyrinth Act 2||0040||0040||03||09||8E27||0D13||0772||04||20|
|Labyrinth Act 3||0040||0040||03||25||AFF6||030B||07CA||00||10|
|Scrap Brain Act 1||4||0100||0010||0001||00||1E||0001||20||01||03||0B||533D||069A||2980||884B||9||8F75||4||6||4||4||07E9||04||0||20||0||4|
|Scrap Brain Act 2||0080||0020||0F||0001||40||03||04||16||59D7||0904||082C||20|
|Scrap Brain Act 3||0040||0040||07||0220||40||07||03||36||7282||08B2||08CE||00|
|Sky Base Act 1||5||0080||0020||0001||00||0F||0001||40||03||02||1D||9B3A||076E||3580||9CEE||9||99E0||5||6||4||5||091A||04||0||22||0||4|
|Sky Base Act 2||5||0040||0040||07||40||06||0A||17||7B34||039D||3580||9CEE||5||6||8||0954||40||20||5|
|Sky Base Act 3||7||0040||0040||07||20||01||02||01||A741||04C0||4300||B3B5||6||8||6||0997||00||00||4|
|Scrap Brain Act 2
(Emerald Maze), From Corridor
|Scrap Brain Act 2
|Scrap Brain Act 2,
|Scrap Brain Act 2
(Emerald Maze), From Transporter
|Scrap Brain Act 2,
From Emerald Maze
|Scrap Brain Act 2,
From Ballhog Area
|Sky Base Act 2 (Interior)||7||0040||0040||0001||00||07||0001||40||07||03||3B||A741||04C0||4300||B3B5||9||99E0||6||8||4||6||09A1||00||0||00||0||4|
|Special Stage 1||6||0040||0040||0001||00||07||0001||40||02||02||06||B441||0760||4890||C7FE||9||A511||7||1||1||7||09A5||4||0||21||0||10|
|Special Stage 2||0040||0040||07||0320||C0||05||02||1E||B441||0760||09AC|
|Special Stage 3||0040||0040||07||0680||40||07||03||3B||B441||0760||09B6|
|Special Stage 4||0010||0100||01||0001||20||1F||06||40||4A62||08DB||09C0|
|Special Stage 5||0040||0040||07||0001||40||02||02||06||B441||0760||09D3|
|Special Stage 6||0040||0040||07||0320||C0||05||02||1E||B441||0760||09E6|
|Special Stage 7||0040||0040||07||0680||40||07||03||3B||B441||0760||09FF|
|Special Stage 8||0010||0100||01||0001||20||1F||06||04||4A62||08DB||0A15|
A palette of 32 colors is used, the first 16 reserved for the level and the second 16 for the sprites.
The Master System uses 6-bit colors, each colour in a palette is one byte (32 bytes for a full palette, 16 bytes for a half-palette). 2 bits are assigned to each color (R:0–2, G:0–2, B:0–2), for a total of 64 possible colors. The extra two bits in the byte are unused, therefore the format of the byte is: 00BBGGRR. The corresponding 24-bit color byte value for the 2-bit numbers are: 0 = 0, 1 = 80, 2 = 175, 3 = 255.
The Game Gear uses 9-bit colors, so each color use two bytes (the first nybble of the second byte is 0, and values for the color nybble are in steps of 2). This color can be defined like that : R(0–7), G(0–7), B(0–7). So, there are only 8 possible values for each primary color. Here are the RGB correspondence : 0/1 = 0, 2/3 = 36, 4/5 = 72, 6/7 = 109, 8/9 = 145, A/B = 182, C/D = 218, E/F = 255. So, you can have a maximum of 512 colors. The format for the two bytes is : GGGGRRRR 0000BBBB
The Initial Palette ("IP") value of a Level Header is an index to the level palette pointers, i.e. 0–7, specifying which palette to load.
To create a simple animation effect, such as flowing water, the palettes are "cycled" through a list of other palettes allowing the colours to rapidly change without having to change actual pixel data.A table of cycle palette pointers exists at Level Header by the Cycle Count ("CC") value. The Cycle Palette ("CP") value in the Level Header is an index to the Cycle Palette Pointers table, determining which palette cycle to use.
Note that the Level Palettes and Cycle Palettes are intermixed, which is why the pointer tables are necessary. See the ROM Map for a detailed listing of the palette locations.
Labyrinth uses an under water effect created by a raster line trick, that is, the palette is changed as the TV's electron beam is half-way down the screen. Since a level can only specify one palette, the "under water" palette is stored elsewhere in the ROM.For Labyrinth Acts 1 & 2 a full 32 color palette is located at Level Header specifies the normal Labyrinth palette, this is overridden by the palette stored at on-demand.
Sky Base 1 has a unique feature in that, as well as the regular palette, a "lightning" flashing effect occurs every few seconds. This is managed entirely separately from the regular palette cycle (i.e. the lightning is not a very long palette cycle list).Locations
This can be broken down into three stages:
"02" controls the frequency of the palette swaps (flashing). Increasing this number will slow the flashing down."04" specifies the number of cycle palettes in the palette to be swapped. The next two bytes are a little-endian address to the palette to use.
The end sign and boss objects have their own palettes separate from the sprite palette used on a level. When these objects are near their palettes are automatically loaded into the level's sprite palette (the last 16 colors in the 32-color system palette).The end sign palette is located at Capsule, is located at
The floor layout for each level is comprised of "blocks": prearranged 4×4 tile (32×32 px) patterns. This reduces the amount of memory required for storing levels ("Floor Layouts") as levels are constructed out of these larger blocks rather than storing every tile seen.
Each block is composed of 16 smaller 8×8 px tiles. The block is 16 bytes, each byte is an index to which tile to display in the Level Art. The bytes are arranged on screen in this order:
And the corresponding data is:
Block Mappings are stored uncompressed in the ROM. The number of blocks in each mapping is apparently not stored in the ROM, so to determine the number of blocks in each mapping you need to compare the distance between "Mapping Location" Level Headers. For your convenience the size of the mappings are charted below.
|$10000 – $10B80||Green Hill (184 blocks)||$10000 – $10BB0||Green Hill (187 blocks)|
|$10B80 – $11480||Bridge (144 blocks)||$10BB0 – $11510||Bridge (150 blocks)|
|$11480 – $11E80||Jungle (160 blocks)||$11510 – $11FE0||Jungle (128 blocks)|
|$11E80 – $12980||Labyrinth (176 blocks)||$11FE0 – $12A10||Labyrinth (208 blocks)|
|$12980 – $13580||Scrap Brain (192 blocks)||$12A10 – $135B0||Scrap Brain (186 blocks)|
|$13580 – $14300||Sky Base 1-2 (216 blocks)||$135B0 – $14330||Sky Base 1-2 (216 blocks)|
|$14300 – $14980||Sky Base 3 (104 blocks)||$14330 – $149B0||Sky Base 3 (104 blocks)|
|$14980 – $1517F||Bonus Stage (128 blocks)||$149B0 – $14D00?||Bonus Stage (53 blocks?)|
The floor layout is composed of multiple 4×4 tile blocks (See Block Mappings). Each byte indicates the index of the tile to which to use. However, the data is compressed, so you will have to decompress it first.Floor layouts are located at: Level Headers), in order to determine their starting address.
Objects are special parts of a level. They can move, attack, give you rings, and do a lot of other things, even if they are not visible. Objects are distinct from "sprites" in that some objects are invisible (have no sprite associated) and have some meta effect (such as setting the water-level in Labyrinth), or load their sprite art on-demand.
Object Layout Data begins with one byte, which is the total number of objects in the zone plus one. Immediately following is the object data itself. Each object uses 3 bytes, in the format:
XX and YY are the object's coordinates divided by 32. OO is one of the objects listed below. (Both the Game Gear and Master System versions share the same Object Layout Data). There are a total of 452 objects throughout the game's levels (though some of these are invalid — 00 / FF).
|01||Super Ring monitor|
|02||Power Sneakers monitor|
|08||Badnik "Crabmeat" (GH)|
|09||Wooden platform - Swinging (GH)|
|0B||Wooden platform (GH)|
|0C||Wooden platform - Falls when touched (GH)|
|0E||Badnik "Buzz Bomber" (GH/B)|
|0F||Wooden platform - Sliding left-right (GH)|
|10||Badnik "Moto Bug" (GH)|
|11||Badnik "Newtron" (GH)|
|12||Robotnik - Green Hill Boss (GH)|
|16||Flame Thrower (SB)|
|17||Door - Opens from left only (SB)|
|18||Door - Opens from right only (SB)|
|19||Door - Two ways (SB)|
|1A||Electric sphere (SB)|
|1B||Badnik "Ball Hog" (SB)|
|1C||Unknown - Ball from the "Ball Hog" ?|
|1D||Switch (SB, L, others ?)|
|1E||Switch Activated Door (SB)|
|1F||Badnik "Caterkiller" (SB)|
|21||Bumper - Sliding left-right (Bonus Stage ?)|
|22||Robotnik - Scrap Brain Boss (SB)|
|23||Free animal - Rabbit|
|24||Free animal - Bird|
|26||Badnik "Chopper" (J, B)|
|27||Vertical Step - Falling from a waterfall (J)|
|28||Horizontal Step - Falling from a waterfall (J)|
|29||Floating Step - Sonic can travel with it (J)|
|2C||Robotnik - Jungle Boss (J)|
|2D||Badnik "Yadrin" (B)|
|2E||Falling Bridge (B)|
|30||Passing Clouds (SKYB)|
|32||Badnik "Bomb" (SKYB)|
|33||Large Cannons in Sky Base Act 2 (SKYB)|
|33||Cannon Ball (SKYB)|
|35||Badnik "Unidus" (SKYB)|
|37||Rotating cannon (SKYB)|
|38||Flying platform (SKYB)|
|39||Spiked wall slowly moving right (SKYB)|
|3A||Small cannon in Sky Base Act 1 (SKYB)|
|3B||Flying platform moving up-down (SKYB)|
|3C||Badnik "Jaws" (L)|
|3D||Rotating spiked ball (L)|
|3E||Spear, shifting up-down (L)|
|3F||Fire ball thrower (L)|
|40||Water Level Object (L)|
|41||Bubble Maker (L)|
|44||Badnik "Burrobot" (L)|
|45||Platform, move up when touched (L)|
|46||Electrical Hazard for the Sky Base Boss (SKYB)|
|48||Robotnik - Bridge Boss (SB)|
|49||Robotnik - Labyrinth Boss (L)|
|4A||Robotnik - Sky Base Boss (SKYB)|
|4B||Zone that makes you fall (like in GH2)|
|4C||Flipper (Bonus Stage)|
|51||Box - Starpost|
|52||Box - Continue|
|53||Final animation in GH, when Sonic falls on Robotnik (then, goes to the next level)|
|54||Emeralds animation (on the map), when Sonic has them all (and goes to the next level)|
|55||Makes Sonic blink for a short time|
This section contains the mappings for some screens. It looks like the Blocks Mappings, except that the 8×8 tiles are written to the screen, so there is more than 16 tiles. Another thing is that they are compressed (see The compression format).
|$16738 – $16865||Title Screen|
|$16962 – $163F6||Map 1 Background|
|$163F6 – $16AFD||Map 1 Foreground|
In the game, there are some blinking items. The most common are the box items. You can easily edit them. Each of these items is 16×16, but you must understand that it is composed of four 8×8 tiles. The tiles are displayed from up to down and from left to right. The format is the same as the art in savestates (32 bytes for each 8×8 tile, 128 bytes for the item).Blinking items are located at:
Here are the items you can edit :
The graphics for a level consist of 256 tiles. Each tile consists of 8 rows (of 8 pixels). See the Art Compression section for how to fully read and decompress the tile graphics.
Strings of text in the game are stored in a simple format that begins with an X / Y location on the screen to begin printing, are terminated with FF and may contain special control-codes, such as FE to move the cursor.
Note that the character codes used for the letters are dependent on the tile map currently being used! There are two tile maps used, one for each of the map screens in the game.
The first map screen shows the overview of the island and is used for the first three zones (Green Hill, Bridge & Jungle). These are the character codes used on this screen:
The second map screen shows the close-up of the mountain top with Robotnik's fortress, and uses the following character codes:
The first three zones use the character codes from the first map screen, therefore the data looks like this:
|$0122D||10 13 46 62 44 44 51 EB 47 40 43 43 EB EB FF||GREEN HILL|
|$0123C||10 13 35 62 40 37 46 44 EB EB EB EB EB EB FF||BRIDGE|
|$0124B||10 13 41 81 51 46 43 44 EB EB EB EB EB EB FF||JUNGLE|
The next three zones use the second map screen, therefore the letters appear differently:
|$0125A||10 13 6F 1E 1F DE 9F 5E 7F AF 4F EB EB EB FF||LABYRINTH|
|$01269||10 13 AE 2E 9F 1E 8F EB 1F 9F 1E 5E 7F EB FF||SCRAP BRAIN|
|$01278||10 13 AE 6E DE EB 1F 1E AE 3E EB EB EB EB FF||SKY BASE|
Each string is padded with spaces to be 13 characters in length. The first tile set is used.
|$0197E||08 0A 36 47 34 61 70 EB 44 50 44 62 34 43 37 FF||CHAOS EMERALD|
|$0198E||08 0A 70 52 51 40 36 EB 43 44 45 80 EB EB EB FF||SONIC LEFT|
|$0199E||08 0A 70 60 44 36 40 34 43 EB 35 52 51 81 70 FF||SPECIAL BONUS|
Additional control codes appear in the credits:
Note that the credits use the second tile map.
Here is a full decode of the credits roll:
$02905 14 03 AE 9E 7F 5E 2E SONIC FE 15 04 AF 4F 3E THE FE 13 05 4F 3E 2F 4E 3E 4F 9E 4E HEDGEHOG FD 3C 00 FE 12 0C 7E 1E AE AF 3E 9F MASTER FE 13 0D AE DE AE AF 3E 7E SYSTEM FE 14 0E BF 3E 9F AE 5E 9E 7F VERSION FD 3C 00 FC 09 FE 14 0B AE 9E 7F 5E 2E SONIC FE 15 0C AF 4F 3E THE FE 13 0D 4F 3E 2F 4E 3E 4F 9E 4E HEDGEHOG FD 3C 00 FE 12 0F 8E 9F 5E 4E 5E 7F 1E 6F ORIGINAL FE 13 10 2E 4F 1E 9F 1E 2E AF 3E 9F CHARACTER FE 14 11 2F 3E AE 5E 4E 7F DESIGN FD 3C 00 FC 04 FE 14 10 AB AE 3E 4E 1E ©SEGA FD B4 00 FC 09 FE 14 0E AE AF 1E 3F 3F STAFF FD B4 00 FC 09 FE 12 0B 4E 1E 7E 3E GAME FE 13 0C 8F 9F 9E 4E 9F 1E 7E PROGRAM FD 3C 00 FE 13 0E AE 4F 5E 7F 9E 1F BE SHINOBU FE 14 0F 4F 1E DE 1E AE 4F 5E HYASHI FD F0 00 FC 09 FE 12 0B 4E 9F 1E 8F 4F 5E 2E GRAPHIC FE 14 0C 2F 3E AE 5E 4E 7F DESIGN FD 3C 00 FE 13 0E 1E DE 1E 7F 9E AYANO FE 14 0F 6E 9E AE 4F 5E 9F 9E KOSHIRO FD 3C 00 FE 13 11 AF 1E CF 3E 3F BE 7F 5E TAKEFUNI FE 14 12 DE BE 7F 9E BE 3E YUNOUE FD F0 00 FC 09 FE 12 0B AE 9E BE 7F 2F SOUND FE 13 0C 8F 9F 9E 2F BE 2E 3E PRODUCE FD 3C 00 FE 13 0E 7E 1E AE 1E AF 9E MASATO FE 14 0F 7F 1E CF 1E 7E BE 9F 1E NAKAMURA FD F0 00 FC 09 FE 12 0B 9F 3E 1E 9F 9F 1E 7F 4E 3E REARRANGE FE 15 0C 1E 7F 2F AND FE 12 0D 9E 9F 5E 4E 5E 7F 1E 6F ORIGINAL FE 16 0E 7E BE AE 5E 2E MUSIC FD 3C 00 FE 13 10 DE BE DF 9E YUZO FE 14 11 6E 9E AE 4F 5E 9F 9E KOSHIRO FD F0 00 FC 09 FE 13 0D AE 8F 3E 2E 5E 1E 6F SPECIAL FE 15 0E AF 4F 1E 7F 6E AE THANKS FD B4 00 FC 02 FE 13 0E DE 8E AE 4F 5E 8E EB DE YOSHIO Y FD 3C 00 FE 13 11 6F BE 7F 1E 9F 5E 1E 7F LUNARIAN FE 1A 12 AE 4E SG FD B4 00 FC 09 FE 12 0C 8F 9F 3E AE 3E 7F AF 3E 2F PRESENTED FE 16 0E 1F DE BY FE 15 10 AE 3E 4E 1E SEGA FD B4 00 FE 19 13 3E 7F 2F END $02AD5 FF
To convert offset values to Gens Plus 0.0.9.61 savestate values, add $00A4.
|$0000||Tile Layout Data|
|$1400||Object Status Table (?)|
|$1403||Sonic's X speed|
|$1406||Sonic's Y speed|
|$206C||Tile Graphics Data|
Unlike in the ROM, the data here is uncompressed. Each byte directly corresponds to one 32×32 tile.
The number of tiles in a horizontal line before they wrap around differs depending on the width of the Zone. Here is table of the values.
|Zone||Tile Line Data Size in Bytes|
|Green Hill Act 1||256|
|Green Hill Act 2||128|
|Green Hill Act 3||128|
|Bridge Act 1||256|
|Bridge Act 2||128|
|Bridge Act 3||128|
|Jungle Act 1||256|
|Jungle Act 2||16|
|Jungle Act 3||64|
|Labyrinth Act 1||64|
|Labyrinth Act 2||64|
|Labyrinth Act 3||64|
|Scrap Brain Act 1||256|
|Scrap Brain Act 2||128|
|Scrap Brain Act 2 (Emerald Maze)||64|
|Scrap Brain Act 2 (Ballhog Area)||32|
|Scrap Brain Act 3||64|
|Sky Base Act 1||128|
|Sky Base Act 2||64|
|Sky Base Act 2 (Interior)||64|
|Sky Base Act 3||64|
|Song ID||Location (SMS)||Location (GG)||Song|
|00||C7D0||C7D0||Green Hill Zone|
|04||DB4F||DB4F||Scrap Brain Zone|
|05||E1A7||E1A7||Sky Base Zone|
|07||E63C||E63C||Map Screen (Act Intro)|
|0F||C7D0||C7D0||Green Hill Zone|
|11||C7D0||C7D0||Green Hill Zone|
|12||C7D0||C7D0||Green Hill Zone|
|13||F98C||F98C||Good Ending SFX|
|--||CD0A||CD0A||Marble Zone (Unused and unreferenced)|
The only difference in the music section of the SMS and GG version is, that the GG version of song 13 has an additional 83 (vibrato) command.
All pointers in a song are absolute (i.e. relative to the beginning of the song) 16-bit pointers stored in Little Endian (Intel) format.
|00||Word||Pointer to Channel 1 Data (usually points to 000A)|
|02||Word||Pointer to Channel 2 Data|
|04||Word||Pointer to Channel 3 Data|
|06||Word||Pointer to Channel 4/Noise Data|
|08||Word||Pointer to Channel 5/SFX data (always zero and ignored)|
There's no header for channel data. Channel setup is done via commands.
The commands start directly at the offset specified in the header.
|00–7F xx||Play Note with length xx
|80 aaaa bbbb||Set song tempo (only present in channel 1)
|81 aa||Set volume (0F = max, 00 = min)|
|82 aa bb cc dd ee ff||Envelope Setup (only present in channels 1-3)
|83 aa bb cc dddd||Modulation (only present in channels 1-3)
|84 aaaa||Set Detune value to aaaa (aaaa is a signed byte that modifies the FNum)
|85 aa||does nothing (only present in channel 1)
|86||Loop Start Marker
|87 aa bbbb||Loop back
|88||Master Loop Start
|89 aa||Set Noise Mode to aa
|8A aa||Set default note length to aa|
|8B||Increase volume by 1|
|8C||Decrease volume by 1|
|8D||no attack for next note|
|FE||SFX Track End
The 86 command is used the make nested loops possible.
Example: 86 86 ... 87 04 aaaa ... 87 02 bbbb
There's no need for an 88 command in non-looping songs.
However every jingle (with exception of the Death-Jingle) has a master loop, consisting of a rest.
|Sonic the Hedgehog (8-bit)|
|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|