Merge from Tom branch to trunk

. SSC now working: PR#2 & IN#2
. etc.
This commit is contained in:
tomch 2007-05-28 11:16:42 +00:00
parent 77ff09654d
commit 43bfc1a05b
41 changed files with 1895 additions and 1312 deletions

View File

@ -48,7 +48,7 @@
AdditionalOptions="/Zm200 " AdditionalOptions="/Zm200 "
Optimization="2" Optimization="2"
InlineFunctionExpansion="2" InlineFunctionExpansion="2"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;HAS_M6803"
StringPooling="true" StringPooling="true"
RuntimeLibrary="0" RuntimeLibrary="0"
EnableFunctionLevelLinking="true" EnableFunctionLevelLinking="true"
@ -141,7 +141,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
AdditionalOptions="/Zm200 " AdditionalOptions="/Zm200 "
Optimization="0" Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;HAS_M6803"
RuntimeLibrary="1" RuntimeLibrary="1"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\Debug/Applewin.pch" PrecompiledHeaderFile=".\Debug/Applewin.pch"
@ -526,16 +526,20 @@
Name="Resources" Name="Resources"
Filter=".txt,.ico,.bmp,.rc" Filter=".txt,.ico,.bmp,.rc"
> >
<File
RelativePath=".\resource\Apple2.rom"
>
</File>
<File
RelativePath=".\resource\Apple2_Plus.rom"
>
</File>
<File <File
RelativePath=".\resource\Apple2e.rom" RelativePath=".\resource\Apple2e.rom"
> >
</File> </File>
<File <File
RelativePath=".\resource\Apple2orig.rom" RelativePath=".\resource\Apple2e_Enhanced.rom"
>
</File>
<File
RelativePath=".\resource\Apple2plus.rom"
> >
</File> </File>
<File <File
@ -596,6 +600,10 @@
RelativePath="RESOURCE\DISK.ICO" RelativePath="RESOURCE\DISK.ICO"
> >
</File> </File>
<File
RelativePath=".\resource\Disk2.rom"
>
</File>
<File <File
RelativePath="RESOURCE\DISKOFF.BMP" RelativePath="RESOURCE\DISKOFF.BMP"
> >
@ -640,6 +648,14 @@
RelativePath="RESOURCE\HELP.BMP" RelativePath="RESOURCE\HELP.BMP"
> >
</File> </File>
<File
RelativePath=".\resource\Mockingboard-D.rom"
>
</File>
<File
RelativePath=".\resource\Parallel.rom"
>
</File>
<File <File
RelativePath="RESOURCE\RUN.BMP" RelativePath="RESOURCE\RUN.BMP"
> >
@ -648,6 +664,10 @@
RelativePath="RESOURCE\SETUP.BMP" RelativePath="RESOURCE\SETUP.BMP"
> >
</File> </File>
<File
RelativePath=".\resource\SSC.rom"
>
</File>
</Filter> </Filter>
<File <File
RelativePath=".\source\Common.h" RelativePath=".\source\Common.h"

Binary file not shown.

Binary file not shown.

View File

@ -258,17 +258,21 @@ END
// FIRMWARE // FIRMWARE
// //
IDR_HDDRVR FIRMWARE "Hddrvr.bin" IDR_DISK2_FW FIRMWARE "Disk2.rom"
IDR_PRINTDRVR FIRMWARE "Parallel.rom" IDR_SSC_FW FIRMWARE "SSC.rom"
IDR_HDDRVR_FW FIRMWARE "Hddrvr.bin"
IDR_PRINTDRVR_FW FIRMWARE "Parallel.rom"
IDR_MOCKINGBOARD_D_FW FIRMWARE "Mockingboard-D.rom"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// ROM // ROM
// //
IDR_APPLE2ORIG_ROM ROM "Apple2orig.rom" IDR_APPLE2_ROM ROM "Apple2.rom"
IDR_APPLE2PLUS_ROM ROM "Apple2plus.rom" IDR_APPLE2_PLUS_ROM ROM "Apple2_Plus.rom"
IDR_APPLE2E_ROM ROM "Apple2e.rom" IDR_APPLE2E_ROM ROM "Apple2e.rom"
IDR_APPLE2E_ENHANCED_ROM ROM "Apple2e_Enhanced.rom"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //

BIN
AppleWin/resource/DISK2.rom Normal file

Binary file not shown.

Binary file not shown.

BIN
AppleWin/resource/SSC.rom Normal file

Binary file not shown.

View File

@ -21,19 +21,23 @@
#define IDD_PROPPAGE_DISK 116 #define IDD_PROPPAGE_DISK 116
#define IDC_BENCHMARK 117 #define IDC_BENCHMARK 117
#define IDC_LOADSTATE 118 #define IDC_LOADSTATE 118
#define IDR_HDDRVR 119 #define IDR_HDDRVR_FW 119
#define IDC_0_5_MHz 120 #define IDC_0_5_MHz 120
#define IDB_APPLEWIN 121 #define IDB_APPLEWIN 121
#define IDC_1_0_MHz 122 #define IDC_1_0_MHz 122
#define IDC_2_0_MHz 123 #define IDC_2_0_MHz 123
#define IDC_MAX_MHz 124 #define IDC_MAX_MHz 124
#define IDR_MENU 125 #define IDR_MENU 125
#define IDR_APPLE2ORIG_ROM 126 #define IDR_APPLE2_ROM 126
#define IDR_APPLE2PLUS_ROM 127 #define IDR_APPLE2_PLUS_ROM 127
#define IDR_APPLE2E_ROM 128 #define IDR_APPLE2E_ROM 128
#define IDR_APPLE2E_ENHANCED_ROM 129
#define IDC_MB_ENABLE 130 #define IDC_MB_ENABLE 130
#define IDD_TFE_SETTINGS_DIALOG 131 #define IDD_TFE_SETTINGS_DIALOG 131
#define IDR_PRINTDRVR 132 #define IDR_PRINTDRVR_FW 132
#define IDR_DISK2_FW 133
#define IDR_SSC_FW 134
#define IDR_MOCKINGBOARD_D_FW 135
#define IDC_KEYB_BUFFER_ENABLE 1005 #define IDC_KEYB_BUFFER_ENABLE 1005
#define IDC_SAVESTATE 1006 #define IDC_SAVESTATE 1006
#define IDC_SAVESTATE_ON_EXIT 1007 #define IDC_SAVESTATE_ON_EXIT 1007
@ -80,7 +84,7 @@
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1 #define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 134 #define _APS_NEXT_RESOURCE_VALUE 136
#define _APS_NEXT_COMMAND_VALUE 40007 #define _APS_NEXT_COMMAND_VALUE 40007
#define _APS_NEXT_CONTROL_VALUE 1043 #define _APS_NEXT_CONTROL_VALUE 1043
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101

View File

