Actions

SCHG

Music Hacking

From Sonic Retro

Revision as of 19:46, 29 January 2007 by Ss is testing (talk | contribs) (Porting between Sonic 3K/3D/Crackers/Chaotix)

Music

Guide originally created by Tweaker on May 25 2005.
Thanks to:

  • Saxman - For cracking the format, hooking me up with loads of info, and making the Sonic 2 hacking guide. The Original Master™.
  • fuzzbuzz - For Sonic 1 stuff and helping me understand a lot of shit I didn't before. Plus, he's ripping apart the Sonic 1 sound driver so Sega can't hide shit from us anymore. It's easier though, because it's in 68K (OSHIT BURN =P). The Sonic 1 Master™.
  • Erik JS - Disassembled the S&K sound driver. Nuff said. =P Also gave me a bunch of savestate locations for realtime music editing (which allowed me to find the locations in the ROM. w00t!), and the list of S&K music locations. He's one of those legendary hackers that just drop by once in a while and make your jaw drop because he just shows up with some revolutionary work out of nowhere. By the time you come to, you realize... You just got served. Word up.
  • Djbrayster - He made the pretty list of Ristar music locations, and is a cool guy in general. Nice work.
  • Me - I'm just that feckin' awesome, eh? =P I mean seriously, you can't live without this guide. It's the best shit out there. You can't deny it. That is, considering you are interesting in editing music. And I know you are, or you would've never taken a look at this guide. I mean shit, I wrote the damn thing. I am... The New Master™.
  • Sega - For making Sonic and letting me exploit their music system. ;)

You must have at least basic hex knowledge. If you have no idea what hex is, then I suggest you steer clear of this guide and figure things out first. It's also reccommended that you read and save a copy of the YM2612 technical documentation and maybe the PSG documentation so that you can more easily understand how the voices and coordination flags work.

Update history

March 29 2005: Initial release.

April 22 2005: Updated Chaotix info. Also added explaination on Sonic 2 Final pointer format and corrected a few bits of incorrect info. Turns out you CAN use 6 FM channels and the DAC at the same time, thanks to the music engine. Can't say it works perfectly though. :P.

May 24 2005: Updated with even more Sonic 2 final info. Also added music pointer locations for Ristar and Micheal Jackson's Moonwalker.

September ?? 2005: Fucking huge update. Massive amounts of new info, mainly concerning DAC samples. All the DAC sample definitions for Sonic 3 are now availiable, leaving many possibilities in the field. Also, I specified the DAC samples in Sonic 1 and 2 more, so Sonic QX users can be more precise with custom imports. Also, the purpose of two more coordination flags has been found out that have to do with PSG. Then, there are the small changes. A bit of proofreading, clarification... etc. I know I promised realtime music editing this update... Sorry I couldn't get it. It's my next priority, promise. =P

Some of these random things:

  1. Added some new locations. Found a new pointer set in Sonic 3 and found the sound effect pointers as well. Can't find out what the SFX add to yet though.
  2. Got into specifics with the Sonic 2 Final pointer list. And yes, it's in the right order. :P
  3. Added "$" signs to most ROM addresses as it's more proper. Meh, nitpicky shit. =P
  4. I wrote a tutorial on porting music from one game to another. I know people have been wanting this, so here you go. ;)

Pointer format

First off, what is a pointer? Well, a pointer is a set of hexadecimal values that point to a location in the ROM (or, in other cases, RAM. More advanced stuff there though). There are different types of pointers.

Some are part of an offset index. These kinds of data pointers are usually 16-bits (2 bytes) long and are determined by adding the pointer value to the current location in the ROM. So if one offset index added to 80000, and a pointer read 0890, then it is reading offset 80890, which would be the location of the data it is looking for.

Other pointers are very basic. 32-bit pointers are the easiest to deal with. They are big endian when dealing with the Megadrive and define the exact location using four bytes. So let's use the previous example. Our location was 80890. The pointer appears as "00 08 08 90". Couldn't be any simpler.

The pointer format in the Sonic games music differs from game to game. I will list the pointer format for each incarnation of the music engine. Follow along.

Sonic 1, Ristar, and Moonwalker

These pointers are relatively easy to deal with. These pointers are like the offset index pointers talked about earlier. They are relative 16-bit pointers that add the pointer value to the current location in the ROM. Here is an example.

Lets say that the music data started at EC000. Now, our voice pointer says 0180. So, from EC000 we add 180 to the value, making the location of the voice data at EC180. You see? That is simple. There are some other things to note about these pointers that I will mention later that have to do with coordination flags.

Sonic 2 Beta, 3, Crackers, Chaotix and 3D

