Merge remote-tracking branch 'upstream/master'

# Conflicts:
#	source/StdAfx.h
This commit is contained in:
Andrea Odetti 2020-01-09 09:30:23 +00:00
commit efec61caba
18 changed files with 448 additions and 301 deletions

View file

@ -9,6 +9,12 @@ https://github.com/AppleWin/AppleWin/issues/new
Tom Charlesworth Tom Charlesworth
1.29.8.0 - ?
----------------------
. Debugger: Changed 'cycles' to be configurable (either absolute or relative).
- extended debugger commmand: videoinfo <dec|hex|apple|real|abs|rel>
1.29.7.0 - 20 Dec 2019 1.29.7.0 - 20 Dec 2019
---------------------- ----------------------
. [Change #726] Disk II card: supported in slot 5 via '-s5 diskii' command line. . [Change #726] Disk II card: supported in slot 5 via '-s5 diskii' command line.

View file

@ -80,6 +80,7 @@ HINSTANCE g_hInstance = (HINSTANCE)0;
AppMode_e g_nAppMode = MODE_LOGO; AppMode_e g_nAppMode = MODE_LOGO;
static bool g_bLoadedSaveState = false; static bool g_bLoadedSaveState = false;
static bool g_bSysClkOK = false;
std::string g_sProgramDir; // Directory of where AppleWin executable resides std::string g_sProgramDir; // Directory of where AppleWin executable resides
std::string g_sDebugDir; // TODO: Not currently used std::string g_sDebugDir; // TODO: Not currently used
@ -433,6 +434,7 @@ void SetCurrentCLK6502(void)
} }
//=========================================================================== //===========================================================================
void EnterMessageLoop(void) void EnterMessageLoop(void)
{ {
MSG message; MSG message;
@ -1097,12 +1099,12 @@ static std::string GetFullPath(LPCSTR szFileName)
static bool DoDiskInsert(const UINT slot, const int nDrive, LPCSTR szFileName) static bool DoDiskInsert(const UINT slot, const int nDrive, LPCSTR szFileName)
{ {
Disk2InterfaceCard* pDisk2Card = dynamic_cast<Disk2InterfaceCard*> (g_CardMgr.GetObj(slot)); Disk2InterfaceCard& disk2Card = dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(slot));
std::string strPathName = GetFullPath(szFileName); std::string strPathName = GetFullPath(szFileName);
if (strPathName.empty()) return false; if (strPathName.empty()) return false;
ImageError_e Error = pDisk2Card->InsertDisk(nDrive, strPathName.c_str(), IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); ImageError_e Error = disk2Card.InsertDisk(nDrive, strPathName.c_str(), IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE);
return Error == eIMAGE_ERROR_NONE; return Error == eIMAGE_ERROR_NONE;
} }
@ -1218,40 +1220,146 @@ static bool CheckOldAppleWinVersion(void)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static void ExceptionHandler(const char* pError)
{
MessageBox( g_hFrameWindow,
pError,
TEXT("Runtime Exception"),
MB_ICONEXCLAMATION | MB_SETFOREGROUND);
LogFileOutput("Runtime Exception: %s\n", pError);
}
//---------------------------------------------------------------------------
static void ProcessCmdLine(LPSTR lpCmdLine);
static void GetAppleWinVersion(void);
static void OneTimeInitialization(HINSTANCE passinstance);
static void RepeatInitialization(void);
static void Shutdown(void);
struct CmdLine
{
CmdLine()
{
bShutdown = false;
bSetFullScreen = false;
bBoot = false;
bChangedDisplayResolution = false;
bSlot0LanguageCard = false;
bSlot7EmptyOnExit = false;
bestWidth = 0;
bestHeight = 0;
szImageName_harddisk[HARDDISK_1] = NULL;
szImageName_harddisk[HARDDISK_2] = NULL;
szSnapshotName = NULL;
szScreenshotFilename = NULL;
uRamWorksExPages = 0;
uSaturnBanks = 0;
newVideoType = -1;
newVideoStyleEnableMask = 0;
newVideoStyleDisableMask = 0;
newVideoRefreshRate = VR_NONE;
clockMultiplier = 0.0; // 0 => not set from cmd-line
model = A2TYPE_MAX;
for (UINT i = 0; i < NUM_SLOTS; i++)
{
bSlotEmpty[i] = false;
slotInsert[i] = CT_Empty;
szImageName_drive[i][DRIVE_1] = NULL;
szImageName_drive[i][DRIVE_2] = NULL;
}
}
bool bShutdown;
bool bSetFullScreen;
bool bBoot;
bool bChangedDisplayResolution;
bool bSlot0LanguageCard;
bool bSlotEmpty[NUM_SLOTS];
bool bSlot7EmptyOnExit;
SS_CARDTYPE slotInsert[NUM_SLOTS];
UINT bestWidth;
UINT bestHeight;
LPSTR szImageName_drive[NUM_SLOTS][NUM_DRIVES];
LPSTR szImageName_harddisk[NUM_HARDDISKS];
LPSTR szSnapshotName;
LPSTR szScreenshotFilename;
UINT uRamWorksExPages;
UINT uSaturnBanks;
int newVideoType;
int newVideoStyleEnableMask;
int newVideoStyleDisableMask;
VideoRefreshRate_e newVideoRefreshRate;
double clockMultiplier;
eApple2Type model;
};
static CmdLine g_cmdLine;
int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
{ {
bool bShutdown = false; ProcessCmdLine(lpCmdLine);
bool bSetFullScreen = false; GetAppleWinVersion();
bool bBoot = false; OneTimeInitialization(passinstance);
bool bChangedDisplayResolution = false;
bool bSlot0LanguageCard = false;
bool bSlotEmpty[NUM_SLOTS] = {};
bool bSlot7EmptyOnExit = false;
SS_CARDTYPE slotInsert[NUM_SLOTS];
UINT bestWidth = 0, bestHeight = 0;
const UINT SLOT5 = 5;
const UINT SLOT6 = 6;
LPSTR szImageName_drive[NUM_SLOTS][NUM_DRIVES] = {};
LPSTR szImageName_harddisk[NUM_HARDDISKS] = {NULL,NULL};
LPSTR szSnapshotName = NULL;
const std::string strCmdLine(lpCmdLine); // Keep a copy for log ouput
UINT uRamWorksExPages = 0;
UINT uSaturnBanks = 0;
int newVideoType = -1;
int newVideoStyleEnableMask = 0;
int newVideoStyleDisableMask = 0;
VideoRefreshRate_e newVideoRefreshRate = VR_NONE;
LPSTR szScreenshotFilename = NULL;
double clockMultiplier = 0.0; // 0 => not set from cmd-line
eApple2Type model = A2TYPE_MAX;
for (UINT i = 0; i < NUM_SLOTS; i++) try
{ {
bSlotEmpty[i] = false; do
slotInsert[i] = CT_Empty; {
szImageName_drive[i][DRIVE_1] = NULL; g_bRestart = false;
szImageName_drive[i][DRIVE_2] = NULL;
RepeatInitialization();
// ENTER THE MAIN MESSAGE LOOP
LogFileOutput("Main: EnterMessageLoop()\n");
EnterMessageLoop();
LogFileOutput("Main: LeaveMessageLoop()\n");
if (g_bRestart)
{
g_cmdLine.bSetFullScreen = g_bRestartFullScreen;
g_bRestartFullScreen = false;
}
MB_Reset();
LogFileOutput("Main: MB_Reset()\n");
CMouseInterface* pMouseCard = g_CardMgr.GetMouseCard();
if (pMouseCard)
{
pMouseCard->Reset(); // Deassert any pending IRQs - GH#514
LogFileOutput("Main: CMouseInterface::Uninitialize()\n");
}
DSUninit();
LogFileOutput("Main: DSUninit()\n");
if (g_bHookSystemKey)
{
UninitHookThread();
LogFileOutput("Main: UnhookFilterForKeyboard()\n");
}
}
while (g_bRestart);
} }
catch(std::runtime_error exception)
{
ExceptionHandler(exception.what());
}
catch(std::exception exception)
{
ExceptionHandler(exception.what());
}
Shutdown();
return 0;
}
static void ProcessCmdLine(LPSTR lpCmdLine)
{
const std::string strCmdLine(lpCmdLine); // Keep a copy for log ouput
while (*lpCmdLine) while (*lpCmdLine)
{ {
@ -1269,25 +1377,25 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
{ {
lpCmdLine = GetCurrArg(lpNextArg); lpCmdLine = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
szImageName_drive[SLOT6][DRIVE_1] = lpCmdLine; g_cmdLine.szImageName_drive[SLOT6][DRIVE_1] = lpCmdLine;
} }
else if (strcmp(lpCmdLine, "-d2") == 0) else if (strcmp(lpCmdLine, "-d2") == 0)
{ {
lpCmdLine = GetCurrArg(lpNextArg); lpCmdLine = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
szImageName_drive[SLOT6][DRIVE_2] = lpCmdLine; g_cmdLine.szImageName_drive[SLOT6][DRIVE_2] = lpCmdLine;
} }
else if (strcmp(lpCmdLine, "-h1") == 0) else if (strcmp(lpCmdLine, "-h1") == 0)
{ {
lpCmdLine = GetCurrArg(lpNextArg); lpCmdLine = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
szImageName_harddisk[HARDDISK_1] = lpCmdLine; g_cmdLine.szImageName_harddisk[HARDDISK_1] = lpCmdLine;
} }
else if (strcmp(lpCmdLine, "-h2") == 0) else if (strcmp(lpCmdLine, "-h2") == 0)
{ {
lpCmdLine = GetCurrArg(lpNextArg); lpCmdLine = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
szImageName_harddisk[HARDDISK_2] = lpCmdLine; g_cmdLine.szImageName_harddisk[HARDDISK_2] = lpCmdLine;
} }
else if (lpCmdLine[0] == '-' && lpCmdLine[1] == 's' && lpCmdLine[2] >= '1' && lpCmdLine[2] <= '7') else if (lpCmdLine[0] == '-' && lpCmdLine[1] == 's' && lpCmdLine[2] >= '1' && lpCmdLine[2] <= '7')
{ {
@ -1298,9 +1406,9 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
lpCmdLine = GetCurrArg(lpNextArg); lpCmdLine = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
if (strcmp(lpCmdLine, "empty") == 0) if (strcmp(lpCmdLine, "empty") == 0)
bSlotEmpty[slot] = true; g_cmdLine.bSlotEmpty[slot] = true;
if (strcmp(lpCmdLine, "diskii") == 0) if (strcmp(lpCmdLine, "diskii") == 0)
slotInsert[slot] = CT_Disk2; g_cmdLine.slotInsert[slot] = CT_Disk2;
} }
else if (lpCmdLine[3] == 'd' && (lpCmdLine[4] == '1' || lpCmdLine[4] == '2')) // -s[1..7]d[1|2] <dsk-image> else if (lpCmdLine[3] == 'd' && (lpCmdLine[4] == '1' || lpCmdLine[4] == '2')) // -s[1..7]d[1|2] <dsk-image>
{ {
@ -1314,7 +1422,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
{ {
lpCmdLine = GetCurrArg(lpNextArg); lpCmdLine = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
szImageName_drive[slot][drive] = lpCmdLine; g_cmdLine.szImageName_drive[slot][drive] = lpCmdLine;
} }
} }
else else
@ -1324,39 +1432,39 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
} }
else if (strcmp(lpCmdLine, "-s7-empty-on-exit") == 0) else if (strcmp(lpCmdLine, "-s7-empty-on-exit") == 0)
{ {
bSlot7EmptyOnExit = true; g_cmdLine.bSlot7EmptyOnExit = true;
} }
else if (strcmp(lpCmdLine, "-load-state") == 0) else if (strcmp(lpCmdLine, "-load-state") == 0)
{ {
lpCmdLine = GetCurrArg(lpNextArg); lpCmdLine = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
szSnapshotName = lpCmdLine; g_cmdLine.szSnapshotName = lpCmdLine;
} }
else if (strcmp(lpCmdLine, "-f") == 0) else if (strcmp(lpCmdLine, "-f") == 0)
{ {
bSetFullScreen = true; g_cmdLine.bSetFullScreen = true;
} }
#define CMD_FS_HEIGHT "-fs-height=" #define CMD_FS_HEIGHT "-fs-height="
else if (strncmp(lpCmdLine, CMD_FS_HEIGHT, sizeof(CMD_FS_HEIGHT)-1) == 0) else if (strncmp(lpCmdLine, CMD_FS_HEIGHT, sizeof(CMD_FS_HEIGHT)-1) == 0)
{ {
bSetFullScreen = true; // Implied g_cmdLine.bSetFullScreen = true; // Implied
LPSTR lpTmp = lpCmdLine + sizeof(CMD_FS_HEIGHT)-1; LPSTR lpTmp = lpCmdLine + sizeof(CMD_FS_HEIGHT)-1;
bool bRes = false; bool bRes = false;
if (strcmp(lpTmp, "best") == 0) if (strcmp(lpTmp, "best") == 0)
{ {
bRes = GetBestDisplayResolutionForFullScreen(bestWidth, bestHeight); bRes = GetBestDisplayResolutionForFullScreen(g_cmdLine.bestWidth, g_cmdLine.bestHeight);
} }
else else
{ {
UINT userSpecifiedHeight = atoi(lpTmp); UINT userSpecifiedHeight = atoi(lpTmp);
if (userSpecifiedHeight) if (userSpecifiedHeight)
bRes = GetBestDisplayResolutionForFullScreen(bestWidth, bestHeight, userSpecifiedHeight); bRes = GetBestDisplayResolutionForFullScreen(g_cmdLine.bestWidth, g_cmdLine.bestHeight, userSpecifiedHeight);
else else
LogFileOutput("Invalid cmd-line parameter for -fs-height=x switch\n"); LogFileOutput("Invalid cmd-line parameter for -fs-height=x switch\n");
} }
if (bRes) if (bRes)
LogFileOutput("Best resolution for -fs-height=x switch: Width=%d, Height=%d\n", bestWidth, bestHeight); LogFileOutput("Best resolution for -fs-height=x switch: Width=%d, Height=%d\n", g_cmdLine.bestWidth, g_cmdLine.bestHeight);
else else
LogFileOutput("Failed to set parameter for -fs-height=x switch\n"); LogFileOutput("Failed to set parameter for -fs-height=x switch\n");
} }
@ -1388,12 +1496,12 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
{ {
lpCmdLine = GetCurrArg(lpNextArg); lpCmdLine = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
uRamWorksExPages = atoi(lpCmdLine); g_cmdLine.uRamWorksExPages = atoi(lpCmdLine);
if (uRamWorksExPages > kMaxExMemoryBanks) if (g_cmdLine.uRamWorksExPages > kMaxExMemoryBanks)
uRamWorksExPages = kMaxExMemoryBanks; g_cmdLine.uRamWorksExPages = kMaxExMemoryBanks;
else else
if (uRamWorksExPages < 1) if (g_cmdLine.uRamWorksExPages < 1)
uRamWorksExPages = 1; g_cmdLine.uRamWorksExPages = 1;
} }
#endif #endif
else if (strcmp(lpCmdLine, "-s0") == 0) else if (strcmp(lpCmdLine, "-s0") == 0)
@ -1402,11 +1510,11 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
if (strcmp(lpCmdLine, "saturn") == 0 || strcmp(lpCmdLine, "saturn128") == 0) if (strcmp(lpCmdLine, "saturn") == 0 || strcmp(lpCmdLine, "saturn128") == 0)
uSaturnBanks = Saturn128K::kMaxSaturnBanks; g_cmdLine.uSaturnBanks = Saturn128K::kMaxSaturnBanks;
else if (strcmp(lpCmdLine, "saturn64") == 0) else if (strcmp(lpCmdLine, "saturn64") == 0)
uSaturnBanks = Saturn128K::kMaxSaturnBanks/2; g_cmdLine.uSaturnBanks = Saturn128K::kMaxSaturnBanks/2;
else if (strcmp(lpCmdLine, "languagecard") == 0 || strcmp(lpCmdLine, "lc") == 0) else if (strcmp(lpCmdLine, "languagecard") == 0 || strcmp(lpCmdLine, "lc") == 0)
bSlot0LanguageCard = true; g_cmdLine.bSlot0LanguageCard = true;
} }
else if (strcmp(lpCmdLine, "-f8rom") == 0) // Use custom 2K ROM at [$F800..$FFFF] else if (strcmp(lpCmdLine, "-f8rom") == 0) // Use custom 2K ROM at [$F800..$FFFF]
{ {
@ -1468,6 +1576,20 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
{ {
JoySetHookAltKeys(false); JoySetHookAltKeys(false);
} }
else if (strcmp(lpCmdLine, "-left-control-alt-buttons") == 0)
{
JoySetButtonVirtualKey(0, VK_CONTROL);
JoySetButtonVirtualKey(1, VK_MENU);
}
else if (strcmp(lpCmdLine, "-right-alt-control-buttons") == 0)
{
JoySetButtonVirtualKey(0, VK_MENU | KF_EXTENDED);
JoySetButtonVirtualKey(1, VK_CONTROL | KF_EXTENDED);
}
else if (strcmp(lpCmdLine, "-swap-buttons") == 0)
{
JoySwapButton0and1(true);
}
else if (strcmp(lpCmdLine, "-spkr-inc") == 0) else if (strcmp(lpCmdLine, "-spkr-inc") == 0)
{ {
lpCmdLine = GetCurrArg(lpNextArg); lpCmdLine = GetCurrArg(lpNextArg);
@ -1509,15 +1631,15 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
} }
else if (strcmp(lpCmdLine, "-video-mode=rgb-monitor") == 0) // GH#616 else if (strcmp(lpCmdLine, "-video-mode=rgb-monitor") == 0) // GH#616
{ {
newVideoType = VT_COLOR_MONITOR_RGB; g_cmdLine.newVideoType = VT_COLOR_MONITOR_RGB;
} }
else if (strcmp(lpCmdLine, "-video-style=vertical-blend") == 0) // GH#616 else if (strcmp(lpCmdLine, "-video-style=vertical-blend") == 0) // GH#616
{ {
newVideoStyleEnableMask = VS_COLOR_VERTICAL_BLEND; g_cmdLine.newVideoStyleEnableMask = VS_COLOR_VERTICAL_BLEND;
} }
else if (strcmp(lpCmdLine, "-video-style=no-vertical-blend") == 0) // GH#616 else if (strcmp(lpCmdLine, "-video-style=no-vertical-blend") == 0) // GH#616
{ {
newVideoStyleDisableMask = VS_COLOR_VERTICAL_BLEND; g_cmdLine.newVideoStyleDisableMask = VS_COLOR_VERTICAL_BLEND;
} }
else if (strcmp(lpCmdLine, "-rgb-card-invert-bit7") == 0) // GH#633 else if (strcmp(lpCmdLine, "-rgb-card-invert-bit7") == 0) // GH#633
{ {
@ -1525,14 +1647,14 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
} }
else if (strcmp(lpCmdLine, "-screenshot-and-exit") == 0) // GH#616: For testing - Use in combination with -load-state else if (strcmp(lpCmdLine, "-screenshot-and-exit") == 0) // GH#616: For testing - Use in combination with -load-state
{ {
szScreenshotFilename = GetCurrArg(lpNextArg); g_cmdLine.szScreenshotFilename = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
} }
else if (strcmp(lpCmdLine, "-clock-multiplier") == 0) else if (strcmp(lpCmdLine, "-clock-multiplier") == 0)
{ {
lpCmdLine = GetCurrArg(lpNextArg); lpCmdLine = GetCurrArg(lpNextArg);
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
clockMultiplier = atof(lpCmdLine); g_cmdLine.clockMultiplier = atof(lpCmdLine);
} }
else if (strcmp(lpCmdLine, "-model") == 0) else if (strcmp(lpCmdLine, "-model") == 0)
{ {
@ -1540,23 +1662,23 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
if (strcmp(lpCmdLine, "apple2") == 0) if (strcmp(lpCmdLine, "apple2") == 0)
model = A2TYPE_APPLE2; g_cmdLine.model = A2TYPE_APPLE2;
else if (strcmp(lpCmdLine, "apple2p") == 0) else if (strcmp(lpCmdLine, "apple2p") == 0)
model = A2TYPE_APPLE2PLUS; g_cmdLine.model = A2TYPE_APPLE2PLUS;
else if (strcmp(lpCmdLine, "apple2e") == 0) else if (strcmp(lpCmdLine, "apple2e") == 0)
model = A2TYPE_APPLE2E; g_cmdLine.model = A2TYPE_APPLE2E;
else if (strcmp(lpCmdLine, "apple2ee") == 0) else if (strcmp(lpCmdLine, "apple2ee") == 0)
model = A2TYPE_APPLE2EENHANCED; g_cmdLine.model = A2TYPE_APPLE2EENHANCED;
else else
LogFileOutput("-model: unsupported type: %s\n", lpCmdLine); LogFileOutput("-model: unsupported type: %s\n", lpCmdLine);
} }
else if (_stricmp(lpCmdLine, "-50hz") == 0) // (case-insensitive) else if (_stricmp(lpCmdLine, "-50hz") == 0) // (case-insensitive)
{ {
newVideoRefreshRate = VR_50HZ; g_cmdLine.newVideoRefreshRate = VR_50HZ;
} }
else if (_stricmp(lpCmdLine, "-60hz") == 0) // (case-insensitive) else if (_stricmp(lpCmdLine, "-60hz") == 0) // (case-insensitive)
{ {
newVideoRefreshRate = VR_60HZ; g_cmdLine.newVideoRefreshRate = VR_60HZ;
} }
else // unsupported else // unsupported
{ {
@ -1567,24 +1689,14 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
} }
LogFileOutput("CmdLine: %s\n", strCmdLine.c_str()); LogFileOutput("CmdLine: %s\n", strCmdLine.c_str());
}
#if 0 static void GetAppleWinVersion(void)
#ifdef RIFF_SPKR {
RiffInitWriteFile("Spkr.wav", SPKR_SAMPLE_RATE, 1);
#endif
#ifdef RIFF_MB
RiffInitWriteFile("Mockingboard.wav", 44100, 2);
#endif
#endif
//-----
char szPath[_MAX_PATH]; char szPath[_MAX_PATH];
if (0 == GetModuleFileName(NULL, szPath, sizeof(szPath))) if (0 == GetModuleFileName(NULL, szPath, sizeof(szPath)))
{ strcpy_s(szPath, sizeof(szPath), __argv[0]);
strcpy(szPath, __argv[0]);
}
// Extract application version and store in a global variable // Extract application version and store in a global variable
DWORD dwHandle, dwVerInfoSize; DWORD dwHandle, dwVerInfoSize;
@ -1615,16 +1727,27 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
} }
LogFileOutput("AppleWin version: %s\n", VERSIONSTRING); LogFileOutput("AppleWin version: %s\n", VERSIONSTRING);
}
//----- // DO ONE-TIME INITIALIZATION
static void OneTimeInitialization(HINSTANCE passinstance)
{
#if 0
#ifdef RIFF_SPKR
RiffInitWriteFile("Spkr.wav", SPKR_SAMPLE_RATE, 1);
#endif
#ifdef RIFF_MB
RiffInitWriteFile("Mockingboard.wav", 44100, 2);
#endif
#endif
// Initialize COM - so we can use CoCreateInstance // Initialize COM - so we can use CoCreateInstance
// . NB. DSInit() & DIMouse::DirectInputInit are done when g_hFrameWindow is created (WM_CREATE) // . NB. DSInit() & DIMouse::DirectInputInit are done when g_hFrameWindow is created (WM_CREATE)
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
LogFileOutput("Init: CoInitializeEx(), hr=0x%08X\n", hr); LogFileOutput("Init: CoInitializeEx(), hr=0x%08X\n", hr);
const bool bSysClkOK = SysClk_InitTimer(); g_bSysClkOK = SysClk_InitTimer();
LogFileOutput("Init: SysClk_InitTimer(), res=%d\n", bSysClkOK ? 1:0); LogFileOutput("Init: SysClk_InitTimer(), res=%d\n", g_bSysClkOK ? 1:0);
#ifdef USE_SPEECH_API #ifdef USE_SPEECH_API
if (g_bEnableSpeech) if (g_bEnableSpeech)
{ {
@ -1636,7 +1759,6 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
DDInit(); // For WaitForVerticalBlank() DDInit(); // For WaitForVerticalBlank()
#endif #endif
// DO ONE-TIME INITIALIZATION
g_hInstance = passinstance; g_hInstance = passinstance;
GdiSetBatchLimit(512); GdiSetBatchLimit(512);
LogFileOutput("Init: GdiSetBatchLimit()\n"); LogFileOutput("Init: GdiSetBatchLimit()\n");
@ -1655,13 +1777,11 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
ImageInitialize(); ImageInitialize();
LogFileOutput("Init: ImageInitialize()\n"); LogFileOutput("Init: ImageInitialize()\n");
}
// // DO INITIALIZATION THAT MUST BE REPEATED FOR A RESTART
static void RepeatInitialization(void)
do {
{
// DO INITIALIZATION THAT MUST BE REPEATED FOR A RESTART
g_bRestart = false;
ResetToLogoMode(); ResetToLogoMode();
// NB. g_OldAppleWinVersion needed by LoadConfiguration() -> Config_Load_Video() // NB. g_OldAppleWinVersion needed by LoadConfiguration() -> Config_Load_Video()
@ -1670,46 +1790,46 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
LoadConfiguration(); LoadConfiguration();
LogFileOutput("Main: LoadConfiguration()\n"); LogFileOutput("Main: LoadConfiguration()\n");
if (model != A2TYPE_MAX) if (g_cmdLine.model != A2TYPE_MAX)
SetApple2Type(model); SetApple2Type(g_cmdLine.model);
if (newVideoType >= 0) if (g_cmdLine.newVideoType >= 0)
{ {
SetVideoType( (VideoType_e)newVideoType ); SetVideoType( (VideoType_e)g_cmdLine.newVideoType );
newVideoType = -1; // Don't reapply after a restart g_cmdLine.newVideoType = -1; // Don't reapply after a restart
} }
SetVideoStyle( (VideoStyle_e) ((GetVideoStyle() | newVideoStyleEnableMask) & ~newVideoStyleDisableMask) ); SetVideoStyle( (VideoStyle_e) ((GetVideoStyle() | g_cmdLine.newVideoStyleEnableMask) & ~g_cmdLine.newVideoStyleDisableMask) );
if (newVideoRefreshRate != VR_NONE) if (g_cmdLine.newVideoRefreshRate != VR_NONE)
{ {
SetVideoRefreshRate(newVideoRefreshRate); SetVideoRefreshRate(g_cmdLine.newVideoRefreshRate);
newVideoRefreshRate = VR_NONE; // Don't reapply after a restart g_cmdLine.newVideoRefreshRate = VR_NONE; // Don't reapply after a restart
SetCurrentCLK6502(); SetCurrentCLK6502();
} }
UseClockMultiplier(clockMultiplier); UseClockMultiplier(g_cmdLine.clockMultiplier);
clockMultiplier = 0.0; g_cmdLine.clockMultiplier = 0.0;
// Apply the memory expansion switches after loading the Apple II machine type // Apply the memory expansion switches after loading the Apple II machine type
#ifdef RAMWORKS #ifdef RAMWORKS
if (uRamWorksExPages) if (g_cmdLine.uRamWorksExPages)
{ {
SetRamWorksMemorySize(uRamWorksExPages); SetRamWorksMemorySize(g_cmdLine.uRamWorksExPages);
SetExpansionMemType(CT_RamWorksIII); SetExpansionMemType(CT_RamWorksIII);
uRamWorksExPages = 0; // Don't reapply after a restart g_cmdLine.uRamWorksExPages = 0; // Don't reapply after a restart
} }
#endif #endif
if (uSaturnBanks) if (g_cmdLine.uSaturnBanks)
{ {
SetSaturnMemorySize(uSaturnBanks); // Set number of banks before constructing Saturn card SetSaturnMemorySize(g_cmdLine.uSaturnBanks); // Set number of banks before constructing Saturn card
SetExpansionMemType(CT_Saturn128K); SetExpansionMemType(CT_Saturn128K);
uSaturnBanks = 0; // Don't reapply after a restart g_cmdLine.uSaturnBanks = 0; // Don't reapply after a restart
} }
if (bSlot0LanguageCard) if (g_cmdLine.bSlot0LanguageCard)
{ {
SetExpansionMemType(CT_LanguageCard); SetExpansionMemType(CT_LanguageCard);
bSlot0LanguageCard = false; // Don't reapply after a restart g_cmdLine.bSlot0LanguageCard = false; // Don't reapply after a restart
} }
DebugInitialize(); DebugInitialize();
@ -1726,40 +1846,40 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
LogFileOutput("Main: FrameCreateWindow() - post\n"); LogFileOutput("Main: FrameCreateWindow() - post\n");
// Allow the 4 hardcoded slots to be configurated as empty // Allow the 4 hardcoded slots to be configurated as empty
if (bSlotEmpty[SLOT1]) if (g_cmdLine.bSlotEmpty[SLOT1])
g_CardMgr.Remove(SLOT1); g_CardMgr.Remove(SLOT1);
if (bSlotEmpty[SLOT2]) if (g_cmdLine.bSlotEmpty[SLOT2])
g_CardMgr.Remove(SLOT2); g_CardMgr.Remove(SLOT2);
if (bSlotEmpty[SLOT3]) if (g_cmdLine.bSlotEmpty[SLOT3])
g_CardMgr.Remove(SLOT3); g_CardMgr.Remove(SLOT3);
if (bSlotEmpty[SLOT6]) if (g_cmdLine.bSlotEmpty[SLOT6])
g_CardMgr.Remove(SLOT6); g_CardMgr.Remove(SLOT6);
if (slotInsert[5] != CT_Empty) if (g_cmdLine.slotInsert[SLOT5] != CT_Empty)
{ {
if (g_CardMgr.QuerySlot(SLOT4) == CT_MockingboardC && slotInsert[SLOT5] != CT_MockingboardC) // Currently MB occupies slot4+5 when enabled if (g_CardMgr.QuerySlot(SLOT4) == CT_MockingboardC && g_cmdLine.slotInsert[SLOT5] != CT_MockingboardC) // Currently MB occupies slot4+5 when enabled
{ {
g_CardMgr.Remove(SLOT4); g_CardMgr.Remove(SLOT4);
g_CardMgr.Remove(SLOT5); g_CardMgr.Remove(SLOT5);
} }
g_CardMgr.Insert(SLOT5, slotInsert[SLOT5]); g_CardMgr.Insert(SLOT5, g_cmdLine.slotInsert[SLOT5]);
} }
// Pre: may need g_hFrameWindow for MessageBox errors // Pre: may need g_hFrameWindow for MessageBox errors
// Post: may enable HDD, required for MemInitialize()->MemInitializeIO() // Post: may enable HDD, required for MemInitialize()->MemInitializeIO()
{ {
bool temp = false; bool temp = false;
InsertFloppyDisks(SLOT5, szImageName_drive[SLOT5], temp); InsertFloppyDisks(SLOT5, g_cmdLine.szImageName_drive[SLOT5], temp);
//szImageName_drive[SLOT5][DRIVE_1] = szImageName_drive[SLOT5][DRIVE_2] = NULL; // *Do* insert on a restart (since no way they could have changed) //g_cmdLine.szImageName_drive[SLOT5][DRIVE_1] = g_cmdLine.szImageName_drive[SLOT5][DRIVE_2] = NULL; // *Do* insert on a restart (since no way they could have changed)
InsertFloppyDisks(SLOT6, szImageName_drive[SLOT6], bBoot); InsertFloppyDisks(SLOT6, g_cmdLine.szImageName_drive[SLOT6], g_cmdLine.bBoot);
szImageName_drive[SLOT6][DRIVE_1] = szImageName_drive[SLOT6][DRIVE_2] = NULL; // Don't insert on a restart g_cmdLine.szImageName_drive[SLOT6][DRIVE_1] = g_cmdLine.szImageName_drive[SLOT6][DRIVE_2] = NULL; // Don't insert on a restart
InsertHardDisks(szImageName_harddisk, bBoot); InsertHardDisks(g_cmdLine.szImageName_harddisk, g_cmdLine.bBoot);
szImageName_harddisk[HARDDISK_1] = szImageName_harddisk[HARDDISK_2] = NULL; // Don't insert on a restart g_cmdLine.szImageName_harddisk[HARDDISK_1] = g_cmdLine.szImageName_harddisk[HARDDISK_2] = NULL; // Don't insert on a restart
if (bSlotEmpty[7]) if (g_cmdLine.bSlotEmpty[7])
HD_SetEnabled(false); HD_SetEnabled(false);
} }
@ -1770,7 +1890,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
if (bShowAboutDlg) if (bShowAboutDlg)
{ {
if (!AboutDlg()) if (!AboutDlg())
bShutdown = true; // Close everything down g_cmdLine.bShutdown = true; // Close everything down
else else
RegSaveString(TEXT(REG_CONFIG), TEXT(REGVALUE_VERSION), 1, VERSIONSTRING); // Only save version after user accepts license RegSaveString(TEXT(REG_CONFIG), TEXT(REGVALUE_VERSION), 1, VERSIONSTRING); // Only save version after user accepts license
} }
@ -1793,10 +1913,10 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
HD_Reset(); // GH#515 HD_Reset(); // GH#515
LogFileOutput("Main: HDDReset()\n"); LogFileOutput("Main: HDDReset()\n");
if (!bSysClkOK) if (!g_bSysClkOK)
{ {
MessageBox(g_hFrameWindow, "DirectX failed to create SystemClock instance", TEXT("AppleWin Error"), MB_OK); MessageBox(g_hFrameWindow, "DirectX failed to create SystemClock instance", TEXT("AppleWin Error"), MB_OK);
bShutdown = true; g_cmdLine.bShutdown = true;
} }
if (g_bCustomRomF8Failed) if (g_bCustomRomF8Failed)
@ -1804,15 +1924,15 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
std::string msg = "Failed to load custom F8 rom (not found or not exactly 2KiB)\n"; std::string msg = "Failed to load custom F8 rom (not found or not exactly 2KiB)\n";
LogFileOutput("%s", msg.c_str()); LogFileOutput("%s", msg.c_str());
MessageBox(g_hFrameWindow, msg.c_str(), TEXT("AppleWin Error"), MB_OK); MessageBox(g_hFrameWindow, msg.c_str(), TEXT("AppleWin Error"), MB_OK);
bShutdown = true; g_cmdLine.bShutdown = true;
} }
tfe_init(); tfe_init();
LogFileOutput("Main: tfe_init()\n"); LogFileOutput("Main: tfe_init()\n");
if (szSnapshotName) if (g_cmdLine.szSnapshotName)
{ {
std::string strPathname(szSnapshotName); std::string strPathname(g_cmdLine.szSnapshotName);
int nIdx = strPathname.find_last_of('\\'); int nIdx = strPathname.find_last_of('\\');
if (nIdx >= 0 && nIdx+1 < (int)strPathname.length()) if (nIdx >= 0 && nIdx+1 < (int)strPathname.length())
{ {
@ -1822,16 +1942,16 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
// Override value just loaded from Registry by LoadConfiguration() // Override value just loaded from Registry by LoadConfiguration()
// . NB. Registry value is not updated with this cmd-line value // . NB. Registry value is not updated with this cmd-line value
Snapshot_SetFilename(szSnapshotName); Snapshot_SetFilename(g_cmdLine.szSnapshotName);
Snapshot_LoadState(); Snapshot_LoadState();
bBoot = true; g_cmdLine.bBoot = true;
#if _DEBUG && 0 // Debug/test: Save a duplicate of the save-state file in tmp folder #if _DEBUG && 0 // Debug/test: Save a duplicate of the save-state file in tmp folder
std::string saveName = std::string("tmp\\") + std::string(szSnapshotName); std::string saveName = std::string("tmp\\") + std::string(szSnapshotName);
Snapshot_SetFilename(saveName); Snapshot_SetFilename(saveName);
g_bSaveStateOnExit = true; g_bSaveStateOnExit = true;
bShutdown = true; bShutdown = true;
#endif #endif
szSnapshotName = NULL; g_cmdLine.szSnapshotName = NULL;
} }
else else
{ {
@ -1839,83 +1959,53 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
LogFileOutput("Main: Snapshot_Startup()\n"); LogFileOutput("Main: Snapshot_Startup()\n");
} }
if (szScreenshotFilename) if (g_cmdLine.szScreenshotFilename)
{ {
Video_RedrawAndTakeScreenShot(szScreenshotFilename); Video_RedrawAndTakeScreenShot(g_cmdLine.szScreenshotFilename);
bShutdown = true; g_cmdLine.bShutdown = true;
} }
if (bShutdown) if (g_cmdLine.bShutdown)
{ {
PostMessage(g_hFrameWindow, WM_DESTROY, 0, 0); // Close everything down PostMessage(g_hFrameWindow, WM_DESTROY, 0, 0); // Close everything down
// NB. If shutting down, then don't post any other messages (GH#286) // NB. If shutting down, then don't post any other messages (GH#286)
} }
else else
{ {
if (bSetFullScreen) if (g_cmdLine.bSetFullScreen)
{ {
if (bestWidth && bestHeight) if (g_cmdLine.bestWidth && g_cmdLine.bestHeight)
{ {
DEVMODE devMode; DEVMODE devMode;
memset(&devMode, 0, sizeof(devMode)); memset(&devMode, 0, sizeof(devMode));
devMode.dmSize = sizeof(devMode); devMode.dmSize = sizeof(devMode);
devMode.dmPelsWidth = bestWidth; devMode.dmPelsWidth = g_cmdLine.bestWidth;
devMode.dmPelsHeight = bestHeight; devMode.dmPelsHeight = g_cmdLine.bestHeight;
devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
DWORD dwFlags = 0; DWORD dwFlags = 0;
LONG res = ChangeDisplaySettings(&devMode, dwFlags); LONG res = ChangeDisplaySettings(&devMode, dwFlags);
if (res == 0) if (res == 0)
bChangedDisplayResolution = true; g_cmdLine.bChangedDisplayResolution = true;
} }
PostMessage(g_hFrameWindow, WM_USER_FULLSCREEN, 0, 0); PostMessage(g_hFrameWindow, WM_USER_FULLSCREEN, 0, 0);
bSetFullScreen = false; g_cmdLine.bSetFullScreen = false;
} }
if (bBoot) if (g_cmdLine.bBoot)
{ {
PostMessage(g_hFrameWindow, WM_USER_BOOT, 0, 0); PostMessage(g_hFrameWindow, WM_USER_BOOT, 0, 0);
bBoot = false; g_cmdLine.bBoot = false;
} }
} }
SetMouseCardInstalled( g_CardMgr.IsMouseCardInstalled() ); SetMouseCardInstalled( g_CardMgr.IsMouseCardInstalled() );
}
// ENTER THE MAIN MESSAGE LOOP static void Shutdown(void)
LogFileOutput("Main: EnterMessageLoop()\n"); {
EnterMessageLoop(); if (g_cmdLine.bChangedDisplayResolution)
LogFileOutput("Main: LeaveMessageLoop()\n");
if (g_bRestart)
{
bSetFullScreen = g_bRestartFullScreen;
g_bRestartFullScreen = false;
}
MB_Reset();
LogFileOutput("Main: MB_Reset()\n");
CMouseInterface* pMouseCard = g_CardMgr.GetMouseCard();
if (pMouseCard)
{
// pMouseCard->Uninitialize(); // Maybe restarting due to switching slot-4 card from MouseCard to Mockingboard
pMouseCard->Reset(); // Deassert any pending IRQs - GH#514
LogFileOutput("Main: CMouseInterface::Uninitialize()\n");
}
DSUninit();
LogFileOutput("Main: DSUninit()\n");
if (g_bHookSystemKey)
{
UninitHookThread();
LogFileOutput("Main: UnhookFilterForKeyboard()\n");
}
}
while (g_bRestart);
if (bChangedDisplayResolution)
ChangeDisplaySettings(NULL, 0); // restore default ChangeDisplaySettings(NULL, 0); // restore default
// Release COM // Release COM
@ -1936,8 +2026,6 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
if (g_hCustomRomF8 != INVALID_HANDLE_VALUE) if (g_hCustomRomF8 != INVALID_HANDLE_VALUE)
CloseHandle(g_hCustomRomF8); CloseHandle(g_hCustomRomF8);
if (bSlot7EmptyOnExit) if (g_cmdLine.bSlot7EmptyOnExit)
UnplugHardDiskControllerCard(); UnplugHardDiskControllerCard();
return 0;
} }

View file

@ -30,6 +30,12 @@ public:
void Insert(UINT slot, SS_CARDTYPE type); void Insert(UINT slot, SS_CARDTYPE type);
void Remove(UINT slot); void Remove(UINT slot);
SS_CARDTYPE QuerySlot(UINT slot) { return m_slot[slot]->QueryType(); } SS_CARDTYPE QuerySlot(UINT slot) { return m_slot[slot]->QueryType(); }
Card& GetRef(UINT slot)
{
SS_CARDTYPE t=QuerySlot(slot); _ASSERT((t==CT_SSC || t==CT_MouseInterface || t==CT_Disk2) && m_slot[slot]);
if (!m_slot[slot]) throw std::runtime_error("slot/card mismatch");
return *m_slot[slot];
}
Card* GetObj(UINT slot) { SS_CARDTYPE t=QuerySlot(slot); _ASSERT(t==CT_SSC || t==CT_MouseInterface || t==CT_Disk2); return m_slot[slot]; } Card* GetObj(UINT slot) { SS_CARDTYPE t=QuerySlot(slot); _ASSERT(t==CT_SSC || t==CT_MouseInterface || t==CT_Disk2); return m_slot[slot]; }
void InsertAux(SS_CARDTYPE type); void InsertAux(SS_CARDTYPE type);

View file

@ -135,6 +135,8 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l
if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
InitComboFloppyDrive(hWnd, SLOT6); InitComboFloppyDrive(hWnd, SLOT6);
else
EnableFloppyDrive(hWnd, FALSE);
InitComboHDD(hWnd, SLOT7); InitComboHDD(hWnd, SLOT7);
@ -158,20 +160,20 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l
void CPageDisk::InitComboFloppyDrive(HWND hWnd, UINT slot) void CPageDisk::InitComboFloppyDrive(HWND hWnd, UINT slot)
{ {
Disk2InterfaceCard* pDisk2Card = dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(slot)); Disk2InterfaceCard& disk2Card = dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(slot));
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK1, m_defaultDiskOptions, -1); m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK1, m_defaultDiskOptions, -1);
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK2, m_defaultDiskOptions, -1); m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_DISK2, m_defaultDiskOptions, -1);
if (!pDisk2Card->GetFullName(DRIVE_1).empty()) if (!disk2Card.GetFullName(DRIVE_1).empty())
{ {
SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_INSERTSTRING, 0, (LPARAM)pDisk2Card->GetFullName(DRIVE_1).c_str()); SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_INSERTSTRING, 0, (LPARAM)disk2Card.GetFullName(DRIVE_1).c_str());
SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_SETCURSEL, 0, 0); SendDlgItemMessage(hWnd, IDC_COMBO_DISK1, CB_SETCURSEL, 0, 0);
} }
if (!pDisk2Card->GetFullName(DRIVE_2).empty()) if (!disk2Card.GetFullName(DRIVE_2).empty())
{ {
SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_INSERTSTRING, 0, (LPARAM)pDisk2Card->GetFullName(DRIVE_2).c_str()); SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_INSERTSTRING, 0, (LPARAM)disk2Card.GetFullName(DRIVE_2).c_str());
SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_SETCURSEL, 0, 0); SendDlgItemMessage(hWnd, IDC_COMBO_DISK2, CB_SETCURSEL, 0, 0);
} }
} }
@ -228,7 +230,7 @@ void CPageDisk::EnableHDD(HWND hWnd, BOOL bEnable)
EnableWindow(GetDlgItem(hWnd, IDC_HDD_SWAP), bEnable); EnableWindow(GetDlgItem(hWnd, IDC_HDD_SWAP), bEnable);
} }
void CPageDisk::EnableDisk(HWND hWnd, BOOL bEnable) void CPageDisk::EnableFloppyDrive(HWND hWnd, BOOL bEnable)
{ {
EnableWindow(GetDlgItem(hWnd, IDC_COMBO_DISK1), bEnable); EnableWindow(GetDlgItem(hWnd, IDC_COMBO_DISK1), bEnable);
EnableWindow(GetDlgItem(hWnd, IDC_COMBO_DISK2), bEnable); EnableWindow(GetDlgItem(hWnd, IDC_COMBO_DISK2), bEnable);
@ -300,9 +302,13 @@ void CPageDisk::HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelected
void CPageDisk::HandleFloppyDriveCombo(HWND hWnd, UINT driveSelected, UINT comboSelected) void CPageDisk::HandleFloppyDriveCombo(HWND hWnd, UINT driveSelected, UINT comboSelected)
{ {
Disk2InterfaceCard* pDisk2Card = (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2)
? dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6)) {
: NULL; _ASSERT(0); // Shouldn't come here, as the combo is disabled
return;
}
Disk2InterfaceCard& disk2Card = dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6));
// Search from "select floppy drive" // Search from "select floppy drive"
DWORD dwOpenDialogIndex = (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_FINDSTRINGEXACT, -1, (LPARAM)&m_defaultDiskOptions[0]); DWORD dwOpenDialogIndex = (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_FINDSTRINGEXACT, -1, (LPARAM)&m_defaultDiskOptions[0]);
@ -312,10 +318,9 @@ void CPageDisk::HandleFloppyDriveCombo(HWND hWnd, UINT driveSelected, UINT combo
if (dwComboSelection == dwOpenDialogIndex) if (dwComboSelection == dwOpenDialogIndex)
{ {
EnableDisk(hWnd, FALSE); // Prevent multiple Selection dialogs to be triggered EnableFloppyDrive(hWnd, FALSE); // Prevent multiple Selection dialogs to be triggered
bool bRes = false; bool bRes = disk2Card.UserSelectNewDiskImage(driveSelected);
if (pDisk2Card) bRes = pDisk2Card->UserSelectNewDiskImage(driveSelected); EnableFloppyDrive(hWnd, TRUE);
EnableDisk(hWnd, TRUE);
if (!bRes) if (!bRes)
{ {
@ -331,8 +336,7 @@ void CPageDisk::HandleFloppyDriveCombo(HWND hWnd, UINT driveSelected, UINT combo
SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0); SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0);
} }
std::string fullname; std::string fullname = disk2Card.GetFullName(driveSelected);
if (pDisk2Card) fullname = pDisk2Card->GetFullName(driveSelected);
SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)fullname.c_str()); SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)fullname.c_str());
SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0); SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0);
@ -354,7 +358,7 @@ void CPageDisk::HandleFloppyDriveCombo(HWND hWnd, UINT driveSelected, UINT combo
if (RemovalConfirmation(uCommand)) if (RemovalConfirmation(uCommand))
{ {
// Eject selected disk // Eject selected disk
if (pDisk2Card) pDisk2Card->EjectDisk(driveSelected); disk2Card.EjectDisk(driveSelected);
// Remove drive from list // Remove drive from list
SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0); SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0);
} }

