Actions

SCHG How-to

Difference between revisions of "Port Sonic 1's Sound Driver to Sonic 2"

From Sonic Retro

m (tabbing fixed)
m
 
(25 intermediate revisions by 12 users not shown)
Line 1: Line 1:
''(Original guide by [[Tweaker]])''
+
{{GuideBy|Tweaker}}
 
==Introduction==
 
==Introduction==
For anyone who's worked with ''[[Sonic 2]]'' before, you'll notice that managing music can be a bit of a hassle. Music has to be in a specific location, has to stay within a certain sound bank... and there's a limited number of sounds you can have in the game. However, the sound driver in ''[[Sonic 1]]'' is entirely written in 68k (except for the DAC driver), making it much easier to edit, and much easier to manage music with. You can place music data anywhere, as the pointers use relative addressing, and there are no limitations on where you can place music data.
+
For anyone who's worked with ''[[Sonic 2]]'' before, you'll notice that managing music can be a bit of a hassle. Music has to be in a specific location, has to stay within a certain sound bank... and there's a limited number of sounds you can have in the game. However, the sound driver in ''[[Sonic 1]]'' is entirely written in 68k (except for the DAC driver), making it much easier to edit, and much easier to manage music with. There are no limitations on where you can place music data, as the pointers use relative addressing.
  
So, when [[Puto]] comes to me with his own port of the ''Sonic 1'' sound driver, and said he had problems, I showed him a personal port that [[Esrael]] made for ''[[Sonic 2 Megamix]]''. Together, we were able to fully patch up all the issues that the driver has when ported to ''Sonic 2''. Therefore, we decided we'd make a guide, that, when followed correctly, allows anybody to use the ''Sonic 1'' sound driver in their hack! Included below is the ''Sonic 1'' sound driver in its own separate ASM file, which you can edit freely, along with the original folder structure for the sound driver's music data, sound data, etc.
+
So, when [[User:Puto|Puto]] comes to me with his own port of the ''Sonic 1'' sound driver, and said he had problems, I showed him a personal port that [[User:Esrael|Esrael]] made for ''[[Sonic 2 Megamix]]''. Together, we were able to fully patch up all the issues that the driver has when ported to ''Sonic 2''. Therefore, we decided we'd make a guide, that, when followed correctly, allows anybody to use the ''Sonic 1'' sound driver in their hack! Included below is the ''Sonic 1'' sound driver in its own separate ASM file, which you can edit freely, along with the original folder structure for the sound driver's music data, sound data, etc.
  
 
Anyway, on with the guide!
 
Anyway, on with the guide!
 +
 +
'''This doesn't seem to work in Kega Fusion.'''
  
 
==Instructions==
 
==Instructions==
Okay, first we're going to get the actual driver to load. Go to loc_45E, which should be this:
+
Okay, first we're going to get the actual driver to load. Go to VintRet, which should be this:
<asm>loc_45E:; CODE XREF: ROM:000004C2�j
+
<pre>VintRet:
; ROM:00000562�j ...
+
addq.l #1,($FFFFFE0C).w
addq.l #1,($FFFFFE0C).w
+
movem.l (sp)+,d0-a6
movem.l (sp)+,d0-a6
+
rte</pre>
rte</asm>
 
  
 
And change it to this...
 
And change it to this...
<asm>loc_45E:; CODE XREF: ROM:000004C2�j
+
<pre>VintRet:
; ROM:00000562�j ...
+
jsr Init_Sonic1_Sound_Driver ; init Sonic 1 sound driver
jsr Init_Sonic1_Sound_Driver; Esrael L. G. Neto
+
addq.l #1,($FFFFFE0C).w
addq.l #1,($FFFFFE0C).w
+
movem.l (sp)+,d0-a6
movem.l (sp)+,d0-a6
+
rte</pre>
rte</asm>
 
  
Next, go to sub_130A, which should be this:
+
Next, go to JmpTo_SoundDriverLoad, which should be this:
<asm>sub_130A:; CODE XREF: ROM:00000386�p
+
<pre>JmpTo_SoundDriverLoad
nop
+
nop
jmp loc_EC000
+
jmp (SoundDriverLoad).l
; End of function sub_130A</asm>
+
; End of function JmpTo_SoundDriverLoad</pre>
 
 
And change it to this...
 
