Merge branch 'rmacri-master'

This commit is contained in:
tomcw 2015-04-09 22:55:01 +01:00
commit 565fd7967b
13 changed files with 211 additions and 51 deletions

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug NoDX|Win32">
@ -125,6 +125,7 @@
<ClCompile Include="source\Configuration\PropertySheet.cpp" />
<ClCompile Include="source\Configuration\PropertySheetHelper.cpp" />
<ClCompile Include="source\CPU.cpp" />
<ClCompile Include="source\SAM.cpp" />
<ClCompile Include="source\Debugger\Debug.cpp" />
<ClCompile Include="source\Debugger\Debugger_Assembler.cpp" />
<ClCompile Include="source\Debugger\Debugger_Color.cpp" />
@ -419,4 +420,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="source\Applewin.cpp">
@ -169,6 +169,9 @@
<ClCompile Include="source\Debugger\Util_MemoryTextFile.cpp">
<Filter>Source Files\Debugger</Filter>
</ClCompile>
<ClCompile Include="source\SAM.cpp">
<Filter>Source Files\Emulator</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="source\Applewin.h">
@ -644,4 +647,4 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
</Project>

View File

@ -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"
>

BIN
Disks/SAM Slot 5.dsk Normal file

Binary file not shown.

View File

@ -154,10 +154,11 @@ BEGIN
CONTROL "Slider1",IDC_SPKR_VOLUME,"msctls_trackbar32",TBS_AUTOTICKS | TBS_VERT | TBS_BOTH | WS_TABSTOP,13,47,28,60
LTEXT "&Mockingboard:",IDC_STATIC,49,39,51,8
CONTROL "Slider1",IDC_MB_VOLUME,"msctls_trackbar32",TBS_AUTOTICKS | TBS_VERT | TBS_BOTH | WS_TABSTOP,59,47,25,60
GROUPBOX "Sound Cards",IDC_STATIC,6,122,197,61
GROUPBOX "Sound Cards",IDC_STATIC,6,122,197,64
CONTROL "Mockingboards (in slots 4 && 5)",IDC_MB_ENABLE,"Button",BS_AUTORADIOBUTTON,10,136,142,8
CONTROL "Phasor (in slot 4)",IDC_PHASOR_ENABLE,"Button",BS_AUTORADIOBUTTON,10,149,92,10
CONTROL "No sound cards",IDC_SOUNDCARD_DISABLE,"Button",BS_AUTORADIOBUTTON,10,163,78,10
CONTROL "SAM/DAC (in slot 5)",IDC_SAM_ENABLE,"Button",BS_AUTORADIOBUTTON,10,162,95,10
CONTROL "No sound cards",IDC_SOUNDCARD_DISABLE,"Button",BS_AUTORADIOBUTTON,10,175,78,10
END
IDD_PROPPAGE_DISK DIALOGEX 0, 0, 211, 188

View File