View file

@ -28,7 +28,7 @@ private:
void InitComboFloppyDrive(HWND hWnd, UINT slot); void InitComboFloppyDrive(HWND hWnd, UINT slot);
void InitComboHDD(HWND hWnd, UINT slot); void InitComboHDD(HWND hWnd, UINT slot);
void EnableHDD(HWND hWnd, BOOL bEnable); void EnableHDD(HWND hWnd, BOOL bEnable);
void EnableDisk(HWND hWnd, BOOL bEnable); void EnableFloppyDrive(HWND hWnd, BOOL bEnable);
void HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelected); void HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelected);
void HandleFloppyDriveCombo(HWND hWnd, UINT driveSelected, UINT comboSelected); void HandleFloppyDriveCombo(HWND hWnd, UINT driveSelected, UINT comboSelected);
void HandleHDDSwap(HWND hWnd); void HandleHDDSwap(HWND hWnd);

View file

@ -217,10 +217,10 @@ void CPropertySheetHelper::GetDiskBaseNameWithAWS(std::string & pszFilename)
if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2)
return; return;
const std::string & pDiskName = dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6))->GetBaseName(DRIVE_1); const std::string& diskName = dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6)).GetBaseName(DRIVE_1);
if (!pDiskName.empty()) if (!diskName.empty())
{ {
pszFilename = pDiskName + ".aws.yaml"; pszFilename = diskName + ".aws.yaml";
} }
} }

