Playing VGM Files with SGDK
Moderator: Stef
-
- Very interested
- Posts: 208
- Joined: Mon Jun 25, 2007 7:19 pm
- Location: Besançon,France
- Contact:
Playing VGM Files with SGDK
Hi all,
I know Mic_s have writted a tools with can generate a Genesis Demo with included vgm files but it will be nice if i can use vgm files directly in SGDK.
In other way sigflup have made a Z80 vm player but it will need a Z80 compilator and actualy sgdk don't have that feature.
So ,did you know a way for playing the vgm files with SGDK?
I know Mic_s have writted a tools with can generate a Genesis Demo with included vgm files but it will be nice if i can use vgm files directly in SGDK.
In other way sigflup have made a Z80 vm player but it will need a Z80 compilator and actualy sgdk don't have that feature.
So ,did you know a way for playing the vgm files with SGDK?
The updated z80vgm player that I posted a few weeks back already has all the z80 stuff precompiled for you. No z80 compilation necessary, just include the vgm_client.h file, your music bin2c'd and tell it to load and start your song.
Not sure how this would be different in sgdk, but the basic C would be something like the following pseudocode:
To get your song into the right format, do the following. First take your vgm file (no PCM instruments, please) and use sigflup's vgm2zgm converter. Then use the bin2c program to turn the '.zgm' file into a '.h' file.
Not sure how this would be different in sgdk, but the basic C would be something like the following pseudocode:
Code: Select all
#include "vgm_client.h"
#include "mysong.h"
int main(void)
{
// Load the z80vgm driver
load_driver();
// May need a short pause here.
song_addr = &mysong_zgm;
load_song(song_addr);
start_it();
while(1)
{
// My video game loop here.
}
return 0;
}
To get your song into the right format, do the following. First take your vgm file (no PCM instruments, please) and use sigflup's vgm2zgm converter. Then use the bin2c program to turn the '.zgm' file into a '.h' file.
-
- Very interested
- Posts: 208
- Joined: Mon Jun 25, 2007 7:19 pm
- Location: Besançon,France
- Contact:
Hi,
I have tried to compile this with SGDK , i have no error but nothing seems to song in the out demo
Did you find something wrong here :
http://sega4ever.power-heberg.com/tutod ... M_Test.rar
this is my C VGM test project , i have just tried to play your music.
I have tried to compile this with SGDK , i have no error but nothing seems to song in the out demo
Did you find something wrong here :
http://sega4ever.power-heberg.com/tutod ... M_Test.rar
this is my C VGM test project , i have just tried to play your music.
I'm not really sure if 'waitMs' is equivalent to 'delay' or not. If there is not enough of a delay between loading the driver and using it, things seem not to work. Perhaps try a longer delay, like a full second sleep.
It does appear that the driver is loaded in the rom you built. Unfortunately I cannot build the SGDK setup ATM, since I don't use Windows.
I'll try to look a bit deeper to see if there is an issue when I get some time.
It does appear that the driver is loaded in the rom you built. Unfortunately I cannot build the SGDK setup ATM, since I don't use Windows.
I'll try to look a bit deeper to see if there is an issue when I get some time.
Now that I got the SGDK setup on my Linux system, I was able to see if I can get the SGDK build chain and the Z80 VGM player to get along nicely.
I've setup a basic example of just that. Get it here:
http://dl.dropbox.com/u/101302896/sgdk_z80vgm.zip
Next up is attempting to get this better incorporated into the SGDK environment, which might be tricky since the z80vgm driver uses sdcc.
I've setup a basic example of just that. Get it here:
http://dl.dropbox.com/u/101302896/sgdk_z80vgm.zip
Next up is attempting to get this better incorporated into the SGDK environment, which might be tricky since the z80vgm driver uses sdcc.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Indeed SGDK does not include any C compiler for Z80 and that for severals reasons : do not mix up C sources files (but can be avoided by using specific c80 extension for instance) and also because i believe we cannot exploit much from Z80 with C language, this is even more true we have very limited ram which should contain both code and work variables.
The VGM player written in C does not handle PCM playback which is, imo, a must have for a VGM driver. There are severals Z80 VGM player around and i believe some are capable to play PCM so they should be a better candidate than the C version. Also at some point i wanted to write my own VGM player to add more possibilities to it (as playing severals PCM) but i don't know if that is really possible (as i ant to somehow keep the VGM established format).
The VGM player written in C does not handle PCM playback which is, imo, a must have for a VGM driver. There are severals Z80 VGM player around and i believe some are capable to play PCM so they should be a better candidate than the C version. Also at some point i wanted to write my own VGM player to add more possibilities to it (as playing severals PCM) but i don't know if that is really possible (as i ant to somehow keep the VGM established format).
I have seen some other VGM players with full PCM support, but they didn't seem to use the Z80, which is a must to be useful. I wouldn't mind checking out some alternatives to what I posted that I may have missed.
I was considering adding PCM support to the posted driver. I should be able to write the PCM stuff in assembly and link this in. Once I find the time that is
I was considering adding PCM support to the posted driver. I should be able to write the PCM stuff in assembly and link this in. Once I find the time that is
Done. See: viewtopic.php?p=17469#17469+1 for PCM in the next feature