@ -67,36 +67,39 @@
#define IDC_SPIN_XTRIM 1026
#define IDC_SPIN_YTRIM 1027
#define IDC_PHASOR_ENABLE 1029
#define IDC_SOUNDCARD_DISABLE 1030
#define IDC_TFE_SETTINGS_ENABLE_T 1031
#define IDC_TFE_SETTINGS_ENABLE 1032
#define IDC_TFE_SETTINGS_INTERFACE_T 1033
#define IDC_TFE_SETTINGS_INTERFACE 1034
#define IDC_TFE_SETTINGS_INTERFACE_NAME 1035
#define IDC_TFE_SETTINGS_INTERFACE_DESC 1036
#define IDS_TFE_CAPTION 1037
#define IDS_TFE_ETHERNET 1038
#define IDS_TFE_INTERFACE 1039
#define IDS_OK 1040
#define IDS_CANCEL 1041
#define IDC_ETHERNET 1042
#define IDC_SCROLLLOCK_TOGGLE 1043
#define IDC_MOUSE_IN_SLOT4 1044
#define IDC_THE_FREEZES_F8_ROM_FW 1045
#define IDC_MOUSE_CROSSHAIR 1046
#define IDC_CLONETYPE 1047
#define IDC_MOUSE_RESTRICT_TO_WINDOW 1048
#define IDC_CIDERPRESS_BROWSE 1049
#define IDC_CIDERPRESS_FILENAME 1050
#define IDC_CPM_CONFIG 1051
#define IDC_DUMPTOPRINTER 1052
#define IDC_PRINTER_DUMP_FILENAME 1053
#define IDC_PRINTER_DUMP_FILENAME_BROWSE 1054
#define IDC_PRINTER_CONVERT_ENCODING 1055
#define IDC_PRINTER_FILTER_UNPRINTABLE 1056
#define IDC_PRINTER_APPEND 1057
#define IDC_SPIN_PRINTER_IDLE 1058
#define IDC_CHECK_HALF_SCAN_LINES 1059
#define IDC_SAM_ENABLE 1030
#define IDC_SOUNDCARD_DISABLE 1031
#define IDC_TFE_SETTINGS_ENABLE_T 1032
#define IDC_TFE_SETTINGS_ENABLE 1033
#define IDC_TFE_SETTINGS_INTERFACE_T 1034
#define IDC_TFE_SETTINGS_INTERFACE 1035
#define IDC_TFE_SETTINGS_INTERFACE_NAME 1036
#define IDC_TFE_SETTINGS_INTERFACE_DESC 1037
#define IDS_TFE_CAPTION 1038
#define IDS_TFE_ETHERNET 1039
#define IDS_TFE_INTERFACE 1040
#define IDS_OK 1041
#define IDS_CANCEL 1042
#define IDC_ETHERNET 1043
#define IDC_SCROLLLOCK_TOGGLE 1044
#define IDC_MOUSE_IN_SLOT4 1045
#define IDC_THE_FREEZES_F8_ROM_FW 1046
#define IDC_MOUSE_CROSSHAIR 1047
#define IDC_CLONETYPE 1048
#define IDC_MOUSE_RESTRICT_TO_WINDOW 1049
#define IDC_CIDERPRESS_BROWSE 1050
#define IDC_CIDERPRESS_FILENAME 1051
#define IDC_CPM_CONFIG 1052
#define IDC_DUMPTOPRINTER 1053
#define IDC_PRINTER_DUMP_FILENAME 1054
#define IDC_PRINTER_DUMP_FILENAME_BROWSE 1055
#define IDC_PRINTER_CONVERT_ENCODING 1056
#define IDC_PRINTER_FILTER_UNPRINTABLE 1057
#define IDC_PRINTER_APPEND 1058
#define IDC_SPIN_PRINTER_IDLE 1059
#define IDC_CHECK_HALF_SCAN_LINES 1060
#define IDC_GPL_TEXT 1061
#define IDC_GPL_BORDER 1063
#define IDC_APPLEWIN_VERSION 1064

View File

