Sonic and Sega Retro Message Board: SMPS2ASM and improved S&K Driver - Sonic and Sega Retro Message Board

Jump to content

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

SMPS2ASM and improved S&K Driver Converting songs and SFX has never been easier

#31 User is offline SoullessSentinel 

Posted 30 May 2013 - 07:32 PM

  • Posts: 249
  • Joined: 01-October 05
  • Gender:Male
  • Location:Grimsby, England
  • Project:Sonic 1 32X Remix

View PostTiddles, on 30 May 2013 - 05:59 PM, said:

One thing I did to get some free Z80 RAM back was to move all the music and SFX bank and pointer tables out of Z80 RAM, attaching them instead to the end of every music and sound bank in ROM, similar to the way the DAC pointers all sit at the top of every DAC bank. You can modify/add macros to splat that out fairly easily, though of course it means you have less space in each bank. I chose to locate them at $7D00 in each bank, which gives quite a bit of room to extend the number of pointers if you want to.


I don't have the Sonic 3 driver on hand right now to test myself, but roughly how much ram does this save? For my current project, I need enough ram to implement the additional FM Channel as well as 4xPWM channels for the 32X

#32 User is offline Tiddles 

Posted 31 May 2013 - 12:59 AM

  • Diamond Dust
  • Posts: 471
  • Joined: 25-December 09
  • Gender:Male
  • Location:Leicester, England
  • Project:Get in an accident and wake up in 1973
  • Wiki edits:31
