don't click here

[SONIC 1] How to add more samples using S1HL custom driver

Discussion in 'Engineering & Reverse Engineering' started by Eduardo Knuckles, Apr 28, 2009.

Thread Status:
Not open for further replies.
  1. Eduardo Knuckles

    Eduardo Knuckles

    Not a loved one, but the most hated person. Banned
    414
    10
    18
    Someplace somewhere
    Project S.A.M.G.
    First of all, all who wants to use this driver needs to give total credits and thanks for HPZMan, that is the author of it. Without him and his large knowledge with samples, this wouldn't have been possible. I thank him especially for the enormous work which he had with this driver for Sonic 1 Harder Levels. Now I let it available to the entire community.


    HPZMan notes:
    "I made this custom driver using the Sonic 1 z80 disassembler by Puto. This was made for use in Sonic 1 Harder Levels. I'm posting it authorized by Eduardo Knuckles. With this driver you can use up to one bank per sample if you want. I know that this is nothing new but it may help someone."


    Before start the work, download the custom sound drive's source code here:
    DOWNLOAD
    (If the link is broken, send a PM for Eduardo Knuckles for re-upload the file)




    1 - Defining the bank

    Go to PCM_Table:
    Every pointer uses 4 lines in word (4 bytes). The first byte on the fourth line in all the pointer defines the bank. To set the bank, get the location of the sample and divide by $10000, and modify the byte to the location divided. If you want, for example, another bank to sample $82, just go in his pointer in the first byte of the fourth line, put the location of the bank (which is the location of the sample divided by $10000).
    The samples should always be located at $8000-$FFFF in banks. This is the limit for every samples bank.




    2 - How to expand the slots

    Sonic 1, by default, uses a routine in 68K to change the speed of the Timpani drum, I just don't think this is a good idea because it could interfere when you are creating more slots. I will explain below how to remove this "pitch changer" mechanism.
    Well, go to PCM_Table: you will see this:

    Code (Text):
    1. PCM_Table:
    2.     dw  DAC1_Location; Kick sample
    3.     dw  DAC1_Size
    4.     dw  0017h; Pitch = 17h
    5.     dw  0000h
    6.    
    7.     dw  DAC2_Location; Snare sample
    8.     dw  DAC2_Size
    9.     dw  0001h; Pitch = 1h
    10.     dw  0000h
    11.    
    12.     dw  DAC3_Location; Timpani sample
    13.     dw  DAC3_Size
    14.     dw  001Bh; Pitch = 1Bh
    15.     dw  0000h

    Sonic 1 has actually 3 instruments. To expand, change it to:
    Code (Text):
    1. PCM_Table:
    2.     dw  DAC1_Location; Kick sample
    3.     dw  DAC1_Size
    4.     dw  0017h; Pitch = 17h
    5.     dw  0000h
    6.    
    7.     dw  DAC2_Location; Snare sample
    8.     dw  DAC2_Size
    9.     dw  0001h; Pitch = 1h
    10.     dw  0000h
    11.    
    12.     dw  DAC3_Location; Timpani sample
    13.     dw  DAC3_Size
    14.     dw  001Bh; Pitch = 1Bh
    15.     dw  0000h
    16.    
    17.     dw  DAC4_Location; Timpani sample
    18.     dw  DAC4_Size
    19.     dw  001Bh; Pitch = 1Bh
    20.     dw  0000h
    To create a variation of a instrument, just create another pointer pointing to the same sample, but using a different speed.



    3 - Setting up the sample size and location

    Go to DAC1_Location, you will see this:

    Code (Text):
    1. DAC1_Location   equ  0000h
    2. DAC2_Location   equ  0000h
    3. DAC3_Location   equ  0000h
    Change the 0000h to the location of the sample >ON THE BANK<.
    For example, suppose you put the sample $81 and $82 in a bank located in $080000, and if the sample $82 is located at

    $088A1C, you should change to:

    Code (Text):
    1. DAC2_Location   equ  8A1Ch
    If the sample $83 is located at the begining of a new bank, the location for it should be 8000h.
    To define the size, go to DAC_Samples_size:, and change the 0000h for the size of the sample.



    4 - Removing the 68k speed changer:

    In Sonic1.asm from your hack make a search for loc_71C88:, and you will see this:

    Code (Text):
    1.         btst    #3,d0
    2.         bne.s   loc_71CAC
    Just remove or comment these lines.



    5 - Including your new sound driver to your source code

    Just go to Kos_Z80:, and you should view this:

    Code (Text):
    1. Kos_Z80:    incbin  sound\z80_1.bin
    2.         dc.w ((SegaPCM&$FF)<<8)+((SegaPCM&$FF00)>>8)
    3.         dc.b $21
    4.         dc.w (((EndOfRom-SegaPCM)&$FF)<<8)+(((EndOfRom-SegaPCM)&$FF00)>>8)
    5.         incbin  sound\z80_2.bin

    Change to this:
    Code (Text):
    1. Kos_Z80:    incbin  z80.bin
    2.         even

    And you need to include the samples banks too. Go to ; end of 'ROM', and add this:

    Code (Text):
    1. ; S1HL DAC samples banks:
    2.         align $240000
    3.         incbin 'S1HLDACBank.bin'
    4.                 align $250000
    This will add the samples bank align it to the offset $240000 in it.
    Then, create your samples bank file putting it on the same directory as the Sonic1.asm file, and starting put your samples on your new driver.
    note: *the example I used shows S1HLDACBank.bin as a example of the file name.

    The result will be:
    Code (Text):
    1. ; S1HL DAC samples banks:
    2.         align $240000
    3.         incbin 'S1HLDACBank.bin'
    4.                 align $250000
    5. ; end of 'ROM'
    6. EndOfRom:
    Just for remember, this driver use compressed samples, as the original Sonic 1 sound driver.
    Make it useful. Please don't forget to credit HPZMan when you use it. Don't credit me, because all the work on it was made by him.
    Thanks Puto for the Sonic 1 Z80 driver disassembly.
     
  2. Master3k

    Master3k

    Member
    278
    0
    0
    Heh, nice job HPZMan did with that.

    Nothing very new to me, as I've been using that driver for 7 months or so. Still a nice job.

    EDIT:7 months, not 8.
    EDIT2:That, and S1HL driver? Wrong name much? I think it should be called HPZMan's Custom S1 driver (or HCS1D).
    I'm only one person, though.
     
  3. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    This is quite useful, Eduardo Knuckles.

    You told me about this a while back, but this helps me understand it. ;)
     
  4. Ollie

    Ollie

    DIGGY DIGGY HOLE Member
    Because Music Hacking isn't my strong point, care to explain the advantages of using this driver instead of the original's?
     
  5. Hitaxas

    Hitaxas

    Retro 80's themed Twitch streamer ( on hiatus) Member
    You can add any DAC sample you want to your ROM,which can lead to some very great music.
     
  6. Eduardo Knuckles

    Eduardo Knuckles

    Not a loved one, but the most hated person. Banned
    414
    10
    18
    Someplace somewhere
    Project S.A.M.G.
    Yes.

    This feature will able you to add different kinds of instruments to the songs you want to add, without that weird S1 thing that limits the DAC driver to have 3 instruments or less. Per example, if you import the Angel Island Act 1's song for your Sonic 1 you will need a big variation of instruments to make this song working fine. And others, adding dance or rock instruments, or specific sets of instruments for specific songs on your game. :eng101:
     
Thread Status:
Not open for further replies.