YM2610: optimize oscilloscope fetch CPU usage

This commit is contained in:
tildearrow 2022-05-03 02:52:38 -05:00
parent b8a2c90b61
commit 4c9b172b50
4 changed files with 52 additions and 27 deletions

View file

@ -220,7 +220,7 @@ bool adpcm_a_channel::clock()
//-------------------------------------------------
template<int NumOutputs>
void adpcm_a_channel::output(ymfm_output<NumOutputs> &output) const
void adpcm_a_channel::output(ymfm_output<NumOutputs> &output)
{
// volume combines instrument and total levels
int vol = (m_regs.ch_instrument_level(m_choffs) ^ 0x1f) + (m_regs.total_level() ^ 0x3f);
@ -239,14 +239,18 @@ void adpcm_a_channel::output(ymfm_output<NumOutputs> &output) const
int16_t value = ((int16_t(m_accumulator << 4) * mul) >> shift) & ~3;
// apply to left/right as appropriate
if (NumOutputs == 1 || m_regs.ch_pan_left(m_choffs))
if (NumOutputs == 1 || m_regs.ch_pan_left(m_choffs)) {
output.data[0] += value;
if (NumOutputs > 1 && m_regs.ch_pan_right(m_choffs))
m_lastOut[0] = value;
}
if (NumOutputs > 1 && m_regs.ch_pan_right(m_choffs)) {
output.data[1] += value;
m_lastOut[1] = value;
}
}
template void adpcm_a_channel::output<1>(ymfm_output<1> &output) const;
template void adpcm_a_channel::output<2>(ymfm_output<2> &output) const;
template void adpcm_a_channel::output<1>(ymfm_output<1> &output);
template void adpcm_a_channel::output<2>(ymfm_output<2> &output);
//*********************************************************
@ -528,7 +532,7 @@ void adpcm_b_channel::clock()
//-------------------------------------------------
template<int NumOutputs>
void adpcm_b_channel::output(ymfm_output<NumOutputs> &output, uint32_t rshift) const
void adpcm_b_channel::output(ymfm_output<NumOutputs> &output, uint32_t rshift)
{
// mask out some channels for debug purposes
if ((debug::GLOBAL_ADPCM_B_CHANNEL_MASK & 1) == 0)
@ -541,10 +545,14 @@ void adpcm_b_channel::output(ymfm_output<NumOutputs> &output, uint32_t rshift) c
result = (result * int32_t(m_regs.level())) >> (8 + rshift);
// apply to left/right
if (NumOutputs == 1 || m_regs.pan_left())
if (NumOutputs == 1 || m_regs.pan_left()) {
m_lastOut[0] = result;
output.data[0] += result;
if (NumOutputs > 1 && m_regs.pan_right())
}
if (NumOutputs > 1 && m_regs.pan_right()) {
m_lastOut[1] = result;
output.data[1] += result;
}
}

View file

@ -146,7 +146,10 @@ public:
// return the computed output value, with panning applied
template<int NumOutputs>
void output(ymfm_output<NumOutputs> &output) const;
void output(ymfm_output<NumOutputs> &output);
// return the last output
int32_t get_last_out(int ch) { return m_lastOut[ch]; }
private:
// internal state
@ -158,6 +161,7 @@ private:
uint32_t m_curaddress; // current address
int32_t m_accumulator; // accumulator
int32_t m_step_index; // index in the stepping table
int32_t m_lastOut[2]; // last output
adpcm_a_registers &m_regs; // reference to registers
adpcm_a_engine &m_owner; // reference to our owner
};
@ -326,7 +330,7 @@ public:
// return the computed output value, with panning applied
template<int NumOutputs>
void output(ymfm_output<NumOutputs> &output, uint32_t rshift) const;
void output(ymfm_output<NumOutputs> &output, uint32_t rshift);
// return the status register
uint8_t status() const { return m_status; }
@ -337,6 +341,9 @@ public:
// handle special register writes
void write(uint32_t regnum, uint8_t value);
// return the last output
int32_t get_last_out(int ch) { return m_lastOut[ch]; }
private:
// helper - return the current address shift
uint32_t address_shift() const;
@ -361,6 +368,7 @@ private:
int32_t m_accumulator; // accumulator
int32_t m_prev_accum; // previous accumulator (for linear interp)
int32_t m_adpcm_step; // next forecast
int32_t m_lastOut[2]; // last output
adpcm_b_registers &m_regs; // reference to registers
adpcm_b_engine &m_owner; // reference to our owner
};
@ -387,6 +395,9 @@ public:
template<int NumOutputs>
void output(ymfm_output<NumOutputs> &output, uint32_t rshift);
// get last output
int32_t get_last_out(int ch) { return m_channel->get_last_out(ch); }
// read from the ADPCM-B registers
uint32_t read(uint32_t regnum) { return m_channel->read(regnum); }