Difficult to say as a comparison to the original setup, as I have much bigger indexes than usual already, but looking at my output, I am using just shy of the entire $300 bytes I allocated in my end-of-bank clearout (which rather explains why expanding the sound index further wasn't working out!) so that's how much more I'd have to use in Z80 RAM if they weren't there.

You will save somewhat less than that given non-bloated bank and pointer tables, but it's still a decent chunk - wish I could remember the original sizes of those to give more info. To clarify, the four things I moved are DAC bank pointers, SFX data pointers, music bank and data pointers. To some extent it depends what you want to do - if you need more space there are probably more tables you can move to duplicating in ROM banks.

Guess I probably need to pull it back to $7C00 next time!

#33 User is offline Cinossu 

Posted 31 May 2013 - 02:46 AM

  • inverted with love~
  • Posts: 2803
  • Joined: 21-June 04
  • Gender:Male
  • Location:London, UK
  • Project:Sonic the Hedgehog Extended Edition
  • Wiki edits:474
With a fancy bit of my own shuffling around of things, I actually got this working fairly simply; the one problem I had (until I solved it this morning) was with pausing the FM6 and not killing the DAC when not in use.

However, everything is all happy now. :> Yay, it's all working~

.. now to see if I can get S1/2-style modulation toggleable.. portamentos.. making the coffee..

#34 User is offline flamewing 

Posted 20 February 2015 - 05:06 PM

  • Emerald Hunter
  • Posts: 1118
  • Joined: 11-October 10
  • Gender:Male
  • Location:🇫🇷 France
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12
This one has been a long time in the making; triple update time!

New version of the sound driver is available: grab v2a here.
New version of SMPS2ASM is available: grab v0.2 here.
New version of the song pack is available: grab v4a here.

Changes:
  • driver: now with support for playing songs with 6 FM channels and no DAC channels;
  • driver: universal voice bank (UVB) is now included in every music bank; while this reduces the space in banks, this allows much more freedom for expanding the sound driver;
  • driver: UVB has been SMPS2ASM'ed;
  • driver: all fixes and changes are now always on;
  • driver: driver makes use of local labels (instead of nameless temporaries) and uses S2-style memory management for the z80 RAM (instead of hard-coding everything);
  • driver: several new coordination flags and fixes based on other drivers from ValleyBell's research pack; specifically:
    • meta CF $FF08 (smpsChanTempoDiv) which works like CF $E5 in S1/S2 drivers;
    • meta CF $FF09 (smpsChanFMCommand) that allows sending FM commands to the appropriate YM2612 part for the current track;
    • meta CF $FF0A (smpsNoteFill) that works like $E8 did in S1/S2 drivers;
    • meta CF $FF0B (smpsPitchSlide) that allows you to do pitch slides (use smpsAlterPitch to set slide speed);
    • meta CF $FF0C (smpsSetLFO) that lets you enable/disable the LFO and set AMS and FMS.

  • SMPS2ASM: can now dump z80 banks given an offset to a pointer table within the bank;
  • SMPS2ASM: simple dataflow analysis added to propagate key displacement changes throughout a track; this is used to fix the handling of the maximum-frequency PSG note (since it is different in S1/S2 and S3/S&K/S3D drivers);
  • song pack: redumped all songs with the new SMPS2ASM;
  • song pack: S3, S&K and S3D songs (and SFX for S&K) now have two versions: the 1:1 versions with unused data and the "optimized" versions without it; the optimized versions also have ALZ song fixed.


A warning: songs dumped with the new SMPS2ASM MUST be used with the "_smps2asm_inc.asm" file present on the sound driver file; earlier versions of the include file will fail. Moreover, I strongly recommend that you redump old songs so that they sound correct due to the PSG maximum-frequency note issue mentioned above.

To use the driver, you will need to either use the constants for zQueueVariables, zMusicNumber, zSFXNumber0 and zSFXNumber1 like what is descriped in Alriightyman's guide to use it in S2 or use the exported symbols for these constants to reference the correct z80 variables.

Edit: Note: the SMPS2ASM release is essentially a bugfix release; I have more things planned, but I wanted to get this out the door because it affects a lot of people.
This post has been edited by flamewing: 27 February 2015 - 08:14 PM

#35 User is offline KingofHarts 

Posted 21 February 2015 - 05:24 PM

  • Posts: 1552
  • Joined: 07-August 10
  • Gender:Male
  • Project:Sonic 1 Complete
  • Wiki edits:1
I never noticed this in the past... I may look into this for use in my Sonic 1 hack. While knowing exactly how to convert sounds and stuff would be better for me personally, I love the idea of being able to backport something that is arguably superior.

#36 User is offline nineko 

Posted 22 February 2015 - 08:45 AM

  • I am the Holy Cat
  • Posts: 5606
  • Joined: 17-August 06
  • Gender:Male
  • Location:italy
  • Project:I... don't even know anymore :U
  • Wiki edits:5,251
I wonder how hard it would be to have a version without the UVB at all. While important for the songs from S3&K, it's a waste of space if one uses songs from S1/2 or custom songs for the most part. An alternative idea: a tool which runs through all the used songs, scanning for their instruments, to create a custom bank to be used instead of the standard UVB. I did something similar when I researched the Cube driver, which uses a global instrument bank similarly (except it's mandatory unlike the UVB), so I made that when you used songs from different Cube games, a new instrument bank was created (and instrument flags in the songs changed accordingly).

#37 User is offline flamewing 

Posted 22 February 2015 - 09:29 AM

  • Emerald Hunter
  • Posts: 1118
  • Joined: 11-October 10
  • Gender:Male
  • Location:🇫🇷 France
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12
The driver without the UVB is a simple matter of not including the UVB in any bank in which it is not used; if no songs use the UVB, you won't have to include it anywhere and it won't take up any space. Moreover, the new setup actually would allow custom "U"VBs for each bank — since each bank has its own copy of the UVB, you could make a voice bank shared by the bank's songs with all of their voices, include it in said bank instead of the UVB, and use it as if it were the UVB. You would still need to redo the FM channels to set the correct voices, though, as there currently* is no way to define voice banks to use.

As for the songs that use the UVB: I suppose I could add a flag that dumps a song stripping its UVB dependency and including the relevant voices in the song itself.

* I am working on changing that, as well as a load of similar things.

#38 User is offline nineko 

Posted 22 February 2015 - 09:57 AM

  • I am the Holy Cat
  • Posts: 5606
  • Joined: 17-August 06
  • Gender:Male
  • Location:italy
  • Project:I... don't even know anymore :U
  • Wiki edits:5,251
