From ad8165d99c2debc5217120cba324c127bccfb8e7 Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 18 Feb 2018 16:37:06 -0500 Subject: ym2203: Handle interrupt output as instant timer to prevent synchronization glitches --- src/devices/sound/2203intf.cpp | 17 +++++++++++------ src/devices/sound/2203intf.h | 9 ++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/devices/sound/2203intf.cpp b/src/devices/sound/2203intf.cpp index 3307e8b798d..8b415d08b5d 100644 --- a/src/devices/sound/2203intf.cpp +++ b/src/devices/sound/2203intf.cpp @@ -15,8 +15,7 @@ const ssg_callbacks ym2203_device::psgintf = /* IRQ Handler */ void ym2203_device::irq_handler(int irq) { - if (!m_irq_handler.isnull()) - m_irq_handler(irq); + m_timer[2]->adjust(attotime::zero, irq); } /* Timer overflow callback from timer.c */ @@ -24,13 +23,18 @@ void ym2203_device::device_timer(emu_timer &timer, device_timer_id id, int param { switch(id) { - case 0: + case TIMER_A: ym2203_timer_over(m_chip,0); break; - case 1: + case TIMER_B: ym2203_timer_over(m_chip,1); break; + + case TIMER_IRQ_SYNC: + if (!m_irq_handler.isnull()) + m_irq_handler(param); + break; } } @@ -77,8 +81,9 @@ void ym2203_device::device_start() m_irq_handler.resolve(); /* Timer Handler set */ - m_timer[0] = timer_alloc(0); - m_timer[1] = timer_alloc(1); + m_timer[0] = timer_alloc(TIMER_A); + m_timer[1] = timer_alloc(TIMER_B); + m_timer[2] = timer_alloc(TIMER_IRQ_SYNC); /* stream system initialize */ calculate_rates(); diff --git a/src/devices/sound/2203intf.h b/src/devices/sound/2203intf.h index af1a2f622a9..d06de139d8b 100644 --- a/src/devices/sound/2203intf.h +++ b/src/devices/sound/2203intf.h @@ -45,6 +45,13 @@ protected: void stream_generate(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); private: + enum + { + TIMER_A, + TIMER_B, + TIMER_IRQ_SYNC + }; + void irq_handler(int irq); void timer_handler(int c, int count, int clock); void update_request() { m_stream->update(); } @@ -56,7 +63,7 @@ private: // internal state sound_stream * m_stream; - emu_timer * m_timer[2]; + emu_timer * m_timer[3]; void * m_chip; devcb_write_line m_irq_handler; -- cgit v1.2.3