From 1266c97eb537fb04243618717f3ce08a69415a8d Mon Sep 17 00:00:00 2001 From: AJR Date: Thu, 20 Feb 2020 23:29:26 -0500 Subject: epg3231: Add speech timer interrupt (nw) --- src/devices/cpu/rii/riscii.cpp | 26 +++++++++++++++++++++++++- src/devices/cpu/rii/riscii.h | 3 +++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/devices/cpu/rii/riscii.cpp b/src/devices/cpu/rii/riscii.cpp index 1932ee6afb9..74f58fb732c 100644 --- a/src/devices/cpu/rii/riscii.cpp +++ b/src/devices/cpu/rii/riscii.cpp @@ -206,6 +206,8 @@ void riscii_series_device::device_start() set_icountptr(m_icount); + m_speech_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(riscii_series_device::speech_timer), this)); + state_add(RII_PC, "PC", [this]() { return m_pc; }, [this](u32 pc) { debug_set_pc(pc); }).mask(m_pcmask); state_add(STATE_GENPC, "GENPC", [this]() { return m_pc; }, [this](u32 pc) { debug_set_pc(pc); }).mask(m_pcmask).noshow(); state_add(STATE_GENPCBASE, "CURPC", m_ppc).mask(m_pcmask).noshow(); @@ -357,6 +359,7 @@ void riscii_series_device::device_reset() m_sphtcon = 0x00; m_sphtrl = 0x00; m_vocon = 0x07; + m_speech_timer->adjust(attotime::never); } void riscii_series_device::debug_set_pc(u32 pc) @@ -898,6 +901,21 @@ void riscii_series_device::sfcr_w(u8 data) // MUSIC/SPEECH SYNTHESIZER //************************************************************************** +void riscii_series_device::spht_reload() +{ + unsigned sphtpsr_shift = ((m_sphtcon & 0xc0) >> 5) + 1; + m_speech_timer->adjust(clocks_to_attotime(((u16(m_sphtcon & 0x07) << 8 | m_sphtrl) + 1) << sphtpsr_shift)); +} + +TIMER_CALLBACK_MEMBER(riscii_series_device::speech_timer) +{ + // Speech timer interrupt + if (BIT(m_sphtcon, 4)) + m_sphtcon |= 0x20; + + spht_reload(); +} + u8 riscii_series_device::addl_r() { return m_add[BIT(m_sfcr, 2) ? 3 : m_sfcr & 0x03] & 0x0000ff; @@ -958,7 +976,13 @@ u8 riscii_series_device::mtcon_sphtcon_r() void riscii_series_device::mtcon_sphtcon_w(u8 data) { if (BIT(m_sfcr, 2)) - m_sphtcon = data; + { + bool old_data = std::exchange(m_sphtcon, data); + if (BIT(data, 3) && !BIT(old_data, 3)) + spht_reload(); + else if (!BIT(data, 3)) + m_speech_timer->adjust(attotime::never); + } else m_mtcon[m_sfcr & 0x03] = data; } diff --git a/src/devices/cpu/rii/riscii.h b/src/devices/cpu/rii/riscii.h index 3105f67649b..4613a9680c3 100644 --- a/src/devices/cpu/rii/riscii.h +++ b/src/devices/cpu/rii/riscii.h @@ -193,6 +193,8 @@ protected: u8 tr2c_r(); u8 sfcr_r(); void sfcr_w(u8 data); + void spht_reload(); + TIMER_CALLBACK_MEMBER(speech_timer); u8 addl_r(); void addl_w(u8 data); u8 addm_r(); @@ -354,6 +356,7 @@ private: u8 m_sphtcon; u8 m_sphtrl; u8 m_vocon; + emu_timer *m_speech_timer; // execution sequencing s32 m_icount; -- cgit v1.2.3