rename SAM to DAC functions

This commit is contained in:
unknown 2015-03-30 17:27:51 +09:00
parent fa43e909ed
commit feccde41bf
3 changed files with 32 additions and 20 deletions

View File

@ -1297,7 +1297,7 @@ void MemInitialize()
}
else
if (g_Slot5 == CT_SAM)
ConfigureDAC(pCxRomPeripheral, 5); // $C500 : Z80 card
ConfigureSAM(pCxRomPeripheral, 5); // $C500 : Z80 card
DiskLoadRom(pCxRomPeripheral, 6); // $C600 : Disk][ f/w
HD_Load_Rom(pCxRomPeripheral, 7); // $C700 : HDD f/w

View File

@ -42,13 +42,21 @@
//
static BYTE __stdcall IOWrite_DAC(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 an 8 bit DAC
// only if using wave data
// uses the existing speaker for the timing but then
// substitutes the analog data which gets subsequently
// sent to audio out
// 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.
byte mb_res;
@ -57,20 +65,24 @@ static BYTE __stdcall IOWrite_DAC(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULON
// use existing speaker code to bring timing up to date
mb_res = SpkrToggle(pc, addr, bWrite, d, nCyclesLeft);
// 8 bit card WAV driver (scaled by 256)
// 0xFF 255 0x7f 127
// 0x80 128 0x00 0
// 0x7f 127 0xFF -1
// 0x00 0 0x80 -128
// replace regular speaker output with 8 bit DAC value
// regular speaker data still audible but quieter until speaker
// goes idle (so both work simultaneously)
// 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;
// make speaker quieter so eg: a metronome click through the
// Apple speaker is softer vs. the analogue SAM output
// Apple speaker is softer vs. the analogue SAM output.
g_quieterSpeaker = 1;
}
else
@ -79,7 +91,7 @@ static BYTE __stdcall IOWrite_DAC(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULON
return mb_res;
}
void ConfigureDAC(LPBYTE pCxRomPeripheral, UINT uSlot)
void ConfigureSAM(LPBYTE pCxRomPeripheral, UINT uSlot)
{
RegisterIoHandler(uSlot,IO_Null,IOWrite_DAC,IO_Null,IO_Null, NULL, NULL);
RegisterIoHandler(uSlot,IO_Null,IOWrite_SAM,IO_Null,IO_Null, NULL, NULL);
}

View File

@ -1,2 +1,2 @@
// SAM speech card (8 bit DAC):
void ConfigureDAC(LPBYTE pCxRomPeripheral, UINT uSlot);
void ConfigureSAM(LPBYTE pCxRomPeripheral, UINT uSlot);