diff --git a/src/sound.cpp b/src/sound.cpp index 1da02c92..24541c82 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -31,6 +31,7 @@ #include "filter.h" #include "state.h" #include "wave.h" +#include "debug.h" static uint32 wlookup1[32]; static uint32 wlookup2[203]; @@ -159,6 +160,12 @@ static uint32 ChannelBC[5]; //savestate sync hack stuff int movieSyncHackOn=0,resetDMCacc=0,movieConvertOffset1,movieConvertOffset2; +#ifdef WIN32 +extern volatile int datacount, undefinedcount; +extern int debug_loggingCD; +extern unsigned char *cdloggerdata; +#endif + static void LoadDMCPeriod(uint8 V) { if(PAL) @@ -171,6 +178,31 @@ static void PrepDPCM() { DMCAddress=0x4000+(DMCAddressLatch<<6); DMCSize=(DMCSizeLatch<<4)+1; + + #ifdef WIN32 + if(debug_loggingCD)LogDPCM(0x8000+DMCAddress, DMCSize); + #endif + +} + +void LogDPCM(int romaddress, int dpcmsize){ + int i = GetPRGAddress(romaddress); + + if(i == -1)return; + + for (int dpcmstart = i; dpcmstart < (i + dpcmsize); dpcmstart++) { + if(!(cdloggerdata[dpcmstart] & 0x40)) { + cdloggerdata[dpcmstart] |= 0x40; + + if(!(cdloggerdata[dpcmstart] & 2)){ + datacount++; + cdloggerdata[dpcmstart] |= 2; + if(!(cdloggerdata[dpcmstart] & 1))undefinedcount--; + } + } + } + + return; } /* Instantaneous? Maybe the new freq value is being calculated all of the time... */ diff --git a/src/sound.h b/src/sound.h index 6a982973..c409a0e9 100644 --- a/src/sound.h +++ b/src/sound.h @@ -51,6 +51,12 @@ extern int32 WaveFinal[2048+512]; extern int32 WaveHi[]; extern uint32 soundtsinc; +#ifdef WIN32 +extern volatile int datacount, undefinedcount; +extern int debug_loggingCD; +extern unsigned char *cdloggerdata; +#endif + extern uint32 soundtsoffs; #define SOUNDTS (timestamp + soundtsoffs) @@ -65,4 +71,6 @@ void FCEUSND_LoadState(int version); void FCEU_SoundCPUHook(int); void Write_IRQFM (uint32 A, uint8 V); //mbg merge 7/17/06 brought over from latest mmbuild +void LogDPCM(int romaddress, int dpcmsize); + #endif