diff --git a/backends/playback/zsm/x16emu/ymglue.cpp b/backends/playback/zsm/x16emu/ymglue.cpp index 7858356..4eeec63 100644 --- a/backends/playback/zsm/x16emu/ymglue.cpp +++ b/backends/playback/zsm/x16emu/ymglue.cpp @@ -82,6 +82,14 @@ class ym2151_interface : public ymfm::ymfm_interface { bool irq() { return m_irq_status; } + void reset() { + m_chip.reset(); + m_timers[0] = 0; + m_timers[1] = 0; + m_busy_timer = 0; + m_irq_status = false; + opm_out.clear(); + } private: ymfm::ym2151 m_chip; @@ -114,6 +122,9 @@ extern "C" { void YM_write_reg(uint8_t reg, uint8_t val) { if (initialized) opm_iface.write(reg, val); } + void YM_reset() { + opm_iface.reset(); + } uint8_t YM_read_status() { if (initialized) diff --git a/backends/playback/zsm/x16emu/ymglue.h b/backends/playback/zsm/x16emu/ymglue.h index f3bd3b7..9a5597a 100644 --- a/backends/playback/zsm/x16emu/ymglue.h +++ b/backends/playback/zsm/x16emu/ymglue.h @@ -12,7 +12,7 @@ extern "C" { void YM_stream_update(int16_t* output, uint32_t numsamples); void YM_write_reg(uint8_t reg, uint8_t val); bool YM_irq(void); - + void YM_reset(); #ifdef __cplusplus } #endif diff --git a/backends/playback/zsm/zsm_backend.cpp b/backends/playback/zsm/zsm_backend.cpp index 77784d9..afce694 100644 --- a/backends/playback/zsm/zsm_backend.cpp +++ b/backends/playback/zsm/zsm_backend.cpp @@ -74,7 +74,9 @@ extern SDL_AudioSpec obtained; void ZsmBackend::switch_stream(int idx) { YM_Create(YM_FREQ); YM_init(YM_FREQ/64, 60); + YM_reset(); psg_reset(); + pcm_reset(); for (uint8_t i = 0; i < 16; i++) { psg_writereg(i * 4 + 2, 0); } diff --git a/backends/playback/zsm/zsm_backend.hpp b/backends/playback/zsm/zsm_backend.hpp index 438078b..43c17ca 100644 --- a/backends/playback/zsm/zsm_backend.hpp +++ b/backends/playback/zsm/zsm_backend.hpp @@ -68,6 +68,8 @@ class ZsmBackend : public PlaybackBackend { DynPtr out_buf; DynPtr ym_buf; DynPtr ym_resample_buf; + bool ym_recorded = false; + uint8_t ym_data[256]; uint32_t loop_rem; uint32_t pcm_data_offs; uint32_t loop;