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
Loading News Feed...
 

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

#16 User is offline flamewing 

Posted 09 November 2011 - 05:46 PM

  • Elite Hacker
  • Posts: 725
  • 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

View PostTiddles, on 09 November 2011 - 03:15 PM, said:

Your description does raise another issue though, of collecting a second 1up while the first is playing, which sounds like it would also wipe a pending music change...

If my description misled you this way, sorry; the 1-up only prevents sound effects (Play_Sound_2 or Play_Sound with a SFX index), another 1-up or the S&K Credits song from playing. All other music (if queued with Play_Sound) will not be wiped out, and will play when the 1-up song ends. Even the S&K Credits song is only harmed because it is kind of hacked-in, even in the original game.

View PostTiddles, on 09 November 2011 - 03:15 PM, said:

The queue idea sounds very good for tempo - it sounds like quite an undertaking, but it really makes a lot more sense in the context of Sonic games, so I'd be very pleased if you did decide add such a thing.

In some ways, it would be kind of easy: since the 1-up song is not supposed to be affected by the speedup, then 3 things need to be done: (1) eliminate the code that backs-up speedup values when starting 1-up song; (2) eliminate the code that restores of speedup values when 1-up song ends; (3) disable tempo speedup when 1-up is playing. The first two require commenting a few lines, the latter one can be done with 2 or 3 lines of additional code (even for multiple 1-up songs if done right).

View PostTiddles, on 09 November 2011 - 03:15 PM, said:

Thinking about it, it would also be nice to have a way to request a music track with an initial tempo change (e.g. collecting invincibility with sneakers active, restarting zone music from an event while sneakers are active, etc.)

I don't see anything that causes it not to behave like that other than a call to zMusicFade; other than that, using Change_Music_Tempo while changing the tempo should work, unless I am being dense.

View PostTiddles, on 09 November 2011 - 03:15 PM, said:

I am concerned regarding its impact on the coordination flag FF/01 to play another music/sound effect by ID, though - without changing the actual flag format, I imagine it would end up being restricted to either music or sound only. Is this flag actually used by anything?

No.

View PostTiddles, on 09 November 2011 - 03:15 PM, said:

Sound effects would seem a more sensible option to leave available, unless something relies on calling fade effects, but I could rig those up to work in both instances if necessary. Regarding the comment on flutters and space - are we running close to a space limit in the current version then?

Yes; the entire sound driver, including tables and variables, must fit inside the $2000 bytes of z80 RAM. The S1/S2 flutters take up a good bit; if you notice by the end, I split them up in a part before 1300h and part after; this is so the tables do not overrun the RAM variables. I don't recall exactly how much space is available before 1300h, but it isn't much.

#17 User is offline Tiddles 

Posted 09 November 2011 - 07:00 PM

  • Diamond Dust
  • Posts: 427
  • Joined: 25-December 09
  • Gender:Male
  • Location:Nottingham, England
  • Project:Get in an accident and wake up in 1973
  • Wiki edits:31
Thanks for the info once again.

View Postflamewing, on 09 November 2011 - 05:46 PM, said:

If my description misled you this way, sorry; the 1-up only prevents sound effects (Play_Sound_2 or Play_Sound with a SFX index), another 1-up or the S&K Credits song from playing. All other music (if queued with Play_Sound) will not be wiped out, and will play when the 1-up song ends. Even the S&K Credits song is only harmed because it is kind of hacked-in, even in the original game.
Just did a quick test - the same principle as the test case I described previously, but with a 1up monitor - get a 1up for 100 rings, immediately turn super, break the 1up monitor, all during the 1up jingle. The invincibility music does still seem to get lost, with the zone music resuming after the 1up jingle completes.

View Postflamewing, on 09 November 2011 - 05:46 PM, said:

I don't see anything that causes it not to behave like that other than a call to zMusicFade; other than that, using Change_Music_Tempo while changing the tempo should work, unless I am being dense.
The problem I found in practice was that calling Change_Music_Tempo immediately after Play_Sound in 68K code would just cause the tempo change to be lost. I assumed this was because the sound driver wasn't picking up the music change immediately, and it was just cancelling the tempo change when it did (as it does during a transition to any new music). I run a five frame delay before calling Change_Music_Tempo to work around this at the moment. (Change_Music_Tempo is what I meant by Call_Sound_Event, by the way - I still have the old disasm names in my head!)

View Postflamewing, on 09 November 2011 - 05:46 PM, said:

Yes; the entire sound driver, including tables and variables, must fit inside the $2000 bytes of z80 RAM. The S1/S2 flutters take up a good bit; if you notice by the end, I split them up in a part before 1300h and part after; this is so the tables do not overrun the RAM variables. I don't recall exactly how much space is available before 1300h, but it isn't much.
OK, I'll watch out for that... I'm hoping to do this without adding too much extra code on balance, but unfortunately I need a fair chunk of music table expansion, even without code changes or adding tracks beyond those I use already. Fingers crossed!

#18 User is offline flamewing 

