per-channel oscilloscope, part 6

YM2612 and OPM (ymfm)!
This commit is contained in:
tildearrow 2022-05-01 03:12:32 -05:00
parent c0e9b48b5b
commit 415e490025
6 changed files with 39 additions and 5 deletions

View file

@ -181,6 +181,8 @@ void DivPlatformArcade::acquire_nuked(short* bufL, short* bufR, size_t start, si
void DivPlatformArcade::acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len) {
static int os[2];
ymfm::ym2151::fm_engine* fme=fm_ymfm->debug_engine();
for (size_t h=start; h<start+len; h++) {
os[0]=0; os[1]=0;
if (!writes.empty()) {
@ -196,6 +198,10 @@ void DivPlatformArcade::acquire_ymfm(short* bufL, short* bufR, size_t start, siz
fm_ymfm->generate(&out_ymfm);
for (int i=0; i<8; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(fme->debug_channel(i)->debug_output(0)+fme->debug_channel(i)->debug_output(1));
}
os[0]=out_ymfm.data[0];
if (os[0]<-32768) os[0]=-32768;
if (os[0]>32767) os[0]=32767;

View file

@ -163,6 +163,8 @@ void DivPlatformGenesis::acquire_nuked(short* bufL, short* bufR, size_t start, s
void DivPlatformGenesis::acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len) {
static int os[2];
ymfm::ym2612::fm_engine* fme=fm_ymfm->debug_engine();
for (size_t h=start; h<start+len; h++) {
if (!dacReady) {
dacDelay+=32000;
@ -218,6 +220,10 @@ void DivPlatformGenesis::acquire_ymfm(short* bufL, short* bufR, size_t start, si
os[1]=out_ymfm.data[1];
//OPN2_Write(&fm,0,0);
for (int i=0; i<6; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(fme->debug_channel(i)->debug_output(0)+fme->debug_channel(i)->debug_output(1))<<6;
}
if (os[0]<-32768) os[0]=-32768;
if (os[0]>32767) os[0]=32767;

View file

@ -301,6 +301,7 @@ public:
// simple getters for debugging
fm_operator<RegisterType> *debug_operator(uint32_t index) const { return m_op[index]; }
int32_t debug_output(uint32_t index) const { return m_output[index]; }
private:
// helper to add values to the outputs based on channel enables
@ -313,14 +314,22 @@ private:
constexpr int out2_index = 2 % RegisterType::OUTPUTS;
constexpr int out3_index = 3 % RegisterType::OUTPUTS;
if (RegisterType::OUTPUTS == 1 || m_regs.ch_output_0(choffs))
if (RegisterType::OUTPUTS == 1 || m_regs.ch_output_0(choffs)) {
m_output[out0_index]=value;
output.data[out0_index] += value;
if (RegisterType::OUTPUTS >= 2 && m_regs.ch_output_1(choffs))
}
if (RegisterType::OUTPUTS >= 2 && m_regs.ch_output_1(choffs)) {
m_output[out1_index]=value;
output.data[out1_index] += value;
if (RegisterType::OUTPUTS >= 3 && m_regs.ch_output_2(choffs))
}
if (RegisterType::OUTPUTS >= 3 && m_regs.ch_output_2(choffs)) {
m_output[out2_index]=value;
output.data[out2_index] += value;
if (RegisterType::OUTPUTS >= 4 && m_regs.ch_output_3(choffs))
}
if (RegisterType::OUTPUTS >= 4 && m_regs.ch_output_3(choffs)) {
m_output[out3_index]=value;
output.data[out3_index] += value;
}
}
// internal state
@ -330,6 +339,7 @@ private:
fm_operator<RegisterType> *m_op[4]; // up to 4 operators
RegisterType &m_regs; // direct reference to registers
fm_engine_base<RegisterType> &m_owner; // reference to the owning engine
mutable int32_t m_output[4];
};

View file

@ -808,7 +808,8 @@ fm_channel<RegisterType>::fm_channel(fm_engine_base<RegisterType> &owner, uint32
m_feedback_in(0),
m_op{ nullptr, nullptr, nullptr, nullptr },
m_regs(owner.regs()),
m_owner(owner)
m_owner(owner),
m_output{ 0, 0, 0, 0 }
{
}
@ -823,6 +824,11 @@ void fm_channel<RegisterType>::reset()
// reset our data
m_feedback[0] = m_feedback[1] = 0;
m_feedback_in = 0;
m_output[0] = 0;
m_output[1] = 0;
m_output[2] = 0;
m_output[3] = 0;
}

View file

@ -281,6 +281,9 @@ public:
// generate one sample of sound
void generate(output_data *output, uint32_t numsamples = 1);
// get the engine
fm_engine* debug_engine() { return &m_fm; }
protected:
// variants
enum opm_variant

View file

@ -761,6 +761,9 @@ public:
// generate one sample of sound
void generate(output_data *output, uint32_t numsamples = 1);
// get the engine
fm_engine* debug_engine() { return &m_fm; }
protected:
// simulate the DAC discontinuity
constexpr int32_t dac_discontinuity(int32_t value) const { return (value < 0) ? (value - 2) : (value + 3); }