<asm>sub_130A:; CODE XREF: ROM:00000386�p
 
nop
 
;jmp loc_EC000
 
move.w  #$0100, ($00A11100); Esrael L. G. Neto Add Sonic 1 Sound Driver
 
move.w  #$0100, ($00A11200); Esrael L. G. Neto Add Sonic 1 Sound Driver
 
lea Kos_Z80, A0; Esrael L. G. Neto Add Sonic 1 Sound Driver
 
lea ($00A00000), A1; Esrael L. G. Neto Add Sonic 1 Sound Driver
 
bsr KozDec_193A; Esrael L. G. Neto Add Sonic 1 Sound Driver
 
move.b  #((SegaPCM>>$10)&$FF), ($00A00019); Esrael L. G. Neto Add Sonic 1 Sound Driver
 
move.w  #$0000, ($00A11200); Esrael L. G. Neto Add Sonic 1 Sound Driver
 
nop ; Esrael L. G. Neto Add Sonic 1 Sound Driver
 
nop ; Esrael L. G. Neto Add Sonic 1 Sound Driver
 
nop ; Esrael L. G. Neto Add Sonic 1 Sound Driver
 
nop ; Esrael L. G. Neto Add Sonic 1 Sound Driver
 
move.w  #$0100, ($00A11200); Esrael L. G. Neto Add Sonic 1 Sound Driver
 
move.w  #$0000, ($00A11100); Esrael L. G. Neto Add Sonic 1 Sound Driver
 
rts ; Esrael L. G. Neto Add Sonic 1 Sound Driver
 
; End of function sub_130A</asm>
 
  
Next, find sub_135E, which should be this:
+
And change the whole surrounding area to this, including the unused Sonic 1 sound driver loading code...
<asm>sub_135E:; CODE XREF: ROM:000037BC�p
+
<pre>JmpTo_SoundDriverLoad
; ROM:0000399C�p ...
+
move.w #$100,(Z80_Bus_Request).l ; stop the Z80
tst.b ($FFFFFFE0).w
+
move.w #$100,(Z80_Reset).l ; reset the Z80
bne.s loc_136A
+
lea (Kos_Z80).l,a0
move.b d0,($FFFFFFE0).w
+
lea (Z80_RAM).l,a1
rts
+
bsr.w KosDec
; ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
+
move.b #$F3,(a1)+
 +
move.b #$F3,(a1)+
 +
move.b #$C3,(a1)+
 +
move.b #0,(a1)+
 +
move.b #0,(a1)+
 +
move.w #0,(Z80_Reset).l
 +
nop
 +
nop
 +
nop
 +
nop
 +
move.w #$100,(Z80_Reset).l ; reset the Z80
 +
move.w #0,(Z80_Bus_Request).l ; start the Z80
 +
rts</pre>
  
loc_136A:; CODE XREF: sub_135E+4�j
+
Next, find PlayMusic, which should be this:
move.b d0,($FFFFFFE4).w
+
<pre>PlayMusic:
rts
+
tst.b (Music_to_play).w
; End of function sub_135E</asm>
+
bne.s +
 +
move.b d0,(Music_to_play).w
 +
rts
 +
+
 +
move.b d0,(Music_to_play_2).w
 +
rts
 +
; End of function PlayMusic</pre>
  
 
And change it to this...
 
And change it to this...
<asm>sub_135E:; CODE XREF: ROM:000037BC�p
+
<pre>PlayMusic:
; ROM:0000399C�p ...
+
move.b d0,($FFFFF00A).w
;tst.b ($FFFFFFE0).w
+
rts
;bne.s loc_136A
+
; End of function PlayMusic</pre>
;move.b d0,($FFFFFFE0).w
 
move.b D0, ($FFFFF00A).w; Esrael L. G. Neto Change Sonic 1 Sound Driver
 
rts
 
; ==============================================================================================
 
 
 
loc_136A:; CODE XREF: sub_135E+4�j
 
;move.b d0,($FFFFFFE4).w
 
