Sonic and Sega Retro Message Board: S1-friendly improved Sonic 2 sound driver - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
Page 1 of 1
    Locked
    Locked Forum

S1-friendly improved Sonic 2 sound driver April Fools' joke gone too far

#1 User is offline Clownacy 

Posted 19 April 2015 - 05:30 PM

  • Needs to make an avatar
  • Posts: 310
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
Have you ever wanted to replace your Sonic 1 sound driver with Sonic 2's? Less buggy, doesn't need loads of (non-Z80) RAM, frees up a little of the 68k, and is more compatible with the original music and SFX than S3K's driver.

It's certainly possible, but bumps in the road are plentiful, and soon, limitations of S2's driver will get in your way. The driver isn't the most usable: compression woes, the mess of porting the thing in the first place, there are only two music banks, one DAC bank, and a very limited number of music slots. Not to mention, the driver itself has very little room for additions to the code. There's also the total lack of support for Special SFX, which GHZ's waterfall uses, and the MZ push SFX behaviour.

Over time, there have come guides that correct these, and it seems the only hurdle left is S1 support. The process is a little... involved, so, rather than a guide, I think something pre-made would be better. I might still eventually split some of this into guides, but that's for another time.

I suppose I should bring up one interesting barrier, sound driver compression: Sonic 2's disasm assembles and compresses the driver at build time. The compression used is Saxman. S3K's and S1's disasms don't do this. Until recently, S1 didn't compress anything at all, but the addition of a disassembled Z80 DAC driver necessitated the addition of a compress-to-Kosinski function, which S3K also has. Changing this would require the user compile a modified s1p2bin. It would be easier to just make the driver settle for Kosinski compression, which I think is better, anyway.

Anyhow, here's a features list.

Features:
  • No Saxman-compressed music - Free up a lot of Z80 RAM
  • Driver is Kosinski-compressed - Better compression, so it seems. Also, S1's disasm supports this by default
  • Support for >2 music banks
  • Support for >1 DAC banks
  • Additional bugfixes
  • Smaller FM frequencies table - More RAM
  • S3K PSG frequency range
  • Track RAM optimisation - More RAM
  • Greater sound ID range - $01-$FF
  • No sndDriverInput - Writes are direct, a la S3K
  • Restored broken sound queue - Used for music :specialed:
  • DAC auto-bankswitch - No need to worry about sample alignment
  • SMPS2ASM
  • Toggleable features - What you do need, and what you don't
    • Special SFX support
    • MZ block push SFX support
    • CPZ's gloop SFX support
    • Spin dash rev SFX support
    • Sonic 2 PSG envelopes
    • Sonic 2 DAC samples


Download (code) | Download (ROM)

S1 VS S2:
Spoiler


Installation:
Spoiler


Fixing up the SEGA screen:
Spoiler


Correcting silence on screenmode change:
Spoiler


Expanding sound test:
Spoiler


Removing needless Z80 stops:
Spoiler


Changelog:
Spoiler


Credits:
Valley Bell - Bugfixes, S2Beta4 driver disassembly (source of Push SFX support)
Flamewing - SMPS2ASM, >$1F songs expansion, pointing out S3K's additional frequency values, improvement for DAC channel register setting
Vladikcomper - Elements of the DAC-related improvements
Clownacy - Making the driver good
This post has been edited by Clownacy: 17 May 2015 - 09:19 AM

#2 User is offline Clownacy 

Posted 24 April 2015 - 04:20 PM

  • Needs to make an avatar
  • Posts: 310
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
Update - v1.1


- Added a new bugfix (PSG fade)
- Stripped down SMPS2ASM core
- Added new driver optimisations (size)
- Improved bugfix descriptions
- Corrected (my) bug in 1-up music backup ('SFX overriding' bit was not cleared)
- Optimised some Special SFX code
- Improved cfOpF9 description
- Added another bugfix (accidental delay on first frame of music playback)
- Switched to S3K's tempo algorithm for the above fix
- Made necessary changes to SMPS2ASM
- Optimised zMasterPlaylist's entry size (3 bytes)
- Moved zDACDecodeTbl to align better
- Changed 'jr' to 'jp' in zWriteToDAC
- Corrected (my) bug in gloop SFX code being skipped
- Removed (my) redundant bankswitch under zloc_F1D
- Renamed 's2.sounddriver.compatibility.asm' to 's2.sounddriver.stuff.asm'

#3 User is offline Caverns 4 

Posted 29 April 2015 - 10:07 PM

  • Posts: 271
  • Joined: 07-December 12
  • Gender:Male
  • Project:Sanik Quest: Journey To The Right
I saw some of the fixes you made to Sonic 2 itself on GitHub - Very impressive stuff.

One thing I do like about the Sonic 2 Sound Driver is that is uses the Z80 Processor as you mentioned instead of just tossing more work onto the 68k(Not that the 68k couldn't handle that and more, that thing's a beast for the time). That in itself is a good enough reason for me to use this over the Clone Driver, which is still good work.
I do have one question though. Since this is essentially a SMPS2ASM Compatible Sonic 2 Sound Driver with tweaks and bugfixes, how friendly is it for use in Sonic 2 itself? Forgive me if it's a stupid question, I don't really now how hard the process of integrating SMPS2ASM support is, and therefore how little or how much you had to change.

#4 User is offline MainMemory 

Posted 29 April 2015 - 10:25 PM

  • Every day's the same old thing... Same place, different day...
  • Posts: 3369
  • Joined: 14-August 09
  • Gender:Not Telling
  • Project:SonLVL
  • Wiki edits:1,339
SMPS2ASM can be used without any modifications to the sound driver (just define SonicDriverVer = 2 and include _smps2asm_inc.asm before any ASM'd songs), and Sonic 2's driver is capable of playing music made for the S1 driver without any modifications. What does require modifications, is adding the DAC samples and PSG envelopes required for S3K/S3D songs, adding more music/DAC banks that more music requires, and bugfixes.

#5 User is offline Clownacy 

Posted 30 April 2015 - 01:55 PM

  • Needs to make an avatar
  • Posts: 310
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
This driver's currently in a form where an S2 equivalent would just be a stock S2 driver with all the guides applied. I still need to make some guides on restoring the Special SFX system, MZ push SFX, and optimising track RAM, but otherwise, it's all there. Even most of the bugfixes and code optimisations have been merged into the S2 Git disasm. Check the links in the credits for all the guides used.

Otherwise... porting this back to S2 would require modifying s2p2bin.exe to compress the driver in Kosinski, or modify SoundDriverLoad to decompress from Saxman. You'd also need to replace the music, SFX, their pointers, speed-up tempos, and all that other stuff with their S2 equivalents. You would also need to remove SndDriverInput, and replace the pause feature with this driver's equivalent. The toggles at the start of the driver would also need to be changed, so the Spin Dash, gloop, DACs and PSGs work. That's not even going into the redundancies within stuff.asm that will cause errors.
This post has been edited by Clownacy: 30 April 2015 - 06:25 PM

Page 1 of 1
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users