With stef posting the XGM driver i figured i would post this as well to give more options for users that want to use Sega CD / Mega CD for music and the Z80 for simple sound effects. I cant take any credit for the driver itself. All i did was get it to a state so it can be called from bex programs.
Just extract all files into a folder called "sfx" within the main basicgaxorz folder and move shiru.bex into the main basicgaxors folder and compile
I'm working on making this work from RAM - and loading samples off the CD-ROM. A bit more complicated than just store them in ROM or preloading them in the binary.
I'll post results as soon as I get them. My idea is set up a special cluster in the CD-ROM and a slot-based sounds pool in the main Genesis RAM (in my own project, I'm using word-ram to store tons of image buffers and need every single byte). You pre-load some sounds from the cluster into the sounds pool and use an ID number to play them from the pool.
I'm still trying to make this work. No luck yet, but I'm getting close.
There was one BIG problem with the original code: The Z80 driver could only read samples from ROM. The bank selection wasn't fully coded, it just sent 7 bits to the bank register at $6000, so only samples loadad in the first 4Mb of address space (this is, the cartridge ROM) could be read and played.
In order to make this usable for the Sega-CD, samples have to be played from RAM.
In my engine I'll be using the main Megadrive RAM, which is allocated from FF0000 onwards. That means that I need all 9 bits written to the bank register. I've made a dirty attempt just writing 1s to bits 8 and 9. I had to modify the driver and reassemble it.
When I make this to work I'll try to share, but without a proper emulator with a nice debugger this is being a nightmare.
I tested your driver and this great. But I see that the sound volume is low compared to the music from a CD.
I tried to increase the volume of samples with Audacity but only get their distortion.
¿I can increase the volume in any way?
This could probably be changed in the ASM source and then re-compiling the driver that is being linked or added into your bex program. I dont know for sure that there is a value in the source for that driver for volume settings that can easily be changed to be honest. Id have to look and see. More than likely its something like adding a multiply value in there for volume when writing the sample out or something of that nature.
Ill try and look later tonight if i get some time.
Last Edit: Jul 29, 2015 12:06:25 GMT -5 by lunchbox