Oh wow that's good to know, sorry about my previous post, I made it from my phone without actually trying the thing and I didn't know it could work in such a way and the UVB inclusion isn't mandatory. Furthermore, that's actually a very interesting setup to have, with a different "CVB" (the "C" can stand for both "Custom" or "Common") per each song bank, I really think it's an operative mode worth pursuing, especially in cases where common instruments are shared amongst several custom songs (which is what most xm3smps / mid2smps users tend to do, afaik, choosing instruments from a selection of a few dozens in most cases). I can look into making such a "bank preparer" tool, since as I said I already did something similar for Cube once, and I guess it wouldn't be that hard to make something similar for SMPS. I imagine it as a window where you can drag a selection of songs and let the tool find out the needed instruments, fixing the instrument flags within each song accordingly (and setting the voice pointer in the header to... whatever value it should be set to). Sadly, since I suck at parsing SMPS, I'd probably make it support only the Sonic 1 SMPS format, so I'm not sure how useful it would be. Then again I can always open source the code so someone better than me can improve it. (Then again)² I'd write it in Visual Basic, making its source code useless to most people here who prefer other languages. I hate when I want to help, but I realise my skills aren't up to the game.

#39 User is offline MainMemory 

Posted 22 February 2015 - 12:00 PM

  • Every day's the same old thing... Same place, different day...
  • Posts: 4058
  • Joined: 14-August 09
  • Gender:Not Telling
  • Project:SonLVL
  • Wiki edits:1,339

View Postflamewing, on 22 February 2015 - 09:29 AM, said:

As for the songs that use the UVB: I suppose I could add a flag that dumps a song stripping its UVB dependency and including the relevant voices in the song itself.

There's a version (not sure if it's publicly available yet) of Valley Bell's SMPSConv tool that will do that if you provide a UVB file and convert a song S3K-S3K.

#40 User is offline flamewing 

Posted 22 February 2015 - 02:02 PM

  • Emerald Hunter
  • Posts: 1118
  • Joined: 11-October 10
  • Gender:Male
  • Location:🇫🇷 France
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12

View Postnineko, on 22 February 2015 - 09:57 AM, said:

(Then again)² I'd write it in Visual Basic, making its source code useless to most people here who prefer other languages. I hate when I want to help, but I realise my skills aren't up to the game.

For what is worth, I was quite the accomplished VB6 hacker back in the day, to the point of being able to do things like splice in [url=inline assembly in VB6. So if you wrote it in VB6, I could use it as a base to translate into C++ without issue.

#41 User is offline flamewing 

Posted 27 February 2015 - 08:05 PM

  • Emerald Hunter
  • Posts: 1118
  • Joined: 11-October 10
  • Gender:Male
  • Location:🇫🇷 France
  • Project:Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
  • Wiki edits:12
Minor new update: I fixed one tiny bug in the driver that caused an extraneous note to play on CNZ songs at around the loop point. I also updated all packages so that they all include the _smps2asm_inc.asm file. The new links:

Sound driver: grab v2a here.
SMPS2ASM: grab v0.2 here.
Song pack: grab v4a here.

Edit: Oh, and I forgot to mention: the song pack now has all the DAC samples that were also present in previous versions too.
This post has been edited by flamewing: 27 February 2015 - 08:14 PM

#42 User is offline Clownacy 

Posted 18 January 2016 - 12:57 PM

  • Layin' the Wax and Spinnin' the Sounds
  • Posts: 675
  • Joined: 06-July 13
  • Gender:Male
  • Location:Englandland
I noticed a bug in my S1 driver, stemming from an SFX header that uses a negative track pointer. SMPS2ASM didn't give me a warning about that, but does for negative FM voice pointers. I also noticed it doesn't raise an error if UVB-dependent music is assembled for an S1/S2 driver, merely excluding the voice pointer altogether, causing a mess of other problems. I also noticed it generates data for smpsFade with a parameter other than $FF in S1/S2 drivers, when they should be ignored, which winds up breaking the S3+ Drowning theme, and probably others.

I put together some fixes for these here. This still uses the old coord. flag names (smpsAlterNote, smpsAlterPitch), so it's compatible with current conversions.

  • 3 Pages +
  • 1
  • 2
  • 3
    Locked
    Locked Forum

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