How to Replace the Sega Chant

Discussion in 'Tutorials' started by Iso Kilo, Jan 10, 2019.

  1. Iso Kilo

    Iso Kilo Mediocre at best Member

    Joined:
    Oct 9, 2017
    Messages:
    85
    Location:
    Small Town in BC, Canada
    Recently, I had been asked how to make a high quality Sega chant replacement. So here I am.

    Edit: You guys really got pissed at the Mega PCM rant, so I'll just remove that. Not like it'll undo the damage, either way; sorry.

    This applies to the 2005 Hivebrain Sonic 1 disassembly, but if you have a brain, you can do it with other disassemblies.
    Firstly, follow this guide. If you don't, then it'd require some Z80 editing and I'd rather not get into that.
    Next, go into 'PlayPCM_Loop:' and find this line;
    Code:
    move.w    #$14,d0     ; Write the pitch ($14 in this case) to d0
    and replace #$14 with #$01. This means our sample will play as fast as possible, 27,025 Hz.
    That's all you need to do in Sonic 1 for now. Next we head to Audacity.
    Grab whatever sound you'd like to replace the Sega chant. Now, there's a few specifications you have to make.
    • Make sure the track is monophonic
    • Make sure the track's sample rate is 27,025 Hz as mentioned earlier
    • Make sure the Audacity's project sample rate is 27,025 Hz as well
    And that's it. Now you have to save the file, make sure to do it with these settings;
    [​IMG]
    Note that the file name can be whatever you want, "RHS_GodFuckingDammit" is just the name of the file I used for Tails' Tales. Once you have that saved, change the file extension to .BIN.
    Drag the file into the sound folder of your Sonic 1 disassembly. Now head down to the end of your main .ASM file, and find this line;
    Code:
    SegaPCM:    incbin    sound\segapcm.bin
    SegaPCM_end:    even
    Simply change it from segapcm.bin to whatever your sample is. Build and you should have your new sample!
    Note
    If you're working with Github, remove this from the end of the main file.;
    Code:
    if SegaPCM_End-SegaPCM>$8000
    
                inform 3,"Sega sound must fit within $8000 bytes, but you have a $%h byte Sega sound.",SegaPCM_End-SegaPCM
    
            endc
    
            if SegaPCM_End-SegaPCM>Size_of_SegaPCM
    
                inform 3,"Size_of_SegaPCM = $%h, but you have a $%h byte Sega sound.",Size_of_SegaPCM,SegaPCM_End-SegaPCM
    
            endc
     
    Last edited: Jan 11, 2019
    ProjectFM, Renegade and maple_t like this.
  2. Natsumi

    Natsumi Phoenix egg Member

    Joined:
    Oct 7, 2011
    Messages:
    659
    Location:
    Long and dangerous river
    I may note that you can remove the entire dbf loop to get even higher sample rate. Really would prefer to have options for other rates besides 27kHz, its unnecessarily high for a sample that is from few seconds to more than 10(!)
     
    ProjectFM and AkumaYin like this.
  3. Clownacy

    Clownacy Grumpy Staff

    Joined:
    Aug 15, 2014
    Messages:
    849
    What does this have to do with anything? You're not showing people how to improve the DAC driver: you're telling them to follow a guide that makes the 68k play the Sega chant... which MegaPCM's installation guide also does.

    MegaPCM has scratchy audio because of the limitations of the Z80, namely how it's halted by DMA transfers and 68k IO accesses all the time. And yet, this is only a problem outside the Sega screen: the game already avoids doing DMAs and IO accesses while the Sega chant is playing, making it as stutter-free as possible.

    So what was the point of that rant? Stuttery voice clips during gameplay? This guide does absolutely nothing about that, and yet it says it can "end that today, and for the future".

    People recommend MegaPCM for voice clips because, unlike S1's DAC driver, it doesn't store all of its samples in Z80 RAM, it can play PCM audio instead of DPCM, it supports large samples, it has a priority system, and it can play at the 2612's maximum sample rate. The only upside S1's DAC driver has is that it avoids being paused by DMAs while playing DPCMs since they're read from Z80 RAM, not the cartridge.

    If you want mostly-stutter-free samples during gameplay, either don't use DMAs, or use a driver like DualPCM that buffers its samples to avoid DMA stalling.
     
    Last edited: Jan 11, 2019
    ProjectFM and AkumaYin like this.
  4. Iso Kilo

    Iso Kilo Mediocre at best Member

    Joined:
    Oct 9, 2017
    Messages:
    85
    Location:
    Small Town in BC, Canada
    I didn't know how the MegaPCM works, that was merely an observation I had made. Feel free to use whatever method you'd like, I just found this one to be the most clean way to do it for me, and hopefully others see it that way too.
     
  5. Clownacy

    Clownacy Grumpy Staff

    Joined:
    Aug 15, 2014
    Messages:
    849
    What method? You're making it sound like you found some kind of alternative, but you're only doing the exact same thing MegaPCM's installation guide tells you to do.