move.b D0, ($FFFFF00A).w; Esrael L. G. Neto Change Sonic 1 Sound Driver
 
rts
 
; End of function sub_135E</asm>
 
  
Next find sub_1370, and find this:
+
Next find PlaySound, and find this:
<asm>sub_1370:; CODE XREF: ROM:0000392C�p
+
<pre>PlaySound:
; ROM:00003CB4�p ...
+
move.b d0,(SFX_to_play).w
move.b d0,($FFFFFFE1).w
+
rts
rts
+
; End of function PlaySound</pre>
; End of function sub_1370</asm>
 
  
 
And replace it with this...
 
And replace it with this...
<asm>sub_1370:; CODE XREF: ROM:0000392C�p
+
<pre>PlaySound:
; ROM:00003CB4�p ...
+
move.b d0,($FFFFF00B).w
;move.b d0,($FFFFFFE1).w
+
rts
        move.b D0, ($FFFFF00B).w; Esrael L. G. Neto Change Sonic 1 Sound Driver
+
; End of function PlaySound</pre>
rts
 
; End of function sub_1370</asm>
 
  
Now, we're going to fix the broken sound effects, such as rings. Look for sub_1376. It should be this:
+
Now, we're going to fix the broken sound effects, such as rings. Look for amything that references PlaySoundStereo, and change it to PlayMusic. You can also remove PlaySoundStereo all together.
<asm>sub_1376: ; CODE XREF: sub_11FC2+54�j
 
; sub_11FC2+B0�j ...
 
move.b d0,($FFFFFFE2).w
 
rts
 
; End of function sub_1376</asm>
 
  
Replace it with this:
+
Now, look for PlaySoundLocal. It should be this:
<asm>sub_1376: ; CODE XREF: sub_11FC2+54�j
+
<pre>PlaySoundLocal:
; sub_11FC2+B0�j ...
+
tst.b render_flags(a0)
bra.s sub_135E; branch to normal sfx playing routine
+
bpl.s +
move.b d0,($FFFFFFE2).w
+
move.b d0,(SFX_to_play).w
rts
+
+
; End of function sub_1376</asm>
+
rts
 
+
; End of function PlaySoundLocal</pre>
Now, look for sub_137C. It should be this:
 
<asm>sub_137C:; CODE XREF: sub_FE70+24�p h+B576�p ...
 
tst.b 1(a0)
 
bpl.s locret_1386
 
move.b d0,($FFFFFFE1).w
 
 
 
locret_1386:; CODE XREF: sub_137C+4�j
 
rts
 
; End of function sub_137C</asm>
 
  
 
Replace it with this:
 
Replace it with this:
<asm>sub_137C:; CODE XREF: sub_FE70+24�p h+B576�p ...
+
<pre>PlaySoundLocal:
tst.b 1(a0)
+
tst.b render_flags(a0)
bpl.s locret_1386
+
bpl.s +
;move.b d0,($FFFFFFE1).w
+
move.b d0,($FFFFF00B).w
move.b D0, ($FFFFF00B).w; Esrael L. G. Neto Change Sonic 1 Sound Driver
+
+
 +
rts</pre>
  
locret_1386:; CODE XREF: sub_137C+4�j
+
Next, we're going to fix the music so it stops correctly when you pause. Find the "+" after PauseGame, which should be this:
rts
+
<pre>+
; End of function sub_137C</asm>
+
move.w #1,(Game_paused).w ; freeze time
 
+
move.b #-2,(Music_to_play).w ; pause music</pre>
Next, we're going to fix the music so it stops correctly when you pause. Find loc_13A6, which should be this:
 
<asm>loc_13A6:; CODE XREF: sub_1388+E�j
 
move.w #1,($FFFFF63A).w
 
move.b #-2,($FFFFFFE0).w</asm>
 
  
 
And replace it with this...
 
And replace it with this...
<asm>loc_13A6:; CODE XREF: sub_1388+E�j
+
<pre>+
move.w #1,($FFFFF63A).w
+
move.w #1,(Game_paused).w ; freeze time
;move.b #-2,($FFFFFFE0).w
+
move.b #1,($FFFFF003).w ; pause music</pre>
move.b #$01,($FFFFF003).w; Esrael L. G. Neto Change Sonic 1 Sound Driver - Pause</asm>
 
  
 
