diff --git a/src/engine/platform/arcade.cpp b/src/engine/platform/arcade.cpp index 844fe67cf..f36b729a1 100644 --- a/src/engine/platform/arcade.cpp +++ b/src/engine/platform/arcade.cpp @@ -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; hgenerate(&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; diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index 27efab759..5325c982b 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -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; hdata[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; diff --git a/src/engine/platform/sound/ymfm/ymfm_fm.h b/src/engine/platform/sound/ymfm/ymfm_fm.h index 3239880e5..352ac9464 100644 --- a/src/engine/platform/sound/ymfm/ymfm_fm.h +++ b/src/engine/platform/sound/ymfm/ymfm_fm.h @@ -301,6 +301,7 @@ public: // simple getters for debugging fm_operator *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 *m_op[4]; // up to 4 operators RegisterType &m_regs; // direct reference to registers fm_engine_base &m_owner; // reference to the owning engine + mutable int32_t m_output[4]; }; diff --git a/src/engine/platform/sound/ymfm/ymfm_fm.ipp b/src/engine/platform/sound/ymfm/ymfm_fm.ipp index 84948aedb..4e851737a 100644 --- a/src/engine/platform/sound/ymfm/ymfm_fm.ipp +++ b/src/engine/platform/sound/ymfm/ymfm_fm.ipp @@ -808,7 +808,8 @@ fm_channel::fm_channel(fm_engine_base &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::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; } diff --git a/src/engine/platform/sound/ymfm/ymfm_opm.h b/src/engine/platform/sound/ymfm/ymfm_opm.h index ad657ac01..830b195e4 100644 --- a/src/engine/platform/sound/ymfm/ymfm_opm.h +++ b/src/engine/platform/sound/ymfm/ymfm_opm.h @@ -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 diff --git a/src/engine/platform/sound/ymfm/ymfm_opn.h b/src/engine/platform/sound/ymfm/ymfm_opn.h index f4136c731..1a2f55805 100644 --- a/src/engine/platform/sound/ymfm/ymfm_opn.h +++ b/src/engine/platform/sound/ymfm/ymfm_opn.h @@ -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); }