Some Sonic 2 Sound/Music Questions

Discussion in 'Discussion and Q&A Archive' started by Shadow Fire, Apr 9, 2012.

Thread Status:
Not open for further replies.
  1. Shadow Fire

    Shadow Fire Well-Known Member Member

    Joined:
    Aug 6, 2007
    Messages:
    303
    Okay, first of all, I would like to explain that I am planning on getting back into hacking Sonic: The Lost Land 2, as well as the original Sonic: The Lost Land. Since I'm working with ASM, it's safe to assume that I've had to do most of the edits I've already made to STLL2, from scratch. Much of it has been restored, and it's looking okay, but I'm having a few questions creeping up on me.


    Firstly, I wanna change the SEGA sound. I have a file that I want to use, but there seems to be no documentation around that explains how to make this happen.


    Secondly, I have music I wish to recover. In the original STLL2, Wing Fortress' level music was replaced by Flying Battery 1's. I can't seem to locate the updated pointer to the music files, and this leaves me a bit confused as to how to bring it back. I'd simply have taken it from S3K using Esrael's tool, but again, Sonic 2 receives no love.
     
  2. Tongara

    Tongara Well-Known Member Exiled

    Joined:
    Feb 10, 2009
    Messages:
    353
    Location:
    Birmingham, UK
    That one is super easy. You can overwrite the segapcm sound file itself with a wav that is 8-bit pcm (not sure if it's stereo or mono). You can download sndrec32.exe to do this!


    When overwriting the segapcm file, make sure that you're saving it as a .bin file.

    Try splitting your original version of the hack with a new disassembly, and see if you can recover the wing fortress .bin music file and replace it with the one in the new version of your hacks disassembly.
     
    Last edited by a moderator: Apr 9, 2012
  3. Shadow Fire

    Shadow Fire Well-Known Member Member

    Joined:
    Aug 6, 2007
    Messages:
    303
    First one sorted, thanks Tongara. For the record, it is 8-bit PCM, 16,000 KHz, Mono that is needed. Figured that out through trial and error.


    As for the FBZ music, I already tried that, but because the locations were altered, and I have no idea where to even begin looking (it seems the location for the pointers has changed also), I can't seem to grab it.
     
  4. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    I downloaded this application and it's in a different language so it's hard to get the hang of. But it seems it only saves as a WAV file. How do you convert it to .bin as I'm guessing it's not as simple as changing the extension from WAV to BIN?
     
  5. Tongara

    Tongara Well-Known Member Exiled

    Joined:
    Feb 10, 2009
    Messages:
    353
    Location:
    Birmingham, UK
    Generally where you select file type in any application, select all files and name it segapcm.bin or whatever the sega sound file is called. OR do what you said. :p
     
  6. ValleyBell

    ValleyBell Well-Known Member Member

    Joined:
    Dec 23, 2011
    Messages:
    166
    Don't make it more complicated than it needs to be - use Audacity.


    To open the SEGA sound, open the File menu and use Import -> Raw Data. The codec is "Unsigned 8-bit PCM".


    To save it, chose File -> Export. Then select the file type "Other uncompressed files", click the Options button and chose "RAW (header-less)" as header type and "Unsigned 8-bit PCM" as codec.


    Then save (ignore the metadata editor, it does nothing in this case) and you're done.


    If you already have a wav-file in the correct format, open it in the hex-editor of your choice and search for "data". Then delete all bytes from offset 0 to the data-text + the 4 bytes after the data-text. (usually 2Ch bytes or 38h bytes if there is a "fact" block between the "fmt" and "data" ones) Done.


    A last note: The size of the SEGA sound is hardcoded into the ROM, so you either need to find and fix this value or your new sound must have the exactly same size as the old one.
     
  7. Tongara

    Tongara Well-Known Member Exiled

    Joined:
    Feb 10, 2009
    Messages:
    353
    Location:
    Birmingham, UK
    Yes, because rather than just saving over a file, importing it as raw data, then editing it in a hex editor is so much easier.... right?


    I'm sorry, but are you on drugs? o_O
     
    Last edited by a moderator: Apr 9, 2012
  8. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    I didn't know it was as simple as naming from WAV to BIN, cheers =P

    That's a bummer. Anyway, I won't be changing the SEGA sound, just be adding some more PCM's. But is there a size limit for putting in PCMs?
     
  9. Tongara

    Tongara Well-Known Member Exiled

    Joined:
    Feb 10, 2009
    Messages:
    353
    Location:
    Birmingham, UK
    As long as it's exported with the right settings, you're good to go!


    As Shadow Fire said: " 8-bit PCM, 16,000 KHz, Mono".
     
  10. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    Generally what I do is:



    Code:
    Sound:        incbin    "Sound.wav", $3A
    
    Sound_End:    even

    WAV files that are 8-bit unsigned mono have a header size of 3A, by placing 3A at the end of the include of the WAV file, I have included the RAW PCM data without the header into the ROM, and I can easily open the sample with a sound/media player to see what it sounds like. This eliminates the need to extract it to RAW.
     
  11. ValleyBell

    ValleyBell Well-Known Member Member

    Joined:
    Dec 23, 2011
    Messages:
    166
    If the PCM sound is played by the 68000 (e.g. S2 Clone Driver), the limit should be the size of the ROM.


    If it's played by the Z80 (plain Sonic 1/2/3), the limit is usually the size of a Z80 bank, i.e. 8000h bytes.
     
  12. Spanner

    Spanner The Tool Member

    Joined:
    Aug 9, 2007
    Messages:
    2,570
    Shadow Fire, surely you could use the Clone Driver and port FBZ again, if you want the file grab it from flamewing's pack.
     
  13. Tongara

    Tongara Well-Known Member Exiled

    Joined:
    Feb 10, 2009
    Messages:
    353
    Location:
    Birmingham, UK
    I wasn't aware that you could just include the .wav files. That is quite amazing!


    The thing is, it doesn't ever really seem to need the header... it just seems to work.
     
  14. Shadow Fire

    Shadow Fire Well-Known Member Member

    Joined:
    Aug 6, 2007
    Messages:
    303
    I managed to (after a lot of hassle) port the clone driver, something I neglected, simply because I forgot to. =P However, this presents me with another problem. As you may or may not know, I have water loaded in MCZ, which I drew from HPZ, modifying its palette to fit with MCZ's already modded palette. The use of the clone driver has changed the underwater palette used, and I cannot for the life of me figure out how to change it to load from my altered palette.
     
  15. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    The problem is that the "Clone Driver" is Sonic 1's SMPS script player, and the address of where the sound driver stores its information is at FFF000+. Now, when Sonic Team changed their sound driver to use Z80 when working on Sonic 2, they decided to move the underwater palettes to where the sound driver space used to be:



    Code:
    Underwater_palette_2 =		 ramaddr( $FFFFF000 ) ; not sure what it's used for but it's only used when there's water
    
    Underwater_palette =		 ramaddr( $FFFFF080 ) ; main palette for underwater parts of the screen
    
    Underwater_palette_line4 =	 ramaddr( $FFFFF0E0 )


    What you will need to do, is change that address to somewhere else, somewhere where there's 100 bytes free to use, Sonic 1 had it's underwater palettes stored at around FFFA00 - FFFAFF if I recall correctly, and from the looks of things, Sonic 2 doesn't use that space (even though they moved the palette), so you "might" get away with moving the underwater palette back to it's original Sonic 1 address:





    Code:
    Underwater_palette_2 =		 ramaddr( $FFFFFA00 ) ; not sure what it's used for but it's only used when there's water
    
    Underwater_palette =		 ramaddr( $FFFFFA80 ) ; main palette for underwater parts of the screen
    
    Underwater_palette_line4 =	 ramaddr( $FFFFFAE0 )

    Although I know my way around the Mega Drive, I'm no expert on Sonic 2 specifically, so forgive me if this doesn't resolve your problem.
     
    Last edited by a moderator: Apr 10, 2012
  16. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    Funny, mine is:



    Code:
    Underwater_palette_2 = 		ramaddr( $FFFFF000 ) ; not sure what it's used for but it's only used when there's water
    
    Underwater_palette = 		ramaddr( $FFFFFA80 ) ; main palette for underwater parts of the screen
    
    Underwater_palette_line4 = 	ramaddr( $FFFFF0E0 )


    And the underwater palette is still fine, and I have the S2Clonedriver. Although I will say ValleyBell has heavily modified mine or has changed it completely. The only problem I get (which is rare) is when lots of objects are underwater, the underwater palette fucks up (sprite-table spills over onto the palette).












    The sound end is a little bit wierd. If I was to do more than 1 WAV, can I try this?







    Code:
    SoundA:		incbin	"Sound.wav", $3A
    
    SoundB:		incbin	"Sound2.wav", $3A
    
    MusicA:		incbin	"Music.wav", $3A
    
    Sound_End:	even


    or







    Code:
    SoundA:		incbin	"Sound.wav", $3A
    
        even
    
    SoundB:		incbin	"Sound2.wav", $3A
    
        even
    
    MusicA:		incbin	"Music.wav", $3A
    
        even




    The size for the 68k sounds way too much, and the Z80 size sounds way too small =P
     
  17. Shadow Fire

    Shadow Fire Well-Known Member Member

    Joined:
    Aug 6, 2007
    Messages:
    303
    I'm afraid that it hasn't resolved the problem...



    I'd like to point out that ARZ and CPZ's underwater palettes are fine, but MCZ isn't. Here is what the palette currently looks like:



    /monthly_04_2012/post-3-0-40820900-1334082912_thumb.gif



    It is meant to look like this:



    /monthly_04_2012/post-3-0-90740500-1334082989_thumb.gif



    It was working fine up until I ported the clone driver. When I look at the palette area for the water, it seems to be correct.





    Code:
    Level_LoadPal:
    
    	moveq	#3,d0
    
    	bsr.w	PalLoad2	; load Sonic's palette line
    
    	tst.b	(Water_flag).w	; does level have water?
    
    	beq.s	Level_GetBgm	; if not, branch
    
    	moveq	#$15,d0	; palette number $15
    
    	cmpi.b	#$B,(Current_Zone).w
    
    	beq.s	Level_WaterPal ; branch if level is HPZ (modified for MCZ)
    
    	moveq	#$16,d0	; palette number $16
    
    	cmpi.b	#$D,(Current_Zone).w
    
    	beq.s	Level_WaterPal ; branch if level is CPZ
    
    	moveq	#$17,d0	; palette number $17
     

    Attached Files:

    Last edited by a moderator: Apr 10, 2012
  18. DrHackMan

    DrHackMan I don't always herp, but when I herp, I derp Member

    Joined:
    Oct 16, 2010
    Messages:
    33
    Location:
    Eggmanland
    Try to comment the driver out part for part. If it works again you know what interferes with the palette.
     
    Last edited by a moderator: Apr 10, 2012
  19. Shadow Fire

    Shadow Fire Well-Known Member Member

    Joined:
    Aug 6, 2007
    Messages:
    303
    XD After ages and ages, I just happened upon the problem by chance. For some reason, when I added in the clone driver, part of my code reverted. This is the code I needed to fix:



    Code:
    loc_42C8:
    
        tst.b    (Water_flag).w
    
        beq.s    loc_42E8
    
        moveq    #$15,d0
    
        cmpi.b    #8,(Current_Zone).w ; <---- #8 = HPZ, I had to change that to #$B, which is MCZ
    
        beq.s    loc_42E4
    
        moveq    #$16,d0
    
        cmpi.b    #$D,(Current_Zone).w
    
        beq.s    loc_42E4
    
        moveq    #$17,d0

    I had done that before, or at least I thought I had. =P
     
Thread Status:
Not open for further replies.