Actions

SCHG

Difference between revisions of "Music Hacking"

From Sonic Retro

m (Text replace - 'Saxman' to 'saxman')
(MJ's Moonwalker)
Line 2,476: Line 2,476:
 
===MJ's Moonwalker===
 
===MJ's Moonwalker===
 
* Music Pointers (32-bit): $600A4
 
* Music Pointers (32-bit): $600A4
 +
** Specifics...
 +
{| class="prettytable"
 +
|-
 +
! Offset||ID||Song
 +
|-
 +
|$63588||81||Smooth Criminal
 +
|-
 +
|$63DAE||82||Beat It
 +
|-
 +
|$64614||83||Another Part of Me
 +
|-
 +
|$64FEA||84||Billy Jean
 +
|-
 +
|$65726||85||Bad
 +
|-
 +
|$65D5C||86||Moonwalker Title SFX
 +
|-
 +
|$65E22||87||"Some Cool SFX" (lol Oerg)
 +
|-
 +
|$65E96||88||Boss Appears
 +
|-
 +
|$66300||89||Smooth Criminal Dance
 +
|-
 +
|$66488||8A||Smooth Criminal Dance
 +
|}
  
 
===Gunstar Heroes===
 
===Gunstar Heroes===

Revision as of 19:34, 8 March 2009

Contents

Original Credits

Guide originally created by Tweaker on May 25 2005.

Thanks to:

Prologue

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 recommended 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. ;)


  • September 2 2006: Wow, it's been over a year since the last update! Has it really been that long? o_O

Anyway, I finally got the realtime music editing section done. Savestate locations and Z80 RAM equivalents are listed, with explanations on how to tinker with music, even while it’s still playing. Also added locations for a shitload of games, mostly from my notes. I also added more to the music porting section. And once again, various corrections and such... I can't be arsed to keep track of what I change anymore, so bleh. =P

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.

68k SMPS

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. Also, note that...

  • Ristar's coordination flag pointers have $1 added to them, compared to the pointers in other 68k SMPS games. If you want to convert between the two, just add or subtract $1 thusly.
  • Some 68k SMPS games use the Sonic 3-style coordination flags.

Z80 SMPS

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 let's 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

Standard SMPS

All pointers in this section differ according to the game you are editing. Remember, relative pointers for 68k SMPS, and absolute little endian pointers for Z80 SMPS. The music header format listed is a universal format used in all incarnations of the SMPS engine except for Knuckles' Chaotix, which uses a slightly modified version to accommodate for the extra sound hardware (the PWM sound channels).

Word offset Description
$00-$01 Voice pointer. This points to the location of the voice data, or instruments, in the song.
$02-$03 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-$05 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, and change the first byte to determine the range of tempo values you can achieve. The higher the divider, the slower the tempo can be.
$06-$07 DAC pointer. This channel is generally used for the drums you hear in the music, though it can be used to play any type of DAC sample available for use.
$08-$09 Unused.
$0A-$0B FM channel 1 pointer. It points to FM channel 1.
$0C-$0D FM channel 1 modifier. First byte modifies pitch, and second byte modifies volume (same for all).
  • NOTE: Volume works "backwards" - the lower the value, the higher the volume.
$0E-$0F FM channel 2 pointer.
$10-$11 FM channel 2 modifier
$12-$13 FM channel 3 pointer.
$14-$15 FM channel 3 modifier.
$16-$17 FM channel 4 pointer.
$18-$19 FM channel 4 modifier.
$1A-$1B FM channel 5 pointer.
$1C-$1D FM channel 5 modifier.
$1E-$1F PSG channel 1 pointer.
$20-$21 PSG channel 1 modifier.
$22-$23 Current PSG 1 instrument. First byte is redundant. Change the value to change the sound of the PSG tone produced.
$24-$25 PSG channel 2 pointer.
$26-$27 PSG channel 2 modifier.
$28-$29 Current PSG 2 instrument.
$2A-$2B PSG channel 3 pointer.
$2C-$2D PSG channel 3 modifier.
$2E-$2F Current PSG 3 Instrument.

Knuckles Chaotix

The format for the SMPS music header is slightly different to accommodate for the 32x's extra sound hardware.

