diff --git a/src/devices/sound/ymfm.cpp b/src/devices/sound/ymfm.cpp index 7c32b1a2eab..9f84ef0dd75 100644 --- a/src/devices/sound/ymfm.cpp +++ b/src/devices/sound/ymfm.cpp @@ -1054,7 +1054,8 @@ void ymopm_registers::log_keyon(u32 choffs, u32 opoffs) template ymopn_registers_base::ymopn_registers_base() : m_lfo_counter(0), - m_lfo_am(0) + m_lfo_am(0), + m_multi_freq(0) { // create the waveforms for (int index = 0; index < WAVEFORM_LENGTH; index++) @@ -1073,6 +1074,7 @@ void ymopn_registers_base::save(device_t &device) { device.save_item(YMFM_NAME(m_lfo_counter)); device.save_item(YMFM_NAME(m_lfo_am)); + device.save_item(YMFM_NAME(m_multi_freq)); } device.save_item(YMFM_NAME(m_regdata)); } @@ -1177,11 +1179,22 @@ bool ymopn_registers_base::write(u16 index, u8 data, u32 &channel, u32 & // handle writes to the key on index if (index == 0x28) { + // channel in low 2 bits; channel 3 is not valid channel = BIT(data, 0, 2); if (channel == 3) return false; + + // upper channels for OPNA if (IsOpnA) channel += BIT(data, 2, 1) * 3; + + // when channel 2 key on hits, latch the multifrequency state + // megadriv sor2 flips the multi_freq bit on and off during playback + // of its sounds, specifically the punch sound + if (channel == 2) + m_multi_freq = multi_freq(); + + // operator mask is the top 4 bits opmask = BIT(data, 4, 4); return true; } @@ -1276,7 +1289,7 @@ void ymopn_registers_base::cache_operator_data(u32 choffs, u32 opoffs, y // if multi-frequency mode is enabled and this is channel 2, // fetch one of the special frequencies - if (multi_freq() && choffs == 2) + if (m_multi_freq && choffs == 2) { if (opoffs == 2) block_freq = cache.block_freq = multi_block_freq(1); @@ -1388,7 +1401,7 @@ void ymopn_registers_base::log_keyon(u32 choffs, u32 opoffs) u32 opnum = (opoffs & 15) - ((opoffs & 15) / 4) + 12 * BIT(opoffs, 8); u32 block_freq = ch_block_freq(choffs); - if (multi_freq() && choffs == 2) + if (m_multi_freq && choffs == 2) { if (opoffs == 2) block_freq = multi_block_freq(1); @@ -1427,7 +1440,7 @@ void ymopn_registers_base::log_keyon(u32 choffs, u32 opoffs) LOG(" pm=%d", ch_lfo_pm_sens(choffs)); if (am || pm) LOG(" lfo=%02X", lfo_rate()); - if (multi_freq() && choffs == 2) + if (m_multi_freq && choffs == 2) LOG(" multi=1"); } diff --git a/src/devices/sound/ymfm.h b/src/devices/sound/ymfm.h index 8ab0ddc9d03..6fe1ff96eb3 100644 --- a/src/devices/sound/ymfm.h +++ b/src/devices/sound/ymfm.h @@ -577,7 +577,7 @@ public: u32 lfo_rate() const { return IsOpnA ? byte(0x22, 0, 3) : 0; } u32 timer_a_value() const { return word(0x24, 0, 8, 0x25, 0, 2); } u32 timer_b_value() const { return byte(0x26, 0, 8); } - u32 csm() const { return (byte(0x27, 6, 2) == 2); } + u32 csm() const { return byte(0x27, 7, 1); } u32 multi_freq() const { return (byte(0x27, 6, 2) != 0); } u32 reset_timer_b() const { return byte(0x27, 5, 1); } u32 reset_timer_a() const { return byte(0x27, 4, 1); } @@ -629,6 +629,7 @@ protected: // internal state u32 m_lfo_counter; // LFO counter u8 m_lfo_am; // current LFO AM value + u8 m_multi_freq; // channel 2 is currently multi-frequency u8 m_regdata[REGISTERS]; // register data u16 m_waveform[WAVEFORMS][WAVEFORM_LENGTH]; // waveforms };