Next, go to loc_13F2, which should be this:
 
Next, go to loc_13F2, which should be this:
<asm>loc_13F2:; CODE XREF: sub_1388+4A�j
+
<pre>loc_13F2:
move.b #-1,($FFFFFFE0).w</asm>
+
move.b #-1,(Music_to_play).w</pre>
  
 
And replace it with this...
 
And replace it with this...
<asm>loc_13F2:; CODE XREF: sub_1388+4A�j
+
<pre>loc_13F2:
;move.b #-1,($FFFFFFE0).w
+
move.b #$80,($FFFFF003).w</pre>
move.b #$80,($FFFFF003).w; Esrael L. G. Neto Change Sonic 1 Sound Driver - Pause</asm>
 
  
Now, find loc_1400, which should be this:
+
Now, find Pause_SlowMo, which should be this:
<asm>loc_1400:; CODE XREF: sub_1388+52�j sub_1388+5A�j
+
<pre>Pause_SlowMo:
move.w #1,($FFFFF63A).w
+
move.w #1,(Game_paused).w
move.b #-1,($FFFFFFE0).w
+
move.b #-1,(Music_to_play).w
rts</asm>
+
rts</pre>
  
 
And replace it with this...
 
And replace it with this...
<asm>loc_1400:; CODE XREF: sub_1388+52�j sub_1388+5A�j
+
<pre>Pause_SlowMo:
move.w #1,($FFFFF63A).w
+
move.w #1,(Game_paused).w
;move.b #-1,($FFFFFFE0).w
+
move.b #1,($FFFFF003).w
move.b #$01,($FFFFF003).w; Esrael L. G. Neto Change Sonic 1 Sound Driver - Pause
+
rts</pre>
rts</asm>
 
  
 
Next, find loc_541A, which should be this:
 
Next, find loc_541A, which should be this:
<asm>loc_541A:; CODE XREF: ROM:00005212�j
+
<pre>loc_541A:
; ROM:0000525A�j
+
move.b #-1,(Music_to_play).w
move.b #-1,($FFFFFFE0).w
+
move.b #8,(Delay_Time).w
move.b #8,($FFFFF62A).w
+
bra.w DelayProgram</pre>
bra.w sub_3384</asm>
 
  
 
And replace it with this...
 
And replace it with this...
<asm>loc_541A:; CODE XREF: ROM:00005212�j
+
<pre>loc_541A:
; ROM:0000525A�j
+
move.b #1,($FFFFF003).w
;move.b #-1,($FFFFFFE0).w
+
move.b #8,(Delay_Time).w
move.b #$01,($FFFFF003).w; Esrael L. G. Neto Change Sonic 1 Sound Driver - Pause
+
bra.w DelayProgram</pre>
move.b #8,($FFFFF62A).w
 
bra.w sub_3384</asm>
 
  
Now, we're going to fix the underwater palettes, since the sound driver uses some space in RAM that, in S2, is used for underwater palettes. Do a search and replace (ctrl+h) and replace all instances of "$FFFFF08" with "$FFFFFA8" - what this will do is make the game read from the Sonic 1 location for underwater palettes, which is unused in S2, and unaffected by the sound driver.
+
Now, we're going to fix the underwater palettes, since the sound driver uses some space in RAM that, in S2, is used for underwater palettes. Do a search and replace (ctrl+h) and replace all instances of "$FFFFF080" with "$FFFFFA80" - what this will do is make the game read from the Sonic 1 location for underwater palettes, which is unused in S2, and unaffected by the sound driver.
 +
Also replace $FFFFF000 and $FFFFF0E0 with $FFFFFA00 and $FFFFFAE0 respectively.
  
