diff --git a/Src/CPU/68K/68K.h b/Src/CPU/68K/68K.h index 5395857..11c0802 100644 --- a/Src/CPU/68K/68K.h +++ b/Src/CPU/68K/68K.h @@ -32,6 +32,7 @@ #ifndef INCLUDED_68K_H #define INCLUDED_68K_H +#include #include "Types.h" #include "Musashi/m68k.h" #include "CPU/Bus.h" @@ -75,6 +76,7 @@ public: Bus = NULL; IRQAck = NULL; musashiCtx = new unsigned char[m68k_context_size()]; + memset(musashiCtx, 0, m68k_context_size()); // very important! garbage in context at reset can cause very strange bugs } ~SM68KCtx(void) diff --git a/Src/CPU/68K/Musashi/m68kcpu.c b/Src/CPU/68K/Musashi/m68kcpu.c index 670a06e..745321f 100644 --- a/Src/CPU/68K/Musashi/m68kcpu.c +++ b/Src/CPU/68K/Musashi/m68kcpu.c @@ -26,6 +26,10 @@ * * Permission was obtained from Karl Stenerud to apply the GPL license to this * code. + * + * NOTE: The internal CPU context is initialized to all zeros here. If setting + * an external context for the first time, make sure it is cleared first, + * otherwise interrupts may appear pending and other nasty problems. */ /* ======================================================================== */ diff --git a/Src/Model3/DSB.cpp b/Src/Model3/DSB.cpp index 7764fa8..5ed3fc2 100644 --- a/Src/Model3/DSB.cpp +++ b/Src/Model3/DSB.cpp @@ -1,4 +1,3 @@ -//TODO: DSB2 save states not working! //TODO: amp can print error messages -- change them to Supermodel error messages /** ** Supermodel @@ -950,6 +949,7 @@ void CDSB2::RunFrame(INT16 *audioL, INT16 *audioR) { #ifdef SUPERMODEL_SOUND M68KSetContext(&M68K); + //printf("DSB2 run frame PC=%06X\n", M68KGetPC()); // While FIFO not empty... while (fifoIdxR != fifoIdxW) @@ -995,6 +995,7 @@ void CDSB2::Reset(void) M68KSetContext(&M68K); M68KReset(); + printf("DSB2 PC=%06X\n", M68KGetPC()); M68KGetContext(&M68K); DebugLog("DSB2 Reset\n"); diff --git a/Src/Model3/SoundBoard.cpp b/Src/Model3/SoundBoard.cpp index 03001da..c16a72a 100644 --- a/Src/Model3/SoundBoard.cpp +++ b/Src/Model3/SoundBoard.cpp @@ -394,10 +394,15 @@ void CSoundBoard::Reset(void) UpdateROMBanks(); M68KSetContext(&M68K); M68KReset(); + printf("SBrd PC=%06X\n", M68KGetPC()); M68KGetContext(&M68K); if (NULL != DSB) DSB->Reset(); DebugLog("Sound Board Reset\n"); + printf("PC=%06X\n", M68KGetPC()); + M68KSetContext(&M68K); + M68KGetContext(&M68K); + printf("PC=%06X\n", M68KGetPC()); } void CSoundBoard::SaveState(CBlockFile *SaveState) @@ -453,7 +458,7 @@ void CSoundBoard::AttachDSB(CDSB *DSBPtr) #define OFFSET_RAM2 (0x100000) // 1 MB SCSP2 RAM #define OFFSET_AUDIO_LEFT (0x200000) // 1470 bytes (16 bits, 44.1 KHz, 1/60th second) left audio channel #define OFFSET_AUDIO_RIGHT (0x2005BE) // 1470 bytes right audio channel -#define MEMORY_POOL_SIZE (0x100000 + 0x100000 + 0x5be + 0x5be) +#define MEMORY_POOL_SIZE (0x100000+0x100000+0x5be+0x5be) BOOL CSoundBoard::Init(const UINT8 *soundROMPtr, const UINT8 *sampleROMPtr) { diff --git a/Src/Sound/SCSP.cpp b/Src/Sound/SCSP.cpp index fc78545..7b22eb6 100644 --- a/Src/Sound/SCSP.cpp +++ b/Src/Sound/SCSP.cpp @@ -1719,7 +1719,7 @@ void SCSP_DoMasterSamples(int nsamples) { int slice=12000000/(SysFPS*nsamples); // 68K cycles/sample static int lastdiff=0; - + for(int s=0;s