SCC: massive optimization

This commit is contained in:
tildearrow 2023-01-29 17:17:15 -05:00
parent 19e3019e4f
commit a08c343f6d
4 changed files with 16 additions and 14 deletions

View file

@ -1,5 +1,9 @@
# Konami SCC # Konami SCC
## modified
the emulation core has been modified for optimization.
## Summary ## Summary
- 5 voice wavetable - 5 voice wavetable

View file

@ -10,17 +10,17 @@
#include "scc.hpp" #include "scc.hpp"
// shared SCC features // shared SCC features
void scc_core::tick() void scc_core::tick(const int cycles)
{ {
m_out = 0; m_out = 0;
for (auto &elem : m_voice) for (auto &elem : m_voice)
{ {
elem.tick(); elem.tick(cycles);
m_out += elem.out(); m_out += elem.out();
} }
} }
void scc_core::voice_t::tick() void scc_core::voice_t::tick(const int cycles)
{ {
if (m_pitch >= 9) // or voice is halted if (m_pitch >= 9) // or voice is halted
{ {
@ -28,23 +28,23 @@ void scc_core::voice_t::tick()
const u16 temp = m_counter; const u16 temp = m_counter;
if (m_host.m_test.freq_4bit()) // 4 bit frequency mode if (m_host.m_test.freq_4bit()) // 4 bit frequency mode
{ {
m_counter = (m_counter & ~0x0ff) | (bitfield(bitfield(m_counter, 0, 8) - 1, 0, 8) << 0); m_counter = (m_counter & ~0x0ff) | (bitfield(bitfield(m_counter, 0, 8) - cycles, 0, 8) << 0);
m_counter = (m_counter & ~0xf00) | (bitfield(bitfield(m_counter, 8, 4) - 1, 0, 4) << 8); m_counter = (m_counter & ~0xf00) | (bitfield(bitfield(m_counter, 8, 4) - cycles, 0, 4) << 8);
} }
else else
{ {
m_counter = bitfield(m_counter - 1, 0, 12); m_counter = bitfield(m_counter - cycles, 0, 12);
} }
// handle counter carry // handle counter carry
const bool carry = m_host.m_test.freq_8bit() const bool carry = (temp<cycles) || (m_host.m_test.freq_8bit()
? (bitfield(temp, 0, 8) == 0) ? (bitfield(temp, 0, 8) == 0)
: (m_host.m_test.freq_4bit() ? (bitfield(temp, 8, 4) == 0) : (m_host.m_test.freq_4bit() ? (bitfield(temp, 8, 4) == 0)
: (bitfield(temp, 0, 12) == 0)); : (bitfield(temp, 0, 12) == 0)));
if (carry) if (carry)
{ {
m_addr = bitfield(m_addr + 1, 0, 5); m_addr = bitfield(m_addr + 1, 0, 5);
m_counter = m_pitch; m_counter = m_pitch - ((temp<cycles)?(cycles-temp-1):0);
} }
} }
// get output // get output

View file

@ -41,7 +41,7 @@ class scc_core : public vgsound_emu_core
// internal state // internal state
void reset(); void reset();
void tick(); void tick(const int cycles=1);
// accessors // accessors
inline void reset_addr() { m_addr = 0; } inline void reset_addr() { m_addr = 0; }
@ -151,7 +151,7 @@ class scc_core : public vgsound_emu_core
// internal state // internal state
virtual void reset(); virtual void reset();
void tick(); void tick(const int cycles=1);
// getters // getters
inline s32 out() { return m_out; } // output to DA0...DA10 pin inline s32 out() { return m_out; } // output to DA0...DA10 pin

View file

@ -82,9 +82,7 @@ const char** DivPlatformSCC::getRegisterSheet() {
void DivPlatformSCC::acquire(short** buf, size_t len) { void DivPlatformSCC::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) { for (size_t h=0; h<len; h++) {
for (int i=0; i<16; i++) { scc->tick(16);
scc->tick();
}
short out=(short)scc->out()<<5; short out=(short)scc->out()<<5;
buf[0][h]=out; buf[0][h]=out;