scsp: zeroize dsp

The Saturn BIOS does not (un)initialize the DSP. Without zeroizing the DSP
program, the SCSP DSP appears to have a program that continuously writes to
0x30000 through 0x3ffff in sound RAM, which has the effect of destroying any
samples stored there.
This commit is contained in:
Zack Buhman 2023-05-19 14:52:15 -07:00
parent b9e6296058
commit 3358d95704
2 changed files with 16 additions and 4 deletions

View File

@ -8,3 +8,12 @@ inline void copy(T * dst, const T * src, int32_t n) noexcept
n -= (sizeof (T)); n -= (sizeof (T));
} }
} }
template <typename T>
inline void fill(T * dst, const T src, int32_t n) noexcept
{
while (n > 0) {
*dst++ = src;
n -= (sizeof (T));
}
}

View File

@ -15,23 +15,26 @@ void main()
The document suggests that Sound RAM is (somewhat) preserved The document suggests that Sound RAM is (somewhat) preserved
during SNDOFF. during SNDOFF.
*/ */
while ((smpc.reg.SF & 1) != 0); while ((smpc.reg.SF & 1) != 0);
smpc.reg.SF = 1; smpc.reg.SF = 1;
smpc.reg.COMREG = COMREG__SNDOFF; smpc.reg.COMREG = COMREG__SNDOFF;
while (smpc.reg.oreg[31] != OREG31__SNDOFF); while (smpc.reg.oreg[31] != OREG31__SNDOFF);
scsp.reg.ctrl.MIXER = MIXER__MEM4MB; scsp.reg.ctrl.MIXER = MIXER__MEM4MB;
reg32 * dsp_steps = reinterpret_cast<reg32*>(&(scsp.reg.dsp.STEP[0].MPRO[0]));
fill<reg32>(dsp_steps, 0, (sizeof (scsp.reg.dsp.STEP)));
uint32_t * m68k_main_start = reinterpret_cast<uint32_t*>(&_m68k_start); uint32_t * m68k_main_start = reinterpret_cast<uint32_t*>(&_m68k_start);
uint32_t m68k_main_size = reinterpret_cast<uint32_t>(&_m68k_size); uint32_t m68k_main_size = reinterpret_cast<uint32_t>(&_m68k_size);
copy<uint32_t>(&scsp.ram.u32[0], m68k_main_start, m68k_main_size); copy<uint32_t>(&scsp.ram.u32[0], m68k_main_start, m68k_main_size);
while ((smpc.reg.SF & 1) != 0); while ((smpc.reg.SF & 1) != 0);
smpc.reg.SF = 1; smpc.reg.SF = 1;
smpc.reg.COMREG = COMREG__SNDON; smpc.reg.COMREG = COMREG__SNDON;
while (smpc.reg.oreg[31] != OREG31__SNDON); while (smpc.reg.oreg[31] != OREG31__SNDON);
// do nothing while the sound CPU manipulates the SCSP // do nothing while the sound CPU manipulates the SCSP
} }