How to restore Sonic 1 prototype drums

Discussion in 'Tutorials' started by SomeUser214, Jun 1, 2021.

  1. SomeUser214

    SomeUser214 Newcomer Trialist

    Joined:
    Dec 22, 2020
    Messages:
    9
    Recently, I figured out how to restore Sonic 1 prototype drums, so I decided to make this guide.
    Thanks to Clownacy, Speems, and JGamer2151 for telling me a more accurate way to restore the prototype drums.
    Step 1:
    Go to the "sound" folder and open up "z80.asm" in a text editor. Once you have done that, replace this
    Code:
    zPCM_Table:
        dw    zDAC_Sample1    ; Kick sample
        dw    (zDAC_Sample1_End-zDAC_Sample1)
        dw    0017h            ; Pitch = 17h
        dw    0000h
    
        dw    zDAC_Sample2    ; Snare sample
        dw    (zDAC_Sample2_End-zDAC_Sample2)
        dw    0001h            ; Pitch = 1h
        dw    0000h
    
        dw    zDAC_Sample3    ; Timpani sample
        dw    (zDAC_Sample3_End-zDAC_Sample3)
    zSample3_Pitch:
        dw    001Bh            ; Pitch = 1Bh
        dw    0000h
    with this
    Code:
    zPCM_Table:
        dw    zDAC_Sample1    ; Kick sample
        dw    (zDAC_Sample1_End-zDAC_Sample1)
        dw    0019h            ; Pitch = 19h
        dw    0000h
    
        dw    zDAC_Sample2    ; Snare sample
        dw    (zDAC_Sample2_End-zDAC_Sample2)
        dw    0006h            ; Pitch = 6h
        dw    0000h
    
        dw    zDAC_Sample3    ; Timpani sample
        dw    (zDAC_Sample3_End-zDAC_Sample3)
    zSample3_Pitch:
        dw    0020h            ; Pitch = 20h
        dw    0000h
    Then save the file.
    Step 2:
    Next, go to s1.sounddriver.asm, and find "DAC_sample_rate:". Once you did, replace this
    Code:
    dc.b $12, $15, $1C, $1D, $FF, $FF
    with this
    Code:
    dc.b $17, $1A, $21, $22, $FF, $FF
    Then save the file, and your done!
     
    Last edited: Jun 2, 2021
  2. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,016
    ...Huh? I don't think that's the way you're meant to do it. The drum files are the same in both the prototype and the final version of the game. What makes them sound different is the speed they play at: the prototype has different speeds, giving the drums different pitches. I imagine the reason what you're doing works is because the speed values Mega PCM uses for Sonic 3's drums happen to result in a similar pitch to the values used by Sonic 1's prototype, so swapping the drums without correcting the speed values happens to create drums that sound like they do in the prototype.

    The speed values can be found here (labelled 'pitch'), in the DAC driver. Higher numbers create lower pitches/speeds. I don't know exactly which numbers are needed to recreate the prototype drums, but you can experiment to figure them out. Note that the disassembled Z80 driver only exists in the AS branch of the Sonic 1 disassembly, so you have to use that if you want to make this modification.
     
    Last edited: Jun 1, 2021
  3. Speems

    Speems Well-Known Member Member

    Joined:
    Mar 14, 2017
    Messages:
    83
    Location:
    Rochester Hills, MI
    Yeah, Mega PCM is not how you would restore the prototype drums for perfect accuracy. Especially since it doesn't sound exact since it plays the 16Khz versions of the samples due to how it's set up. So when it comes to Clownacy's idea of editing the speed value, it sounds more legitimate and a good way the proto drums and the Sega chant can be together. For the kick, add 2 (19h). The snare requires an addition of 5 (6h). Currently trying to figure out the right digit for the third sample (timpani) but I can confirm it sounds more accurate while playing it alongside the ripped samples through a certain emulator's sound layer tricks.
     
  4. JGamer2151

    JGamer2151 Well-Known Member/Lurker Member

    Joined:
    Dec 1, 2020
    Messages:
    94
    Alright, so I have figured out the proto pitches (speed values) for the timpani sample (the third sample) while comparing the proto ROM to my Sonic 1 test ROM with this guide applied. This is essentially continuing on from where Speems left off. Basically, I had to add the pitch of the timpani sample by 5 (20h) just like with the snare drum sample, and then go into s1.sounddriver.asm and change the four values of the timpani samples at DAC_sample_rate: before the two $FFs to be an addition of 5.

    For example, we'll go to "DAC_sample_rate" and see this:
    Code:
    dc.b $12, $15, $1C, $1D, $FF, $FF
    We can change those four values by adding them by 5, giving our result of this:
    Code:
    dc.b $17, $1A, $21, $22, $FF, $FF
    With that being said, this additional method restores the Sonic 1 proto samples in the finalized build of Sonic 1.

    And hey, this was my second post here on this forum. Hello again!
     
    Last edited: Jun 1, 2021
  5. Speems

    Speems Well-Known Member Member

    Joined:
    Mar 14, 2017
    Messages:
    83
    Location:
    Rochester Hills, MI
    I can confirm both of these work and sound like a perfect implementation of the proto drums in Sonic 1 final, at least for the AS disassembly. The primary GitHub and Hivebrain disassemblies need their own methods of restoring the proto drums, with bonus points for retaining the Sega chant like with this.
     
  6. Deactivated Account

    Deactivated Account Well-Known Member Exiled

    Joined:
    Aug 26, 2016
    Messages:
    244
    I remember hearing these samples in an old hack called 30 Days Challenge, so now I see that it can be modified not only in MegaPCM. I must also explore the values in the original disassembly to see the rate as it works.
    So the values can be raised up to 5 hz, the maximum I guess is 12 hz, no?
     
  7. Speems

    Speems Well-Known Member Member

    Joined:
    Mar 14, 2017
    Messages:
    83
    Location:
    Rochester Hills, MI
    This is not a joke, I managed to figure out applying the DAC pitches from the prototype into the final version of Sonic 1 with the original Hivebrain disassembly. So how do we get this achieved? Here's how we do this.

    First off, download Puto's disassembly of the Z80 portion of S1's sound driver:
    https://forums.sonicretro.org/index.php?threads/sonic-1-z80-driver-disassembly.9504/

    Next up, open the smps.asm file and locate PCM_Table. Change the values to represent the following:
    Code:
    PCM_Table:
        dw    DAC_Sample1    ; Kick sample
        dw    (DAC_Sample1_End-DAC_Sample1)
        dw    0019h        ; Pitch = 19h
        dw    0000h
      
        dw    DAC_Sample2    ; Snare sample
        dw    (DAC_Sample2_End-DAC_Sample2)
        dw    0006h        ; Pitch = 6h
        dw    0000h
      
        dw    DAC_Sample3    ; Timpani sample
        dw    (Dac_Sample3_End-DAC_Sample3)
    Sample3_Pitch:
        dw    0020h        ; Pitch = 20h
        dw    0000h
    Save and build the file, giving you a smpsbuilt_compressed.bin alongside an uncompressed version. Ignore the latter file. Copy the former file (compressed) and paste it in the sound folder of your disassembly. Don't forget to rename the file to "z80.bin" without quote marks. If you don't want a contribution to an ever growing pile of disassemblies, the z80 file made for this guide is attached on this post.

    Now we're going to delete the _1 and _2 files since we're not using separate files anymore. Now don't build just yet because we're taking care of the code now.

    Head to the sonic1.asm file and search for Kos_Z80, which gives us this:
    Code:
    Kos_Z80:    incbin    sound\z80_1.bin
            dc.w ((SegaPCM&$FF)<<8)+((SegaPCM&$FF00)>>8)
            dc.b $21
            dc.w (((EndOfRom-SegaPCM)&$FF)<<8)+(((EndOfRom-SegaPCM)&$FF00)>>8)
            incbin    sound\z80_2.bin
            even
    Delete the z80_2 line and remove the _1 from that top line. Save and build, and we legitimately have the prototype sample pitches in the final game. At least for the kick and snare, there's something else we gotta do for the timpani. Look for byte_71CC4 in the same sonic1.asm file and you should have these digits:
    Code:
    byte_71CC4:    dc.b $17, $1A, $21, $22, $FF, $FF
    Save and build once more and you're covered on the timpani. Congrats, now the Hivebrain 2005 disassembly is covered!
     

    Attached Files:

    • z80.bin
      File size:
      5.8 KB
      Views:
      152
    EddyTF, Scrap Sorra and JGamer2151 like this.
  8. EddyTF

    EddyTF somebody once told me Member

    Joined:
    Jan 9, 2022
    Messages:
    70
    Location:
    Russia
    Hmm... An interesting thing, but there is still an option how to install Sonic 1 MegaPCM and put the drums out of Sonic 1 Prototype Disassembly, I do this