Next, go to sub_2764. This is the Sonic 2 equivalent of "PalLoad4_Water" in Sonic 1, and what we're going to do is change a line in it to match the Sonic 1 routine, so the underwater palettes load to the correct address. The routine should look like this:
+
Next, go to PalLoad4_Water. What we're going to do is change a line in it to match the Sonic 1 routine, so the underwater palettes load to the correct address. The routine should look like this:
<asm>sub_2764:; CODE XREF: ROM:000042E4�p
+
<pre>PalLoad4_Water:
lea (PalPoint).l,a1
+
lea (PalPointers).l,a1
lsl.w #3,d0
+
lsl.w #3,d0
adda.w d0,a1
+
adda.w d0,a1
movea.l (a1)+,a2
+
movea.l (a1)+,a2
movea.w (a1)+,a3
+
movea.w (a1)+,a3
suba.l #$B00,a3
+
suba.l #$B00,a3
move.w (a1)+,d7
+
move.w (a1)+,d7
  
loc_277A:; CODE XREF: sub_2764+18�j
+
- move.l (a2)+,(a3)+
move.l (a2)+,(a3)+
+
dbf d7,-
dbf d7,loc_277A
+
rts
rts
+
; End of function PalLoad4_Water</pre>
; End of function sub_2764</asm>
 
  
 
Change it to this:
 
Change it to this:
<asm>sub_2764:; CODE XREF: ROM:000042E4�p
+
<pre>PalLoad4_Water:
lea (PalPoint).l,a1
+
lea (PalPointers).l,a1
lsl.w #3,d0
+
lsl.w #3,d0
adda.w d0,a1
+
adda.w d0,a1
movea.l (a1)+,a2
+
movea.l (a1)+,a2
movea.w (a1)+,a3
+
movea.w (a1)+,a3
suba.l #$80,a3
+
suba.l #$80,a3
move.w (a1)+,d7
+
move.w (a1)+,d7
  
loc_277A:; CODE XREF: sub_2764+18�j
+
- move.l (a2)+,(a3)+
move.l (a2)+,(a3)+
+
dbf d7,-
dbf d7,loc_277A
+
rts
rts
+
; End of function PalLoad4_Water</pre>
; End of function sub_2764</asm>
 
  
 
What this does is change how much the game subtracts from $FB00, in order to calculate the location to move underwater palettes to.
 
What this does is change how much the game subtracts from $FB00, in order to calculate the location to move underwater palettes to.
 
The last thing we have to do in order to fix underwater palettes for good is to change a VDP instruction, which is what changes the palette fully to the underwater pallete once you're deep enough underwater, and the raster effects are no longer in effect. Do a search and replace for "-$69076AC0" and replace all instances of it with "$96FD9540" - this will make sure that when you're deep enough underwater, the correct palette is loaded.
 
  
 
The final step is to grab a slightly modified version of the Sonic 1 sound driver from Hivebrain's 2005 Sonic 1 disassembly (link below), and insert it into the Sonic 2 disassembly - the location does not matter, though I personally recommend the end of the ROM. You can also delete the Sonic 2 sound driver now, if you wish, though it is not required to do so.
 
The final step is to grab a slightly modified version of the Sonic 1 sound driver from Hivebrain's 2005 Sonic 1 disassembly (link below), and insert it into the Sonic 2 disassembly - the location does not matter, though I personally recommend the end of the ROM. You can also delete the Sonic 2 sound driver now, if you wish, though it is not required to do so.
Line 221: Line 180:
  
 
===Note===
 
===Note===
Certain sound effects and music from Sonic 2 WILL be missing, and you WILL need to add these yourself if you wish to still have them in game. To add a sound effect/music, simply tack it at the end of SoundIndex or MusicIndex. You can also get rid of SoundD0Index (and related setup) if you wish, as Sonic 2 does not have any sound effects that require it. Kega may also mess up a tad bit, not sure why - if anyone can figure it out, let us know.
+
Certain sound effects and music from Sonic 2 WILL be missing, and you WILL need to add these yourself if you wish to still have them in game. To add a sound effect/music, simply tack it at the end of SoundIndex or MusicIndex. You can also get rid of SoundD0Index (and related setup) if you wish, as Sonic 2 does not have any sound effects that require it.
 
 
Also, Sega sound is garbled. If you want to use it, either use a custom song, or figure out how to get it working. If anyone figures out how to do the latter, it would be appreciated if you shared your methods.
 
  
 
==Sound Driver Files==
 
