SAM: Clean up before merge
This commit is contained in:
parent
feccde41bf
commit
c052d10d2f
6 changed files with 80 additions and 75 deletions
|
@ -686,6 +686,14 @@
|
|||
RelativePath=".\source\Riff.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\source\SAM.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\source\SAM.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\source\SaveState.cpp"
|
||||
>
|
||||
|
|
|
@ -118,10 +118,10 @@ BOOL CPageSound::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM
|
|||
SendDlgItemMessage(hWnd,IDC_MB_VOLUME,TBM_SETTICFREQ,10,0);
|
||||
SendDlgItemMessage(hWnd,IDC_MB_VOLUME,TBM_SETPOS,1,MB_GetVolume());
|
||||
|
||||
if (g_Slot5 == CT_SAM)
|
||||
if (g_Slot5 == CT_SAM)
|
||||
m_NewCardType = CT_SAM;
|
||||
else
|
||||
m_NewCardType = MB_GetSoundcardType(); // Reinit 1st time page is activated (fires before PSN_SETACTIVE)
|
||||
else
|
||||
m_NewCardType = MB_GetSoundcardType(); // Reinit 1st time page is activated (fires before PSN_SETACTIVE)
|
||||
|
||||
InitOptions(hWnd);
|
||||
|
||||
|
@ -163,7 +163,7 @@ void CPageSound::InitOptions(HWND hWnd)
|
|||
m_nCurrentIDCheckButton = IDC_PHASOR_ENABLE;
|
||||
else if(m_NewCardType == CT_SAM)
|
||||
m_nCurrentIDCheckButton = IDC_SAM_ENABLE;
|
||||
else
|
||||
else
|
||||
m_nCurrentIDCheckButton = IDC_SOUNDCARD_DISABLE;
|
||||
|
||||
CheckRadioButton(hWnd, IDC_MB_ENABLE, IDC_SOUNDCARD_DISABLE, m_nCurrentIDCheckButton);
|
||||
|
@ -178,20 +178,20 @@ void CPageSound::InitOptions(HWND hWnd)
|
|||
|
||||
// Phasor button
|
||||
{
|
||||
const BOOL bEnable = bIsSlot4Empty || Slot4 == CT_MockingboardC || Slot4 == CT_Phasor;
|
||||
const BOOL bEnable = bIsSlot4Empty || Slot4 == CT_MockingboardC || Slot4 == CT_Phasor;
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_PHASOR_ENABLE), bEnable); // Disable Phasor (slot 4)
|
||||
}
|
||||
|
||||
// Mockingboard button
|
||||
{
|
||||
const BOOL bEnable = (bIsSlot4Empty || Slot4 == CT_Phasor || Slot4 == CT_MockingboardC) &&
|
||||
(bIsSlot5Empty || Slot5 == CT_SAM || Slot5 == CT_MockingboardC);
|
||||
(bIsSlot5Empty || Slot5 == CT_SAM || Slot5 == CT_MockingboardC);
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_MB_ENABLE), bEnable); // Disable Mockingboard (slot 4 & 5)
|
||||
}
|
||||
|
||||
// SAM button
|
||||
// SAM button
|
||||
{
|
||||
const BOOL bEnable = bIsSlot5Empty || Slot5 == CT_MockingboardC || Slot5 == CT_SAM;
|
||||
const BOOL bEnable = bIsSlot5Empty || Slot5 == CT_MockingboardC || Slot5 == CT_SAM;
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_SAM_ENABLE), bEnable); // Disable SAM (slot 5)
|
||||
}
|
||||
|
||||
|
@ -223,17 +223,17 @@ bool CPageSound::NewSoundcardConfigured(HWND hWnd, WPARAM wparam, SS_CARDTYPE Ne
|
|||
m_PropertySheetHelper.GetConfigNew().m_Slot[5] = CT_Empty;
|
||||
}
|
||||
else if (NewCardType == CT_SAM)
|
||||
{
|
||||
if ((Slot4 == CT_MockingboardC) || (Slot4 == CT_Phasor))
|
||||
{
|
||||
if ((Slot4 == CT_MockingboardC) || (Slot4 == CT_Phasor))
|
||||
m_PropertySheetHelper.GetConfigNew().m_Slot[4] = CT_Empty;
|
||||
m_PropertySheetHelper.GetConfigNew().m_Slot[5] = CT_SAM;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((Slot4 == CT_MockingboardC) || (Slot4 == CT_Phasor))
|
||||
m_PropertySheetHelper.GetConfigNew().m_Slot[4] = CT_Empty;
|
||||
m_PropertySheetHelper.GetConfigNew().m_Slot[4] = CT_Empty;
|
||||
if ((Slot5 == CT_MockingboardC) || (Slot5 == CT_SAM))
|
||||
m_PropertySheetHelper.GetConfigNew().m_Slot[5] = CT_Empty;
|
||||
m_PropertySheetHelper.GetConfigNew().m_Slot[5] = CT_Empty;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -42,56 +42,52 @@
|
|||
//
|
||||
|
||||
|
||||
static BYTE __stdcall IOWrite_SAM(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft)
|
||||
static BYTE __stdcall IOWrite_SAM(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft)
|
||||
{
|
||||
// Emulate audio from a SAM / 8 bit DAC card
|
||||
// Only supportable if AppleWin is using WAVE output
|
||||
//
|
||||
// This works by using the existing speaker handling but then
|
||||
// replacing the speaker audio with the 8 bit samples from the DAC
|
||||
// before they get sent out to the soundcard buffer, whilst
|
||||
// audio samples are being written to the SAM.
|
||||
//
|
||||
// Whilst very unusual, it is possible to intermingle use of SAM and the apple
|
||||
// speaker. This is crudely supported with g_quieterSpeaker making the Apple
|
||||
// speaker produce quieter clicks which will be crudely intermingled
|
||||
// with the SAM data. The mute gets reset after the speaker code detects
|
||||
// silence.
|
||||
// Emulate audio from a SAM / 8 bit DAC card
|
||||
// Only supportable if AppleWin is using WAVE output
|
||||
//
|
||||
// This works by using the existing speaker handling but then
|
||||
// replacing the speaker audio with the 8 bit samples from the DAC
|
||||
// before they get sent out to the soundcard buffer, whilst
|
||||
// audio samples are being written to the SAM.
|
||||
//
|
||||
// Whilst very unusual, it is possible to intermingle use of SAM and the apple
|
||||
// speaker. This is crudely supported with g_bQuieterSpeaker making the Apple
|
||||
// speaker produce quieter clicks which will be crudely intermingled
|
||||
// with the SAM data. The mute gets reset after the speaker code detects
|
||||
// silence.
|
||||
|
||||
byte mb_res;
|
||||
if (soundtype != SOUND_WAVE)
|
||||
return MemReadFloatingBus(nCyclesLeft);
|
||||
|
||||
if (soundtype == SOUND_WAVE)
|
||||
{
|
||||
// use existing speaker code to bring timing up to date
|
||||
mb_res = SpkrToggle(pc, addr, bWrite, d, nCyclesLeft);
|
||||
// use existing speaker code to bring timing up to date
|
||||
BYTE res = SpkrToggle(pc, addr, bWrite, d, nCyclesLeft);
|
||||
|
||||
// The DAC in the SAM uses unsigned 8 bit samples
|
||||
// The WAV data that g_nSpeakerData is loaded into is a signed short
|
||||
//
|
||||
// We convert unsigned 8 bit to signed by toggling the most significant bit
|
||||
//
|
||||
// SAM card WAV driver SAM WAV
|
||||
// 0xFF 255 0x7f 127 _ FF 7F
|
||||
// 0x81 129 0x01 1 / \
|
||||
// 0x80 128 0x00 0 / \ /80 00
|
||||
// 0x7f 127 0xFF -1 \_/
|
||||
// 0x00 0 0x80 -128 00 80
|
||||
//
|
||||
// SAM is 8 bit, PC WAV is 16 so shift audio to the MSB (<< 8)
|
||||
// The DAC in the SAM uses unsigned 8 bit samples
|
||||
// The WAV data that g_nSpeakerData is loaded into is a signed short
|
||||
//
|
||||
// We convert unsigned 8 bit to signed by toggling the most significant bit
|
||||
//
|
||||
// SAM card WAV driver SAM WAV
|
||||
// 0xFF 255 0x7f 127 _ FF 7F
|
||||
// 0x81 129 0x01 1 / \
|
||||
// 0x80 128 0x00 0 / \ /80 00
|
||||
// 0x7f 127 0xFF -1 \_/
|
||||
// 0x00 0 0x80 -128 00 80
|
||||
//
|
||||
// SAM is 8 bit, PC WAV is 16 so shift audio to the MSB (<< 8)
|
||||
|
||||
g_nSpeakerData = (d ^ 0x80) << 8;
|
||||
g_nSpeakerData = (d ^ 0x80) << 8;
|
||||
|
||||
// make speaker quieter so eg: a metronome click through the
|
||||
// Apple speaker is softer vs. the analogue SAM output.
|
||||
g_quieterSpeaker = 1;
|
||||
}
|
||||
else
|
||||
mb_res = MemReadFloatingBus(nCyclesLeft);
|
||||
// make speaker quieter so eg: a metronome click through the
|
||||
// Apple speaker is softer vs. the analogue SAM output.
|
||||
g_bQuieterSpeaker = true;
|
||||
|
||||
return mb_res;
|
||||
return res;
|
||||
}
|
||||
|
||||
void ConfigureSAM(LPBYTE pCxRomPeripheral, UINT uSlot)
|
||||
{
|
||||
RegisterIoHandler(uSlot,IO_Null,IOWrite_SAM,IO_Null,IO_Null, NULL, NULL);
|
||||
{
|
||||
RegisterIoHandler(uSlot, IO_Null, IOWrite_SAM, IO_Null, IO_Null, NULL, NULL);
|
||||
}
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
// SAM speech card (8 bit DAC):
|
||||
#pragma once
|
||||
|
||||
void ConfigureSAM(LPBYTE pCxRomPeripheral, UINT uSlot);
|
||||
|
|
|
@ -73,7 +73,7 @@ DWORD soundtype = SOUND_WAVE;
|
|||
double g_fClksPerSpkrSample; // Setup in SetClksPerSpkrSample()
|
||||
|
||||
// Allow temporary quietening of speaker (8 bit DAC)
|
||||
UINT g_quieterSpeaker = 0;
|
||||
bool g_bQuieterSpeaker = false;
|
||||
|
||||
// Globals
|
||||
static DWORD lastcyclenum = 0;
|
||||
|
@ -444,19 +444,21 @@ BYTE __stdcall SpkrToggle (WORD, WORD, BYTE, BYTE, ULONG nCyclesLeft)
|
|||
|
||||
UpdateSpkr();
|
||||
|
||||
// quieten the speaker if 8 bit DAC in use
|
||||
|
||||
// g_nSpeakerData = ~g_nSpeakerData;
|
||||
if (g_quieterSpeaker)
|
||||
if (g_nSpeakerData == (SPKR_DATA_INIT >> 2))
|
||||
g_nSpeakerData = ~g_nSpeakerData;
|
||||
else
|
||||
g_nSpeakerData = SPKR_DATA_INIT>>2;
|
||||
else
|
||||
if (g_nSpeakerData == SPKR_DATA_INIT)
|
||||
g_nSpeakerData = ~g_nSpeakerData;
|
||||
else
|
||||
g_nSpeakerData = SPKR_DATA_INIT;
|
||||
if (g_bQuieterSpeaker)
|
||||
{
|
||||
// quieten the speaker if 8 bit DAC in use
|
||||
if (g_nSpeakerData == (SPKR_DATA_INIT >> 2))
|
||||
g_nSpeakerData = ~g_nSpeakerData;
|
||||
else
|
||||
g_nSpeakerData = SPKR_DATA_INIT>>2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_nSpeakerData == SPKR_DATA_INIT)
|
||||
g_nSpeakerData = ~g_nSpeakerData;
|
||||
else
|
||||
g_nSpeakerData = SPKR_DATA_INIT;
|
||||
}
|
||||
}
|
||||
else if (soundtype != SOUND_NONE)
|
||||
{
|
||||
|
@ -1002,7 +1004,7 @@ static void Spkr_SetActive(bool bActive)
|
|||
// Called by SpkrUpdate() after 0.2s of speaker inactivity
|
||||
g_bSpkrRecentlyActive = false;
|
||||
SpeakerVoice.bRecentlyActive = false;
|
||||
g_quieterSpeaker = 0; // undo any muting (for 8 bit DAC)
|
||||
g_bQuieterSpeaker = 0; // undo any muting (for 8 bit DAC)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
extern DWORD soundtype;
|
||||
extern double g_fClksPerSpkrSample;
|
||||
extern UINT g_quieterSpeaker;
|
||||
extern bool g_bQuieterSpeaker;
|
||||
extern short g_nSpeakerData;
|
||||
|
||||
void SpkrDestroy ();
|
||||
|
@ -30,5 +30,3 @@ DWORD SpkrGetSnapshot(SS_IO_Speaker* pSS);
|
|||
DWORD SpkrSetSnapshot(SS_IO_Speaker* pSS);
|
||||
|
||||
BYTE __stdcall SpkrToggle (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue