Sonic and Sega Retro Message Board: Sonic 2 Clone Driver v2 - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
  • 7 Pages +
  • 1
  • 2
  • 3
  • 4
  • Last ►
    Locked
    Locked Forum

Sonic 2 Clone Driver v2 v2.7 | and other SMPS-related ramblings

#16 User is offline redquebec 

Posted 30 April 2014 - 04:21 PM

  • Posts: 38
  • Joined: 29-April 14
The main advantage of Mega PCM is the very cristal-clear clarity of the DAC playing. It is superior-sounding to the original driver. :) Did you noticed that too or is it my ears? ^^

#17 User is offline Clownacy 

Posted 04 May 2014 - 09:46 AM

  • Layin' the Wax and Spinnin' the Sounds
  • Posts: 616
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
Vladikcomper mentioned how even the stock DACs play static-ish, but his solution was to optimise the Z80 stops in the H-Interrupt. Not Mega PCM itself. I wouldn't know if that would even work with the Z80 drivers.
This post has been edited by Clownacy: 05 May 2014 - 03:15 AM

#18 User is offline Clownacy 

Posted 17 June 2014 - 12:45 PM

  • Layin' the Wax and Spinnin' the Sounds
  • Posts: 616
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
Haven't bothered to write posts on the past couple of update, so I'll group them all here.

v2.1.1
  • 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


v2.1.2
  • 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


v2.1.3
  • 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:
    • v_gloop_toggle
    • Spindash_LastSound_Flag
    • v_ring_speaker
    • f_updating_dac
    • f_fadein_flag
  • 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
This post has been edited by Clownacy: 27 February 2015 - 08:39 AM

#19 User is offline redquebec 

Posted 17 June 2014 - 01:49 PM

  • Posts: 38
  • Joined: 29-April 14
Looking good Clownacy, thanks a lot for the hard work. :) Will update my build tonight. You know, tracking all the improvement you did on Sonic 1 and 2 is really something. Well done :)

#20 User is offline Clownacy 

Posted 28 June 2014 - 10:11 PM

  • Layin' the Wax and Spinnin' the Sounds
  • Posts: 616
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
Two major things here, ported PSG flags and S3K tempo algorithm. The latter is a really welcome addition; even with the modified S2 music of the original Sonic 2 Clone Driver, the tempos were still way off on certain songs, and even worse, the speedup tempos were broken, as the modified music's tempos were already near maximum! With the introduction of S3K's tempo algorithm, I can restore the stock S2 music files and restore the speedup tempos to their former functionality! With this, Sonic 2's driver should be mostly 'cloned' (functionality wise)! Currently, there are some very minor audio differences that I believe to be bugs with the original Sonic 1 driver.

v2.2
  • 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'.

Updating:
You must overwrite _smps2asm_inc.asm with the new one. This is to allow usage of S3K tempos.
This post has been edited by Clownacy: 27 February 2015 - 08:35 AM

#21 User is offline Clownacy 

Posted 03 July 2014 - 09:46 AM

  • Layin' the Wax and Spinnin' the Sounds
  • Posts: 616
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
More updates, woooooo... Wish I was this productive with my hack.

v2.2.1
  • 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


v2.2.1.1
  • 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 v2.2.1.1, 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.

Updating:
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.
This post has been edited by Clownacy: 27 February 2015 - 08:34 AM

#22 User is offline Hitaxas 

Posted 03 July 2014 - 11:02 AM

  • SEGA: Sorry Classic Sonic, we are sending you back to 1994
  • Posts: 1436
  • Joined: 30-September 07
  • Gender:Male
  • Location:Back in Litchfield,CT
  • Project:Sonic: Super Deformed (head director) - Slowly working on it.
  • Wiki edits:196
Just updated my test disassembly. PAL_AUDIO_COUNTDOWN is a duplicate in the constants files for the game itself and the sound driver. Not difficult to work around though, I removed the line in the s1.sounddriver.constants.asm and the game builds no problem.

#23 User is offline Clownacy 

Posted 03 July 2014 - 11:56 AM

  • Layin' the Wax and Spinnin' the Sounds
  • Posts: 616
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
Yeah, I eliminated the addition of that constant from the installation guide when I updated it. Looks like I forgot to add that to the update guide though.

#24 User is offline Clownacy 

Posted 03 July 2014 - 07:56 PM

  • Layin' the Wax and Spinnin' the Sounds
  • Posts: 616
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
Just uploaded an emergency update. Those jumps I mentioned? They weren't fixed. It's complicated, but all that needs to be known is that it ruins whatever code tries reading from the Stack in not-so-normal ways. So I've switched back to some less-efficient-but-more-efficient-than-what-was-in-2.2.1 code which uses a single bit of RAM.

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.
This post has been edited by Clownacy: 03 July 2014 - 07:57 PM