Posted 10 November 2011 - 02:22 PM

  • Elite Hacker
  • Posts: 725
  • 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

View PostTiddles, on 09 November 2011 - 07:00 PM, said:

Just did a quick test - the same principle as the test case I described previously, but with a 1up monitor - get a 1up for 100 rings, immediately turn super, break the 1up monitor, all during the 1up jingle. The invincibility music does still seem to get lost, with the zone music resuming after the 1up jingle completes.

That is because you queued another 1-up, which overwrote the invincibility song from the 68k side. Hrm. That can pose a problem.

#19 User is offline Tiddles 

Posted 10 November 2011 - 06:22 PM

  • Diamond Dust
  • Posts: 427
  • Joined: 25-December 09
  • Gender:Male
  • Location:Nottingham, England
  • Project:Get in an accident and wake up in 1973
  • Wiki edits:31
Do you think that running it through Play_Sound_2 I.e. the SFX slots is a viable workaround, or will that cause other problems? (Other than for splitting the functions of course... I have an unpleasant but workable solution in mind for that if this is the best way to go.)

On the space limits: is there a particular reason that the tables have to be at 1300h, or that I couldn't sneak a bit of code in after the end of them?

#20 User is offline flamewing 

Posted 11 November 2011 - 06:53 AM

  • Elite Hacker
  • Posts: 725
  • 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

View PostTiddles, on 10 November 2011 - 06:22 PM, said:

Do you think that running it through Play_Sound_2 I.e. the SFX slots is a viable workaround, or will that cause other problems? (Other than for splitting the functions of course... I have an unpleasant but workable solution in mind for that if this is the best way to go.)

The only issue I see is that another sound effect could override the 1-up song before it started to play.

View PostTiddles, on 10 November 2011 - 06:22 PM, said:

On the space limits: is there a particular reason that the tables have to be at 1300h, or that I couldn't sneak a bit of code in after the end of them?

At least with the S2 volume flutters, there is very little space after the tables (which is why I snuck some before 1300h). The reason I did it this way was simply so the improved driver was a drop-in replacement -- otherwise, I would have to modify s3p2bin.exe (which requires 2 adjacent z80 segments, one of which must be at 1300h) and the driver loading function. I can make these changes too, mind you, I just didn't want to :-)

#21 User is offline Varion Icaria 

Posted 02 December 2011 - 03:33 PM

  • He's waiting....
  • Posts: 983
  • Joined: 26-August 03
  • Gender:Male
  • Project:S4: Cybernetic Outbreak
  • Wiki edits:1
Sorry for the month bump. My S3K disassembly doesn't use AS it uses ASM68K. How would I go about incorporating this into mine?

#22 User is offline Cinossu 

Posted 16 March 2012 - 12:27 PM

  • inverted with love~
  • Posts: 2633
  • Joined: 21-June 04
  • Gender:Male
  • Location:London, UK
  • Project:Sonic the Hedgehog Extended Edition
  • Wiki edits:474
A four month bump? From an admin? Preposterous!

ANYWAY :U I was wondering if you, flamewing, would consider releasing the actual converter tool you used (if you did) for songs into this format. I have interest in it for converting Knuckles Chaotix songs into this format, and have already got them working with the engine flawlessly (as it is essentially the same SMPS engine, including the co-ordination flag set, just with 4 channel PWM instead of DAC).

As an additional question, and if there is no such tool/you are unwilling to release it, do you by any chance have a version of the Sonic 3 LE Credits medley (the one with the Sonic 3 and Sonic & Knuckles zone musics)?

Yes, I know it's a bump for questions, but this project can always do with bumping for viewing purposes. :v:

#23 User is offline flamewing 

Posted 16 March 2012 - 01:03 PM

  • Elite Hacker
  • Posts: 725
  • 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
Yeah, I can release it. Let me just modify it so you can also dump S1/S2 songs in a more S3&K-format (as in, chained rests always print the rest note also) and undo the related bugfix (since at least SSZ song and the S3 miniboss song need it to work) and I will release it; it will probably be this weekend.

FYI, the tool is still unmodified from the first post; I have neglected working on it.
This post has been edited by flamewing: 18 March 2012 - 07:15 AM

#24 User is offline flamewing 

Posted 18 March 2012 - 07:15 AM

  • Elite Hacker
  • Posts: 725
  • 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
v3 is out. The changes are:
  • Due to its effects in some S3, S&K and S3D songs, I undid the following bugfix:
    • [bugfix] original S3/S&K/S3D driver could not correctly handle playing the sequence "<note>, <duration>, $80, <duration>, <duration>", and would play <note> again instead of a rest.
  • S1 and S2 songs that were affected by the previous change got a new version that explicitly puts a $80 before the duration of each rest;
  • The "_spms2asm_inc.asm" file now handles the differences in modulation flags that are explained in this post by ValleyBell;
  • I have made a release of the SMPS2ASM tool.

