Playing VGM Files with SGDK

SGDK only sub forum

Moderator: Stef

Post Reply
bastien
Very interested
Posts: 208
Joined: Mon Jun 25, 2007 7:19 pm
Location: Besançon,France
Contact:

Playing VGM Files with SGDK

Post by bastien » Fri Sep 21, 2012 7:35 am

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?

KanedaFr
Administrateur
Posts: 1128
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Fri Sep 21, 2012 9:15 am

SGDK has a z80 assembler
I wrote a VGM driver last year using WlaDX (which could be an interesting alternative to sjasm )

bastien
Very interested
Posts: 208
Joined: Mon Jun 25, 2007 7:19 pm
Location: Besançon,France
Contact:

Post by bastien » Fri Sep 21, 2012 10:31 am

did you male it public ?

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

Post by kubilus1 » Mon Sep 24, 2012 8:12 pm

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:

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.

bastien
Very interested
Posts: 208
Joined: Mon Jun 25, 2007 7:19 pm
Location: Besançon,France
Contact:

Post by bastien » Tue Sep 25, 2012 3:38 pm

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.

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

Post by kubilus1 » Wed Sep 26, 2012 1:18 am

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.

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

Post by kubilus1 » Mon Oct 15, 2012 1:36 am

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.

Stef
Very interested
Posts: 3004
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Mon Oct 15, 2012 8:33 am

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).

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

Post by kubilus1 » Mon Oct 15, 2012 3:35 pm

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 ;)

bastien
Very interested
Posts: 208
Joined: Mon Jun 25, 2007 7:19 pm
Location: Besançon,France
Contact:

Post by bastien » Fri Oct 19, 2012 5:10 pm

thanks you very much for sharing your exemple :D
Now my demo works 8)
+1 for PCM in the next feature

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

Post by kubilus1 » Thu Oct 25, 2012 3:35 pm

+1 for PCM in the next feature
Done. See: viewtopic.php?p=17469#17469

Post Reply