These pointers are also pretty easy to deal with, once you understand their format. These pointers are also 16-bit, but they are absolute pointers. This means that they add to a specified location, which is usually even. Now, what you must understand is that these pointers are little endian, because the sound driver runs on the Z80. Little endian simply means that the bytes are swapped. A good example would be if a location was 8180 (big endian) for voice data, the pointer would read 8081 (little endian). This may seem confusing at first, but I will explain further.

You see, these pointers always read "8000", regardless of the starting location. So if the starting location of the music was C0000 for one song, and the starting location of another was C8000, the resulting pointer would still be 0080. You see, 8000 bytes is one music bank. So when 8000 bytes are used up by the first bank of music data, the second set of music pointers will add to that second bank location. So if the first bank's location was C0000, and the second was C8000, then the first set of pointers would add to C0000, and the second to C8000. Not too complicated. So lets break things down now.

Lets say the voice pointer for one song was F289. Since these are little endian, swap the bytes. This makes 89F2. Now, lets say that the current bank adds to C8000. So we can deduce that the location of the voice data is C89F2. You get it now? It is easier to find things with these pointers, but it becomes a bit of a problem if you are porting music, since you have to either put the music in its "original" location or fix all the pointers in the song.

Sonic 2 Final

All pointers add to a certain constant, including those in coordination flags. This constant is 1380. With these pointers, 1380 acts as zero. So lets say that the voice pointer reads 1915. Since 1380 is zero, we would subtract 1380 from 1915 and we get the distance away from the beginning of the song that the voice data is. Essentially the pointers in Sonic 2 Beta, but with a different constant. Note that each song is treated as it's own bank, and the beginning of the song is the beginning of the bank, while the end of the song is the end of the bank.

Exceptions: Credits music is uncompressed, unlike all the other music. Uses the S2B pointer format. So do the pointers to the music data itself at F8000.

Header format

Sonic 1, Sonic 2, Sonic 3, Sonic & Knuckles, Sonic 3D Blast, and Sonic Crackers

All pointers in this section differ according to the game you are hacking. Remember, relative for Sonic 1, Ristar, and Moonwalker, and absolute little endian for the others. The music header format listed is a universal format used in all the major Megadrive Sonic games, including Sonic 1, Sonic 2, Sonic 3, Sonic & Knuckles, Sonic 3D Blast, and Sonic Crackers.

Word offset Description
$00 Voice pointer. This points to the location of the voice data, or instruments in the song.
$02 Channel setup. This is usually 0603, and means there are 5 FM channels, 1 DAC, and 3 PSG channels. Changing these bytes will either make the header larger or smaller, depending on what you change them to. If you want to use the 6th FM channel, the 6th FM channel will be located after the 5th FM channel modifier. The same applies if you decide to use the PSG noise channel. It will be located right after the instrument modifier for the 3rd PSG modifier.
$04 Tempo modifier. First byte is the dividing timing, and the second is the main tempo modifier. Change the second byte to make the music faster or slower.
$06 DAC pointer. This points to the drums you hear in the music. In Chaotix, this points to the PWM channel used instead of the DAC channel. Treat them as the same for now.
$08 Dunno. They seem to be redundant.
$0A Dunno. They seem to be redundant.
$0C FM channel 1 pointer. It points to FM channel 1.
$0E FM channel 1 modifier. First byte modifies pitch, and second byte modifies volume (same for all).
$10 FM channel 2 pointer.
$12 FM channel 2 modifier
$14 FM channel 3 pointer.
$16 FM channel 3 modifier.
$18 FM channel 4 pointer.
$1A FM channel 4 modifier.
$1C FM channel 5 pointer.
$1E FM channel 5 modifier.
$20 PSG channel 1 pointer.
$22 PSG channel 1 modifier.
$24 Current PSG 1 instrument. First byte is redundant. Change the value to change the sound of the PSG tone produced.
$26 PSG channel 2 pointer.
$28 PSG channel 2 modifier.
$2A Current PSG 2 instrument.
$2C PSG channel 3 pointer.
$2E PSG channel 3 modifier.
$30 Current PSG 3 Instrument.

Knuckles Chaotix

The format for the Chaotix music pointers is slightly different to accomodate the 32x's hardware.

