mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-12-22 09:30:15 +00:00
Logging: add more logging to Speaker code
Debug: add a debug-enabled MB S/S card
This commit is contained in:
parent
60ddf0fa35
commit
5bc1261281
@ -93,6 +93,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "AY8910.h"
|
||||
#include "SSI263.h"
|
||||
|
||||
#define DBG_MB_SS_CARD 0 // From UI, select Mockingboard (not Phasor)
|
||||
|
||||
#define SY6522_DEVICE_A 0
|
||||
#define SY6522_DEVICE_B 1
|
||||
@ -621,6 +622,10 @@ static void SY6522_Write(BYTE nDevice, BYTE nReg, BYTE nValue)
|
||||
break;
|
||||
}
|
||||
|
||||
#if DBG_MB_SS_CARD
|
||||
if ((nDevice & 1) == 1)
|
||||
AY8910_Write(nDevice, nReg, nValue, 0);
|
||||
#else
|
||||
if(g_bPhasorEnable)
|
||||
{
|
||||
int nAY_CS = (g_phasorMode == PH_Phasor) ? (~(nValue >> 3) & 3) : 1;
|
||||
@ -635,6 +640,7 @@ static void SY6522_Write(BYTE nDevice, BYTE nReg, BYTE nValue)
|
||||
{
|
||||
AY8910_Write(nDevice, nReg, nValue, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1311,6 +1317,11 @@ static BYTE __stdcall MB_Read(WORD PC, WORD nAddr, BYTE bWrite, BYTE nValue, ULO
|
||||
return bAccessedDevice ? nRes : MemReadFloatingBus(nExecutedCycles);
|
||||
}
|
||||
|
||||
#if DBG_MB_SS_CARD
|
||||
if (nMB == 1)
|
||||
return MemReadFloatingBus(nExecutedCycles);
|
||||
#endif
|
||||
|
||||
// NB. Mockingboard: SSI263.bit7 not readable (TODO: check this with real h/w)
|
||||
if (nOffset < SY6522B_Offset)
|
||||
return SY6522_Read(nMB*NUM_DEVS_PER_MB + SY6522_DEVICE_A, nAddr&0xf);
|
||||
@ -1410,10 +1421,12 @@ static BYTE __stdcall MB_Write(WORD PC, WORD nAddr, BYTE bWrite, BYTE nValue, UL
|
||||
else
|
||||
SY6522_Write(nMB*NUM_DEVS_PER_MB + SY6522_DEVICE_B, nAddr&0xf, nValue);
|
||||
|
||||
#if !DBG_MB_SS_CARD
|
||||
if (nAddr & 0x40)
|
||||
g_MB[nMB*2+1].ssi263.Write(nAddr&0x7, nValue); // 2nd 6522 is used for 1st speech chip
|
||||
if (nAddr & 0x20)
|
||||
g_MB[nMB*2+0].ssi263.Write(nAddr&0x7, nValue); // 1st 6522 is used for 2nd speech chip
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -237,10 +237,12 @@ void SpkrInitialize ()
|
||||
if(g_bDisableDirectSound)
|
||||
{
|
||||
SpeakerVoice.bMute = true;
|
||||
LogFileOutput("SpkrInitialize: g_bDisableDirectSound=1... SpeakerVoice.bMute=true\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_bSpkrAvailable = Spkr_DSInit();
|
||||
LogFileOutput("Spkr_DSInit(), res=%d\n", g_bSpkrAvailable ? 1 : 0);
|
||||
if (!g_bSpkrAvailable)
|
||||
{
|
||||
GetFrame().FrameMessageBox(
|
||||
@ -673,7 +675,8 @@ static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples)
|
||||
|
||||
// Don't call DSZeroVoiceBuffer() - get noise with "VIA AC'97 Enhanced Audio Controller"
|
||||
// . I guess SpeakerVoice.Stop() isn't really working and the new zero buffer causes noise corruption when submitted.
|
||||
DSZeroVoiceWritableBuffer(&SpeakerVoice, g_dwDSSpkrBufferSize);
|
||||
bool res = DSZeroVoiceWritableBuffer(&SpeakerVoice, g_dwDSSpkrBufferSize);
|
||||
LogFileOutput("Spkr_SubmitWaveBuffer: DSZeroVoiceWritableBuffer, res=%d\n", res ? 1 : 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -686,8 +689,11 @@ static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples)
|
||||
|
||||
DWORD dwCurrentPlayCursor, dwCurrentWriteCursor;
|
||||
HRESULT hr = SpeakerVoice.lpDSBvoice->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor);
|
||||
if(FAILED(hr))
|
||||
if (FAILED(hr))
|
||||
{
|
||||
LogFileOutput("Spkr_SubmitWaveBuffer: GetCurrentPosition failed (%08X)\n", hr);
|
||||
return nNumSamples;
|
||||
}
|
||||
|
||||
if(dwByteOffset == (DWORD)-1)
|
||||
{
|
||||
@ -771,11 +777,14 @@ static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples)
|
||||
{
|
||||
//sprintf(szDbg, "[Submit] C=%08X, PC=%08X, WC=%08X, Diff=%08X, Off=%08X, NS=%08X +++\n", nDbgSpkrCnt, dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor, dwByteOffset, nNumSamplesToUse); OutputDebugString(szDbg);
|
||||
|
||||
if(!DSGetLock(SpeakerVoice.lpDSBvoice,
|
||||
dwByteOffset, (DWORD)nNumSamplesToUse*sizeof(short),
|
||||
&pDSLockedBuffer0, &dwDSLockedBufferSize0,
|
||||
&pDSLockedBuffer1, &dwDSLockedBufferSize1))
|
||||
if (!DSGetLock(SpeakerVoice.lpDSBvoice,
|
||||
dwByteOffset, (DWORD)nNumSamplesToUse * sizeof(short),
|
||||
&pDSLockedBuffer0, &dwDSLockedBufferSize0,
|
||||
&pDSLockedBuffer1, &dwDSLockedBufferSize1))
|
||||
{
|
||||
LogFileOutput("Spkr_SubmitWaveBuffer: DSGetLock failed\n");
|
||||
return nNumSamples;
|
||||
}
|
||||
|
||||
memcpy(pDSLockedBuffer0, &pSpeakerBuffer[0], dwDSLockedBufferSize0);
|
||||
#ifdef RIFF_SPKR
|
||||
@ -793,8 +802,11 @@ static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples)
|
||||
// Commit sound buffer
|
||||
hr = SpeakerVoice.lpDSBvoice->Unlock((void*)pDSLockedBuffer0, dwDSLockedBufferSize0,
|
||||
(void*)pDSLockedBuffer1, dwDSLockedBufferSize1);
|
||||
if(FAILED(hr))
|
||||
if (FAILED(hr))
|
||||
{
|
||||
LogFileOutput("Spkr_SubmitWaveBuffer: Unlock failed (%08X)\n", hr);
|
||||
return nNumSamples;
|
||||
}
|
||||
|
||||
dwByteOffset = (dwByteOffset + (DWORD)nNumSamplesToUse*sizeof(short)*g_nSPKR_NumChannels) % g_dwDSSpkrBufferSize;
|
||||
}
|
||||
@ -804,20 +816,24 @@ static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// NB. Not currently used
|
||||
void Spkr_Mute()
|
||||
{
|
||||
if(SpeakerVoice.bActive && !SpeakerVoice.bMute)
|
||||
{
|
||||
SpeakerVoice.lpDSBvoice->SetVolume(DSBVOLUME_MIN);
|
||||
HRESULT hr = SpeakerVoice.lpDSBvoice->SetVolume(DSBVOLUME_MIN);
|
||||
LogFileOutput("Spkr_Mute: SetVolume(%d) res = %08X\n", DSBVOLUME_MIN, hr);
|
||||
SpeakerVoice.bMute = true;
|
||||
}
|
||||
}
|
||||
|
||||
// NB. Only called by SpkrReset()
|
||||
void Spkr_Unmute()
|
||||
{
|
||||
if(SpeakerVoice.bActive && SpeakerVoice.bMute)
|
||||
{
|
||||
SpeakerVoice.lpDSBvoice->SetVolume(SpeakerVoice.nVolume);
|
||||
HRESULT hr = SpeakerVoice.lpDSBvoice->SetVolume(SpeakerVoice.nVolume);
|
||||
LogFileOutput("Spkr_Unmute: SetVolume(%d) res = %08X\n", SpeakerVoice.nVolume, hr);
|
||||
SpeakerVoice.bMute = false;
|
||||
}
|
||||
}
|
||||
@ -865,7 +881,10 @@ void SpkrSetVolume(DWORD dwVolume, DWORD dwVolumeMax)
|
||||
SpeakerVoice.nVolume = NewVolume(dwVolume, dwVolumeMax);
|
||||
|
||||
if (SpeakerVoice.bActive && !SpeakerVoice.bMute)
|
||||
SpeakerVoice.lpDSBvoice->SetVolume(SpeakerVoice.nVolume);
|
||||
{
|
||||
HRESULT hr = SpeakerVoice.lpDSBvoice->SetVolume(SpeakerVoice.nVolume);
|
||||
LogFileOutput("SpkrSetVolume: SetVolume(%d) res = %08X\n", SpeakerVoice.nVolume, hr);
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -876,20 +895,26 @@ bool Spkr_DSInit()
|
||||
// Create single Apple speaker voice
|
||||
//
|
||||
|
||||
if(!g_bDSAvailable)
|
||||
if (!g_bDSAvailable)
|
||||
{
|
||||
LogFileOutput("Spkr_DSInit: g_bDSAvailable=0\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
SpeakerVoice.bIsSpeaker = true;
|
||||
|
||||
HRESULT hr = DSGetSoundBuffer(&SpeakerVoice, DSBCAPS_CTRLVOLUME, g_dwDSSpkrBufferSize, SPKR_SAMPLE_RATE, 1, "Spkr");
|
||||
if(FAILED(hr))
|
||||
if (FAILED(hr))
|
||||
{
|
||||
LogFileOutput("Spkr: DSGetSoundBuffer failed (%08X)\n", hr);
|
||||
LogFileOutput("Spkr_DSInit: DSGetSoundBuffer failed (%08X)\n", hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!DSZeroVoiceBuffer(&SpeakerVoice, g_dwDSSpkrBufferSize))
|
||||
if (!DSZeroVoiceBuffer(&SpeakerVoice, g_dwDSSpkrBufferSize))
|
||||
{
|
||||
LogFileOutput("Spkr_DSInit: DSZeroVoiceBuffer failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
SpeakerVoice.bActive = true;
|
||||
|
||||
@ -897,19 +922,23 @@ bool Spkr_DSInit()
|
||||
if(!SpeakerVoice.nVolume)
|
||||
SpeakerVoice.nVolume = DSBVOLUME_MAX;
|
||||
|
||||
SpeakerVoice.lpDSBvoice->SetVolume(SpeakerVoice.nVolume);
|
||||
hr = SpeakerVoice.lpDSBvoice->SetVolume(SpeakerVoice.nVolume);
|
||||
LogFileOutput("Spkr_DSInit: SetVolume(%d) res = %08X\n", SpeakerVoice.nVolume, hr);
|
||||
|
||||
//
|
||||
|
||||
DWORD dwCurrentPlayCursor, dwCurrentWriteCursor;
|
||||
hr = SpeakerVoice.lpDSBvoice->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor);
|
||||
if(SUCCEEDED(hr) && (dwCurrentPlayCursor == dwCurrentWriteCursor))
|
||||
if (FAILED(hr))
|
||||
LogFileOutput("Spkr_DSInit: GetCurrentPosition failed (%08X)\n", hr);
|
||||
if (SUCCEEDED(hr) && (dwCurrentPlayCursor == dwCurrentWriteCursor))
|
||||
{
|
||||
// KLUDGE: For my WinXP PC with "VIA AC'97 Enhanced Audio Controller"
|
||||
// . Not required for my Win98SE/WinXP PC with PCI "Soundblaster Live!"
|
||||
Sleep(200);
|
||||
|
||||
hr = SpeakerVoice.lpDSBvoice->GetCurrentPosition(&dwCurrentPlayCursor, &dwCurrentWriteCursor);
|
||||
LogFileOutput("Spkr_DSInit: GetCurrentPosition kludge (%08X)\n", hr);
|
||||
char szDbg[100];
|
||||
sprintf(szDbg, "[DSInit] PC=%08X, WC=%08X, Diff=%08X\n", dwCurrentPlayCursor, dwCurrentWriteCursor, dwCurrentWriteCursor-dwCurrentPlayCursor); OutputDebugString(szDbg);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user