Word offset Description
$00-$01 Voice pointer.
$02-$03 Channel setup.
$04-$05 Tempo modifier.
$06-$07 FM channel 1 pointer.
$08-$09 FM channel 1 modifier.
$0A-$0B FM channel 2 pointer.
$0C-$0D FM channel 2 modifier.
$0E-$0F FM channel 3 pointer.
$10-$11 FM channel 3 modifier.
$12-$13 FM channel 4 pointer.
$14-$15 FM channel 4 modifier.
$16-$17 FM channel 5 pointer.
$18-$19 FM channel 5 modifier.
$1A-$1B FM channel 6 pointer.
$1C-$1D FM channel 6 modifier.
$1E-$1F PSG channel 1 pointer.
$20-$21 PSG channel 1 modifier.
$22-$23 Current PSG 1 instrument.
$24-$25 PSG channel 2 pointer.
$26-$27 PSG channel 2 modifier.
$28-$29 Current PSG 2 instrument.
$2A-$2B PSG channel 3 pointer.
$2C-$2D PSG channel 3 modifier.
$2E-$2F Current PSG 3 instrument.
$30-$31 PWM channel 1 pointer. This will point to one of the four available PWM channels used for percussion and other samples that can be played in the song. It works exactly like DAC, except there are more channels available for use.
$32-$33 PWM channel 1 modifier. Unlike DAC, the pitch and volume of a PWM channel can be changed, and in the same way as any other melodic sound channel. However, the volume byte will work by output strength, and not resistance--in other words, the higher the value, the louder the sample.
$34-$35 PWM channel 2 pointer.
$36-$37 PWM channel 2 modifier.
$38-$39 PWM channel 3 pointer.
$3A-$3B PWM channel 3 modifier.
$3C-$3D PWM channel 4 pointer.
$3E-$3F 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 information 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 3D 3E
$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

It should be noted that Sonic 2 uses a different format than the other main Sonic games; to correcty convert songs from and to that game, it is necessary to swap the second and the third byte in each group of operators, as shown in the following chart: VoiceOperators.png

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.

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

Note Equivalents

Value Note
$81 C
$82 C#/Db
$83 D
$84 D#/Eb
$85 E
$86 F
$87 F#/Gb
$88 G
$89 G#/Ab
$8A A
$8B A#/Bb
$8C B
$8D 1C
$8E 1C#/Db
$8F 1D
$90 1D#/Eb
$91 1E
$92 1F
$93 1F#/Gb
$94 1G
$95 1G#/Ab
$96 1A
$97 1A#/Bb
$98 1B
$99 2C
$9A 2C#/Db
$9B 2D
$9C 2D#/Eb
$9D 2E
$9E 2F
$9F 2F#/Gb
$A0 2G
$A1 2G#/Ab
$A2 2A
$A3 2A#/Bb
$A4 2B
$A5 3C
$A6 3C#/Db
$A7 3D
$A8 3D#/Eb
$A9 3E
$AA 3F
$AB 3F#/Gb
$AC 3G
$AD 3G#/Ab
$AE 3A
$AF 3A#/Bb
$B0 3B
$B1 4C
$B2 4C#/Db
$B3 4D
$B4 4D#/Eb
$B5 4E
$B6 4F
$B7 4F#/Gb
$B8 4G
$B9 4G#/Ab
$BA 4A
$BB 4A#/Bb
$BC 4B
$BD 5C
$BE 5C#/Db
$BF 5D
$C0 5D#/Eb
$C1 5E
$C2 5F
$C3 5F#/Gb
$C4 5G
$C5 5G#/Ab
$C6 5A
$C7 5A#/Bb
$C8 5B
$C9 6C
$CA 6C#/Db
$CB 6D
$CC 6D#/Eb
$CD 6E
$CE 6F
$CF 6F#/Gb
$D0 6G
$D1 6G#/Ab
$D2 6A
$D3 6A#/Bb
$D4 6B
$D5 7C
$D6 7C#/Db
$D7 7D
$D8 7D#/Eb
$D9 7E
$DA 7F
$DB 7F#/Gb
$DC 7G
$DD 7G#/Ab
$DE 7A
$DF 7A#/Bb

Sonic 1

Value Sample
$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

Value Sample
$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

Value Sample
$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

Value Sample
$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 samples may be missing or changed in Sonic 3D, such as most sound effect-based samples. All of the major drums are there, though.

Sonic Crackers

Value Sample
$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 raw PCM samples, generally used for 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...

Audio Compression

Samples are all "compressed" to 4-bit PCM data in the ROM itself, and are decompressed and converted to 8-bit PCM once processed in-game. You can decompress (and recompress) samples by using jman2050's Sonic 1 sample decompressor (though it works for all SMPS games), located here.

Sonic 1

Samples in Sonic 1 are inside the Z80 portion of the sound driver, located at $72E7C, and compressed in Kosinski format. All following locations are for the decompressed sound driver.

DAC Sample Pointers

  • DAC sample setup index: $D6

Each DAC pointer is listed one after another, and a single entry for one DAC sample is $8 bytes. The format is as follows:

Offset Size Description
$00-$01 Word Location of the DAC sample in decompressed driver.
  • NOTE: Value is little endian, so swap the bytes to get the real value.
$02-$03 Word Size of the compressed DAC sample in decompressed driver.
  • NOTE: Value is little endian, so swap the bytes to get the real value.
$05 Byte Sample rate/pitch. The lower the value, the faster the sample will play.
$06-$08 3 Bytes Unused/redundant.


Sonic 1 has 3 DAC sample slots - one for the kick, one for the snare, and one for the Timpani. The other pitches of Timpani ($88-$8B) are defined by a special table, located at $71CC4, and are fully editable to suit other samples using the Timpani slot ($83).

Sonic 2

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

Sonic 3

Setup Pointers

  • DAC $81-$9A Pointer Index (Adds to $E0000): $E0000
  • DAC $9B-$AA Pointer Index (Adds to $E8000): $E8000
  • DAC $AB-$C0 Pointer Index (Adds to $F0000): $F0000

These pointer indexes work by pointing to the sample setup data for the particular samples. You'll notice there are 3 pointer indexes - this is since not all the samples can fit in a single bank, so they span 3 banks. The pointers are repeated at all 3 indexes, but only the defined samples for the index (listed above) will be in the relevant ROM bank.

DAC Sample Setup Format

The format for a DAC sample entry is pretty simple. Follow along:

Offset Size Function
$00 Byte Sample rate/pitch. The lower the value, the faster the sample will play.
$01-$02 Word Size of the DAC sample, in bytes.
  • NOTE: Value is little endian, so remember to swap the bytes to get the real value.
$03-$04 Word Pointer to the DAC sample, within the current bank.
  • NOTE: Value is little endian, so remember to swap the bytes to get the real value.

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.

Flag Purpose
$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???
$E2FF Fade-in to previous song (needed on DAC channel, Sonic 3 & etc)
$E3 Return (Sonic 1 & 2)
$E4 Fade-in to previous song (needed on DAC channel, Sonic 1 & 2)
$E5xx Change tempo divider to xx
$E6xx Change channel volume by 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 to xx; xx is signed
$EE Something with Voice Selection
$EFxx Change current voice to xx
  • 00 is the first voice in the bank. So in other words, subtract 01 from the value to get the voice in the bank you want.
$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
$F7xxyyzzzz Repeat section of music
  • xx - Loop index, for loops within loops without confusing the engine.
    • EXAMPLE: Some notes, then a section that is looped twice, then some more notes, and finally the whole thing is looped three times.
      The "inner" loop (the section that is looped twice) would have an xx of 01, looking something along the lines of F70102zzzz, whereas the "outside" loop (the whole thing loop) would have an xx of 00, looking something like F70003zzzz.
  • yy - Number of times to repeat
    • NOTE: This includes the initial encounter of the F7 flag, not number of times to repeat AFTER hitting the flag.
  • zzzz - Position to loop back to
$F8yyyy Jump to position yyyy (keep previous position in memory for returning)
$F9 Return (Sonic 3 & etc)
$FBxx Add xx to channel key (Sonic 3 & etc)

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 equivalents 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

Notes on $E0

Only FM and DAC channels can be panned, the PSG channels will ignore this flag. In Sonic 1, if the sixth channel (either FM6 or the DAC) of your Game Over song is panned, the SEGA sound after the reset will be panned as well.

Further Explanation

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. It works by taking a base address - generally the start of a music bank - and, for each increment of the value, it reads ahead another word in the current ROM bank. So, say, $00 would be the first word in the bank ($00-$01), $01 would be the next ($02-$03), and so on. The base address for this bank, in both Sonic 2 Beta AND final, is $F0000, and the addressing range spans as far as the value can allow, which is two Z80 ROM banks ($10000 bytes).

However, as a simple guide to understanding how it works (at least, for the casual hacker), all values for the original, untouched music (for the most part, anyway) 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 (visually, anyway - the game still uses $80 > values internally) in the final version of the game. The only exception to this is in Sonic 2 Beta, where some songs use the upper $8000 bytes of the bank start address to store music (making the values for calling said music start with $00). The locations for the master playlist are as follows:

  • Master Playlist in Sonic 2 Beta: $ECE9F
  • Master Playlist in Sonic 2 Final: $ECF36

As previously mentioned, 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 - these are compression bytes for the driver, and touching them will bork the decompressor in-game, and prevent the sound driver from booting. The "master playlist" is only in Sonic 2 (Beta/Final) 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.

Sonic 3

Universal Voice Bank

In Sonic 3, some games have the value "$D817" as their voice pointer. When a song has this in its voice pointer, that means it's being prepped to use a global set of multiple voices that any song in the game can use. This is generally used to save space for songs that use the same voices. Interestingly enough, though, the Special Stage music has the first 5 voices used in the Universal Voice Bank, and all in the same order, so it's puzzling why they didn't just have the song use the bank (as it's fully capable of doing so).

  • Universal Voice Bank in Sonic 3: $E77D8
Universal Voice Bank definitions

Using the Universal Voice Bank is akin to using voices in a normal song - each voice has a value, defined by coordination flag $EF. Here are some of the voices used in the Universal Voice Bank.

Value Description
$00 Synth Bass 2
$01 Trumpet 1
$02 Slap Bass 2
$03 Synth Bass 1
$04 Bell Synth 1
$05 Bell Synth 2
$06 Synth Brass 1
$07 Synth like Bassoon
$08 Bell Horn type thing
$09 Synth Bass 3
$0A Synth Trumpet
$0B Wood Block
$0C Tubular Bell
$0D Strike Bass
$0E Elec Piano
$0F Bright Piano
$10 Church Bell
$11 Synth Brass 2
$12 Bell Piano
$13 Wet Wood Bass
$14 Silent Bass
$15 Picked Bass
$16 Xylophone
$17 Sine Flute
$18 Pipe Organ
$19 Synth Brass 2
$1A Harpischord
$1B Metallic Bass
$1C Alternate Metallic Bass
$1D Backdropped Metallic Bass
$1E Sine like Bell
$1F Synth like Metallic with Small Bell.
$20 Nice Synth like lead.
$21 Rock Organ
$22 Strike like Slap Bass

Realtime Music Editing

By editing values in savestates, you can edit music, pointers and other various values in realtime. Re-load the savestate to see your changes applied!

Sonic 3/Sonic & Knuckles

Offset Z80 RAM Location Purpose
$001A8C 1618 Music Pointers (Sonic & Knuckles)
$001A8E 161A Music Pointers (Sonic 3)
$001778 1304 Pointer for Music Pointers
$000FD9 0B65 Music Bank IDs (Sonic & Knuckles)
$000FBC 0B48 Music Bank IDs (Sonic 3)
$00177A 1306 Pointer for Sound Effect Pointers
$001AF2 167E Sound Effect Pointers

Sonic 3D

Offset Z80 RAM Location Purpose
$001AD0 165C Music Pointers
$001778 1304 Pointer for Music Pointers
$00177A 1306 Pointer for Sound Effect Pointers
$001AD0 165C Music Pointers
$001B34 16C0 Sound Effect Pointers

Sonic 2 Final

Offset Z80 RAM Location Purpose
$001669 11F5 Master Playlist
$000C16 07A2 Pointer for Master Playlist
$000DF9 0985 Pointer for Sound Effects list

Games That Use The Engine

This sound engine isn't specific to only the Sonic games - many other games use this sound engine as well. The "official" name for this sound system is called SMPS, or the Sample Music Playback System.

There are two derivatives of the system - one is the driver that runs on the Z80 processor, and the other runs on the 68k. 68k games will use relative pointers internally (with absolute music pointers), while the Z80 games will use Z80 bank addressing. Keep this in mind when searching for music data within games.

Game List