==Sound Driver Files==
{{Download|file=S1SoundDriverFiles.zip|filesize=63kb|title=the Sonic 1 sound driver files}}
+
{{Download|file=S1SoundDriverFiles.zip|filesize=63kb|title=The Sonic 1 sound driver files|plural=1}}
  
 
==Credits==
 
==Credits==
*[[Varion Icaria]] - Puto's sound driver port.
+
*[[User:Varion Icaria|Varion Icaria]] - Puto's sound driver port.
*[[Esrael]] - My driver port, plus fixes for things broken in Puto's port, such as hanging on the title card. Extra thanks for fixing the Sega sound.
+
*[[User:Esrael|Esrael]] - My driver port, plus fixes for things broken in Puto's port, such as hanging on the title card. Extra thanks for fixing the Sega sound.
*[[Puto]] - Fixes for underwater palette stuff, as well as special stage ring stuff, and various other fixes.
+
*[[User:Puto|Puto]] - Fixes for underwater palette stuff, as well as special stage ring stuff, and various other fixes.
*[[StephenUK]] - Hints on how to fix the underwater stuff.
+
*[[User:StephenUK|StephenUK]] - Hints on how to fix the underwater stuff.
*[[drx]] - Hacking CulT's VDP calculator.
+
*[[User:Drx|drx]] - Hacking CulT's VDP calculator.
*[[Tweaker|Myself]] - I helped Puto fix the underwater stuff, and I wrote the guide. =P
+
*[[User:Tweaker|Myself]] - I helped Puto fix the underwater stuff, and I wrote the guide. =P
  
 
And that's it! Enjoy! Let me or Puto know if there's any issues left, and we'll try and patch them up.
 
And that's it! Enjoy! Let me or Puto know if there's any issues left, and we'll try and patch them up.
  
[[Category:SCHG How-tos]]
+
{{S2Howtos}}
 +
 
 +
|{{PAGENAME}}]]

Latest revision as of 20:45, 12 July 2020

(Original guide by Tweaker)

Introduction

For anyone who's worked with Sonic 2 before, you'll notice that managing music can be a bit of a hassle. Music has to be in a specific location, has to stay within a certain sound bank... and there's a limited number of sounds you can have in the game. However, the sound driver in Sonic 1 is entirely written in 68k (except for the DAC driver), making it much easier to edit, and much easier to manage music with. There are no limitations on where you can place music data, as the pointers use relative addressing.

So, when Puto comes to me with his own port of the Sonic 1 sound driver, and said he had problems, I showed him a personal port that Esrael made for Sonic 2 Megamix. Together, we were able to fully patch up all the issues that the driver has when ported to Sonic 2. Therefore, we decided we'd make a guide, that, when followed correctly, allows anybody to use the Sonic 1 sound driver in their hack! Included below is the Sonic 1 sound driver in its own separate ASM file, which you can edit freely, along with the original folder structure for the sound driver's music data, sound data, etc.

Anyway, on with the guide!

This doesn't seem to work in Kega Fusion.

Instructions

Okay, first we're going to get the actual driver to load. Go to VintRet, which should be this:

VintRet:
	addq.l	#1,($FFFFFE0C).w
	movem.l	(sp)+,d0-a6
	rte

And change it to this...

VintRet:
	jsr	Init_Sonic1_Sound_Driver	; init Sonic 1 sound driver
	addq.l	#1,($FFFFFE0C).w
	movem.l	(sp)+,d0-a6
	rte

Next, go to JmpTo_SoundDriverLoad, which should be this:

JmpTo_SoundDriverLoad 
	nop
	jmp	(SoundDriverLoad).l
; End of function JmpTo_SoundDriverLoad

And change the whole surrounding area to this, including the unused Sonic 1 sound driver loading code...

JmpTo_SoundDriverLoad 
	move.w	#$100,(Z80_Bus_Request).l ; stop the Z80
	move.w	#$100,(Z80_Reset).l ; reset the Z80
	lea	(Kos_Z80).l,a0
	lea	(Z80_RAM).l,a1
	bsr.w	KosDec
	move.b	#$F3,(a1)+
	move.b	#$F3,(a1)+
	move.b	#$C3,(a1)+
	move.b	#0,(a1)+
	move.b	#0,(a1)+
	move.w	#0,(Z80_Reset).l
	nop
	nop
	nop
	nop
	move.w	#$100,(Z80_Reset).l ; reset the Z80
	move.w	#0,(Z80_Bus_Request).l ; start the Z80
	rts

