diff --git a/src/burn/sound/burn_ym2612.cpp b/src/burn/sound/burn_ym2612.cpp index 3a2eb5cd3..10871f7c4 100644 --- a/src/burn/sound/burn_ym2612.cpp +++ b/src/burn/sound/burn_ym2612.cpp @@ -38,6 +38,10 @@ static INT32 YM2612StreamCallbackDummy(INT32 /* nSoundRate */) static void YM2612Render(INT32 nSegmentLength) { +#if defined FBA_DEBUG + if (!DebugSnd_YM2612Initted) bprintf(PRINT_ERROR, _T("YM2612Render called without init\n")); +#endif + if (nYM2612Position >= nSegmentLength) { return; } @@ -66,6 +70,10 @@ static void YM2612Render(INT32 nSegmentLength) // Update the sound buffer static void YM2612UpdateNormal(INT16* pSoundBuf, INT32 nSegmentEnd) { +#if defined FBA_DEBUG + if (!DebugSnd_YM2612Initted) bprintf(PRINT_ERROR, _T("YM2612UpdateNormal called without init\n")); +#endif + INT32 nSegmentLength = nSegmentEnd; INT32 i; @@ -152,6 +160,10 @@ static void YM2612UpdateNormal(INT16* pSoundBuf, INT32 nSegmentEnd) void BurnYM2612UpdateRequest() { +#if defined FBA_DEBUG + if (!DebugSnd_YM2612Initted) bprintf(PRINT_ERROR, _T("YM2612UpdateRequest called without init\n")); +#endif + YM2612Render(BurnYM2612StreamCallback(nBurnYM2612SoundRate)); } @@ -160,6 +172,10 @@ void BurnYM2612UpdateRequest() void BurnYM2612Reset() { +#if defined FBA_DEBUG + if (!DebugSnd_YM2612Initted) bprintf(PRINT_ERROR, _T("BurnYM2612Reset called without init\n")); +#endif + BurnTimerReset(); for (INT32 i = 0; i < nNumChips; i++) { @@ -169,6 +185,10 @@ void BurnYM2612Reset() void BurnYM2612Exit() { +#if defined FBA_DEBUG + if (!DebugSnd_YM2612Initted) bprintf(PRINT_ERROR, _T("BurnYM2612Exit called without init\n")); +#endif + YM2612Shutdown(); BurnTimerExit(); @@ -180,10 +200,14 @@ void BurnYM2612Exit() nNumChips = 0; bYM2612AddSignal = 0; + + DebugSnd_YM2612Initted = 0; } INT32 BurnYM2612Init(INT32 num, INT32 nClockFrequency, FM_IRQHANDLER IRQCallback, INT32 (*StreamCallback)(INT32), double (*GetTimeCallback)(), INT32 bAddSignal) { + DebugSnd_YM2612Initted = 1; + if (num > MAX_YM2612) num = MAX_YM2612; BurnTimerInit(&YM2612TimerOver, GetTimeCallback); @@ -218,6 +242,10 @@ INT32 BurnYM2612Init(INT32 num, INT32 nClockFrequency, FM_IRQHANDLER IRQCallback void BurnYM2612Scan(INT32 nAction, INT32* pnMin) { +#if defined FBA_DEBUG + if (!DebugSnd_YM2612Initted) bprintf(PRINT_ERROR, _T("BurnYM2612Scan called without init\n")); +#endif + BurnTimerScan(nAction, pnMin); if (nAction & ACB_DRIVER_DATA) { diff --git a/src/burn/sound/burn_ym2612.h b/src/burn/sound/burn_ym2612.h index ab1bdb459..507fc25dd 100644 --- a/src/burn/sound/burn_ym2612.h +++ b/src/burn/sound/burn_ym2612.h @@ -13,9 +13,14 @@ void BurnYM2612Exit(); extern void (*BurnYM2612Update)(INT16* pSoundBuf, INT32 nSegmentEnd); void BurnYM2612Scan(INT32 nAction, INT32* pnMin); -#define BurnYM2612Write(i, a, n) YM2612Write(i, a, n) #define BurnYM2612Read(i, a) YM2612Read(i, a) +#if defined FBA_DEBUG + #define BurnYM2612Write(i, a, n) if (!DebugSnd_YM2612Initted) bprintf(PRINT_ERROR, _T("BurnYM2612Write called without init\n")); YM2612Write(i, a, n) +#else + #define BurnYM2612Write(i, a, n) YM2612Write(i, a, n) +#endif + #define BurnYM3438Init(i, n, a, b, c, d) BurnYM2612Init(i, n, a, b, c, d) #define BurnYM3438Reset() BurnYM2612Reset() #define BurnYM3438Exit() BurnYM2612Exit() diff --git a/src/burn/sound/burn_ym3526.cpp b/src/burn/sound/burn_ym3526.cpp index dece3e478..d3081b371 100644 --- a/src/burn/sound/burn_ym3526.cpp +++ b/src/burn/sound/burn_ym3526.cpp @@ -340,6 +340,10 @@ static INT32 YM3526StreamCallbackDummy(INT32 /* nSoundRate */) static void YM3526Render(INT32 nSegmentLength) { +#if defined FBA_DEBUG + if (!DebugSnd_YM3526Initted) bprintf(PRINT_ERROR, _T("YM3526Render called without init\n")); +#endif + if (nYM3526Position >= nSegmentLength) { return; } @@ -358,6 +362,10 @@ static void YM3526Render(INT32 nSegmentLength) static void YM3526UpdateResample(INT16* pSoundBuf, INT32 nSegmentEnd) { +#if defined FBA_DEBUG + if (!DebugSnd_YM3526Initted) bprintf(PRINT_ERROR, _T("YM3526UpdateResample called without init\n")); +#endif + INT32 nSegmentLength = nSegmentEnd; INT32 nSamplesNeeded = nSegmentEnd * nBurnYM3526SoundRate / nBurnSoundRate + 1; @@ -408,6 +416,10 @@ static void YM3526UpdateResample(INT16* pSoundBuf, INT32 nSegmentEnd) static void YM3526UpdateNormal(INT16* pSoundBuf, INT32 nSegmentEnd) { +#if defined FBA_DEBUG + if (!DebugSnd_YM3526Initted) bprintf(PRINT_ERROR, _T("YM3526UpdateNormal called without init\n")); +#endif + INT32 nSegmentLength = nSegmentEnd; // bprintf(PRINT_NORMAL, _T(" YM3526 render %6i -> %6i\n"), nYM3526Position, nSegmentEnd); @@ -455,6 +467,10 @@ static void YM3526UpdateNormal(INT16* pSoundBuf, INT32 nSegmentEnd) void BurnYM3526UpdateRequest(int, int) { +#if defined FBA_DEBUG + if (!DebugSnd_YM3526Initted) bprintf(PRINT_ERROR, _T("BurnYM3526UpdateRequest called without init\n")); +#endif + YM3526Render(BurnYM3526StreamCallback(nBurnYM3526SoundRate)); } @@ -463,6 +479,10 @@ void BurnYM3526UpdateRequest(int, int) void BurnYM3526Reset() { +#if defined FBA_DEBUG + if (!DebugSnd_YM3526Initted) bprintf(PRINT_ERROR, _T("BurnYM3526Reset called without init\n")); +#endif + BurnTimerResetYM3526(); YM3526ResetChip(0); @@ -470,6 +490,10 @@ void BurnYM3526Reset() void BurnYM3526Exit() { +#if defined FBA_DEBUG + if (!DebugSnd_YM3526Initted) bprintf(PRINT_ERROR, _T("BurnYM3526Exit called without init\n")); +#endif + YM3526Shutdown(); BurnTimerExitYM3526(); @@ -480,10 +504,14 @@ void BurnYM3526Exit() } bYM3526AddSignal = 0; + + DebugSnd_YM3526Initted = 0; } INT32 BurnYM3526Init(INT32 nClockFrequency, OPL_IRQHANDLER IRQCallback, INT32 (*StreamCallback)(INT32), INT32 bAddSignal) { + DebugSnd_YM3526Initted = 1; + BurnTimerInitYM3526(&YM3526TimerOver, NULL); if (nBurnSoundRate <= 0) { @@ -534,6 +562,10 @@ INT32 BurnYM3526Init(INT32 nClockFrequency, OPL_IRQHANDLER IRQCallback, INT32 (* void BurnYM3526Scan(INT32 nAction, INT32* pnMin) { +#if defined FBA_DEBUG + if (!DebugSnd_YM3526Initted) bprintf(PRINT_ERROR, _T("BurnYM3526Scan called without init\n")); +#endif + BurnTimerScanYM3526(nAction, pnMin); if (nAction & ACB_DRIVER_DATA) { diff --git a/src/burn/sound/burn_ym3526.h b/src/burn/sound/burn_ym3526.h index 04ac24cb1..9ffe51ddd 100644 --- a/src/burn/sound/burn_ym3526.h +++ b/src/burn/sound/burn_ym3526.h @@ -23,5 +23,10 @@ void BurnYM3526Exit(); extern void (*BurnYM3526Update)(INT16* pSoundBuf, INT32 nSegmentEnd); void BurnYM3526Scan(INT32 nAction, INT32* pnMin); -#define BurnYM3526Write(a, n) YM3526Write(0, a, n) #define BurnYM3526Read(a) YM3526Read(0, a) + +#if defined FBA_DEBUG + #define BurnYM3526Write(a, n) if (!DebugSnd_YM3526Initted) bprintf(PRINT_ERROR, _T("BurnYM3526Write called without init\n")); YM3526Write(0, a, n) +#else + #define BurnYM3526Write(a, n) YM3526Write(0, a, n) +#endif diff --git a/src/burn/sound/burn_ym3812.cpp b/src/burn/sound/burn_ym3812.cpp index 5eaed9662..f6f60f75f 100644 --- a/src/burn/sound/burn_ym3812.cpp +++ b/src/burn/sound/burn_ym3812.cpp @@ -340,6 +340,10 @@ static INT32 YM3812StreamCallbackDummy(INT32 /* nSoundRate */) static void YM3812Render(INT32 nSegmentLength) { +#if defined FBA_DEBUG + if (!DebugSnd_YM3812Initted) bprintf(PRINT_ERROR, _T("YM3812Render called without init\n")); +#endif + if (nYM3812Position >= nSegmentLength) { return; } @@ -358,6 +362,10 @@ static void YM3812Render(INT32 nSegmentLength) static void YM3812UpdateResample(INT16* pSoundBuf, INT32 nSegmentEnd) { +#if defined FBA_DEBUG + if (!DebugSnd_YM3812Initted) bprintf(PRINT_ERROR, _T("YM3812UpdateResample called without init\n")); +#endif + INT32 nSegmentLength = nSegmentEnd; INT32 nSamplesNeeded = nSegmentEnd * nBurnYM3812SoundRate / nBurnSoundRate + 1; @@ -408,6 +416,10 @@ static void YM3812UpdateResample(INT16* pSoundBuf, INT32 nSegmentEnd) static void YM3812UpdateNormal(INT16* pSoundBuf, INT32 nSegmentEnd) { +#if defined FBA_DEBUG + if (!DebugSnd_YM3812Initted) bprintf(PRINT_ERROR, _T("YM3812UpdateNormal called without init\n")); +#endif + INT32 nSegmentLength = nSegmentEnd; // bprintf(PRINT_NORMAL, _T(" YM3812 render %6i -> %6i\n"), nYM3812Position, nSegmentEnd); @@ -455,6 +467,10 @@ static void YM3812UpdateNormal(INT16* pSoundBuf, INT32 nSegmentEnd) void BurnYM3812UpdateRequest(INT32, INT32) { +#if defined FBA_DEBUG + if (!DebugSnd_YM3812Initted) bprintf(PRINT_ERROR, _T("BurnYM3812UpdateRequest called without init\n")); +#endif + YM3812Render(BurnYM3812StreamCallback(nBurnYM3812SoundRate)); } @@ -463,6 +479,10 @@ void BurnYM3812UpdateRequest(INT32, INT32) void BurnYM3812Reset() { +#if defined FBA_DEBUG + if (!DebugSnd_YM3812Initted) bprintf(PRINT_ERROR, _T("BurnYM3812Reset called without init\n")); +#endif + BurnTimerResetYM3812(); YM3812ResetChip(0); @@ -470,6 +490,10 @@ void BurnYM3812Reset() void BurnYM3812Exit() { +#if defined FBA_DEBUG + if (!DebugSnd_YM3812Initted) bprintf(PRINT_ERROR, _T("BurnYM3812Exit called without init\n")); +#endif + YM3812Shutdown(); BurnTimerExitYM3812(); @@ -480,10 +504,14 @@ void BurnYM3812Exit() } bYM3812AddSignal = 0; + + DebugSnd_YM3812Initted = 0; } INT32 BurnYM3812Init(INT32 nClockFrequency, OPL_IRQHANDLER IRQCallback, INT32 (*StreamCallback)(INT32), INT32 bAddSignal) { + DebugSnd_YM3812Initted = 1; + BurnTimerInitYM3812(&YM3812TimerOver, NULL); if (nBurnSoundRate <= 0) { @@ -534,6 +562,10 @@ INT32 BurnYM3812Init(INT32 nClockFrequency, OPL_IRQHANDLER IRQCallback, INT32 (* void BurnYM3812Scan(INT32 nAction, INT32* pnMin) { +#if defined FBA_DEBUG + if (!DebugSnd_YM3812Initted) bprintf(PRINT_ERROR, _T("BurnYM3812Scan called without init\n")); +#endif + BurnTimerScanYM3812(nAction, pnMin); if (nAction & ACB_DRIVER_DATA) { diff --git a/src/burn/sound/burn_ym3812.h b/src/burn/sound/burn_ym3812.h index dd0b4c909..728572f96 100644 --- a/src/burn/sound/burn_ym3812.h +++ b/src/burn/sound/burn_ym3812.h @@ -24,5 +24,10 @@ void BurnYM3812Exit(); extern void (*BurnYM3812Update)(INT16* pSoundBuf, INT32 nSegmentEnd); void BurnYM3812Scan(INT32 nAction, INT32* pnMin); -#define BurnYM3812Write(a, n) YM3812Write(0, a, n) #define BurnYM3812Read(a) YM3812Read(0, a) + +#if defined FBA_DEBUG + #define BurnYM3812Write(a, n) if (!DebugSnd_YM3812Initted) bprintf(PRINT_ERROR, _T("BurnYM3812Write called without init\n")); YM3812Write(0, a, n) +#else + #define BurnYM3812Write(a, n) YM3812Write(0, a, n) +#endif diff --git a/src/burn/sound/burn_ymf278b.cpp b/src/burn/sound/burn_ymf278b.cpp index 25c03647d..53bd0b93d 100644 --- a/src/burn/sound/burn_ymf278b.cpp +++ b/src/burn/sound/burn_ymf278b.cpp @@ -24,6 +24,10 @@ static INT32 YMF278BStreamCallbackDummy(INT32 /* nSoundRate */) static void YMF278BRender(INT32 nSegmentLength) { +#if defined FBA_DEBUG + if (!DebugSnd_YMF278BInitted) bprintf(PRINT_ERROR, _T("YMF278BRender called without init\n")); +#endif + if (nYMF278BPosition >= nSegmentLength) { return; } @@ -45,6 +49,10 @@ static void YMF278BRender(INT32 nSegmentLength) void BurnYMF278BUpdate(INT32 nSegmentEnd) { +#if defined FBA_DEBUG + if (!DebugSnd_YMF278BInitted) bprintf(PRINT_ERROR, _T("BurnYMF278BUpdate called without init\n")); +#endif + INT16* pSoundBuf = pBurnSoundOut; INT32 nSegmentLength = nSegmentEnd; @@ -93,6 +101,10 @@ void BurnYMF278BUpdate(INT32 nSegmentEnd) void BurnYMF278BSelectRegister(INT32 nRegister, UINT8 nValue) { +#if defined FBA_DEBUG + if (!DebugSnd_YMF278BInitted) bprintf(PRINT_ERROR, _T("BurnYMF278BSelectRegister called without init\n")); +#endif + switch (nRegister) { case 0: // bprintf(PRINT_NORMAL, _T(" YMF278B register A -> %i\n"), nValue); @@ -109,6 +121,10 @@ void BurnYMF278BSelectRegister(INT32 nRegister, UINT8 nValue) } void BurnYMF278BWriteRegister(INT32 nRegister, UINT8 nValue) { +#if defined FBA_DEBUG + if (!DebugSnd_YMF278BInitted) bprintf(PRINT_ERROR, _T("BurnYMF278BWriteRegister called without init\n")); +#endif + switch (nRegister) { case 0: BurnYMF278BUpdate(BurnYMF278BStreamCallback(nBurnSoundRate)); @@ -126,12 +142,20 @@ void BurnYMF278BWriteRegister(INT32 nRegister, UINT8 nValue) UINT8 BurnYMF278BReadStatus() { +#if defined FBA_DEBUG + if (!DebugSnd_YMF278BInitted) bprintf(PRINT_ERROR, _T("BurnYMF278BReadStatus called without init\n")); +#endif + BurnYMF278BUpdate(BurnYMF278BStreamCallback(nBurnSoundRate)); return YMF278B_status_port_0_r(); } UINT8 BurnYMF278BReadData() { +#if defined FBA_DEBUG + if (!DebugSnd_YMF278BInitted) bprintf(PRINT_ERROR, _T("BurnYMF278BReadData called without init\n")); +#endif + return YMF278B_data_port_0_r(); } @@ -139,11 +163,19 @@ UINT8 BurnYMF278BReadData() void BurnYMF278BReset() { +#if defined FBA_DEBUG + if (!DebugSnd_YMF278BInitted) bprintf(PRINT_ERROR, _T("BurnYMF278BReset called without init\n")); +#endif + BurnTimerReset(); } void BurnYMF278BExit() { +#if defined FBA_DEBUG + if (!DebugSnd_YMF278BInitted) bprintf(PRINT_ERROR, _T("BurnYMF278BExit called without init\n")); +#endif + YMF278B_sh_stop(); BurnTimerExit(); @@ -152,11 +184,15 @@ void BurnYMF278BExit() free(pBuffer); pBuffer = NULL; } + + DebugSnd_YMF278BInitted = 0; } INT32 BurnYMF278BInit(INT32 /* nClockFrequency */, UINT8* YMF278BROM, void (*IRQCallback)(INT32, INT32), INT32 (*StreamCallback)(INT32)) { - BurnYMF278BExit(); + DebugSnd_YMF278BInitted = 1; + BurnYMF278BExit(); + DebugSnd_YMF278BInitted = 1; BurnYMF278BStreamCallback = YMF278BStreamCallbackDummy; if (StreamCallback) { @@ -176,7 +212,11 @@ INT32 BurnYMF278BInit(INT32 /* nClockFrequency */, UINT8* YMF278BROM, void (*IRQ return 0; } -void BurnYMF278BScan(int nAction, int* pnMin) +void BurnYMF278BScan(INT32 nAction, INT32* pnMin) { +#if defined FBA_DEBUG + if (!DebugSnd_YMF278BInitted) bprintf(PRINT_ERROR, _T("BurnYMF278BScan called without init\n")); +#endif + BurnTimerScan(nAction, pnMin); } diff --git a/src/burn/sound/dac.cpp b/src/burn/sound/dac.cpp index 657d11bb8..356b47a8d 100644 --- a/src/burn/sound/dac.cpp +++ b/src/burn/sound/dac.cpp @@ -26,6 +26,10 @@ static INT32 bAddSignal; void DACUpdate(INT16* Buffer, INT32 Length) { +#if defined FBA_DEBUG + if (!DebugSnd_DACInitted) bprintf(PRINT_ERROR, _T("DACUpdate called without init\n")); +#endif + INT32 Out = Chip0->Output; if (NumChips >= 2) Out += Chip1->Output; @@ -52,6 +56,11 @@ void DACUpdate(INT16* Buffer, INT32 Length) void DACWrite(INT32 Chip, UINT8 Data) { +#if defined FBA_DEBUG + if (!DebugSnd_DACInitted) bprintf(PRINT_ERROR, _T("DACWrite called without init\n")); + if (Chip > NumChips) bprintf(PRINT_ERROR, _T("DACWrite called with invalid chip number %x\n"), Chip); +#endif + if (Chip == 0) Chip0->Output = Chip0->UnsignedVolTable[Data] >> Chip0->nVolShift; if (Chip == 1) Chip1->Output = Chip1->UnsignedVolTable[Data] >> Chip1->nVolShift; if (Chip == 2) Chip2->Output = Chip2->UnsignedVolTable[Data] >> Chip2->nVolShift; @@ -64,6 +73,11 @@ void DACWrite(INT32 Chip, UINT8 Data) void DACSignedWrite(INT32 Chip, UINT8 Data) { +#if defined FBA_DEBUG + if (!DebugSnd_DACInitted) bprintf(PRINT_ERROR, _T("DACSignedWrite called without init\n")); + if (Chip > NumChips) bprintf(PRINT_ERROR, _T("DACSignedWrite called with invalid chip number %x\n"), Chip); +#endif + if (Chip == 0) Chip0->Output = Chip0->SignedVolTable[Data] >> Chip0->nVolShift; if (Chip == 1) Chip1->Output = Chip1->SignedVolTable[Data] >> Chip1->nVolShift; if (Chip == 2) Chip2->Output = Chip2->SignedVolTable[Data] >> Chip2->nVolShift; @@ -121,6 +135,8 @@ static void DACBuildVolTables() void DACInit(INT32 Num, UINT32 Clock, INT32 bAdd) { + DebugSnd_DACInitted = 1; + NumChips = Num; if (Num == 0) { @@ -194,6 +210,11 @@ void DACInit(INT32 Num, UINT32 Clock, INT32 bAdd) void DACSetVolShift(INT32 Chip, INT32 nShift) { +#if defined FBA_DEBUG + if (!DebugSnd_DACInitted) bprintf(PRINT_ERROR, _T("DACSetVolShift called without init\n")); + if (Chip > NumChips) bprintf(PRINT_ERROR, _T("DACSetVolShift called with invalid chip number %x\n"), Chip); +#endif + if (Chip == 0) Chip0->nVolShift = nShift; if (Chip == 1) Chip1->nVolShift = nShift; if (Chip == 2) Chip2->nVolShift = nShift; @@ -206,6 +227,10 @@ void DACSetVolShift(INT32 Chip, INT32 nShift) void DACReset() { +#if defined FBA_DEBUG + if (!DebugSnd_DACInitted) bprintf(PRINT_ERROR, _T("DACReset called without init\n")); +#endif + Chip0->Output = 0; if (NumChips >= 2) Chip1->Output = 0; if (NumChips >= 3) Chip2->Output = 0; @@ -218,6 +243,10 @@ void DACReset() void DACExit() { +#if defined FBA_DEBUG + if (!DebugSnd_DACInitted) bprintf(PRINT_ERROR, _T("DACExit called without init\n")); +#endif + if (Chip0) { free(Chip0); Chip0 = NULL; @@ -259,10 +288,16 @@ void DACExit() } NumChips = 0; + + DebugSnd_DACInitted = 0; } INT32 DACScan(INT32 nAction,INT32 *pnMin) { +#if defined FBA_DEBUG + if (!DebugSnd_DACInitted) bprintf(PRINT_ERROR, _T("DACScan called without init\n")); +#endif + struct BurnArea ba; char szName[16]; diff --git a/src/burn/sound/es5506.cpp b/src/burn/sound/es5506.cpp index 56cf3ea0f..d8e529465 100644 --- a/src/burn/sound/es5506.cpp +++ b/src/burn/sound/es5506.cpp @@ -853,6 +853,10 @@ static void generate_samples(INT32 *left, INT32 *right, INT32 samples) //static STREAM_UPDATE( es5506_update ) void ES5506Update(INT16 *pBuffer, INT32 samples) { +#if defined FBA_DEBUG + if (!DebugSnd_ES5506Initted) bprintf(PRINT_ERROR, _T("ES5506Update called without init\n")); +#endif + // es5506_state *chip = (es5506_state *)param; INT32 *lsrc = chip->scratch, *rsrc = chip->scratch; // short *ldest = &pBuffer[0]; @@ -909,6 +913,8 @@ void ES5506Update(INT16 *pBuffer, INT32 samples) static void es5506_start_common(INT32 clock, UINT8* region0, UINT8* region1, UINT8* region2, UINT8* region3, irq_callback callback, INT32 sndtype) { + DebugSnd_ES5506Initted = 1; + // const es5506_interface *intf = (const es5506_interface *)config; // es5506_state *chip = get_safe_token(device); INT32 j; @@ -1018,6 +1024,10 @@ void ES5506Init(INT32 clock, UINT8* region0, UINT8* region1, UINT8* region2, UIN void ES5506Exit() { +#if defined FBA_DEBUG + if (!DebugSnd_ES5506Initted) bprintf(PRINT_ERROR, _T("ES5506Exit called without init\n")); +#endif + /* debugging */ if (LOG_COMMANDS && eslog) { @@ -1036,11 +1046,16 @@ void ES5506Exit() } } #endif + + DebugSnd_ES5506Initted = 0; } void ES5506Reset() { +#if defined FBA_DEBUG + if (!DebugSnd_ES5506Initted) bprintf(PRINT_ERROR, _T("ES5506Reset called without init\n")); +#endif } @@ -1316,6 +1331,10 @@ ES5506_INLINE void es5506_reg_write_test(UINT32 offset, UINT32 data) //WRITE8_DEVICE_HANDLER( es5506_w ) void ES5506Write(UINT32 offset, UINT8 data) { +#if defined FBA_DEBUG + if (!DebugSnd_ES5506Initted) bprintf(PRINT_ERROR, _T("ES5506Write called without init\n")); +#endif + // es5506_state *chip = get_safe_token(device); es5506_voice *voice = &chip->voice[chip->current_page & 0x1f]; INT32 shift = 8 * (offset & 3); @@ -1526,6 +1545,10 @@ ES5506_INLINE UINT32 es5506_reg_read_test(UINT32 offset) //READ8_DEVICE_HANDLER( es5506_r ) UINT8 ES5506Read(UINT32 offset) { +#if defined FBA_DEBUG + if (!DebugSnd_ES5506Initted) bprintf(PRINT_ERROR, _T("ES5506Read called without init\n")); +#endif + // es5506_state *chip = get_safe_token(device); es5506_voice *voice = &chip->voice[chip->current_page & 0x1f]; INT32 shift = 8 * (offset & 3); @@ -1559,6 +1582,10 @@ UINT8 ES5506Read(UINT32 offset) void es5506_voice_bank_w(INT32 voice, INT32 bank) { +#if defined FBA_DEBUG + if (!DebugSnd_ES5506Initted) bprintf(PRINT_ERROR, _T("es5506_voice_bank_w called without init\n")); +#endif + // es5506_state *chip = get_safe_token(device); chip->voice[voice].exbank=bank; } @@ -1959,6 +1986,10 @@ ES5506_INLINE void es5505_reg_write_test(UINT32 offset, UINT16 data) //WRITE16_DEVICE_HANDLER( es5505_w ) void ES5505Write(UINT32 offset, UINT16 data) { +#if defined FBA_DEBUG + if (!DebugSnd_ES5506Initted) bprintf(PRINT_ERROR, _T("ES5505Write called without init\n")); +#endif + // es5506_state *chip = get_safe_token(device); es5506_voice *voice = &chip->voice[chip->current_page & 0x1f]; @@ -2171,6 +2202,10 @@ ES5506_INLINE UINT16 es5505_reg_read_test(UINT32 offset) //READ16_DEVICE_HANDLER( es5505_r ) UINT16 ES5505Read(UINT32 offset) { +#if defined FBA_DEBUG + if (!DebugSnd_ES5506Initted) bprintf(PRINT_ERROR, _T("ES5505Read called without init\n")); +#endif + // es5506_state *chip = get_safe_token(device); es5506_voice *voice = &chip->voice[chip->current_page & 0x1f]; UINT16 result = 0; @@ -2200,6 +2235,10 @@ UINT16 ES5505Read(UINT32 offset) void es5505_voice_bank_w(INT32 voice, INT32 bank) { +#if defined FBA_DEBUG + if (!DebugSnd_ES5506Initted) bprintf(PRINT_ERROR, _T("es5505_voice_bank_w called without init\n")); +#endif + // es5506_state *chip = get_safe_token(device); #if RAINE_CHECK chip->voice[voice].control = CONTROL_STOPMASK; diff --git a/src/burn/sound/es8712.cpp b/src/burn/sound/es8712.cpp index 76f0ac43a..3a1bf94cb 100644 --- a/src/burn/sound/es8712.cpp +++ b/src/burn/sound/es8712.cpp @@ -177,6 +177,10 @@ static void generate_adpcm(INT16 *buffer, INT32 samples) void es8712Update(INT32 device, INT16 *buffer, INT32 samples) { +#if defined FBA_DEBUG + if (!DebugSnd_ES8712Initted) bprintf(PRINT_ERROR, _T("es8712Update called without init\n")); +#endif + if (device >= MAX_ES8712_CHIPS) return; chip = &chips[device]; @@ -211,6 +215,8 @@ void es8712Update(INT32 device, INT16 *buffer, INT32 samples) void es8712Init(INT32 device, UINT8 *rom, INT32 sample_rate, float volume, INT32 addSignal) { + DebugSnd_ES8712Initted = 1; + if (device >= MAX_ES8712_CHIPS) return; chip = &chips[device]; @@ -245,6 +251,10 @@ void es8712Init(INT32 device, UINT8 *rom, INT32 sample_rate, float volume, INT32 void es8712Exit(INT32 device) { +#if defined FBA_DEBUG + if (!DebugSnd_ES8712Initted) bprintf(PRINT_ERROR, _T("es8712Exit called without init\n")); +#endif + if (device >= MAX_ES8712_CHIPS) return; chip = &chips[device]; @@ -255,6 +265,8 @@ void es8712Exit(INT32 device) free (tbuf[device]); tbuf[device] = NULL; } + + DebugSnd_ES8712Initted = 0; } /************************************************************************************* @@ -265,6 +277,10 @@ void es8712Exit(INT32 device) void es8712Reset(INT32 device) { +#if defined FBA_DEBUG + if (!DebugSnd_ES8712Initted) bprintf(PRINT_ERROR, _T("es8712Reset called without init\n")); +#endif + if (device >= MAX_ES8712_CHIPS) return; chip = &chips[device]; @@ -286,6 +302,10 @@ void es8712Reset(INT32 device) void es8712SetBankBase(INT32 device, INT32 base) { +#if defined FBA_DEBUG + if (!DebugSnd_ES8712Initted) bprintf(PRINT_ERROR, _T("es8712SetBankBase called without init\n")); +#endif + if (device >= MAX_ES8712_CHIPS) return; chip = &chips[device]; @@ -302,6 +322,10 @@ void es8712SetBankBase(INT32 device, INT32 base) void es8712Play(INT32 device) { +#if defined FBA_DEBUG + if (!DebugSnd_ES8712Initted) bprintf(PRINT_ERROR, _T("es8712Play called without init\n")); +#endif + if (device >= MAX_ES8712_CHIPS) return; chip = &chips[device]; @@ -358,6 +382,10 @@ void es8712Play(INT32 device) void es8712Write(INT32 device, INT32 offset, UINT8 data) { +#if defined FBA_DEBUG + if (!DebugSnd_ES8712Initted) bprintf(PRINT_ERROR, _T("es8712Write called without init\n")); +#endif + if (device >= MAX_ES8712_CHIPS) return; chip = &chips[device]; @@ -395,6 +423,10 @@ void es8712Write(INT32 device, INT32 offset, UINT8 data) INT32 es8712Scan(INT32 device, INT32 nAction) { +#if defined FBA_DEBUG + if (!DebugSnd_ES8712Initted) bprintf(PRINT_ERROR, _T("es8712Scan called without init\n")); +#endif + if (device >= MAX_ES8712_CHIPS) return 1; if (nAction & ACB_DRIVER_DATA) { diff --git a/src/burn/sound/ics2115.cpp b/src/burn/sound/ics2115.cpp index 98627bebc..cfd5599e5 100644 --- a/src/burn/sound/ics2115.cpp +++ b/src/burn/sound/ics2115.cpp @@ -106,6 +106,10 @@ static void recalc_timer(INT32 timer) UINT16 ics2115read_reg(UINT8 reg) { +#if defined FBA_DEBUG + if (!DebugSnd_ICS2115Initted) bprintf(PRINT_ERROR, _T("ics2115read_reg called without init\n")); +#endif + switch (reg) { case 0x0d: // [osc] Volume Enveloppe Control return 0x100; @@ -142,6 +146,10 @@ UINT16 ics2115read_reg(UINT8 reg) void ics2115write_reg(UINT8 reg, UINT8 data, INT32 msb) { +#if defined FBA_DEBUG + if (!DebugSnd_ICS2115Initted) bprintf(PRINT_ERROR, _T("ics2115write_reg called without init\n")); +#endif + // bprintf(PRINT_NORMAL, _T("ics2115write_reg(%02x, %02x, %d); %4.1f%%\n"), reg, data, msb, 6.0 * ZetTotalCycles() / 8468.0 ); switch (reg) { @@ -237,6 +245,10 @@ void ics2115write_reg(UINT8 reg, UINT8 data, INT32 msb) UINT8 ics2115read(UINT8 offset) { +#if defined FBA_DEBUG + if (!DebugSnd_ICS2115Initted) bprintf(PRINT_ERROR, _T("ics2115read called without init\n")); +#endif + switch ( offset ) { case 0x00: { UINT8 res = 0; @@ -262,6 +274,10 @@ UINT8 ics2115read(UINT8 offset) void ics2115write(UINT8 offset, UINT8 data) { +#if defined FBA_DEBUG + if (!DebugSnd_ICS2115Initted) bprintf(PRINT_ERROR, _T("ics2115write called without init\n")); +#endif + switch (offset) { case 0x01: chip->reg = data; @@ -279,6 +295,8 @@ void ics2115write(UINT8 offset, UINT8 data) INT32 ics2115_init() { + DebugSnd_ICS2115Initted = 1; + chip = (struct ics2115 *) malloc( sizeof(struct ics2115) ); // ICS2115V if (chip == NULL) return 1; @@ -290,6 +308,10 @@ INT32 ics2115_init() void ics2115_exit() { +#if defined FBA_DEBUG + if (!DebugSnd_ICS2115Initted) bprintf(PRINT_ERROR, _T("ics2115_exit called without init\n")); +#endif + if (chip) { free( chip ); chip = NULL; @@ -306,6 +328,8 @@ void ics2115_exit() free( sndbuffer ); sndbuffer = NULL; } + + DebugSnd_ICS2115Initted = 0; } static void recalculate_ulaw() @@ -322,6 +346,10 @@ static void recalculate_ulaw() void ics2115_reset() { +#if defined FBA_DEBUG + if (!DebugSnd_ICS2115Initted) bprintf(PRINT_ERROR, _T("ics2115_reset called without init\n")); +#endif + memset(chip, 0, sizeof(struct ics2115)); chip->rom = ICSSNDROM; @@ -346,6 +374,10 @@ void ics2115_reset() UINT16 ics2115_soundlatch_r(INT32 i) { +#if defined FBA_DEBUG + if (!DebugSnd_ICS2115Initted) bprintf(PRINT_ERROR, _T("ics2115_soundlatch_r called without init\n")); +#endif + // bprintf(PRINT_NORMAL, _T("soundlatch_r(%d) %4.1f%% of frame\n"), i, 6.0 * SekTotalCycles() / 20000.0 ); bSoundlatchRead[i] = 1; return nSoundlatch[i]; @@ -353,6 +385,10 @@ UINT16 ics2115_soundlatch_r(INT32 i) void ics2115_soundlatch_w(INT32 i, UINT16 d) { +#if defined FBA_DEBUG + if (!DebugSnd_ICS2115Initted) bprintf(PRINT_ERROR, _T("ics2115_soundlatch_w called without init\n")); +#endif + // if ( !bSoundlatchRead[i] && nSoundlatch[i] != d ) // bprintf(PRINT_ERROR, _T("soundlatch_w(%d, %04x) %4.1f%% of frame\n"), i, d, 6.0 * SekTotalCycles() / 20000.0); // else @@ -363,12 +399,20 @@ void ics2115_soundlatch_w(INT32 i, UINT16 d) void ics2115_frame() { +#if defined FBA_DEBUG + if (!DebugSnd_ICS2115Initted) bprintf(PRINT_ERROR, _T("ics2115_frame called without init\n")); +#endif + if (chip->timer[0].active ) timer_cb_0(); if (chip->timer[1].active ) timer_cb_1(); } void ics2115_update(INT32 /*length*/) { +#if defined FBA_DEBUG + if (!DebugSnd_ICS2115Initted) bprintf(PRINT_ERROR, _T("ics2115_update called without init\n")); +#endif + INT32 rec_irq = 0; //short* pSoundBuf = pBurnSoundOut; @@ -430,6 +474,10 @@ void ics2115_update(INT32 /*length*/) void ics2115_scan(INT32 nAction,INT32 * /*pnMin*/) { +#if defined FBA_DEBUG + if (!DebugSnd_ICS2115Initted) bprintf(PRINT_ERROR, _T("ics2115_scan called without init\n")); +#endif + struct BurnArea ba; if ( nAction & ACB_DRIVER_DATA ) { diff --git a/src/burn/sound/iremga20.cpp b/src/burn/sound/iremga20.cpp index 3f5042ddc..eb234fd05 100644 --- a/src/burn/sound/iremga20.cpp +++ b/src/burn/sound/iremga20.cpp @@ -66,6 +66,10 @@ static UINT32 computed_steps; void iremga20_update(INT32 device, INT16 *buffer, INT32 length) { +#if defined FBA_DEBUG + if (!DebugSnd_IremGA20Initted) bprintf(PRINT_ERROR, _T("iremga20_update called without init\n")); +#endif + chip = &chips[device]; UINT32 rate[4], pos[4], frac[4], end[4], vol[4], play[4]; UINT8 *pSamples; @@ -138,6 +142,10 @@ void iremga20_update(INT32 device, INT16 *buffer, INT32 length) void iremga20_write(INT32 device, INT32 offset, INT32 data) { +#if defined FBA_DEBUG + if (!DebugSnd_IremGA20Initted) bprintf(PRINT_ERROR, _T("iremga20_write called without init\n")); +#endif + chip = &chips[device]; INT32 channel = offset >> 3; @@ -180,6 +188,10 @@ void iremga20_write(INT32 device, INT32 offset, INT32 data) UINT8 iremga20_read(INT32 device, INT32 offset) { +#if defined FBA_DEBUG + if (!DebugSnd_IremGA20Initted) bprintf(PRINT_ERROR, _T("iremga20_read called without init\n")); +#endif + chip = &chips[device]; switch (offset & 0x7) @@ -196,6 +208,10 @@ UINT8 iremga20_read(INT32 device, INT32 offset) void iremga20_reset(INT32 device) { +#if defined FBA_DEBUG + if (!DebugSnd_IremGA20Initted) bprintf(PRINT_ERROR, _T("iremga20_reset called without init\n")); +#endif + chip = &chips[device]; for(INT32 i = 0; i < 4; i++ ) { @@ -217,6 +233,8 @@ void iremga20_reset(INT32 device) void iremga20_init(INT32 device, UINT8 *rom, INT32 rom_size, INT32 frequency) { + DebugSnd_IremGA20Initted = 1; + chip = &chips[device]; /* Initialize our chip structure */ @@ -231,11 +249,19 @@ void iremga20_init(INT32 device, UINT8 *rom, INT32 rom_size, INT32 frequency) void iremga20_exit() { +#if defined FBA_DEBUG + if (!DebugSnd_IremGA20Initted) bprintf(PRINT_ERROR, _T("iremga20_exit called without init\n")); +#endif + DebugSnd_IremGA20Initted = 0; } INT32 iremga20_scan(INT32 device, INT32 nAction, INT32 *pnMin) { +#if defined FBA_DEBUG + if (!DebugSnd_IremGA20Initted) bprintf(PRINT_ERROR, _T("iremga20_scan called without init\n")); +#endif + chip = &chips[device]; struct BurnArea ba; diff --git a/src/burn/sound/k007232.cpp b/src/burn/sound/k007232.cpp index 065d76cd8..4e8036747 100644 --- a/src/burn/sound/k007232.cpp +++ b/src/burn/sound/k007232.cpp @@ -41,6 +41,10 @@ static INT32 *Right = NULL; void K007232Update(INT32 chip, INT16* pSoundBuf, INT32 nLength) { +#if defined FBA_DEBUG + if (!DebugSnd_K007232Initted) bprintf(PRINT_ERROR, _T("K007232Update called without init\n")); +#endif + INT32 i; Chip = &Chips[chip]; @@ -104,6 +108,10 @@ void K007232Update(INT32 chip, INT16* pSoundBuf, INT32 nLength) UINT8 K007232ReadReg(INT32 chip, INT32 r) { +#if defined FBA_DEBUG + if (!DebugSnd_K007232Initted) bprintf(PRINT_ERROR, _T("K007232ReadReg called without init\n")); +#endif + INT32 ch = 0; Chip = &Chips[chip]; @@ -126,6 +134,10 @@ UINT8 K007232ReadReg(INT32 chip, INT32 r) void K007232WriteReg(INT32 chip, INT32 r, INT32 v) { +#if defined FBA_DEBUG + if (!DebugSnd_K007232Initted) bprintf(PRINT_ERROR, _T("K007232WriteReg called without init\n")); +#endif + INT32 Data; Chip = &Chips[chip]; @@ -175,6 +187,10 @@ void K007232WriteReg(INT32 chip, INT32 r, INT32 v) void K007232SetPortWriteHandler(INT32 chip, void (*Handler)(INT32 v)) { +#if defined FBA_DEBUG + if (!DebugSnd_K007232Initted) bprintf(PRINT_ERROR, _T("K007232SetPortWriteHandler called without init\n")); +#endif + Chip = &Chips[chip]; Ptr = &Pointers[chip]; @@ -188,6 +204,8 @@ static void KDAC_A_make_fncode() void K007232Init(INT32 chip, INT32 clock, UINT8 *pPCMData, INT32 PCMDataSize) { + DebugSnd_K007232Initted = 1; + Chip = &Chips[chip]; Ptr = &Pointers[chip]; @@ -229,6 +247,10 @@ void K007232Init(INT32 chip, INT32 clock, UINT8 *pPCMData, INT32 PCMDataSize) void K007232Exit() { +#if defined FBA_DEBUG + if (!DebugSnd_K007232Initted) bprintf(PRINT_ERROR, _T("K007232Exit called without init\n")); +#endif + if (Left) { free(Left); Left = NULL; @@ -237,11 +259,17 @@ void K007232Exit() if (Right) { free(Right); Right = NULL; - } + } + + DebugSnd_K007232Initted = 0; } INT32 K007232Scan(INT32 nAction, INT32 *pnMin) { +#if defined FBA_DEBUG + if (!DebugSnd_K007232Initted) bprintf(PRINT_ERROR, _T("K007232Scan called without init\n")); +#endif + struct BurnArea ba; char szName[32]; @@ -265,6 +293,10 @@ INT32 K007232Scan(INT32 nAction, INT32 *pnMin) void K007232SetVolume(INT32 chip, INT32 channel,INT32 volumeA,INT32 volumeB) { +#if defined FBA_DEBUG + if (!DebugSnd_K007232Initted) bprintf(PRINT_ERROR, _T("K007232SetVolume called without init\n")); +#endif + Chip = &Chips[chip]; Chip->vol[channel][0] = volumeA; @@ -273,6 +305,10 @@ void K007232SetVolume(INT32 chip, INT32 channel,INT32 volumeA,INT32 volumeB) void k007232_set_bank(INT32 chip, INT32 chABank, INT32 chBBank ) { +#if defined FBA_DEBUG + if (!DebugSnd_K007232Initted) bprintf(PRINT_ERROR, _T("k007232_set_bank called without init\n")); +#endif + Chip = &Chips[chip]; Chip->bank[0] = chABank<<17; diff --git a/src/burn/sound/k051649.cpp b/src/burn/sound/k051649.cpp index 8251d71af..670636e9b 100644 --- a/src/burn/sound/k051649.cpp +++ b/src/burn/sound/k051649.cpp @@ -85,6 +85,10 @@ static void make_mixer_table(INT32 voices) /* generate sound to the mix buffer */ void K051649Update(INT16 *pBuf, INT32 samples) { +#if defined FBA_DEBUG + if (!DebugSnd_K051649Initted) bprintf(PRINT_ERROR, _T("K051649Update called without init\n")); +#endif + info = &Chips[0]; k051649_sound_channel *voice=info->channel_list; INT16 *mix; @@ -143,6 +147,8 @@ void K051649Update(INT16 *pBuf, INT32 samples) void K051649Init(INT32 clock, float gain) { + DebugSnd_K051649Initted = 1; + info = &Chips[0]; /* get stream channels */ @@ -161,6 +167,10 @@ void K051649Init(INT32 clock, float gain) void K051659Exit() { +#if defined FBA_DEBUG + if (!DebugSnd_K051649Initted) bprintf(PRINT_ERROR, _T("K051649Exit called without init\n")); +#endif + info = &Chips[0]; if (info->mixer_buffer) { @@ -174,10 +184,16 @@ void K051659Exit() } nUpdateStep = 0; + + DebugSnd_K051649Initted = 0; } void K051649Reset() { +#if defined FBA_DEBUG + if (!DebugSnd_K051649Initted) bprintf(PRINT_ERROR, _T("K051649Reset called without init\n")); +#endif + info = &Chips[0]; k051649_sound_channel *voice = info->channel_list; INT32 i; @@ -192,6 +208,10 @@ void K051649Reset() INT32 K051649Scan(INT32 nAction, INT32 *pnMin) { +#if defined FBA_DEBUG + if (!DebugSnd_K051649Initted) bprintf(PRINT_ERROR, _T("K051649Scan called without init\n")); +#endif + struct BurnArea ba; if ((nAction & ACB_DRIVER_DATA) == 0) { @@ -221,6 +241,10 @@ INT32 K051649Scan(INT32 nAction, INT32 *pnMin) void K051649WaveformWrite(INT32 offset, INT32 data) { +#if defined FBA_DEBUG + if (!DebugSnd_K051649Initted) bprintf(PRINT_ERROR, _T("K051649WaveformWrite called without init\n")); +#endif + info = &Chips[0]; info->channel_list[offset>>5].waveform[offset&0x1f]=data; /* SY 20001114: Channel 5 shares the waveform with channel 4 */ @@ -228,8 +252,12 @@ void K051649WaveformWrite(INT32 offset, INT32 data) info->channel_list[4].waveform[offset&0x1f]=data; } -unsigned char K051649WaveformRead(INT32 offset) +UINT8 K051649WaveformRead(INT32 offset) { +#if defined FBA_DEBUG + if (!DebugSnd_K051649Initted) bprintf(PRINT_ERROR, _T("K051649WaveformRead called without init\n")); +#endif + info = &Chips[0]; return info->channel_list[offset>>5].waveform[offset&0x1f]; } @@ -237,6 +265,10 @@ unsigned char K051649WaveformRead(INT32 offset) /* SY 20001114: Channel 5 doesn't share the waveform with channel 4 on this chip */ void K052539WaveformWrite(INT32 offset, INT32 data) { +#if defined FBA_DEBUG + if (!DebugSnd_K051649Initted) bprintf(PRINT_ERROR, _T("K052539WaveformWrite called without init\n")); +#endif + info = &Chips[0]; info->channel_list[offset>>5].waveform[offset&0x1f]=data; @@ -244,6 +276,10 @@ void K052539WaveformWrite(INT32 offset, INT32 data) void K051649VolumeWrite(INT32 offset, INT32 data) { +#if defined FBA_DEBUG + if (!DebugSnd_K051649Initted) bprintf(PRINT_ERROR, _T("K051649VolumeWrite called without init\n")); +#endif + info = &Chips[0]; info->channel_list[offset&0x7].volume=data&0xf; @@ -251,6 +287,10 @@ void K051649VolumeWrite(INT32 offset, INT32 data) void K051649FrequencyWrite(INT32 offset, INT32 data) { +#if defined FBA_DEBUG + if (!DebugSnd_K051649Initted) bprintf(PRINT_ERROR, _T("K051649FrequencyWrite called without init\n")); +#endif + info = &Chips[0]; info->f[offset]=data; @@ -259,6 +299,10 @@ void K051649FrequencyWrite(INT32 offset, INT32 data) void K051649KeyonoffWrite(INT32 data) { +#if defined FBA_DEBUG + if (!DebugSnd_K051649Initted) bprintf(PRINT_ERROR, _T("K051649KeyonoffWrite called without init\n")); +#endif + info = &Chips[0]; info->channel_list[0].key=data&1; info->channel_list[1].key=data&2; diff --git a/src/burn/sound/k053260.cpp b/src/burn/sound/k053260.cpp index 4a6f99780..317f3198d 100644 --- a/src/burn/sound/k053260.cpp +++ b/src/burn/sound/k053260.cpp @@ -64,6 +64,10 @@ static void InitDeltaTable(INT32 rate, INT32 clock ) { void K053260Reset(INT32 chip) { +#if defined FBA_DEBUG + if (!DebugSnd_K053260Initted) bprintf(PRINT_ERROR, _T("K053260Reset called without init\n")); +#endif + ic = &Chips[chip]; for(INT32 i = 0; i < 4; i++ ) { @@ -95,6 +99,10 @@ K053260_INLINE INT32 limit( INT32 val, INT32 max, INT32 min ) { void K053260Update(INT32 chip, INT16 *pBuf, INT32 length) { +#if defined FBA_DEBUG + if (!DebugSnd_K053260Initted) bprintf(PRINT_ERROR, _T("K053260Update called without init\n")); +#endif + static const INT32 dpcmcnv[] = { 0,1,2,4,8,16,32,64, -128, -64, -32, -16, -8, -4, -2, -1}; INT32 i, j, lvol[4], rvol[4], play[4], loop[4], ppcm_data[4], ppcm[4]; @@ -194,6 +202,8 @@ void K053260Update(INT32 chip, INT16 *pBuf, INT32 length) void K053260Init(INT32 chip, INT32 clock, UINT8 *rom, INT32 nLen) { + DebugSnd_K053260Initted = 1; + ic = &Chips[chip]; memset (ic, 0, sizeof(k053260_chip_def)); @@ -222,6 +232,10 @@ void K053260Init(INT32 chip, INT32 clock, UINT8 *rom, INT32 nLen) void K053260Exit() { +#if defined FBA_DEBUG + if (!DebugSnd_K053260Initted) bprintf(PRINT_ERROR, _T("K053260Exit called without init\n")); +#endif + for (INT32 i = 0; i < 2; i++) { ic = &Chips[i]; @@ -232,6 +246,8 @@ void K053260Exit() } nUpdateStep = 0; + + DebugSnd_K053260Initted = 0; } K053260_INLINE void check_bounds(INT32 channel ) { @@ -252,6 +268,10 @@ K053260_INLINE void check_bounds(INT32 channel ) { void K053260Write(INT32 chip, INT32 offset, UINT8 data) { +#if defined FBA_DEBUG + if (!DebugSnd_K053260Initted) bprintf(PRINT_ERROR, _T("K053260Write called without init\n")); +#endif + INT32 i, t; INT32 r = offset; INT32 v = data; @@ -366,6 +386,10 @@ void K053260Write(INT32 chip, INT32 offset, UINT8 data) UINT8 K053260Read(INT32 chip, INT32 offset) { +#if defined FBA_DEBUG + if (!DebugSnd_K053260Initted) bprintf(PRINT_ERROR, _T("K053260Read called without init\n")); +#endif + ic = & Chips[chip]; switch ( offset ) { @@ -401,6 +425,10 @@ UINT8 K053260Read(INT32 chip, INT32 offset) INT32 K053260Scan(INT32 nAction) { +#if defined FBA_DEBUG + if (!DebugSnd_K053260Initted) bprintf(PRINT_ERROR, _T("K053260Scan called without init\n")); +#endif + struct BurnArea ba; char szName[32]; diff --git a/src/burn/sound/k054539.cpp b/src/burn/sound/k054539.cpp index 6875d9b0a..2ee634bb6 100644 --- a/src/burn/sound/k054539.cpp +++ b/src/burn/sound/k054539.cpp @@ -62,35 +62,59 @@ static INT32 *soundbuf[2]; void K054539_init_flags(INT32 chip, INT32 flags) { +#if defined FBA_DEBUG + if (!DebugSnd_K054539Initted) bprintf(PRINT_ERROR, _T("K054539_init_flags called without init\n")); +#endif + info = &Chips[chip]; info->k054539_flags = flags; } void K054539_set_gain(INT32 chip, INT32 channel, double gain) { +#if defined FBA_DEBUG + if (!DebugSnd_K054539Initted) bprintf(PRINT_ERROR, _T("K054539_set_gain called without init\n")); +#endif + info = &Chips[chip]; if (gain >= 0) info->k054539_gain[channel] = gain; } static INT32 k054539_regupdate() { +#if defined FBA_DEBUG + if (!DebugSnd_K054539Initted) bprintf(PRINT_ERROR, _T("K054539_regupdate called without init\n")); +#endif + return !(info->regs[0x22f] & 0x80); } static void k054539_keyon(INT32 channel) { +#if defined FBA_DEBUG + if (!DebugSnd_K054539Initted) bprintf(PRINT_ERROR, _T("K054539_keyon called without init\n")); +#endif + if(k054539_regupdate()) info->regs[0x22c] |= 1 << channel; } static void k054539_keyoff(INT32 channel) { +#if defined FBA_DEBUG + if (!DebugSnd_K054539Initted) bprintf(PRINT_ERROR, _T("K054539_keyoff called without init\n")); +#endif + if(k054539_regupdate()) info->regs[0x22c] &= ~(1 << channel); } void K054539Write(INT32 chip, INT32 offset, UINT8 data) { +#if defined FBA_DEBUG + if (!DebugSnd_K054539Initted) bprintf(PRINT_ERROR, _T("K054539Write called without init\n")); +#endif + info = &Chips[chip]; INT32 latch, offs, ch, pan; @@ -178,6 +202,10 @@ void K054539Write(INT32 chip, INT32 offset, UINT8 data) UINT8 K054539Read(INT32 chip, INT32 offset) { +#if defined FBA_DEBUG + if (!DebugSnd_K054539Initted) bprintf(PRINT_ERROR, _T("K054539Read called without init\n")); +#endif + info = &Chips[chip]; switch(offset) { @@ -203,6 +231,10 @@ UINT8 K054539Read(INT32 chip, INT32 offset) void K054539Reset(INT32 chip) { +#if defined FBA_DEBUG + if (!DebugSnd_K054539Initted) bprintf(PRINT_ERROR, _T("K054539Reset called without init\n")); +#endif + info = &Chips[chip]; INT32 data = info->regs[0x22e]; info->cur_zone = @@ -240,6 +272,8 @@ static void k054539_init_chip(INT32 clock, UINT8 *rom, INT32 nLen) void K054539Init(INT32 chip, INT32 clock, UINT8 *rom, INT32 nLen) { + DebugSnd_K054539Initted = 1; + static const k054539_interface defintrf = { 0, 0 }; INT32 i; @@ -269,6 +303,10 @@ void K054539Init(INT32 chip, INT32 clock, UINT8 *rom, INT32 nLen) void K054539Exit() { +#if defined FBA_DEBUG + if (!DebugSnd_K054539Initted) bprintf(PRINT_ERROR, _T("K054539Exit called without init\n")); +#endif + if (soundbuf[0] != NULL) { free (soundbuf[0]); soundbuf[0] = NULL; @@ -286,10 +324,16 @@ void K054539Exit() info->ram = NULL; } } + + DebugSnd_K054539Initted = 0; } void K054539Update(INT32 chip, INT16 *pBuf, INT32 length) { +#if defined FBA_DEBUG + if (!DebugSnd_K054539Initted) bprintf(PRINT_ERROR, _T("K054539Update called without init\n")); +#endif + info = &Chips[chip]; #define VOL_CAP 1.80 @@ -543,6 +587,10 @@ else INT32 K054539Scan(INT32 nAction) { +#if defined FBA_DEBUG + if (!DebugSnd_K054539Initted) bprintf(PRINT_ERROR, _T("K054539Scan called without init\n")); +#endif + struct BurnArea ba; char szName[32];