Game Name SMPS Version
A Ressha de Ikou MD SMPS 68k
Aa Harimanada SMPS 68k
Advanced Daisenryaku SMPS Z80
Air Buster (Aero Blasters) SMPS Z80
Alex Kidd in the Enchanted Castle SMPS Z80
Alien Soldier SMPS/Treasure
Alien Storm SMPS Z80
Arrow Flash SMPS Z80
Art of Fighting (Ryuuko no Ken) SMPS Z80
Atomic Robo-Kid SMPS Z80 (banked)
ATP Tour Championship Tennis SMPS Z80
Ayrton Senna's Super Monaco GP II SMPS 68k
Bahamut Senki SMPS 68k
Battle Golfer Yui SMPS 68k
Battletoads SMPS Z80
Bishoujo Senshi Sailor Moon SMPS 68k
Bonanza Brothers SMPS Z80
Cadash SMPS Z80
Castle of Illusion SMPS Z80
Chou Yakyuu Miracle Nine SMPS Z80/mod
Columns SMPS Z80
Columns III SMPS Z80
Crayon Shin-Chan SMPS 68k
Cyberball SMPS Z80
Dahna: Megami Tanjou SMPS Z80
Dangerous Seed SMPS Z80
Dick Tracy SMPS Z80
DJ Boy SMPS Z80
Doraemon: Yume Dorobouto 7-nin no Gozansu SMPS 68k
Dragon's Eye Plus: Shanghai 3 SMPS 68k
Dyna Brothers SMPS Z80 (banked)
Dyna Brothers 2 SMPS Z80 (banked)
Dynamite Duke SMPS Z80
Dynamite Headdy SMPS/Treasure
ESWAT Cyber Police SMPS Z80
F1 Circus MD SMPS Z80
Fatal Fury (Garou Densetsu) SMPS 68k
Fatal Fury 2 (Garou Densetsu 2) SMPS 68k
Fatal Labyrinth SMPS Z80
Fighting Masters SMPS Z80
Flicky SMPS Z80
Gain Ground SMPS Z80
Game no Kandzume Otokuyou SMPS Z80
Ghostbusters SMPS Z80
Golden Axe II SMPS 68k
Golden Axe III SMPS 68k
Gouketsuji Ichizoku SMPS Z80/mod
Growl (Runark) SMPS Z80
Gunstar Heroes SMPS/Treasure
Honoo no Toukyuuji Dodge Danpei SMPS Z80
J.League Pro Striker/Perfect Edition SMPS Z80
J.League Pro Striker 2 SMPS Z80
King of the Monsters SMPS Z80
King of the Monsters 2 SMPS Z80
Light Crusader SMPS/Treasure
Magical Hat no Buttobi Turbo! Daibouken SMPS Z80
Magical Taruruuto-kun SMPS 68k
Marvel Land (Talmit's Adventure) SMPS Z80
Mazin Saga (Mazin Wars) SMPS Z80
McDonald's Treasure Land Adventure SMPS/Treasure
Mega Anser SMPS Z80
Mega Games 2/3 menu SMPS 68k
Mega Man - The Wily Wars SMPS Z80 (Banked)
Mega Q: Party Quiz SMPS 68k
Mercs (Senjou no Ookami II) SMPS Z80
Metal Fangs SMPS 68k
Michael Jackson's Moonwalker SMPS 68k
Mighty Morphin' Power Rangers SMPS Z80
Mighty Morphin' Power Rangers: The Movie SMPS 68k
Mystic Defender (Kujaku Ou II) SMPS 68k
Nekketsu Koukou Dodgeball Bu Soccer Hen MD SMPS 68k
OutRun SMPS Z80
OutRun 2019 SMPS Z80
OutRunners SMPS Z80
Pat Riley Basketball (Super Real Basketball) SMPS Z80
Phantasy Star III: Generations of Doom SMPS Z80
Phantasy Star: The End of the Millenium SMPS 68k
Pro Striker Final Stage SMPS Z80/mod
Pulseman SMPS 68k/mod
Puzzle & Action: Ichidant-R SMPS Z80
Puzzle & Action: Tant-R SMPS Z80
QuackShot SMPS Z80
Rastan Saga II SMPS Z80
Ristar SMPS 68k/mod
Saint Sword SMPS Z80
Samurai Shodown (Samurai Spirits) SMPS 68k
Sangokushi Retsuden SMPS Z80
Shadow Dancer: The Secret of Shinobi SMPS 68k
Shinobi III (The Super Shinobi II) SMPS 68k
Shogi no Hoshi SMPS Z80
Shura no Mon SMPS Z80
Slam Dunk SMPS Z80
Sonic & Knuckles SMPS Z80/mod
Sonic 3D Blast (Sonic 3D Flickies' Island) SMPS Z80
Sonic the Hedgehog SMPS 68k
Sonic the Hedgehog 2 SMPS Z80/mod
Sonic the Hedgehog 3 SMPS Z80/mod
Sorcerian SMPS Z80 (banked)
Streets of Rage (Bare Knuckle) SMPS 68k/mod
Strider (Strider Hiryuu) SMPS 68k
Super League '91 SMPS Z80
Super Monaco GP SMPS Z80
Surging Aura SMPS Z80
Syd of Valis (Valis SD) SMPS Z80
Tecmo Cup (Captain Tsubasa) (beta) SMPS Z80
Tecmo World Cup SMPS Z80
The Hybrid Front SMPS Z80
The Revenge of Shinobi (The Super Shinobi) SMPS 68k
Toki: Going Ape Spit (JuJu Densetsu) SMPS 68k
Ultimate Qix (Volfied) SMPS Z80
Viewpoint SMPS Z80
Virtua Fighter 2 SMPS Z80
Virtua Racing SMPS Z80 (banked)
Wani Wani World SMPS Z80
Whip Rush SMPS Z80
Wimbledon Championship Tennis SMPS Z80
World of Illusion SMPS Z80
Yuu Yuu Hakusho Gaiden SMPS Z80
Yuu Yuu Hakusho: Makyou Touitsusen SMPS/Treasure
32x Games:
Cosmic Carnage (Cyber Brawl) SMPS 68k
Knuckles' Chaotix SMPS Z80/mod
Metal Head SMPS 68k
Shadow Squadron (Stellar Assault) SMPS 68k
Tempo SMPS Z80/mod
Virtua Racing Deluxe SMPS 68k
Zaxxon's Motherbase 2000 (Parasquad) SMPS Z80

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
    • Specifics...
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
    • Specifics...
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
    • Specifics...
Sound ID Song Location
$81 Electoria $10000
$82 Walkin' $1088C
$83 Hyper-Hyper $10BDA
$84 Evening Star $11210
$85 Moonrise $1172B
$86 Game Over $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 $F8000): $E767E

Sonic 3D

  • Music Pointers (These add to $C0000): $D3233
  • Music Pointers (These add to $C8000): $D3245
  • Music Pointers (These add to $D0000): $D325D
    • Specifics...
Music ID Music Pointer Song name
These add to $C0000:
01 2480 Green Grove 1
02 8F91 Green Grove 2
03 A0A8 Rusty Ruin 1
04 E7B9 Rusty Ruin 2
05 95C7 Volcano Valley 2
06 4AD0 Volcano Valley 1
07 39D7 Spring Stadium 1
08 72E3 Spring Stadium 2
09 91F0 Diamond Dust 1
These add to $C8000:
0A 2480 Diamond Dust 2
0B DE8B Gene Gadget 1
0C BD96 Gene Gadget 2
0D A8A0 Panic Puppet 2
0E E0A8 The Final Fight
0F B396 Ending
10 55BB Bonus Stage
11 8FC6 Panic Puppet 1/Level Select Screen
12 12D0 Boss Theme 1
13 20D6 Boss Theme 2
14 98DD Intro
15 D9E1 Credits
These add to $D0000:
16 2480 Game Over
17 7F82 Congratulations: You have found the secret Level Select screen" screen
18 9886 Bonus Stage End
19 158B Extra Life
1A 658C Chaos Emerald Gain
1B 558D Invincibility
1C 2791 Main Menu
  • 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
Address Song
$40000 Door Into Summer
$40D61 Electoria
$41904 Speed of Sound
$428a6 Seascape
$4349a Midnight Greenhouse
$44220 New Moon
$4509c Labyrinth
$4536b Trial and Error
$45DEE Walkin'
$461be Hyper-Hyper
$468e5 Evening Star
$46Fe8 Moonrise
$474e3 Overture
$477f0 This Horizon
$48000 Take Off
$4836a Combination
$48a39 Take a Nap
$48c96 Surging Power
$4915d Mechanical Dance
$4951d Tube Panic
$49fb0 Crystal Nightmare
$4a58c Child's Song
$4ac3c Soda Pop
$4b082 Pendulum
$4b6f5 Silver Screen
$4bBFF Tachy Touch
$4c44e Chaotic World
$4c8fa Surprise!
$4cd0d Nice Meeting You
$4d0ef Have a Happy Day
$4d34c Reach the Goal
$4d53f High Five
$4d67a Decision
$4d81d From Party to Party
$4d9f4 Have Some Fun
$4dc41 Oriental Legend
$4e33d Steel Heart
$50000 Tribute
$509ac Destructive Power
$50c6a Just Another Day
$5400b Decision 2nd
  • 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
  • NOTE: 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 ICZ1
0C 8000 ICZ2
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
  • Sound Effect Pointers (These add to $F8000): $F79AD
    • Specifics...
Sound Test ID Pointer Value
$33 DE30
$34 DE5E
$35 DE6F
$36 DEA1
$37 DEC5
$38 DEF4
$39 DF2A
$3A DF6B
$3B DF96
$3C DFE5
$3D E023
$3E E05D
$3F E088
$40 E0AB
$41 E0CE
$42 E0F1
$43 E109
$44 E122
$45 E14F
$46 E177
$47 E1A4
$48 E1C4
$49 E1DE
$4A E206
$4B E22E
$4C E278
$4D E2A2
$4E E2CF
$4F E313
$50 E322
$51 E35A
$52 E38B
$53 E3A8
$54 E3E8
$55 E42B
$56 E453
$57 E463
$58 E481
$59 E49A
$5A E4F6
$5B E523
$5C E530
$5D E558
$5E E581
$5F E5B2
$60 E5DA
$61 E61B
$62 E64C
$63 E662
$64 E68C
$65 E6AB
$66 E6E1
$67 E730
$68 E75C
$69 E7B0
$6A E7DD
$6B E811
$6C E823
$6D E833
$6E E852
$6F E886
$70 E896
$71 E8E0
$72 E8EA
$73 E917
$74 E94B
$75 E978
$76 E9A7
$77 E9D1
$78 EA1B
$79 EA48
$7A EA93
$7B EAC7
$7C EAF7
$7D EB28
$7E EB55
$7F EB6D
$80 EB8B
$81 EBBA
$82 EC05
$83 EC32
$84 EC7E
$85 ECAB
$86 ECD8
$87 ED05
$88 ED3B
$89 ED68
$8A ED75
$8B EDA9
$8C EDDF
$8D EE10
$8E EE2A
$8F EE5B
$90 EE91
$91 EEC3
$92 EEF9
$93 EF2D
$94 EF77
$95 EFA6
$96 EFD5
$97 F009
$98 F01C
$99 F068
$9A F090
$9B F0AF
$9C F114
$9D F14B
$9E F17F
$9F F1C0
$A0 F1FC
$A1 F214
$A2 F23C
$A3 F274
$A4 F2A1
$A5 F2CE
$A6 F2FB
$A7 F313
$A8 F33B
$A9 F365
$AA F38F
$AB F3EA
$AC F42A
$AD F49C
$AE F4AB
$AF F4DA
$B0 F507
$B1 F582
$B2 F5D7
$B3 F603
$B4 F67D
$B5 F6AA
$B6 F6D2
$B7 F713
$B8 F745
$B9 F76C
$BA F794
$BB F7BE
$BC F7CE
$BD F7F9
$BE F837
$BF F86A
$C0 F89C
$C1 F8D1
$C2 F907
$C3 F91E
$C4 F94E
$C5 F97E
$C6 F9B7
$C7 F9F2
$C8 FA21
$C9 FA2B
$CA FA66
$CB FA9C
$CC FAD7
$CD FB12
$CE FB45
$CF FB60
$D0 FB6A
$D1 FBA1
$D2 FBBE
$D3 FBF4
$D4 FC2D
$D5 FC64
$D6 FC9D
$D7 FCCE
$D8 FCFF
$D9 FD32
$DA FD62
$DB FD94
$DC FD94
$DD FD94
$DE FD94
$DF FD94

Ristar

  • Music Pointers (32-bit): C852A
    • Specifics...
Address Song
$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
    • Specifics...
Offset ID Song
$63588 81 Smooth Criminal
$63DAE 82 Beat It
$64614 83 Another Part of Me
$64FEA 84 Billy Jean
$65726 85 Bad
$65D5C 86 Moonwalker Title SFX
$65E22 87 "Some Cool SFX" (lol Oerg)
$65E96 88 Boss Appears
$66300 89 Smooth Criminal Dance
$66488 8A Smooth Criminal Dance

Gunstar Heroes

  • Music Pointers (32-bit): $68F42
    • Specifics...
Offset ID Song
$68F42 81 Stage 1 - Village
$68F46 82 Completion fanfare
$68F4A 83 VS. Pinky Roader
$68F4E 84 VS. Orange
$68F52 85 Stage 2 - The Mine
$68F56 86 VS. Bravoo Man
$68F5A 87 Stage 3 - Airship (Also used in other in-game locations.)
$68F5E 88 VS. Green/Seven Force
$68F62 89 Stage 5 - The Empire
$68F66 8A Stage 4 - Black's Silly Dice Maze
$68F6A 8B Title Screen
$68F6E 8C Ending Cutscene
$68F72 8D Stage 6 - Empire's Spaceship
$68F76 8E Stage Complete
$68F7A 8F Crisis theme
$68F7E 90 VS. Black
$68F82 91 VS. Smash Daisaku
$68F86 92 VS. Empire's Spaceship core
$68F8A 93 Intro
$68F8E 94 VS. Golden Silver
$68F92 95 Briefing/Level Select
$68F96 96 Credits
$68F9A 97 Game Over
$68F9E 98 Options tune/Final Stage
$68FA2 99 Continue?
$68FA6 9A (not on sound test) Airship
$68FAA 9B (not on sound test) Options

Crayon Shin-Chan

  • Music Pointers (32-bit): $1301EC

Dynamite Headdy

  • Music Pointers (32-bit): $5E536

Alien Soldier

  • Music Pointers (32-bit): $84E78

Phantasy Star 3

  • Music Pointers (These add to $6800): $70376

Phantasy Star 4

  • Music Pointers (32-bit): $D1C40

Pulseman

  • Music Pointers (32-bit): $601A6

The Hybrid Front

  • Music Pointers (These add to $60000): $63AFA
  • Sound Effect Pointers (These add to $68000): $63B2A
    • Specifics...
ID Pointer Song
$81 8000 Opening Theme ~ Title
$82 8FB1 Tactics Preparation
$83 951D Earth ~ Rebellion Fight BGM 1
$84 9CF6 Turn Start
$85 9D8F Prologue
$86 9EBD Combat Scenario
$87 A306 Earth ~ Sukarabe Fight BGM 1
$88 8030 Title (no opening)
$89 A99A Earth ~ Rebellion Fight BGM 2
$8A 892F Earth ~ PETO Fight BGM 1
$8B 935B Game Over
$8C 9578 At the End of Combat
$8D 98BC Earth ~ Sukarabe Fight BGM 2
$8E A271 Earth ~ Sukarabe Fight BGM 3
$8F A973 Earth ~ PETO Fight BGM 2
$90 B2A4 Ending Theme
$91 BDE2 Staff Roll
$92 C6A0 Moon - Mars ~ Sakurabe Fight BGM 3
$93 CD49 Moon - Mars ~ Sakurabe Fight BGM 1
$94 D345 Moon - Mars ~ Sakurabe Fight BGM 2
$95 DA73 Moon - Mars ~ Cocoon Fight BGM 2
$96 E2DF Moon - Mars ~ Cocoon Fight BGM 1
$97 EA42 Moon - Mars ~ PETO Fight BGM 2
$98 ED86 Moon - Mars ~ PETO Fight BGM 1

Dyna Brothers 2

  • Music Pointers (These add to $1D0000): $1D01DF

Revenge of Shinobi

  • Music Pointers (32-bit): $74770
  • Sound Effect Pointers (32-bit): $747EC

Dick Tracy

  • Music Pointers (These add to $78000): $78236

Ghostbusters

  • Music Pointers (These add to $78000): $78268

Castle of Illusion

  • Music Pointers (These add to $70000): $7008D

Mystic Defender

  • Music Pointers (These add to $48000): $482AA

ESWAT Cyber Police

  • Music Pointers (These add to $18000): $18326

Dangerous Seed

  • Music Pointers (These add to $70000): $7823F

Viewpoint

  • Music Pointers (These add to $10000): $10237

Alien Storm

  • Music Pointers (These add to $78000): $78064

Cosmic Carnage

  • Music Pointers (32-bit): $82AAC
    • NOTE: Cosmic Carnage is 32x, so $900000 is added to each pointer.

Columns III

  • Music Pointers (These add to $70000): $70255

Stellar Assault (Shadow Squadron)

  • Music Pointers (32-bit): $C2868
    • NOTE: Shadow Squadron is 32x, so $900000 is added to each pointer.

Virtua Racing Deluxe (U)

  • Music Pointers (32-bit): $32AB7
    • NOTE: "8B" at start of pointers resolves to $30000.

Zaxxon's Motherbase 2000

  • Music Pointers (These add to $78000): $1F7E
  • Music Pointers (These add to $70000): $1F9E
  • Sound Effect Pointers (These add to $78000): $1FAE

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.

Porting from Sonic 2 Beta to Sonic 3K/3D/Crackers/Chaotix

This is a very simple job, provided you have a good eye for detail. The trick is to replace the differing coordination flags between the two games. This is a simple task, and you can do it in two simple steps.

  1. Run a search in the song for coordination flag E3. This is the S2 flag to return. We need to replace this with the Sonic 3K/etc equivalent, F9. Change all valid instances of E3 to F9. This will fix awkward jumps in the song that were hindering porting before.
  1. Run another search in the song for coordination flag E9. This is the S2 flag to add a value to the current channel pitch. We need to replace this with the Sonic 3K equivalent, FB. Change all valid instances of E9 to FB. This will fix certain lagging in some songs, lack of pitch change, and even crashing.

When I mention valid instances, I mean that the values of E9 or E3 are not part of another coordination flag. Make sure you know the format of most coordination flags, as to avoid making fatal mistakes that may destroy your entire port.

Points to note

Some voices may be wrong. You will have to fix this manually, provided you know how.

Porting from Sonic 3K/3D/Crackers/Chaotix to Sonic 2 Beta

Just do the opposite of the method above; replace F9 with E3 and FB with E9.


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