Next, find PlayMusic, which should be this:

PlayMusic:
	tst.b	(Music_to_play).w
	bne.s	+
	move.b	d0,(Music_to_play).w
	rts
+
	move.b	d0,(Music_to_play_2).w
	rts
; End of function PlayMusic

And change it to this...

PlayMusic:
	move.b	d0,($FFFFF00A).w
	rts
; End of function PlayMusic

Next find PlaySound, and find this:

PlaySound:
	move.b	d0,(SFX_to_play).w
	rts
; End of function PlaySound

And replace it with this...

PlaySound:
	move.b	d0,($FFFFF00B).w
	rts
; End of function PlaySound

Now, we're going to fix the broken sound effects, such as rings. Look for amything that references PlaySoundStereo, and change it to PlayMusic. You can also remove PlaySoundStereo all together.

Now, look for PlaySoundLocal. It should be this:

PlaySoundLocal:
	tst.b	render_flags(a0)
	bpl.s	+
	move.b	d0,(SFX_to_play).w
+
	rts
; End of function PlaySoundLocal

Replace it with this:

PlaySoundLocal:
	tst.b	render_flags(a0)
	bpl.s	+
	move.b	d0,($FFFFF00B).w
+
	rts

Next, we're going to fix the music so it stops correctly when you pause. Find the "+" after PauseGame, which should be this:

+
	move.w	#1,(Game_paused).w	; freeze time
	move.b	#-2,(Music_to_play).w	; pause music

And replace it with this...

+
	move.w	#1,(Game_paused).w	; freeze time
	move.b	#1,($FFFFF003).w	; pause music

Next, go to loc_13F2, which should be this:

loc_13F2:
	move.b	#-1,(Music_to_play).w

And replace it with this...

loc_13F2:
	move.b	#$80,($FFFFF003).w

Now, find Pause_SlowMo, which should be this:

Pause_SlowMo:
	move.w	#1,(Game_paused).w
	move.b	#-1,(Music_to_play).w
	rts

And replace it with this...

Pause_SlowMo:
	move.w	#1,(Game_paused).w
	move.b	#1,($FFFFF003).w
	rts

Next, find loc_541A, which should be this:

loc_541A:
	move.b	#-1,(Music_to_play).w
	move.b	#8,(Delay_Time).w
	bra.w	DelayProgram

And replace it with this...

loc_541A:
	move.b	#1,($FFFFF003).w
	move.b	#8,(Delay_Time).w
	bra.w	DelayProgram

Now, we're going to fix the underwater palettes, since the sound driver uses some space in RAM that, in S2, is used for underwater palettes. Do a search and replace (ctrl+h) and replace all instances of "$FFFFF080" with "$FFFFFA80" - what this will do is make the game read from the Sonic 1 location for underwater palettes, which is unused in S2, and unaffected by the sound driver. Also replace $FFFFF000 and $FFFFF0E0 with $FFFFFA00 and $FFFFFAE0 respectively.

Next, go to PalLoad4_Water. What we're going to do is change a line in it to match the Sonic 1 routine, so the underwater palettes load to the correct address. The routine should look like this:

PalLoad4_Water:
	lea	(PalPointers).l,a1
	lsl.w	#3,d0
	adda.w	d0,a1
	movea.l	(a1)+,a2
	movea.w	(a1)+,a3
	suba.l	#$B00,a3
	move.w	(a1)+,d7

-	move.l	(a2)+,(a3)+
	dbf	d7,-
	rts
; End of function PalLoad4_Water

Change it to this:

PalLoad4_Water:
	lea	(PalPointers).l,a1
	lsl.w	#3,d0
	adda.w	d0,a1
	movea.l	(a1)+,a2
	movea.w	(a1)+,a3
	suba.l	#$80,a3
	move.w	(a1)+,d7

