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
## modified
the emulation core has been modified for optimization.
## Summary
- 5 voice wavetable

View File

@ -10,17 +10,17 @@
#include "scc.hpp"
// shared SCC features
void scc_core::tick()
void scc_core::tick(const int cycles)
{
m_out = 0;
for (auto &elem : m_voice)
{
elem.tick();
elem.tick(cycles);
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
{
@ -28,23 +28,23 @@ void scc_core::voice_t::tick()
const u16 temp = m_counter;
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 & ~0xf00) | (bitfield(bitfield(m_counter, 8, 4) - 1, 0, 4) << 8);
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) - cycles, 0, 4) << 8);
}
else
{
m_counter = bitfield(m_counter - 1, 0, 12);
m_counter = bitfield(m_counter - cycles, 0, 12);
}
// 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)
: (m_host.m_test.freq_4bit() ? (bitfield(temp, 8, 4) == 0)
: (bitfield(temp, 0, 12) == 0));
: (bitfield(temp, 0, 12) == 0)));
if (carry)
{
m_addr = bitfield(m_addr + 1, 0, 5);
m_counter = m_pitch;
m_counter = m_pitch - ((temp<cycles)?(cycles-temp-1):0);
}
}
// get output

View File

@ -41,7 +41,7 @@ class scc_core : public vgsound_emu_core
// internal state
void reset();
void tick();
void tick(const int cycles=1);
// accessors
inline void reset_addr() { m_addr = 0; }
@ -151,7 +151,7 @@ class scc_core : public vgsound_emu_core
// internal state
virtual void reset();
void tick();
void tick(const int cycles=1);
// getters
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) {
for (size_t h=0; h<len; h++) {
for (int i=0; i<16; i++) {
scc->tick();
}
scc->tick(16);
short out=(short)scc->out()<<5;
buf[0][h]=out;