@ -31,10 +31,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
char VERSIONSTRING[] = "xx.yy.zz.ww"; char VERSIONSTRING[] = "xx.yy.zz.ww";
TCHAR *g_pAppTitle = TITLE_APPLE_2_E; TCHAR *g_pAppTitle = TITLE_APPLE_2E_ENHANCED;
bool g_bApple2e = true; eApple2Type g_Apple2Type = A2TYPE_APPLE2EEHANCED;
bool g_bApple2plus = true;
BOOL behind = 0; // Redundant BOOL behind = 0; // Redundant
DWORD cumulativecycles = 0; // Wraps after ~1hr 9mins DWORD cumulativecycles = 0; // Wraps after ~1hr 9mins
@ -65,6 +64,8 @@ DWORD g_dwCyclesThisFrame = 0;
FILE* g_fh = NULL; FILE* g_fh = NULL;
bool g_bDisableDirectSound = false; bool g_bDisableDirectSound = false;
CSuperSerialCard sg_SSC;
//=========================================================================== //===========================================================================
#define DBG_CALC_FREQ 0 #define DBG_CALC_FREQ 0
@ -132,7 +133,7 @@ void ContinueExecution()
VideoUpdateVbl(g_dwCyclesThisFrame); VideoUpdateVbl(g_dwCyclesThisFrame);
SpkrUpdate(cyclenum); SpkrUpdate(cyclenum);
CommUpdate(cyclenum); sg_SSC.CommUpdate(cyclenum);
PrintUpdate(cyclenum); PrintUpdate(cyclenum);
// //
@ -346,15 +347,37 @@ void GetProgramDirectory () {
} }
//=========================================================================== //===========================================================================
void LoadConfiguration () { void LoadConfiguration ()
DWORD comptype; {
LOAD(TEXT("Computer Emulation"),&comptype); DWORD dwComputerType;
g_bApple2e = (comptype == 2);
g_bApple2plus = (comptype == 1); if (LOAD(TEXT(REGVALUE_APPLE2_TYPE),&dwComputerType))
{
if (dwComputerType >= A2TYPE_MAX)
dwComputerType = A2TYPE_APPLE2EEHANCED;
g_Apple2Type = (eApple2Type) dwComputerType;
}
else
{
LOAD(TEXT("Computer Emulation"),&dwComputerType);
switch (dwComputerType)
{
// NB. No A2TYPE_APPLE2E
case 0: g_Apple2Type = A2TYPE_APPLE2;
case 1: g_Apple2Type = A2TYPE_APPLE2PLUS;
case 2: g_Apple2Type = A2TYPE_APPLE2EEHANCED;
default: g_Apple2Type = A2TYPE_APPLE2EEHANCED;
}
}
LOAD(TEXT("Joystick 0 Emulation"),&joytype[0]); LOAD(TEXT("Joystick 0 Emulation"),&joytype[0]);
LOAD(TEXT("Joystick 1 Emulation"),&joytype[1]); LOAD(TEXT("Joystick 1 Emulation"),&joytype[1]);
LOAD(TEXT("Sound Emulation") ,&soundtype); LOAD(TEXT("Sound Emulation") ,&soundtype);
LOAD(TEXT("Serial Port") ,&serialport);
DWORD dwSerialPort;
LOAD(TEXT("Serial Port") ,&dwSerialPort);
sg_SSC.SetSerialPort(dwSerialPort);
LOAD(TEXT("Emulation Speed") ,&g_dwSpeed); LOAD(TEXT("Emulation Speed") ,&g_dwSpeed);
LOAD(TEXT("Enhance Disk Speed"),(DWORD *)&enhancedisk); LOAD(TEXT("Enhance Disk Speed"),(DWORD *)&enhancedisk);
LOAD(TEXT("Video Emulation") ,&videotype); LOAD(TEXT("Video Emulation") ,&videotype);
@ -622,6 +645,7 @@ int APIENTRY WinMain (HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
// DO ONE-TIME INITIALIZATION // DO ONE-TIME INITIALIZATION
g_hInstance = passinstance; g_hInstance = passinstance;
MemPreInitialize(); // Call before any of the slot devices are initialized
GdiSetBatchLimit(512); GdiSetBatchLimit(512);
GetProgramDirectory(); GetProgramDirectory();
RegisterExtensions(); RegisterExtensions();

View File

@ -4,8 +4,7 @@ extern char VERSIONSTRING[]; // Contructed in WinMain()
extern TCHAR *g_pAppTitle; extern TCHAR *g_pAppTitle;
extern bool g_bApple2e; extern eApple2Type g_Apple2Type;
extern bool g_bApple2plus;
extern BOOL behind; extern BOOL behind;
extern DWORD cumulativecycles; extern DWORD cumulativecycles;

View File

@ -149,13 +149,9 @@ static volatile BOOL g_bNmiFlank = FALSE; // Positive going flank on NMI line
if (regs.sp < 0x100) \ if (regs.sp < 0x100) \
regs.sp = 0x1FF; regs.sp = 0x1FF;
#define READ ( \ #define READ ( \
((addr & 0xFF00) == 0xC000) \ ((addr & 0xF000) == 0xC000) \
? ioread[addr & 0xFF](regs.pc,(BYTE)addr,0,0,uExecutedCycles) \ ? IORead[(addr>>4) & 0xFF](regs.pc,addr,0,0,uExecutedCycles) \
: ( \
(((addr & 0xFF00) == 0xC400) || ((addr & 0xFF00) == 0xC500)) \
? CxReadFunc(regs.pc, addr, 0, 0, uExecutedCycles) \
: *(mem+addr) \ : *(mem+addr) \
) \
) )
#define SETNZ(a) { \ #define SETNZ(a) { \
flagn = ((a) & 0x80); \ flagn = ((a) & 0x80); \
@ -164,13 +160,11 @@ static volatile BOOL g_bNmiFlank = FALSE; // Positive going flank on NMI line
#define SETZ(a) flagz = !((a) & 0xFF); #define SETZ(a) flagz = !((a) & 0xFF);
#define WRITE(a) { \ #define WRITE(a) { \
memdirty[addr >> 8] = 0xFF; \ memdirty[addr >> 8] = 0xFF; \
LPBYTE page = memwrite[0][addr >> 8]; \ LPBYTE page = memwrite[addr >> 8]; \
if (page) \ if (page) \
*(page+(addr & 0xFF)) = (BYTE)(a); \ *(page+(addr & 0xFF)) = (BYTE)(a); \
else if ((addr & 0xFF00) == 0xC000) \ else if ((addr & 0xF000) == 0xC000) \
iowrite[addr & 0xFF](regs.pc,(BYTE)addr,1,(BYTE)(a),uExecutedCycles); \ IOWrite[(addr>>4) & 0xFF](regs.pc,addr,1,(BYTE)(a),uExecutedCycles); \
else if(((addr & 0xFF00) == 0xC400) || ((addr & 0xFF00) == 0xC500)) \
CxWriteFunc(regs.pc, addr, 1, (BYTE)(a), uExecutedCycles); \
} }
// //
@ -841,7 +835,11 @@ static DWORD Cpu65C02 (DWORD uTotalCycles)
g_uInternalExecutedCycles = uExecutedCycles; g_uInternalExecutedCycles = uExecutedCycles;
USHORT uExtraCycles = 0; USHORT uExtraCycles = 0;
BYTE iOpcode = *(mem+regs.pc); // BYTE iOpcode = *(mem+regs.pc);
BYTE 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);
if (CheckDebugBreak( iOpcode )) if (CheckDebugBreak( iOpcode ))
break; break;
@ -1166,7 +1164,11 @@ static DWORD Cpu6502 (DWORD uTotalCycles)
g_uInternalExecutedCycles = uExecutedCycles; g_uInternalExecutedCycles = uExecutedCycles;
USHORT uExtraCycles = 0; USHORT uExtraCycles = 0;
BYTE iOpcode = *(mem+regs.pc); // BYTE iOpcode = *(mem+regs.pc);
BYTE iOpcode = ((regs.pc & 0xF000) == 0xC000)
? IORead[(regs.pc>>4) & 0xFF](regs.pc,regs.pc,0,0,uExecutedCycles)
: *(mem+regs.pc);
if (CheckDebugBreak( iOpcode )) if (CheckDebugBreak( iOpcode ))
break; break;
@ -1472,10 +1474,10 @@ static DWORD Cpu6502 (DWORD uTotalCycles)
static DWORD InternalCpuExecute (DWORD uTotalCycles) static DWORD InternalCpuExecute (DWORD uTotalCycles)
{ {
if (g_bApple2e) if (IS_APPLE2 || (g_Apple2Type == A2TYPE_APPLE2E))
return Cpu65C02(uTotalCycles); return Cpu6502(uTotalCycles); // Apple ][, ][+, //e
else // Apple ][ else
return Cpu6502(uTotalCycles); return Cpu65C02(uTotalCycles); // Enhanced Apple //e
} }
// //

View File

@ -9,6 +9,8 @@ const UINT uVisibleLinesPerFrame = 64*3; // 192
const UINT uLinesPerFrame = 262; // 64 in each third of the screen & 70 in VBL const UINT uLinesPerFrame = 262; // 64 in each third of the screen & 70 in VBL
const DWORD dwClksPerFrame = uCyclesPerLine * uLinesPerFrame; // 17030 const DWORD dwClksPerFrame = uCyclesPerLine * uLinesPerFrame; // 17030
#define NUM_SLOTS 8
#define MAX(a,b) (((a) > (b)) ? (a) : (b)) #define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b)) #define MIN(a,b) (((a) < (b)) ? (a) : (b))
@ -51,12 +53,13 @@ enum AppMode_e
#define BTN_DEBUG 6 #define BTN_DEBUG 6
#define BTN_SETUP 7 #define BTN_SETUP 7
#define MAXIMAGES 16 //#define MAXIMAGES 16
// TODO: Move to StringTable.h // TODO: Move to StringTable.h
#define TITLE_APPLE_2_ORG TEXT("Apple ][ Emulator") #define TITLE_APPLE_2 TEXT("Apple ][ Emulator")
#define TITLE_APPLE_2_PLUS TEXT("Apple ][+ Emulator") #define TITLE_APPLE_2_PLUS TEXT("Apple ][+ Emulator")
#define TITLE_APPLE_2_E TEXT("Apple //e Emulator") #define TITLE_APPLE_2E TEXT("Apple //e Emulator")
// #define TITLE TITLE_APPLE_2_E #define TITLE_APPLE_2E_ENHANCED TEXT("Enhanced Apple //e Emulator")
#define TITLE_PAUSED TEXT(" Paused ") #define TITLE_PAUSED TEXT(" Paused ")
#define TITLE_STEPPING TEXT("Stepping") #define TITLE_STEPPING TEXT("Stepping")
@ -65,6 +68,7 @@ enum AppMode_e
#define SAVE(a,b) RegSaveValue(TEXT("Configuration"),a,1,b) #define SAVE(a,b) RegSaveValue(TEXT("Configuration"),a,1,b)
// Configuration // Configuration
#define REGVALUE_APPLE2_TYPE "Apple2 Type"
#define REGVALUE_SPKR_VOLUME "Speaker Volume" #define REGVALUE_SPKR_VOLUME "Speaker Volume"
#define REGVALUE_MB_VOLUME "Mockingboard Volume" #define REGVALUE_MB_VOLUME "Mockingboard Volume"
#define REGVALUE_SOUNDCARD_TYPE "Soundcard Type" #define REGVALUE_SOUNDCARD_TYPE "Soundcard Type"
@ -87,9 +91,27 @@ enum AppMode_e
enum eSOUNDCARDTYPE {SC_UNINIT=0, SC_NONE, SC_MOCKINGBOARD, SC_PHASOR}; // Apple soundcard type enum eSOUNDCARDTYPE {SC_UNINIT=0, SC_NONE, SC_MOCKINGBOARD, SC_PHASOR}; // Apple soundcard type
typedef BYTE (__stdcall *iofunction)(WORD nPC, BYTE nAddr, BYTE nWriteFlag, BYTE nWriteValue, ULONG nCyclesLeft); typedef BYTE (__stdcall *iofunction)(WORD nPC, WORD nAddr, BYTE nWriteFlag, BYTE nWriteValue, ULONG nCyclesLeft);
typedef BYTE (__stdcall *cxfunction)(WORD nPC, WORD nAddr, BYTE nWriteFlag, BYTE nWriteValue, ULONG nCyclesLeft);
typedef struct _IMAGE__ { int unused; } *HIMAGE; typedef struct _IMAGE__ { int unused; } *HIMAGE;
enum eIRQSRC {IS_6522=0, IS_SPEECH, IS_SSC}; enum eIRQSRC {IS_6522=0, IS_SPEECH, IS_SSC};
//
#define APPLE2E_MASK 0x10
#define APPLE2C_MASK 0x20
#define IS_APPLE2 ((g_Apple2Type & (APPLE2E_MASK|APPLE2C_MASK)) == 0)
#define IS_APPLE2E (g_Apple2Type & APPLE2E_MASK)
#define IS_APPLE2C (g_Apple2Type & APPLE2C_MASK)
// NB. These get persisted to the Registry, so don't change the values for these enums!
enum eApple2Type {
A2TYPE_APPLE2=0,
A2TYPE_APPLE2PLUS,
A2TYPE_APPLE2E=APPLE2E_MASK,
A2TYPE_APPLE2EEHANCED,
// A2TYPE_APPLE2C=APPLE2C_MASK, // Placeholder
A2TYPE_MAX
};

View File

