NDS: prepare for optimization

This commit is contained in:
tildearrow 2025-03-08 04:37:42 -05:00
parent ab1759f09b
commit d8f66523b6
2 changed files with 16 additions and 0 deletions

View file

@ -54,6 +54,15 @@ namespace nds_sound_emu
m_routput = 0;
}
s32 nds_sound_t::predict() {
s32 ret=INT32_MAX;
for (u8 i = 0; i < 16; i++) {
const s32 next=m_channel[i].predict();
if (next<ret) ret=next;
}
return ret;
}
void nds_sound_t::tick(s32 cycle)
{
m_loutput = m_routput = (m_bias & 0x3ff);
@ -328,6 +337,11 @@ namespace nds_sound_emu
}
}
s32 nds_sound_t::channel_t::predict() {
if (!m_playing) return INT32_MAX;
return m_counter-m_freq;
}
void nds_sound_t::channel_t::fetch()
{
if (m_playing)

View file

@ -121,6 +121,7 @@ namespace nds_sound_emu
void reset();
void tick(s32 cycle);
s32 predict();
// host accesses
u32 read32(u32 addr);
@ -205,6 +206,7 @@ namespace nds_sound_emu
void write(u32 offset, u32 data, u32 mask = ~0);
void update(s32 cycle);
s32 predict();
// getters
// control word