View file

@ -3756,7 +3756,7 @@ Update_t CmdDisk ( int nArgs)
if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2)
return ConsoleDisplayError("No DiskII card in slot-6"); return ConsoleDisplayError("No DiskII card in slot-6");
Disk2InterfaceCard* pDiskCard = dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6)); Disk2InterfaceCard& diskCard = dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6));
// check for info command // check for info command
int iParam = 0; int iParam = 0;
@ -3769,13 +3769,13 @@ Update_t CmdDisk ( int nArgs)
char buffer[200] = ""; char buffer[200] = "";
ConsoleBufferPushFormat(buffer, "D%d at T$%s, phase $%s, offset $%X, mask $%02X, extraCycles %.2f, %s", ConsoleBufferPushFormat(buffer, "D%d at T$%s, phase $%s, offset $%X, mask $%02X, extraCycles %.2f, %s",
pDiskCard->GetCurrentDrive() + 1, diskCard.GetCurrentDrive() + 1,
pDiskCard->GetCurrentTrackString().c_str(), diskCard.GetCurrentTrackString().c_str(),
pDiskCard->GetCurrentPhaseString().c_str(), diskCard.GetCurrentPhaseString().c_str(),
pDiskCard->GetCurrentOffset(), diskCard.GetCurrentOffset(),
pDiskCard->GetCurrentLSSBitMask(), diskCard.GetCurrentLSSBitMask(),
pDiskCard->GetCurrentExtraCycles(), diskCard.GetCurrentExtraCycles(),
pDiskCard->GetCurrentState() diskCard.GetCurrentState()
); );
return ConsoleUpdate(); return ConsoleUpdate();
@ -3803,7 +3803,7 @@ Update_t CmdDisk ( int nArgs)
if (nArgs > 2) if (nArgs > 2)
goto _Help; goto _Help;
pDiskCard->EjectDisk( iDrive ); diskCard.EjectDisk( iDrive );
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES);
} }
else else
@ -3817,7 +3817,7 @@ Update_t CmdDisk ( int nArgs)
if (nArgs == 3) if (nArgs == 3)
bProtect = g_aArgs[ 3 ].nValue ? true : false; bProtect = g_aArgs[ 3 ].nValue ? true : false;
pDiskCard->SetProtect( iDrive, bProtect ); diskCard.SetProtect( iDrive, bProtect );
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES);
} }
else else
@ -3828,7 +3828,7 @@ Update_t CmdDisk ( int nArgs)
LPCTSTR pDiskName = g_aArgs[ 3 ].sArg; LPCTSTR pDiskName = g_aArgs[ 3 ].sArg;
// DISK # "Diskname" // DISK # "Diskname"
pDiskCard->InsertDisk( iDrive, pDiskName, IMAGE_FORCE_WRITE_PROTECTED, IMAGE_DONT_CREATE ); diskCard.InsertDisk( iDrive, pDiskName, IMAGE_FORCE_WRITE_PROTECTED, IMAGE_DONT_CREATE );
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES);
} }
@ -7037,7 +7037,7 @@ Update_t CmdWatchAdd (int nArgs)
if (iWatch == NO_6502_TARGET) if (iWatch == NO_6502_TARGET)
{ {
iWatch = 0; iWatch = 0;
while ((iWatch < MAX_ZEROPAGE_POINTERS) && (g_aWatches[iWatch].bSet)) while ((iWatch < MAX_WATCHES) && (g_aWatches[iWatch].bSet))
{ {
iWatch++; iWatch++;
} }
@ -9642,6 +9642,14 @@ void DebugDisplay( BOOL bInitDisasm/*=FALSE*/ )
if (bInitDisasm) if (bInitDisasm)
InitDisasm(); InitDisasm();
if (DebugVideoMode::Instance().IsSet())
{
uint32_t mode = 0;
DebugVideoMode::Instance().Get(&mode);
VideoRefreshScreen(mode, true);
return;
}
UpdateDisplay( UPDATE_ALL ); UpdateDisplay( UPDATE_ALL );
} }

