Keep in mind that OPL has ADSR envelopes instead of fixed volume as in the psg/scc. You want to set A and D as fast as possible, and S as long as possible in order for it to work.
(I have done samples using FM in the past. Besides that ADSR problem, I was also using too few formants, which made the voice sound robotic).
do you have a sample code to play a tone on ym2413?
Just tried to find those sources, but no luck, lost to the tides of time.
I guess the next best thing is using openmsx to dump the FM registers during a basic command PLAY "C". This should have the setup for a single note.
From what I understand one should disable the envelope generator completely
http://www.smspower.org/maxim/Documents/YM2413ApplicationMan...
[Edit]
Himm... not possibile apparently...
I'm disassembling the msx-music bios to get how to play a tone...
Very frustrating...
Does anyone have some code able to detect and activate the YM2413 and play a tone with constant envelope ?
I'm too old and tired and I'm surely reinventing the wheel...
Does anyone have some code able to detect and activate the YM2413 and play a tone with constant envelope ?
You want to play a sine wave at a specific frequency and volume, right?
For this you first need to create a 'custom instrument'. This is done via registers R#00-R#07. For example these values give a good approximation of a sine:
mod={AM=0 PM=0 EG=0 KR=0 ML=01 KL=0 TL=63 WF=0 FB=0 AR=15 DR=15 SL=15 RR=15} car={AM=0 PM=0 EG=1 KR=0 ML=01 KL=0 WF=0 AR=15 DR=00 SL=00 RR=15} Registers R#00-R#07 = { 01 21 3F 00 FF F0 FF 0F }
Then you have to program registers R#10(+n), R#20(+n) and R#30(+n) (n being the channel number 0..8) to select the custom instrument and play a specific frequency and volume.
R#10 = fnum(7:0) R#20 = xx | xx | sustain(0) | keyon(0) | block(3:0) | fnum(8) R#30 = instrument(3:0) | volume(3:0)
instrument (4 bits) should be zero, selects the custom instrument.
volume (4 bits) selects the volume. 0 is maximum volume, every increment decreases volume by -3dB. So uses a logarithmic scale.
keyon single bit, should be set to '1' to enable the channel.
sustain single bit, has no effect in this particular case, but set to '0'.
fnum (9 bits) and block (3 bits) select the frequency according to this formula (valid for instruments with car.ML=1):
fnum * pow(2, block) = desired-freq * pow(2, 17) * 72 / 3579545
Thanks, if I understand your TCL, in order to have 5 tones, I have to set:
Registers R#00-R#07 = { 01 21 3F 00 FF F0 FF 0F }
R#10 = f-num (lower 8 bits) - channel 0
R#11 = f-num (lower 8 bits) - channel 1
R#12 = f-num (lower 8 bits) - channel 2
R#13 = f-num (lower 8 bits) - channel 3
R#14 = f-num (lower 8 bits) - channel 4
R#20 = 000000BBBF (octave -3 bits- f-num 9th bit) - channel 0
R#21 = 000000BBBF (octave -3 bits- f-num 9th bit) - channel 1
R#22 = 000000BBBF (octave -3 bits- f-num 9th bit) - channel 2
R#23 = 000000BBBF (octave -3 bits- f-num 9th bit) - channel 3
R#24 = 000000BBBF (octave -3 bits- f-num 9th bit) - channel 4
R#30 = volume (lower 4 bits) - channel 0
R#31 = volume (lower 4 bits) - channel 1
R#32 = volume (lower 4 bits) - channel 2
R#33 = volume (lower 4 bits) - channel 3
R#34 = volume (lower 4 bits) - channel 4
Mostly yes, you forgot the 'keyon' bit in registers R#20-R#24. So R#20 must be 0001BBBF.
I have modified the Salamander ROM and included the voices rutine inside the ROM.
Aply this patch on your Salamander ROM File:
Salamander Voices FRS IPS Patch
Include:
- Search any other SCC and use it for the voices. If it doesn't found other SCC the game works without voices.
- FRS patch included. This is an obligation!!!
Tell me if it works!!
Hey, thanks, just to say it works (openMSX). Though dyn. vsync makes the game so fast on a JP machine, I certainly don't think that's the way Konami would've intended it (but that's another story.. ;))
Anyway, a new version is out :)