From 1b54291b1f019786bb942dee23f22e10a0b85578 Mon Sep 17 00:00:00 2001 From: tomcw Date: Sat, 2 Jul 2022 11:26:07 +0100 Subject: [PATCH] Spkr: more logging for very fine C030 accesses; 48000Hz; spkr data: 0x8001/0x7FFF --- source/Common.h | 2 +- source/Speaker.cpp | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/source/Common.h b/source/Common.h index 98256d9e..2fb8efaf 100644 --- a/source/Common.h +++ b/source/Common.h @@ -13,7 +13,7 @@ const double CLK_6502_PAL = (_14M_PAL * 65.0) / (65.0*14.0+2.0); // Use a base freq so that DirectX (or sound h/w) doesn't have to up/down-sample // Assume base freqs are 44.1KHz & 48KHz -const DWORD SPKR_SAMPLE_RATE = 44100; +const DWORD SPKR_SAMPLE_RATE = 48000; // 44100; enum AppMode_e { diff --git a/source/Speaker.cpp b/source/Speaker.cpp index fc972fd9..d2115da1 100644 --- a/source/Speaker.cpp +++ b/source/Speaker.cpp @@ -61,7 +61,7 @@ static const DWORD g_dwDSSpkrBufferSize = MAX_SAMPLES * sizeof(short) * g_nSPKR_ static short* g_pSpeakerBuffer = NULL; // Globals (SOUND_WAVE) -const short SPKR_DATA_INIT = (short)0x8000; +const short SPKR_DATA_INIT = (short)0x8001; short g_nSpeakerData = SPKR_DATA_INIT; static UINT g_nBufferIdx = 0; @@ -322,8 +322,14 @@ static void ReinitRemainderBuffer(UINT nCyclesRemaining) _ASSERT(g_nRemainderBufferIdx < g_nRemainderBufferSize); } +static int g_count = 0; +static bool g_flag = false; static void UpdateRemainderBuffer(ULONG* pnCycleDiff) { + const bool flag = *pnCycleDiff <= g_nRemainderBufferSize; // gap between $C030 accesses is less than a 44.1kHz sample + if (regs.pc < 0xc000 && !g_flag && flag) + g_flag = false;// true; + if(g_nRemainderBufferIdx) { while((g_nRemainderBufferIdx < g_nRemainderBufferSize) && *pnCycleDiff) @@ -339,12 +345,25 @@ static void UpdateRemainderBuffer(ULONG* pnCycleDiff) signed long nSampleMean = 0; for(UINT i=0; i