View file

@ -125,7 +125,7 @@ WORD _CmdDefineByteRange(int nArgs,int iArg,DisasmData_t & tData_)
// TODO: Note: need to call ConsoleUpdate(), as may print symbol has been updated // TODO: Note: need to call ConsoleUpdate(), as may print symbol has been updated
strcpy( tData_.sSymbol, pSymbolName ); strcpy_s( tData_.sSymbol, sizeof(tData_.sSymbol), pSymbolName );
return nAddress; return nAddress;
} }

View file

@ -40,7 +40,7 @@ bool Disk2CardManager::IsConditionForFullSpeed(void)
{ {
if (g_CardMgr.QuerySlot(i) == CT_Disk2) if (g_CardMgr.QuerySlot(i) == CT_Disk2)
{ {
if (dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(i))->IsConditionForFullSpeed()) if (dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(i)).IsConditionForFullSpeed())
return true; // if any card is true then the condition for full-speed is true return true; // if any card is true then the condition for full-speed is true
} }
} }
@ -54,7 +54,7 @@ void Disk2CardManager::UpdateDriveState(UINT cycles)
{ {
if (g_CardMgr.QuerySlot(i) == CT_Disk2) if (g_CardMgr.QuerySlot(i) == CT_Disk2)
{ {
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(i))->UpdateDriveState(cycles); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(i)).UpdateDriveState(cycles);
} }
} }
} }
@ -65,7 +65,7 @@ void Disk2CardManager::Reset(const bool powerCycle /*=false*/)
{ {
if (g_CardMgr.QuerySlot(i) == CT_Disk2) if (g_CardMgr.QuerySlot(i) == CT_Disk2)
{ {
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(i))->Reset(powerCycle); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(i)).Reset(powerCycle);
} }
} }
} }
@ -77,7 +77,7 @@ bool Disk2CardManager::GetEnhanceDisk(void)
if (g_CardMgr.QuerySlot(i) == CT_Disk2) if (g_CardMgr.QuerySlot(i) == CT_Disk2)
{ {
// All Disk2 cards should have the same setting, so just return the state of the first card // All Disk2 cards should have the same setting, so just return the state of the first card
return dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(i))->GetEnhanceDisk(); return dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(i)).GetEnhanceDisk();
} }
} }
return false; return false;
@ -89,7 +89,7 @@ void Disk2CardManager::SetEnhanceDisk(bool enhanceDisk)
{ {
if (g_CardMgr.QuerySlot(i) == CT_Disk2) if (g_CardMgr.QuerySlot(i) == CT_Disk2)
{ {
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(i))->SetEnhanceDisk(enhanceDisk); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(i)).SetEnhanceDisk(enhanceDisk);
} }
} }
} }
@ -102,8 +102,8 @@ void Disk2CardManager::LoadLastDiskImage(void)
if (g_CardMgr.QuerySlot(i) == CT_Disk2) if (g_CardMgr.QuerySlot(i) == CT_Disk2)
{ {
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(i))->LoadLastDiskImage(DRIVE_1); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(i)).LoadLastDiskImage(DRIVE_1);
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(i))->LoadLastDiskImage(DRIVE_2); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(i)).LoadLastDiskImage(DRIVE_2);
} }
} }
} }
@ -114,7 +114,7 @@ void Disk2CardManager::Destroy(void)
{ {
if (g_CardMgr.QuerySlot(i) == CT_Disk2) if (g_CardMgr.QuerySlot(i) == CT_Disk2)
{ {
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(i))->Destroy(); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(i)).Destroy();
} }
} }
} }

View file

@ -56,6 +56,7 @@ ImageInfo::ImageInfo()
pImageBuffer = NULL; pImageBuffer = NULL;
pTrackMap = NULL; pTrackMap = NULL;
optimalBitTiming = 0; optimalBitTiming = 0;
maxNibblesPerTrack = 0;
} }
/* DO logical order 0 1 2 3 4 5 6 7 8 9 A B C D E F */ /* DO logical order 0 1 2 3 4 5 6 7 8 9 A B C D E F */
@ -123,11 +124,12 @@ bool CImageBase::WriteTrack(ImageInfo* pImageInfo, const int nTrack, LPBYTE pTra
return false; return false;
int nLen = gzwrite(hGZFile, pImageInfo->pImageBuffer, pImageInfo->uImageSize); int nLen = gzwrite(hGZFile, pImageInfo->pImageBuffer, pImageInfo->uImageSize);
int nRes = gzclose(hGZFile); // close before returning (due to error) to avoid resource leak
hGZFile = NULL;
if (nLen != pImageInfo->uImageSize) if (nLen != pImageInfo->uImageSize)
return false; return false;
int nRes = gzclose(hGZFile);
hGZFile = NULL;
if (nRes != Z_OK) if (nRes != Z_OK)
return false; return false;
} }
@ -244,11 +246,12 @@ bool CImageBase::WriteBlock(ImageInfo* pImageInfo, const int nBlock, LPBYTE pBlo
return false; return false;
int nLen = gzwrite(hGZFile, pImageInfo->pImageBuffer, pImageInfo->uImageSize); int nLen = gzwrite(hGZFile, pImageInfo->pImageBuffer, pImageInfo->uImageSize);
int nRes = gzclose(hGZFile); // close before returning (due to error) to avoid resource leak
hGZFile = NULL;
if (nLen != pImageInfo->uImageSize) if (nLen != pImageInfo->uImageSize)
return false; return false;
int nRes = gzclose(hGZFile);
hGZFile = NULL;
if (nRes != Z_OK) if (nRes != Z_OK)
return false; return false;
} }
@ -1398,11 +1401,12 @@ ImageError_e CImageHelperBase::CheckGZipFile(LPCTSTR pszImageFilename, ImageInfo
pImageInfo->pImageBuffer = new BYTE[MAX_UNCOMPRESSED_SIZE]; pImageInfo->pImageBuffer = new BYTE[MAX_UNCOMPRESSED_SIZE];
int nLen = gzread(hGZFile, pImageInfo->pImageBuffer, MAX_UNCOMPRESSED_SIZE); int nLen = gzread(hGZFile, pImageInfo->pImageBuffer, MAX_UNCOMPRESSED_SIZE);
int nRes = gzclose(hGZFile); // close before returning (due to error) to avoid resource leak
hGZFile = NULL;
if (nLen < 0 || nLen == MAX_UNCOMPRESSED_SIZE) if (nLen < 0 || nLen == MAX_UNCOMPRESSED_SIZE)
return eIMAGE_ERROR_BAD_SIZE; return eIMAGE_ERROR_BAD_SIZE;
int nRes = gzclose(hGZFile);
hGZFile = NULL;
if (nRes != Z_OK) if (nRes != Z_OK)
return eIMAGE_ERROR_GZ; return eIMAGE_ERROR_GZ;
@ -1414,7 +1418,7 @@ ImageError_e CImageHelperBase::CheckGZipFile(LPCTSTR pszImageFilename, ImageInfo
DWORD dwSize = nLen; DWORD dwSize = nLen;
DWORD dwOffset = 0; DWORD dwOffset = 0;
CImageBase* pImageType = Detect(pImageInfo->pImageBuffer, dwSize, szExt, dwOffset, pImageInfo->bWriteProtected, pImageInfo->pTrackMap, pImageInfo->optimalBitTiming, pImageInfo->maxNibblesPerTrack); CImageBase* pImageType = Detect(pImageInfo->pImageBuffer, dwSize, szExt, dwOffset, pImageInfo);
if (!pImageType) if (!pImageType)
return eIMAGE_ERROR_UNSUPPORTED; return eIMAGE_ERROR_UNSUPPORTED;
@ -1505,7 +1509,7 @@ ImageError_e CImageHelperBase::CheckZipFile(LPCTSTR pszImageFilename, ImageInfo*
DWORD dwSize = nLen; DWORD dwSize = nLen;
DWORD dwOffset = 0; DWORD dwOffset = 0;
CImageBase* pImageType = Detect(pImageInfo->pImageBuffer, dwSize, szExt, dwOffset, pImageInfo->bWriteProtected, pImageInfo->pTrackMap, pImageInfo->optimalBitTiming, pImageInfo->maxNibblesPerTrack); CImageBase* pImageType = Detect(pImageInfo->pImageBuffer, dwSize, szExt, dwOffset, pImageInfo);
if (!pImageType) if (!pImageType)
{ {
@ -1602,7 +1606,7 @@ ImageError_e CImageHelperBase::CheckNormalFile(LPCTSTR pszImageFilename, ImageIn
return eIMAGE_ERROR_BAD_SIZE; return eIMAGE_ERROR_BAD_SIZE;
} }
pImageType = Detect(pImageInfo->pImageBuffer, dwSize, szExt, dwOffset, pImageInfo->bWriteProtected, pImageInfo->pTrackMap, pImageInfo->optimalBitTiming, pImageInfo->maxNibblesPerTrack); pImageType = Detect(pImageInfo->pImageBuffer, dwSize, szExt, dwOffset, pImageInfo);
if (bTempDetectBuffer) if (bTempDetectBuffer)
{ {
delete [] pImageInfo->pImageBuffer; delete [] pImageInfo->pImageBuffer;
@ -1747,13 +1751,12 @@ CDiskImageHelper::CDiskImageHelper(void) :
m_vecImageTypes.push_back( new CWOZ2Image ); m_vecImageTypes.push_back( new CWOZ2Image );
} }
CImageBase* CDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, CImageBase* CDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, ImageInfo* pImageInfo)
bool& writeProtected, BYTE*& pTrackMap, BYTE& optimalBitTiming, UINT& maxNibblesPerTrack)
{ {
dwOffset = 0; dwOffset = 0;
m_MacBinaryHelper.DetectHdr(pImage, dwSize, dwOffset); m_MacBinaryHelper.DetectHdr(pImage, dwSize, dwOffset);
m_Result2IMG = m_2IMGHelper.DetectHdr(pImage, dwSize, dwOffset); m_Result2IMG = m_2IMGHelper.DetectHdr(pImage, dwSize, dwOffset);
maxNibblesPerTrack = NIBBLES_PER_TRACK; // Start with the default size (for all types). May get changed below. pImageInfo->maxNibblesPerTrack = NIBBLES_PER_TRACK; // Start with the default size (for all types). May get changed below.
// CALL THE DETECTION FUNCTIONS IN ORDER, LOOKING FOR A MATCH // CALL THE DETECTION FUNCTIONS IN ORDER, LOOKING FOR A MATCH
eImageType imageType = eImageUNKNOWN; eImageType imageType = eImageUNKNOWN;
@ -1798,14 +1801,14 @@ CImageBase* CDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* p
if (imageType == eImageWOZ1 || imageType == eImageWOZ2) if (imageType == eImageWOZ1 || imageType == eImageWOZ2)
{ {
if (m_WOZHelper.ProcessChunks(pImage, dwSize, dwOffset, pTrackMap) != eMatch) if (m_WOZHelper.ProcessChunks(pImage, dwSize, dwOffset, pImageInfo->pTrackMap) != eMatch)
return NULL; return NULL;
// if (m_WOZHelper.IsWriteProtected() && !writeProtected) // Force write-protected until writing is supported // if (m_WOZHelper.IsWriteProtected() && !pImageInfo->writeProtected) // Force write-protected until writing is supported
writeProtected = true; pImageInfo->bWriteProtected = true;
optimalBitTiming = m_WOZHelper.GetOptimalBitTiming(); pImageInfo->optimalBitTiming = m_WOZHelper.GetOptimalBitTiming();
maxNibblesPerTrack = m_WOZHelper.GetMaxNibblesPerTrack(); pImageInfo->maxNibblesPerTrack = m_WOZHelper.GetMaxNibblesPerTrack();
} }
else else
{ {
@ -1821,8 +1824,8 @@ CImageBase* CDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* p
{ {
pImageType->SetVolumeNumber( m_2IMGHelper.GetVolumeNumber() ); pImageType->SetVolumeNumber( m_2IMGHelper.GetVolumeNumber() );
if (m_2IMGHelper.IsLocked() && !writeProtected) if (m_2IMGHelper.IsLocked() && !pImageInfo->bWriteProtected)
writeProtected = true; pImageInfo->bWriteProtected = true;
} }
else else
{ {
@ -1877,8 +1880,7 @@ CHardDiskImageHelper::CHardDiskImageHelper(void) :
m_vecImageTypes.push_back( new CHDVImage ); m_vecImageTypes.push_back( new CHDVImage );
} }
CImageBase* CHardDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, CImageBase* CHardDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, ImageInfo* pImageInfo)
bool& writeProtected, BYTE*& pTrackMap, BYTE& optimalBitTiming, UINT& maxNibblesPerTrack)
{ {
dwOffset = 0; dwOffset = 0;
m_Result2IMG = m_2IMGHelper.DetectHdr(pImage, dwSize, dwOffset); m_Result2IMG = m_2IMGHelper.DetectHdr(pImage, dwSize, dwOffset);
@ -1903,14 +1905,14 @@ CImageBase* CHardDiskImageHelper::Detect(LPBYTE pImage, DWORD dwSize, const TCHA
{ {
if (m_Result2IMG == eMatch) if (m_Result2IMG == eMatch)
{ {
if (m_2IMGHelper.IsLocked() && !writeProtected) if (m_2IMGHelper.IsLocked() && !pImageInfo->bWriteProtected)
writeProtected = true; pImageInfo->bWriteProtected = true;
} }
} }
pTrackMap = 0; // TODO: WOZ pImageInfo->pTrackMap = 0; // TODO: WOZ
optimalBitTiming = 0; // TODO: WOZ pImageInfo->optimalBitTiming = 0; // TODO: WOZ
maxNibblesPerTrack = 0; // TODO pImageInfo->maxNibblesPerTrack = 0; // TODO
return pImageType; return pImageType;
} }

View file

@ -307,7 +307,7 @@ public:
ImageError_e Open(LPCTSTR pszImageFilename, ImageInfo* pImageInfo, const bool bCreateIfNecessary, std::string& strFilenameInZip); ImageError_e Open(LPCTSTR pszImageFilename, ImageInfo* pImageInfo, const bool bCreateIfNecessary, std::string& strFilenameInZip);
void Close(ImageInfo* pImageInfo, const bool bDeleteFile); void Close(ImageInfo* pImageInfo, const bool bDeleteFile);
virtual CImageBase* Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, bool& writeProtected, BYTE*& pTrackMap, BYTE& optimalBitTiming, UINT& maxNibblesPerTrack) = 0; virtual CImageBase* Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, ImageInfo* pImageInfo) = 0;
virtual CImageBase* GetImageForCreation(const TCHAR* pszExt, DWORD* pCreateImageSize) = 0; virtual CImageBase* GetImageForCreation(const TCHAR* pszExt, DWORD* pCreateImageSize) = 0;
virtual UINT GetMaxImageSize(void) = 0; virtual UINT GetMaxImageSize(void) = 0;
virtual UINT GetMinDetectSize(const UINT uImageSize, bool* pTempDetectBuffer) = 0; virtual UINT GetMinDetectSize(const UINT uImageSize, bool* pTempDetectBuffer) = 0;
@ -352,7 +352,7 @@ public:
CDiskImageHelper(void); CDiskImageHelper(void);
virtual ~CDiskImageHelper(void) {} virtual ~CDiskImageHelper(void) {}
virtual CImageBase* Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, bool& writeProtected, BYTE*& pTrackMap, BYTE& optimalBitTiming, UINT& maxNibblesPerTrack); virtual CImageBase* Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, ImageInfo* pImageInfo);
virtual CImageBase* GetImageForCreation(const TCHAR* pszExt, DWORD* pCreateImageSize); virtual CImageBase* GetImageForCreation(const TCHAR* pszExt, DWORD* pCreateImageSize);
virtual UINT GetMaxImageSize(void); virtual UINT GetMaxImageSize(void);
virtual UINT GetMinDetectSize(const UINT uImageSize, bool* pTempDetectBuffer); virtual UINT GetMinDetectSize(const UINT uImageSize, bool* pTempDetectBuffer);
@ -378,7 +378,7 @@ public:
CHardDiskImageHelper(void); CHardDiskImageHelper(void);
virtual ~CHardDiskImageHelper(void) {} virtual ~CHardDiskImageHelper(void) {}
virtual CImageBase* Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, bool& writeProtected, BYTE*& pTrackMap, BYTE& optimalBitTiming, UINT& maxNibblesPerTrack); virtual CImageBase* Detect(LPBYTE pImage, DWORD dwSize, const TCHAR* pszExt, DWORD& dwOffset, ImageInfo* pImageInfo);
virtual CImageBase* GetImageForCreation(const TCHAR* pszExt, DWORD* pCreateImageSize); virtual CImageBase* GetImageForCreation(const TCHAR* pszExt, DWORD* pCreateImageSize);
virtual UINT GetMaxImageSize(void); virtual UINT GetMaxImageSize(void);
virtual UINT GetMinDetectSize(const UINT uImageSize, bool* pTempDetectBuffer); virtual UINT GetMinDetectSize(const UINT uImageSize, bool* pTempDetectBuffer);

View file

@ -129,7 +129,6 @@ static bool g_bIsFullScreen = false;
BOOL g_bMultiMon = 0; // OFF = load window position & clamp initial frame to screen, ON = use window position as is BOOL g_bMultiMon = 0; // OFF = load window position & clamp initial frame to screen, ON = use window position as is
static BOOL helpquit = 0; static BOOL helpquit = 0;
static BOOL g_bPaintingWindow = 0;
static HFONT smallfont = (HFONT)0; static HFONT smallfont = (HFONT)0;
static HWND tooltipwindow = (HWND)0; static HWND tooltipwindow = (HWND)0;
static BOOL g_bUsingCursor = FALSE; // TRUE = AppleWin is using (hiding) the mouse-cursor && restricting cursor to window - see SetUsingCursor() static BOOL g_bUsingCursor = FALSE; // TRUE = AppleWin is using (hiding) the mouse-cursor && restricting cursor to window - see SetUsingCursor()
@ -515,7 +514,7 @@ static void DrawButton (HDC passdc, int number) {
SetBkMode(dc,TRANSPARENT); SetBkMode(dc,TRANSPARENT);
LPCTSTR pszBaseName = (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) LPCTSTR pszBaseName = (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
? dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6))->GetBaseName(number-BTN_DRIVE1).c_str() ? dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6)).GetBaseName(number-BTN_DRIVE1).c_str()
: ""; : "";
ExtTextOut(dc,x+offset+22,rect.top,ETO_CLIPPED,&rect, ExtTextOut(dc,x+offset+22,rect.top,ETO_CLIPPED,&rect,
@ -623,13 +622,14 @@ static void DrawCrosshairs (int x, int y) {
} }
//=========================================================================== //===========================================================================
static void DrawFrameWindow () static void DrawFrameWindow (bool bPaintingWindow = false);
static void DrawFrameWindow (bool bPaintingWindow/*=false*/)
{ {
FrameReleaseDC(); FrameReleaseDC();
PAINTSTRUCT ps; PAINTSTRUCT ps;
HDC dc = (g_bPaintingWindow HDC dc = bPaintingWindow
? BeginPaint(g_hFrameWindow,&ps) ? BeginPaint(g_hFrameWindow,&ps)
: GetDC(g_hFrameWindow)); : GetDC(g_hFrameWindow);
if (!g_bIsFullScreen) if (!g_bIsFullScreen)
{ {
@ -677,7 +677,7 @@ static void DrawFrameWindow ()
else else
VideoRedrawScreen(); VideoRedrawScreen();
if (g_bPaintingWindow) if (bPaintingWindow)
EndPaint(g_hFrameWindow,&ps); EndPaint(g_hFrameWindow,&ps);
else else
ReleaseDC(g_hFrameWindow,dc); ReleaseDC(g_hFrameWindow,dc);
@ -710,14 +710,14 @@ void FrameDrawDiskLEDS( HDC passdc )
// Slot6 drive takes priority unless it's off: // Slot6 drive takes priority unless it's off:
if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6))->GetLightStatus(&g_eStatusDrive1, &g_eStatusDrive2); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6)).GetLightStatus(&g_eStatusDrive1, &g_eStatusDrive2);
// Slot5: // Slot5:
{ {
Disk_Status_e eDrive1StatusSlot5 = DISK_STATUS_OFF; Disk_Status_e eDrive1StatusSlot5 = DISK_STATUS_OFF;
Disk_Status_e eDrive2StatusSlot5 = DISK_STATUS_OFF; Disk_Status_e eDrive2StatusSlot5 = DISK_STATUS_OFF;
if (g_CardMgr.QuerySlot(SLOT5) == CT_Disk2) if (g_CardMgr.QuerySlot(SLOT5) == CT_Disk2)
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT5))->GetLightStatus(&eDrive1StatusSlot5, &eDrive2StatusSlot5); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT5)).GetLightStatus(&eDrive1StatusSlot5, &eDrive2StatusSlot5);
if (g_eStatusDrive1 == DISK_STATUS_OFF) g_eStatusDrive1 = eDrive1StatusSlot5; if (g_eStatusDrive1 == DISK_STATUS_OFF) g_eStatusDrive1 = eDrive1StatusSlot5;
if (g_eStatusDrive2 == DISK_STATUS_OFF) g_eStatusDrive2 = eDrive2StatusSlot5; if (g_eStatusDrive2 == DISK_STATUS_OFF) g_eStatusDrive2 = eDrive2StatusSlot5;
@ -775,10 +775,10 @@ void FrameDrawDiskStatus( HDC passdc )
if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2)
return; return;
Disk2InterfaceCard* pDisk2Card = dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6)); Disk2InterfaceCard& disk2Card = dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6));
int nActiveFloppy = pDisk2Card->GetCurrentDrive(); int nActiveFloppy = disk2Card.GetCurrentDrive();
int nDisk1Track = pDisk2Card->GetTrack(DRIVE_1); int nDisk1Track = disk2Card.GetTrack(DRIVE_1);
int nDisk2Track = pDisk2Card->GetTrack(DRIVE_2); int nDisk2Track = disk2Card.GetTrack(DRIVE_2);
// Probe known OS's for Track/Sector // Probe known OS's for Track/Sector
int isProDOS = mem[ 0xBF00 ] == 0x4C; int isProDOS = mem[ 0xBF00 ] == 0x4C;
@ -1183,9 +1183,9 @@ LRESULT CALLBACK FrameWndProc (
LogFileOutput("WM_DDE_EXECUTE\n"); LogFileOutput("WM_DDE_EXECUTE\n");
if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
{ {
Disk2InterfaceCard* pDisk2Card = dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6)); Disk2InterfaceCard& disk2Card = dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6));
LPTSTR filename = (LPTSTR)GlobalLock((HGLOBAL)lparam); LPTSTR filename = (LPTSTR)GlobalLock((HGLOBAL)lparam);
ImageError_e Error = pDisk2Card->InsertDisk(DRIVE_1, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); ImageError_e Error = disk2Card.InsertDisk(DRIVE_1, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE);
if (Error == eIMAGE_ERROR_NONE) if (Error == eIMAGE_ERROR_NONE)
{ {
if (!g_bIsFullScreen) if (!g_bIsFullScreen)
@ -1195,7 +1195,7 @@ LRESULT CALLBACK FrameWndProc (
} }
else else
{ {
pDisk2Card->NotifyInvalidImage(DRIVE_1, filename, Error); disk2Card.NotifyInvalidImage(DRIVE_1, filename, Error);
} }
} }
GlobalUnlock((HGLOBAL)lparam); GlobalUnlock((HGLOBAL)lparam);
@ -1211,7 +1211,7 @@ LRESULT CALLBACK FrameWndProc (
{ {
if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
{ {
Disk2InterfaceCard* pDisk2Card = dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6)); Disk2InterfaceCard& disk2Card = dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6));
TCHAR filename[MAX_PATH]; TCHAR filename[MAX_PATH];
DragQueryFile((HDROP)wparam,0,filename,sizeof(filename)); DragQueryFile((HDROP)wparam,0,filename,sizeof(filename));
POINT point; POINT point;
@ -1222,7 +1222,7 @@ LRESULT CALLBACK FrameWndProc (
rect.top = buttony+BTN_DRIVE2*BUTTONCY+1; rect.top = buttony+BTN_DRIVE2*BUTTONCY+1;
rect.bottom = rect.top+BUTTONCY; rect.bottom = rect.top+BUTTONCY;
const int iDrive = PtInRect(&rect,point) ? DRIVE_2 : DRIVE_1; const int iDrive = PtInRect(&rect,point) ? DRIVE_2 : DRIVE_1;
ImageError_e Error = pDisk2Card->InsertDisk(iDrive, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE); ImageError_e Error = disk2Card.InsertDisk(iDrive, filename, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE);
if (Error == eIMAGE_ERROR_NONE) if (Error == eIMAGE_ERROR_NONE)
{ {
if (!g_bIsFullScreen) if (!g_bIsFullScreen)
@ -1236,7 +1236,7 @@ LRESULT CALLBACK FrameWndProc (
} }
else else
{ {
pDisk2Card->NotifyInvalidImage(iDrive, filename, Error); disk2Card.NotifyInvalidImage(iDrive, filename, Error);
} }
} }
DragFinish((HDROP)wparam); DragFinish((HDROP)wparam);
@ -1746,10 +1746,8 @@ LRESULT CALLBACK FrameWndProc (
break; break;
case WM_PAINT: case WM_PAINT:
if (GetUpdateRect(window,NULL,0)) { if (GetUpdateRect(window,NULL,0)){
g_bPaintingWindow = 1; DrawFrameWindow(true);
DrawFrameWindow();
g_bPaintingWindow = 0;
} }
break; break;
@ -2058,7 +2056,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/)
if (g_nAppMode == MODE_LOGO) if (g_nAppMode == MODE_LOGO)
{ {
if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6))->Boot(); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6)).Boot();
LogFileTimeUntilFirstKeyReadReset(); LogFileTimeUntilFirstKeyReadReset();
g_nAppMode = MODE_RUNNING; g_nAppMode = MODE_RUNNING;
@ -2084,7 +2082,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/)
case BTN_DRIVE2: case BTN_DRIVE2:
if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
{ {
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6))->UserSelectNewDiskImage(button-BTN_DRIVE1); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6)).UserSelectNewDiskImage(button-BTN_DRIVE1);
if (!g_bIsFullScreen) if (!g_bIsFullScreen)
DrawButton((HDC)0,button); DrawButton((HDC)0,button);
} }
@ -2093,7 +2091,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/)
case BTN_DRIVESWAP: case BTN_DRIVESWAP:
if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
{ {
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6))->DriveSwap(); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6)).DriveSwap();
} }
break; break;
@ -2152,7 +2150,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive)
if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2)
return; return;
Disk2InterfaceCard* pDisk2Card = dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6)); Disk2InterfaceCard& disk2Card = dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6));
// This is the default installation path of CiderPress. // This is the default installation path of CiderPress.
// It shall not be left blank, otherwise an explorer window will be open. // It shall not be left blank, otherwise an explorer window will be open.
@ -2167,7 +2165,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive)
//TODO: A directory is open if an empty path to CiderPress is set. This has to be fixed. //TODO: A directory is open if an empty path to CiderPress is set. This has to be fixed.
std::string filename1= "\""; std::string filename1= "\"";
filename1.append( pDisk2Card->GetFullName(iDrive) ); filename1.append( disk2Card.GetFullName(iDrive) );
filename1.append("\""); filename1.append("\"");
std::string sFileNameEmpty = "\""; std::string sFileNameEmpty = "\"";
sFileNameEmpty.append("\""); sFileNameEmpty.append("\"");
@ -2189,16 +2187,16 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive)
// Check menu depending on current floppy protection // Check menu depending on current floppy protection
{ {
int iMenuItem = ID_DISKMENU_WRITEPROTECTION_OFF; int iMenuItem = ID_DISKMENU_WRITEPROTECTION_OFF;
if (pDisk2Card->GetProtect( iDrive )) if (disk2Card.GetProtect( iDrive ))
iMenuItem = ID_DISKMENU_WRITEPROTECTION_ON; iMenuItem = ID_DISKMENU_WRITEPROTECTION_ON;
CheckMenuItem(hmenu, iMenuItem, MF_CHECKED); CheckMenuItem(hmenu, iMenuItem, MF_CHECKED);
} }
if (pDisk2Card->IsDriveEmpty(iDrive)) if (disk2Card.IsDriveEmpty(iDrive))
EnableMenuItem(hmenu, ID_DISKMENU_EJECT, MF_GRAYED); EnableMenuItem(hmenu, ID_DISKMENU_EJECT, MF_GRAYED);
if (pDisk2Card->IsDiskImageWriteProtected(iDrive)) if (disk2Card.IsDiskImageWriteProtected(iDrive))
{ {
// If image-file is read-only (or a gzip) then disable these menu items // If image-file is read-only (or a gzip) then disable these menu items
EnableMenuItem(hmenu, ID_DISKMENU_WRITEPROTECTION_ON, MF_GRAYED); EnableMenuItem(hmenu, ID_DISKMENU_WRITEPROTECTION_ON, MF_GRAYED);
@ -2214,13 +2212,13 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive)
, hwnd, NULL ); , hwnd, NULL );
if (iCommand == ID_DISKMENU_EJECT) if (iCommand == ID_DISKMENU_EJECT)
pDisk2Card->EjectDisk( iDrive ); disk2Card.EjectDisk( iDrive );
else else
if (iCommand == ID_DISKMENU_WRITEPROTECTION_ON) if (iCommand == ID_DISKMENU_WRITEPROTECTION_ON)
pDisk2Card->SetProtect( iDrive, true ); disk2Card.SetProtect( iDrive, true );
else else
if (iCommand == ID_DISKMENU_WRITEPROTECTION_OFF) if (iCommand == ID_DISKMENU_WRITEPROTECTION_OFF)
pDisk2Card->SetProtect( iDrive, false ); disk2Card.SetProtect( iDrive, false );
else else
if (iCommand == ID_DISKMENU_SENDTO_CIDERPRESS) if (iCommand == ID_DISKMENU_SENDTO_CIDERPRESS)
{ {
@ -2229,7 +2227,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive)
"Please install CiderPress.\n" "Please install CiderPress.\n"
"Otherwise set the path to CiderPress from Configuration->Disk."; "Otherwise set the path to CiderPress from Configuration->Disk.";
pDisk2Card->FlushCurrentTrack(iDrive); disk2Card.FlushCurrentTrack(iDrive);
//if(!filename1.compare("\"\"") == false) //Do not use this, for some reason it does not work!!! //if(!filename1.compare("\"\"") == false) //Do not use this, for some reason it does not work!!!
if(!filename1.compare(sFileNameEmpty) ) if(!filename1.compare(sFileNameEmpty) )
@ -2298,7 +2296,7 @@ void ResetMachineState ()
MemReset(); // calls CpuInitialize() MemReset(); // calls CpuInitialize()
PravetsReset(); PravetsReset();
if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6))->Boot(); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6)).Boot();
VideoResetState(); VideoResetState();
KeybReset(); KeybReset();
if (g_CardMgr.IsSSCInstalled()) if (g_CardMgr.IsSSCInstalled())

