how can i do music on megadrive?

For anything related to sound (YM2612, PSG, Z80, PCM...)

Moderator: BigEvilCorporation

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Tue Mar 13, 2007 2:15 pm

TmEE co.(TM) wrote:I was thinking about 1 thing: What would happen if VBL happens while you're changing bank :?:
You've to disable interrupt during your main process and re-enable it only on safe period...
It's why setting a flag during the V-Int handler is ok what ever you're doing :)

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Wed Mar 14, 2007 7:49 am

No other way than disabling ints, this could cause nasty note skips though :(
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Wed Mar 14, 2007 9:34 am

TmEE co.(TM) wrote:No other way than disabling ints, this could cause nasty note skips though :(
Then you can do as i'm doing : setting a flag in the V-Int code then in your main loop you check for this flag and do the accorded process.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Wed Mar 14, 2007 1:31 pm

I don't quite get your point... if I set a flag in Vint routine and reset it in its end, main code won't see any changes......... I just figured out a way to get over the problem: In Bank changing routine, there will be a bit-counter, so when Vint happens, you set(or unset) the bits not set yet, so you can do other bank changes. In the end you set the set bits thet were set before again, and main routine runs like there isn't anything happened, problem is solved !!! I hope its not too ununderstandable :wink:
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Wed Mar 14, 2007 3:32 pm

I guess that will help you :

vint_handler
LD A, #1
LD (FLAG), A
RETI



...
main_loop
...
LD A, (FLAG)
CALL NZ, process_vint_stuff
...
JP main_loop


process_vint_stuff
...
XOR A
LD (FLAG), A
RET
Last edited by Stef on Thu Mar 15, 2007 8:03 am, edited 1 time in total.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Mar 15, 2007 6:23 am

That way...
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Thu Mar 15, 2007 8:04 am

TmEE co.(TM) wrote:That way...
Imo, still the best way of doing it... no corruption possible :)

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Mar 15, 2007 2:01 pm

Yes that should work very well, i have thought about one problem but I guess if the code is fast enough, it won't occur
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

TulioAdriano
Very interested
Posts: 81
Joined: Tue Jul 10, 2007 7:45 pm
Location: Brazil / USA
Contact:

Post by TulioAdriano » Wed Aug 22, 2007 2:20 pm

Hi, sorry for resurrecting this topic, but I have a question. What is the maximum sample size you load for playing DAC or do you play it directly from ROM (making it unlimited like Tiido's HI-FI rom)?

Thanks
Tulio
Image

Eke
Very interested
Posts: 885
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Thu Aug 23, 2007 9:21 am

Hi, I'm currently looking into the MAME YM2612's core and have a little question about the YM2612 chip:

according to Sega documentation, both Channels 3 and 6 have the capability to have full separated frequencies for each 4 operators, by setting bit6 in register 27h (Part 1). Although this bit is named 'CH3 MODE' , this seems logic to me as registers A8h-ACh (used to set the extra frequencies for CH3 ops) also exist on Part2 side, which control Channels 4 to 6

however, in the Mame FM core, this feature is only emulated for Channel 3 (writing registers A8h-ACh in Part 2 do nothing and Channel 6 is always refreshed like any other channel)

So, which is right ?

I didn't have modified the Fm core yet to support channel 6 "special mode" but I was wondering if current sound weirdness in some games (some percussion sounds for example) might come from this eventual missing feature ?

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Aug 23, 2007 11:53 am

Samples are usually played form ROM (through z80 bank), but I'm pretty sure there's games that have some in z80 RAM... you can't fit much in there, 8KB is not much...
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Aug 23, 2007 8:38 pm

TmEE co.(TM) wrote:Samples are usually played form ROM (through z80 bank), but I'm pretty sure there's games that have some in z80 RAM... you can't fit much in there, 8KB is not much...
Yeah, I would say most digital samples are played from ROM - to play from RAM, you'd have to copy the data to the RAM first, and as TmEE remarks, there's not much of that. Setting the ROM bank the Z80 reads is quick compared to the sample period of the audio, so even when you run out of space in the bank you use to read the ROM, you just quickly switch the bank to continue reading more, so samples are now limited by the total size of the ROM, not the space in the Z80 memory.

Eke
Very interested
Posts: 885
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Fri Aug 24, 2007 7:56 am

Maybe it's also possible to access the 68K RAM through the bank ? So you would have even more space to store your samples :?:

from gen-hw.txt:
2.3) Banking
...
In my own tests, I've been unable to do the following:

- Read banked 68000 RAM. (returns FFh)
- Find result of partial writes to the bank address register.
- Have the Z80 read A00000-A0FFFF through the banked memory area.
(locks up the machine)

Steve Snake informed me that reading 68000 RAM is possible, but is not a recommended practice by Sega. Perhaps only some models of the Genesis allow for it.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Fri Aug 24, 2007 9:09 am

Thing is, that it won't work... and I think there is no reason to waste RAM on samples because you use banking anyway and it works on ROM and with good code like I've written, you can have up to 110KHz sampling rate (which is little too much, real HW can handle only 70KHz for a short period of time, and I'm pretty sure that everything after 33KHz(if you wait before chip is ready, busy flag... this might interest Eke) won't make any difference (samples get missed I supose). I need to learn to write shorter sentences :wink:
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Shiru
Very interested
Posts: 786
Joined: Sat Apr 07, 2007 3:11 am
Location: Russia, Moscow
Contact:

Post by Shiru » Sat Aug 25, 2007 5:47 pm

TmEE co.(TM) wrote:real HW can handle only 70KHz for a short period of time, and I'm pretty sure that everything after 33KHz(if you wait before chip is ready, busy flag... this might interest Eke) won't make any difference (samples get missed I supose)
Maybe, I said somethere on this forum already. I assume that it can depends from YM2612 output DAC frequency itself. Some of YM2xxx chips has no internal DAC, and send output data to external DAC with fixed samplerate (YM3812 uses 49KHz, for example). I think, YM2xxx with built-in DAC, like YM2612, works same way, and DAC mode of channel 6 just replaces output from channel operators with value from #2A register, so it's not possible to get samplerate higher than built-in DAC has.

Post Reply