z80 vgm player
Moderator: BigEvilCorporation
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.
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.
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?
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?
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.
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.