Hello everyone,
I'm working on a music replayer in asm. My music format is loosely based on the PLAY strings, with some differences. Anyway, the replayer is decrementing a different counter for each channel, depending on the lengths of the notes played, of course. As well as interpreting note lengths, alterations, etc ...
I would like to insert an SFX (like any noise inside a game - shoot, fall, explosion ...) or a little music (like a door opened, or treasure found, you get the idea) into a playing track, and be able to resume the music after the SFX/music is finished. The difficulty being that I'm using the full 3 PSG channels for the main track. And of course, all 3 channels must remain synchronized.
The solution I have found so far is to use a silent 'shadow channel'. So, when the SFX is needed :
- I copy the designated channel data (counter, queue, ...) to the shadow channel
- I load the SFX in the designated channel
- I continue to decode the 3 PSG channel PLUS the shadow channel (but not sending notes to the PSG for that one, of course)
- When the SFX is finished, I copy back the shadow channel data to the designated channel, and stop decoding the shadow channel.
Of course it needs for the replayer to decode 4 channels instead of 3, and maybe even more if inserted SFX/music needs more than one channel (although I could live with the capacity of only one channel for SFX/music).
Does someone have a better solution?
What are your thoughts?
Thanks.