mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-12-28 02:32:08 +00:00
Cmd line: add -wav-speaker <file> & -wav-mockingboard <file>
This commit is contained in:
parent
494aaa04c0
commit
08c730c647
@ -537,6 +537,18 @@ bool ProcessCmdLine(LPSTR lpCmdLine)
|
||||
{
|
||||
g_cmdLine.snesMaxAltControllerType[1] = true;
|
||||
}
|
||||
else if (strcmp(lpCmdLine, "-wav-speaker") == 0)
|
||||
{
|
||||
lpCmdLine = GetCurrArg(lpNextArg);
|
||||
lpNextArg = GetNextArg(lpNextArg);
|
||||
g_cmdLine.wavFileSpeaker = lpCmdLine;
|
||||
}
|
||||
else if (strcmp(lpCmdLine, "-wav-mockingboard") == 0)
|
||||
{
|
||||
lpCmdLine = GetCurrArg(lpNextArg);
|
||||
lpNextArg = GetNextArg(lpNextArg);
|
||||
g_cmdLine.wavFileMockingboard = lpCmdLine;
|
||||
}
|
||||
else // unsupported
|
||||
{
|
||||
LogFileOutput("Unsupported arg: %s\n", lpCmdLine);
|
||||
|
@ -84,6 +84,8 @@ struct CmdLine
|
||||
bool bestFullScreenResolution;
|
||||
UINT userSpecifiedWidth;
|
||||
UINT userSpecifiedHeight;
|
||||
std::string wavFileSpeaker;
|
||||
std::string wavFileMockingboard;
|
||||
};
|
||||
|
||||
bool ProcessCmdLine(LPSTR lpCmdLine);
|
||||
|
@ -185,6 +185,16 @@ static UINT g_cyclesThisAudioFrame = 0;
|
||||
// Forward refs:
|
||||
static int MB_SyncEventCallback(int id, int cycles, ULONG uExecutedCycles);
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static bool g_bMBOutputToRiff = false;
|
||||
|
||||
void MB_OutputToRiff(void)
|
||||
{
|
||||
g_bMBOutputToRiff = true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static bool IsAnyTimer1Active(void)
|
||||
@ -565,9 +575,8 @@ static void MB_UpdateInt(void)
|
||||
|
||||
dwByteOffset = (dwByteOffset + (DWORD)nNumSamples*sizeof(short)*g_nMB_NumChannels) % g_dwDSBufferSize;
|
||||
|
||||
#ifdef RIFF_MB
|
||||
RiffPutSamples(&g_nMixBuffer[0], nNumSamples);
|
||||
#endif
|
||||
if (g_bMBOutputToRiff)
|
||||
RiffPutSamples(&g_nMixBuffer[0], nNumSamples);
|
||||
}
|
||||
|
||||
static void MB_Update(void)
|
||||
|
@ -24,6 +24,7 @@ bool MB_IsActive();
|
||||
DWORD MB_GetVolume();
|
||||
void MB_SetVolume(DWORD dwVolume, DWORD dwVolumeMax);
|
||||
void MB_Get6522IrqDescription(std::string& desc);
|
||||
void MB_OutputToRiff(void);
|
||||
|
||||
void MB_UpdateIRQ(void);
|
||||
UINT64 MB_GetLastCumulativeCycles(void);
|
||||
|
@ -35,12 +35,12 @@ static DWORD dwDataOffset;
|
||||
static DWORD g_dwTotalNumberOfBytesWritten = 0;
|
||||
static unsigned int g_NumChannels = 2;
|
||||
|
||||
int RiffInitWriteFile(const char* pszFile, unsigned int sample_rate, unsigned int NumChannels)
|
||||
bool RiffInitWriteFile(const char* pszFile, unsigned int sample_rate, unsigned int NumChannels)
|
||||
{
|
||||
g_hRiffFile = CreateFile(pszFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
|
||||
if(g_hRiffFile == INVALID_HANDLE_VALUE)
|
||||
return 1;
|
||||
return false;
|
||||
|
||||
g_NumChannels = NumChannels;
|
||||
|
||||
@ -92,13 +92,13 @@ int RiffInitWriteFile(const char* pszFile, unsigned int sample_rate, unsigned in
|
||||
dwDataOffset = SetFilePointer(g_hRiffFile, 0, NULL, FILE_CURRENT);
|
||||
WriteFile(g_hRiffFile, &temp32, 4, &dwNumberOfBytesWritten, NULL);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int RiffFinishWriteFile()
|
||||
bool RiffFinishWriteFile()
|
||||
{
|
||||
if(g_hRiffFile == INVALID_HANDLE_VALUE)
|
||||
return 1;
|
||||
return false;
|
||||
|
||||
//
|
||||
|
||||
@ -114,13 +114,13 @@ int RiffFinishWriteFile()
|
||||
SetFilePointer(g_hRiffFile, dwDataOffset, NULL, FILE_BEGIN);
|
||||
WriteFile(g_hRiffFile, &temp32, 4, &dwNumberOfBytesWritten, NULL);
|
||||
|
||||
return CloseHandle(g_hRiffFile);
|
||||
return CloseHandle(g_hRiffFile) ? true : false;
|
||||
}
|
||||
|
||||
int RiffPutSamples(const short* buf, unsigned int uSamples)
|
||||
bool RiffPutSamples(const short* buf, unsigned int uSamples)
|
||||
{
|
||||
if(g_hRiffFile == INVALID_HANDLE_VALUE)
|
||||
return 1;
|
||||
return false;
|
||||
|
||||
//
|
||||
|
||||
@ -135,5 +135,5 @@ int RiffPutSamples(const short* buf, unsigned int uSamples)
|
||||
|
||||
g_dwTotalNumberOfBytesWritten += dwNumberOfBytesWritten;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
int RiffInitWriteFile(const char* pszFile, unsigned int sample_rate, unsigned int NumChannels);
|
||||
int RiffFinishWriteFile();
|
||||
int RiffPutSamples(const short* buf, unsigned int uSamples);
|
||||
bool RiffInitWriteFile(const char* pszFile, unsigned int sample_rate, unsigned int NumChannels);
|
||||
bool RiffFinishWriteFile(void);
|
||||
bool RiffPutSamples(const short* buf, unsigned int uSamples);
|
||||
|
@ -4,10 +4,6 @@
|
||||
|
||||
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
|
||||
|
||||
// Define max 1 of these:
|
||||
//#define RIFF_SPKR
|
||||
//#define RIFF_MB
|
||||
|
||||
struct VOICE
|
||||
{
|
||||
LPDIRECTSOUNDBUFFER lpDSBvoice;
|
||||
|
@ -92,6 +92,15 @@ static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples);
|
||||
static void Spkr_SetActive(bool bActive);
|
||||
static void Spkr_DSUninit();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static bool g_bSpkrOutputToRiff = false;
|
||||
|
||||
void Spkr_OutputToRiff(void)
|
||||
{
|
||||
g_bSpkrOutputToRiff = true;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
||||
static void DisplayBenchmarkResults ()
|
||||
@ -603,17 +612,15 @@ static ULONG Spkr_SubmitWaveBuffer_FullSpeed(short* pSpeakerBuffer, ULONG nNumSa
|
||||
}
|
||||
|
||||
memcpy(pDSLockedBuffer0, &pSpeakerBuffer[0], dwBufferSize0);
|
||||
#ifdef RIFF_SPKR
|
||||
RiffPutSamples(pDSLockedBuffer0, dwBufferSize0/sizeof(short));
|
||||
#endif
|
||||
if (g_bSpkrOutputToRiff)
|
||||
RiffPutSamples(pDSLockedBuffer0, dwBufferSize0/sizeof(short));
|
||||
nNumSamples = dwBufferSize0/sizeof(short);
|
||||
|
||||
if(pDSLockedBuffer1 && dwBufferSize1)
|
||||
{
|
||||
memcpy(pDSLockedBuffer1, &pSpeakerBuffer[dwDSLockedBufferSize0/sizeof(short)], dwBufferSize1);
|
||||
#ifdef RIFF_SPKR
|
||||
RiffPutSamples(pDSLockedBuffer1, dwBufferSize1/sizeof(short));
|
||||
#endif
|
||||
if (g_bSpkrOutputToRiff)
|
||||
RiffPutSamples(pDSLockedBuffer1, dwBufferSize1/sizeof(short));
|
||||
nNumSamples += dwBufferSize1/sizeof(short);
|
||||
}
|
||||
}
|
||||
@ -628,17 +635,15 @@ static ULONG Spkr_SubmitWaveBuffer_FullSpeed(short* pSpeakerBuffer, ULONG nNumSa
|
||||
if(dwBufferSize0)
|
||||
{
|
||||
wmemset((wchar_t*)pDSLockedBuffer0, (wchar_t)DCFilter(g_nSpeakerData), dwBufferSize0/sizeof(wchar_t));
|
||||
#ifdef RIFF_SPKR
|
||||
RiffPutSamples(pDSLockedBuffer0, dwBufferSize0/sizeof(short));
|
||||
#endif
|
||||
if (g_bSpkrOutputToRiff)
|
||||
RiffPutSamples(pDSLockedBuffer0, dwBufferSize0/sizeof(short));
|
||||
}
|
||||
|
||||
if(pDSLockedBuffer1)
|
||||
{
|
||||
wmemset((wchar_t*)pDSLockedBuffer1, (wchar_t)DCFilter(g_nSpeakerData), dwBufferSize1/sizeof(wchar_t));
|
||||
#ifdef RIFF_SPKR
|
||||
RiffPutSamples(pDSLockedBuffer1, dwBufferSize1/sizeof(short));
|
||||
#endif
|
||||
if (g_bSpkrOutputToRiff)
|
||||
RiffPutSamples(pDSLockedBuffer1, dwBufferSize1/sizeof(short));
|
||||
}
|
||||
}
|
||||
|
||||
@ -782,16 +787,14 @@ static ULONG Spkr_SubmitWaveBuffer(short* pSpeakerBuffer, ULONG nNumSamples)
|
||||
}
|
||||
|
||||
memcpy(pDSLockedBuffer0, &pSpeakerBuffer[0], dwDSLockedBufferSize0);
|
||||
#ifdef RIFF_SPKR
|
||||
RiffPutSamples(pDSLockedBuffer0, dwDSLockedBufferSize0/sizeof(short));
|
||||
#endif
|
||||
if (g_bSpkrOutputToRiff)
|
||||
RiffPutSamples(pDSLockedBuffer0, dwDSLockedBufferSize0/sizeof(short));
|
||||
|
||||
if(pDSLockedBuffer1)
|
||||
{
|
||||
memcpy(pDSLockedBuffer1, &pSpeakerBuffer[dwDSLockedBufferSize0/sizeof(short)], dwDSLockedBufferSize1);
|
||||
#ifdef RIFF_SPKR
|
||||
RiffPutSamples(pDSLockedBuffer1, dwDSLockedBufferSize1/sizeof(short));
|
||||
#endif
|
||||
if (g_bSpkrOutputToRiff)
|
||||
RiffPutSamples(pDSLockedBuffer1, dwDSLockedBufferSize1/sizeof(short));
|
||||
}
|
||||
|
||||
// Commit sound buffer
|
||||
|
@ -30,6 +30,7 @@ void Spkr_Mute();
|
||||
void Spkr_Unmute();
|
||||
bool Spkr_IsActive();
|
||||
bool Spkr_DSInit();
|
||||
void Spkr_OutputToRiff(void);
|
||||
void SpkrSaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
|
||||
void SpkrLoadSnapshot(class YamlLoadHelper& yamlLoadHelper);
|
||||
|
||||
|
@ -616,14 +616,17 @@ static void GetAppleWinVersion(void)
|
||||
// DO ONE-TIME INITIALIZATION
|
||||
static void OneTimeInitialization(HINSTANCE passinstance)
|
||||
{
|
||||
#if 0
|
||||
#ifdef RIFF_SPKR
|
||||
RiffInitWriteFile("Spkr.wav", SPKR_SAMPLE_RATE, 1);
|
||||
#endif
|
||||
#ifdef RIFF_MB
|
||||
RiffInitWriteFile("Mockingboard.wav", 44100, 2);
|
||||
#endif
|
||||
#endif
|
||||
// Currently only support one RIFF file
|
||||
if (!g_cmdLine.wavFileSpeaker.empty())
|
||||
{
|
||||
if (RiffInitWriteFile(g_cmdLine.wavFileSpeaker.c_str(), SPKR_SAMPLE_RATE, 1))
|
||||
Spkr_OutputToRiff();
|
||||
}
|
||||
else if (!g_cmdLine.wavFileMockingboard.empty())
|
||||
{
|
||||
if (RiffInitWriteFile(g_cmdLine.wavFileMockingboard.c_str(), 44100, 2))
|
||||
MB_OutputToRiff();
|
||||
}
|
||||
|
||||
// Initialize COM - so we can use CoCreateInstance
|
||||
// . DSInit() & DIMouse::DirectInputInit are done when g_hFrameWindow is created (WM_CREATE)
|
||||
|
Loading…
Reference in New Issue
Block a user