View file

@ -303,6 +303,24 @@ void JoyInitialize()
//=========================================================================== //===========================================================================
static bool g_swapButton0and1 = false;
void JoySwapButton0and1(bool swap)
{
g_swapButton0and1 = swap;
}
static UINT g_buttonVirtKey[2] = { VK_MENU, VK_MENU | KF_EXTENDED };
void JoySetButtonVirtualKey(UINT button, UINT virtKey)
{
_ASSERT(button < 2);
if (button >= 2) return;
g_buttonVirtKey[button] = virtKey;
}
//===========================================================================
#define SUPPORT_CURSOR_KEYS #define SUPPORT_CURSOR_KEYS
BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep) BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep)
@ -330,11 +348,17 @@ BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep)
BOOL keychange = 0; BOOL keychange = 0;
bool bIsCursorKey = false; bool bIsCursorKey = false;
UINT virtKeyWithExtended = ((UINT)virtkey) | (extended ? KF_EXTENDED : 0);
if (virtkey == VK_MENU) // VK_MENU == ALT Key (Button #0 or #1) if (virtKeyWithExtended == g_buttonVirtKey[!g_swapButton0and1 ? 0 : 1])
{ {
keychange = 1; keychange = 1;
keydown[JK_OPENAPPLE+(extended != 0)] = down; keydown[JK_OPENAPPLE] = down;
}
else if (virtKeyWithExtended == g_buttonVirtKey[!g_swapButton0and1 ? 1 : 0])
{
keychange = 1;
keydown[JK_CLOSEDAPPLE] = down;
} }
else if (!extended) else if (!extended)
{ {

View file

@ -25,6 +25,8 @@ void JoySetTrim(short nValue, bool bAxisX);
short JoyGetTrim(bool bAxisX); short JoyGetTrim(bool bAxisX);
void JoyportControl(const UINT uControl); void JoyportControl(const UINT uControl);
void JoySetHookAltKeys(bool hook); void JoySetHookAltKeys(bool hook);
void JoySwapButton0and1(bool swap);
void JoySetButtonVirtualKey(UINT button, UINT virtKey);
void JoySaveSnapshot(class YamlSaveHelper& yamlSaveHelper); void JoySaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
void JoyLoadSnapshot(class YamlLoadHelper& yamlLoadHelper); void JoyLoadSnapshot(class YamlLoadHelper& yamlLoadHelper);

View file

@ -1659,7 +1659,7 @@ void MemInitializeIO(void)
PrintLoadRom(pCxRomPeripheral, SLOT1); // $C100 : Parallel printer f/w PrintLoadRom(pCxRomPeripheral, SLOT1); // $C100 : Parallel printer f/w
if (g_CardMgr.QuerySlot(SLOT2) == CT_SSC) if (g_CardMgr.QuerySlot(SLOT2) == CT_SSC)
dynamic_cast<CSuperSerialCard*>(g_CardMgr.GetObj(SLOT2))->CommInitialize(pCxRomPeripheral, SLOT2); // $C200 : SSC dynamic_cast<CSuperSerialCard&>(g_CardMgr.GetRef(SLOT2)).CommInitialize(pCxRomPeripheral, SLOT2); // $C200 : SSC
if (g_CardMgr.QuerySlot(SLOT3) == CT_Uthernet) if (g_CardMgr.QuerySlot(SLOT3) == CT_Uthernet)
{ {
@ -1672,7 +1672,7 @@ void MemInitializeIO(void)
if (g_CardMgr.QuerySlot(SLOT4) == CT_MouseInterface) if (g_CardMgr.QuerySlot(SLOT4) == CT_MouseInterface)
{ {
dynamic_cast<CMouseInterface*>(g_CardMgr.GetObj(SLOT4))->Initialize(pCxRomPeripheral, SLOT4); // $C400 : Mouse f/w dynamic_cast<CMouseInterface&>(g_CardMgr.GetRef(SLOT4)).Initialize(pCxRomPeripheral, SLOT4); // $C400 : Mouse f/w
} }
else if (g_CardMgr.QuerySlot(SLOT4) == CT_MockingboardC || g_CardMgr.QuerySlot(SLOT4) == CT_Phasor) else if (g_CardMgr.QuerySlot(SLOT4) == CT_MockingboardC || g_CardMgr.QuerySlot(SLOT4) == CT_Phasor)
{ {
@ -1697,11 +1697,11 @@ void MemInitializeIO(void)
} }
else if (g_CardMgr.QuerySlot(SLOT5) == CT_Disk2) else if (g_CardMgr.QuerySlot(SLOT5) == CT_Disk2)
{ {
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT5))->Initialize(pCxRomPeripheral, SLOT5); // $C500 : Disk][ card dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT5)).Initialize(pCxRomPeripheral, SLOT5); // $C500 : Disk][ card
} }
if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6))->Initialize(pCxRomPeripheral, SLOT6); // $C600 : Disk][ card dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6)).Initialize(pCxRomPeripheral, SLOT6); // $C600 : Disk][ card
if (g_CardMgr.QuerySlot(SLOT7) == CT_GenericHDD) if (g_CardMgr.QuerySlot(SLOT7) == CT_GenericHDD)
HD_Load_Rom(pCxRomPeripheral, SLOT7); // $C700 : HDD f/w HD_Load_Rom(pCxRomPeripheral, SLOT7); // $C700 : HDD f/w
@ -1836,8 +1836,8 @@ void MemReset()
for( int i = 0; i < 256; i++ ) for( int i = 0; i < 256; i++ )
{ {
clock = getRandomTime(); clock = getRandomTime();
random[ (i+0) & 0xFF ] ^= (clock >> 0) & 0xFF; random[ (i+0) & 0xFF ] = (clock >> 0) & 0xFF;
random[ (i+1) & 0xFF ] ^= (clock >> 11) & 0xFF; random[ (i+1) & 0xFF ] = (clock >> 11) & 0xFF;
} }
memcpy( &memmain[ iByte ], random, 256 ); memcpy( &memmain[ iByte ], random, 256 );

