z80 vgm player
Moderator: BigEvilCorporation
z80 vgm player
This is my vgm player for the z80. Works on real hardware. This assumes that the vgm starts at 0x8000 in the rom. Doesn't play samples as of yet. You have to pre-process the vgm with vgm2zgm in the tarball. This compiles with a slightly modified sdcc. prog.c tells you what's modified. I'll also supply the firmware, here you go
source code is here
source code is here
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
bin2head coverts a binary onto a c header file. basically I #include the firware into my codekubilus1 wrote:Wow, that seems to be what I am looking for. Now I just have to figure out how to incorporate it into a running example. BTW, what is bin2head? Google only seems to show window EXE, is there something more *nix friendly?
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
I've never used sgdk so I don't know. as far as I know sgdk is just a gcc library so yeah. you could #include it or .incbin it. vgm2zgm just makes all the vgm instructions the same size. that's to promise the same number of z80 clocks per instruction. aside from samples it should work on any sega genesis vgm
-
- Very interested
- Posts: 710
- Joined: Sat Feb 18, 2012 2:44 am
Updated the Driver
Okay I spent some time revamping this driver and making it a bit more of an API. Now the songs can be located anywhere in the memory and the driver will take care of banking, finding the offset within the bank, etc.
The sdcc stack space at 0x1fff still applies, but I went ahead and precompiled the z80 driver and bin2c'd it to a .h file so it won't be necessary to deal with this.
This is in three parts:
* The z80 stuff: vgm_drv.c (The source) vgm_drv.h (The compiled driver) Makefile
* The 68k interface: vgm_client.c (The main lib) vgm_client.h (The api to this) Makefile.client (yeah two makefiles, crappy I know!)
* A sample use case: test.c (Just threw this into Makefile.client because I'm lazy)
Test.c should show how this is used and now should be very straightforward. Deflemask > vgm > vgm2zgm > bin2c. Then just point the driver at the start of your song and tell it to go. I'm sure there are some bugs, which I'll work on when I get time.
I also threw in a couple crappy songs I did in deflemask with the vgm export, just to show that it can be done. I apologize for any injured ears. Prebuilt this as z80vgm.bin.
Also, thanks to Sigflup, ChillyWilly, and others whose bits and pieces of code from the forum found there way into this.
Here's the download: http://dl.dropbox.com/u/101302896/z80_sound_drvr.tgz
The sdcc stack space at 0x1fff still applies, but I went ahead and precompiled the z80 driver and bin2c'd it to a .h file so it won't be necessary to deal with this.
This is in three parts:
* The z80 stuff: vgm_drv.c (The source) vgm_drv.h (The compiled driver) Makefile
* The 68k interface: vgm_client.c (The main lib) vgm_client.h (The api to this) Makefile.client (yeah two makefiles, crappy I know!)
* A sample use case: test.c (Just threw this into Makefile.client because I'm lazy)
Test.c should show how this is used and now should be very straightforward. Deflemask > vgm > vgm2zgm > bin2c. Then just point the driver at the start of your song and tell it to go. I'm sure there are some bugs, which I'll work on when I get time.
I also threw in a couple crappy songs I did in deflemask with the vgm export, just to show that it can be done. I apologize for any injured ears. Prebuilt this as z80vgm.bin.
Also, thanks to Sigflup, ChillyWilly, and others whose bits and pieces of code from the forum found there way into this.
Here's the download: http://dl.dropbox.com/u/101302896/z80_sound_drvr.tgz
Glad you like it. I kind of cheated with the IO between the z80 and 68k. It seems sdcc will not do staticly located variables, at least not on the z80. This should be fine unless the variables are moved around, then you would have to reference the .map file. I thought about making some sort of parser for this and spitting out a header, perhaps later.
Otherwise, sdcc is really neat!
Now onto, making some graphics, sprites and stuff. Will look at mega-happy-sprite. It's great there are other *Nix developers doing genesis development, I was starting to worry that this was a Windows only club.
Otherwise, sdcc is really neat!
Now onto, making some graphics, sprites and stuff. Will look at mega-happy-sprite. It's great there are other *Nix developers doing genesis development, I was starting to worry that this was a Windows only club.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Damn! That's pretty nifty! I'd have never though to do a z80 sound driver in C.
That's probably plenty fine for anything but pcm. For that you'd need to redo the player to 100% assembly.
You're right about sdcc not doing static entry points in banks... so what we did for the SMS Myth menu was mic made a little tool to convert sdcc map files into h and inc files with the values needed. If you're interested, look at the map2h.cpp file in the sms tools branch of the neomythmenu project at google code.
http://code.google.com/p/neo-myth-menu/
Note - there's also a vgm player in the sms myth menu, but it's for playing SMS VGMs. It could be altered to play MD VGMs, I imagine.
That's probably plenty fine for anything but pcm. For that you'd need to redo the player to 100% assembly.
You're right about sdcc not doing static entry points in banks... so what we did for the SMS Myth menu was mic made a little tool to convert sdcc map files into h and inc files with the values needed. If you're interested, look at the map2h.cpp file in the sms tools branch of the neomythmenu project at google code.
http://code.google.com/p/neo-myth-menu/
Note - there's also a vgm player in the sms myth menu, but it's for playing SMS VGMs. It could be altered to play MD VGMs, I imagine.
-
- Very interested
- Posts: 208
- Joined: Mon Jun 25, 2007 7:19 pm
- Location: Besançon,France
- Contact:
Re: Updated the Driver
How did u use vgm2zgm i have builded the .c and use the syntaxe vgm2zgm test.vgm but don't works.kubilus1 wrote:
Test.c should show how this is used and now should be very straightforward. Deflemask > vgm > vgm2zgm > bin2c. Then just point the driver at the start of your song and tell it to go. I'm sure there are some bugs, which I'll work on when I get time.
Thanks for help
Updated Sound Driver.
Updated the z80 VGM player:
* vgm2zgm no longer required. Just turn a regular vgm into a header file with bin2c or something similar. Have tried with a number of different VGM versions.
* PCM support. This works with PCM from files exported from Deflemask. 8khz samples only.
* Banking switching, looping, etc. This should work correctly with files split across banks, that loop across banks, PCM split across banks, etc. Reading header and determining loop location and other relevant info.
* Examples for both sgdk and non-sgdk usage.
* Pausing works.
Get it here: http://dl.dropbox.com/u/101302896/sound ... _25_12.zip
----------------------------
Note, it's unlikely I'll try for anything above 8khz samples since this would be impractical in C, unless I re-write this in straight assembly. However, I would rather work on something else, such as, I don't know, creating a game of sorts!
* vgm2zgm no longer required. Just turn a regular vgm into a header file with bin2c or something similar. Have tried with a number of different VGM versions.
* PCM support. This works with PCM from files exported from Deflemask. 8khz samples only.
* Banking switching, looping, etc. This should work correctly with files split across banks, that loop across banks, PCM split across banks, etc. Reading header and determining loop location and other relevant info.
* Examples for both sgdk and non-sgdk usage.
* Pausing works.
Get it here: http://dl.dropbox.com/u/101302896/sound ... _25_12.zip
----------------------------
Note, it's unlikely I'll try for anything above 8khz samples since this would be impractical in C, unless I re-write this in straight assembly. However, I would rather work on something else, such as, I don't know, creating a game of sorts!