BambooTracker / BambooTracker

YM2608 music tracker 🎍🎋
https://bambooTracker.github.io/BambooTracker/
GNU General Public License v2.0
483 stars 29 forks source link

Incorrect bit set for FM 3ch expanded mode #131

Closed rerrahkr closed 5 years ago

rerrahkr commented 5 years ago

@jpcima I find that the tone of FM 3ch is different from the tone of other channels when using Nuked OPN-Mod added at #94. fm3chex.zip

Changing some envelope parameters, I also notice that it will not update TL in 3ch, so there may be a mistake in writing to the register.

jpcima commented 5 years ago

I'm going to check it, feel free to assign me this one. Apologies for the delay noticing, my mail provider had some trouble during this week.

jpcima commented 5 years ago

Hi @nukeykt, I believe @rerrahkr has possibly discovered some very strange behavior in Nuked OPN2. Here are sound samples and VGM. nukedfm3ch.zip

(for a short introduction, Bambootracker is an OPNA tracker, and NukedOPN-Mod is a work over NukedOPN2 which added some OPNA features and raised channel clipping levels ; but, I have also checked in VGMPlay where Nuked is vanilla)

For comparison, we have YM2612 and YM2608 recordings of one note played.

  1. BambooTracker, MAME YM2608 (or VGMPlay, it's same)
  2. BambooTracker, Nuked(Mod) OPNA-ish
  3. VGMPlay, Nuked OPN2
  4. VGMPlay, Genesis Plus GX
  5. VGMPlay, Gens

We have (1) as comparison reference.
In VGMPlay, (4) and (5) output similar waveform (clipping of YM2612 aside), which suggest correct operation.
Nuked (2) and (3) generate completely different tone. (The OPN2 makes a ton of clipping also)

Capture du 2019-06-06 23-52-49

Capture du 2019-06-06 23-54-15

Do you have an idea about this?

nukeykt commented 5 years ago

VGM writes 0x80 to 0x27 register which enables CSM mode, so may be this is reason of weird sound? Neither MAME nor Gens emulate CSM mode accurately AFAIK. Also according to YM2608 datasheet YM2608 CSM mode is activated a bit differently: you need to write 0x40 to 0x27 register. Anyway i'm going to test this VGM on real MegaDrive to make sure later today

nukeykt commented 5 years ago

Hm, according to MAME YM2608 code CSM mode is enabled using 0x80 data just like YM2612, so i guess datasheet is wrong. Would be nice if someone could verify this on real YM2608 as well

nukeykt commented 5 years ago

Sample from real YM2612, aside from tonal difference it's matches to Nuked OPN2 sample. I guess your VGM sets YM2612 rate at 8 MHz? realym2612.zip

jpcima commented 5 years ago

Oh you are correct about CSM, it's an accidental CSM Enable. Thanks.

I came to the same conclusion as you looking at MAME and YM2608 manual. It's likely specification of register $27 has data bits 6-7 mixed.

The MAME source notes

    /* b7 = CSM MODE */
    /* b6 = 3 slot mode */

Judging from this, probably BT needs to set $40 not $80 for FM3ch.

@rerrahkr can you check behavior on real chip?

Sample from real YM2612, aside from tonal difference it's matches to Nuked OPN2 sample. I guess your VGM sets YM2612 rate at 8 MHz?

Yes BambooTracker uses clock defined as 3993600 * 2.

rerrahkr commented 5 years ago

wav.zip I checked on real YM2608 and found Nuked is right (real_0x80.wav). I'm sorry I didn't try it with real chips.

I also check the sounds in setting 0x40 to 0x27 register, and they sound the same. (mame_0x40.wav, nuked_0x40.wav, real_0x40.wav)

I did not know the datasheet is wrong, I will fix it soon. Thanks @nukeykt and @jpcima!

rerrahkr commented 5 years ago

I fixed it at 729c56cf86a5fc86853afb93cc8b0832a5987923. Closed.

jotego commented 4 years ago

Hi @rerrahkr , could you please attach the VGM file you to produce this effect to MiSTer issue https://github.com/MiSTer-devel/Genesis_MiSTer/issues/85, please?

rerrahkr commented 4 years ago

@jotego tests.zip - this contains 2 vgms for YM2612 that set 0x40 (actually 0x42) or 0x80 (0x82) to register 0x27.