Let's shove Flamewings S3K Sound Driver into Sonic 2

Discussion in 'Engineering & Reverse Engineering' started by Alriightyman, Sep 16, 2013.

  1. Alriightyman

    Alriightyman

    !!!!!!!!!!!!!!!!&#33 Tech Member
    351
    0
    0
    Largo, Fl
    0101001101101111011011100110100101100011 00000010: 0101001100000011 01000101011001000110100101110100011010010110111101101110
    So one day, about a year ago, I decided to try to port flamewing's S3K Sound driver into Sonic 2. I had originally planned to release this quite a while ago, but have been real busy with real life.

    This guide was written with the HG version of the Sonic 2 disassembly in mind, however, it should work with the old and ancient Xenowhirl disassembly as well. For HG users, this guide will fix the sound effects/music so it uses all Sonic 2 sound effects and music. Unfortunately, for Xeno users, you will have to manually go through and fix all the sound/music ids by hand. Anyway, on to the guide:





    QuotePorting Flamewing's S3K Sound Driver into Sonic the Hedgehog 2

    PREPARING FOR THE SOUND DRIVER


    1. Go to - VintSub0: and delete these three lines
    Code (ASM):
    1.  
    2.     stopZ80 ; stop the Z80
    3.     bsr.w sndDriverInput ; give input to the sound driver
    4.     startZ80
    5.    
    You should have something that looks like this:
    Code (ASM):
    1.  
    2. VintSub0:
    3.     cmpi.b  #GameModeID_TitleCard|GameModeID_Demo,(Game_Mode).w ; pre-level Demo Mode?
    4.     beq.s   loc_4C4
    5.     cmpi.b  #GameModeID_TitleCard|GameModeID_Level,(Game_Mode).w    ; pre-level Zone play mode?
    6.     beq.s   loc_4C4
    7.     cmpi.b  #GameModeID_Demo,(Game_Mode).w  ; Demo Mode?
    8.     beq.s   loc_4C4
    9.     cmpi.b  #GameModeID_Level,(Game_Mode).w ; Zone play mode?
    10.     beq.s   loc_4C4
    11.  
    12. ;   stopZ80         ; S3K ; stop the Z80    ; S3K
    13. ;   bsr.w   sndDriverInput  ; S3K ; give input to the sound driver
    14. ;   startZ80        ; S3K ; start the Z80
    15.  
    16.     bra.s   VintRet
    17. ; ---------------------------------------------------------------------------
    18.  
    2. Ok, Next got to the following labels:
    • loc_54A:
    • Vint0_noWater:
    • loc_748:
    • VintSub18:
    • VintSub16:
    • loc_EFE:
    And delete this line:
    Code (ASM):
    1.  
    2.     bsr.w sndDriverInput
    3.  
    3. Similarly, go to these labels as well
    • Vint10_specialStage:
    • loc_BD6:
    and delete this line:
    Code (ASM):
    1.  
    2.     jsr (sndDriverInput).l
    3.  
    4. Go to
    Code (ASM):
    1.  
    2. SS_PNTA_Transfer_Table:
    3.  
    Once there, scroll down just a little and you will see:
    Code (ASM):
    1.  
    2.     jsr (sndDriverInput).l
    3.  
    Delete that as well.

    UPGRADING THE LOAD DRIVER ROUTINE

    1. Go to
    Code (ASM):
    1.  
    2. sndDriverInput:
    3.  
    and delete all the code right before JmpTo_LoadTilesAsYouMove:
    Under that is:
    Code (ASM):
    1.  
    2. DecompressSoundDriver:
    3.  
    Delete all of it up to:
    Code (ASM):
    1.  
    2. Snd_Driver:
    3.  
    But make sure that you leave this line or you will get an error:
    Code (ASM):
    1.  
    2.     ; WARNING: the build script needs editing if you rename this label
    3. movewZ80CompSize: move.w #Snd_Driver_End-Snd_Driver,d7
    4.  
    2. OK, let's start adding the S3K driver!!!!!
    Go to:
    Code (ASM):
    1.  
    2. JmpTo_SoundDriverLoad:
    3.  
    Delete these:
    Code (ASM):
    1.  
    2.     nop
    3.     jmp (SoundDriverLoad).l
    4.  
    and ADD the following:
    Code (ASM):
    1.  
    2.     nop
    3.     move.w #$100,(Z80_bus_request).l
    4.     move.w #$100,(Z80_reset).l ; release Z80 reset
    5.     lea (Z80_Snd_Driver).l,a0
    6.     lea (Z80_RAM).l,a1
    7.     bsr.w KosDec
    8.     lea (Z80_RAM+$1300).l,a1
    9.     bsr.w KosDec
    10.     lea (Z80_Blank_Dat).l,a0
    11.     lea (Z80_RAM+zVariablesStart).l,a1
    12.     move.w #$F,d0
    13. -   move.b (a0)+,(a1)+
    14.     dbf d0,-
    15.     btst #6,(Graphics_flags).w
    16.     beq.s +
    17.     move.b #1,(Z80_RAM+zPalFlag).l ; set PAL mode flag
    18. +
    19.     move.w #0,(Z80_reset).l ; reset Z80
    20.     nop
    21.     nop
    22.     nop
    23.     nop
    24.     move.w #$100,(Z80_reset).l ; release reset
    25.     startZ80
    26.     rts
    27. ; End of function SndDrvInit
    28.  
    29. ; ---------------------------------------------------------------------------
    30. Z80_Blank_Dat: dc.b 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    31. ; ---------------------------------------------------------------------------
    32.  
    Upgrading the Playback Routines

    1. Find
    Code (ASM):
    1. PlayMusic:
    and replace it's code with the following:
    Code (ASM):
    1.  
    2.     stopZ80
    3.     move.b d0,(Z80_RAM+zMusicNumber).l
    4.     startZ80
    5. +
    6.     rts
    7.  
    2. Next, is a little different. Delete all of:
    Code (ASM):
    1.  
    2. PlaySoundLocal:
    3. PlaySoundStereo:
    4. PlaySound:
    5.  
    Replace it with:
    Code (ASM):
    1.  
    2. ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||
    3. PlaySoundLocal:
    4.     tst.b render_flags(a0)
    5.     bpl.s +++ ; rts
    6. PlaySoundStereo:
    7. PlaySound:
    8.     stopZ80
    9.     cmp.b (Z80_RAM+zSFXNumber0).l,d0
    10.     beq.s ++
    11.     tst.b (Z80_RAM+zSFXNumber0).l
    12.     bne.s +
    13.     move.b d0,(Z80_RAM+zSFXNumber0).l
    14.     startZ80
    15.     rts
    16. +
    17.     move.b d0,(Z80_RAM+zSFXNumber1).l
    18. +
    19.     startZ80
    20. +
    21.     rts
    22. ; End of function PlaySound
    23. ; =============== S U B R O U T I N E =======================================
    24. Change_Music_Tempo:
    25.     stopZ80
    26.     move.b d0,(Z80_RAM+zTempoSpeedup).l
    27.     startZ80
    28.     rts
    29. ; End of function Change_Music_Tempo
    30.  
    Upgrading Pause / Resume routines
    1. So, starting from where we left off, PauseGame should be right under the PlayMusic/PlaySound routines. First thing we need to do, is fix a future error. So, from PauseGame, scroll down until you see this:
    Code (ASM):
    1.  
    2.     beq.s Pause_DoNothing ; if not, branch
    3.  
    That should be the 9th line from PauseGame. Let's edit it to this:
    Code (ASM):
    1.  
    2.     beq.w Pause_DoNothing ; if not, branch
    3.  
    2. Continue scrolling until you find:
    Code (ASM):
    1.  
    2.     move.b #MusID_Pause,(Music_to_play).w ; pause music
    3.  
    Delete it, and replace it with these three lines:
    Code (ASM):
    1.  
    2.     stopZ80
    3.     move.b #1,(Z80_RAM+zPauseFlag).l ; Pause the music
    4.     startZ80
    5.  
    3. To resume music, Go to:
    Code (ASM):
    1.  
    2. ; loc_13F2:
    3. Pause_Resume:
    4.  
    And delete this:
    Code (ASM):
    1.  
    2.     move.b  #MusID_Unpause,(Music_to_play).w
    3.  
    Replace it with:
    Code (ASM):
    1.  
    2.     stopZ80
    3.     move.b #$80,(Z80_RAM+zPauseFlag).l ; Unpause music
    4.     startZ80
    5.  
    4. And to fix the Slow motion pause/unpause, Go to:
    Code (ASM):
    1.  
    2. ; loc_1400:
    3. Pause_SlowMo:
    4.  
    And delete:
    Code (ASM):
    1.  
    2.     move.b  #MusID_Unpause,(Music_to_play).w
    3.  
    Replace it with:
    Code (ASM):
    1.  
    2.     stopZ80
    3.     move.b #$80,(Z80_RAM+zPauseFlag).l ; Unpause music
    4.     startZ80
    5.  
    5. Next, fixing the speed shoes! Go to:
    Code (ASM):
    1.  
    2. super_shoes_Tails:
    3.  
    Delete these:
    Code (ASM):
    1.  
    2.     move.w    #MusID_SpeedUp,d0
    3.     jmp    (PlayMusic).l    ; Speed up tempo
    4.  
    and replace it with:
    Code (ASM):
    1.  
    2.     moveq   #8,d0
    3.     jmp (Change_Music_Tempo).l
    4.  
    Next, go to:
    Code (ASM):
    1.  
    2. Obj01_RmvSpeed:
    3.  
    Delete these two lines:
    Code (ASM):
    1.  
    2.     move.w  #MusID_SlowDown,d0  ; Slow down tempo
    3.     jmp (PlayMusic).l
    4.  
    and replace them with this:
    Code (ASM):
    1.  
    2.     moveq   #0,d0
    3.     jmp (Change_Music_Tempo).l
    4.  
    Same thing as before, but with Tails. Find this:
    Code (ASM):
    1.  
    2. Obj02_RmvSpeed:
    3.  
    (*note: that line is commented out.)
    Replace these lines:
    Code (ASM):
    1.  
    2.     move.w  #MusID_SlowDown,d0  ; Slow down tempo
    3.     jmp (PlayMusic).l
    4.  
    with these:
    Code (ASM):
    1.  
    2.     moveq   #0,d0
    3.     jmp (Change_Music_Tempo).l
    4.  
    Replacing S2 driver with new S3K driver

    1. Go to:
    Code (ASM):
    1.  
    2. Snd_Driver:
    3.  
    and delete the inner contents. It should look like this when you are done:
    Code (ASM):
    1.  
    2. Snd_Driver:
    3. ; loc_ED04C:
    4. Snd_Driver_End:
    5.  
    2. After that, delete everything after that label, upto but not including
    Code (ASM):
    1.  ArtNem_Buzzer_Fireball:
    3. Find
    Code (ASM):
    1.  Snd_Sega:
    and delete the cnop above it, and everything afterwards up to
    Code (ASM):
    1. Sound70:
    including the data after it,
    Code (ASM):
    1.  if * > soundBankStart + $8000
    and the 4 lines after as well.
    Now, right above
    Code (ASM):
    1.  ; end of 'ROM'
    add this line:
    Code (ASM):
    1.  Z80_Snd_Driver: include "s2.sounddriver.asm"
    2. align $8000
    4. Download flamewing's sound diver:
    http://www.mediafire...songs-sfx-v3.7z
    Now open the compressed file and copy everything to the sound folder.
    in the sound folder, delete "Z80 Sound Driver.asm" file.
    5. Now Download this:
    https://www.dropbox....sounddriver.asm
    and replace s2.sounddriver.asm in your Sonic hack folder with the one of the same name that you downloaded.
    6. download this package:
    https://www.dropbox....21rtc/win32.rar
    and replace win32 folder with it.
    7. Last, download https://www.dropbox..../Sega%20PCM.bin
    and put it in you "sound" folder.


    FIXING CONSTANTS AND MUSIC/SOUND POINTERS

    1. Open s2.constnts.asm
    2. Change
    Code (ASM):
    1.  Size_of_Snd_driver_guess = $F64
    to
    Code (ASM):
    1.  Size_of_Snd_driver_guess = $1580
    3. Find
    Code (ASM):
    1.  zMasterPlaylist
    Here is what the area we are going to change looks like now:
    Code (ASM):
    1.  
    2. ; Music IDs
    3. offset :=   zMasterPlaylist
    4. ptrsize :=  1
    5. idstart :=  $81
    6. ; $80 is reserved for silence, so if you make idstart $80 or less,
    7. ; you may need to insert a dummy zMusIDPtr in the $80 slot
    8.  
    9. MusID__First = idstart
    10. MusID_2PResult =    id(zMusIDPtr_2PResult)  ; 81
    11. MusID_EHZ =     id(zMusIDPtr_EHZ)   ; 82
    12. MusID_MCZ_2P =  id(zMusIDPtr_MCZ_2P)    ; 83
    13. MusID_OOZ =     id(zMusIDPtr_OOZ)   ; 84
    14. MusID_MTZ =     id(zMusIDPtr_MTZ)   ; 85
    15. MusID_HTZ =     id(zMusIDPtr_HTZ)   ; 86
    16. MusID_ARZ =     id(zMusIDPtr_ARZ)   ; 87
    17. MusID_CNZ_2P =  id(zMusIDPtr_CNZ_2P)    ; 88
    18. MusID_CNZ =     id(zMusIDPtr_CNZ)   ; 89
    19. MusID_DEZ =     id(zMusIDPtr_DEZ)   ; 8A
    20. MusID_MCZ =     id(zMusIDPtr_MCZ)   ; 8B
    21. MusID_EHZ_2P =  id(zMusIDPtr_EHZ_2P)    ; 8C
    22. MusID_SCZ =     id(zMusIDPtr_SCZ)   ; 8D
    23. MusID_CPZ =     id(zMusIDPtr_CPZ)   ; 8E
    24. MusID_WFZ =     id(zMusIDPtr_WFZ)   ; 8F
    25. MusID_HPZ =     id(zMusIDPtr_HPZ)   ; 90
    26. MusID_Options = id(zMusIDPtr_Options)   ; 91
    27. MusID_SpecStage =   id(zMusIDPtr_SpecStage) ; 92
    28. MusID_Boss =        id(zMusIDPtr_Boss)  ; 93
    29. MusID_EndBoss = id(zMusIDPtr_EndBoss)   ; 94
    30. MusID_Ending =  id(zMusIDPtr_Ending)    ; 95
    31. MusID_SuperSonic =  id(zMusIDPtr_SuperSonic); 96
    32. MusID_Invincible =  id(zMusIDPtr_Invincible); 97
    33. MusID_ExtraLife =   id(zMusIDPtr_ExtraLife) ; 98
    34. MusID_Title =       id(zMusIDPtr_Title) ; 99
    35. MusID_EndLevel =    id(zMusIDPtr_EndLevel)  ; 9A
    36. MusID_GameOver =    id(zMusIDPtr_GameOver)  ; 9B
    37. MusID_Continue =    id(zMusIDPtr_Continue)  ; 9C
    38. MusID_Emerald = id(zMusIDPtr_Emerald)   ; 9D
    39. MusID_Credits = id(zMusIDPtr_Credits)   ; 9E
    40. MusID_Countdown =   id(zMusIDPtr_Countdown) ; 9F
    41. MusID__End =        id(zMusIDPtr__End)  ; A0
    42.  
    Go ahead and delete it and replace it with the following:
    Code (ASM):
    1.  
    2. ; Music IDs
    3. offset :=   z80_MusicPointers
    4. ptrsize := 2
    5. idstart :=  1
    6.  
    7. MusID__First = idstart
    8. MusID_2PResult =    id(Snd_AIZ1_Ptr)    ; 01
    9. MusID_EHZ =     id(Snd_AIZ2_Ptr)    ; 02
    10. MusID_MCZ_2P =      id(Snd_HCZ1_Ptr)    ; 03
    11. MusID_OOZ =     id(Snd_HCZ2_Ptr)    ; 04
    12. MusID_MTZ =     id(Snd_MGZ1_Ptr)    ; 05
    13. MusID_HTZ =     id(Snd_MGZ2_Ptr)    ; 06
    14. MusID_ARZ =     id(Snd_CNZ2_Ptr)    ; 07
    15. MusID_CNZ_2P =      id(Snd_CNZ1_Ptr)    ; 08
    16. MusID_CNZ =     id(Snd_FBZ1_Ptr)    ; 09
    17. MusID_DEZ =     id(Snd_FBZ2_Ptr)    ; 0A
    18. MusID_MCZ =     id(Snd_MHZ1_Ptr)    ; 0B
    19. MusID_EHZ_2P =      id(Snd_MHZ2_Ptr)    ; 0C
    20. MusID_SCZ =     id(Snd_SOZ1_Ptr)    ; 0D
    21. MusID_CPZ =     id(Snd_SOZ2_Ptr)    ; 0E
    22. MusID_WFZ =     id(Snd_LRZ1_Ptr)    ; 0F
    23. MusID_HPZ =     id(Snd_LRZ2_Ptr)    ; 10
    24. MusID_Options =     id(Snd_SSZ_Ptr)     ; 11
    25. MusID_SpecStage =   id(Snd_DEZ1_Ptr)    ; 12
    26. MusID_Boss =        id(Snd_DEZ2_Ptr)    ; 13
    27. MusID_EndBoss =     id(Snd_Minib_SK_Ptr)    ; 14
    28. MusID_Ending =      id(Snd_Boss_Ptr)    ; 15
    29. MusID_SuperSonic =  id(Snd_DDZ_Ptr)     ; 16
    30. MusID_Invincible =  id(Snd_PachBonus_Ptr)   ; 17
    31. MusID_ExtraLife =   MusID_1UP       ; 18
    32. MusID_Title =       id(Snd_SpecialS_Ptr)    ; 19
    33. MusID_EndLevel =    id(Snd_SlotBonus_Ptr)   ; 1A
    34. MusID_GameOver =    id(Snd_Knux_Ptr)    ; 1B
    35. MusID_Continue =    id(Snd_Title_Ptr)   ; 1C
    36. MusID_Emerald =     id(Snd_Emerald_Ptr) ; 1D
    37. MusID_Credits =     id(Snd_ICZ2_Ptr)    ; 1E
    38. MusID_Countdown =   id(Snd_Drown_Ptr)   ; 1F
    39. MusID__End =        id(zMusIDPtr__End)  ; 20
    40.  
    4. We are going to do the same for the sound effects. right after the music pointers, you should see the following:
    Code (ASM):
    1.  
    2. ; Sound IDs
    3. offset :=   SoundIndex
    4. ptrsize :=  2
    5. idstart :=  $A0
    6. ; $80 is reserved for silence, so if you make idstart $80 or less,
    7. ; you may need to insert a dummy SndPtr in the $80 slot
    8.  
    9. SndID__First = idstart
    10. SndID_Jump =        id(SndPtr_Jump)         ; A0
    11. SndID_Checkpoint =  id(SndPtr_Checkpoint)       ; A1
    12. SndID_SpikeSwitch = id(SndPtr_SpikeSwitch)      ; A2
    13. SndID_Hurt =        id(SndPtr_Hurt)         ; A3
    14. SndID_Skidding =    id(SndPtr_Skidding)     ; A4
    15. SndID_BlockPush =   id(SndPtr_BlockPush)        ; A5
    16. SndID_HurtBySpikes =    id(SndPtr_HurtBySpikes)     ; A6
    17. SndID_Sparkle =     id(SndPtr_Sparkle)      ; A7
    18. SndID_Beep =        id(SndPtr_Beep)         ; A8
    19. SndID_Bwoop =       id(SndPtr_Bwoop)        ; A9
    20. SndID_Splash =      id(SndPtr_Splash)       ; AA
    21. SndID_Swish =       id(SndPtr_Swish)        ; AB
    22. SndID_BossHit =     id(SndPtr_BossHit)      ; AC
    23. SndID_InhalingBubble =  id(SndPtr_InhalingBubble)   ; AD
    24. SndID_ArrowFiring = id(SndPtr_ArrowFiring)      ; AE
    25. SndID_LavaBall =    id(SndPtr_LavaBall)     ; AE
    26. SndID_Shield =      id(SndPtr_Shield)       ; AF
    27. SndID_LaserBeam =   id(SndPtr_LaserBeam)        ; B0
    28. SndID_Zap =     id(SndPtr_Zap)          ; B1
    29. SndID_Drown =       id(SndPtr_Drown)        ; B2
    30. SndID_FireBurn =    id(SndPtr_FireBurn)     ; B3
    31. SndID_Bumper =      id(SndPtr_Bumper)       ; B4
    32. SndID_Ring =        id(SndPtr_Ring)         ; B5
    33. SndID_RingRight =   id(SndPtr_RingRight)        ; B5
    34. SndID_SpikesMove =  id(SndPtr_SpikesMove)       ; B6
    35. SndID_Rumbling =    id(SndPtr_Rumbling)     ; B7
    36. SndID_Smash =       id(SndPtr_Smash)        ; B9
    37. SndID_DoorSlam =    id(SndPtr_DoorSlam)     ; BB
    38. SndID_SpindashRelease = id(SndPtr_SpindashRelease)  ; BC
    39. SndID_Hammer =      id(SndPtr_Hammer)       ; BD
    40. SndID_Roll =        id(SndPtr_Roll)         ; BE
    41. SndID_ContinueJingle =  id(SndPtr_ContinueJingle)   ; BF
    42. SndID_CasinoBonus = id(SndPtr_CasinoBonus)      ; C0
    43. SndID_Explosion =   id(SndPtr_Explosion)        ; C1
    44. SndID_WaterWarning =    id(SndPtr_WaterWarning)     ; C2
    45. SndID_EnterGiantRing =  id(SndPtr_EnterGiantRing)   ; C3
    46. SndID_BossExplosion =   id(SndPtr_BossExplosion)    ; C4
    47. SndID_TallyEnd =    id(SndPtr_TallyEnd)     ; C5
    48. SndID_RingSpill =   id(SndPtr_RingSpill)        ; C6
    49. SndID_Flamethrower =    id(SndPtr_Flamethrower)     ; C8
    50. SndID_Bonus =       id(SndPtr_Bonus)        ; C9
    51. SndID_SpecStageEntry =  id(SndPtr_SpecStageEntry)   ; CA
    52. SndID_SlowSmash =   id(SndPtr_SlowSmash)        ; CB
    53. SndID_Spring =      id(SndPtr_Spring)       ; CC
    54. SndID_Blip =        id(SndPtr_Blip)         ; CD
    55. SndID_RingLeft =    id(SndPtr_RingLeft)     ; CE
    56. SndID_Signpost =    id(SndPtr_Signpost)     ; CF
    57. SndID_CNZBossZap =  id(SndPtr_CNZBossZap)       ; D0
    58. SndID_Signpost2P =  id(SndPtr_Signpost2P)       ; D3
    59. SndID_OOZLidPop =   id(SndPtr_OOZLidPop)        ; D4
    60. SndID_SlidingSpike =    id(SndPtr_SlidingSpike)     ; D5
    61. SndID_CNZElevator = id(SndPtr_CNZElevator)      ; D6
    62. SndID_PlatformKnock =   id(SndPtr_PlatformKnock)    ; D7
    63. SndID_BonusBumper = id(SndPtr_BonusBumper)      ; D8
    64. SndID_LargeBumper = id(SndPtr_LargeBumper)      ; D9
    65. SndID_Gloop =       id(SndPtr_Gloop)        ; DA
    66. SndID_PreArrowFiring =  id(SndPtr_PreArrowFiring)   ; DB
    67. SndID_Fire =        id(SndPtr_Fire)         ; DC
    68. SndID_ArrowStick =  id(SndPtr_ArrowStick)       ; DD
    69. SndID_Helicopter =  id(SndPtr_Helicopter)       ; DE
    70. SndID_SuperTransform =  id(SndPtr_SuperTransform)   ; DF
    71. SndID_SpindashRev = id(SndPtr_SpindashRev)      ; E0
    72. SndID_Rumbling2 =   id(SndPtr_Rumbling2)        ; E1
    73. SndID_CNZLaunch =   id(SndPtr_CNZLaunch)        ; E2
    74. SndID_Flipper =     id(SndPtr_Flipper)      ; E3
    75. SndID_HTZLiftClick =    id(SndPtr_HTZLiftClick)     ; E4
    76. SndID_Leaves =      id(SndPtr_Leaves)       ; E5
    77. SndID_MegaMackDrop =    id(SndPtr_MegaMackDrop)     ; E6
    78. SndID_DrawbridgeMove =  id(SndPtr_DrawbridgeMove)   ; E7
    79. SndID_QuickDoorSlam =   id(SndPtr_QuickDoorSlam)    ; E8
    80. SndID_DrawbridgeDown =  id(SndPtr_DrawbridgeDown)   ; E9
    81. SndID_LaserBurst =  id(SndPtr_LaserBurst)       ; EA
    82. SndID_Scatter =     id(SndPtr_Scatter)      ; EB
    83. SndID_LaserFloor =  id(SndPtr_LaserFloor)       ; EB
    84. SndID_Teleport =    id(SndPtr_Teleport)     ; EC
    85. SndID_Error =       id(SndPtr_Error)        ; ED
    86. SndID_MechaSonicBuzz =  id(SndPtr_MechaSonicBuzz)   ; EE
    87. SndID_LargeLaser =  id(SndPtr_LargeLaser)       ; EF
    88. SndID_OilSlide =    id(SndPtr_OilSlide)     ; F0
    89. SndID__End =        id(SndPtr__End)         ; F1
    90.     if MOMPASS == 2
    91.     if SndID__End > MusID_StopSFX
    92.         fatal "You have too many SndPtrs. SndID__End ($\{SndID__End}) can't exceed MusID_StopSFX ($\{MusID_StopSFX})."
    93.     endif
    94.     endif
    95.  
    96. ; Special sound IDs
    97.  
    98. MusID_StopSFX =     $78+$80         ; F8
    99. MusID_FadeOut =     $79+$80         ; F9
    100. SndID_SegaSound =   $7A+$80         ; FA
    101. MusID_SpeedUp =     $7B+$80         ; FB
    102. MusID_SlowDown =    $7C+$80         ; FC
    103. MusID_Stop =        $7D+$80         ; FD
    104. MusID_Pause =       $7E+$80         ; FE
    105. MusID_Unpause =     $7F+$80         ; FF
    106.  
    Delete it and replace it with this
    Code (ASM):
    1.  
    2. ; Sound IDs
    3. offset :=   z80_SFXPointers
    4. ptrsize :=  2
    5. idstart :=  MusID__End
    6.  
    7. SndID__First = idstart
    8. SndID_Ring =        id(Sound_33_Ptr)    ; 20
    9. SndID_RingRight =   id(Sound_34_Ptr)    ; 21
    10. SndID_Jump =        id(Sound_35_Ptr)    ; 22
    11. SndID_Checkpoint =  id(Sound_36_Ptr)    ; 23
    12. SndID_SpikeSwitch = id(Sound_37_Ptr)    ; 24
    13. SndID_Hurt =        id(Sound_38_Ptr)    ; 25
    14. SndID_Skidding =    id(Sound_39_Ptr)    ; 26
    15. SndID_BlockPush =   id(Sound_3A_Ptr)    ; 27
    16. SndID_HurtBySpikes =    id(Sound_3B_Ptr)    ; 28
    17. SndID_Sparkle =     id(Sound_3C_Ptr)    ; 29
    18. SndID_Beep =        id(Sound_3D_Ptr)    ; 2A
    19. SndID_Bwoop =       id(Sound_3E_Ptr)    ; 2B
    20. SndID_Splash =      id(Sound_3F_Ptr)    ; 2C
    21. SndID_Swish =       id(Sound_40_Ptr)    ; 2D
    22. SndID_BossHit =     id(Sound_41_Ptr)    ; 2E
    23. SndID_InhalingBubble =  id(Sound_42_Ptr)    ; 2E
    24. SndID_ArrowFiring = id(Sound_43_Ptr)    ; 2F ; MOVE
    25. SndID_LavaBall =    id(Sound_43_Ptr)    ; 30
    26. SndID_Shield =      id(Sound_44_Ptr)    ; 31
    27. SndID_LaserBeam =   id(Sound_45_Ptr)    ; 32
    28. SndID_Zap =     id(Sound_46_Ptr)    ; 33
    29. SndID_Drown =       id(Sound_47_Ptr)    ; 34
    30. SndID_FireBurn =    id(Sound_48_Ptr)    ; 36
    31. SndID_Bumper =      id(Sound_49_Ptr)    ; 37
    32. SndID_SpikesMove =  id(Sound_4A_Ptr)    ; 39
    33. SndID_Rumbling =    id(Sound_4B_Ptr)    ; 3B
    34. SndID_Smash =       id(Sound_4D_Ptr)    ; 3C
    35. SndID_DoorSlam =    id(Sound_4F_Ptr)    ; 3D
    36. SndID_SpindashRelease = id(Sound_50_Ptr)    ; 3E
    37. SndID_Hammer =      id(Sound_51_Ptr)    ; 3F
    38. SndID_Roll =        id(Sound_52_Ptr)    ; 40
    39. SndID_ContinueJingle =  id(Sound_53_Ptr)    ; 41
    40. SndID_CasinoBonus = id(Sound_54_Ptr)    ; 42
    41. SndID_Explosion =   id(Sound_55_Ptr)    ; 43
    42. SndID_WaterWarning =    id(Sound_56_Ptr)    ; 44
    43. SndID_EnterGiantRing =  id(Sound_57_Ptr)    ; 45
    44. SndID_BossExplosion =   id(Sound_58_Ptr)    ; 46
    45. SndID_TallyEnd =    id(Sound_59_Ptr)    ; 48
    46. SndID_RingSpill =   id(Sound_5A_Ptr)    ; 49
    47. SndID_Flamethrower =    id(Sound_5C_Ptr)    ; 4A
    48. SndID_Bonus =       id(Sound_5D_Ptr)    ; 4B
    49. SndID_SpecStageEntry =  id(Sound_5E_Ptr)    ; 4C
    50. SndID_SlowSmash =   id(Sound_5F_Ptr)    ; 4D
    51. SndID_Spring =      id(Sound_60_Ptr)    ; 4E
    52. SndID_Blip =        id(Sound_61_Ptr)    ; 4F
    53. SndID_RingLeft =    id(Sound_62_Ptr)    ; 50
    54. SndID_Signpost =    id(Sound_63_Ptr)    ; 53
    55. SndID_CNZBossZap =  id(Sound_66_Ptr)    ; 54
    56. SndID_Signpost2P =  id(Sound_67_Ptr)    ; 55
    57. SndID_OOZLidPop =   id(Sound_68_Ptr)    ; 56
    58. SndID_SlidingSpike =    id(Sound_69_Ptr)    ; 57
    59. SndID_CNZElevator = id(Sound_6A_Ptr)    ; 58
    60. SndID_PlatformKnock =   id(Sound_6B_Ptr)    ; 59
    61. SndID_BonusBumper = id(Sound_6C_Ptr)    ; 5A
    62. SndID_LargeBumper = id(Sound_6D_Ptr)    ; 5B
    63. SndID_Gloop =       id(Sound_6E_Ptr)    ; 5C
    64. SndID_PreArrowFiring =  id(Sound_6F_Ptr)    ; 5D
    65. SndID_Fire =        id(Sound_70_Ptr)    ; 5E
    66. SndID_ArrowStick =  id(Sound_71_Ptr)    ; 5F
    67. SndID_Helicopter =  id(Sound_71_Ptr)    ; 60
    68. SndID_SuperTransform =  id(Sound_72_Ptr)    ; 61
    69. SndID_SpindashRev = id(Sound_73_Ptr)    ; 62
    70. SndID_Rumbling2 =   id(Sound_74_Ptr)    ; 63
    71. SndID_CNZLaunch =   id(Sound_75_Ptr)    ; 64
    72. SndID_Flipper =     id(Sound_76_Ptr)    ; 65
    73. SndID_HTZLiftClick =    id(Sound_77_Ptr)    ; 66
    74. SndID_Leaves =      id(Sound_78_Ptr)    ; 67
    75. SndID_MegaMackDrop =    id(Sound_79_Ptr)    ; 68
    76. SndID_DrawbridgeMove =  id(Sound_7A_Ptr)    ; 69
    77. SndID_QuickDoorSlam =   id(Sound_7B_Ptr)    ; 6A
    78. SndID_DrawbridgeDown =  id(Sound_7C_Ptr)    ; 6B
    79. SndID_LaserBurst =  id(Sound_7D_Ptr)    ; 6B
    80. SndID_Scatter =     id(Sound_7E_Ptr)    ; 6C
    81. SndID_LaserFloor =  id(Sound_7E_Ptr)    ; 6D
    82. SndID_Teleport =    id(Sound_7F_Ptr)    ; 6E
    83. SndID_Error =       id(Sound_80_Ptr)    ; 6F
    84. SndID_MechaSonicBuzz =  id(Sound_81_Ptr)    ; 70
    85. SndID_LargeLaser =  id(Sound_82_Ptr)    ; 71
    86. SndID_OilSlide =    id(Sound_83_Ptr)    ; 72
    87. SndID__End =        id(Sound_End_Ptr)           ; F1
    88.  
    89. ; Special sound IDs
    90.  
    91. MusID_StopSFX =     FadeID__First+3     ; F8
    92. MusID_FadeOut =     FadeID__First       ; F9
    93. SndID_SegaSound =   SndID_Sega      ; FA
    94. MusID_SpeedUp =     8           ; FB
    95. MusID_SlowDown =    0           ; FC
    96. MusID_Stop =            $FE         ; FD
    97. MusID_Pause =       1           ; FE
    98. MusID_Unpause =     $80         ; FF
    99.  
    FIXING SOUND TEST

    1. Fixing the sound test in the options menu is very easy. First, go to
    Code (ASM):
    1.  OptionScreen_Controls:
    and find this line:
    Code (ASM):
    1.    
    2.     addi.w  #$80,d0
    3.  
    Delete it.
    2. Right under that find
    Code (ASM):
    1.  OptionScreen_Choices:
    It should look like this
    Code (ASM):
    1.  
    2. ; word_917A:
    3. OptionScreen_Choices:
    4.     dc.l (3-1)<<24|(Player_option&$FFFFFF)
    5.     dc.l (2-1)<<24|(Two_player_items&$FFFFFF)
    6.     dc.l ($80-1)<<24|(Sound_test_sound&$FFFFFF)
    7.  
    We want to edit that last line. Change the ($80-1) to $FF. So it should look like:
    Code (ASM):
    1.  
    2. ; word_917A:
    3. OptionScreen_Choices:
    4.     dc.l (3-1)<<24|(Player_option&$FFFFFF)
    5.     dc.l (2-1)<<24|(Two_player_items&$FFFFFF)
    6.     dc.l $FF<<24|(Sound_test_sound&$FFFFFF)  
    7.  
    3. To fix the Level Select Sound test, go to
    Code (ASM):
    1.  LevSelControls_CheckLR:
    find this section of code:
    Code (ASM):
    1.  
    2.     btst    #button_left,d1
    3.     beq.s   +
    4.     subq.b  #1,d0
    5.     bcc.s   +
    6.     moveq   #$7F,d0
    7.  
    Remove the last two lines. It should now look like this:
    Code (ASM):
    1.  
    2.     btst    #button_left,d1
    3.     beq.s   +
    4.     subq.b  #1,d0
    5.  
    6.  
    Under that, is this:
    Code (ASM):
    1.  
    2.     beq.s   +
    3.     addq.b  #1,d0  
    4.     cmpi.w  #$80,d0  
    5.     blo.s   +
    6.     moveq   #0,d0
    7.  
    Delete the last three lines. It should now look like this:
    Code (ASM):
    1.  
    2.     beq.s   +
    3.     addq.b  #1,d0  
    4.  
    5.  
    Right under that section of code you should see:
    Code (ASM):
    1.  
    2. +
    3.     btst    #button_A,d1
    4.     beq.s   +
    5.     addi.b  #$10,d0
    6.     andi.b  #$7F,d0  
    7.  
    As before, delete the last line. Should look like this:
    Code (ASM):
    1.  
    2. +
    3.     btst    #button_A,d1
    4.     beq.s   +
    5.     addi.b  #$10,d0
    6.    
    7.  
    And last, the final part of the code, look for
    Code (ASM):
    1.  
    2.     addi.w  #$80,d0
    3.  
    And delete it!
    The whole routine should look like this: (I commented my lines out)
    Code (ASM):
    1.  
    2. ; loc_9522:
    3. LevSelControls_CheckLR:
    4.     cmpi.w  #$15,(Level_select_zone).w  ; are we in the sound test?
    5.     bne.s   LevSelControls_SwitchSide   ; no
    6.    
    7.     move.w  (Sound_test_sound).w,d0
    8.     move.b  (Ctrl_1_Press).w,d1
    9.     btst    #button_left,d1
    10.     beq.s   +
    11.     subq.b  #1,d0
    12. ;   bcc.s   +
    13. ;   moveq   #$7F,d0
    14.  
    15. +
    16.     btst    #button_right,d1
    17.     beq.s   +
    18.     addq.b  #1,d0  
    19. ;   cmpi.w  #$80,d0  
    20. ;   blo.s   +
    21. ;   moveq   #0,d0
    22.  
    23. +
    24.     btst    #button_A,d1
    25.     beq.s   +
    26.     addi.b  #$10,d0
    27. ;   andi.b  #$7F,d0  
    28.  
    29. +
    30.     move.w  d0,(Sound_test_sound).w
    31.     andi.w  #button_B_mask|button_C_mask,d1
    32.     beq.s   +   ; rts
    33.     move.w  (Sound_test_sound).w,d0
    34. ;   addi.w  #$80,d0     ; here
    35.     bsr.w   JmpTo_PlayMusic
    36.     lea (debug_cheat).l,a0
    37.     lea (super_sonic_cheat).l,a2
    38.     lea (Night_mode_flag).w,a1
    39.     moveq   #1,d2   ; flag to tell the routine to enable the Super Sonic cheat
    40.     bsr.w   CheckCheats
    41.  
    42. +
    43.     rts
    44.  
    Now build and enjoy!

    That about wraps that up. I would like to thank flamewing for his awesome s3k driver and his very cool tool! Go here to see what his driver and tool is about.
     
  2. Aerosol

    Aerosol

    FML and FU2 Member
    10,326
    2
    18
    Not where I want to be.
    Sonic (?): Coming summer of 2055...?
    Good stuff. Thanks alot Alriightyman
     
  3. Dracula

    Dracula

    Oldbie
    603
    0
    16
    I'm watching you!
    Restoring Thunder Force II Music and Voices from X68000 Version
    Thank you for sharing this! I did some fixes on this:

    s2.constants:

    Change this:
    Code (Text):
    1. ; Special sound IDs
    2.  
    3. MusID_StopSFX =         $78+$80                 ; F8
    4. MusID_FadeOut =         $79+$80                 ; F9
    5. SndID_SegaSound =       $7A+$80                 ; FA
    6. MusID_SpeedUp =         $7B+$80                 ; FB
    7. MusID_SlowDown =        $7C+$80                 ; FC
    8. MusID_Stop =            $7D+$80                 ; FD
    9. MusID_Pause =           $7E+$80                 ; FE
    10. MusID_Unpause =         $7F+$80                 ; FF
    11.  
    Into this:
    Code (Text):
    1. ; Special sound IDs
    2.  
    3. MusID_StopSFX =         FadeID__First+3     ; F8
    4. MusID_FadeOut =         -$1F            ; F9
    5. SndID_SegaSound =       SndID_Sega          ; FA
    6. MusID_SpeedUp =             8           ; FB
    7. MusID_SlowDown =        0               ; FC
    8. MusID_Stop =            -2          ; FD
    9. MusID_Pause =           1               ; FE
    10. MusID_Unpause =         $80         ; FF
    Now the MusID_Stop is fixed. I got it from s3k ASM.

    In s2.sounddriver, I did some changes in this too.

    change this:
    Code (Text):
    1. ; ---------------------------------------------------------------------------
    2. ; ===========================================================================
    3. ; Music Banks
    4. ; ===========================================================================
    5. ; Music Bank 1
    6. ; ---------------------------------------------------------------------------
    7. Snd_Bank1_Start:    startBank
    8. Snd_FBZ1:       include "Sound/s2/Music/CNZ.asm"
    9. Snd_FBZ2:       include "Sound/s2/Music/DEZ.asm"       
    10. Snd_MHZ1:       include "Sound/s2/Music/MCZ.asm"       
    11. Snd_MHZ2:       include "Sound/s2/Music/EHZ_2p.asm"    
    12. Snd_SOZ1:       include "Sound/s2/Music/SCZ.asm"       
    13. Snd_SOZ2:       include "Sound/s2/Music/CPZ.asm"       
    14. Snd_LRZ1:       include "Sound/s2/Music/WFZ.asm"       
    15. Snd_LRZ2:       include "Sound/s2/Music/HPZ.asm"       
    16. Snd_SSZ:        include "Sound/s2/Music/Options.asm"    
    17. Snd_DEZ1:       include "Sound/s2/Music/SpecStg.asm"    
    18. Snd_DEZ2:       include "Sound/s2/Music/Boss.asm"      
    19. Snd_Minib_SK:       include "Sound/s2/Music/End_Boss.asm"  
    20. Snd_Boss:       include "Sound/s2/Music/Ending.asm"    
    21. Snd_DDZ:        include "Sound/s2/Music/Supersonic.asm"  
    22. Snd_PachBonus:      include "Sound/s2/Music/Invincible.asm"  
    23. Snd_SpecialS:       include "Sound/s2/Music/Title screen.asm"
    24. Snd_SlotBonus:      include "Sound/s2/Music/End of level.asm"
    25. Snd_Knux:       include "Sound/s2/Music/Game Over.asm"  
    26. Snd_Title:      include "Sound/s2/Music/Continue.asm"  
    27. Snd_1UP:        include "Sound/s2/Music/Extra life.asm"
    28. Snd_Emerald:        include "Sound/s2/Music/Got Emerald.asm"
    29.  
    30.     finishBank
    31. ; ---------------------------------------------------------------------------
    32. ; s3/Music Bank 2
    33. ; ---------------------------------------------------------------------------
    34. Snd_Bank2_Start:    startBank
    35. Snd_AIZ1:       include "Sound/s2/Music/Results screen 2p.asm"
    36. Snd_AIZ2:       include "Sound/s2/Music/EHZ.asm"
    37. Snd_HCZ1:       include "Sound/s2/Music/MCZ_2p.asm"
    38. Snd_HCZ2:       include "Sound/s2/Music/OOZ.asm"
    39. Snd_MGZ1:       include "Sound/s2/Music/MTZ.asm"
    40. Snd_MGZ2:       include "Sound/s2/Music/HTZ.asm"  
    41. Snd_CNZ2:       include "Sound/s2/Music/ARZ.asm"  
    42. Snd_CNZ1:       include "Sound/s2/Music/CNZ_2p.asm"
    43.                        
    44.     finishBank
    45.  
    46. ; ---------------------------------------------------------------------------
    47. ; s3/Music Bank 3
    48. ; ---------------------------------------------------------------------------
    49. Snd_Bank3_Start:    startBank
    50. Snd_ICZ2:       include "Sound/s2/Music/Credits.asm"
    51. Snd_ICZ1:       include "Sound/sk/Music/ICZ1.asm"
    52. Snd_LBZ2:       include "Sound/sk/Music/LBZ2.asm"
    53. Snd_LBZ1:       include "Sound/sk/Music/LBZ1.asm"
    54. Snd_SKCredits:      include "Sound/sk/Music/Credits.asm"
    55. Snd_GameOver:       include "Sound/sk/Music/Game Over.asm"
    56. Snd_Continue:       include "Sound/sk/Music/Continue.asm"
    57. Snd_Results:        include "Sound/sk/Music/Level Outro.asm"
    58. Snd_Invic:      include "Sound/sk/Music/Invincible.asm"
    59. Snd_Menu:       include "Sound/sk/Music/Menu.asm"
    60. Snd_FinalBoss:      include "Sound/sk/Music/Final Boss.asm"
    61. Snd_PresSega:       include "Sound/sk/Music/Game Complete.asm"
    62.  
    63.     finishBank
    64.  
    65. ; ---------------------------------------------------------------------------
    66. ; s3/Music Bank 4
    67. ; ---------------------------------------------------------------------------
    68. Snd_Bank4_Start:    startBank
    69. Snd_GumBonus:       include "Sound/sk/Music/Gum Ball Machine.asm"
    70. Snd_ALZ:        include "Sound/sk/Music/Azure Lake.asm"
    71. Snd_BPZ:        include "Sound/sk/Music/Balloon Park.asm"
    72. Snd_DPZ:        include "Sound/sk/Music/Desert Palace.asm"
    73. Snd_CGZ:        include "Sound/sk/Music/Chrome Gadget.asm"
    74. Snd_EMZ:        include "Sound/sk/Music/Endless Mine.asm"
    75. Snd_S3Credits:      include "Sound/sk/Music/Sonic 3 Credits.asm"
    76. Snd_2PMenu:     include "Sound/sk/Music/Competition Menu.asm"  
    77. Snd_Drown:      include "Sound/sk/Music/Countdown.asm"
    78.  
    79.     finishBank
    into this:
    Code (Text):
    1. ; ---------------------------------------------------------------------------
    2. ; ===========================================================================
    3. ; Music Banks
    4. ; ===========================================================================
    5. ; Music Bank 1
    6. ; ---------------------------------------------------------------------------
    7. Snd_Bank1_Start:    startBank
    8. Snd_FBZ1:       include "Sound/s2/Music/CNZ.asm"
    9. Snd_FBZ2:       include "Sound/s2/Music/DEZ.asm"       
    10. Snd_MHZ1:       include "Sound/s2/Music/WFZ.asm"       
    11. Snd_MHZ2:       include "Sound/s2/Music/HPZ.asm"   
    12. Snd_SOZ1:       include "Sound/s2/Music/Options.asm"       
    13. Snd_SOZ2:       include "Sound/s2/Music/SpecStg.asm"       
    14. Snd_LRZ1:       include "Sound/s2/Music/Boss.asm"      
    15. Snd_LRZ2:       include "Sound/s2/Music/End_Boss.asm"      
    16. Snd_SSZ:        include "Sound/s2/Music/Ending.asm"    
    17. Snd_DEZ1:       include "Sound/s2/Music/Supersonic.asm"    
    18. Snd_DEZ2:       include "Sound/s2/Music/Invincible.asm"    
    19. Snd_Minib_SK:       include "Sound/s2/Music/Extra life.asm"
    20. Snd_Boss:       include "Sound/s2/Music/Title screen.asm"  
    21. Snd_DDZ:        include "Sound/s2/Music/End of level.asm"  
    22. Snd_PachBonus:      include "Sound/s2/Music/Game Over.asm"  
    23. Snd_SpecialS:       include "Sound/s2/Music/Continue.asm"
    24. Snd_SlotBonus:      include "Sound/s2/Music/Got Emerald.asm"
    25. Snd_Knux:       include "Sound/s2/Music/Drowning.asm"  
    26. Snd_Title:      include "Sound/sk/Music/Title.asm" 
    27. Snd_1UP:        include "Sound/sk/Music/1UP.asm"
    28. Snd_Emerald:        include "Sound/sk/Music/Chaos Emerald.asm"
    29.  
    30.     finishBank
    31. ; ---------------------------------------------------------------------------
    32. ; s3/Music Bank 2
    33. ; ---------------------------------------------------------------------------
    34. Snd_Bank2_Start:    startBank
    35. Snd_AIZ1:       include "Sound/s2/Music/Results screen 2p.asm"
    36. Snd_AIZ2:       include "Sound/s2/Music/EHZ.asm"
    37. Snd_HCZ1:       include "Sound/s2/Music/MCZ_2p.asm"
    38. Snd_HCZ2:       include "Sound/s2/Music/OOZ.asm"
    39. Snd_MGZ1:       include "Sound/s2/Music/MTZ.asm"
    40. Snd_MGZ2:       include "Sound/s2/Music/HTZ.asm"  
    41. Snd_CNZ2:       include "Sound/s2/Music/CNZ_2p.asm"  
    42. Snd_CNZ1:       include "Sound/s2/Music/ARZ.asm"
    43.                        
    44.     finishBank
    45.  
    46. ; ---------------------------------------------------------------------------
    47. ; s3/Music Bank 3
    48. ; ---------------------------------------------------------------------------
    49. Snd_Bank3_Start:    startBank
    50. Snd_ICZ2:       include "Sound/s2/Music/EHZ_2p.asm"
    51. Snd_ICZ1:       include "Sound/s2/Music/MCZ.asm"
    52. Snd_LBZ2:       include "Sound/s2/Music/CPZ.asm"
    53. Snd_LBZ1:       include "Sound/s2/Music/SCZ.asm"
    54. Snd_SKCredits:      include "Sound/sk/Music/Credits.asm"
    55. Snd_GameOver:       include "Sound/sk/Music/Game Over.asm"
    56. Snd_Continue:       include "Sound/sk/Music/Continue.asm"
    57. Snd_Results:        include "Sound/sk/Music/Level Outro.asm"
    58. Snd_Invic:      include "Sound/sk/Music/Invincible.asm"
    59. Snd_Menu:       include "Sound/sk/Music/Menu.asm"
    60. Snd_FinalBoss:      include "Sound/sk/Music/Final Boss.asm"
    61. Snd_PresSega:       include "Sound/sk/Music/Game Complete.asm"
    62.  
    63.     finishBank
    64.  
    65. ; ---------------------------------------------------------------------------
    66. ; s3/Music Bank 4
    67. ; ---------------------------------------------------------------------------
    68. Snd_Bank4_Start:    startBank
    69. Snd_GumBonus:       include "Sound/s2/Music/Credits.asm"
    70. Snd_ALZ:        include "Sound/sk/Music/Azure Lake.asm"
    71. Snd_BPZ:        include "Sound/sk/Music/Balloon Park.asm"
    72. Snd_DPZ:        include "Sound/sk/Music/Desert Palace.asm"
    73. Snd_CGZ:        include "Sound/sk/Music/Chrome Gadget.asm"
    74. Snd_EMZ:        include "Sound/sk/Music/Endless Mine.asm"
    75. Snd_S3Credits:      include "Sound/sk/Music/Sonic 3 Credits.asm"
    76. Snd_2PMenu:     include "Sound/sk/Music/Competition Menu.asm"  
    77. Snd_Drown:      include "Sound/sk/Music/Countdown.asm"
    78.  
    79.     finishBank
    Now the this correct the order that the music plays in the sound test number like in Sonic 2.


    Now look for this in s2.sounddriver:
    Code (Text):
    1. MusID_1UP           = 2Ah
    Change 2Ah to 18h.

    Now thanks to this Sound Driver, now we can use the unused RAM that is located here: $F100-$F5FF
     
  4. steveswede

    steveswede

    Member
    5,032
    1
    16
    Ask my hand
    Fighting against the Unitary State of Europe
    Can I bother you for the rom itself, I've always wanted to have a version of Sonic 2 where the sounds effects didn't cut out the music channels, I just don't fancy going back into ASM after trying to put in the spindash into Sonic 1 a while back.
     
  5. Alriightyman

    Alriightyman

    !!!!!!!!!!!!!!!!&#33 Tech Member
    351
    0
    0
    Largo, Fl
    0101001101101111011011100110100101100011 00000010: 0101001100000011 01000101011001000110100101110100011010010110111101101110
    I knew I was forgetting to add something to this! Also, the one I sent you was missing info about speeding/slowing the music via speed shoes. It's fixed in my original post!

    Sure.
     
  6. steveswede

    steveswede

    Member
    5,032
    1
    16
    Ask my hand
    Fighting against the Unitary State of Europe
    Thanks. There are still some drop outs in the music (in Hill Top Zone) when jumping and collecting rings. Is this mod there just to improve it or get rid of all the drop outs?
     
  7. Alriightyman

    Alriightyman

    !!!!!!!!!!!!!!!!&#33 Tech Member
    351
    0
    0
    Largo, Fl
    0101001101101111011011100110100101100011 00000010: 0101001100000011 01000101011001000110100101110100011010010110111101101110
    It was never meant to get rid of any drop outs in sound. The thing is some sounds are using channels that the song is using so you hear part of the song "drop out". As far as I know, I don't think that can be fixed.
     
  8. flamewing

    flamewing

    Emerald Hunter Tech Member
    1,138
    0
    16
    France
    Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
    This is impossible without losing channels on the music. The Genesis has a limited number of sound channels, all of which are typically used in music, and none of which can play more than a single note at a time*. Unless you completely disable all sound effects, they will always cut into the music.

    * Technically, you can mix samples before sending them to the DAC, but you lose accuracy in both samples.
     
  9. steveswede

    steveswede

    Member
    5,032
    1
    16
    Ask my hand
    Fighting against the Unitary State of Europe
    I know the channels are limited and are monophonic, I've always thought that it would be impossible but this is where my confusion started.

    That's why I jumped straight to Hill Top Zone to check out the fix.
     
  10. Clownacy

    Clownacy

    Tech Member
    777
    4
    18
    A note and a bugfix:

    I swear this driver has a problem with holding notes, just listen to the opening of ARZ, oww... This could just be me however: my left speaker's faulty so I'm only hearing the right audio channel.

    Spindash revs don't increase in pitch, and there exist some bothersome hardcoded values. Time for a little HG treatment!

    Fixing this:
    First off, let's make the spindash detection more dynamic:

    Code (ASM):
    1. z80_SoundDriver:
    2.         !org    0                           ; z80 Align, handled by the build process
    3.         CPU Z80
    4.         listing off
    5. MusID_1UP           = 2Ah
    6. SndID_Spindash          = 0ABh
    7. SndID__FirstContinuous      = 0BCh
    8. MusID_SKCredits         = 0DCh
    9. FadeID__First           = 0E1h
    10. FadeID__End         = 0E6h
    11. SndID_StopSega          = 0FEh
    12. SndID_Sega          = 0FFh


    It is actually worth working on not only SndID_Spindash, but MusID_1UP and MusID_SKCredits. The hardcoding really just makes things difficult, but we'll just stick with the spindash for now.

    Delete its entry so that you're left with this:

    Code (ASM):
    1. z80_SoundDriver:
    2.         !org    0                           ; z80 Align, handled by the build process
    3.         CPU Z80
    4.         listing off
    5. MusID_1UP           = 2Ah
    6. SndID__FirstContinuous      = 0BCh
    7. MusID_SKCredits         = 0DCh
    8. FadeID__First           = 0E1h
    9. FadeID__End         = 0E6h
    10. SndID_StopSega          = 0FEh
    11. SndID_Sega          = 0FFh


    Now, run a search-and-replace of SndID_Spindash in s2.sounddriver.asm (the new one), replacing it with SndID_SpindashRev. But this alone won't fix our problems, the pitch still doesn't increase. As you could tell by that code we deleted, the spindash sound was AB(.asm), go to sound/sk/sfx and open AB.asm, then go to sound/s2/sfx and open sound60.asm up. You'll want to compare the FM5 channels:

    Sound 60 (S2)
    Code (ASM):
    1. ; FM5 Data
    2. Sound60_SpindashRev_FM5:
    3.     smpsSetvoice        $00
    4.     smpsModSet          $00, $01, $20, $F6
    5.     dc.b    nG5, $16, smpsNoAttack
    6.     smpsModOff
    7.     dc.b    nG6, $18, smpsNoAttack
    8.  
    9. Sound60_SpindashRev_Loop00:
    10.     dc.b    $04, smpsNoAttack
    11.     smpsAlterVol        $03
    12.     smpsLoop            $00, $10, Sound60_SpindashRev_Loop00
    13.     smpsStop

    Sound AB (S&K)
    Code (ASM):
    1. ; FM5 Data
    2. Sound_AB_FM5:
    3.     smpsSpindashRev
    4.     smpsSetvoice        $00
    5.     smpsModSet          $01, $01, $1A, $01
    6.     dc.b    nC5, $18, smpsNoAttack
    7.     smpsModSet          $00, $00, $00, $00
    8.     dc.b    $02
    9.  
    10. Sound_AB_Loop00:
    11.     dc.b    smpsNoAttack, $02
    12.     smpsFMAlterVol      $02
    13.     smpsLoop            $00, $18, Sound_AB_Loop00
    14.     smpsResetSpindashRev
    15.     smpsStop



    See the cause? The S&K variant references some functions that the S2 variant does not! smpsSpindashRev and smpsResetSpindashRev! Apply these to Sound60, you should have something like this:

    Code (ASM):
    1. ; FM5 Data
    2. Sound60_SpindashRev_FM5:
    3.     smpsSpindashRev
    4.     smpsSetvoice        $00
    5.     smpsModSet          $00, $01, $20, $F6
    6.     dc.b    nG5, $16, smpsNoAttack
    7.     smpsModOff
    8.     dc.b    nG6, $18, smpsNoAttack
    9.  
    10. Sound60_SpindashRev_Loop00:
    11.     dc.b    $04, smpsNoAttack
    12.     smpsAlterVol        $03
    13.     smpsLoop            $00, $10, Sound60_SpindashRev_Loop00
    14.     smpsResetSpindashRev
    15.     smpsStop


    Save and build, and the rev's pitch increase should now work!



    But wait! Rev a bunch of times, and the pitch goes too high!

    The S3&K driver has its own way of managing spindash pitch, I'm looking into porting the S2 method over, but for now we can just work around this: Go to cfSpindashRev, you should find this:

    Code (ASM):
    1. cfSpindashRev:
    2.         ld  hl, zSpindashRev                ; hl = pointer to escalating transposition
    3.         ld  a, (hl)                         ; a = value of escalating transposition
    4.         add a, (ix+zTrackKeyOffset)         ; Add in current track key offset
    5.         ld  (ix+zTrackKeyOffset), a         ; Store result as new track key offset
    6.         cp  10h                             ; Is the current transposition 10h?
    7.         jp  z, +                            ; Branch if yes
    8.         inc (hl)                            ; Otherwise, increase escalating transposition
    9. +
    10.         dec de                              ; Put parameter byte back
    11.         ret

    That 10h needs changing, 09h sounds close enough.




    Done and done, but the spindash still isn't perfect, each rev audibly silences the one before it just as in S3K, I'm still looking into that.

    Now, onto those issue from earlier.

    Code (ASM):
    1. z80_SoundDriver:
    2.         !org    0                           ; z80 Align, handled by the build process
    3.         CPU Z80
    4.         listing off
    5. MusID_1UP           = 2Ah
    6. SndID__FirstContinuous      = 0BCh
    7. MusID_SKCredits         = 0DCh
    8. FadeID__First           = 0E1h
    9. FadeID__End         = 0E6h
    10. SndID_StopSega          = 0FEh
    11. SndID_Sega          = 0FFh


    Back here, let's get to work on MusID_1UP, starting with deleting that entry.

    Next, head over to s2.constants.asm and change the MusID_ExtraLife entry to this:

    Code (ASM):
    1. MusID_ExtraLife =   id(Snd_1UP_Ptr)     ; 18


    Once again, in s2.sounddriver.asm do a search-and-replace of MusID_1UP with MusID_ExtraLife.



    Done. Lastly, back at z80_SoundDriver, let's get rid of the MusID_SKCredits entry, then, go to zPlaySoundByIndex:

    Code (ASM):
    1. zPlaySoundByIndex:
    2.         cp  MusID_SKCredits                 ; Is this the credits music?
    3.         jp  z, zPlayMusicCredits            ; Branch if yes
    4.         cp  SndID_Sega                      ; Is this the SEGA sound?
    5.         jp  z, zPlaySegaSound               ; Branch if yes
    6.         ; etcetera


    Delete the check, unless of course you're using the S&K credits in your hack, in which case you'll want to make the check match its MusID.
    Also, a little cleaning:
    Code (ASM):
    1.         ; WARNING: the build script needs editing if you rename this label
    2. movewZ80CompSize: move.w #Snd_Driver_End-Snd_Driver,d7


    Delete this.

    Code (ASM):
    1. Snd_Driver:
    2. ; loc_ED04C:
    3. Snd_Driver_End:


    Delete this too.

    Find this:

    Code (ASM):
    1.     shared word_728C_user,Obj5F_MapUnc_7240,off_3A294,MapRUnc_Sonic,movewZ80CompSize


    Delete the last entry.
    I'm certainly interested in this driver, after leaving the Clone Driver due to RAM and CPU demands, and being too stupid to figure out how to expand the music index in the S2 driver, this has certainly caught my interest. Just too bad this thing's incompatible with everything, even itself: I adjust the settings at the top of the file so it only bincludes the S2 DAC samples, and the thing goes and doesn't compile the second DAC bank despite still being referenced and needed! :argh:
     
  11. flamewing

    flamewing

    Emerald Hunter Tech Member
    1,138
    0
    16
    France
    Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
    The driver changed the way held notes are specified; specifically, it changed how silence is held. Old songs need to be edited accordingly.

    Well, the driver was intended originally as a drop-in replacement for the S&K driver, but with the ability to use S1 and S2 songs; so I never really tried to assemble it with only S2 DAC samples.