For the SMPS2ASM tool, I am providing a Windows binary; for those of you that don't use Windows, I am also providing the source code; it is bundled with the source code of my S2 Special Stage editor, which you can nab here.

Edit: FYI, SMPS2ASM is a command-line utility.
This post has been edited by flamewing: 18 March 2012 - 07:15 AM

#25 User is offline kram1024 

Posted 05 April 2012 - 07:58 AM

  • Researcher / Hacker
  • Posts: 55
  • Joined: 02-March 04
  • Gender:Male
  • Location:at home, duh
  • Project:Part of the new Team Revamped; Kraminator Special Series disassemblies; Sonic 3 Sound Driver porting guides; KENS 1.5; smps studio; various non-sonic related things
  • Wiki edits:542
sorry for the long time bump, but I got a very strange error when trying to compress it into a sonic1 rom:

Quote

ERROR: Compressed sound driver might not fit.
Please increase your value of Size_of_Snd_driver_guess to at least $1555 and try again.
error: couldn't open "s1built.bin"
error: couldn't open "s1built.bin"

and what it is saying is impossible, the value is set higher than that:
Size_of_Snd_driver_guess = $1580
		CPU 68000
		padding off	; we don"t want AS padding out dc.b instructions
		listing off	; we don"t need to generate anything for a listing file
		supmode on	; we don"t need warnings about privileged instructions
		
		include "sonic1.macrosetup.asm"



#26 User is offline flamewing 

Posted 05 April 2012 - 11:04 AM

  • Elite Hacker
  • Posts: 725
  • 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
Is the constant being redefined to a lower value somewhere else?

#27 User is offline kram1024 

Posted 05 April 2012 - 08:10 PM

  • Researcher / Hacker
  • Posts: 55
  • Joined: 02-March 04
  • Gender:Male
  • Location:at home, duh
  • Project:Part of the new Team Revamped; Kraminator Special Series disassemblies; Sonic 3 Sound Driver porting guides; KENS 1.5; smps studio; various non-sonic related things
  • Wiki edits:542

View Postflamewing, on 05 April 2012 - 11:04 AM, said:

Is the constant being redefined to a lower value somewhere else?


in hivebrain 2005 sonic 1 with some added macros from the hg sonic 3 disasm? I did a search and could not find any

#28 User is offline Cinossu 

Posted 30 May 2013 - 02:26 PM

  • inverted with love~
  • Posts: 2633
  • Joined: 21-June 04
  • Gender:Male
  • Location:London, UK
  • Project:Sonic the Hedgehog Extended Edition
  • Wiki edits:474
A big bump, and by an admin as well. What is the world coming to? :U

A relevant one, though, as it's a question about said driver; I've (finally) got this lovely thing working in Sonic 1 (and have been extending its functionality, namely multi-bank PCM sample playing with the limited z80 knowledge I have), however the Special Stage music, which uses 6 FM Channels rather than 5 FM Channels and 1 DAC, refuses to have its 6th FM channel play anything at all.

As previously mentioned, I have very limited z80 knowledge (at the moment, learning on the fly here) and wouldn't know where to start looking where to debug this. I have noticed that even though the Chaos Emerald sound in S3K uses the same thing (6 FM Channels) it sounds like it never played properly in the original ROM either. Is this a "feature" of the S3K Driver, or something that broke and is easily fixed?

#29 User is offline flamewing 

Posted 30 May 2013 - 04:19 PM

  • Elite Hacker
  • Posts: 725
  • 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
The S1 and S2 sound drivers both reserve enough space for 1 DAC + 6 FM + 3 PSG tracks in music. They update all tracks that are playing when needed, and initialize the FM6 or DAC channel as needed by the song.

The S3&K driver, however, only sets aside enough RAM for 1 DAC + 5 FM + 3 PSG tracks in music. The DAC track is only ever updated as a DAC track, and never as an FM track; the DAC is toggled on/off if there is a DAC sample to be played or finished playing. You are correct that the Chaos Emerald song is broken in the sense that it does not play all tracks; track FM6 is overwritten by the PSG1 track during load. I had noticed it when I made my version of SMPS2ASM, but didn't think to mention it here (which would have saved you some trouble).

The driver itself has precious little RAM left in the z80's 2KB RAM; it would take at last $60 bytes to add extra channels like in S1/S2 drivers, plus any needed code changes (which include disabling both DAC and FM6 channels from music in order to play track FM6 for SFX).

Another less RAM-hungry possibility would be to add code to update the FM6/DAC channel selectively as an FM or DAC channel; the song would need to have the FM6 channel in place of the DAC channel (instead of having a stub DAC channel and 6 FM channels as the case for S1/S2 drivers) and there would be the need to differentiate the channel as being DAC or FM (maybe a bit flag).

#30 User is offline Tiddles 

Posted 30 May 2013 - 05:59 PM

  • Diamond Dust
  • Posts: 427
  • Joined: 25-December 09
  • Gender:Male
  • Location:Nottingham, England
  • Project:Get in an accident and wake up in 1973
  • Wiki edits:31
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.

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

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