@ -2650,8 +2650,8 @@ Update_t CmdIn (int nArgs)
WORD nAddress = g_aArgs[1].nValue; WORD nAddress = g_aArgs[1].nValue;
// ioread[ g_aArgs[1].nValue & 0xFF ](regs.pc,g_aArgs[1].nValue & 0xFF,0,0,0); BYTE nPageOffset = nAddress & 0xFF;
ioread[ nAddress & 0xFF ](regs.pc, nAddress & 0xFF,0,0,0); // g_aArgs[1].nValue IORead[ (nAddress>>4) & 0xF ](regs.pc, nAddress & 0xFF, 0, 0, 0); // g_aArgs[1].nValue
return UPDATE_CONSOLE_DISPLAY; // TODO: Verify // 1 return UPDATE_CONSOLE_DISPLAY; // TODO: Verify // 1
} }
@ -2712,8 +2712,8 @@ Update_t CmdOut (int nArgs)
WORD nAddress = g_aArgs[1].nValue; WORD nAddress = g_aArgs[1].nValue;
// iowrite[ g_aArgs[1].nValue & 0xFF](regs.pc,g_aArgs[1].nValue & 0xFF,1,g_aArgs[2].nValue & 0xFF,0); BYTE nPageOffset = nAddress & 0xFF;
iowrite[ nAddress & 0xFF ] (regs.pc, nAddress & 0xFF, 1, g_aArgs[2].nValue & 0xFF,0); IOWrite[ (nAddress>>4) & 0xF ] (regs.pc, nAddress & 0xFF, 1, g_aArgs[2].nValue & 0xFF, 0);
return UPDATE_CONSOLE_DISPLAY; // TODO: Verify // 1 return UPDATE_CONSOLE_DISPLAY; // TODO: Verify // 1
} }
@ -8150,13 +8150,18 @@ void DebugBegin ()
g_nAppMode = MODE_DEBUG; g_nAppMode = MODE_DEBUG;
FrameRefreshStatus(DRAW_TITLE); FrameRefreshStatus(DRAW_TITLE);
if (g_bApple2e) if (IS_APPLE2 || (g_Apple2Type == A2TYPE_APPLE2E))
g_aOpcodes = & g_aOpcodes65C02[ 0 ]; // Enhanced Apple //e {
g_aOpcodes = & g_aOpcodes6502[ 0 ]; // Apple ][, ][+, //e
g_aOpmodes[ AM_2 ].m_nBytes = 1;
g_aOpmodes[ AM_3 ].m_nBytes = 1;
}
else else
g_aOpcodes = & g_aOpcodes6502[ 0 ]; // Original Apple ][ ][+ {
g_aOpcodes = & g_aOpcodes65C02[ 0 ]; // Enhanced Apple //e
g_aOpmodes[ AM_2 ].m_nBytes = g_bApple2e ? 2 : 1; g_aOpmodes[ AM_2 ].m_nBytes = 2;
g_aOpmodes[ AM_3 ].m_nBytes = g_bApple2e ? 3 : 1; g_aOpmodes[ AM_3 ].m_nBytes = 3;
}
g_nDisasmCurAddress = regs.pc; g_nDisasmCurAddress = regs.pc;
DisasmCalcTopBotAddress(); DisasmCalcTopBotAddress();

View File

