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
  • 5 Pages +
  • 1
  • 2
  • 3
  • Last ►
    Locked
    Locked Forum

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

#1 User is online Clownacy 

Posted 30 March 2014 - 07:14 PM

  • Needs to make an avatar
  • Posts: 245
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
Important:
  • This driver is intended to have its sound files in SMPS2ASM .asm format; assembled (.bin) files are unsupported.
  • This driver is designed for use with the Macro Assembler AS.
  • To quote Irixion: "Do not reproduce [in part or in whole] without permission of creator, or I will hunt you down, and cut your penis off." This is your only warning. Mega PCM and SMPS2ASM are property of Vladikcomper and Flamewing, respectively.
  • It's the Clone Driver v2, FFS


Recently, I noticed that the Sonic 2 Clone Driver is painfully outdated, even to the point of an unhealthily large chunk of the guide that was supposed to simply detail porting it being about bringing the old thing up to date and making it actually imitate S2's driver. So I chose to do something about it: by giving the thing an S2 Community Disasm overhaul!

Looking closer at the Clone Driver, I saw that it was made with old components and older methods. So I scrapped it and started from scratch with a fresh S1 sound driver. Here is the result.

Sonic 2 Clone Driver v2
version 2.2.4.1b

Features:
  • Community Disasm comments and formatting - You'll no longer be left in the dark as to what the heck you're looking at
  • Community and Hivebrain labels - To do what no one else could be bothered to do, apparently. Guides are no longer a guessing game (now part of S1 Community disasm)
  • Clean changes - Most of my own changes, and those from other sources, are commented, identifiable and with reasons given
  • Now with more Sonic 2 - The original Clone Driver didn't have these S2 features:
    - Priorities
    - PSGs
    - The actual Sonic 2 Sega PCM
    - Spin Dash support (rev increases in pitch)
    - Gloop support (only plays every other time it's called)
    - StopSFX sound command (used by EHZ boss' propeller)
    - SFX-only priorities list
    - Runs at full speed on PAL consoles ("PAL mode")
    - Working speedup tempos
    - More accurate tempos in general
    - Song-sensitive PAL mode (S2's drowning theme plays slower on PAL)
  • Now with more Sonic 3 - Sonic 3 Clone Driver? Not yet...
    - PSGs
    - PSG flags (reset, rest)
    - PSG frequencies
    - Universal Voice Bank
    - DAC samples (S3+S&K+S3D)
    - Tempo algorithm
    - Continuous SFX system
  • Now with more... Crackers?! - DACs included
  • Less HAX - Real support for music slots >=$E0 (now optional part of S1 Community disasm)
  • More HAX - Real support for music slots <$80 (Git only)
  • Absolute voice pointers - Now you can put your voices anywhere!~
  • "Only limited by the RAM size" - Up to $7C DAC sample slots, and growing
  • More sound queues - Less developer oversight, more music queuing (currently at 4, the same as Sonic 2)
  • Optional 68k Sega chant playback - Greatly optimised, too
  • Optimised - Should make up for the additional code
  • SMPS2ASM - Hex editor? What's that?
  • Mega PCM - Z80 stops optimisations included


In its unchanged state, the sound slot allocation is a little funny. Here's the layout (Git only; in Xenowhirl, the layout is stock):

$00 - Silence
$01-$1F - Music
$20-$7F - Blank
$80-$D0 - SFX
$D1-$F9 - Blank
$FB-$FF - Flags

To change this, adjust s2.constants.asm's 'idstart's and 'Mus/SndID_End's.

You'll also want to extend your Sound Test's range to $00-$FF. The installation guide details this.

Download link here, or would you rather try a ROM first?

Here's how to put it in a clean disassembly (if you're updating, follow the update guide further down the post):

Installation
Spoiler


Further work needs to be done to gain high-quality PCM playback...

Optimising VBlank routines (in Sonic 2)
Spoiler


Updating
Spoiler


Changelog
Spoiler


Credits

Original Sonic 2 Clone Driver
Varion Icaria - Puto's sound driver port
Esrael - Tweaker's sound driver port, plus fixes for Puto's port, including a fix for the Sega sound
Puto, Tweaker, StephenUK - Numerous fixes
drx - Hacking CulT's VDP calculator
JMan2050 - Jman's PCM driver
ValleyBell - $EC sound fix

Sonic 2 Clone Driver v2
Those that contributed to the sound driver sections of the Sonic Community disassemblies
ValleyBell - General help. Also, inspiration
Shobiz - Ported Spin Dash rev code
Puto - Original 68k Sega sound fix
MarkeyJester - DAC fade-in fix
Flamewing - SMPS2ASM core; pointing out S3K's additional PSG frequencies; his perfect-compression koscmp, used to compress Mega PCM
Vladikcomper - Mega PCM
Clownacy - Go read the changelog =P
This post has been edited by Clownacy: 17 December 2014 - 09:11 AM

#2 User is online Clownacy 

Posted 15 April 2014 - 08:33 AM

  • Needs to make an avatar
  • Posts: 245
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
Update time: Link in main post

Sonic 2 Clone Driver 2.1
  • Fixed Priorities list not including the Sound Flags ($FB-$FF)
  • Adapted Sonic 2's feature of having the priorities system only apply to SFXs
  • Added Sound Flag $FA, StopSFX, now back from Sonic 2, and fully functional
  • Added S3+ PSG instruments
  • Added S3+ DAC samples
  • Added S3+ Universal Voice Bank
  • Modified _smps2asm_inc.asm to have an option for the Clone Driver 2, 'SonicDriverVer = 0'
  • Removed remainder of the Special SFXs ($D0-$DF), freeing up $60 bytes of RAM
  • Rearranged data and indexes:
    - Data (UniVoiceBank, PSG, Music, SFX) at bottom
    - Indexes (PSG, Music, SFX) at top
  • Music and SFXs use absolute (longword) pointers for their Voices, this is to allow UniVoiceBank support
  • Removed all 'Go_Index' nonsense, references are now direct
  • Made Sega PCM ID dynamic
  • Added Flag IDs

This post has been edited by Clownacy: 15 April 2014 - 08:34 AM

#3 User is offline Caverns 4 

Posted 15 April 2014 - 04:42 PM

  • Posts: 259
  • Joined: 07-December 12
  • Gender:Male
  • Project:Sanik Quest: Journey To The Right
Did you miss something? I tried the installation guide and now I'm getting a black screen on Regen, leading me to believe that it certainly won't work on real hardware either. Is it just me?

edit: Yeah, I think it's probably me. I already had the original version of the Clone Driver in my hack, so I think something's being wobbly because of that.
This post has been edited by Caverns 4: 15 April 2014 - 04:47 PM

#4 User is online Clownacy 

Posted 15 April 2014 - 06:37 PM

  • Needs to make an avatar
  • Posts: 245
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
If it means anything, I primarily test on Regen, with good results. I'm surprised that this is incompatible with hacks that had the original Clone Driver installed, heck, the installation guide is based on the one I posted in your thread all that time ago!

There is a black-screen bug associated with a certain component of this driver, but I fixed it: Mega PCM's 'Optimising Z80 stops' guide had you remove code that stopped the Z80, but not the code after it that checked if the Z80 had stopped, and, if not, loop back and check again, going in an infinite loop which left you at a black screen.

EDIT: Tested with a new installation, no blank screen. The Optimised Z80 Stops guide may have to be improvised, though, looks like some of my labels are old. Just clear out the stop/startz80 in V_int.
This post has been edited by Clownacy: 16 April 2014 - 06:01 AM

#5 User is offline Caverns 4 

Posted 26 April 2014 - 05:31 PM

  • Posts: 259
  • Joined: 07-December 12
  • Gender:Male
  • Project:Sanik Quest: Journey To The Right
I was able to get the new version of the Clone Driver working in a hack without issue, though now I want to know if it's possible to convert assembled songs into the macro format? If not, then this may provide limited usefulnes, unless it's simple enough to to revert it so that built files can be read.
This post has been edited by Caverns 4: 26 April 2014 - 05:41 PM

#6 User is online Clownacy 

Posted 26 April 2014 - 08:10 PM

  • Needs to make an avatar
  • Posts: 245
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
Macro format? You mean 'run a built song through smps2asm.exe and have it converted properly'? No, not in its native state. But why would you want to do that? Unless you're stealing a song from a hack, why would you pull a song from an assembled game? In their SMPS2ASM form, all sound files follow stock SMPS2ASM standards, so any other driver using SMPS2ASM can use the songs with no issues, though this will be broken in a later update, where in order to expand the DAC range, I'll need to add a proceeding flag, and I've yet to find a way to effectively "macro-ise" it, so that it'd be handled by _smps2asm_inc.asm without any changes to the individual songs. So far, it looks like you'd have to manually append a flag byte before every DAC entry or duration.

One epic digression later... In the current version, the Voices pointer is absolute, so you'd need to change that to a word-length pointer relative to its location. You'd also have to restore the Coordination Flag layout of Sonic 1: Currently, their order is almost the same, only they all occupy $FF and $FE. Remove $E0 and slap a $FF before it, and you have the Clone Driver 2 equivalent (for example, "$E2" becomes "$FF,$02"), this somewhat also applys to smpsNoAttack, but, due to a problem with maintaining compatibility with SMPS2ASM-converted files, it is relocated to $FE; the macros don't like smpsNoAttack having the company.

Of course, there's also the problem with songs that use anything but S1 DACs: smps2asm.exe will label them incorrectly, so you'd have to manually equate them yourself.

With that all done, you'd still need to correct all of the pointers to accommodate all of the removed bytes.

Unless I'm a massive idiot and is misreading your post entirely: As I said above, for the moment, this driver's fully compatible with standard SMPS2ASM songs, in the same way that Flamewing's driver is. SMPS2ASM songs do not require any modification to work with the driver, outside of those normally needed for Sonic 1 driver compatibility, such as coordination flag removal/replacement.
This post has been edited by Clownacy: 26 April 2014 - 10:27 PM

#7 User is offline Caverns 4 

Posted 26 April 2014 - 11:18 PM

  • Posts: 259
  • Joined: 07-December 12
  • Gender:Male
  • Project:Sanik Quest: Journey To The Right

View PostClownacy, on 26 April 2014 - 08:10 PM, said:

Macro format? You mean 'run a built song through smps2asm.exe and have it converted properly'? No, not in its native state. But why would you want to do that? Unless you're stealing a song from a hack,

Maybe it's just me, but it kind of sounded like you were pointing a finger at me. For your imformation, I wanted Sonic 1/2Beta/3K songs in my hacks, and all of those songs are assembled in their respective disassemlies.

What you're doing now is creating a new music format for the Sonic 1 Sound Driver, and elimating compatibility with the original, making all pre-existing songs incompatable, and while I'm all for moving forward normally, this is one case where I'm not on board unless the the rest of the community is about to embrace this, especially since, from what I understand, you're telling me that porting GHZ's music from Sonic 1 to 2 just went from a copy paste job to writing an entire song in assembly.

If you intend to move in that direction, then I which you the best of luck, and I'll keep an eye on your sound driver for code reference, but I will not be using your sound driver in my hacks.

#8 User is offline MainMemory 

Posted 26 April 2014 - 11:25 PM

  • Every day's the same old thing... Same place, different day...
  • Posts: 3217
  • Joined: 14-August 09
  • Gender:Not Telling
  • Project:SonLVL
  • Wiki edits:1,339
The SMPS2ASM tool can convert binary songs to the macro format, and there is in fact an archive linked in that post containing all of the music and SFX from S1-S3D preconverted. You will have to modify some things, but you won't have to rewrite the entire song in assembly.

#9 User is online Clownacy 

Posted 26 April 2014 - 11:52 PM

  • Needs to make an avatar
  • Posts: 245
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland

View PostClownacy, on 30 March 2014 - 07:14 PM, said:

This driver is intended to have its music and sound effects is SMPS2ASM .asm format; assembled files are unsupported.

Really? I said "SMPS2ASM" so many times, I thought I needn't point out that the sound files use it.

So Sonic 2 and 3 can get away with slightly differing formatting but not me? :v:/>

EDIT: It's worth mentioning that I thought you meant "Can I pull an assembled song from a ROM that uses this driver and have smps2asm.exe process it correctly?"
This post has been edited by Clownacy: 27 April 2014 - 08:29 AM

#10 User is offline Caverns 4 

Posted 27 April 2014 - 11:35 AM

  • Posts: 259
  • Joined: 07-December 12
  • Gender:Male
  • Project:Sanik Quest: Journey To The Right

View PostMainMemory, on 26 April 2014 - 11:25 PM, said:

The SMPS2ASM tool can convert binary songs to the macro format, and there is in fact an archive linked in that post containing all of the music and SFX from S1-S3D preconverted. You will have to modify some things, but you won't have to rewrite the entire song in assembly.


I didn't know about this, thanks for linking it.

View PostClownacy, on 26 April 2014 - 11:52 PM, said:

EDIT: It's worth mentioning that I thought you meant "Can I pull an assembled song from a ROM that uses this driver and have smps2asm.exe process it correctly?"


I suppose in fairness, I DID misread your post in a few places. I do understand better now. In that case, I might use this Sound Driver some time in the future, but not for the time being.

The mean reason modifying the format is a problem for me is simply because of the fact that while label and bug fixing, adding a few macros and so on is fine, the Sonic 1 music format was the most widely accepted one... Or so I thought, prior to learning about SMPS2ASM. Knowing that there is a more or less "community format" now, if what you're working on is an improved variant of that, I probably will get on board with it later, assuming it acquires support.
This post has been edited by Caverns 4: 27 April 2014 - 11:35 AM

#11 User is online Clownacy 

Posted 28 April 2014 - 10:22 AM

  • Needs to make an avatar
  • Posts: 245
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
The format hasn't been changed yet: it's fully compatible with other drivers and other versions of SMPS2ASM. The internals of the driver have changed, but the songs haven't, as long as they're .asm. Every .asm sound file in that archive MainMemory gave you is compatible with the driver, as are any music files you have smps2asm.exe process.

But the quickest and easiest way I can imagine my soon-to-be-modified format seeing more widespread support is if the program that converts .bin to .asm, smps2asm.exe, began supporting user-input layout configuration. The reason smpsNoAttack doesn't follow the other coord flag's pattern is because of SMPS2ASM's non-changeable layout, it's currently set so that smpsNoAttack's usage is more strict than other flags'. Yes, one could modify their music files and their _smps2asm_inc.asm, but any files created by smps2asm.exe will require modification. In the future, it will have to be that I will need to leave instructions indicating how to change your music files to a compatible format.

I know a possible way to "macro-ise" DAC instrument calls so that they have a preceding flag, allowing more DAC samples. But, in other locations, where there are only raw values, manual flag insertion or manual macro-ising of every significant byte of raw data will have to be done. I've had to do this with my personal build of the Clone Driver, it ain't fun.

I'm not so willing to remove support for SMPS2ASM, but several restrictions regarding macros, brought on by Macro Assembler AS or SMPS2ASM itself restrict me from incorporating features without modifications to them.
This post has been edited by Clownacy: 28 April 2014 - 03:27 PM

#12 User is offline Caverns 4 

Posted 28 April 2014 - 06:48 PM

  • Posts: 259
  • Joined: 07-December 12
  • Gender:Male
  • Project:Sanik Quest: Journey To The Right

View PostClownacy, on 28 April 2014 - 10:22 AM, said:

The format hasn't been changed yet: it's fully compatible with other drivers and other versions of SMPS2ASM. The internals of the driver have changed, but the songs haven't, as long as they're .asm. Every .asm sound file in that archive MainMemory gave you is compatible with the driver, as are any music files you have smps2asm.exe process.


In that case, I would have no problem using this version of the Sound Driver, except for the fact that I haven't been able to get SMPS2ASM to do anything.

#13 User is online Clownacy 

Posted 29 April 2014 - 05:14 AM

  • Needs to make an avatar
  • Posts: 245
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
It's command line, took a while to figure it out completely. The most basic setup you'll want is to get smps2asm.exe in a folder, in the same folder, have GHZ's music in .bin S1 format then hold Shift key and right-click in the Explorer window without anything selected, select "Open command window here", then input the following:

smps2asm.exe -v 1 "GHZ.bin" "GHZ.asm" GHZ

If you just enter "smps2asm.exe" you'll get an explanation of what these are: "-v" being driver version, and "1" the variable following it, which matches the driver which the file came from. After that is the input .bin filename, then the output .asm filename, and finally, the name the .asm file uses to identify itself. So labels such as the voices label are "GHZ_Voices".

There are more settings that are worth using in other situations, like Offset for Z80 driver sound files.
This post has been edited by Clownacy: 29 April 2014 - 05:18 AM

#14 User is offline redquebec 

Posted 30 April 2014 - 01:20 PM

  • Posts: 11
  • Joined: 29-April 14
I want to take this opportunity to thank you Clownacy for the great work you've done here! I've been playing with the Clone Driver for some time now, and the cleanup you did is simply short of amazing. The new DAC table open so much possibilities for hacking, and great sound quality too (Mega PCM in Sonic 2? Raaaahh lovely ^^). What do you plans to do next?

#15 User is online Clownacy 

Posted 30 April 2014 - 02:09 PM

  • Needs to make an avatar
  • Posts: 245
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
Well, the DAC table still has a way to go: As described above, I intend to roughly double the maximum number of DAC samples. I also plan to implement a less hackish way of supporting S3+ PSGs. You can thank the Community Disasm contributors for the cleanup, all I did was add Hivebrain labels and replace the local ones.

On the topic of your queries on S3 Complete's thread, what would be the most direct approach of simply adding Mega PCM is hindered by several things, as described here. Though I don't know what upgrading the DAC playback would do: from what I've seen, outside of the PC tracks, S3C doesn't stray from the stock music, so the benefits of additional playback functions would go unnoticed due to lack of use.

  • 5 Pages +
  • 1
  • 2
  • 3
  • Last ►
    Locked
    Locked Forum

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