Word offset Description
$00 Voice pointer. This points to the location of the voice data, or instruments in the song.
$02 Channel setup. This is usually 0603, and means there are 6 FM channels, and 3 PSG channels. Changing these bytes will either make the header larger or smaller, depending on what you change them to. If you decide to use the 4th PSG channel, it will be located right after the instrument modifier for the PSG 3 modifier. Following that will be the PWM pointers.
$04 Tempo modifier. First byte is the dividing timing, and the second is the main tempo modifier. Change the second byte to make the music faster or slower.
$06 FM channel 1 pointer. It points to FM channel 1.
$08 FM channel 1 modifier. First byte modifies pitch, and second byte modifies volume (same for all).
$0A FM channel 2 pointer.
$0C FM channel 2 modifier.
$0E FM channel 3 pointer
$10 FM channel 3 modifier.
$12 FM channel 4 pointer.
$14 FM channel 4 modifier.
$16 FM channel 5 pointer.
$18 FM channel 5 modifier.
$1A FM channel 6 pointer.
$1C FM channel 6 modifier.
$1E PSG channel 1 pointer.
$20 PSG channel 1 modifier.
$22 Current PSG 1 instrument. First byte is redundant. Change the value to change the sound of the PSG tone produced.
$24 PSG channel 2 pointer.
$26 PSG channel 2 modifier.
$28 Current PSG 2 instrument
$2A PSG channel 3 pointer.
$2C PSG channel 3 modifier.
$2E Current PSG 3 instrument
$30 PWM channel 1 pointer
$32 PWM channel 1 modifier
$34 PWM channel 2 pointer
$36 PWM channel 2 modifier.
$38 PWM channel 3 pointer
$3A PWM channel 3 modifier
$3C PWM channel 4 pointer
$3E PWM channel 4 modifier

Understanding the header is essential to editing music. This is the basis of basic music editing, such as pitch and tempo editing. Once you understand the pointers and the header, then you are ready to start learning more advanced things.

Voice editing

Voices are the instruments that you hear playing in the music throught the FM channels. To edit them correctly, you need to know FM synthesis. Swapping and copying voices is a simple copy-paste job. A voice is 19 hex bytes, and has no header. It is raw data that gives info to the YM2612 FM chip in the Megadrive to give the desired sound output. The format of a voice is as follows.

Offset Description Register
Ch.1/3 Ch.2/4 Ch.3/6
$0 Feedback (next 3 bits) / Algorithm (lower 3 bits) B0 B1 B2
$1 Detune of operator 4 (nybble 1) / Coarse-frequency of operator 4 (nybble 2) 3C CD CE
$2 Detune of operator 3 (nybble 1) / Coarse-frequency of operator 3 (nybble 2) 38 39 3A
$3 Detune of operator 2 (nybble 1) / Coarse-frequency of operator 2 (nybble 2) 34 35 36
$4 Detune of operator 1 (nybble 1) / Coarse-frequency of operator 1 (nybble 2) 30 31 32
$5 [RS] of operator 4 (upper 2 bits) / Attack rate [AR] of operator 4 (lower 5 bits) 5C 5D 5E
$6 [RS] of operator 3 (upper 2 bits) / Attack rate [AR] of operator 3 (lower 5 bits) 58 59 5A
$7 [RS] of operator 2 (upper 2 bits) / Attack rate [AR] of operator 2 (lower 5 bits) 54 55 56
$8 [RS] of operator 1 (upper 2 bits) / Attack rate [AR] of operator 1 (lower 5 bits) 50 51 52
$9 [AM] of operator 4 / First decay rate [D1R] of operator 4 (lower 5 bits) 6C 6D 6E
$A [AM] of operator 3 / First decay rate [D1R] of operator 3 (lower 5 bits) 68 69 6A
$B [AM] of operator 2 / First decay rate [D1R] of operator 2 (lower 5 bits) 64 65 66
$C [AM] of operator 1 / First decay rate [D1R] of operator 1 (lower 5 bits) 60 61 62
$D Second decay rate [D2R] of operator 4 7C 7D 7E
$E Second decay rate [D2R] of operator 3 78 79 7A
$F Second decay rate [D2R] of operator 2 74 75 76
$10 Second decay rate [D2R] of operator 1 70 71 72
$11 First decay level [D1L] of operator 4 (nybble 1) / Release rate [RR] of operator 4 (nybble 2) 8C 8D 8E
$12 First decay level [D1L] of operator 3 (nybble 1) / Release rate [RR] of operator 3 (nybble 2) 88 89 8A
$13 First decay level [D1L] of operator 2 (nybble 1) / Release rate [RR] of operator 2 (nybble 2) 84 85 86
$14 First decay level [D1L] of operator 1 (nybble 1) / Release rate [RR] of operator 1 (nybble 2) 80 81 82
$15 Total level of operator 4 4C 4D 4E
$16 Total level of operator 3 48 49 4A
$17 Total level of operator 2 44 45 46
$18 Total level of operator 1 40 41 42

Note editing

The way the music is set up in the Sonic games is similar to how music is structured in a MIDI file. Here are some values that will help you directly edit notation data in the music.

  • 00-7F: Note duration (How long a note is held for)
  • 80-DF: Notes (80 is a rest)
  • E0-FF: Coordination flags