@ -28,6 +28,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h" #include "StdAfx.h"
#pragma hdrstop #pragma hdrstop
#include "..\resource\resource.h"
static BYTE __stdcall DiskControlMotor (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
static BYTE __stdcall DiskControlStepper (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
static BYTE __stdcall DiskEnable (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
static BYTE __stdcall DiskReadWrite (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
static BYTE __stdcall DiskSetLatchValue (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
static BYTE __stdcall DiskSetReadMode (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
static BYTE __stdcall DiskSetWriteMode (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
#define LOG_DISK_ENABLED 1 #define LOG_DISK_ENABLED 1
@ -275,14 +284,14 @@ void DiskBoot () {
} }
//=========================================================================== //===========================================================================
BYTE __stdcall DiskControlMotor (WORD, BYTE address, BYTE, BYTE, ULONG) { static BYTE __stdcall DiskControlMotor (WORD, WORD address, BYTE, BYTE, ULONG) {
floppymotoron = address & 1; floppymotoron = address & 1;
CheckSpinning(); CheckSpinning();
return MemReturnRandomData(1); return MemReturnRandomData(1);
} }
//=========================================================================== //===========================================================================
BYTE __stdcall DiskControlStepper (WORD, BYTE address, BYTE, BYTE, ULONG) static BYTE __stdcall DiskControlStepper (WORD, WORD address, BYTE, BYTE, ULONG)
{ {
Disk_t * fptr = &g_aFloppyDisk[currdrive]; Disk_t * fptr = &g_aFloppyDisk[currdrive];
int phase = (address >> 1) & 3; int phase = (address >> 1) & 3;
@ -349,7 +358,7 @@ void DiskDestroy ()
} }
//=========================================================================== //===========================================================================
BYTE __stdcall DiskEnable (WORD, BYTE address, BYTE, BYTE, ULONG) { static BYTE __stdcall DiskEnable (WORD, WORD address, BYTE, BYTE, ULONG) {
currdrive = address & 1; currdrive = address & 1;
g_aFloppyDisk[!currdrive].spinning = 0; g_aFloppyDisk[!currdrive].spinning = 0;
g_aFloppyDisk[!currdrive].writelight = 0; g_aFloppyDisk[!currdrive].writelight = 0;
@ -392,10 +401,16 @@ LPCTSTR DiskGetName (int drive) {
} }
//=========================================================================== //===========================================================================
void DiskInitialize () {
BYTE __stdcall Disk_IORead(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall Disk_IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
void DiskInitialize ()
{
int loop = DRIVES; int loop = DRIVES;
while (loop--) while (loop--)
ZeroMemory(&g_aFloppyDisk[loop],sizeof(Disk_t )); ZeroMemory(&g_aFloppyDisk[loop],sizeof(Disk_t ));
TCHAR imagefilename[MAX_PATH]; TCHAR imagefilename[MAX_PATH];
_tcscpy(imagefilename,g_sProgramDir); _tcscpy(imagefilename,g_sProgramDir);
_tcscat(imagefilename,TEXT("MASTER.DSK")); // TODO: Should remember last disk by user _tcscat(imagefilename,TEXT("MASTER.DSK")); // TODO: Should remember last disk by user
@ -485,7 +500,7 @@ void DiskSetProtect( const int iDrive, const bool bWriteProtect )
//=========================================================================== //===========================================================================
BYTE __stdcall DiskReadWrite (WORD programcounter, BYTE, BYTE, BYTE, ULONG) { static BYTE __stdcall DiskReadWrite (WORD programcounter, WORD, BYTE, BYTE, ULONG) {
Disk_t * fptr = &g_aFloppyDisk[currdrive]; Disk_t * fptr = &g_aFloppyDisk[currdrive];
diskaccessed = 1; diskaccessed = 1;
if ((!fptr->trackimagedata) && fptr->imagehandle) if ((!fptr->trackimagedata) && fptr->imagehandle)
@ -517,7 +532,9 @@ BYTE __stdcall DiskReadWrite (WORD programcounter, BYTE, BYTE, BYTE, ULONG) {
} }
//=========================================================================== //===========================================================================
void DiskReset () {
void DiskReset()
{
floppymotoron = 0; floppymotoron = 0;
phases = 0; phases = 0;
} }
@ -575,20 +592,21 @@ void DiskSelect (int drive)
} }
//=========================================================================== //===========================================================================
BYTE __stdcall DiskSetLatchValue (WORD, BYTE, BYTE write, BYTE value, ULONG) {
static BYTE __stdcall DiskSetLatchValue (WORD, WORD, BYTE write, BYTE value, ULONG) {
if (write) if (write)
floppylatch = value; floppylatch = value;
return floppylatch; return floppylatch;
} }
//=========================================================================== //===========================================================================
BYTE __stdcall DiskSetReadMode (WORD, BYTE, BYTE, BYTE, ULONG) { static BYTE __stdcall DiskSetReadMode (WORD, WORD, BYTE, BYTE, ULONG) {
floppywritemode = 0; floppywritemode = 0;
return MemReturnRandomData(g_aFloppyDisk[currdrive].writeprotected); return MemReturnRandomData(g_aFloppyDisk[currdrive].writeprotected);
} }
//=========================================================================== //===========================================================================
BYTE __stdcall DiskSetWriteMode (WORD, BYTE, BYTE, BYTE, ULONG) { static BYTE __stdcall DiskSetWriteMode (WORD, WORD, BYTE, BYTE, ULONG) {
floppywritemode = 1; floppywritemode = 1;
BOOL modechange = !g_aFloppyDisk[currdrive].writelight; BOOL modechange = !g_aFloppyDisk[currdrive].writelight;
g_aFloppyDisk[currdrive].writelight = 20000; g_aFloppyDisk[currdrive].writelight = 20000;
@ -646,6 +664,99 @@ bool DiskDriveSwap()
//=========================================================================== //===========================================================================
static BYTE __stdcall Disk_IORead(WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
static BYTE __stdcall Disk_IOWrite(WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
void DiskLoadRom(LPBYTE pCxRomPeripheral, UINT uSlot)
{
const UINT DISK2_FW_SIZE = 256;
HRSRC hResInfo = FindResource(NULL, MAKEINTRESOURCE(IDR_DISK2_FW), "FIRMWARE");
if(hResInfo == NULL)
return;
DWORD dwResSize = SizeofResource(NULL, hResInfo);
if(dwResSize != DISK2_FW_SIZE)
return;
HGLOBAL hResData = LoadResource(NULL, hResInfo);
if(hResData == NULL)
return;
BYTE* pData = (BYTE*) LockResource(hResData); // NB. Don't need to unlock resource
if(pData == NULL)
return;
memcpy(pCxRomPeripheral + uSlot*256, pData, DISK2_FW_SIZE);
// TODO/FIXME: HACK! REMOVE A WAIT ROUTINE FROM THE DISK CONTROLLER'S FIRMWARE
*(pCxRomPeripheral+0x064C) = 0xA9;
*(pCxRomPeripheral+0x064D) = 0x00;
*(pCxRomPeripheral+0x064E) = 0xEA;
//
RegisterIoHandler(uSlot, Disk_IORead, Disk_IOWrite, NULL, NULL, NULL, NULL);
}
//===========================================================================
static BYTE __stdcall Disk_IORead(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft)
{
addr &= 0xFF;
switch (addr & 0xf)
{
case 0x0: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x1: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x2: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x3: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x4: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x5: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x6: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x7: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x8: return DiskControlMotor(pc, addr, bWrite, d, nCyclesLeft);
case 0x9: return DiskControlMotor(pc, addr, bWrite, d, nCyclesLeft);
case 0xA: return DiskEnable(pc, addr, bWrite, d, nCyclesLeft);
case 0xB: return DiskEnable(pc, addr, bWrite, d, nCyclesLeft);
case 0xC: return DiskReadWrite(pc, addr, bWrite, d, nCyclesLeft);
case 0xD: return DiskSetLatchValue(pc, addr, bWrite, d, nCyclesLeft);
case 0xE: return DiskSetReadMode(pc, addr, bWrite, d, nCyclesLeft);
case 0xF: return DiskSetWriteMode(pc, addr, bWrite, d, nCyclesLeft);
}
return 0;
}
static BYTE __stdcall Disk_IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft)
{
addr &= 0xFF;
switch (addr & 0xf)
{
case 0x0: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x1: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x2: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x3: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x4: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x5: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x6: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x7: return DiskControlStepper(pc, addr, bWrite, d, nCyclesLeft);
case 0x8: return DiskControlMotor(pc, addr, bWrite, d, nCyclesLeft);
case 0x9: return DiskControlMotor(pc, addr, bWrite, d, nCyclesLeft);
case 0xA: return DiskEnable(pc, addr, bWrite, d, nCyclesLeft);
case 0xB: return DiskEnable(pc, addr, bWrite, d, nCyclesLeft);
case 0xC: return DiskReadWrite(pc, addr, bWrite, d, nCyclesLeft);
case 0xD: return DiskSetLatchValue(pc, addr, bWrite, d, nCyclesLeft);
case 0xE: return DiskSetReadMode(pc, addr, bWrite, d, nCyclesLeft);
case 0xF: return DiskSetWriteMode(pc, addr, bWrite, d, nCyclesLeft);
}
return 0;
}
//===========================================================================
DWORD DiskGetSnapshot(SS_CARD_DISK2* pSS, DWORD dwSlot) DWORD DiskGetSnapshot(SS_CARD_DISK2* pSS, DWORD dwSlot)
{ {
pSS->Hdr.UnitHdr.dwLength = sizeof(SS_CARD_DISK2); pSS->Hdr.UnitHdr.dwLength = sizeof(SS_CARD_DISK2);

View File

@ -36,13 +36,6 @@ void DiskSetProtect( const int iDrive, const bool bWriteProtect );
void DiskSelect (int); void DiskSelect (int);
void DiskUpdatePosition (DWORD); void DiskUpdatePosition (DWORD);
bool DiskDriveSwap(); bool DiskDriveSwap();
void DiskLoadRom(LPBYTE pCxRomPeripheral, UINT uSlot);
DWORD DiskGetSnapshot(SS_CARD_DISK2* pSS, DWORD dwSlot); DWORD DiskGetSnapshot(SS_CARD_DISK2* pSS, DWORD dwSlot);
DWORD DiskSetSnapshot(SS_CARD_DISK2* pSS, DWORD dwSlot); DWORD DiskSetSnapshot(SS_CARD_DISK2* pSS, DWORD dwSlot);
BYTE __stdcall DiskControlMotor (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall DiskControlStepper (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall DiskEnable (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall DiskReadWrite (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall DiskSetLatchValue (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall DiskSetReadMode (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall DiskSetWriteMode (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);

View File

@ -350,7 +350,7 @@ void DrawStatusArea (HDC passdc, int drawflags)
TextOut(dc,x+ 3,y+2,TEXT("1"),1); TextOut(dc,x+ 3,y+2,TEXT("1"),1);
SetTextColor(dc,RGB((iDrive2Status==2 ? 255 : 0),(iDrive2Status==1 ? 255 : 0),0)); SetTextColor(dc,RGB((iDrive2Status==2 ? 255 : 0),(iDrive2Status==1 ? 255 : 0),0));
TextOut(dc,x+13,y+2,TEXT("2"),1); TextOut(dc,x+13,y+2,TEXT("2"),1);
if (g_bApple2e) if (!IS_APPLE2)
{ {
SetTextAlign(dc,TA_RIGHT | TA_TOP); SetTextAlign(dc,TA_RIGHT | TA_TOP);
SetTextColor(dc,(bCaps SetTextColor(dc,(bCaps
@ -387,7 +387,7 @@ void DrawStatusArea (HDC passdc, int drawflags)
DrawBitmapRect(dc,x+12,y+8,&rect,diskbitmap[iDrive1Status]); DrawBitmapRect(dc,x+12,y+8,&rect,diskbitmap[iDrive1Status]);
DrawBitmapRect(dc,x+30,y+8,&rect,diskbitmap[iDrive2Status]); DrawBitmapRect(dc,x+30,y+8,&rect,diskbitmap[iDrive2Status]);
if (g_bApple2e) if (!IS_APPLE2)
{ {
RECT rect = {0,0,30,8}; RECT rect = {0,0,30,8};
DrawBitmapRect(dc,x+7,y+19,&rect,capsbitmap[bCaps != 0]); DrawBitmapRect(dc,x+7,y+19,&rect,capsbitmap[bCaps != 0]);
@ -397,11 +397,13 @@ void DrawStatusArea (HDC passdc, int drawflags)
if (drawflags & DRAW_TITLE) if (drawflags & DRAW_TITLE)
{ {
TCHAR title[40]; TCHAR title[40];
_tcscpy(title,g_bApple2e switch (g_Apple2Type)
? TITLE_APPLE_2_E {
: (g_bApple2plus case A2TYPE_APPLE2: _tcscpy(title, TITLE_APPLE_2); break;
? TITLE_APPLE_2_PLUS case A2TYPE_APPLE2PLUS: _tcscpy(title, TITLE_APPLE_2_PLUS); break;
: TITLE_APPLE_2_ORG )); case A2TYPE_APPLE2E: _tcscpy(title, TITLE_APPLE_2E); break;
case A2TYPE_APPLE2EEHANCED: _tcscpy(title, TITLE_APPLE_2E_ENHANCED); break;
}
switch (g_nAppMode) switch (g_nAppMode)
{ {
@ -522,7 +524,7 @@ LRESULT CALLBACK FrameWndProc (
HD_Cleanup(); HD_Cleanup();
} }
PrintDestroy(); PrintDestroy();
CommDestroy(); sg_SSC.CommDestroy();
CpuDestroy(); CpuDestroy();
MemDestroy(); MemDestroy();
SpkrDestroy(); SpkrDestroy();
@ -1071,7 +1073,7 @@ void ResetMachineState () {
MemReset(); MemReset();
DiskBoot(); DiskBoot();
VideoResetState(); VideoResetState();
CommReset(); sg_SSC.CommReset();
PrintReset(); PrintReset();
JoyReset(); JoyReset();
MB_Reset(); MB_Reset();
@ -1182,25 +1184,16 @@ void FrameCreateWindow ()
if (!RegLoadValue(TEXT("Preferences"),TEXT("Window Y-Position"),1,(DWORD *)&ypos)) if (!RegLoadValue(TEXT("Preferences"),TEXT("Window Y-Position"),1,(DWORD *)&ypos))
ypos = (GetSystemMetrics(SM_CYSCREEN)-height) >> 1; ypos = (GetSystemMetrics(SM_CYSCREEN)-height) >> 1;
if (g_bApple2e) switch (g_Apple2Type)
{ {
g_pAppTitle = TITLE_APPLE_2_E; case A2TYPE_APPLE2: g_pAppTitle = TITLE_APPLE_2; break;
} case A2TYPE_APPLE2PLUS: g_pAppTitle = TITLE_APPLE_2_PLUS; break;
else case A2TYPE_APPLE2E: g_pAppTitle = TITLE_APPLE_2E; break;
{ case A2TYPE_APPLE2EEHANCED: g_pAppTitle = TITLE_APPLE_2E_ENHANCED; break;
if (g_bApple2plus)
g_pAppTitle = TITLE_APPLE_2_PLUS;
else
g_pAppTitle = TITLE_APPLE_2_ORG;
} }
g_hFrameWindow = CreateWindow( g_hFrameWindow = CreateWindow(
TEXT("APPLE2FRAME"), TEXT("APPLE2FRAME"),
// g_bApple2e
// ? TITLE_APPLE_2_E
// : (g_bApple2plus
// ? TITLE_APPLE_2_PLUS
// : TITLE_APPLE_2),
g_pAppTitle, g_pAppTitle,
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
WS_MINIMIZEBOX | WS_VISIBLE, WS_MINIMIZEBOX | WS_VISIBLE,

View File

@ -127,6 +127,8 @@ static BYTE g_nHD_Command;
static HDD g_HardDrive[2] = {0}; static HDD g_HardDrive[2] = {0};
static UINT g_uSlot = 7;
//=========================================================================== //===========================================================================
static void GetImageTitle (LPCTSTR imagefilename, PHDD pHardDrive) static void GetImageTitle (LPCTSTR imagefilename, PHDD pHardDrive)
@ -212,6 +214,8 @@ static LPCTSTR HD_DiskGetName (int nDrive)
// everything below is global // everything below is global
static BYTE __stdcall HD_IO_EMUL (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
static const DWORD HDDRVR_SIZE = 0x100; static const DWORD HDDRVR_SIZE = 0x100;
static LPBYTE lpMemC000 = NULL; static LPBYTE lpMemC000 = NULL;
@ -231,9 +235,11 @@ void HD_SetEnabled(bool bEnabled)
return; return;
if(g_bHD_Enabled) if(g_bHD_Enabled)
HD_Load_Rom(lpMemC000); HD_Load_Rom(lpMemC000, g_uSlot);
else else
memset(lpMemC000+0x700, 0, HDDRVR_SIZE); memset(lpMemC000 + g_uSlot*256, 0, HDDRVR_SIZE);
RegisterIoHandler(g_uSlot, HD_IO_EMUL, HD_IO_EMUL, NULL, NULL, NULL, NULL);
} }
LPCTSTR HD_GetFullName (int nDrive) LPCTSTR HD_GetFullName (int nDrive)
@ -241,14 +247,14 @@ LPCTSTR HD_GetFullName (int nDrive)
return g_HardDrive[nDrive].hd_fullname; return g_HardDrive[nDrive].hd_fullname;
} }
VOID HD_Load_Rom(LPBYTE lpMemRom) VOID HD_Load_Rom(LPBYTE pCxRomPeripheral, UINT uSlot)
{ {
lpMemC000 = lpMemRom; // Keep a copy for HD_SetEnabled() lpMemC000 = pCxRomPeripheral; // Keep a copy for HD_SetEnabled()
if(!g_bHD_Enabled) if(!g_bHD_Enabled)
return; return;
HRSRC hResInfo = FindResource(NULL, MAKEINTRESOURCE(IDR_HDDRVR), "FIRMWARE"); HRSRC hResInfo = FindResource(NULL, MAKEINTRESOURCE(IDR_HDDRVR_FW), "FIRMWARE");
if(hResInfo == NULL) if(hResInfo == NULL)
return; return;
@ -264,7 +270,8 @@ VOID HD_Load_Rom(LPBYTE lpMemRom)
if(pData == NULL) if(pData == NULL)
return; return;
memcpy(lpMemRom+0x700, pData, HDDRVR_SIZE); g_uSlot = uSlot;
memcpy(pCxRomPeripheral + uSlot*256, pData, HDDRVR_SIZE);
g_bHD_RomLoaded = true; g_bHD_RomLoaded = true;
} }
@ -354,9 +361,10 @@ void HD_Select(int nDrive)
#define DEVICE_UNKNOWN_ERROR 0x03 #define DEVICE_UNKNOWN_ERROR 0x03
#define DEVICE_IO_ERROR 0x08 #define DEVICE_IO_ERROR 0x08
BYTE __stdcall HD_IO_EMUL (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft) static BYTE __stdcall HD_IO_EMUL (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft)
{ {
BYTE r = DEVICE_OK; BYTE r = DEVICE_OK;
addr &= 0xFF;
if (!HD_CardIsEnabled()) if (!HD_CardIsEnabled())
return r; return r;
@ -505,8 +513,7 @@ BYTE __stdcall HD_IO_EMUL (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCycle
} }
break; break;
default: default:
{ return IO_Null(pc, addr, bWrite, d, nCyclesLeft);
}
} }
} }
else // write else // write
@ -547,21 +554,9 @@ BYTE __stdcall HD_IO_EMUL (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCycle
} }
break; break;
default: default:
break; return IO_Null(pc, addr, bWrite, d, nCyclesLeft);
} }
} }
return r; return r;
} }

View File

@ -3,10 +3,8 @@
bool HD_CardIsEnabled(); bool HD_CardIsEnabled();
void HD_SetEnabled(bool bEnabled); void HD_SetEnabled(bool bEnabled);
LPCTSTR HD_GetFullName (int drive); LPCTSTR HD_GetFullName (int drive);
VOID HD_Load_Rom(LPBYTE lpMemRom); VOID HD_Load_Rom(LPBYTE pCxRomPeripheral, UINT uSlot);
VOID HD_Cleanup(); VOID HD_Cleanup();
BOOL HD_InsertDisk2(int nDrive, LPCTSTR pszFilename); BOOL HD_InsertDisk2(int nDrive, LPCTSTR pszFilename);
BOOL HD_InsertDisk(int nDrive, LPCTSTR imagefilename); BOOL HD_InsertDisk(int nDrive, LPCTSTR imagefilename);
void HD_Select(int nDrive); void HD_Select(int nDrive);
BYTE __stdcall HD_IO_EMUL (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);

View File

@ -365,8 +365,10 @@ BOOL JoyProcessKey (int virtkey, BOOL extended, BOOL down, BOOL autorep)
//=========================================================================== //===========================================================================
BYTE __stdcall JoyReadButton (WORD, BYTE address, BYTE, BYTE, ULONG) BYTE __stdcall JoyReadButton (WORD, WORD address, BYTE, BYTE, ULONG)
{ {
address &= 0xFF;
if(joyinfo[joytype[0]].device == DEVICE_JOYSTICK) if(joyinfo[joytype[0]].device == DEVICE_JOYSTICK)
CheckJoystick0(); CheckJoystick0();
if(joyinfo[joytype[1]].device == DEVICE_JOYSTICK) if(joyinfo[joytype[1]].device == DEVICE_JOYSTICK)
@ -417,7 +419,7 @@ BYTE __stdcall JoyReadButton (WORD, BYTE address, BYTE, BYTE, ULONG)
static const double PDL_CNTR_INTERVAL = 2816.0 / 255.0; // 11.04 (From KEGS) static const double PDL_CNTR_INTERVAL = 2816.0 / 255.0; // 11.04 (From KEGS)
BYTE __stdcall JoyReadPosition (WORD programcounter, BYTE address, BYTE, BYTE, ULONG nCyclesLeft) BYTE __stdcall JoyReadPosition (WORD programcounter, WORD address, BYTE, BYTE, ULONG nCyclesLeft)
{ {
int nJoyNum = (address & 2) ? 1 : 0; // $C064..$C067 int nJoyNum = (address & 2) ? 1 : 0; // $C064..$C067
@ -443,7 +445,7 @@ void JoyReset ()
} }
//=========================================================================== //===========================================================================
BYTE __stdcall JoyResetPosition (WORD, BYTE, BYTE, BYTE, ULONG nCyclesLeft) BYTE __stdcall JoyResetPosition (WORD, WORD, BYTE, BYTE, ULONG nCyclesLeft)
{ {
CpuCalcCycles(nCyclesLeft); CpuCalcCycles(nCyclesLeft);
g_nJoyCntrResetCycle = g_nCumulativeCycles; g_nJoyCntrResetCycle = g_nCumulativeCycles;

View File

@ -17,6 +17,6 @@ short JoyGetTrim(bool bAxisX);
DWORD JoyGetSnapshot(SS_IO_Joystick* pSS); DWORD JoyGetSnapshot(SS_IO_Joystick* pSS);
DWORD JoySetSnapshot(SS_IO_Joystick* pSS); DWORD JoySetSnapshot(SS_IO_Joystick* pSS);
BYTE __stdcall JoyReadButton (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); BYTE __stdcall JoyReadButton (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall JoyReadPosition (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); BYTE __stdcall JoyReadPosition (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall JoyResetPosition (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); BYTE __stdcall JoyResetPosition (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);

View File

@ -167,7 +167,7 @@ void KeybQueueKeypress (int key, BOOL bASCII)
if (key > 0x7F) if (key > 0x7F)
return; return;
if (g_bApple2e) if (!IS_APPLE2)
{ {
if (g_bCapsLock && (key >= 'a') && (key <='z')) if (g_bCapsLock && (key >= 'a') && (key <='z'))
keycode = key - 32; keycode = key - 32;
@ -188,12 +188,12 @@ void KeybQueueKeypress (int key, BOOL bASCII)
if ((key == VK_CANCEL) && (GetKeyState(VK_CONTROL) < 0)) if ((key == VK_CANCEL) && (GetKeyState(VK_CONTROL) < 0))
{ {
// Ctrl+Reset // Ctrl+Reset
if (g_bApple2e) if (!IS_APPLE2)
MemResetPaging(); MemResetPaging();
DiskReset(); DiskReset();
KeybReset(); KeybReset();
if (g_bApple2e) if (!IS_APPLE2)
VideoResetState(); // Switch Alternate char set off VideoResetState(); // Switch Alternate char set off
MB_Reset(); MB_Reset();
@ -213,10 +213,10 @@ void KeybQueueKeypress (int key, BOOL bASCII)
return; return;
} }
if (!((key >= VK_LEFT) && (key <= VK_DELETE) && asciicode[g_bApple2e][key - VK_LEFT])) if (!((key >= VK_LEFT) && (key <= VK_DELETE) && asciicode[IS_APPLE2 ? 0 : 1][key - VK_LEFT]))
return; return;
keycode = asciicode[g_bApple2e][key - VK_LEFT]; // Convert to Apple arrow keycode keycode = asciicode[IS_APPLE2 ? 0 : 1][key - VK_LEFT]; // Convert to Apple arrow keycode
lastvirtkey = key; lastvirtkey = key;
} }
#ifdef KEY_OLD #ifdef KEY_OLD
@ -314,7 +314,7 @@ static char ClipboardCurrChar(bool bIncPtr)
//=========================================================================== //===========================================================================
BYTE __stdcall KeybReadData (WORD, BYTE, BYTE, BYTE, ULONG) BYTE __stdcall KeybReadData (WORD, WORD, BYTE, BYTE, ULONG)
{ {
keyboardqueries++; keyboardqueries++;
@ -352,7 +352,7 @@ BYTE __stdcall KeybReadData (WORD, BYTE, BYTE, BYTE, ULONG)
//=========================================================================== //===========================================================================
BYTE __stdcall KeybReadFlag (WORD, BYTE, BYTE, BYTE, ULONG) BYTE __stdcall KeybReadFlag (WORD, WORD, BYTE, BYTE, ULONG)
{ {
keyboardqueries++; keyboardqueries++;
@ -389,7 +389,7 @@ BYTE __stdcall KeybReadFlag (WORD, BYTE, BYTE, BYTE, ULONG)
//=========================================================================== //===========================================================================
void KeybToggleCapsLock () void KeybToggleCapsLock ()
{ {
if (g_bApple2e) if (!IS_APPLE2)
{ {
g_bCapsLock = (GetKeyState(VK_CAPITAL) & 1); g_bCapsLock = (GetKeyState(VK_CAPITAL) & 1);
FrameRefreshStatus(DRAW_LEDS); FrameRefreshStatus(DRAW_LEDS);

View File

@ -15,5 +15,5 @@ void KeybToggleCapsLock ();
DWORD KeybGetSnapshot(SS_IO_Keyboard* pSS); DWORD KeybGetSnapshot(SS_IO_Keyboard* pSS);
DWORD KeybSetSnapshot(SS_IO_Keyboard* pSS); DWORD KeybSetSnapshot(SS_IO_Keyboard* pSS);
BYTE __stdcall KeybReadData (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); BYTE __stdcall KeybReadData (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall KeybReadFlag (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); BYTE __stdcall KeybReadFlag (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);

File diff suppressed because it is too large Load Diff

View File

@ -9,12 +9,9 @@ enum MemoryInitPattern_e
}; };
extern MemoryInitPattern_e g_eMemoryInitPattern; extern MemoryInitPattern_e g_eMemoryInitPattern;
extern iofunction ioread[0x100]; extern iofunction IORead[256];
extern iofunction iowrite[0x100]; extern iofunction IOWrite[256];
extern LPBYTE memshadow[MAXIMAGES][0x100]; extern LPBYTE memwrite[0x100];
extern LPBYTE memwrite[MAXIMAGES][0x100];
extern DWORD image;
extern DWORD lastimage;
extern LPBYTE mem; extern LPBYTE mem;
extern LPBYTE memdirty; extern LPBYTE memdirty;
@ -22,10 +19,14 @@ extern LPBYTE memdirty;
extern UINT g_uMaxExPages; // user requested ram pages (from cmd line) extern UINT g_uMaxExPages; // user requested ram pages (from cmd line)
#endif #endif
void RegisterIoHandler(UINT uSlot, iofunction IOReadC0, iofunction IOWriteC0, iofunction IOReadCx, iofunction IOWriteCx, LPVOID lpSlotParameter, BYTE* pExpansionRom);
void MemDestroy (); void MemDestroy ();
bool MemGet80Store(); bool MemGet80Store();
bool MemCheckSLOTCXROM();
LPBYTE MemGetAuxPtr (WORD); LPBYTE MemGetAuxPtr (WORD);
LPBYTE MemGetMainPtr (WORD); LPBYTE MemGetMainPtr (WORD);
void MemPreInitialize ();
void MemInitialize (); void MemInitialize ();
BYTE MemReadFloatingBus(); BYTE MemReadFloatingBus();
BYTE MemReadFloatingBus(BYTE highbit); BYTE MemReadFloatingBus(BYTE highbit);
@ -34,11 +35,11 @@ void MemResetPaging ();
BYTE MemReturnRandomData (BYTE highbit); BYTE MemReturnRandomData (BYTE highbit);
void MemSetFastPaging (BOOL); void MemSetFastPaging (BOOL);
void MemTrimImages (); void MemTrimImages ();
LPVOID MemGetSlotParameters (UINT uSlot);
DWORD MemGetSnapshot(SS_BaseMemory* pSS); DWORD MemGetSnapshot(SS_BaseMemory* pSS);
DWORD MemSetSnapshot(SS_BaseMemory* pSS); DWORD MemSetSnapshot(SS_BaseMemory* pSS);
BYTE __stdcall CxReadFunc(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); BYTE __stdcall IO_Null(WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCycles);
BYTE __stdcall CxWriteFunc(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall MemCheckPaging (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); BYTE __stdcall MemCheckPaging (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall MemSetPaging (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); BYTE __stdcall MemSetPaging(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);

View File

@ -1269,6 +1269,10 @@ static void MB_DSUninit()
//============================================================================= //=============================================================================
static BYTE __stdcall PhasorIO (WORD PC, WORD nAddr, BYTE bWrite, BYTE nValue, ULONG nCyclesLeft);
static BYTE __stdcall MB_Read(WORD PC, WORD nAddr, BYTE bWrite, BYTE nValue, ULONG nCyclesLeft);
static BYTE __stdcall MB_Write(WORD PC, WORD nAddr, BYTE bWrite, BYTE nValue, ULONG nCyclesLeft);
void MB_Initialize() void MB_Initialize()
{ {
if(g_bDisableDirectSound) if(g_bDisableDirectSound)
@ -1300,6 +1304,14 @@ void MB_Initialize()
// //
g_bMB_Active = (g_SoundcardType != SC_NONE); g_bMB_Active = (g_SoundcardType != SC_NONE);
//
const UINT uSlot4 = 4;
RegisterIoHandler(uSlot4, PhasorIO, PhasorIO, MB_Read, MB_Write, NULL, NULL);
const UINT uSlot5 = 5;
RegisterIoHandler(uSlot5, PhasorIO, PhasorIO, MB_Read, MB_Write, NULL, NULL);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1340,8 +1352,13 @@ void MB_Reset()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
BYTE MB_Read(WORD nAddr) static BYTE __stdcall MB_Read(WORD PC, WORD nAddr, BYTE bWrite, BYTE nValue, ULONG nCyclesLeft)
{ {
CpuCalcCycles(nCyclesLeft);
if(!IS_APPLE2 && !MemCheckSLOTCXROM())
return mem[nAddr];
if(g_SoundcardType == SC_NONE) if(g_SoundcardType == SC_NONE)
return 0; return 0;
@ -1385,10 +1402,15 @@ BYTE MB_Read(WORD nAddr)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void MB_Write(WORD nAddr, BYTE nValue) static BYTE __stdcall MB_Write(WORD PC, WORD nAddr, BYTE bWrite, BYTE nValue, ULONG nCyclesLeft)
{ {
CpuCalcCycles(nCyclesLeft);
if(!IS_APPLE2 && !MemCheckSLOTCXROM())
return 0;
if(g_SoundcardType == SC_NONE) if(g_SoundcardType == SC_NONE)
return; return 0;
BYTE nMB = (nAddr>>8)&0xf - SLOT4; BYTE nMB = (nAddr>>8)&0xf - SLOT4;
BYTE nOffset = nAddr&0xff; BYTE nOffset = nAddr&0xff;
@ -1396,7 +1418,7 @@ void MB_Write(WORD nAddr, BYTE nValue)
if(g_bPhasorEnable) if(g_bPhasorEnable)
{ {
if(nMB != 0) // Slot4 only if(nMB != 0) // Slot4 only
return; return 0;
int CS; int CS;
@ -1414,7 +1436,7 @@ void MB_Write(WORD nAddr, BYTE nValue)
if((nOffset >= SSI263_Offset) && (nOffset <= (SSI263_Offset+0x05))) if((nOffset >= SSI263_Offset) && (nOffset <= (SSI263_Offset+0x05)))
SSI263_Write(nMB*2+1, nAddr&0xf, nValue); // Second 6522 is used for speech chip SSI263_Write(nMB*2+1, nAddr&0xf, nValue); // Second 6522 is used for speech chip
return; return 0;
} }
if(nOffset <= (SY6522A_Offset+0x0F)) if(nOffset <= (SY6522A_Offset+0x0F))
@ -1423,19 +1445,21 @@ void MB_Write(WORD nAddr, BYTE nValue)
SY6522_Write(nMB*NUM_DEVS_PER_MB + SY6522_DEVICE_B, nAddr&0xf, nValue); SY6522_Write(nMB*NUM_DEVS_PER_MB + SY6522_DEVICE_B, nAddr&0xf, nValue);
else if((nOffset >= SSI263_Offset) && (nOffset <= (SSI263_Offset+0x05))) else if((nOffset >= SSI263_Offset) && (nOffset <= (SSI263_Offset+0x05)))
SSI263_Write(nMB*2+1, nAddr&0xf, nValue); // Second 6522 is used for speech chip SSI263_Write(nMB*2+1, nAddr&0xf, nValue); // Second 6522 is used for speech chip
return 0;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
BYTE __stdcall PhasorIO (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft) static BYTE __stdcall PhasorIO (WORD PC, WORD nAddr, BYTE bWrite, BYTE nValue, ULONG nCyclesLeft)
{ {
if(!g_bPhasorEnable) if(!g_bPhasorEnable)
return 0; return 0;
if(g_nPhasorMode < 2) if(g_nPhasorMode < 2)
g_nPhasorMode = addr & 1; g_nPhasorMode = nAddr & 1;
double fCLK = (addr & 4) ? CLK_6502*2 : CLK_6502; double fCLK = (nAddr & 4) ? CLK_6502*2 : CLK_6502;
AY8910_InitClock((int)fCLK); AY8910_InitClock((int)fCLK);

View File

@ -7,8 +7,6 @@ void MB_Initialize();
void MB_Reinitialize(); void MB_Reinitialize();
void MB_Destroy(); void MB_Destroy();
void MB_Reset(); void MB_Reset();
BYTE MB_Read(WORD nAddr);
void MB_Write(WORD nAddr, BYTE nValue);
void MB_Mute(); void MB_Mute();
void MB_Demute(); void MB_Demute();
void MB_EndOfFrame(); void MB_EndOfFrame();
@ -22,5 +20,3 @@ DWORD MB_GetVolume();
void MB_SetVolume(DWORD dwVolume, DWORD dwVolumeMax); void MB_SetVolume(DWORD dwVolume, DWORD dwVolumeMax);
DWORD MB_GetSnapshot(SS_CARD_MOCKINGBOARD* pSS, DWORD dwSlot); DWORD MB_GetSnapshot(SS_CARD_MOCKINGBOARD* pSS, DWORD dwSlot);
DWORD MB_SetSnapshot(SS_CARD_MOCKINGBOARD* pSS, DWORD dwSlot); DWORD MB_SetSnapshot(SS_CARD_MOCKINGBOARD* pSS, DWORD dwSlot);
BYTE __stdcall PhasorIO (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);

View File

@ -35,9 +35,13 @@ static FILE* file = NULL;
DWORD const PRINTDRVR_SIZE = 0x100; DWORD const PRINTDRVR_SIZE = 0x100;
//=========================================================================== //===========================================================================
VOID PrintLoadRom(LPBYTE lpMemRom)
static BYTE __stdcall PrintStatus(WORD, WORD, BYTE, BYTE, ULONG);
static BYTE __stdcall PrintTransmit(WORD, WORD, BYTE, BYTE value, ULONG);
VOID PrintLoadRom(LPBYTE pCxRomPeripheral, const UINT uSlot)
{ {
HRSRC hResInfo = FindResource(NULL, MAKEINTRESOURCE(IDR_PRINTDRVR), "FIRMWARE"); HRSRC hResInfo = FindResource(NULL, MAKEINTRESOURCE(IDR_PRINTDRVR_FW), "FIRMWARE");
if(hResInfo == NULL) if(hResInfo == NULL)
return; return;
@ -53,7 +57,11 @@ VOID PrintLoadRom(LPBYTE lpMemRom)
if(pData == NULL) if(pData == NULL)
return; return;
memcpy(lpMemRom + 0x100, pData, PRINTDRVR_SIZE); memcpy(pCxRomPeripheral + uSlot*256, pData, PRINTDRVR_SIZE);
//
RegisterIoHandler(uSlot, PrintStatus, PrintTransmit, NULL, NULL, NULL, NULL);
} }
//=========================================================================== //===========================================================================
@ -108,14 +116,14 @@ void PrintReset()
} }
//=========================================================================== //===========================================================================
BYTE __stdcall PrintStatus(WORD, BYTE, BYTE, BYTE, ULONG) static BYTE __stdcall PrintStatus(WORD, WORD, BYTE, BYTE, ULONG)
{ {
CheckPrint(); CheckPrint();
return 0xFF; // status - TODO? return 0xFF; // status - TODO?
} }
//=========================================================================== //===========================================================================
BYTE __stdcall PrintTransmit(WORD, BYTE, BYTE, BYTE value, ULONG) static BYTE __stdcall PrintTransmit(WORD, WORD, BYTE, BYTE value, ULONG)
{ {
if (!CheckPrint()) if (!CheckPrint())
{ {

View File

@ -1,9 +1,6 @@
#pragma once #pragma once
void PrintDestroy(); void PrintDestroy();
void PrintLoadRom(LPBYTE); void PrintLoadRom(LPBYTE pCxRomPeripheral, UINT uSlot);
void PrintReset(); void PrintReset();
void PrintUpdate(DWORD); void PrintUpdate(DWORD);
BYTE __stdcall PrintStatus (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall PrintTransmit (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);

View File

@ -34,10 +34,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Tfe\Tfesupp.h" #include "Tfe\Tfesupp.h"
#include "Tfe\Uilib.h" #include "Tfe\Uilib.h"
TCHAR computerchoices[] =
TCHAR computerchoices[] = TEXT("Apple ][ (Original Model)\0") TEXT("Apple ][ (Original Model)\0")
TEXT("Apple ][+\0") TEXT("Apple ][+\0")
TEXT("Apple //e\0"); TEXT("Apple //e\0")
TEXT("Enhanced Apple //e\0");
TCHAR* szJoyChoice0 = TEXT("Disabled\0"); TCHAR* szJoyChoice0 = TEXT("Disabled\0");
TCHAR* szJoyChoice1 = TEXT("PC Joystick #1\0"); TCHAR* szJoyChoice1 = TEXT("PC Joystick #1\0");
@ -203,11 +204,24 @@ static void InitJoystickChoices(HWND window, int nJoyNum, int nIdcValue)
static void ConfigDlg_OK(HWND window, BOOL afterclose) static void ConfigDlg_OK(HWND window, BOOL afterclose)
{ {
BOOL newcomptype = (BOOL) SendDlgItemMessage(window,IDC_COMPUTER,CB_GETCURSEL,0,0); eApple2Type NewApple2Type;
{
DWORD newcomptype = (DWORD) SendDlgItemMessage(window,IDC_COMPUTER,CB_GETCURSEL,0,0);
switch (newcomptype)
{
case 0: NewApple2Type = A2TYPE_APPLE2; break;
case 1: NewApple2Type = A2TYPE_APPLE2PLUS; break;
case 2: NewApple2Type = A2TYPE_APPLE2E; break;
case 3: NewApple2Type = A2TYPE_APPLE2EEHANCED; break;
}
}
DWORD newvidtype = (DWORD)SendDlgItemMessage(window,IDC_VIDEOTYPE,CB_GETCURSEL,0,0); DWORD newvidtype = (DWORD)SendDlgItemMessage(window,IDC_VIDEOTYPE,CB_GETCURSEL,0,0);
DWORD newserialport = (DWORD)SendDlgItemMessage(window,IDC_SERIALPORT,CB_GETCURSEL,0,0); DWORD newserialport = (DWORD)SendDlgItemMessage(window,IDC_SERIALPORT,CB_GETCURSEL,0,0);
if (newcomptype != (g_bApple2e ? 2 : (g_bApple2plus ? 1 : 0))) if (NewApple2Type != g_Apple2Type)
{ {
if (MessageBox(window, if (MessageBox(window,
TEXT( TEXT(
@ -228,7 +242,8 @@ static void ConfigDlg_OK(HWND window, BOOL afterclose)
if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG)) if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG))
VideoRedrawScreen(); VideoRedrawScreen();
} }
CommSetSerialPort(window,newserialport);
sg_SSC.CommSetSerialPort(window,newserialport);
if (IsDlgButtonChecked(window,IDC_AUTHENTIC_SPEED)) if (IsDlgButtonChecked(window,IDC_AUTHENTIC_SPEED))
g_dwSpeed = SPEED_NORMAL; g_dwSpeed = SPEED_NORMAL;
@ -237,8 +252,8 @@ static void ConfigDlg_OK(HWND window, BOOL afterclose)
SetCurrentCLK6502(); SetCurrentCLK6502();
SAVE(TEXT("Computer Emulation"),newcomptype); SAVE(TEXT(REGVALUE_APPLE2_TYPE),NewApple2Type);
SAVE(TEXT("Serial Port") ,serialport); SAVE(TEXT("Serial Port") ,sg_SSC.GetSerialPort());
SAVE(TEXT("Custom Speed") ,IsDlgButtonChecked(window,IDC_CUSTOM_SPEED)); SAVE(TEXT("Custom Speed") ,IsDlgButtonChecked(window,IDC_CUSTOM_SPEED));
SAVE(TEXT("Emulation Speed") ,g_dwSpeed); SAVE(TEXT("Emulation Speed") ,g_dwSpeed);
SAVE(TEXT("Video Emulation") ,videotype); SAVE(TEXT("Video Emulation") ,videotype);
@ -342,9 +357,18 @@ static BOOL CALLBACK ConfigDlgProc (HWND window,
{ {
g_nLastPage = PG_CONFIG; g_nLastPage = PG_CONFIG;
FillComboBox(window,IDC_COMPUTER,computerchoices,g_bApple2e ? 2 : (g_bApple2plus ? 1 : 0)); UINT iApple2String;
switch (g_Apple2Type)
{
case A2TYPE_APPLE2: iApple2String = 0; break;
case A2TYPE_APPLE2PLUS: iApple2String = 1; break;
case A2TYPE_APPLE2E: iApple2String = 2; break;
case A2TYPE_APPLE2EEHANCED: iApple2String = 3; break;
}
FillComboBox(window,IDC_COMPUTER,computerchoices,iApple2String);
FillComboBox(window,IDC_VIDEOTYPE,videochoices,videotype); FillComboBox(window,IDC_VIDEOTYPE,videochoices,videotype);
FillComboBox(window,IDC_SERIALPORT,serialchoices,serialport); FillComboBox(window,IDC_SERIALPORT,serialchoices,sg_SSC.GetSerialPort());
SendDlgItemMessage(window,IDC_SLIDER_CPU_SPEED,TBM_SETRANGE,1,MAKELONG(0,40)); SendDlgItemMessage(window,IDC_SLIDER_CPU_SPEED,TBM_SETRANGE,1,MAKELONG(0,40));
SendDlgItemMessage(window,IDC_SLIDER_CPU_SPEED,TBM_SETPAGESIZE,0,5); SendDlgItemMessage(window,IDC_SLIDER_CPU_SPEED,TBM_SETPAGESIZE,0,5);
SendDlgItemMessage(window,IDC_SLIDER_CPU_SPEED,TBM_SETTICFREQ,10,0); SendDlgItemMessage(window,IDC_SLIDER_CPU_SPEED,TBM_SETTICFREQ,10,0);

View File

@ -116,7 +116,7 @@ void Snapshot_LoadState()
// Reset all sub-systems // Reset all sub-systems
MemReset(); MemReset();
if (g_bApple2e) if (!IS_APPLE2)
MemResetPaging(); MemResetPaging();
DiskReset(); DiskReset();
@ -129,7 +129,7 @@ void Snapshot_LoadState()
// //
CpuSetSnapshot(&pSS->Apple2Unit.CPU6502); CpuSetSnapshot(&pSS->Apple2Unit.CPU6502);
CommSetSnapshot(&pSS->Apple2Unit.Comms); sg_SSC.CommSetSnapshot(&pSS->Apple2Unit.Comms);
JoySetSnapshot(&pSS->Apple2Unit.Joystick); JoySetSnapshot(&pSS->Apple2Unit.Joystick);
KeybSetSnapshot(&pSS->Apple2Unit.Keyboard); KeybSetSnapshot(&pSS->Apple2Unit.Keyboard);
SpkrSetSnapshot(&pSS->Apple2Unit.Speaker); SpkrSetSnapshot(&pSS->Apple2Unit.Speaker);
@ -186,7 +186,7 @@ void Snapshot_SaveState()
pSS->Apple2Unit.UnitHdr.dwVersion = MAKE_VERSION(1,0,0,0); pSS->Apple2Unit.UnitHdr.dwVersion = MAKE_VERSION(1,0,0,0);
CpuGetSnapshot(&pSS->Apple2Unit.CPU6502); CpuGetSnapshot(&pSS->Apple2Unit.CPU6502);
CommGetSnapshot(&pSS->Apple2Unit.Comms); sg_SSC.CommGetSnapshot(&pSS->Apple2Unit.Comms);
JoyGetSnapshot(&pSS->Apple2Unit.Joystick); JoyGetSnapshot(&pSS->Apple2Unit.Joystick);
KeybGetSnapshot(&pSS->Apple2Unit.Keyboard); KeybGetSnapshot(&pSS->Apple2Unit.Keyboard);
SpkrGetSnapshot(&pSS->Apple2Unit.Speaker); SpkrGetSnapshot(&pSS->Apple2Unit.Speaker);

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,109 @@
#pragma once #pragma once
extern DWORD serialport; extern class CSuperSerialCard sg_SSC;
void CommDestroy (); enum {COMMEVT_WAIT=0, COMMEVT_ACK, COMMEVT_TERM, COMMEVT_MAX};
void CommReset (); enum eFWMODE {FWMODE_CIC=0, FWMODE_SIC_P8, FWMODE_PPC, FWMODE_SIC_P8A}; // NB. CIC = SSC
void CommSetSerialPort (HWND,DWORD);
void CommUpdate (DWORD);
bool CommThInit();
void CommThUninit();
DWORD CommGetSnapshot(SS_IO_Comms* pSS);
DWORD CommSetSnapshot(SS_IO_Comms* pSS);
BYTE __stdcall CommCommand (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); typedef struct
BYTE __stdcall CommControl (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); {
BYTE __stdcall CommDipSw (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); //DIPSW1
BYTE __stdcall CommReceive (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); UINT uBaudRate;
BYTE __stdcall CommStatus (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); eFWMODE eFirmwareMode;
BYTE __stdcall CommTransmit (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
//DIPSW2
UINT uStopBits;
UINT uByteSize;
UINT uParity;
bool bLinefeed;
bool bInterrupts;
} SSC_DIPSW;
class CSuperSerialCard
{
public:
CSuperSerialCard();
~CSuperSerialCard();
void CommInitialize(LPBYTE pCxRomPeripheral, UINT uSlot);
void CommReset();
void CommDestroy();
void CommSetSerialPort(HWND,DWORD);
void CommUpdate(DWORD);
DWORD CommGetSnapshot(SS_IO_Comms* pSS);
DWORD CommSetSnapshot(SS_IO_Comms* pSS);
DWORD GetSerialPort() { return m_dwSerialPort; }
void SetSerialPort(DWORD dwSerialPort) { m_dwSerialPort = dwSerialPort; }
static BYTE __stdcall SSC_IORead(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nCyclesLeft);
static BYTE __stdcall SSC_IOWrite(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nCyclesLeft);
private:
BYTE __stdcall CommCommand(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall CommControl(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall CommDipSw(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall CommReceive(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall CommStatus(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall CommTransmit(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
void GetDIPSW();
void SetDIPSWDefaults();
BYTE GenerateControl();
UINT BaudRateToIndex(UINT uBaudRate);
void UpdateCommState();
BOOL CheckComm();
void CloseComm();
void CheckCommEvent(DWORD dwEvtMask);
static DWORD WINAPI CommThread(LPVOID lpParameter);
bool CommThInit();
void CommThUninit();
//
private:
DWORD m_dwSerialPort;
static SSC_DIPSW m_DIPSWDefault;
SSC_DIPSW m_DIPSWCurrent;
// Derived from DIPSW1
UINT m_uBaudRate;
// Derived from DIPSW2
UINT m_uStopBits;
UINT m_uByteSize;
UINT m_uParity;
// SSC Registers
BYTE m_uControlByte;
BYTE m_uCommandByte;
//
HANDLE m_hCommHandle;
DWORD m_dwCommInactivity;
//
CRITICAL_SECTION m_CriticalSection; // To guard /g_vRecvBytes/
BYTE m_RecvBuffer[uRecvBufferSize]; // NB: More work required if >1 is used
volatile DWORD m_vRecvBytes;
//
bool m_bTxIrqEnabled;
bool m_bRxIrqEnabled;
bool m_bWrittenTx;
//
volatile bool m_vbCommIRQ;
HANDLE m_hCommThread;
HANDLE m_hCommEvent[COMMEVT_MAX];
OVERLAPPED m_o;
BYTE* m_pExpansionRom;
};

View File

@ -419,7 +419,7 @@ static void UpdateSpkr()
// Called by emulation code when Speaker I/O reg is accessed // Called by emulation code when Speaker I/O reg is accessed
// //
BYTE __stdcall SpkrToggle (WORD, BYTE address, BYTE write, BYTE, ULONG nCyclesLeft) BYTE __stdcall SpkrToggle (WORD, WORD, BYTE, BYTE, ULONG nCyclesLeft)
{ {
g_bSpkrToggleFlag = true; g_bSpkrToggleFlag = true;

View File

@ -20,4 +20,4 @@ void Spkr_DSUninit();
DWORD SpkrGetSnapshot(SS_IO_Speaker* pSS); DWORD SpkrGetSnapshot(SS_IO_Speaker* pSS);
DWORD SpkrSetSnapshot(SS_IO_Speaker* pSS); DWORD SpkrSetSnapshot(SS_IO_Speaker* pSS);
BYTE __stdcall SpkrToggle (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); BYTE __stdcall SpkrToggle (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);

View File

@ -37,6 +37,13 @@
#include "tfearch.h" #include "tfearch.h"
#include "tfesupp.h" #include "tfesupp.h"
#ifndef NULL
#define NULL 0
#endif
typedef unsigned int UINT;
#include "..\common.h"
// Define here, so we don't drag in the whole of stdafx.h:
void RegisterIoHandler(UINT uSlot, iofunction IORead16, iofunction IOWrite16, iofunction IOReadCx, iofunction IOWriteCx, LPVOID lpSlotParameter, BYTE* pExpansionRom);
/**/ /**/
/** #define TFE_DEBUG_DUMP 1 **/ /** #define TFE_DEBUG_DUMP 1 **/
@ -384,6 +391,8 @@ void tfe_debug_output_pp( void )
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* initialization and deinitialization functions */ /* initialization and deinitialization functions */
BYTE __stdcall TfeIo (WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCycles);
void tfe_reset(void) void tfe_reset(void)
{ {
if (tfe_enabled && !should_activate) if (tfe_enabled && !should_activate)
@ -442,6 +451,9 @@ void tfe_reset(void)
TFE_DEBUG_OUTPUT_REG(); TFE_DEBUG_OUTPUT_REG();
} }
const UINT uSlot = 3;
RegisterIoHandler(uSlot, TfeIo, TfeIo, NULL, NULL, NULL, NULL);
} }
#ifdef DOS_TFE #ifdef DOS_TFE
@ -1489,7 +1501,7 @@ int tfe_enumadapter_close(void)
} }
BYTE __stdcall TfeIo (WORD programcounter, BYTE address, BYTE write, BYTE value, ULONG nCycles) static BYTE __stdcall TfeIo (WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCycles)
{ {
BYTE ret = 0; BYTE ret = 0;

View File

@ -52,7 +52,6 @@ extern BYTE REGPARM1 tfe_read(WORD addr);
extern void REGPARM2 tfe_store(WORD addr, BYTE byte); extern void REGPARM2 tfe_store(WORD addr, BYTE byte);
extern int tfe_read_snapshot_module(struct snapshot_s *s); extern int tfe_read_snapshot_module(struct snapshot_s *s);
extern int tfe_write_snapshot_module(struct snapshot_s *s); extern int tfe_write_snapshot_module(struct snapshot_s *s);
extern BYTE __stdcall TfeIo (WORD programcounter, BYTE address, BYTE write, BYTE value, ULONG nCycles);
/* /*
These functions let the UI enumerate the available interfaces. These functions let the UI enumerate the available interfaces.

View File

@ -50,6 +50,10 @@
#ifndef ULONG #ifndef ULONG
typedef unsigned long ULONG; typedef unsigned long ULONG;
#endif #endif
/* TC added for AppleWin */
#ifndef LPVOID
typedef void *LPVOID;
#endif
typedef signed char SIGNED_CHAR; typedef signed char SIGNED_CHAR;
typedef signed short SWORD; typedef signed short SWORD;

View File

@ -1011,10 +1011,8 @@ bool Update40ColCell (int x, int y, int xpixel, int ypixel, int offset)
CopySource(xpixel,ypixel, CopySource(xpixel,ypixel,
APPLE_FONT_WIDTH, APPLE_FONT_HEIGHT, APPLE_FONT_WIDTH, APPLE_FONT_HEIGHT,
(g_bApple2e (IS_APPLE2 ? SRCOFFS_IIPLUS : SRCOFFS_40COL) + ((ch & 0x0F) << 4),
? SRCOFFS_40COL (ch & 0xF0) + g_nAltCharSetOffset + (bInvert ? 0x40 : 0x00));
: SRCOFFS_IIPLUS) + ((ch & 0x0F) << 4),
(ch & 0xF0)+g_nAltCharSetOffset + (bInvert?0x40:0x00));
return true; return true;
} }
@ -1563,7 +1561,7 @@ void VideoBenchmark () {
(unsigned)totaltextfps, (unsigned)totaltextfps,
(unsigned)(totalmhz10/10), (unsigned)(totalmhz10/10),
(unsigned)(totalmhz10 % 10), (unsigned)(totalmhz10 % 10),
(LPCTSTR)(g_bApple2e ? TEXT("") : TEXT(" (6502)")), (LPCTSTR)(IS_APPLE2 ? TEXT(" (6502)") : TEXT("")),
(unsigned)realisticfps); (unsigned)realisticfps);
MessageBox(g_hFrameWindow, MessageBox(g_hFrameWindow,
outstr, outstr,
@ -1572,7 +1570,9 @@ void VideoBenchmark () {
} }
//=========================================================================== //===========================================================================
BYTE __stdcall VideoCheckMode (WORD, BYTE address, BYTE, BYTE, ULONG) { BYTE __stdcall VideoCheckMode (WORD, WORD address, BYTE, BYTE, ULONG)
{
address &= 0xFF;
if (address == 0x7F) if (address == 0x7F)
return MemReadFloatingBus(SW_DHIRES != 0); return MemReadFloatingBus(SW_DHIRES != 0);
else { else {
@ -1601,7 +1601,7 @@ void VideoCheckPage (BOOL force) {
} }
//=========================================================================== //===========================================================================
BYTE __stdcall VideoCheckVbl (WORD, BYTE, BYTE, BYTE, ULONG) BYTE __stdcall VideoCheckVbl (WORD, WORD, BYTE, BYTE, ULONG)
{ {
/* /*
// Drol expects = 80 // Drol expects = 80
@ -2042,16 +2042,18 @@ void VideoResetState () {
} }
//=========================================================================== //===========================================================================
BYTE __stdcall VideoSetMode (WORD, BYTE address, BYTE write, BYTE, ULONG) { BYTE __stdcall VideoSetMode (WORD, WORD address, BYTE write, BYTE, ULONG)
{
address &= 0xFF;
DWORD oldpage2 = SW_PAGE2; DWORD oldpage2 = SW_PAGE2;
int oldvalue = g_nAltCharSetOffset+(int)(vidmode & ~(VF_MASK2 | VF_PAGE2)); int oldvalue = g_nAltCharSetOffset+(int)(vidmode & ~(VF_MASK2 | VF_PAGE2));
switch (address) { switch (address) {
case 0x00: vidmode &= ~VF_MASK2; break; case 0x00: vidmode &= ~VF_MASK2; break;
case 0x01: vidmode |= VF_MASK2; break; case 0x01: vidmode |= VF_MASK2; break;
case 0x0C: if (g_bApple2e) vidmode &= ~VF_80COL; break; case 0x0C: if (!IS_APPLE2) vidmode &= ~VF_80COL; break;
case 0x0D: if (g_bApple2e) vidmode |= VF_80COL; break; case 0x0D: if (!IS_APPLE2) vidmode |= VF_80COL; break;
case 0x0E: if (g_bApple2e) g_nAltCharSetOffset = 0; break; // Alternate char set off case 0x0E: if (!IS_APPLE2) g_nAltCharSetOffset = 0; break; // Alternate char set off
case 0x0F: if (g_bApple2e) g_nAltCharSetOffset = 256; break; // Alternate char set on case 0x0F: if (!IS_APPLE2) g_nAltCharSetOffset = 256; break; // Alternate char set on
case 0x50: vidmode &= ~VF_TEXT; break; case 0x50: vidmode &= ~VF_TEXT; break;
case 0x51: vidmode |= VF_TEXT; break; case 0x51: vidmode |= VF_TEXT; break;
case 0x52: vidmode &= ~VF_MIXED; break; case 0x52: vidmode &= ~VF_MIXED; break;
@ -2060,8 +2062,8 @@ BYTE __stdcall VideoSetMode (WORD, BYTE address, BYTE write, BYTE, ULONG) {
case 0x55: vidmode |= VF_PAGE2; break; case 0x55: vidmode |= VF_PAGE2; break;
case 0x56: vidmode &= ~VF_HIRES; break; case 0x56: vidmode &= ~VF_HIRES; break;
case 0x57: vidmode |= VF_HIRES; break; case 0x57: vidmode |= VF_HIRES; break;
case 0x5E: if (g_bApple2e) vidmode |= VF_DHIRES; break; case 0x5E: if (!IS_APPLE2) vidmode |= VF_DHIRES; break;
case 0x5F: if (g_bApple2e) vidmode &= ~VF_DHIRES; break; case 0x5F: if (!IS_APPLE2) vidmode &= ~VF_DHIRES; break;
} }
if (SW_MASK2) if (SW_MASK2)
vidmode &= ~VF_PAGE2; vidmode &= ~VF_PAGE2;
@ -2243,7 +2245,7 @@ WORD VideoGetScannerAddress(bool* pbVblBar_OUT)
{ {
// N: text, so no higher address bits unless Apple ][, not Apple //e // N: text, so no higher address bits unless Apple ][, not Apple //e
// //
if ((!g_bApple2e) && // Apple ][? if ((IS_APPLE2) && // Apple ][?
(kHPEClock <= nHClock) && // Y: HBL? (kHPEClock <= nHClock) && // Y: HBL?
(nHClock <= (kHClocks - 1))) (nHClock <= (kHClocks - 1)))
{ {

View File

@ -70,6 +70,6 @@ bool VideoGetSW80COL();
DWORD VideoGetSnapshot(SS_IO_Video* pSS); DWORD VideoGetSnapshot(SS_IO_Video* pSS);
DWORD VideoSetSnapshot(SS_IO_Video* pSS); DWORD VideoSetSnapshot(SS_IO_Video* pSS);
BYTE __stdcall VideoCheckMode (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); BYTE __stdcall VideoCheckMode (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall VideoCheckVbl (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); BYTE __stdcall VideoCheckVbl (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);
BYTE __stdcall VideoSetMode (WORD pc, BYTE addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft); BYTE __stdcall VideoSetMode (WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nCyclesLeft);