@ -93,6 +93,10 @@ BOOL CPageSound::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM
if (NewSoundcardConfigured(hWnd, wparam, CT_Phasor))
InitOptions(hWnd); // re-init
break;
case IDC_SAM_ENABLE:
if (NewSoundcardConfigured(hWnd, wparam, CT_SAM))
InitOptions(hWnd); // re-init
break;
case IDC_SOUNDCARD_DISABLE:
if (NewSoundcardConfigured(hWnd, wparam, CT_Empty))
InitOptions(hWnd); // re-init
@ -114,7 +118,11 @@ 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());
m_NewCardType = MB_GetSoundcardType(); // Reinit 1st time page is activated (fires before PSN_SETACTIVE)
if (g_Slot5 == CT_SAM)
m_NewCardType = CT_SAM;
else
m_NewCardType = MB_GetSoundcardType(); // Reinit 1st time page is activated (fires before PSN_SETACTIVE)
InitOptions(hWnd);
break;
@ -153,6 +161,8 @@ void CPageSound::InitOptions(HWND hWnd)
m_nCurrentIDCheckButton = IDC_MB_ENABLE;
else if(m_NewCardType == CT_Phasor)
m_nCurrentIDCheckButton = IDC_PHASOR_ENABLE;
else if(m_NewCardType == CT_SAM)
m_nCurrentIDCheckButton = IDC_SAM_ENABLE;
else
m_nCurrentIDCheckButton = IDC_SOUNDCARD_DISABLE;
@ -168,16 +178,23 @@ void CPageSound::InitOptions(HWND hWnd)
// Phasor button
{
const BOOL bEnable = bIsSlot4Empty || Slot4 == CT_MockingboardC;
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) && bIsSlot5Empty;
const BOOL bEnable = (bIsSlot4Empty || Slot4 == CT_Phasor || Slot4 == CT_MockingboardC) &&
(bIsSlot5Empty || Slot5 == CT_SAM || Slot5 == CT_MockingboardC);
EnableWindow(GetDlgItem(hWnd, IDC_MB_ENABLE), bEnable); // Disable Mockingboard (slot 4 & 5)
}
// SAM button
{
const BOOL bEnable = bIsSlot5Empty || Slot5 == CT_MockingboardC || Slot5 == CT_SAM;
EnableWindow(GetDlgItem(hWnd, IDC_SAM_ENABLE), bEnable); // Disable SAM (slot 5)
}
EnableWindow(GetDlgItem(hWnd, IDC_MB_VOLUME), (m_nCurrentIDCheckButton != IDC_SOUNDCARD_DISABLE) ? TRUE : FALSE);
}
@ -191,6 +208,7 @@ bool CPageSound::NewSoundcardConfigured(HWND hWnd, WPARAM wparam, SS_CARDTYPE Ne
m_NewCardType = NewCardType;
const SS_CARDTYPE Slot4 = m_PropertySheetHelper.GetConfigNew().m_Slot[4];
const SS_CARDTYPE Slot5 = m_PropertySheetHelper.GetConfigNew().m_Slot[5];
if (NewCardType == CT_MockingboardC)
@ -201,13 +219,20 @@ bool CPageSound::NewSoundcardConfigured(HWND hWnd, WPARAM wparam, SS_CARDTYPE Ne
else if (NewCardType == CT_Phasor)
{
m_PropertySheetHelper.GetConfigNew().m_Slot[4] = CT_Phasor;
if (Slot5 == CT_MockingboardC)
if ((Slot5 == CT_MockingboardC) || (Slot5 == CT_SAM))
m_PropertySheetHelper.GetConfigNew().m_Slot[5] = CT_Empty;
}
else if (NewCardType == CT_SAM)
{
if ((Slot4 == CT_MockingboardC) || (Slot4 == CT_Phasor))
m_PropertySheetHelper.GetConfigNew().m_Slot[4] = CT_Empty;
m_PropertySheetHelper.GetConfigNew().m_Slot[5] = CT_SAM;
}
else
{
m_PropertySheetHelper.GetConfigNew().m_Slot[4] = CT_Empty;
if (Slot5 == CT_MockingboardC)
if ((Slot4 == CT_MockingboardC) || (Slot4 == CT_Phasor))
m_PropertySheetHelper.GetConfigNew().m_Slot[4] = CT_Empty;
if ((Slot5 == CT_MockingboardC) || (Slot5 == CT_SAM))
m_PropertySheetHelper.GetConfigNew().m_Slot[5] = CT_Empty;
}

View File

@ -44,7 +44,7 @@ Input
. Mouse WM_USER_RESTART
. CP/M WM_USER_RESTART
Sound
. MB/Phasor/None WM_USER_RESTART
. MB/Phasor/SAM/None WM_USER_RESTART
Disk
. Enhanced disk speed WM_USER_RESTART Why? (used to patch Disk][ f/w - but not anymore)
. HDD enable WM_USER_RESTART

View File

@ -51,6 +51,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "..\resource\resource.h"
#include "Configuration\PropertySheet.h"
#include "Debugger\DebugDefs.h"
#include "SAM.h"
// Memory Flag
#define MF_80STORE 0x00000001
@ -1294,6 +1295,9 @@ void MemInitialize()
{
ConfigureSoftcard(pCxRomPeripheral, 5); // $C500 : Z80 card
}
else
if (g_Slot5 == CT_SAM)
ConfigureSAM(pCxRomPeripheral, 5); // $C500 : Z80 card
DiskLoadRom(pCxRomPeripheral, 6); // $C600 : Disk][ f/w
HD_Load_Rom(pCxRomPeripheral, 7); // $C700 : HDD f/w

93
source/SAM.cpp Normal file
View File

@ -0,0 +1,93 @@
/*
AppleWin : An Apple //e emulator for Windows
Copyright (C) 1994-1996, Michael O'Brien
Copyright (C) 1999-2001, Oliver Schmidt
Copyright (C) 2002-2005, Tom Charlesworth
Copyright (C) 2006-2007, Tom Charlesworth, Michael Pohoreski
AppleWin is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
AppleWin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AppleWin; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
SAM.CPP
Emulate an 8 bit DAC (eg: SAM card) which writes unsigned byte
data written to its IO area to the audio buffer (as used by the speaker).
This merges the data with the speaker stream, reducing the volume
of the Apple speaker when active.
Riccardo Macri Mar 2015
*/
#include "StdAfx.h"
#include "AppleWin.h"
#include "Memory.h"
#include "SAM.h"
#include "Speaker.h"
//
// Write 8 bit data to speaker. Emulates a "SAM" speech card DAC
//
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_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.
if (soundtype != SOUND_WAVE)
return MemReadFloatingBus(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)
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_bQuieterSpeaker = true;
return res;
}
void ConfigureSAM(LPBYTE pCxRomPeripheral, UINT uSlot)
{
RegisterIoHandler(uSlot, IO_Null, IOWrite_SAM, IO_Null, IO_Null, NULL, NULL);
}

3
source/SAM.h Normal file
View File

@ -0,0 +1,3 @@
#pragma once
void ConfigureSAM(LPBYTE pCxRomPeripheral, UINT uSlot);

View File

@ -51,11 +51,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// their buffers are running low.
//
#define SOUND_NONE 0
#define SOUND_DIRECT 1
#define SOUND_SMART 2
#define SOUND_WAVE 3
static const unsigned short g_nSPKR_NumChannels = 1;
static const DWORD g_dwDSSpkrBufferSize = MAX_SAMPLES * sizeof(short) * g_nSPKR_NumChannels;
@ -66,18 +61,20 @@ static short* g_pSpeakerBuffer = NULL;
// Globals (SOUND_WAVE)
const short SPKR_DATA_INIT = (short)0x8000;
static short g_nSpeakerData = SPKR_DATA_INIT;
short g_nSpeakerData = SPKR_DATA_INIT;
static UINT g_nBufferIdx = 0;
static short* g_pRemainderBuffer = NULL;
static UINT g_nRemainderBufferSize; // Setup in SpkrInitialize()
static UINT g_nRemainderBufferIdx; // Setup in SpkrInitialize()
// Application-wide globals:
DWORD soundtype = SOUND_WAVE;
double g_fClksPerSpkrSample; // Setup in SetClksPerSpkrSample()
// Allow temporary quietening of speaker (8 bit DAC)
bool g_bQuieterSpeaker = false;
// Globals
static DWORD lastcyclenum = 0;
static DWORD toggles = 0;
@ -447,7 +444,21 @@ BYTE __stdcall SpkrToggle (WORD, WORD, BYTE, BYTE, ULONG nCyclesLeft)
UpdateSpkr();
g_nSpeakerData = ~g_nSpeakerData;
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)
{
@ -993,6 +1004,7 @@ static void Spkr_SetActive(bool bActive)
// Called by SpkrUpdate() after 0.2s of speaker inactivity
g_bSpkrRecentlyActive = false;
SpeakerVoice.bRecentlyActive = false;
g_bQuieterSpeaker = 0; // undo any muting (for 8 bit DAC)
}
}

View File

@ -1,7 +1,14 @@
#pragma once
#define SOUND_NONE 0
#define SOUND_DIRECT 1
#define SOUND_SMART 2
#define SOUND_WAVE 3
extern DWORD soundtype;
extern double g_fClksPerSpkrSample;
extern bool g_bQuieterSpeaker;
extern short g_nSpeakerData;
void SpkrDestroy ();
void SpkrInitialize ();