aaronsgiles / ymfm

BSD-licensed Yamaha FM sound cores (OPM, OPN, OPL, and others)
BSD 3-Clause "New" or "Revised" License
259 stars 40 forks source link

OPZ can not handle key on/off properly #20

Open 110-kenichi opened 2 years ago

110-kenichi commented 2 years ago

The following code in the opz_registers::write(uint16_t, uint8_t, uint32_t, uint32_t) is not correct.

// handle writes to the key on index
if ((index & 0xf8) == 0x20 && bitfield(index, 0, 3) == bitfield(m_regdata[0x08], 0, 3))

OPZ does not see the 0x08 register for key on/off . So. change it like the following.

// handle writes to the key on index
if ((index & 0xf8) == 0x20)
110-kenichi commented 2 years ago

Sorry, this info is not correct.

The following URL information is not perfect. http://sr4.sakura.ne.jp/fmsound/opz.html

・Panpot, Key on/off register is same as OPM/OPP. ・Ch volume register(#0 -#7) does not exist on OPZ.

aaronsgiles commented 2 years ago

What is the evidence for this change? The document referenced is not correct.

The current implementation is based on actual behavior of what the TX-81Z writes in emulation. Until I see strong evidence of different behavior that is still compatible with the way the TX-81Z programs the chip, I'm reluctant to make any changes here.

110-kenichi commented 2 years ago

We do not have an application manual of YM2414.

So, I've contact FITOM author ”madscient” to check correctly implementing of the OPZ.

Do you know FITOM project? https://sites.google.com/site/fitomproject/

He said that "I checked the registers one by one and created a FITOM. My implementing is correct."

See this thread. https://twitter.com/SNDR_SNDL/status/1445013048628944899

I think the behavior of the TX-81Z is due to the software sound driver.

110-kenichi commented 2 years ago

He said that this source contains OPZ driver that is derived from OPM and the driver can drive OPZ properly.

https://github.com/madscient/FITOMApp/blob/primary/FITOMApp/OPM.cpp

110-kenichi commented 2 years ago

He created a document about YM2414 (Tentative ver)

https://sites.google.com/site/undocumentedsoundchips/yamaha/ym2414

110-kenichi commented 2 years ago

My friend replaced a chip from YM2151 to YM2414. https://twitter.com/sdhizumi/status/1453924274989793280

YM2414 can output LR ch properly by YM2151 driver except MONO ch.

aaronsgiles commented 2 years ago

If that is a legitimate (true) YM2414, then it is possible that key on/off can also be triggered like a YM2151. I will be interested to see if the YM2414 shown works in the TX-81Z.

The firmware of the TX-81Z uses the documented sequence in my code to send key on/off, and not the YM2151 way. If this is true, then ymfm will need to be updated to support both ways.

110-kenichi commented 2 years ago

I see. Thanks.

110-kenichi commented 2 years ago

FYI: Here is an Output Level algorithm of TX81Z(not YM2414) sound driver.

https://nornand.hatenablog.com/entry/2020/11/21/201911