z80 vgm player

For anything related to sound (YM2612, PSG, Z80, PCM...)

Moderator: BigEvilCorporation

kubilus1
Very interested
Posts: 237
Joined: Thu Aug 16, 2012 2:25 am
Contact:

Post by kubilus1 » Fri Nov 02, 2012 10:11 pm

Turns out that sdcc will use an assembler lookup table for switch statements as long as the cases are more or less sequential. Filling in the missing commands does the trick! Next update should be a bit faster.

Boddah
Newbie
Posts: 3
Joined: Sun May 04, 2014 12:13 am

Post by Boddah » Sat Aug 23, 2014 7:15 pm

Just wanted to say thanks for this driver. I've only just started learning megadrive development using SGDK. Wanted to loop a vgm file but the sgdk functions didn't seem to want to loop my file. Your driver works a treat :)

Ste
Newbie
Posts: 2
Joined: Tue Sep 02, 2014 7:33 pm

Post by Ste » Tue Sep 02, 2014 7:45 pm

Hey, guys. I've been writing some software using the SGDK, and found some issues with the VGM driver. I contacted Stephane, and he told me to post my findings here.

I've noticed that if the VGM file doesn't contain a parameter at the end to loop itself back to a previous spot in the VGM, the VGM driver does weird things and can crash the entire program. We've been using DefleMask to generate some sounds. After much investigation, we determined that the driver doesn't behave properly without having this "go to pattern" command at the end of a track.

The other issue, is that the driver is unable to stop itself until it hits a command in the VGM. This is a little harder to explain, but take a look at this screenshot. There are 64 "rows" in this song. Let's say I play a note at row 000 and I have blank rows all the way until 063. If I play the song using SND_startPlay_VGM() and then issue a SND_stopPlay_VGM() some time between row 001 and row 063, it won't actually stop the song until it loops back to row 000 (because that's where the next note or "command" is). Our solution was to add special "OFF" commands in every row, for the purpose of not leaving any row blank. With these dummy commands, the sound driver seems to be responsive to a SND_stopPlay_VGM() no matter when it is initiated.

That's all I have right now. Let me know if I need to clarify anything. I appreciate all the work that was put into this driver. Thank you.
Ste Kulov
Lead Design Engineer
HD Retrovision
http://www.hdretrovision.com

kubilus1
Very interested
Posts: 237
Joined: Thu Aug 16, 2012 2:25 am
Contact:

Post by kubilus1 » Tue Sep 02, 2014 10:44 pm

As far as having a pause before stopping, this is likely due to how the VGM spec does waits, plus some optimization I had to do to get everything working working quickly enough on the z80.

The wait times are potential times I may need to feed PCM data, in order to have this go smoothly, I skip checking commands from the 68k during this time. By putting in a dummy command, you have essentially forced the system to do the check.

Now the first problem seems strange to me. By default, the vgm player should just keep looping the song when it reaches the end, indicated by a 0x66 command, and required by the VGM spec. The actual position this will loop to is specified in the VGM header (0x1C).

There could be a bug in the player, or possibly in the file. What version of VGM is the file, btw?

Ste
Newbie
Posts: 2
Joined: Tue Sep 02, 2014 7:33 pm

Post by Ste » Tue Sep 02, 2014 11:54 pm

I tried all three versions I was allowed to export to: 1.50, 1.60, and 1.61.

I was able to get any VGM without a specific auto-loop at the end to exhibit the odd behavior. To eliminate the notion of me possibly screwing something up in code, I was simply using the sound sample program provided by the SGDK and just kept swapping out "roadrash.vgm" with various other VGMs.

Let me know if you need any more info.
Ste Kulov
Lead Design Engineer
HD Retrovision
http://www.hdretrovision.com

Post Reply