Sonic 2 Clone Driver v2 v2.7 | and other SMPS-related ramblings
Posted 04 May 2014 - 09:46 AM
Posted 17 June 2014 - 12:45 PM
- Compressed Mega PCM Z80 code, DAC tables are still uncompressed though
- Reintroduced Mega PCM .wav compatibility
- Matched S2 DAC pitches to those in the S2 driver, but they're still inaccurate, the snare seems to be BETWEEN 3 and 4
- Added Crackers DACs
- Fixed SMPS2ASM's dLowerEchoedClapHit entry
- Relocated Coord flags from $E0+ to $FE+, as a result, there are now free DAC slots and a total of $7C DAC slots
- Corrected S3/K/3D DAC order
- Named all S3/K/3D/C DACs
- Removed cfStopSpecialFM4
- Removed more Special SFX remnants, namely v_special_voice_ptr
- Freed up a tiny amount of RAM by turning some byte-sized flags to bit-size. They are grouped under the RAM address 'misc_flags'. Flags include:
- f_updating_dac and f_fadein_flag been changed to a bit, so their 'On' state isn't defined by being set to $80, but to 1
- Removed f_fastmusic entirely, it's not even used in this version of the Community disasm. It's just v_1up_ram_copy's copy of f_speedup
- Fixed typo in instruction under PSFX_NotSpinDashRev label
- Rearranged RAM variables to group all unused RAM in one area ($19-$39)
- Split music and sound 'include's from main asm file, allowing users to update their s1.sounddriver.asm without overwriting their custom music and sound 'include's
- Done the above to the music and SFX pointers, also. Said pointers have also been moved to above their respective 'include's, for sake the of ease when updating
- Added missing equate under Sound_PlaySpecial
- Modified installation guide to feature a full-speed PAL audio fix, straight from MJ's Moonwalker
With the v2.1.3 update, an update-friendly system has been introduced, to make it possible for one to update without losing their custom music and SFX.
Hopefully, this is the end of my optimisation spree, and I'll finally move on to adding some features...
...which I apparently couldn't wait to get to and already added one! That last point, I'm quite happy with; at least something came of that Moonwalker SMPS disassembly. I'll see if I can pick anything from it in the future. It's slightly modified, however: Moonwalker used word operations on PAL_Audio_CountDown despite the highest value written to it being 5. I'm surprised the issue of slowed music on PAL units evaded me until now. I hadn't even thought of it despite me being in a PAL region, myself :P
Posted 28 June 2014 - 10:11 PM
- Rearranged indexes and data again, now they are all located after the driver's code
- Reformatted PSGDoVolFX
- Ported three new PSG flags, two are used by S3K's PSGs, the final is unused, but added for the sake of completion
- Now using stock S3K PSGs instead of converted-to-S1 equivalents
- Ported S1 & S2 PSGs
- Added missing 'even' after the Universal Voice Bank
- Optimised the unused coordination flags' code
- Optimised some code under Sound_Play
- Corrected some comments
- Ported S3K's TempoWait, allowing full access to S3K-style tempos
- Added S2 speedup tempos, converted to S3K tempos
- Replaced the Original Clone Driver's modified S2 music with stock S2 music
Well, that's it. This now has features and code from at least five different drivers crammed into it. I'm officially dubbing this 'Project Clusterfuck'.
You must overwrite _smps2asm_inc.asm with the new one. This is to allow usage of S3K tempos.
Posted 03 July 2014 - 09:46 AM
- Removed 68K-freeze code in PlaySega, it has negative effects in Sonic 2
- Added coordination flag cfSilenceStopTrack
- Added coordination flag cfPlayDACSample
- Added coordination flag cfPlaySound
- Added coordination flag cfSetKey
- Added coordination flag cfSetVolume
- Removed two unused coordination flags
- Redone PAL mode
- Replicated S2's ability to force PAL slowness on certain songs
- Optimised PAL mode
- Ported S2's PAL timer system
- Made PAL_Audio_CountDown part of the Clone Driver's RAM
The 68k halt code caused the SEGA screen to overstay its welcome.
Added some pointless and gimmicky coordination flags as an exercise in porting from Z80 ASM. I'm not too sure of the intended function and use of cfSetKey and cfSetVolume, but they're ported as literally as possible, while being optimised for 68k. I can't find any S3K songs to test these on, except the S&K credits, whose playback is broken in this driver, but that probably goes all the way back to S1 bugs or S3K's weird note reading bugs/features.
Does anyone remember how in S2, if on a PAL system, most of the game's music would play at non-PAL speeds, yet the drowning theme played at PAL speed? That was so the drowning theme was synchronised with the gameplay. In v2.2.1, I replicated the feature. Well, it's more of a port, but the way the music index is set to determine if a song should play at PAL speed was my own method. Because the music has to begin on an even address, the indexes never make use of the odd/even bit of the addresses. I now use that bit as a PAL mode on/off flag. To make use of it, just append your song's index entry with "+1". See s1.sounddriver.music.asm for an example.
I had some problems with using jumps to achieve PAL mode, so v2.2.1 contained a hackish way of processing the same code twice. For some reason whatever made jumps problematic doesn't exist in v220.127.116.11, so the code's been optimised to use them again.
MJ's Moonwalker's PAL mode code has been replaced with S2's. Moonwalker's updated the entire driver twice on every fifth frame. S2's only updates the music channels twice. S2's is also better synchronised, as Moonwalker forces the PAL timer to 5 in SoundDriverLoad, S2 does that whenever new music is played.
When updating to v2.2.1(.1), you need to append the drowning theme's index entry with "+1", like this:
ptr_mus9F: dc.l Music9F+1
This forces the song to play at PAL speed on PAL consoles, for synchronisation.
Remove the PAL_Audio_Countdown constant from s2.constants.asm. It's been relocated to Clone_Driver_RAM.
Posted 03 July 2014 - 11:02 AM
Posted 03 July 2014 - 07:56 PM
In other news:
Oh god, what have I done, SO MUCH LAGS
Nah actually. The game performs just fine.
So, I thought I'd pick up where Bobesh8 left off and port a 68K SMPS sound driver to Sonic 3 & Knuckles. In order to free up the RAM for the new sound driver, I decompressed the level Blocks and had the game load them from ROM as uncompressed data. Just as MarkeyJester had recommended in Bobesh8's topic.
S3K's disassembly hasn't been developed enough for a switch to a new driver to happen smoothly. Because of this, I never fixed the sound effects, otherwise I'd be doing that forever. Music/SFX IDs help big time in these situations.
This was a good learning experience. Outside of the hardcoded nonsense regarding sound effect and music calls, porting the sound driver is incredibly easy. The method being extremely similar to porting the driver to Sonic 2. Porting this to S3K is actually easier, due to that game's driver being not as deeply integrated as Sonic 2's, allowing easier removal.
Posted 04 July 2014 - 11:54 AM
I've actually been working on this lately. When it's done I'll post the list on THIS thread and everyone can take a look, offer their two cents, etc.
Posted 04 July 2014 - 02:34 PM
I still see the Clone Driver as an archaic mod made for those who didn't understand Sonic 2's sound driver. Sonic 2's sound driver does support uncompressed files (the credits!), and while yes, there are some nuances that are a pain to work with, I'd rather use something that doesn't require both overhauling the entire game and potentially breaking the game and is instead more powerful than what's being used.
That being said, I'm intrigued by the modifications you've made to the sound driver yourself (particularly actual PAL support; that's really neat) so I'll keep an eye on how this progresses.
(particularly referring to Clone Driver in S3K in this post, if it wasn't clear, but Clone Driver in S2 is still something I see as unnecessary today)
Posted 04 July 2014 - 03:57 PM
When I first released the Clone V2, back in its 2.0 days, I didn't have much faith in it. Back then, it had flaws, flaws inherent from Sonic 1's driver. The tempos would never match S2's, the speed shoes would be forever broken, it was missing a sound flag, StopSFX. So, in my own hack, when the lack of coord flags in S2's driver got in the way of my music porting, I switched to Flamewing's S3K driver. A case of a boxing coach that bets against his own fighter :P. But now, the S3K driver's limitations have gotten in my way, and guess what I'm switching to? And if any missing flags get in my way, I'll port them. What I'm saying is, I feel that the 68K SMPS driver has more potential. If the only true limitation in software is hardware, then I don't wanna get comfortable with the Z80.
Installation doesn't require a total overhaul, where'd you get that from? You have a sound ID relay/input, which any SMPS-using game has, a Z80 DAC driver loader, and a jump to the driver in V-Int. That's all. That's the minimal amount you need. Compare that to S3K's driver, what, the only thing the S3K driver doesn't need is the jump in V-Int. Real minimal...
SMPS2ASM support isn't exclusive to Flamewing's driver, you could get it working with the stock buggy S3K driver. Even S2's driver, or S1's, or this one. But how is S3K's driver better? It has space limitations, bizarre note reading "bugs", lacks an FM6 channel, and you can't go crazy with the DAC channel. And I'm not talking 'Jester's Challenge' kind of DAC usage, even the more minimal of things such as Ristar's usage seems to have justified the use of a 68K driver. So what if the 68K looses some cycles to the driver? What good is all the effort put into optimising our hacks if we aren't gonna cash in on the free cycles? What, is Sonic Classic Heroes bad for using an additional AI? Anyway, S3K's so optimised that I never encountered slowdown, S2 runs just as crap as it always does, is 3.2% really that much? I'll assume that's what you meant by the driver "breaking the game".
The port to S3K was mostly a joke and a test to see if there's any truth to this "but think of the lag!" thing that gets passed around whenever someone uses something that isn't the S3K driver. The Clone V2 was always intended for S2, just with S3K features for any music ports users were planing to do. But with the mimicking of S2's driver nearing perfection, the cloning of S3K looks like an interesting end goal for next time.
Let's step back for a bit. S1's driver is a modified 68K SMPS sound driver. It was stripped of a significant amount of code during S1's development (PSG flags, coordination flags), while containing some additions of its own (extra life system, speed shoes(?)). S2's driver, according to some sources, is Sonic 1's modified 68K SMPS driver ported to Z80 and modified (quite extensively). S3K's driver is a modified native-Z80 (unlike S2's) SMPS sound driver. It too was stripped of functions (FM6 /> , songs being loaded into RAM), and had additions of its own (same as before). At their core, they're all variations of SMPS that have been meddled with. These modifications could be ported between them: I could get S3K's Spin Dash code working in S2's driver just as I did the latter's PAL mode in S1's. I could get S1's to load its songs into RAM, just as S2's did, even use Saxman compression. At their core, the only difference is the processor, and I'm bored of the LAGZ debates. Besides, why should I work on Z80 drivers when Flamewing seems to have that covered? An improved S2 driver is redundant. Might as well have the variation of both an improved Z80 and an improved 68K driver.
Posted 04 July 2014 - 04:58 PM
I would, however, like to nitpick that the 3.2% of frame time is used during V-Int, which lasts 5.7% of an NTSC frame: this is a full 56% of V-Int.
Edit: Striked out some technically irrelevant information (I had forgotten that music is updated after DMA).
Posted 04 July 2014 - 09:41 PM
Don't take it as an insult to you! My feelings are more than mixed about this but I personally feel that whillst the Clone Driver is cool for what it is, I still would recommend other options that are available, like how I'd recommend SonED2 over SonLVL, it's a preference thing. I'm aware of the mods you've done to it - I made particular mention to them and I found them pretty interesting! Use of MegaPCM in it is a great addition and I'm a huge fan of what it does myself to the point where I have the entire DAC table filled up in my own hack. This is a fun little project and I'm aware of the technical stuff you've done in it and I'd have loved to use this three years ago when I was working on my old Sonic 2 hack. Personally I think for someone who might just want new music in a Sonic 2 hack might find this unnecessary considering that it's a lot less difficult to just make the music Sonic 2 friendly over replacing the sound driver for just a bit of new music.
As an aside, my own feelings is that a 'perfect' SMPS driver for end users would need to be both optimized and be flexible, but also customizable to what the end user requires for what they're doing, including the option of being either Z80 or 68K based (some people actually like the bitcrushing that Z80 drivers bring with them and see it as an iconic sound characteristic of the Mega Drive to the point where it's emulated in FM Drive). It certainly would be nice to see this dream a reality at some point!
By the way, when I mentioned breaking the game, many years ago when I tried installing the Clone Driver I distinctly remember it going pretty badly - the guide was a little unclear and I wasn't paying too much attention admittedly, but there was still a good bit of risk in messing up the installation of the Clone Driver. :p I haven't looked too deeply in this, but if the installation is pretty easy now then what do I have to worry about? :v
Posted 04 July 2014 - 10:25 PM
Well yeah even I'd recommend a good Z80 SMPS driver over this one to the average hacker that just wants more music. They probably won't run into the Z80's limitations anyway. But, if anyone were to try something that the Z80 can't handle, then there's always a 68K driver that isn't bugged and missing features available. Though I still need to work on the bugs, I hear there are more in there.
I don't really know about replacing the sound driver being particularly difficult. The guide's meant to be easy to work with, and the driver is practically plug-and-play. But 'installation of this driver' VS 'porting the song, adding all S3K DACs, adding Uni Voice Bank support, adding S3K PSGs'... if you're porting S3K music, you'll have to port this or the S3K driver anyway.
Breaking the game because of installation... This thing was very vague on how to remove the old S2 driver. I tried to make my guide as friendly as possible to avoid that stuff.