View file

@ -269,13 +269,13 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion)
{ {
type = CT_SSC; type = CT_SSC;
g_CardMgr.Insert(slot, type); g_CardMgr.Insert(slot, type);
bRes = dynamic_cast<CSuperSerialCard*>(g_CardMgr.GetObj(slot))->LoadSnapshot(yamlLoadHelper, slot, cardVersion); bRes = dynamic_cast<CSuperSerialCard&>(g_CardMgr.GetRef(slot)).LoadSnapshot(yamlLoadHelper, slot, cardVersion);
} }
else if (card == CMouseInterface::GetSnapshotCardName()) else if (card == CMouseInterface::GetSnapshotCardName())
{ {
type = CT_MouseInterface; type = CT_MouseInterface;
g_CardMgr.Insert(slot, type); g_CardMgr.Insert(slot, type);
bRes = dynamic_cast<CMouseInterface*>(g_CardMgr.GetObj(slot))->LoadSnapshot(yamlLoadHelper, slot, cardVersion); bRes = dynamic_cast<CMouseInterface&>(g_CardMgr.GetRef(slot)).LoadSnapshot(yamlLoadHelper, slot, cardVersion);
} }
else if (card == Z80_GetSnapshotCardName()) else if (card == Z80_GetSnapshotCardName())
{ {
@ -296,7 +296,7 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion)
{ {
type = CT_Disk2; type = CT_Disk2;
g_CardMgr.Insert(slot, type); g_CardMgr.Insert(slot, type);
bRes = dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(slot))->LoadSnapshot(yamlLoadHelper, slot, cardVersion); bRes = dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(slot)).LoadSnapshot(yamlLoadHelper, slot, cardVersion);
} }
else if (card == HD_GetSnapshotCardName()) else if (card == HD_GetSnapshotCardName())
{ {
@ -532,13 +532,13 @@ void Snapshot_SaveState(void)
Printer_SaveSnapshot(yamlSaveHelper); Printer_SaveSnapshot(yamlSaveHelper);
if (g_CardMgr.QuerySlot(SLOT2) == CT_SSC) if (g_CardMgr.QuerySlot(SLOT2) == CT_SSC)
dynamic_cast<CSuperSerialCard*>(g_CardMgr.GetObj(SLOT2))->SaveSnapshot(yamlSaveHelper); dynamic_cast<CSuperSerialCard&>(g_CardMgr.GetRef(SLOT2)).SaveSnapshot(yamlSaveHelper);
// if (g_CardMgr.QuerySlot(SLOT3) == CT_Uthernet) // if (g_CardMgr.QuerySlot(SLOT3) == CT_Uthernet)
// sg_Uthernet.SaveSnapshot(yamlSaveHelper); // sg_Uthernet.SaveSnapshot(yamlSaveHelper);
if (g_CardMgr.QuerySlot(SLOT4) == CT_MouseInterface) if (g_CardMgr.QuerySlot(SLOT4) == CT_MouseInterface)
dynamic_cast<CMouseInterface*>(g_CardMgr.GetObj(SLOT4))->SaveSnapshot(yamlSaveHelper); dynamic_cast<CMouseInterface&>(g_CardMgr.GetRef(SLOT4)).SaveSnapshot(yamlSaveHelper);
if (g_CardMgr.QuerySlot(SLOT4) == CT_Z80) if (g_CardMgr.QuerySlot(SLOT4) == CT_Z80)
Z80_SaveSnapshot(yamlSaveHelper, SLOT4); Z80_SaveSnapshot(yamlSaveHelper, SLOT4);
@ -556,10 +556,10 @@ void Snapshot_SaveState(void)
Phasor_SaveSnapshot(yamlSaveHelper, SLOT4); Phasor_SaveSnapshot(yamlSaveHelper, SLOT4);
if (g_CardMgr.QuerySlot(SLOT5) == CT_Disk2) if (g_CardMgr.QuerySlot(SLOT5) == CT_Disk2)
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT5))->SaveSnapshot(yamlSaveHelper); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT5)).SaveSnapshot(yamlSaveHelper);
if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2) if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6))->SaveSnapshot(yamlSaveHelper); dynamic_cast<Disk2InterfaceCard&>(g_CardMgr.GetRef(SLOT6)).SaveSnapshot(yamlSaveHelper);
if (g_CardMgr.QuerySlot(SLOT7) == CT_GenericHDD) if (g_CardMgr.QuerySlot(SLOT7) == CT_GenericHDD)
HD_SaveSnapshot(yamlSaveHelper); HD_SaveSnapshot(yamlSaveHelper);

View file

@ -31,6 +31,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <stdexcept>
#include <cstdarg> #include <cstdarg>
#include "linux/win.h" #include "linux/win.h"

View file

@ -239,7 +239,7 @@ int GH445_test_jmp(BYTE op)
const WORD target16 = 0x1234; const WORD target16 = 0x1234;
int target0, target1, target2; int target0=0, target1=0, target2=0;
if (op == OPCODE_JMP_A) if (op == OPCODE_JMP_A)
{ {
target0 = NO_6502_TARGET; target0 = NO_6502_TARGET;
@ -262,6 +262,10 @@ int GH445_test_jmp(BYTE op)
mem[target0] = target2 & 0xff; mem[target0] = target2 & 0xff;
mem[target1] = (target2>>8) & 0xff; mem[target1] = (target2>>8) & 0xff;
} }
else
{
_ASSERT(0);
}
mem[regs.pc] = op; mem[regs.pc] = op;
mem[(regs.pc+1)&0xFFFF] = (BYTE) (target16&0xff); mem[(regs.pc+1)&0xFFFF] = (BYTE) (target16&0xff);
@ -542,7 +546,7 @@ int GH451_test_jmp(BYTE op)
const WORD target16 = 0x1234; const WORD target16 = 0x1234;
int target0, target1; int target0=0, target1=0;
if (op == OPCODE_JMP_A) if (op == OPCODE_JMP_A)
{ {
target0 = NO_6502_TARGET; target0 = NO_6502_TARGET;
@ -558,6 +562,10 @@ int GH451_test_jmp(BYTE op)
target0 = (target16+regs.x)&0xffff; target0 = (target16+regs.x)&0xffff;
target1 = (target16+regs.x+1)&0xffff; target1 = (target16+regs.x+1)&0xffff;
} }
else
{
_ASSERT(0);
}
mem[regs.pc] = op; mem[regs.pc] = op;
mem[(regs.pc+1)&0xFFFF] = (BYTE) (target16&0xff); mem[(regs.pc+1)&0xFFFF] = (BYTE) (target16&0xff);