Merge from Tom: r683

Added Speech API support:
. Capture char output to COUT
. Enable speech via -speech cmd-line
. Ctrl+Reset and FullSpeed mode purge the speech buffers
Removed #pragma hdrstop from all .cpp files except AppleWin.cpp (which is the PCH create file)
This commit is contained in:
tomch 2010-02-14 21:11:26 +00:00
parent 82f0bbf8a6
commit 0f72cdb43e
45 changed files with 231 additions and 59 deletions

View File

@ -729,6 +729,14 @@
RelativePath=".\source\Speaker.h"
>
</File>
<File
RelativePath=".\source\Speech.cpp"
>
</File>
<File
RelativePath=".\source\Speech.h"
>
</File>
<File
RelativePath=".\source\Tape.cpp"
>

View File

@ -19,6 +19,19 @@ Restrictions/bugs:
- For an original Apple //e, 80-column (PR#3) and INVERSE, it still appears to be mousetext character, but it should be inverted upper-case from $40 to $5F.
1.18.1 - 14 Feb 2010 (beta)
---------------------------
Changes:
. Added "-speech" cmd-line switch
- Captures text from COUT and outputs to Speech API
- Ctrl+RESET and FullSpeed mode (ie. disk access) will purge the speech buffers
Fixed:
. [Bug #16699] Debugger: G xxxx not clearing BP
. [Bug #16688] Debugger RUN <script-file> still not 100%
- Honour absolute path (ie. don't prefix with CWD)
1.18.0 - 17 Jan 2010 (beta)
---------------------------
Changes:

View File

@ -27,7 +27,7 @@
/*#define MC_DEBUG*/
#include "StdAfx.h"
#pragma hdrstop
#include "6821.h"

View File

@ -25,7 +25,7 @@
// [AppleWin-TC] From FUSE's sound.c module
#include "StdAfx.h"
#pragma hdrstop
#include <windows.h>
#include <stdio.h>

View File

@ -27,12 +27,16 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop // Normally would have stdafx.cpp (being the file with /Yc) and wouldn't bother with #pragma hdrstop
#include "DiskImage.h"
#include "Harddisk.h"
#pragma hdrstop
#include <objbase.h>
//#include <objbase.h> // Updated[TC]: Removed, as not needed
#include "MouseInterface.h"
#ifdef USE_SPEECH_API
#include "Speech.h"
#endif
char VERSIONSTRING[16] = "xx.yy.zz.ww";
@ -90,6 +94,9 @@ eCPU g_ActiveCPU = CPU_6502;
HANDLE g_hCustomRomF8 = INVALID_HANDLE_VALUE; // Cmd-line specified custom ROM at $F800..$FFFF
static bool g_bCustomRomF8Failed = false; // Set if custom ROM file failed
static bool g_bEnableSpeech = false;
CSpeech g_Speech;
//===========================================================================
#define DBG_CALC_FREQ 0
@ -162,6 +169,7 @@ void ContinueExecution()
// Don't call Spkr_Mute() - will get speaker clicks
MB_Mute();
SysClk_StopTimer();
g_Speech.Reset(); // TODO: Put this on a timer (in emulated cycles)... otherwise CATALOG cuts out
g_nCpuCyclesFeedback = 0; // For the case when this is a big -ve number
@ -852,6 +860,10 @@ int APIENTRY WinMain (HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
{
g_bEnableDumpToRealPrinter = true;
}
else if(strcmp(lpCmdLine, "-speech") == 0)
{
g_bEnableSpeech = true;
}
lpCmdLine = lpNextArg;
}
@ -912,6 +924,12 @@ int APIENTRY WinMain (HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
// . NB. DSInit() & DIMouse::DirectInputInit are done when g_hFrameWindow is created (WM_CREATE)
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
bool bSysClkOK = SysClk_InitTimer();
#ifdef USE_SPEECH_API
if (g_bEnableSpeech)
{
bool bSpeechOK = g_Speech.Init();
}
#endif
// DO ONE-TIME INITIALIZATION
g_hInstance = passinstance;

View File

@ -56,3 +56,7 @@ extern HANDLE g_hCustomRomF8; // NULL if no custom rom
enum eCPU {CPU_6502=1, CPU_Z80};
extern eCPU g_ActiveCPU;
#ifdef USE_SPEECH_API
class CSpeech;
extern CSpeech g_Speech;
#endif

View File

@ -85,7 +85,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h"
#pragma hdrstop
#include "MouseInterface.h"
#ifdef SUPPORT_CPM
@ -94,6 +93,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Z80VICE\z80mem.h"
#endif
#ifdef USE_SPEECH_API
#include "Speech.h"
#endif
#define AF_SIGN 0x80
#define AF_OVERFLOW 0x40
#define AF_RESERVED 0x20
@ -841,20 +844,85 @@ void CpuWrite(USHORT addr, BYTE a, ULONG uExecutedCycles)
//===========================================================================
#ifdef USE_SPEECH_API
const USHORT COUT = 0xFDED;
const UINT OUTPUT_BUFFER_SIZE = 256;
char g_OutputBuffer[OUTPUT_BUFFER_SIZE+1+1]; // +1 for EOL, +1 for NULL
UINT OutputBufferIdx = 0;
bool bEscMode = false;
void CaptureCOUT(void)
{
const char ch = regs.a & 0x7f;
if (ch == 0x07) // Bell
{
// Ignore
}
else if (ch == 0x08) // Backspace
{
if (OutputBufferIdx)
OutputBufferIdx--;
}
else if (ch == 0x0A) // LF
{
// Ignore
}
else if (ch == 0x0D) // CR
{
if (bEscMode)
{
bEscMode = false;
}
else if (OutputBufferIdx)
{
g_OutputBuffer[OutputBufferIdx] = 0;
g_Speech.Speak(g_OutputBuffer);
#ifdef _DEBUG
g_OutputBuffer[OutputBufferIdx] = '\n';
g_OutputBuffer[OutputBufferIdx+1] = 0;
OutputDebugString(g_OutputBuffer);
#endif
OutputBufferIdx = 0;
}
}
else if (ch == 0x1B) // Escape
{
bEscMode = bEscMode ? false : true; // Toggle mode
}
else if (ch >= ' ' && ch <= '~')
{
if (OutputBufferIdx < OUTPUT_BUFFER_SIZE && !bEscMode)
g_OutputBuffer[OutputBufferIdx++] = ch;
}
}
#endif
//===========================================================================
static __forceinline int Fetch(BYTE& iOpcode, ULONG uExecutedCycles)
{
//g_uInternalExecutedCycles = uExecutedCycles;
const USHORT PC = regs.pc;
// iOpcode = *(mem+regs.pc);
iOpcode = ((regs.pc & 0xF000) == 0xC000)
? IORead[(regs.pc>>4) & 0xFF](regs.pc,regs.pc,0,0,uExecutedCycles) // Fetch opcode from I/O memory, but params are still from mem[]
: *(mem+regs.pc);
iOpcode = ((PC & 0xF000) == 0xC000)
? IORead[(PC>>4) & 0xFF](PC,PC,0,0,uExecutedCycles) // Fetch opcode from I/O memory, but params are still from mem[]
: *(mem+PC);
if (CheckDebugBreak( iOpcode ))
return 0;
if (CheckDebugBreak( iOpcode ))
return 0;
regs.pc++;
return 1;
#ifdef USE_SPEECH_API
if (PC == COUT && g_Speech.IsEnabled() && !g_bFullSpeed)
CaptureCOUT();
#endif
regs.pc++;
return 1;
}
//#define ENABLE_NMI_SUPPORT // Not used - so don't enable

View File

@ -1,6 +1,7 @@
#pragma once
#define SUPPORT_CPM
#define USE_SPEECH_API
const double _M14 = (157500000.0 / 11.0); // 14.3181818... * 10^6
const double CLK_6502 = ((_M14 * 65.0) / 912.0); // 65 cycles per 912 14M clocks

View File

@ -30,7 +30,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//#pragma warning(disable: 4786)
#include "StdAfx.h"
#pragma hdrstop
// #define DEBUG_COMMAND_HELP 1
// #define DEBUG_ASM_HASH 1

View File

@ -27,7 +27,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
// Globals __________________________________________________________________

View File

@ -27,8 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
#include <assert.h>
// Console ________________________________________________________________________________________

View File

@ -7,7 +7,7 @@ AppleWin : An Apple //e emulator for Windows
*/
#include "StdAfx.h"
#pragma hdrstop
// Disassembler Data ______________________________________________________________________________

View File

@ -27,11 +27,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
#include <assert.h>
// NEW UI debugging
#define DEBUG_FORCE_DISPLAY 0

View File

@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
#define DEBUG_COLOR_CONSOLE 0

View File

@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
// Args ___________________________________________________________________________________________

View File

@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
// Util - Range _______________________________________________________________

View File

@ -1,5 +1,5 @@
#include "StdAfx.h"
#pragma hdrstop
// Symbols ________________________________________________________________________________________

View File

@ -28,7 +28,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h"
#include "DiskImage.h"
#pragma hdrstop
#include "..\resource\resource.h"
#define LOG_DISK_ENABLED 0

View File

@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h"
#include "DiskImage.h"
#include "DiskImageHelper.h"
#pragma hdrstop
static CDiskImageHelper sg_DiskImageHelper;
@ -93,7 +93,8 @@ void ImageClose(const HIMAGE hDiskImage, const bool bOpenError /*=false*/)
{
if (!ptr->ValidTrack[uTrack])
{
// What's the reason for this?
// TODO: Comment using info from this URL:
// http://groups.google.de/group/comp.emulators.apple2/msg/7a1b9317e7905152
bDeleteFile = true;
break;
}

View File

@ -29,10 +29,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h"
#include "DiskImage.h"
#include "Harddisk.h"
#pragma hdrstop
#include "MouseInterface.h"
#include "..\resource\resource.h"
#include <sys/stat.h>
#ifdef USE_SPEECH_API
#include "Speech.h"
#endif
//#define ENABLE_MENU 0
@ -1658,6 +1660,9 @@ void ResetMachineState ()
#ifdef SUPPORT_CPM
g_ActiveCPU = CPU_6502;
#endif
#ifdef USE_SPEECH_API
g_Speech.Reset();
#endif
SoundCore_SetFade(FADE_NONE);
}
@ -1676,6 +1681,9 @@ void CtrlReset()
VideoResetState(); // Switch Alternate char set off
sg_SSC.CommReset();
MB_Reset();
#ifdef USE_SPEECH_API
g_Speech.Reset();
#endif
CpuReset();
g_bFreshReset = true;

View File

@ -30,7 +30,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "HardDisk.h"
#include "DiskImage.h" // ImageError_e
#include "DiskImageHelper.h"
#pragma hdrstop
#include "..\resource\resource.h"
/*

View File

@ -38,7 +38,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// - This is because the 2-joystick version of Mario Bros expects the 2nd joystick to control Apple switch #2.
#include "StdAfx.h"
#pragma hdrstop
#include "MouseInterface.h"
#define BUTTONTIME 5000

View File

@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
static bool g_bKeybBufferEnable = false;

View File

@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
//---------------------------------------------------------------------------

View File

@ -28,7 +28,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h"
#include "Harddisk.h"
#pragma hdrstop
#include "MouseInterface.h"
#ifdef SUPPORT_CPM
#include "z80emu.h"

View File

@ -76,7 +76,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "StdAfx.h"
#pragma hdrstop
#define LOG_SSI263 0

View File

@ -41,7 +41,7 @@ Etc.
#include "stdafx.h"
#pragma hdrstop
#ifdef _DEBUG
#define _DEBUG_SPURIOUS_IRQ

View File

@ -27,9 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
#include "..\resource\resource.h"
#include <stdlib.h>
static DWORD inactivity = 0;
static FILE* file = NULL;

View File

@ -29,7 +29,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h"
#include "Harddisk.h"
#pragma hdrstop
#include "..\resource\resource.h"
#include "Tfe\Tfesupp.h"
#include "Tfe\Uilib.h"

View File

@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
//===========================================================================
BOOL RegLoadString (LPCTSTR section, LPCTSTR key, BOOL peruser,

View File

@ -27,9 +27,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "Stdafx.h"
#pragma hdrstop
#include <windows.h>
#include "riff.h"
static HANDLE g_hRiffFile = INVALID_HANDLE_VALUE;

View File

@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
#define DEFAULT_SNAPSHOT_NAME "SaveState.aws"

View File

@ -39,7 +39,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "StdAfx.h"
#pragma hdrstop
#include "..\resource\resource.h"
//#define SUPPORT_MODEM

View File

@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
//-----------------------------------------------------------------------------

View File

@ -27,7 +27,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
#include <wchar.h>
// Notes:

View File

@ -0,0 +1,55 @@
#include "StdAfx.h"
#include <sapi.h>
#include "Speech.h"
CSpeech::~CSpeech(void)
{
// Don't do this: causes crash on app exit!
//if (m_cpVoice)
// m_cpVoice->Release();
}
bool CSpeech::Init(void)
{
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_INPROC, IID_ISpVoice, (LPVOID*)&m_cpVoice);
return hr == S_OK;
}
void CSpeech::Reset(void)
{
if (!m_cpVoice)
return;
HRESULT hr = m_cpVoice->Speak(NULL, SPF_PURGEBEFORESPEAK, 0);
_ASSERT(hr == S_OK);
}
void CSpeech::Speak(const char* const pBuffer)
{
if (!m_cpVoice)
return;
size_t uSize;
errno_t err = mbstowcs_s(&uSize, NULL, 0, pBuffer, 0);
if (err)
return;
WCHAR* pszWTextString = new WCHAR[uSize];
if (!pszWTextString)
return;
err = mbstowcs_s(&uSize, pszWTextString, uSize, pBuffer, uSize);
if (err)
{
delete [] pszWTextString;
return;
}
HRESULT hr = m_cpVoice->Speak(pszWTextString, SPF_ASYNC | SPF_IS_NOT_XML, 0);
_ASSERT(hr == S_OK);
hr = m_cpVoice->Resume();
_ASSERT(hr == S_OK);
delete [] pszWTextString;
}

19
AppleWin/source/Speech.h Normal file
View File

@ -0,0 +1,19 @@
struct ISpVoice;
class CSpeech
{
public:
CSpeech() :
m_cpVoice(NULL)
{
}
virtual ~CSpeech();
bool Init(void);
void Reset(void);
bool IsEnabled(void) { return m_cpVoice != NULL; }
void Speak(const char* const pBuffer);
private:
ISpVoice* m_cpVoice;
};

View File

@ -1,9 +1,9 @@
//#define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT 0x0400 // For CoInitializeEx() to get defined in objbase.h
//#define _WIN32_WINNT 0x0400 // For CoInitializeEx() to get defined in objbase.h (Updated[TC]: Removed as not needed)
// Mouse Wheel is not supported on Win95.
// If we didn't care about supporting Win95 (compile/run-time errors)
// we would just define the minmimum windows version to support.
// we would just define the minimum windows version to support.
// #define _WIN32_WINDOWS 0x0401
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020A
@ -27,6 +27,7 @@
#include <commctrl.h>
#include <ddraw.h>
#include <htmlhelp.h>
#include <assert.h>
#include <queue>
#include <vector>

View File

@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
static BYTE C060 = 255;
static bool CapsLockAllowed = false;

View File

@ -25,7 +25,6 @@
*/
#include "..\StdAfx.h"
#pragma hdrstop
#include <assert.h>
#include <stdio.h>

View File

@ -33,8 +33,6 @@
*
*/
#pragma hdrstop
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

View File

@ -1,5 +1,5 @@
#include "StdAfx.h"
#pragma hdrstop
// MemoryTextFile _________________________________________________________________________________

View File

@ -27,7 +27,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "StdAfx.h"
#pragma hdrstop
#include "..\resource\resource.h"
/* reference: technote tn-iigs-063 "Master Color Values"

View File

@ -25,7 +25,7 @@
*/
#include "..\stdafx.h"
#pragma hdrstop
#undef IN // Defined in windef.h
#undef OUT // Defined in windef.h

View File

@ -14,8 +14,6 @@
// Emula a CPU Z80
#include "StdAfx.h"
#pragma hdrstop
#include "z80emu.h"
// Variaveis