From 0e0aab88de679927a1ecff980d88727cc5ebd1e6 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 18 Feb 2025 05:53:54 -0500 Subject: [PATCH] GA20: another optimization --- src/engine/platform/sound/ga20/iremga20.cpp | 8 +++++--- src/engine/platform/sound/ga20/iremga20.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/platform/sound/ga20/iremga20.cpp b/src/engine/platform/sound/ga20/iremga20.cpp index e9af15fa0..182d21e11 100644 --- a/src/engine/platform/sound/ga20/iremga20.cpp +++ b/src/engine/platform/sound/ga20/iremga20.cpp @@ -77,6 +77,7 @@ void iremga20_device::device_reset() { m_channel[i].rate = 0; m_channel[i].pos = 0; + m_channel[i].sample = 0; m_channel[i].counter = 0; m_channel[i].end = 0; m_channel[i].volume = 0; @@ -99,17 +100,17 @@ void iremga20_device::sound_stream_update(short** outputs, int len) channel_def &ch = m_channel[j]; if (ch.play) { - int sample = m_intf.read_byte(ch.pos); - if (sample == 0x00) // check for sample end marker + if (ch.sample == 0x00) // check for sample end marker ch.play = false; else { - sampleout = ch.mute ? 0 : (sample - 0x80) * (s32)ch.volume; + sampleout = ch.mute ? 0 : (ch.sample - 0x80) * (s32)ch.volume; ch.counter--; if (ch.counter <= ch.rate) { ch.pos++; ch.counter = 0x100; + ch.sample = m_intf.read_byte(ch.pos); } } } @@ -150,6 +151,7 @@ void iremga20_device::write(u32 offset, u8 data) m_channel[ch].pos = (m_regs[ch << 3 | 0] | m_regs[ch << 3 | 1] << 8) << 4; m_channel[ch].end = (m_regs[ch << 3 | 2] | m_regs[ch << 3 | 3] << 8) << 4; m_channel[ch].counter = 0x100; + m_channel[ch].sample = m_intf.read_byte(m_channel[ch].pos); } else m_channel[ch].play = false; diff --git a/src/engine/platform/sound/ga20/iremga20.h b/src/engine/platform/sound/ga20/iremga20.h index 1a27891ec..cfe181397 100644 --- a/src/engine/platform/sound/ga20/iremga20.h +++ b/src/engine/platform/sound/ga20/iremga20.h @@ -57,6 +57,7 @@ private: struct channel_def { channel_def() : + sample(0), rate(0), pos(0), counter(0), @@ -67,6 +68,7 @@ private: { } + int sample; u32 rate; u32 pos; u32 counter;