GenDev SpritesMind Website SpritesMind.Net
Sega Megadrive/Genesis development
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

z80 vgm player
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    SpritesMind.Net Forum Index -> Megadrive/Genesis
View previous topic :: View next topic  
Author Message
sigflup
Very interested


Joined: 06 Sep 2010
Posts: 62

PostPosted: Sat Aug 04, 2012 11:18 pm    Post subject: z80 vgm player Reply with quote

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
View user's profile Send private message
Chilly Willy
Very interested


Joined: 17 Aug 2007
Posts: 2005

PostPosted: Sat Aug 04, 2012 11:47 pm    Post subject: Reply with quote

Nice work! You've been busy. Very Happy
Back to top
View user's profile Send private message
kubilus1
Very interested


Joined: 16 Aug 2012
Posts: 70

PostPosted: Fri Aug 17, 2012 4:06 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
sigflup
Very interested


Joined: 06 Sep 2010
Posts: 62

PostPosted: Fri Aug 17, 2012 4:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
djcouchycouch
Very interested


Joined: 18 Feb 2012
Posts: 455

PostPosted: Fri Aug 17, 2012 6:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
sigflup
Very interested


Joined: 06 Sep 2010
Posts: 62

PostPosted: Sat Aug 18, 2012 6:42 pm    Post subject: Reply with quote

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
View user's profile Send private message
djcouchycouch
Very interested


Joined: 18 Feb 2012
Posts: 455

PostPosted: Sun Aug 19, 2012 1:35 am    Post subject: Reply with quote

Can it play music and sound effects together?
Back to top
View user's profile Send private message
sigflup
Very interested


Joined: 06 Sep 2010
Posts: 62

PostPosted: Sun Aug 19, 2012 2:09 am    Post subject: Reply with quote

don't see why not. You'd have to play the sound effects with the 68k though
Back to top
View user's profile Send private message
kubilus1
Very interested


Joined: 16 Aug 2012
Posts: 70

PostPosted: Wed Aug 29, 2012 4:03 am    Post subject: Updated the Driver Reply with quote

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
View user's profile Send private message Visit poster's website
sigflup
Very interested


Joined: 06 Sep 2010
Posts: 62

PostPosted: Thu Aug 30, 2012 7:51 pm    Post subject: Reply with quote

wow! this is awesome! thank you
Back to top
View user's profile Send private message
kubilus1
Very interested


Joined: 16 Aug 2012
Posts: 70

PostPosted: Thu Aug 30, 2012 8:40 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Chilly Willy
Very interested


Joined: 17 Aug 2007
Posts: 2005

PostPosted: Fri Aug 31, 2012 12:40 am    Post subject: Reply with quote

Damn! That's pretty nifty! I'd have never though to do a z80 sound driver in C. Laughing

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
View user's profile Send private message
bastien
Very interested


Joined: 25 Jun 2007
Posts: 157

PostPosted: Sat Oct 20, 2012 9:21 am    Post subject: Re: Updated the Driver Reply with quote

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
View user's profile Send private message Visit poster's website
kubilus1
Very interested


Joined: 16 Aug 2012
Posts: 70

PostPosted: Mon Oct 22, 2012 4:02 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
kubilus1
Very interested


Joined: 16 Aug 2012
Posts: 70

PostPosted: Thu Oct 25, 2012 3:32 pm    Post subject: Updated Sound Driver. Reply with quote

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! Smile
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    SpritesMind.Net Forum Index -> Megadrive/Genesis All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group