Sonic and Sega Retro Message Board: Sonic 1 sound driver in Sonic 2 - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
  • 2 Pages +
  • 1
  • 2
    Locked
    Locked Forum

Sonic 1 sound driver in Sonic 2

#1 User is offline Tweaker 

Posted 08 June 2007 - 04:04 PM

  • Posts: 12389
  • Joined: 27-June 04
  • Gender:Male
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.

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 seperate 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!

---------------------------------------------------

Okay, first we're going to get the actual driver to load. Go to loc_45E, which should be this:
Syntax Highlighted Code: ASM
loc_45E:[color= #adadad; font-style: italic;]; CODE XREF: ROM:000004C2j[/color]
[color= #adadad; font-style: italic;]; ROM:00000562j ...[/color]
[color= #00bfff;]addq[/color].[color= #00bfff;]l[/color] [color= #ff0000;]#[/color][color= #ff0000;]1[/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFFE0C[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]movem[/color].[color= #00bfff;]l[/color] (sp)+,d0-a6
[color= #00bfff;]rte[/color]


And change it to this...
Syntax Highlighted Code: ASM
loc_45E:[color= #adadad; font-style: italic;]; CODE XREF: ROM:000004C2j[/color]
[color= #adadad; font-style: italic;]; ROM:00000562j ...[/color]
[color= #00bfff;]jsr[/color] Init_Sonic1_Sound_Driver[color= #adadad; font-style: italic;]; Esrael L. G. Neto [/color]
[color= #00bfff;]addq[/color].[color= #00bfff;]l[/color] [color= #ff0000;]#[/color][color= #ff0000;]1[/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFFE0C[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]movem[/color].[color= #00bfff;]l[/color] (sp)+,d0-a6
[color= #00bfff;]rte[/color]


Next, go to sub_130A, which should be this:
Syntax Highlighted Code: ASM
sub_130A:[color= #adadad; font-style: italic;]; CODE XREF: ROM:00000386p[/color]
[color= #00bfff;]nop[/color]
[color= #00bfff;]jmp[/color] loc_EC000
[color= #adadad; font-style: italic;]; End of function sub_130A[/color]


And change it to this...
Syntax Highlighted Code: ASM
sub_130A:[color= #adadad; font-style: italic;]; CODE XREF: ROM:00000386p[/color]
[color= #00bfff;]nop[/color]
[color= #adadad; font-style: italic;];jmp loc_EC000[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]w[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color][color= #ff0000;][color= #ff0000;]0100[/color][/color], ([color= #ff0000;]$[/color][color= #ff0000;]00A11100[/color])[color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]w[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color][color= #ff0000;][color= #ff0000;]0100[/color][/color], ([color= #ff0000;]$[/color][color= #ff0000;]00A11200[/color])[color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #00bfff;]lea[/color] Kos_Z80, A0[color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #00bfff;]lea[/color] ([color= #ff0000;]$[/color][color= #ff0000;]00A00000[/color]), A1[color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #00bfff;]bsr[/color] KozDec_193A[color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] [color= #ff0000;]#[/color]((SegaPCM>>[color= #ff0000;]$[/color][color= #ff0000;][color= #ff0000;]10[/color][/color])&[color= #ff0000;]$[/color][color= #ff0000;]FF[/color]), ([color= #ff0000;]$[/color][color= #ff0000;]00A00019[/color])[color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]w[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color][color= #ff0000;][color= #ff0000;]0000[/color][/color], ([color= #ff0000;]$[/color][color= #ff0000;]00A11200[/color])[color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #00bfff;]nop[/color] [color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #00bfff;]nop[/color] [color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #00bfff;]nop[/color] [color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #00bfff;]nop[/color] [color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]w[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color][color= #ff0000;][color= #ff0000;]0100[/color][/color], ([color= #ff0000;]$[/color][color= #ff0000;]00A11200[/color])[color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]w[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color][color= #ff0000;][color= #ff0000;]0000[/color][/color], ([color= #ff0000;]$[/color][color= #ff0000;]00A11100[/color])[color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #00bfff;]rts[/color] [color= #adadad; font-style: italic;]; Esrael L. G. Neto Add Sonic 1 Sound Driver[/color]
[color= #adadad; font-style: italic;]; End of function sub_130A[/color]


Next, find sub_135E, which should be this:
Syntax Highlighted Code: ASM
sub_135E:[color= #adadad; font-style: italic;]; CODE XREF: ROM:000037BCp[/color]
[color= #adadad; font-style: italic;]; ROM:0000399Cp ...[/color]
[color= #00bfff;]tst[/color].[color= #00bfff;]b[/color] ([color= #ff0000;]$[/color][color= #ff0000;]FFFFFFE0[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]bne[/color].[color= #00bfff;]s[/color] loc_136A
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] d0,([color= #ff0000;]$[/color][color= #ff0000;]FFFFFFE0[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]rts[/color]
[color= #adadad; font-style: italic;]; ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ[/color]
 
loc_136A:[color= #adadad; font-style: italic;]; CODE XREF: sub_135E+4j[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] d0,([color= #ff0000;]$[/color][color= #ff0000;]FFFFFFE4[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]rts[/color]
[color= #adadad; font-style: italic;]; End of function sub_135E[/color]


And change it to this...
Syntax Highlighted Code: ASM
sub_135E:[color= #adadad; font-style: italic;]; CODE XREF: ROM:000037BCp[/color]
[color= #adadad; font-style: italic;]; ROM:0000399Cp ...[/color]
[color= #adadad; font-style: italic;];tst.b ($FFFFFFE0).w[/color]
[color= #adadad; font-style: italic;];bne.s loc_136A[/color]
[color= #adadad; font-style: italic;];move.b d0,($FFFFFFE0).w[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] D0, ([color= #ff0000;]$[/color][color= #ff0000;]FFFFF00A[/color]).[color= #00bfff;]w[/color][color= #adadad; font-style: italic;]; Esrael L. G. Neto Change Sonic 1 Sound Driver [/color]
[color= #00bfff;]rts[/color]
[color= #adadad; font-style: italic;]; ================================================================================
====================================================[/color]
 
loc_136A:[color= #adadad; font-style: italic;]; CODE XREF: sub_135E+4j[/color]
[color= #adadad; font-style: italic;];move.b d0,($FFFFFFE4).w[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] D0, ([color= #ff0000;]$[/color][color= #ff0000;]FFFFF00A[/color]).[color= #00bfff;]w[/color][color= #adadad; font-style: italic;]; Esrael L. G. Neto Change Sonic 1 Sound Driver[/color]
[color= #00bfff;]rts[/color]
[color= #adadad; font-style: italic;]; End of function sub_135E[/color]


Next find sub_1370, and find this:
Syntax Highlighted Code: ASM
sub_1370:[color= #adadad; font-style: italic;]; CODE XREF: ROM:0000392Cp[/color]
[color= #adadad; font-style: italic;]; ROM:00003CB4p ...[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] d0,([color= #ff0000;]$[/color][color= #ff0000;]FFFFFFE1[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]rts[/color]
[color= #adadad; font-style: italic;]; End of function sub_1370[/color]


And replace it with this...
Syntax Highlighted Code: ASM
sub_1370:[color= #adadad; font-style: italic;]; CODE XREF: ROM:0000392Cp[/color]
[color= #adadad; font-style: italic;]; ROM:00003CB4p ...[/color]
[color= #adadad; font-style: italic;];move.b d0,($FFFFFFE1).w [/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] D0, ([color= #ff0000;]$[/color][color= #ff0000;]FFFFF00B[/color]).[color= #00bfff;]w[/color][color= #adadad; font-style: italic;]; Esrael L. G. Neto Change Sonic 1 Sound Driver[/color]
[color= #00bfff;]rts[/color]
[color= #adadad; font-style: italic;]; End of function sub_1370[/color]


Now, we're going to fix the broken sound effects, such as rings. Look for sub_1376. It should be this:
Syntax Highlighted Code: ASM
sub_1376:		[color= #adadad; font-style: italic;]; CODE XREF: sub_11FC2+54j[/color]
[color= #adadad; font-style: italic;]; sub_11FC2+B0j ...[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] d0,([color= #ff0000;]$[/color][color= #ff0000;]FFFFFFE2[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]rts[/color]
[color= #adadad; font-style: italic;]; End of function sub_1376[/color]


Replace it with this:
Syntax Highlighted Code: ASM
sub_1376:		[color= #adadad; font-style: italic;]; CODE XREF: sub_11FC2+54j[/color]
[color= #adadad; font-style: italic;]; sub_11FC2+B0j ...[/color]
[color= #00bfff;]bra[/color].[color= #00bfff;]s[/color] sub_135E[color= #adadad; font-style: italic;]; branch to normal sfx playing routine[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] d0,([color= #ff0000;]$[/color][color= #ff0000;]FFFFFFE2[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]rts[/color]
[color= #adadad; font-style: italic;]; End of function sub_1376[/color]


Now, look for sub_137C. It should be this:
Syntax Highlighted Code: ASM
sub_137C:[color= #adadad; font-style: italic;]; CODE XREF: sub_FE70+24p h+B576p ...[/color]
[color= #00bfff;]tst[/color].[color= #00bfff;]b[/color] [color= #ff0000;]1[/color](a0)
[color= #00bfff;]bpl[/color].[color= #00bfff;]s[/color] locret_1386
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] d0,([color= #ff0000;]$[/color][color= #ff0000;]FFFFFFE1[/color]).[color= #00bfff;]w[/color]
 
locret_1386:[color= #adadad; font-style: italic;]; CODE XREF: sub_137C+4j[/color]
[color= #00bfff;]rts[/color]
[color= #adadad; font-style: italic;]; End of function sub_137C[/color]


Replace it with this:
Syntax Highlighted Code: ASM
sub_137C:[color= #adadad; font-style: italic;]; CODE XREF: sub_FE70+24p h+B576p ...[/color]
[color= #00bfff;]tst[/color].[color= #00bfff;]b[/color] [color= #ff0000;]1[/color](a0)
[color= #00bfff;]bpl[/color].[color= #00bfff;]s[/color] locret_1386
[color= #adadad; font-style: italic;];move.b d0,($FFFFFFE1).w[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] D0, ([color= #ff0000;]$[/color][color= #ff0000;]FFFFF00B[/color]).[color= #00bfff;]w[/color][color= #adadad; font-style: italic;]; Esrael L. G. Neto Change Sonic 1 Sound Driver[/color]
 
locret_1386:[color= #adadad; font-style: italic;]; CODE XREF: sub_137C+4j[/color]
[color= #00bfff;]rts[/color]
[color= #adadad; font-style: italic;]; End of function sub_137C[/color]


Next, we're going to fix the music so it stops correctly when you pause. Find loc_13A6, which should be this:
Syntax Highlighted Code: ASM
loc_13A6:[color= #adadad; font-style: italic;]; CODE XREF: sub_1388+Ej[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]w[/color] [color= #ff0000;]#[/color][color= #ff0000;]1[/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFF63A[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] [color= #ff0000;]#[/color][color= #ff0000;]-2[/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFFFE0[/color]).[color= #00bfff;]w[/color]


And replace it with this...
Syntax Highlighted Code: ASM
loc_13A6:[color= #adadad; font-style: italic;]; CODE XREF: sub_1388+Ej[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]w[/color] [color= #ff0000;]#[/color][color= #ff0000;]1[/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFF63A[/color]).[color= #00bfff;]w[/color]
[color= #adadad; font-style: italic;];move.b #-2,($FFFFFFE0).w [/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color][color= #ff0000;][color= #ff0000;]01[/color][/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFF003[/color]).[color= #00bfff;]w[/color][color= #adadad; font-style: italic;]; Esrael L. G. Neto Change Sonic 1 Sound Driver - Pause[/color]


Next, go to loc_13F2, which should be this:
Syntax Highlighted Code: ASM
loc_13F2:[color= #adadad; font-style: italic;]; CODE XREF: sub_1388+4Aj[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] [color= #ff0000;]#[/color][color= #ff0000;]-1[/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFFFE0[/color]).[color= #00bfff;]w[/color]


And replace it with this...
Syntax Highlighted Code: ASM
loc_13F2:[color= #adadad; font-style: italic;]; CODE XREF: sub_1388+4Aj[/color]
[color= #adadad; font-style: italic;];move.b #-1,($FFFFFFE0).w [/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color][color= #ff0000;][color= #ff0000;]80[/color][/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFF003[/color]).[color= #00bfff;]w[/color][color= #adadad; font-style: italic;]; Esrael L. G. Neto Change Sonic 1 Sound Driver - Pause[/color]


Now, find loc_1400, which should be this:
Syntax Highlighted Code: ASM
loc_1400:[color= #adadad; font-style: italic;]; CODE XREF: sub_1388+52j sub_1388+5Aj[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]w[/color] [color= #ff0000;]#[/color][color= #ff0000;]1[/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFF63A[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] [color= #ff0000;]#[/color][color= #ff0000;]-1[/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFFFE0[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]rts[/color]


And replace it with this...
Syntax Highlighted Code: ASM
loc_1400:[color= #adadad; font-style: italic;]; CODE XREF: sub_1388+52j sub_1388+5Aj[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]w[/color] [color= #ff0000;]#[/color][color= #ff0000;]1[/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFF63A[/color]).[color= #00bfff;]w[/color]
[color= #adadad; font-style: italic;];move.b #-1,($FFFFFFE0).w [/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color][color= #ff0000;][color= #ff0000;]01[/color][/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFF003[/color]).[color= #00bfff;]w[/color][color= #adadad; font-style: italic;]; Esrael L. G. Neto Change Sonic 1 Sound Driver - Pause[/color]
[color= #00bfff;]rts[/color]


Next, find loc_541A, which should be this:
Syntax Highlighted Code: ASM
loc_541A:[color= #adadad; font-style: italic;]; CODE XREF: ROM:00005212j[/color]
[color= #adadad; font-style: italic;]; ROM:0000525Aj[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] [color= #ff0000;]#[/color][color= #ff0000;]-1[/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFFFE0[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] [color= #ff0000;]#[/color][color= #ff0000;]8[/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFF62A[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]bra[/color].[color= #00bfff;]w[/color] sub_3384


And replace it with this...
Syntax Highlighted Code: ASM
loc_541A:[color= #adadad; font-style: italic;]; CODE XREF: ROM:00005212j[/color]
[color= #adadad; font-style: italic;]; ROM:0000525Aj[/color]
[color= #adadad; font-style: italic;];move.b #-1,($FFFFFFE0).w[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color][color= #ff0000;][color= #ff0000;]01[/color][/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFF003[/color]).[color= #00bfff;]w[/color][color= #adadad; font-style: italic;]; Esrael L. G. Neto Change Sonic 1 Sound Driver - Pause [/color]
[color= #00bfff;]move[/color].[color= #00bfff;]b[/color] [color= #ff0000;]#[/color][color= #ff0000;]8[/color],([color= #ff0000;]$[/color][color= #ff0000;]FFFFF62A[/color]).[color= #00bfff;]w[/color]
[color= #00bfff;]bra[/color].[color= #00bfff;]w[/color] sub_3384


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.

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:
Syntax Highlighted Code: ASM
sub_2764:[color= #adadad; font-style: italic;]; CODE XREF: ROM:000042E4p[/color]
[color= #00bfff;]lea[/color] (PalPoint).[color= #00bfff;]l[/color],a1
[color= #00bfff;]lsl[/color].[color= #00bfff;]w[/color] [color= #ff0000;]#[/color][color= #ff0000;]3[/color],d0
[color= #00bfff;]adda[/color].[color= #00bfff;]w[/color] d0,a1
[color= #00bfff;]movea[/color].[color= #00bfff;]l[/color] (a1)+,a2
[color= #00bfff;]movea[/color].[color= #00bfff;]w[/color] (a1)+,a3
[color= #00bfff;]suba[/color].[color= #00bfff;]l[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color][color= #ff0000;]B00[/color],a3
[color= #00bfff;]move[/color].[color= #00bfff;]w[/color] (a1)+,d7
 
loc_277A:[color= #adadad; font-style: italic;]; CODE XREF: sub_2764+18j[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]l[/color] (a2)+,(a3)+
[color= #00bfff;]dbf[/color] d7,loc_277A
[color= #00bfff;]rts[/color]
[color= #adadad; font-style: italic;]; End of function sub_2764[/color]


Change it to this:
Syntax Highlighted Code: ASM
sub_2764:[color= #adadad; font-style: italic;]; CODE XREF: ROM:000042E4p[/color]
[color= #00bfff;]lea[/color] (PalPoint).[color= #00bfff;]l[/color],a1
[color= #00bfff;]lsl[/color].[color= #00bfff;]w[/color] [color= #ff0000;]#[/color][color= #ff0000;]3[/color],d0
[color= #00bfff;]adda[/color].[color= #00bfff;]w[/color] d0,a1
[color= #00bfff;]movea[/color].[color= #00bfff;]l[/color] (a1)+,a2
[color= #00bfff;]movea[/color].[color= #00bfff;]w[/color] (a1)+,a3
[color= #00bfff;]suba[/color].[color= #00bfff;]l[/color] [color= #ff0000;]#[/color][color= #ff0000;]$[/color][color= #ff0000;][color= #ff0000;]80[/color][/color],a3
[color= #00bfff;]move[/color].[color= #00bfff;]w[/color] (a1)+,d7
 
loc_277A:[color= #adadad; font-style: italic;]; CODE XREF: sub_2764+18j[/color]
[color= #00bfff;]move[/color].[color= #00bfff;]l[/color] (a2)+,(a3)+
[color= #00bfff;]dbf[/color] d7,loc_277A
[color= #00bfff;]rts[/color]
[color= #adadad; font-style: italic;]; End of function sub_2764[/color]


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 reccomend 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. Kega may also mess up a tad bit, not sure why - if anyone can figure it out, let us know.

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: http://www.fileden.c...DriverFiles.rar

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.

#2 User is offline drx 

Posted 08 June 2007 - 05:07 PM

  • <Shade> fuck MJ
  • Posts: 2158
  • Joined: 02-March 04
  • Gender:Male
  • Project::rolleyes:
  • Wiki edits:8
Esrael puts nice watermarks in his stuff :P

#3 User is offline LocalH 

Posted 10 June 2007 - 11:44 PM

  • roxoring your soxors
  • Posts: 3212
  • Joined: 11-January 03
  • Gender:Male
  • Location:wouldn't you like to know
  • Project:Guitar Hero II: Rhythm Games Community Edition aka Pizza Hero II: Electric Pizza
  • Wiki edits:3
One thing to be aware of when you do this - you're taking time away from the main program code on the 68k in order to run your music driver now, so the chance for the game to lag is a bit higher.

#4 User is offline Tweaker 

Posted 10 June 2007 - 11:59 PM

  • Posts: 12389
  • Joined: 27-June 04
  • Gender:Male

View PostLocalH, on Jun 11 2007, 12:44 AM, said:

One thing to be aware of when you do this - you're taking time away from the main program code on the 68k in order to run your music driver now, so the chance for the game to lag is a bit higher.

I'm aware. But, at least in the case of the original Sonic 2, no more noticable lag is induced, even in 2-player splitscreen mode.

#5 User is offline StephenUK 

Posted 11 June 2007 - 12:20 AM

  • Liquor in the front, poker in the rear
  • Posts: 1675
  • Joined: 30-December 04
  • Gender:Male
  • Location:Manchester, UK
  • Project:Quackshot Disassembly
Except on the title card, where it has a small amount of lag. You can hear it in the music, but it's not a lot.

#6 User is offline Puto 

Posted 11 June 2007 - 03:20 AM

  • Shin'ichi Kudō, detective.
  • Posts: 2012
  • Joined: 31-July 05
  • Gender:Male
  • Location:Portugal, Oeiras
  • Project:Part of Team Megamix, but haven't done any actual work in ages.
  • Wiki edits:51
I think we no longer have any lag on the title card. Either that, or it's such a small amount, that it's un-noticeable.

#7 User is offline Quickman 

Posted 11 June 2007 - 04:47 AM

  • Posts: 5584
  • Joined: 03-December 03
  • Gender:Male
  • Location::x
  • Project:omg porjcet
  • Wiki edits:10
I must be unique in wanting to do the exact opposite to what this guide is doing - I'd rather port the Sonic 2 sound driver to Sonic 1 - the Sonic 2 sound driver is far more modular, so it's easier to drag it around as a bundle.

(Besides which there's actually a disassembly of Sonic 1, whereas there isn't one for Sonic 2. :P)

#8 User is offline Puto 

Posted 11 June 2007 - 08:25 AM

  • Shin'ichi Kudō, detective.
  • Posts: 2012
  • Joined: 31-July 05
  • Gender:Male
  • Location:Portugal, Oeiras
  • Project:Part of Team Megamix, but haven't done any actual work in ages.
  • Wiki edits:51
drx already did that once, it's somewhere here on s2b.

#9 User is offline drx 

Posted 11 June 2007 - 01:10 PM

  • <Shade> fuck MJ
  • Posts: 2158
  • Joined: 02-March 04
  • Gender:Male
  • Project::rolleyes:
  • Wiki edits:8

View PostPuto, on Jun 11 2007, 03:25 PM, said:

drx already did that once, it's somewhere here on s2b.


Yea, and an I did that before the ASM times if I remember correctly.

#10 User is offline Dracula 

Posted 11 June 2007 - 02:47 PM

  • Posts: 599
  • Joined: 03-March 03
  • Gender:Male
  • Location:I'm watching you!
  • Project:The Guardian Legend UNROM to MMC5 and Issues
  • Wiki edits:12
Awesome guide!

#11 User is offline Esrael 

Posted 15 June 2007 - 08:25 PM

  • Posts: 177
  • Joined: 24-July 03
  • Gender:Male
  • Location:Brazil, São Paulo, Guarulhos
  • Project:Neto Assembler Editor / Sonic 2 Delta / Neto Boot Loader
To Fix Sega Sound Change The Following instrunctions:

Edit:
  
Replace  
		move.b  $0F, ($00A00019); Esrael L. G. Neto Add Sonic 1 Sound Driver
  With	 
		move.b  #((SegaPCm>>$10)&$FF), ($00A00019); Esrael L. G. Neto Add Sonic 1 Sound Driver


And
Edit: Use this code before SegaPCM this will calculate Segaaaa Bank

		cnop $0, (((((*+$6978)>>$10)+$01)*$10000)-$6978); Esrael L. G. Neto Auto Detect Bank	
SegaPCM:	
		incbin	sound\segapcm.bin

This post has been edited by Esrael: 17 June 2007 - 07:44 AM

#12 User is offline Puto 

Posted 16 June 2007 - 02:37 AM

  • Shin'ichi Kudō, detective.
  • Posts: 2012
  • Joined: 31-July 05
  • Gender:Male
  • Location:Portugal, Oeiras
  • Project:Part of Team Megamix, but haven't done any actual work in ages.
  • Wiki edits:51
"Oops". Apparently, I made a mistake when I fixed the water palettes. Here's a fixed version of that part of the guide, with changes in bold:

View PostTweaker, on Jun 8 2007, 10:04 PM, said:

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.

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:
sub_2764:; CODE XREF: ROM:000042E4p
		lea	(PalPoint).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

loc_277A:; CODE XREF: sub_2764+18j
		move.l	(a2)+,(a3)+
		dbf	d7,loc_277A
		rts	
; End of function sub_2764


Change it to this:
sub_2764:; CODE XREF: ROM:000042E4p
		lea	(PalPoint).l,a1
		lsl.w	#3,d0
		adda.w	d0,a1
		movea.l	(a1)+,a2
		movea.w	(a1)+,a3
		suba.l	#$80,a3; BTW, I changed this too, but you can't put bold in a codebox =P
		move.w	(a1)+,d7

loc_277A:; CODE XREF: sub_2764+18j
		move.l	(a2)+,(a3)+
		dbf	d7,loc_277A
		rts	
; End of function sub_2764


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.


Also, for the record, you forgot to credit drx. I couldn't have fixed the underwater palettes without his VDP Calculator =P.
This post has been edited by Puto: 16 June 2007 - 02:38 AM

#13 User is offline Tweaker 

Posted 16 June 2007 - 03:14 AM

  • Posts: 12389
  • Joined: 27-June 04
  • Gender:Male
Thanks, guide edited.

#14 User is offline Tweaker 

Posted 17 June 2007 - 01:48 AM

  • Posts: 12389
  • Joined: 27-June 04
  • Gender:Male
Another edit; this one includes dynamic recalculation of the Sega sound's location, so the Sega sound now works perfectly. Redownload the sound driver files and make the necessary edits if you've already followed this guide before.

#15 User is offline Ultima 

Posted 17 June 2007 - 01:47 PM

  • Games Publisher
  • Posts: 2396
  • Joined: 26-January 03
  • Gender:Male
  • Location:London, England
  • Project:Publishing mobile games!
Nice one, guys.

  • 2 Pages +
  • 1
  • 2
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users