| View previous topic :: View next topic |
| Author |
Message |
sigflup Very interested

Joined: 06 Sep 2010 Posts: 62
|
Posted: Sat Aug 04, 2012 11:18 pm Post subject: 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 |
|
| Back to top |
|
 |
Chilly Willy Very interested
Joined: 17 Aug 2007 Posts: 2005
|
Posted: Sat Aug 04, 2012 11:47 pm Post subject: |
|
|
Nice work! You've been busy.  |
|
| Back to top |
|
 |
kubilus1 Very interested

Joined: 16 Aug 2012 Posts: 70
|
Posted: Fri Aug 17, 2012 4:06 pm Post subject: |
|
|
| 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? |
|
| Back to top |
|
 |
sigflup Very interested

Joined: 06 Sep 2010 Posts: 62
|
Posted: Fri Aug 17, 2012 4:49 pm Post subject: |
|
|
| kubilus1 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? |
bin2head coverts a binary onto a c header file. basically I #include the firware into my code |
|
| Back to top |
|
 |
djcouchycouch Very interested
Joined: 18 Feb 2012 Posts: 455
|
Posted: Fri Aug 17, 2012 6:56 pm Post subject: |
|
|
Hi,
Can this be made to work with the SGDK?
What does the vgm2zgm tool do the vgm file?
Other than not playing samples, are there any other current limitations?
Thanks!
DJCC |
|
| Back to top |
|
 |
sigflup Very interested

Joined: 06 Sep 2010 Posts: 62
|
Posted: Sat Aug 18, 2012 6:42 pm Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
djcouchycouch Very interested
Joined: 18 Feb 2012 Posts: 455
|
Posted: Sun Aug 19, 2012 1:35 am Post subject: |
|
|
| Can it play music and sound effects together? |
|
| Back to top |
|
 |
sigflup Very interested

Joined: 06 Sep 2010 Posts: 62
|
Posted: Sun Aug 19, 2012 2:09 am Post subject: |
|
|
| don't see why not. You'd have to play the sound effects with the 68k though |
|
| Back to top |
|
 |
kubilus1 Very interested

Joined: 16 Aug 2012 Posts: 70
|
Posted: Wed Aug 29, 2012 4:03 am Post subject: 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 |
|
| Back to top |
|
 |
sigflup Very interested

Joined: 06 Sep 2010 Posts: 62
|
Posted: Thu Aug 30, 2012 7:51 pm Post subject: |
|
|
| wow! this is awesome! thank you |
|
| Back to top |
|
 |
kubilus1 Very interested

Joined: 16 Aug 2012 Posts: 70
|
Posted: Thu Aug 30, 2012 8:40 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Chilly Willy Very interested
Joined: 17 Aug 2007 Posts: 2005
|
Posted: Fri Aug 31, 2012 12:40 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
bastien Very interested
Joined: 25 Jun 2007 Posts: 157
|
Posted: Sat Oct 20, 2012 9:21 am Post subject: Re: Updated the Driver |
|
|
| 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.
|
How did u use vgm2zgm i have builded the .c and use the syntaxe vgm2zgm test.vgm but don't works.
Thanks for help |
|
| Back to top |
|
 |
kubilus1 Very interested

Joined: 16 Aug 2012 Posts: 70
|
Posted: Mon Oct 22, 2012 4:02 pm Post subject: |
|
|
I believe like this:
$ cat test.vgm | vgm2zgm > test.zgm
PS: I'm working on an update to this driver that will no longer require vgm2zgm and will support PCM, along with other improvements. |
|
| Back to top |
|
 |
kubilus1 Very interested

Joined: 16 Aug 2012 Posts: 70
|
Posted: Thu Oct 25, 2012 3:32 pm Post subject: 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_drvr_10_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!  |
|
| Back to top |
|
 |
|