From 3b7f2683cf2466ee28719ab9afbc34bd844aaa8c Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 4 Jul 2025 14:39:09 +0600 Subject: [PATCH 1/2] Backport https://github.com/aaronsgiles/ymfm/pull/66 --- src/sound/ymfm/ymfm_opl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sound/ymfm/ymfm_opl.h b/src/sound/ymfm/ymfm_opl.h index 843e5b274..71b098e97 100644 --- a/src/sound/ymfm/ymfm_opl.h +++ b/src/sound/ymfm/ymfm_opl.h @@ -52,7 +52,7 @@ namespace ymfm // // System-wide registers: // 01 xxxxxxxx Test register -// --x----- Enable OPL compatibility mode [OPL2 only] (1 = enable) +// --x----- Enable OPL compatibility mode [OPL2 only] (0 = enable) // 02 xxxxxxxx Timer A value (4 * OPN) // 03 xxxxxxxx Timer B value // 04 x------- RST @@ -243,7 +243,7 @@ public: uint32_t op_decay_rate(uint32_t opoffs) const { return byte(0x60, 0, 4, opoffs); } uint32_t op_sustain_level(uint32_t opoffs) const { return byte(0x80, 4, 4, opoffs); } uint32_t op_release_rate(uint32_t opoffs) const { return byte(0x80, 0, 4, opoffs); } - uint32_t op_waveform(uint32_t opoffs) const { return IsOpl2Plus ? byte(0xe0, 0, newflag() ? 3 : 2, opoffs) : 0; } + uint32_t op_waveform(uint32_t opoffs) const { return waveform_enable() ? byte(0xe0, 0, newflag() ? 3 : 2, opoffs) : 0; } protected: // return a bitfield extracted from a byte From b44b7ff81a07f35311af3c27a25b98d14ff53c30 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Fri, 4 Jul 2025 14:39:22 +0600 Subject: [PATCH 2/2] Backport https://github.com/aaronsgiles/ymfm/pull/67 --- src/sound/ymfm/ymfm_opn.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/sound/ymfm/ymfm_opn.cpp b/src/sound/ymfm/ymfm_opn.cpp index 16ca3416c..60469e1c0 100644 --- a/src/sound/ymfm/ymfm_opn.cpp +++ b/src/sound/ymfm/ymfm_opn.cpp @@ -155,14 +155,13 @@ bool opn_registers_base::write(uint16_t index, uint8_t data, uint32_t &c // writes to the upper half just latch (only low 6 bits matter) if (bitfield(index, 2)) - m_regdata[latchindex] = data | 0x80; + m_regdata[latchindex] = data & 0x3f; - // writes to the lower half only commit if the latch is there - else if (bitfield(m_regdata[latchindex], 7)) + // writes to the lower half also apply said latch + else { m_regdata[index] = data; - m_regdata[index | 4] = m_regdata[latchindex] & 0x3f; - m_regdata[latchindex] = 0; + m_regdata[index | 4] = m_regdata[latchindex]; } return false; }