Now, the DAC channel uses values starting with 81 (As with FM and PSG, 80 is used as a rest) to define the DAC drum sample that is played. Here are the sample definitions for a few games. Expect this section to be updated with more soon.

Sonic 1

  • 81: Kick
  • 82: Snare
  • 83: Hi-Timpani
  • 84: Noise
  • 85: Noise
  • 86: Noise
  • 87: Sega Sound
  • 88: Hi-Timpani
  • 89: Mid-Timpani
  • 8A: Low-Timpani
  • 8B: Low-Timpani

Sonic 2 Beta

  • 81: Kick
  • 82: Snare
  • 83: Clap
  • 84: Scratch
  • 85: Hi-Timpani
  • 86: Hi-Tom
  • 87: Silent
  • 88: Hi-Timpani
  • 89: Mid-Timpani
  • 8A: Low-Timpani
  • 8B: Low-Timpani
  • 8C: Mid-Tom
  • 8D: Low-Tom
  • 8E: Floor-Tom
  • 8F: Clap

Sonic 2 Final

  • 81: Kick
  • 82: Snare
  • 83: Clap
  • 84: Scratch
  • 85: Timpani
  • 86: Tom
  • 87: Bongo
  • 88: Hi-Timpani
  • 89: Mid-Timpani
  • 8A: Low-Timpani
  • 8B: Low-Timpani
  • 8C: Mid-Tom
  • 8D: Low-Tom
  • 8E: Floor-Tom
  • 8F: Hi-Bongo
  • 90: Mid-Bongo
  • 91: Low-Bongo

Sonic 3 and Knuckles; Sonic 3D Blast

  • 81: Snare
  • 82: High-Tom
  • 83: Mid-Tom
  • 84: Low-Tom
  • 85: Floor Tom
  • 86: Kick
  • 87: Muffled Snare
  • 88: Crash Cymbal
  • 89: Ride Cymbal(?)
  • 8A: Low Metal Hit
  • 8B: Metal Hit
  • 8C: High Metal Hit
  • 8D: Higher Metal Hit
  • 8F: Clap
  • 90: Electric High-Tom
  • 91: Electric Mid-Tom
  • 92: Electric Low-Tom
  • 93: Electric Floor Tom
  • 94: Tight Snare
  • 95: Mid-pitch Snare
  • 96: Loose Snare
  • 97: Looser Snare
  • 98: Hi-Timpani
  • 99: Low-Timpani
  • 9A: Mid-Timpani
  • 9B: Quick Loose Snare
  • 9C: Click
  • 9D: Power Kick
  • 9E: Quick Glass Crash
  • 9F: Glass Crash with Snare
  • A0: Glass Crash
  • A1: Glass Crash with Kick
  • A2: Quiet Glass Crash
  • A3: Odd Snare with Kick
  • A4: Kick with extra bass
  • A5: "Come on!"
  • A6: Dance Snare
  • A7: Loose Kick
  • A8: Moderately Loose Kick
  • A9: "Woo!"
  • AA: "Go!"
  • AB: Snare with voice going "Go!"
  • AC: Power Tom
  • AD: Hi-Wood Block
  • AE: Low-Wood Block
  • AF: Hi-Hit Drum
  • B0: Low-Hit Drum
  • B1: Metal Crash Hit
  • B2: Echoed Clap Hit
  • B3: Lower Echoed Clap Hit
  • B4: Hip-Hop style hit with a kick
  • B5: Hip-Hop style hit with a Power Kick
  • B6: Some Bass with a voice going "Hey!"
  • B7: Dance Style Kick
  • B8: Hip-Hop hit with a kick
  • B9: Hip-Hop hit with a kick
  • BA: Reverse Fading Wind Sound
  • BB: Scratch
  • BC: Loose Snare with noise
  • BD: Power Kick
  • BE: Crashing noise with voice going "Woo!"
  • BF: Quick Hit
  • C0: Kick with a voice going "Hey!"
  • C1: Power Kick with hit
  • C2: Low Power Kick with hit
  • C3: Lower Power Kick with hit
  • C4: Lowest Power Kick with hit

Note: Some may be missing or changed in 3D, such as most SFX. The major drums are there though.

Sonic Crackers

  • 81: Kick
  • 82: Snare
  • 83: Tom
  • 84: Tom
  • 85: Tom
  • 86: Voice sample "Let's go!"
  • 87: Voice sample "Hey!"
  • 88: Beep/screech

DAC Samples

DAC samples are the drums and voices that you hear in game. You can customize these audio samples to your needs. Here is some information to do so below...

DAC Sample Pointers:

Pointers to DAC Samples in Sonic 2 Beta: $ECDA6