-	move.l	(a2)+,(a3)+
	dbf	d7,-
	rts
; End of function PalLoad4_Water

What this does is change how much the game subtracts from $FB00, in order to calculate the location to move underwater palettes to.

The final step is to grab a slightly modified version of the Sonic 1 sound driver from Hivebrain's 2005 Sonic 1 disassembly (link below), and insert it into the Sonic 2 disassembly - the location does not matter, though I personally recommend the end of the ROM. You can also delete the Sonic 2 sound driver now, if you wish, though it is not required to do so.

You can either use the include directive to insert S1 Sound Driver.asm, or you can simply copy/paste what's in there. Either will be sufficient.

Note

Certain sound effects and music from Sonic 2 WILL be missing, and you WILL need to add these yourself if you wish to still have them in game. To add a sound effect/music, simply tack it at the end of SoundIndex or MusicIndex. You can also get rid of SoundD0Index (and related setup) if you wish, as Sonic 2 does not have any sound effects that require it.

Sound Driver Files

Download.svg Download The Sonic 1 sound driver files
File: S1SoundDriverFiles.zip (66 kB) (info)

Credits

  • Varion Icaria - Puto's sound driver port.
  • Esrael - My driver port, plus fixes for things broken in Puto's port, such as hanging on the title card. Extra thanks for fixing the Sega sound.
  • Puto - Fixes for underwater palette stuff, as well as special stage ring stuff, and various other fixes.
  • StephenUK - Hints on how to fix the underwater stuff.
  • drx - Hacking CulT's VDP calculator.
  • Myself - I helped Puto fix the underwater stuff, and I wrote the guide. =P

And that's it! Enjoy! Let me or Puto know if there's any issues left, and we'll try and patch them up.

SCHG How-To Guide: Sonic the Hedgehog 2 (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix Super Sonic Bugs | Use Correct Height When Roll Jumping | Fix Jump Height Bug When Exiting Water | Fix Screen Boundary Spin Dash Bug | Correct Drowning Bugs | Fix Camera Y Position for Tails | Fix Tails Subanimation Error | Fix Tails' Respawn Speeds | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix Rexon Crash | Fix Monitor Collision Bug | Fix EHZ Deformation Bug | Correct CPZ Boss Attack Behavior | Fix Bug in ARZ Boss Arrow's Platform Behavior | Fix ARZ Boss Walking on Air Glitch | Fix ARZ Boss Sprite Behavior | Fix Multiple CNZ Boss Bugs | Fix HTZ Background Scrolling Mountains | Fix OOZ Launcher Speed Up Glitch | Fix DEZ Giant Mech Collision Glitch | Fix Boss Deconstruction Behavior | Fix Speed Bugs | Fix 14 Continues Cheat | Fix Debug Mode Crash | Fix 99+ Lives | Fix Sonic 2's Sega Screen
Design Choices
Remove the Air Speed Cap | Disable Floor Collision While Dying | Modify Super Sonic Transformation Methods & Behavior | Enable/Disable Tails in Certain Levels | Collide with Water After Being Hurt | Retain Rings When Returning at a Star Post | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Insert LZ Water Ripple Effect | Restore Lost CPZ Boss Feature | Prevent SCZ Tornado Spin Dash Death | Improve ObjectMove Subroutines | Port S3K Rings Manager | Port S3K Object Manager | Port S3K Priority Manager | Edit Level Order with ASM‎ | Alter Ring Requirements in Special Stages | Make Special Stage Characters Use Normal DPLCs | Speed Up Ring Loss Process | Change spike behaviour in Sonic 2
Adding Features
Create Insta-kill and High Jump Monitors | Create Clone and Special Stage Monitors | Port Knuckles
Sound Features
Expand Music Index to Start at $00 | Port Sonic 1 Sound Driver | Port Sonic 2 Clone Driver | Port Sonic 3 Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Expand the Music Index to Start at $00 (Sonic 2 Clone Driver Version) | Play Different Songs Per Act
Extending the Game
Extend the Level Index Past $10 | Extend the Level Select | Extend Water Tables | Add Extra Characters | Free Up 2 Universal SSTs


|Port Sonic 1's Sound Driver to Sonic 2]]