Extend Music Slots in Sonic 1
From Sonic Retro
(Original guide by Mikel and ValleyBell)
NOTE: If you want to extend more music slots starting from $00 to $FF, see this guide here. Also see this guide here for a newer method.
Important note: This guide prefers label names of the Sonic 1 GitHub disassembly, but labels of the 2005 disassembly are also mentioned.
You may notice that in the Sound Test stops on $CF, and can't go any further than $CF. So here are instructions on how to extend the Music Slots to $FF in Sonic 1.
Step 1: editing the sound driver
To start go to Sound_ChkValue, if you see this line:
cmpi.b #$E4,d7
bls.s Sound_E0toE4
Add this under Sound_E0toE4:
cmpi.b #$FF,d7
bls.w Sound_PlayMoreBGM
Then, go to Sound_PlayBGM (Sound_81to9F in the 2005 disassembly), and add this right above Sound_PlayBGM:
Sound_PlayMoreBGM: ; Sound_E5toFF
subi.b #$45, d7 ; map E5-FF range to A0-BA
; fall through to Sound_PlayBGM
Then, go to MusicIndex. At first make sure that Music81 to Music9F are listed. If the list contains only Music81 to Music93, add Music94 to Music9F (and don't forget to define/include those songs).
Then add MusicE5 to MusicFF to the end of the list, after Music9F:
dc.l MusicE5, MusicE6, MusicE7, MusicE8
dc.l MusicE9, MusicEA, MusicEB, MusicEC
dc.l MusicED, MusicEE, MusicEF, MusicF0
dc.l MusicF1, MusicF2, MusicF3, MusicF4
dc.l MusicF5, MusicF6, MusicF7, MusicF8
dc.l MusicF9, MusicFA, MusicFB, MusicFC
dc.l MusicFD, MusicFE, MusicFF
Then search for Music9F:
Music9F: incbin sound\music9F.bin
even
and add these lines:
MusicE5: incbin sound\musicE5.bin
even
MusicE6: incbin sound\musicE6.bin
even
MusicE7: incbin sound\musicE7.bin
even
MusicE8: incbin sound\musicE8.bin
even
MusicE9: incbin sound\musicE9.bin
even
MusicEA: incbin sound\musicEA.bin
even
MusicEB: incbin sound\musicEB.bin
even
MusicEC: incbin sound\musicEC.bin
even
MusicED: incbin sound\musicED.bin
even
MusicEE: incbin sound\musicEE.bin
even
MusicEF: incbin sound\musicEF.bin
even
MusicF0: incbin sound\musicF0.bin
even
MusicF1: incbin sound\musicF1.bin
even
MusicF2: incbin sound\musicF2.bin
even
MusicF3: incbin sound\musicF3.bin
even
MusicF4: incbin sound\musicF4.bin
even
MusicF5: incbin sound\musicF5.bin
even
MusicF6: incbin sound\musicF6.bin
even
MusicF7: incbin sound\musicF7.bin
even
MusicF8: incbin sound\musicF8.bin
even
MusicF9: incbin sound\musicF9.bin
even
MusicFA: incbin sound\musicFA.bin
even
MusicFB: incbin sound\musicFB.bin
even
MusicFC: incbin sound\musicFC.bin
even
MusicFD: incbin sound\musicFD.bin
even
MusicFE: incbin sound\musicFE.bin
even
MusicFF: incbin sound\musicFF.bin
even
If you would try to play songs in the range E5-FF now, they might not always play.
The reason for this is, that the sound priority list has values for sound IDs 81-E4 only.
So go to SoundPriorities (SoundTypes in the 2005 disassembly). The last line of the array is:
dc.b $90,$90,$90,$90,$90 ; $E0
Now add the additional values for sound IDs E5-FF by replacing the line with:
dc.b $90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90 ; $E0
dc.b $90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90,$90 ; $F0
Step 2: extending the sound test
Next, we are going to extend the slots in the Sound Test. First go to LevSel_SndTest, and change:
moveq #$4F,d0 ; if sound test moves below 0, set to $4F
To:
moveq #$7F,d0 ; if sound test moves below 0, set to $7F
Then, go to LevSel_Right, and change:
cmpi.w #$50,d0
To:
cmpi.w #$80,d0
Last but not least, we are going to allow the Sound Test to read slots $E5 to $FF, so go to LevSel_NoCheat, and comment all lines until LevSel_PlaySnd out. (It should be 4 instructions.)
Then, build the rom and check out your newly added tunes.