Specifics...

  • $ECDA6 - Sample 81 pointer
  • $ECDA8 - Sample 81 length
  • $ECDAA - Sample 82 pointer
  • $ECDAC - Sample 82 length (skip FF)
  • $ECDAF - Sample 83 pointer
  • $ECDB1 - Sample 83 length
  • $ECDB3 - Sample 84 pointer
  • $ECDB5 - Sample 84 length (skip FF)
  • $ECDB8 - Sample 85 pointer
  • $ECDBA - Sample 85 length
  • $ECDBC - Sample 86 pointer
  • $ECDBE - Sample 86 length -- This one is tricky. You need to skip the second FF, as the first FF is valid.

Pointers to DAC Samples in Sonic 2 Final: $ECF7C

Specifics...

  • $ECF7C - Sample 81 pointer
  • $ECF7E - Sample 81 length
  • $ECF81 - Sample 82 pointer
  • $ECF83 - Sample 82 length
  • $ECF85 - Sample 83 pointer
  • $ECF87 - Sample 83 length
  • $ECF8A - Sample 84 pointer
  • $ECF8C - Sample 84 length
  • $ECF8E - Sample 85 pointer
  • $ECF90 - Sample 85 length
  • $ECF93 - Sample 86 pointer
  • $ECF95 - Sample 86 length
  • $ECF97 - Sample 87 pointer
  • $ECF99 - Sample 87 length

