From beed67aaa11b063fda4bfe0e1cf7b3131a5782c2 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 4 Feb 2023 17:22:16 -0500 Subject: [PATCH] BubSys: optimize --- .../vgsound_emu/src/k005289/k005289.cpp | 12 ++++++------ .../vgsound_emu/src/k005289/k005289.hpp | 4 ++-- src/engine/platform/bubsyswsg.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/extern/vgsound_emu-modified/vgsound_emu/src/k005289/k005289.cpp b/extern/vgsound_emu-modified/vgsound_emu/src/k005289/k005289.cpp index 464ce5bc9..13eb70838 100644 --- a/extern/vgsound_emu-modified/vgsound_emu/src/k005289/k005289.cpp +++ b/extern/vgsound_emu-modified/vgsound_emu/src/k005289/k005289.cpp @@ -8,11 +8,11 @@ #include "k005289.hpp" -void k005289_core::tick() +void k005289_core::tick(const unsigned int cycles) { for (timer_t &elem : m_timer) { - elem.tick(); + elem.tick(cycles); } } @@ -24,12 +24,12 @@ void k005289_core::reset() } } -void k005289_core::timer_t::tick() -{ - if (bitfield(++m_counter, 0, 12) == 0) +void k005289_core::timer_t::tick(const unsigned int cycles) { + m_counter-=cycles; + while (m_counter < 0) { m_addr = bitfield(m_addr + 1, 0, 5); - m_counter = m_freq; + m_counter += 0x1000-(m_freq&0xfff); } } diff --git a/extern/vgsound_emu-modified/vgsound_emu/src/k005289/k005289.hpp b/extern/vgsound_emu-modified/vgsound_emu/src/k005289/k005289.hpp index 2c2b0715a..981af8897 100644 --- a/extern/vgsound_emu-modified/vgsound_emu/src/k005289/k005289.hpp +++ b/extern/vgsound_emu-modified/vgsound_emu/src/k005289/k005289.hpp @@ -32,7 +32,7 @@ class k005289_core : public vgsound_emu_core // internal state void reset(); - void tick(); + void tick(const unsigned int cycles=1); // accessors // Replace current frequency to lastest loaded pitch @@ -63,7 +63,7 @@ class k005289_core : public vgsound_emu_core // internal state void reset(); - void tick(); + void tick(const unsigned int cycles); // accessors // TG1/2 pin diff --git a/src/engine/platform/bubsyswsg.cpp b/src/engine/platform/bubsyswsg.cpp index 782ee062e..94202de19 100644 --- a/src/engine/platform/bubsyswsg.cpp +++ b/src/engine/platform/bubsyswsg.cpp @@ -44,7 +44,7 @@ void DivPlatformBubSysWSG::acquire(short** buf, size_t len) { for (size_t h=0; h=64) writeOscBuf=0; + if (++writeOscBuf>=8) writeOscBuf=0; out<<=6; // scale output to 16 bit @@ -332,9 +332,9 @@ void DivPlatformBubSysWSG::notifyInsDeletion(void* ins) { void DivPlatformBubSysWSG::setFlags(const DivConfig& flags) { chipClock=COLOR_NTSC; CHECK_CUSTOM_CLOCK; - rate=chipClock; + rate=chipClock/8; for (int i=0; i<2; i++) { - oscBuf[i]->rate=rate/64; + oscBuf[i]->rate=rate/8; } }