#25 User is offline KingofHarts 

Posted 04 July 2014 - 11:54 AM

  • WHY CANT I EDIT THE WIKIIII????
  • Posts: 1540
  • Joined: 07-August 10
  • Gender:Male
  • Project:Sonic 1 Complete (SHC 2016 Entry)
  • Wiki edits:1

View PostClownacy, on 03 July 2014 - 07:56 PM, said:

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.


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.




#26 User is offline amphobius 

Posted 04 July 2014 - 02:34 PM

  • where are the japanese shaman girls, lintahlo?
  • Posts: 2098
  • Joined: 19-February 08
  • Gender:Male
  • Location:Northern Ireland, Belfast
  • Project:Sonic Thrash, Sonic Boom, Super Famidev
  • Wiki edits:165
..While I understand the point of this as a technical exercise, I fail to see why anyone'd actually use this for practical reasons primarily since the Clone Driver is based off Sonic 1's sound driver. Sonic 3's sound driver is excellent and far better than Sonic 1's sound driver, and with flamewing's mod of it it becomes extremely easy to use with any program that outputs to ASM (read: most of them except mid2smps, which can then be converted via smps2asm). It running on a Z80 based sound driver additionally makes the game itself run better even if sample quality takes a hit.

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)
This post has been edited by DalekSam: 04 July 2014 - 02:37 PM

#27 User is offline Clownacy 

Posted 04 July 2014 - 03:57 PM

  • Layin' the Wax and Spinnin' the Sounds
  • Posts: 616
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
My goal with the Clone Driver V2 was the same as that of the original Clone Driver, to create a 68K sound driver that can work as a total replacement for S2's Z80 driver, which is apparently just a modified port of Sonic 1's 68K driver to Z80. Were the original Clone Driver never made, I probably never would have developed this. Look at the beginning of the original post, the original Clone Driver was still being used despite it being, from my observations, "made with old components and older methods", along with outright not being at all close to fully imitating S2's driver. I knew I could do better, so I did. Not out of spite of course, but for the sake of those that were using the driver, not aware of its many shortcomings. Just read through the feature list, the original Clone Driver had a custom DAC driver, with S2's DACs, "ported" S2 music and SFXes and nothing else! Well, that and a messy workaround for a simple yet nasty bug.

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 :argh:/> , 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.
This post has been edited by Clownacy: 04 July 2014 - 04:09 PM

#28 User is offline flamewing 

Posted 04 July 2014 - 04:58 PM

  • Emerald Hunter
  • Posts: 1084
  • Joined: 11-October 10
  • Gender:Male
  • Location:Brasil
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12
Well, I was going to reply that a perfect clone driver (not the version everyone was using before) with MegaPCM is a perfectly good choice -- you are trading 68k cycles for vastly better PCM playback quality while keeping all the capabilities of the S2 driver. I have been thinking of making a S3&K driver with Mega PCM myself, which may end up being picking one of the equivalents ValleyBell has studied and modifying it for full S3&K capabilities and MegaPCM. But I don't know if I would use it myself yet, so it has been pushed back.

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. V-Int is also when DMA transfers are done because they have higher bandwidth; when delayed, the DMA transfers can end up happening out of V-Int. Since they stall the 68k for their duration, they will stall the 68k for longer out of V-Int. Also, this may cause graphical glitches due to partially transferred art. But that is me, nitpicking. The nitpick, by the way, is a caution on using the 3.2% figure. It is interesting, but it has to be interpreted properly or you will come to bad conclusions.

Edit: Striked out some technically irrelevant information (I had forgotten that music is updated after DMA).
This post has been edited by flamewing: 04 July 2014 - 06:00 PM

#29 User is offline amphobius 

Posted 04 July 2014 - 09:41 PM

  • where are the japanese shaman girls, lintahlo?
  • Posts: 2098
  • Joined: 19-February 08
  • Gender:Male
  • Location:Northern Ireland, Belfast
  • Project:Sonic Thrash, Sonic Boom, Super Famidev
  • Wiki edits:165
@Clownacy

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

#30 User is offline Clownacy 

Posted 04 July 2014 - 10:25 PM

  • Layin' the Wax and Spinnin' the Sounds
  • Posts: 616
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
An insult? No, no I didn't take it as that at all. Don't worry about that.

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.

  • 7 Pages +
  • 1
  • 2
  • 3
  • 4
  • Last ►
    Locked
    Locked Forum

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