These pointers are 4 bytes in size. First two bytes are the pointer to the sample (the pointers add to E0000, little endian, and don't follow the music pointer format. Simple 16-bit absolute), and the other two bytes are the length of the sample (also little endian). If you see an FF, skip it and move on to the next byte.


DAC Master List:

  • DAC Master List in Sonic 2 Beta: $ECDC1
  • DAC Master List in Sonic 2 Final: $ECF9C

These work similarly to the master playlist in concept.. The format is two bytes per sample. First byte defines the sample ID, and the second byte defines the rate that the sample is played at. The lower the rate value, the faster the sample is played. This is used to make certain samples (like toms) appear to have different pitches (high tom, low tom, etc). If you see an FF, skip it and move on to the next byte. If you touch the FF, you fuck the entire sound driver. Don't. :P

Coordination flags

Coordination flags alter the music in real time. They are what tell the game to jump from one part of the song to another and to set up the channels. They are also what makes the music loop in the games. They are complicated, and it is recommended that you understand the YM2612 more before messing with them.

The coordination flags differ from game to game. They are the same in Sonic 1 and 2, but different in the others. For now, I will only give the flags for Sonic 1 and 2. Not all of them are known, but a majority are.

  • E0xx - panning, AMS, FMS
    • xx - Value
      • Bit 7 - Left channel status
      • Bit 6 - Right channel Status
      • Bit 5-3 - AMS
      • Bit 2 - 0
      • Bit 1-0 - FMS
  • E1xx - Alter note values by xx???
  • E6xx - Change channel volume with xx; xx is signed
  • E7xx - prevent next note from attacking
  • E8xx - set note fill amount to xx
  • E9xx - add xx to channel key
  • EAxx - set music tempo to xx
  • EBxx - Change Tempo Modifier to xx for ALL channels
  • ECxx - Change channel volume by xx; xx is signed
  • EE - Something with Voice Selection
  • EFxx - set voice selection to xx
  • F0wwxxyyzz - modulation
    • ww - Wait for ww period of time before modulation starts
    • xx - Modulation Speed
    • yy - Modulation change per Mod. Step
    • zz - Number of steps in modulation
  • F1 - Turn on modulation
  • F2 - stop the track
  • F3xx - Change current PSG noise to xx (For noise channel)
    • Applicable values are E0 - E7
    • Anything beyond E7 will wrap back to the E0 waveform
  • F4 - Turn off modulation
  • F5xx - Change current PSG tone to xx
  • F6yyyy - jump to position yyyy
  • F7xxyyyy - repeat xx times at position yyyy before moving on
  • F8yyyy - jump to position yyyy (keep previous position in memory for returning)
  • F9 - return

Note on F3 and F5: These determine whether a PSG channel is a tone channel or the noise channel. There is only one noise channel, and 3 tone channels. F3 for noise, F5 for tone.

Note on F8 and F9: I like to refer to these as the music editing equivelants of JSR and RTS. F8 adds the previous location to stack and branches to the specified location. F9 will return to the previous address on stack. Just like 68k, eh? =P

Now, you will notice that some of these flags speak of a signed value. Signed values have the capability to be positive or negative. What makes a hexadecimal value signed? Bit number 7, the first bit on the left, will be 1 for negative and 0 for positive. So, a hexadecimal value that is 00-7F is positive, and values 80-FF are negative. Here's an example:

Let's say that you wanted to go back 9 bytes to locate some music data in Sonic 1. Sonic 1 uses relative pointers, so let's use a signed value. With signed bytes, FFFF is the lowest value you can have. FFFF resembles zero. So FFFE would be -1, FFFD would be -2, etc. Signed values are used to locate data before the current location. So if I wanted to locate data that was 9 bytes back from my current location, I would take FFFF and subtract 9 bytes in hex from it. This leaves me with FFF6. If you wanted to go forward 9 bytes, you would take FFFF and add 9 to it (while keeping it 16-bit), which would be 0008. This is confusing, and kinda advanced, but if you plan on learning 68k ASM at all, it's something you have to know.

Game specifics

Sonic 2

Master Playlist

Sonic 2 has a special Master playlist that defines what music ID plays in what slot. All values for music subtract 1 from the value. So to change Track 81 to Track 82, change 80 to 81. 80 is 81, 81 is 82, etc. These values go up to slot 9F, or 1F in the final version of the game. The locations are as follows.

Master Playlist in Sonic 2 Beta: ECE9F

Master Playlist in Sonic 2 Final: ECF36

As said before, track 81 is represented by 80, 82 is reresented by 81, etc. If you see an FF, skip it and move on to the next byte. This master playlist is only in Sonic 2 as far as I know. If I find it in any other games, I will update this section.

Music Compression

In Sonic 2 Final, there is a compression applied to all music data in the game except for the credits. This format has been dubbed the Saxman compression, named after the person who cracked the format. I will not note how to manually decompress this format -- Refer to Saxman's hacking guide to do so. The music can be decompressed by using Magus' Sega Data Compressor. Refer to the pointer format to edit the music properly.

Music locations

Now that you know all the basics, you can start editing music. Here are some locations for various games that will help. You can use the music pointers to locate the music data for now, but I may document the locations of each individual track in the future.

Sonic 1

  • Music Pointers: 71A9C
  • Sound Effect Pointers: 78B44

Sonic 2 Beta

  • Music Pointers (These add to $F0000, for 98-9F): $F0000
  • Music Pointers (These add to $F8000): $F8000
  • Pointer to Music Pointers at $F8000: $EC79D
  • Sound Effect Pointers (These add to $F8000): $FF000
  • Pointer to Sound Effect Pointers: $EC08E

Sonic 2 Final

  • Music Pointers (These add to F8000): F8000
Pointer ID Address Sound Test ID Song name
81 $F84F6 08 Casino Night Zone (2 Player)
82 $F88C4 02 Emerald Hill Zone
83 $F8DEE 05 Metropolis Zone
84 $F917B 09 Casino Night Zone
85 $F9664 0B Mystic Cave Zone
86 $F9A3C 03 Mystic Cave Zone (2 Player)
87 $F9D69 07 Aquatic Ruin Zone
88 $FA36B 0A Death Egg Zone
89 $FA6ED 12 Special Stage
8A $FAAC4 11 Option Screens
8B $FAC3C 15 "Sweet Sweet Sweet" (Ending)
8C $FB124 14 Final Battle
8D $FB3F7 0E Chemical Plant Zone
8E $FB81E 13 Boss
8F $FBA6F 0D Sky Chase Zone
90 $FBD8C 04 Oil Ocean Zone
91 $FC146 0F Wing Fortress Zone
92 $FC480 0C Emerald Hill Zone (2 Player)
93 $FC824 01 2 Player Results Screen
94 $FCBBC 16 Super Sonic
95 $FCE74 06 Hill Top Zone
96 $FD48D 18 1-Up
97 $FD193 19 Title Screen
98 $FD35E 1A Stage Cleared
99 $FD57A 1B Game Over
9A $F8359 17 Invincibility
9B $FD6C9 1D Got an Emerald
9C $F803C 10 Hidden Palace Zone
9D $F823B 1F Underwater Timing
9E $FD797 1E Credits
  • Pointer to Music Pointers at $F8000: $EC810
  • Music Pointers (These add to F8000 and are for 98-9F, excluding continue): F802A
Pointer ID Address Sound Test ID Song name
01 0F0002 1C Continue
  • Sound Effect Pointers (These add to F8000): FEE91
  • Pointer to Sound Effect Pointers: $EC09C

Sonic Crackers

  • Music Pointers: $0633F
    • Electoria (81): $10000
    • Walkin' (82): $1088C
    • Hyper-Hyper (83): $10BDA
    • Evening Star (84): $11210
    • Moonrise (85): $1172B
    • Game Over (86): $11B10

Sonic 3

  • Music Pointers (These add to $C8000): $E761A
  • Music Pointers (These add to $D0000): $E762E
  • Music Pointers (These add to $D8000): $E7652
  • Music Pointers (These add to $C0000): $E7674
  • Sound Effect Pointers (These add to ?????): $E767E

Sonic 3D

  • Music Pointers (These add to $C0000): $D3233
  • Music Pointers (These add to $C8000): $D3245
  • Music Pointers (These add to $D0000): $D325D
  • Sound Effect Pointers (These add to $D8000): $D3297

Knuckles Chaotix

  • Music Pointers (These add to $40000): $76AE9
  • Music Pointers (These add to $48000): $76B05
  • Music Pointers (These add to $50000): $76B33
  • Sound Effect Pointers (These add to $50000): $76B3B

Sonic & Knuckles

  • Music Pointers: $F793E
Music ID Music pointer Song name
These add to 2C8000:
01 8000 AIZ1
02 9B6D AIZ2
03 B0BC HZ1
04 C0C6 HZ2
05 D364 MGZ1
06 D97B MGZ2
07 E48F CNZ1
08 DDA9 CNZ2
These add to E8000:
09 8000 FBZ1
0A 8597 FBZ2
0F 8AFE MHZ1 -- This one is a bit tricky... The FE is right before the FF. Make sure to skip the FF or the driver will crash.
10 9106 MHZ2
11 9688 SZ1
12 9CF2 SZ2
13 A2E5 LRZ1
14 ACF3 LRZ2
15 BE80 SSZ
16 C2B4 DEZ1
17 C79F DEZ2
18 CBB1 Act 1 Boss
19 CEE1 Act 2 Boss
1A D3DD Doomsday
1B DCC0 Rolling Jump Bonus Stage
1C E223 Special Stage
1D EABB Slot Machine Bonus Stage
1F F5A3 Knuckles Theme
25 F88E Title
2A FD4B 1UP
2B FE75 Chaos Emerald
2E CBB1 Act 1 Boss (same as 18)
These add to 2D0000:
0B 86AA IZ1
0C 8000 IZ2
0D 9345 LBZ1
0E 8DC8 LBZ2
1E 8AE8 Gum Ball Machine Bonus Stage
20 99F7 Azure Lake
21 A4FD Balloon Park
22 B0EC Desert Palace
23 C324 Chrome Gadget
24 DA47 Endless Mine
26 E587 S3 credits
2D F5E4 Competition Menu
31 FABE S3 countdown
These add to E0000:
27 DD4B Game/Time Over
28 DFA6 Continue
29 E3C0 Bonus Screen
2C E574 Invincible
2F E7AF Menu
30 F74C Final Boss
32 FCDE S&K outro
DC C104 S&K credits

Ristar

Music Pointers (32-bit): C852A

Music locations:

  • $CDBF4 - Flora 1 [shooting ristar]
  • $CEA0E - Scorch 1 [busy flare]
  • $CF6B6 - Flora 2 bgm [dancing leaves]
  • $D05F6 - Pre boss [concentration]
  • $D0774 - Sonata 1 (initial bgm) [intension]
  • $D0AC6 - Sonata 1 (1st metronome)
  • $D0E7C - Sonata 1 (2nd metronome)
  • $D1218 - Sonata 1 (final metronome)
  • $D1520 - Sonata 2 [on parade]
  • $D1E88 - Automaton 2 [lock up]
  • $D2C38 - Freon 1 [ring rink]
  • $D36DC - Undertow 2 [break silence]
  • $D4346 - Boss [crazy kings]
  • $D4DBE - Scorch 2 [under magma]
  • $D5A0A - Undertow 1 [splash down]
  • $D6752 - Freon 2 [ice scream]
  • $D732C - Ending 2 [next cruise]
  • $D7E4E - Sonata 1 (mini boss) [du di du da]
  • $D81E8 - Intro 1 [ebony force]
  • $D858C - Bonus [ready...GO!]
  • $D8D80 - Intro 2/ Title [pray pray play!]
  • $D97EC - Bonus (preview) [formation lap]
  • $D997A - Continue Screen
  • $D9CFC - Greedy [theme of kaiser]
  • $DAA66 - Automaton 1 [crying world]
  • $DAFB2 - Ending 1 [star humming]
  • $DC422 - Sonata 1 (initial bgm) [intension] *MID ROUND??*
  • $DC69A - round clear 2 [beyond space]
  • $DCF66 - round clear 1 [lets go]
  • $DD240 - area clear [go ahead]
  • $DD5C8 - game over [game over .. fuu]
  • $DD7EC - defeated Greedy, before imploding cutscene
  • $DD978 - Sonata 1 (mini boss 3 note intro)
  • $DDA1E - "Sega" music

MJ's Moonwalker

Music Pointers (32-bit): $600A4

Tricks of the Trade

Music porting

Ah, yes. Music porting. An infamous practice that many want to achieve. This section will explain the various methods of porting music from one game to another. If something is not possible, it will be noted.

Sonic 1 -> Sonic 2 Beta

This is one of the easier jobs in my opinion, but it can be a bit tough at first. The trick is to convert the pointer format from S1 to S2B format. First, you have to convert the header pointers. This is the easiest part, as all the pointers are simple relative pointers. So here's what you do...

First off, mark the location you want to place the music at in pointer form. EX: F8000 goes to 8000, which goes to 0080, etc etc. Then, take this base location and add the relative values to it. So if I was placing my music at F9CDE, and my voice pointer was 0312, I would add 312 bytes to F9CDE. This gives me F9FF0. I then take this and convert it into pointer form. An easy way to do so in this case is to simply remove the F. This leaves me with 9FF0, which I then byteswap. This leaves me with the final converted pointer of F09F. Do this for every pointer in the header, as the rest you can leave intact.

The next job is to convert all the pointers in the coordination flags that have them. There are 3 flags in total that do so: F6, F7, and F8. Become familiar with the syntax; Know which is the pointer and which is not. Converting proceeds as follows...

We'll start with an example of sorts. As I noted before, with coordination flag pointers in S1, signed values are used. FFFF is 0, etc. The math works in the same way as our last job, but this time we use different variables. Our base location is found out by marking the offset of the byte where the actual pointer is. In the case of F6 and F8, the byte after F6/F8. In the case of F7, skip two bytes after the F7 to where the pointer is. This is all in my syntax breakdowns, BTW.

Now that we have our base location, we can convert the pointer. Now remember, instead of 0000 being zero, in this case FFFF is zero. So if we want to convert our pointer easily, we have to make our pointer as simple as the header pointers. For negative jumps (below FFFF), we take the pointer value and subtract FFFF from it. This will leave us with a simple relative value. For example, if my S1 pointer was FFE6, I would subtract FFE6 from FFFF. This gives me 19 as a result, meaning this pointer is meant to locate data 19 bytes before our base location. Now we have to convert this into S2B form. Take your base location and subtract your result relative value (19 in my case) from it. For example, if my base location was FEE90 (90EE), I would subtract 19 bytes from it (my result value from the above operation). That would give me the offset of FEE77. I then convert this into pointer form, giving me the final converted pointer of 77EE.

For positive values (above FFFF), things are a bit simpler. Simply take the positive value and subtract 1 from it. Then, add it to your base location. So if my pointer was 0090, I subtract 1 from it. This gives me 8F. I then add this value to my base location, which was FEE90. FEE90 + 8F = FEF1F. Then, convert this into S2B pointer form. This gives me the final converted pointer of 1FEF. Fun, eh? =P

Remember to do this with ALL pointers in the song. You won't get off correcting two or three, I'll tell you that much. :P

Points to note: Always remember to change the music pointer to point to your new music. Otherwise you'll have done this all for nothing. Also, S1 voices are not entirely compatible with S2 voices. You may have to apply new voices to the song to make it sound right. This is why the instruments in Esrael's port of Marble zone sounded different; He had to make new ones.

Porting between Sonic 3K/3D/Crackers/Chaotix

This job is much simpler, as all pointers use the same format. There are two methods of porting this music between each other...

  1. Simply put the music in the "same" location according to pointer format. For example, having music at C0000 or C8000 would be the same as having it at 10000 or 18000. All the result pointers would be 0080. Get it? =P Simple copy and paste, and nothing else needs to be done. Just change the music pointer to point to the new music and presto! Ported music. This method limits your customization as where to put the music though, and I don't recommend it unless you are porting whole music banks or it is incredibly convenient. It is easier though, so hey. =P
  2. Modify all pointers inside the music (header and coordination flags) to go along with the new location you put it at. Here's a simple way to do so...

First off, take your original location, which is the beginning of the song. Then, work out where you are going to put the song. Convert both these values into pointer format. Now, work out the difference between these two values. For example, if the original location was F802A (2A80 in pointer format), and I wanted to put it at FD980 (80D9 in pointer format), then I would subtract my new location from my original location. So in my case, FD980 - F802A. This gives me 5956. Now, this will be your modifying value for each pointer. You add this location to each pointer in the song to get your converted pointer.

Let me give an example of a negative value. My original location was FA000 and my new location was F9027. This time, we switch the operation. FA000 - F9027 = FD9. This time, you subtract this value from each pointer in the song to get the converted pointer. So remember, if you are moving a song to a location before the original location, subtract. If you are moving it to a location beyond the original, add.

Points to note: If Sonic 3 music has D817 as the voice pointer, then it cannot be ported outside of S3K without being given a new voice set. Sonic 3K is the only game with this universal voice bank, and specifying it in any other game will have no effect.

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