From 024e97ac9be03a4e596e15cc4c8cdafb4e24c6c4 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sat, 30 Jan 2021 10:31:31 +0000 Subject: [PATCH] MB-AY8913 fix so that no AY changes get dumped (#770) . Needed for read of AY8913 regs too, during built-in debugger stepping (mb-audit) --- source/AY8910.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/AY8910.cpp b/source/AY8910.cpp index 223d9d0d..5bf442f3 100644 --- a/source/AY8910.cpp +++ b/source/AY8910.cpp @@ -468,6 +468,7 @@ sound_write_buf_pstereo( libspectrum_signed_word * out, int c ) #define AY_ENV_HOLD 1 #define HZ_COMMON_DENOMINATOR 50 +#include "Log.h" void CAY8910::sound_ay_overlay( void ) { @@ -492,9 +493,24 @@ void CAY8910::sound_ay_overlay( void ) sfreq = sound_generator_freq / HZ_COMMON_DENOMINATOR; // cpufreq = machine_current->timings.processor_speed / HZ_COMMON_DENOMINATOR; cpufreq = (libspectrum_dword) (m_fCurrentCLK_AY8910 / HZ_COMMON_DENOMINATOR); // [TC] + int dbgCount=0; for( f = 0; f < ay_change_count; f++ ) + { ay_change[f].ofs = (USHORT) (( ay_change[f].tstates * sfreq ) / cpufreq); // [TC] Added cast + if (ay_change[f].ofs >= sound_generator_framesiz) // [TC] Ensure that all ay_change's get processed + { + ay_change[f].ofs = sound_generator_framesiz-1; // [TC] - as parent, sound_frame(), just dumps outstanding changes (ay_change_count=0) + dbgCount++; + } + } +#if defined(_DEBUG) && 1 + if (dbgCount) + { + LogOutput("ay_change: saved %d\n", dbgCount); // [TC] previously would've been dumped! + } +#endif + libspectrum_signed_word* pBuf1 = g_ppSoundBuffers[0]; libspectrum_signed_word* pBuf2 = g_ppSoundBuffers[1]; libspectrum_signed_word* pBuf3 = g_ppSoundBuffers[2];