Years ago I was tasked with writing a mod player and SFX player (single-channel, single track mods) in Z80. I did this by getting one of those Master System plug-ins for the Megadrive and altered the chip-select logic so it appeared in the right place for the Z80s view of it. It was a lot of fun. The code sat in the 8K RAM and it accessed the ROM to read the mod data. There was even enough CPU time left to support playing samples (but, to be fair, they were a bit ropy since the mod-player used quite a lot of CPU time. I tried to work out a way of introducing interrupts to allow accurate playing. Well, the system allowed H-blank interrupts but these only worked ON screen time. Not in the VBlank. If you want to examine the player, then look at Chuck Rock 2 on the Megadrive. It was cool, you could halt the 68000 and the music carried right on playing. The Megadrive was an amazing machine. If only they had used bit-0 of the RGB values on the palette so it would have had 4096 colours instead of the crummy 512. I mean, they just ignored bit 0! Same with the sound chip. The channels were 0,1,2,4,5,6 (that caused fun in developement) suggesting that it was a cut-down 8 channel chip. Overall, in many areas, the Megadrive had all the hallmarks of cut-down arcade hardware. The function of changing Y scroll every 16 pixels. If only it were every 8. Still, using 2 playfields you could make mighty canyons (although the two playfields could only overlap using color 0 (transparent). I still have an unanswered question about the machine. If you placed a high priority sprite and placed it with priority to go behind the playfields, then placed a lower priority sprite to go OVER the playfields, what is displayed. I ask because this problem existed on the humble C64. Maybe some interesting effects could be produced. Regards to all, Sean;-) PS what with the power and disc space of the new consoles, you could put a NES,SNES,Master System, Genesis, PC Engine and even (maybe) an N64 emulator AND a whole heap of ROMS onto a single disc. I mean, I thought the Nintendo Wii encryption had been cracked so it would be possible to make it work on an unmodded machine. PPS Anyone know the record for the number of channels played on the GBA and N64?
You might want to check out this forum. I'm sure someone there could answer your question about sprite priorities. BTW Chuck Rock was a cool game. :icon_bigg
Piglet, do you have any of that anywhere available ? I myself have worked on a nice sound engine for MD myself : http://www.fileden.com/files/2008/4/21/1876835/TMFPLAY.BIN (works nicely only in Kega Fusion or on real HW) For the low/high priority sprites quirk, the sprite in front of the the other which is behind a BG layer will have a transparent silouette shaped like the sprite behind BG (so you see BG layer).... I hope this made any sense...
I used a master-system emulator on the MD and hard-wired the sound-chip so that the Z80 could see it. It was interesting because if you halter the 68000, the sound kept on running...
As they all should. I don't know if 68000 or Z80 has bus priority, but either way, why, when one processor halts, would the other halt? Oh, I did do samples on it but the quality was a bit ropey...
Did you do any frequency scaling on the samples (ala fixed point counter/indexer) or were the samples played at a fixed frequency? Just curious 'cause you said MOD.
A 2ch MOD player with volume and all other effects is percetly feasible, but you cannot maintain good sample rate... I could add resampling to TMSE, but it would mean I get less than 22KHz rate, and this is unacceptable for me. 4ch player will require creativity, and I can positively say 8KHz is max you get, unless you have all your samples in single 32KB bank. If Sega would have used a flipflop instead of a shift reg in the banker, things would have been soooooo much easier. On 68K, you could possibly have 16channels, with Z80 doing playback, but the quality would suck due to low bit per channel...
What sample playback method are you using? The DAC on the 2612 or the PWM method on the PSG unit? If you can output at 22khz 8bit PCM, then that's pretty damn good. Amiga's 4 channel mod players only had a maximum output of 32khz. Many instruments in mod files are played back at less than 16khz. Usually in the 8-16khz range for notes. http://www.youtube.com/watch?v=U5sZQEzfbPA (A standard 22khz 8bit mono playback demo) I wouldn't do anymore channels than 4. That'd still give you 6bits per channel when mixed, 7bit if you handle clipping. You still have FM channels, so no need to do more than 4 wavetable synth channels. I doubt the Z80 even has enough resource to properly scale the frequency of four samples simultaneously at the rate of 22khz. Plus you still have to handle software volume for each channel and then downmix into a single channel (and clipping if you want higher quality). That's 273 samples per channel per 1/60 second you'd have to handle. On the 7.16mhz PCE, the fastest I could get frequency scaling of all 4 channels was at 27% CPU resource per frame at 15.7khz, with a little bit of self modifying code. And that's a much faster processor than the z80 in the Megadrive. Why not have 68k do the frequency scaling, volume, and mixing and transfer the preped data to the z80? No bank switching to worry about and such.
I only use DAC of YM2612, it is nothing bad, its that only Fusion and Regen emulate it correctly (ALL other emulators have it sound REALLY poor). PSG is used for PSG I have 2 channels with volumes at maximum of 35KHz. If I cut out sample rate adjustment and volume stuff I get 56KHz or close to it. My current playback management method does not allow easy resampling to be added (I have everything working around the number 256). my connection sucks today (snowstorm), I'll check later. I COULD add a 3rd channel to TMSE, but it will have too negative effect of the sample playback quality. I have still above 22KHz rate, but the jitter makes things too scratchy... Street Fighter anyone ? Only things in my code that run on frames are SFX (~57Hz) and BGM(~49Hz). All other time, sample playback is being managed... fully functioning MOD player doing 8KHz is quite possible providing all samples are in the same bank. Bank switching is the only pain here, if there wouldn't be this stupid method used, I could be having some really nice things being done. Because you have Z80 for sound, and in my case I need every cycle 68K offers. Only few cycles per frame are allowed for sound generation
Don't forget, the address of the Megadrive RAM means if you will forgo an address register, you can short-word address ALL the RAM (point it 32K in).
I did not quite get what you meant but Z80 cannot do effective access to 68K RAM... writes fail and reads return nothing useful.