diff --git a/common/copy.hpp b/common/copy.hpp index 4df90fc..d9c1274 100644 --- a/common/copy.hpp +++ b/common/copy.hpp @@ -8,3 +8,12 @@ inline void copy(T * dst, const T * src, int32_t n) noexcept n -= (sizeof (T)); } } + +template +inline void fill(T * dst, const T src, int32_t n) noexcept +{ + while (n > 0) { + *dst++ = src; + n -= (sizeof (T)); + } +} diff --git a/scsp/sound_cpu__interrupt.cpp b/scsp/sound_cpu__interrupt.cpp index 1cdc707..bccae66 100644 --- a/scsp/sound_cpu__interrupt.cpp +++ b/scsp/sound_cpu__interrupt.cpp @@ -15,23 +15,26 @@ void main() The document suggests that Sound RAM is (somewhat) preserved during SNDOFF. */ - + while ((smpc.reg.SF & 1) != 0); smpc.reg.SF = 1; smpc.reg.COMREG = COMREG__SNDOFF; while (smpc.reg.oreg[31] != OREG31__SNDOFF); scsp.reg.ctrl.MIXER = MIXER__MEM4MB; - + + reg32 * dsp_steps = reinterpret_cast(&(scsp.reg.dsp.STEP[0].MPRO[0])); + fill(dsp_steps, 0, (sizeof (scsp.reg.dsp.STEP))); + uint32_t * m68k_main_start = reinterpret_cast(&_m68k_start); uint32_t m68k_main_size = reinterpret_cast(&_m68k_size); copy(&scsp.ram.u32[0], m68k_main_start, m68k_main_size); - + while ((smpc.reg.SF & 1) != 0); smpc.reg.SF = 1; smpc.reg.COMREG = COMREG__SNDON; while (smpc.reg.oreg[31] != OREG31__SNDON); - + // do nothing while the sound CPU manipulates the SCSP }