2020-11-26 21:50:06 +00:00
|
|
|
/*AppleWin : An Apple //e emulator for Windows
|
|
|
|
|
|
|
|
Copyright (C) 1994-1996, Michael O'Brien
|
|
|
|
Copyright (C) 1999-2001, Oliver Schmidt
|
|
|
|
Copyright (C) 2002-2005, Tom Charlesworth
|
|
|
|
Copyright (C) 2006-2014, Tom Charlesworth, Michael Pohoreski
|
|
|
|
|
|
|
|
AppleWin is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
AppleWin is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with AppleWin; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Description: main
|
|
|
|
*
|
|
|
|
* Author: Various
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
|
|
|
#include "Utilities.h"
|
|
|
|
#include "Core.h"
|
|
|
|
#include "CardManager.h"
|
|
|
|
#include "CPU.h"
|
|
|
|
#include "Joystick.h"
|
|
|
|
#include "Log.h"
|
|
|
|
#include "Mockingboard.h"
|
|
|
|
#include "MouseInterface.h"
|
|
|
|
#include "ParallelPrinter.h"
|
|
|
|
#include "Registry.h"
|
|
|
|
#include "Riff.h"
|
|
|
|
#include "SaveState.h"
|
|
|
|
#include "SerialComms.h"
|
|
|
|
#include "Speaker.h"
|
2020-11-29 21:11:05 +00:00
|
|
|
#include "Memory.h"
|
|
|
|
#include "Pravets.h"
|
|
|
|
#include "Keyboard.h"
|
2020-11-26 21:50:06 +00:00
|
|
|
#include "Mockingboard.h"
|
2020-11-29 17:30:06 +00:00
|
|
|
#include "Interface.h"
|
2020-11-29 21:11:05 +00:00
|
|
|
#include "SoundCore.h"
|
2020-11-26 21:50:06 +00:00
|
|
|
|
2020-11-27 20:57:35 +00:00
|
|
|
#include "Configuration/IPropertySheet.h"
|
2022-02-27 17:26:48 +00:00
|
|
|
#include "Tfe/PCapBackend.h"
|
2020-11-26 21:50:06 +00:00
|
|
|
|
2020-11-29 21:11:05 +00:00
|
|
|
#ifdef USE_SPEECH_API
|
|
|
|
#include "Speech.h"
|
|
|
|
#endif
|
|
|
|
|
2020-11-26 21:50:06 +00:00
|
|
|
// Backwards compatibility with AppleWin <1.24.0
|
|
|
|
static void LoadConfigOldJoystick_v1(const UINT uJoyNum)
|
|
|
|
{
|
|
|
|
DWORD dwOldJoyType;
|
|
|
|
if (!REGLOAD(TEXT(uJoyNum==0 ? REGVALUE_OLD_JOYSTICK0_EMU_TYPE1 : REGVALUE_OLD_JOYSTICK1_EMU_TYPE1), &dwOldJoyType))
|
|
|
|
return; // EG. Old AppleWin never installed
|
|
|
|
|
|
|
|
UINT uNewJoyType;
|
|
|
|
switch (dwOldJoyType)
|
|
|
|
{
|
|
|
|
case 0: // Disabled
|
|
|
|
default:
|
|
|
|
uNewJoyType = J0C_DISABLED;
|
|
|
|
break;
|
|
|
|
case 1: // PC Joystick
|
|
|
|
uNewJoyType = J0C_JOYSTICK1;
|
|
|
|
break;
|
|
|
|
case 2: // Keyboard (standard)
|
|
|
|
uNewJoyType = J0C_KEYBD_NUMPAD;
|
2020-12-20 15:32:51 +00:00
|
|
|
GetPropertySheet().SetJoystickCenteringControl(JOYSTICK_MODE_FLOATING);
|
2020-11-26 21:50:06 +00:00
|
|
|
break;
|
|
|
|
case 3: // Keyboard (centering)
|
|
|
|
uNewJoyType = J0C_KEYBD_NUMPAD;
|
2020-12-20 15:32:51 +00:00
|
|
|
GetPropertySheet().SetJoystickCenteringControl(JOYSTICK_MODE_CENTERING);
|
2020-11-26 21:50:06 +00:00
|
|
|
break;
|
|
|
|
case 4: // Mouse
|
|
|
|
uNewJoyType = J0C_MOUSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
JoySetJoyType(uJoyNum, uNewJoyType);
|
|
|
|
}
|
|
|
|
|
2021-12-11 17:57:35 +00:00
|
|
|
// Reads configuration from the registry entries
|
|
|
|
//
|
|
|
|
// NB. loadImages=false if loading a save-state from cmd-line afterwards
|
|
|
|
// - Registry images may have been deleted from disk, so avoid the MessageBox
|
|
|
|
void LoadConfiguration(bool loadImages)
|
2020-11-26 21:50:06 +00:00
|
|
|
{
|
|
|
|
DWORD dwComputerType = 0;
|
|
|
|
eApple2Type apple2Type = A2TYPE_APPLE2EENHANCED;
|
|
|
|
|
|
|
|
if (REGLOAD(TEXT(REGVALUE_APPLE2_TYPE), &dwComputerType))
|
|
|
|
{
|
|
|
|
const DWORD dwLoadedComputerType = dwComputerType;
|
|
|
|
|
|
|
|
if ( (dwComputerType >= A2TYPE_MAX) ||
|
|
|
|
(dwComputerType >= A2TYPE_UNDEFINED && dwComputerType < A2TYPE_CLONE) ||
|
|
|
|
(dwComputerType >= A2TYPE_CLONE_A2_MAX && dwComputerType < A2TYPE_CLONE_A2E) )
|
|
|
|
dwComputerType = A2TYPE_APPLE2EENHANCED;
|
|
|
|
|
|
|
|
// Remap the bad Pravets models (before AppleWin v1.26)
|
|
|
|
if (dwComputerType == A2TYPE_BAD_PRAVETS82) dwComputerType = A2TYPE_PRAVETS82;
|
|
|
|
if (dwComputerType == A2TYPE_BAD_PRAVETS8M) dwComputerType = A2TYPE_PRAVETS8M;
|
|
|
|
|
|
|
|
// Remap the bad Pravets models (at AppleWin v1.26) - GH#415
|
|
|
|
if (dwComputerType == A2TYPE_CLONE) dwComputerType = A2TYPE_PRAVETS82;
|
|
|
|
|
|
|
|
if (dwLoadedComputerType != dwComputerType)
|
|
|
|
{
|
2022-02-15 18:48:20 +00:00
|
|
|
std::string strText = StrFormat("Unsupported Apple2Type(%d). Changing to %d", dwLoadedComputerType, dwComputerType);
|
2020-11-26 21:50:06 +00:00
|
|
|
|
2022-02-15 18:48:20 +00:00
|
|
|
LogFileOutput("%s\n", strText.c_str());
|
2020-11-26 21:50:06 +00:00
|
|
|
|
2022-02-15 18:48:20 +00:00
|
|
|
GetFrame().FrameMessageBox(strText.c_str(),
|
|
|
|
"Load Configuration",
|
|
|
|
MB_ICONSTOP | MB_SETFOREGROUND);
|
2020-11-26 21:50:06 +00:00
|
|
|
|
2020-12-20 15:32:51 +00:00
|
|
|
GetPropertySheet().ConfigSaveApple2Type((eApple2Type)dwComputerType);
|
2020-11-26 21:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
apple2Type = (eApple2Type) dwComputerType;
|
|
|
|
}
|
|
|
|
else if (REGLOAD(TEXT(REGVALUE_OLD_APPLE2_TYPE), &dwComputerType)) // Support older AppleWin registry entries
|
|
|
|
{
|
|
|
|
switch (dwComputerType)
|
|
|
|
{
|
|
|
|
// NB. No A2TYPE_APPLE2E (this is correct)
|
|
|
|
case 0: apple2Type = A2TYPE_APPLE2; break;
|
|
|
|
case 1: apple2Type = A2TYPE_APPLE2PLUS; break;
|
|
|
|
case 2: apple2Type = A2TYPE_APPLE2EENHANCED; break;
|
|
|
|
default: apple2Type = A2TYPE_APPLE2EENHANCED; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetApple2Type(apple2Type);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
DWORD dwMainCpuType;
|
|
|
|
REGLOAD_DEFAULT(TEXT(REGVALUE_CPU_TYPE), &dwMainCpuType, CPU_65C02);
|
|
|
|
if (dwMainCpuType != CPU_6502 && dwMainCpuType != CPU_65C02)
|
|
|
|
dwMainCpuType = CPU_65C02;
|
|
|
|
SetMainCpu((eCpuType)dwMainCpuType);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
DWORD dwJoyType;
|
|
|
|
if (REGLOAD(TEXT(REGVALUE_JOYSTICK0_EMU_TYPE), &dwJoyType))
|
|
|
|
JoySetJoyType(JN_JOYSTICK0, dwJoyType);
|
|
|
|
else if (REGLOAD(TEXT(REGVALUE_OLD_JOYSTICK0_EMU_TYPE2), &dwJoyType)) // GH#434
|
|
|
|
JoySetJoyType(JN_JOYSTICK0, dwJoyType);
|
|
|
|
else
|
|
|
|
LoadConfigOldJoystick_v1(JN_JOYSTICK0);
|
|
|
|
|
|
|
|
if (REGLOAD(TEXT(REGVALUE_JOYSTICK1_EMU_TYPE), &dwJoyType))
|
|
|
|
JoySetJoyType(JN_JOYSTICK1, dwJoyType);
|
|
|
|
else if (REGLOAD(TEXT(REGVALUE_OLD_JOYSTICK1_EMU_TYPE2), &dwJoyType)) // GH#434
|
|
|
|
JoySetJoyType(JN_JOYSTICK1, dwJoyType);
|
|
|
|
else
|
|
|
|
LoadConfigOldJoystick_v1(JN_JOYSTICK1);
|
|
|
|
|
|
|
|
DWORD dwSoundType;
|
|
|
|
REGLOAD_DEFAULT(TEXT(REGVALUE_SOUND_EMULATION), &dwSoundType, REG_SOUNDTYPE_WAVE);
|
|
|
|
switch (dwSoundType)
|
|
|
|
{
|
|
|
|
case REG_SOUNDTYPE_NONE:
|
|
|
|
case REG_SOUNDTYPE_DIRECT: // Not supported from 1.26
|
|
|
|
case REG_SOUNDTYPE_SMART: // Not supported from 1.26
|
|
|
|
default:
|
|
|
|
soundtype = SOUND_NONE;
|
|
|
|
break;
|
|
|
|
case REG_SOUNDTYPE_WAVE:
|
|
|
|
soundtype = SOUND_WAVE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
REGLOAD_DEFAULT(TEXT(REGVALUE_EMULATION_SPEED), &g_dwSpeed, SPEED_NORMAL);
|
2020-12-28 16:25:29 +00:00
|
|
|
GetVideo().Config_Load_Video();
|
2020-11-26 21:50:06 +00:00
|
|
|
SetCurrentCLK6502(); // Pre: g_dwSpeed && Config_Load_Video()->SetVideoRefreshRate()
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
DWORD dwTmp = 0;
|
|
|
|
|
|
|
|
if(REGLOAD(TEXT(REGVALUE_FS_SHOW_SUBUNIT_STATUS), &dwTmp))
|
2020-12-24 15:08:50 +00:00
|
|
|
GetFrame().SetFullScreenShowSubunitStatus(dwTmp ? true : false);
|
2020-11-26 21:50:06 +00:00
|
|
|
|
|
|
|
if(REGLOAD(TEXT(REGVALUE_THE_FREEZES_F8_ROM), &dwTmp))
|
2020-12-20 15:32:51 +00:00
|
|
|
GetPropertySheet().SetTheFreezesF8Rom(dwTmp);
|
2020-11-26 21:50:06 +00:00
|
|
|
|
|
|
|
if(REGLOAD(TEXT(REGVALUE_SPKR_VOLUME), &dwTmp))
|
2020-12-20 15:32:51 +00:00
|
|
|
SpkrSetVolume(dwTmp, GetPropertySheet().GetVolumeMax());
|
2020-11-26 21:50:06 +00:00
|
|
|
|
|
|
|
if(REGLOAD(TEXT(REGVALUE_MB_VOLUME), &dwTmp))
|
2020-12-20 15:32:51 +00:00
|
|
|
MB_SetVolume(dwTmp, GetPropertySheet().GetVolumeMax());
|
2020-11-26 21:50:06 +00:00
|
|
|
|
|
|
|
if(REGLOAD(TEXT(REGVALUE_SAVE_STATE_ON_EXIT), &dwTmp))
|
|
|
|
g_bSaveStateOnExit = dwTmp ? true : false;
|
|
|
|
|
|
|
|
if(REGLOAD(TEXT(REGVALUE_PDL_XTRIM), &dwTmp))
|
|
|
|
JoySetTrim((short)dwTmp, true);
|
|
|
|
if(REGLOAD(TEXT(REGVALUE_PDL_YTRIM), &dwTmp))
|
|
|
|
JoySetTrim((short)dwTmp, false);
|
|
|
|
|
|
|
|
if(REGLOAD(TEXT(REGVALUE_SCROLLLOCK_TOGGLE), &dwTmp))
|
2020-12-20 15:32:51 +00:00
|
|
|
GetPropertySheet().SetScrollLockToggle(dwTmp);
|
2020-11-26 21:50:06 +00:00
|
|
|
|
|
|
|
if(REGLOAD(TEXT(REGVALUE_CURSOR_CONTROL), &dwTmp))
|
2020-12-20 15:32:51 +00:00
|
|
|
GetPropertySheet().SetJoystickCursorControl(dwTmp);
|
2020-11-26 21:50:06 +00:00
|
|
|
if(REGLOAD(TEXT(REGVALUE_AUTOFIRE), &dwTmp))
|
2020-12-20 15:32:51 +00:00
|
|
|
GetPropertySheet().SetAutofire(dwTmp);
|
2020-11-26 21:50:06 +00:00
|
|
|
if(REGLOAD(TEXT(REGVALUE_SWAP_BUTTONS_0_AND_1), &dwTmp))
|
2020-12-20 15:32:51 +00:00
|
|
|
GetPropertySheet().SetButtonsSwapState(dwTmp ? true : false);
|
2020-11-26 21:50:06 +00:00
|
|
|
if(REGLOAD(TEXT(REGVALUE_CENTERING_CONTROL), &dwTmp))
|
2020-12-20 15:32:51 +00:00
|
|
|
GetPropertySheet().SetJoystickCenteringControl(dwTmp);
|
2020-11-26 21:50:06 +00:00
|
|
|
|
|
|
|
if(REGLOAD(TEXT(REGVALUE_MOUSE_CROSSHAIR), &dwTmp))
|
2020-12-20 15:32:51 +00:00
|
|
|
GetPropertySheet().SetMouseShowCrosshair(dwTmp);
|
2020-11-26 21:50:06 +00:00
|
|
|
if(REGLOAD(TEXT(REGVALUE_MOUSE_RESTRICT_TO_WINDOW), &dwTmp))
|
2020-12-20 15:32:51 +00:00
|
|
|
GetPropertySheet().SetMouseRestrictToWindow(dwTmp);
|
2020-11-26 21:50:06 +00:00
|
|
|
|
2021-09-10 12:57:55 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
TCHAR szFilename[MAX_PATH];
|
|
|
|
|
|
|
|
//
|
|
|
|
|
2021-08-29 10:39:51 +00:00
|
|
|
for (UINT slot = SLOT0; slot <= SLOT7; slot++)
|
|
|
|
{
|
2022-02-16 20:14:40 +00:00
|
|
|
std::string regSection = RegGetConfigSlotSection(slot);
|
2021-08-29 10:39:51 +00:00
|
|
|
|
|
|
|
if (RegLoadValue(regSection.c_str(), REGVALUE_CARD_TYPE, TRUE, &dwTmp))
|
|
|
|
{
|
2021-09-10 12:57:55 +00:00
|
|
|
if (slot == SLOT3)
|
|
|
|
{
|
2022-02-27 17:26:48 +00:00
|
|
|
// this must happen before the card is instantitated
|
|
|
|
// TODO move to the card
|
|
|
|
if ((SS_CARDTYPE)dwTmp == CT_Uthernet || (SS_CARDTYPE)dwTmp == CT_Uthernet2) // TODO: move this to when UthernetCard object is instantiated
|
2021-09-10 12:57:55 +00:00
|
|
|
{
|
2022-02-16 20:14:40 +00:00
|
|
|
std::string regSection = RegGetConfigSlotSection(slot);
|
2021-09-10 12:57:55 +00:00
|
|
|
if (RegLoadString(regSection.c_str(), REGVALUE_UTHERNET_INTERFACE, TRUE, szFilename, MAX_PATH, TEXT("")))
|
2022-02-27 17:26:48 +00:00
|
|
|
PCapBackend::tfe_interface = szFilename;
|
2021-09-10 12:57:55 +00:00
|
|
|
}
|
|
|
|
}
|
2022-02-27 17:26:48 +00:00
|
|
|
|
|
|
|
GetCardMgr().Insert(slot, (SS_CARDTYPE)dwTmp, false);
|
2021-08-29 10:39:51 +00:00
|
|
|
}
|
|
|
|
else // legacy (AppleWin 1.30.3 or earlier)
|
|
|
|
{
|
2021-09-10 12:57:55 +00:00
|
|
|
if (slot == SLOT3)
|
|
|
|
{
|
|
|
|
// TODO: move this to when UthernetCard object is instantiated
|
|
|
|
RegLoadString(TEXT(REG_CONFIG), TEXT(REGVALUE_UTHERNET_INTERFACE), 1, szFilename, MAX_PATH, TEXT(""));
|
2022-02-27 17:26:48 +00:00
|
|
|
PCapBackend::tfe_interface = szFilename;
|
2021-09-21 20:32:14 +00:00
|
|
|
|
2022-02-27 17:26:48 +00:00
|
|
|
DWORD tfeEnabled;
|
|
|
|
REGLOAD_DEFAULT(TEXT(REGVALUE_UTHERNET_ACTIVE), &tfeEnabled, 0);
|
|
|
|
GetCardMgr().Insert(SLOT3, tfeEnabled ? CT_Uthernet : CT_Empty);
|
2021-09-10 12:57:55 +00:00
|
|
|
}
|
|
|
|
else if (slot == SLOT4 && REGLOAD(TEXT(REGVALUE_SLOT4), &dwTmp))
|
2021-08-29 10:39:51 +00:00
|
|
|
GetCardMgr().Insert(SLOT4, (SS_CARDTYPE)dwTmp);
|
|
|
|
else if (slot == SLOT5 && REGLOAD(TEXT(REGVALUE_SLOT5), &dwTmp))
|
|
|
|
GetCardMgr().Insert(SLOT5, (SS_CARDTYPE)dwTmp);
|
2022-01-04 20:19:21 +00:00
|
|
|
else if (slot == SLOT7 && REGLOAD(TEXT(REGVALUE_HDD_ENABLED), &dwTmp) && dwTmp == 1) // GH#1015
|
|
|
|
GetCardMgr().Insert(SLOT7, CT_GenericHDD);
|
2021-08-29 10:39:51 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-26 21:50:06 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Load save-state pathname *before* inserting any harddisk/disk images (for both init & reinit cases)
|
|
|
|
// NB. inserting harddisk/disk can change snapshot pathname
|
|
|
|
RegLoadString(TEXT(REG_CONFIG), TEXT(REGVALUE_SAVESTATE_FILENAME), 1, szFilename, MAX_PATH, TEXT("")); // Can be pathname or just filename
|
|
|
|
Snapshot_SetFilename(szFilename); // If not in Registry than default will be used (ie. g_sCurrentDir + default filename)
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
RegLoadString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_HDV_START_DIR), 1, szFilename, MAX_PATH, TEXT(""));
|
|
|
|
if (szFilename[0] == '\0')
|
|
|
|
GetCurrentDirectory(sizeof(szFilename), szFilename);
|
|
|
|
SetCurrentImageDir(szFilename);
|
|
|
|
|
2021-12-11 17:57:35 +00:00
|
|
|
if (loadImages && GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
|
2021-11-01 20:12:42 +00:00
|
|
|
{
|
|
|
|
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).LoadLastDiskImage(HARDDISK_1);
|
|
|
|
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).LoadLastDiskImage(HARDDISK_2);
|
|
|
|
}
|
2020-11-26 21:50:06 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Current/Starting Dir is the "root" of where the user keeps their disk images
|
|
|
|
RegLoadString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_START_DIR), 1, szFilename, MAX_PATH, TEXT(""));
|
|
|
|
if (szFilename[0] == '\0')
|
|
|
|
GetCurrentDirectory(sizeof(szFilename), szFilename);
|
|
|
|
SetCurrentImageDir(szFilename);
|
|
|
|
|
2021-12-11 17:57:35 +00:00
|
|
|
if (loadImages)
|
|
|
|
GetCardMgr().GetDisk2CardMgr().LoadLastDiskImage();
|
2020-11-26 21:50:06 +00:00
|
|
|
|
2021-09-10 13:27:22 +00:00
|
|
|
// Do this after populating the slots with Disk II controller(s)
|
|
|
|
DWORD dwEnhanceDisk;
|
|
|
|
REGLOAD_DEFAULT(TEXT(REGVALUE_ENHANCE_DISK_SPEED), &dwEnhanceDisk, 1);
|
|
|
|
GetCardMgr().GetDisk2CardMgr().SetEnhanceDisk(dwEnhanceDisk ? true : false);
|
|
|
|
|
2020-11-26 21:50:06 +00:00
|
|
|
//
|
|
|
|
|
2022-03-18 22:04:34 +00:00
|
|
|
if (GetCardMgr().IsParallelPrinterCardInstalled())
|
|
|
|
GetCardMgr().GetParallelPrinterCard()->GetRegistryConfig();
|
2020-11-26 21:50:06 +00:00
|
|
|
|
2022-03-18 22:04:34 +00:00
|
|
|
//
|
2020-11-26 21:50:06 +00:00
|
|
|
|
|
|
|
if (REGLOAD(TEXT(REGVALUE_WINDOW_SCALE), &dwTmp))
|
2020-12-24 15:08:50 +00:00
|
|
|
GetFrame().SetViewportScale(dwTmp);
|
2020-11-26 21:50:06 +00:00
|
|
|
|
|
|
|
if (REGLOAD(TEXT(REGVALUE_CONFIRM_REBOOT), &dwTmp))
|
2020-12-24 15:08:50 +00:00
|
|
|
GetFrame().g_bConfirmReboot = dwTmp;
|
2020-11-26 21:50:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static std::string GetFullPath(LPCSTR szFileName)
|
|
|
|
{
|
|
|
|
std::string strPathName;
|
|
|
|
|
2021-05-19 20:10:22 +00:00
|
|
|
if (szFileName[0] == PATH_SEPARATOR || szFileName[1] == ':')
|
2020-11-26 21:50:06 +00:00
|
|
|
{
|
|
|
|
// Abs pathname
|
|
|
|
strPathName = szFileName;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Rel pathname (GH#663)
|
|
|
|
strPathName = g_sStartDir;
|
|
|
|
strPathName.append(szFileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return strPathName;
|
|
|
|
}
|
|
|
|
|
2021-07-25 10:55:25 +00:00
|
|
|
static void SetCurrentDir(const std::string & pathname)
|
2020-11-26 21:50:06 +00:00
|
|
|
{
|
|
|
|
// Due to the order HDDs/disks are inserted, then s7 insertions take priority over s6 & s5; and d2 takes priority over d1:
|
|
|
|
// . if -s6[dN] and -hN are specified, then g_sCurrentDir will be set to the HDD image's path
|
|
|
|
// . if -s5[dN] and -s6[dN] are specified, then g_sCurrentDir will be set to the s6 image's path
|
|
|
|
// . if -[sN]d1 and -[sN]d2 are specified, then g_sCurrentDir will be set to the d2 image's path
|
|
|
|
// This is purely dependent on the current order of InsertFloppyDisks() & InsertHardDisks() - ie. very brittle!
|
|
|
|
// . better to use -current-dir to be explicit
|
2021-05-19 20:10:22 +00:00
|
|
|
std::size_t found = pathname.find_last_of(PATH_SEPARATOR);
|
2020-11-26 21:50:06 +00:00
|
|
|
std::string path = pathname.substr(0, found);
|
|
|
|
SetCurrentImageDir(path);
|
|
|
|
}
|
|
|
|
|
2021-07-11 11:06:29 +00:00
|
|
|
static bool DoDiskInsert(const UINT slot, const int nDrive, LPCSTR szFileName)
|
2020-11-26 21:50:06 +00:00
|
|
|
{
|
|
|
|
Disk2InterfaceCard& disk2Card = dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(slot));
|
|
|
|
|
|
|
|
if (szFileName[0] == '\0')
|
|
|
|
{
|
|
|
|
disk2Card.EjectDisk(nDrive);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string strPathName = GetFullPath(szFileName);
|
|
|
|
if (strPathName.empty()) return false;
|
|
|
|
|
2021-07-25 10:55:25 +00:00
|
|
|
ImageError_e Error = disk2Card.InsertDisk(nDrive, strPathName, IMAGE_USE_FILES_WRITE_PROTECT_STATUS, IMAGE_DONT_CREATE);
|
2020-11-26 21:50:06 +00:00
|
|
|
bool res = (Error == eIMAGE_ERROR_NONE);
|
|
|
|
if (res)
|
|
|
|
SetCurrentDir(strPathName);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2021-07-11 11:06:29 +00:00
|
|
|
static bool DoHardDiskInsert(const int nDrive, LPCSTR szFileName)
|
2020-11-26 21:50:06 +00:00
|
|
|
{
|
2021-11-01 20:12:42 +00:00
|
|
|
_ASSERT(GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD);
|
|
|
|
if (GetCardMgr().QuerySlot(SLOT7) != CT_GenericHDD)
|
|
|
|
return false;
|
|
|
|
|
2020-11-26 21:50:06 +00:00
|
|
|
if (szFileName[0] == '\0')
|
|
|
|
{
|
2021-11-01 20:12:42 +00:00
|
|
|
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).Unplug(nDrive);
|
2020-11-26 21:50:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string strPathName = GetFullPath(szFileName);
|
|
|
|
if (strPathName.empty()) return false;
|
|
|
|
|
2021-11-01 20:12:42 +00:00
|
|
|
BOOL bRes = dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).Insert(nDrive, strPathName);
|
2020-11-26 21:50:06 +00:00
|
|
|
bool res = (bRes == TRUE);
|
|
|
|
if (res)
|
|
|
|
SetCurrentDir(strPathName);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2021-07-25 10:55:25 +00:00
|
|
|
void InsertFloppyDisks(const UINT slot, LPCSTR szImageName_drive[NUM_DRIVES], bool driveConnected[NUM_DRIVES], bool& bBoot)
|
2020-11-26 21:50:06 +00:00
|
|
|
{
|
|
|
|
_ASSERT(slot == 5 || slot == 6);
|
|
|
|
|
|
|
|
bool bRes = true;
|
|
|
|
|
2020-12-12 20:49:46 +00:00
|
|
|
if (!driveConnected[DRIVE_1])
|
|
|
|
{
|
|
|
|
dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(slot)).UnplugDrive(DRIVE_1);
|
|
|
|
}
|
|
|
|
else if (szImageName_drive[DRIVE_1])
|
2020-11-26 21:50:06 +00:00
|
|
|
{
|
|
|
|
bRes = DoDiskInsert(slot, DRIVE_1, szImageName_drive[DRIVE_1]);
|
|
|
|
LogFileOutput("Init: S%d, DoDiskInsert(D1), res=%d\n", slot, bRes);
|
2021-01-10 16:33:06 +00:00
|
|
|
GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS); // floppy activity LEDs and floppy buttons
|
2020-11-26 21:50:06 +00:00
|
|
|
bBoot = true;
|
|
|
|
}
|
|
|
|
|
2020-12-12 20:49:46 +00:00
|
|
|
if (!driveConnected[DRIVE_2])
|
|
|
|
{
|
|
|
|
dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(slot)).UnplugDrive(DRIVE_2);
|
|
|
|
}
|
|
|
|
else if (szImageName_drive[DRIVE_2])
|
2020-11-26 21:50:06 +00:00
|
|
|
{
|
2021-09-10 13:38:40 +00:00
|
|
|
bRes &= DoDiskInsert(slot, DRIVE_2, szImageName_drive[DRIVE_2]);
|
2020-11-26 21:50:06 +00:00
|
|
|
LogFileOutput("Init: S%d, DoDiskInsert(D2), res=%d\n", slot, bRes);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bRes)
|
2021-01-19 20:37:43 +00:00
|
|
|
GetFrame().FrameMessageBox("Failed to insert floppy disk(s) - see log file", "Warning", MB_ICONASTERISK | MB_OK);
|
2020-11-26 21:50:06 +00:00
|
|
|
}
|
|
|
|
|
2021-07-25 10:55:25 +00:00
|
|
|
void InsertHardDisks(LPCSTR szImageName_harddisk[NUM_HARDDISKS], bool& bBoot)
|
2020-11-26 21:50:06 +00:00
|
|
|
{
|
|
|
|
if (!szImageName_harddisk[HARDDISK_1] && !szImageName_harddisk[HARDDISK_2])
|
|
|
|
return;
|
|
|
|
|
2021-11-01 20:12:42 +00:00
|
|
|
if (GetCardMgr().QuerySlot(SLOT7) != CT_GenericHDD)
|
|
|
|
GetCardMgr().Insert(SLOT7, CT_GenericHDD); // Enable the Harddisk controller card
|
2020-11-26 21:50:06 +00:00
|
|
|
|
|
|
|
bool bRes = true;
|
|
|
|
|
|
|
|
if (szImageName_harddisk[HARDDISK_1])
|
|
|
|
{
|
|
|
|
bRes = DoHardDiskInsert(HARDDISK_1, szImageName_harddisk[HARDDISK_1]);
|
|
|
|
LogFileOutput("Init: DoHardDiskInsert(HDD1), res=%d\n", bRes);
|
2021-01-10 16:33:06 +00:00
|
|
|
GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_DISK_STATUS); // harddisk activity LED
|
2020-11-26 21:50:06 +00:00
|
|
|
bBoot = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (szImageName_harddisk[HARDDISK_2])
|
|
|
|
{
|
2021-09-10 13:38:40 +00:00
|
|
|
bRes &= DoHardDiskInsert(HARDDISK_2, szImageName_harddisk[HARDDISK_2]);
|
2020-11-26 21:50:06 +00:00
|
|
|
LogFileOutput("Init: DoHardDiskInsert(HDD2), res=%d\n", bRes);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bRes)
|
2021-01-19 20:37:43 +00:00
|
|
|
GetFrame().FrameMessageBox("Failed to insert harddisk(s) - see log file", "Warning", MB_ICONASTERISK | MB_OK);
|
2020-11-26 21:50:06 +00:00
|
|
|
}
|
|
|
|
|
2020-11-28 15:49:19 +00:00
|
|
|
void GetAppleWindowTitle()
|
|
|
|
{
|
|
|
|
switch (g_Apple2Type)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case A2TYPE_APPLE2: g_pAppTitle = TITLE_APPLE_2; break;
|
|
|
|
case A2TYPE_APPLE2PLUS: g_pAppTitle = TITLE_APPLE_2_PLUS; break;
|
|
|
|
case A2TYPE_APPLE2JPLUS: g_pAppTitle = TITLE_APPLE_2_JPLUS; break;
|
|
|
|
case A2TYPE_APPLE2E: g_pAppTitle = TITLE_APPLE_2E; break;
|
|
|
|
case A2TYPE_APPLE2EENHANCED: g_pAppTitle = TITLE_APPLE_2E_ENHANCED; break;
|
|
|
|
case A2TYPE_PRAVETS82: g_pAppTitle = TITLE_PRAVETS_82; break;
|
|
|
|
case A2TYPE_PRAVETS8M: g_pAppTitle = TITLE_PRAVETS_8M; break;
|
|
|
|
case A2TYPE_PRAVETS8A: g_pAppTitle = TITLE_PRAVETS_8A; break;
|
|
|
|
case A2TYPE_TK30002E: g_pAppTitle = TITLE_TK3000_2E; break;
|
|
|
|
case A2TYPE_BASE64A: g_pAppTitle = TITLE_BASE64A; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if _DEBUG
|
|
|
|
g_pAppTitle += " *DEBUG* ";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (g_nAppMode == MODE_LOGO)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_pAppTitle += " - ";
|
|
|
|
|
2020-12-28 16:25:29 +00:00
|
|
|
if (GetVideo().IsVideoStyle(VS_HALF_SCANLINES))
|
2020-11-28 15:49:19 +00:00
|
|
|
g_pAppTitle += " 50% ";
|
|
|
|
|
2020-12-28 16:25:29 +00:00
|
|
|
g_pAppTitle += GetVideo().VideoGetAppWindowTitle();
|
2020-11-28 15:49:19 +00:00
|
|
|
|
|
|
|
if (GetCardMgr().GetDisk2CardMgr().IsAnyFirmware13Sector())
|
|
|
|
g_pAppTitle += " (S6-13) ";
|
|
|
|
|
|
|
|
if (g_hCustomRomF8 != INVALID_HANDLE_VALUE)
|
|
|
|
g_pAppTitle += TEXT(" (custom rom)");
|
2020-12-20 15:32:51 +00:00
|
|
|
else if (GetPropertySheet().GetTheFreezesF8Rom() && IS_APPLE2)
|
2020-11-28 15:49:19 +00:00
|
|
|
g_pAppTitle += TEXT(" (The Freeze's non-autostart F8 rom)");
|
|
|
|
|
|
|
|
switch (g_nAppMode)
|
|
|
|
{
|
|
|
|
case MODE_PAUSED: g_pAppTitle += std::string(TEXT(" [")) + TITLE_PAUSED + TEXT("]"); break;
|
|
|
|
case MODE_STEPPING: g_pAppTitle += std::string(TEXT(" [")) + TITLE_STEPPING + TEXT("]"); break;
|
|
|
|
}
|
|
|
|
}
|
2020-11-29 21:11:05 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
// CtrlReset() vs ResetMachineState():
|
|
|
|
// . CPU:
|
|
|
|
// Ctrl+Reset : 6502.sp=-3 / CpuReset()
|
|
|
|
// Power cycle: 6502.sp=0x1ff / CpuInitialize()
|
|
|
|
// . Disk][:
|
|
|
|
// Ctrl+Reset : if motor-on, then motor-off but continue to spin for 1s
|
|
|
|
// Power cycle: motor-off & immediately stop spinning
|
|
|
|
|
|
|
|
// todo: consolidate CtrlReset() and ResetMachineState()
|
|
|
|
void ResetMachineState()
|
|
|
|
{
|
2022-03-12 10:16:25 +00:00
|
|
|
LogFileOutput("Apple II power-cycle\n");
|
|
|
|
|
2022-03-11 22:17:03 +00:00
|
|
|
GetCardMgr().Reset(true);
|
2020-11-29 21:11:05 +00:00
|
|
|
g_bFullSpeed = 0; // Might've hit reset in middle of InternalCpuExecute() - so beep may get (partially) muted
|
|
|
|
|
|
|
|
MemReset(); // calls CpuInitialize(), CNoSlotClock.Reset()
|
2021-01-17 10:48:06 +00:00
|
|
|
GetPravets().Reset();
|
2020-11-29 21:11:05 +00:00
|
|
|
if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2)
|
|
|
|
dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(SLOT6)).Boot();
|
2020-12-28 16:25:29 +00:00
|
|
|
GetVideo().VideoResetState();
|
2020-11-29 21:11:05 +00:00
|
|
|
KeybReset();
|
|
|
|
JoyReset();
|
2021-02-13 16:56:29 +00:00
|
|
|
MB_Reset(true);
|
2020-11-29 21:11:05 +00:00
|
|
|
SpkrReset();
|
|
|
|
SetActiveCpu(GetMainCpu());
|
|
|
|
#ifdef USE_SPEECH_API
|
|
|
|
g_Speech.Reset();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
SoundCore_SetFade(FADE_NONE);
|
|
|
|
LogFileTimeUntilFirstKeyReadReset();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In comments, UTAII is an abbreviation for a reference to "Understanding the Apple II" by James Sather
|
|
|
|
*/
|
|
|
|
|
|
|
|
// todo: consolidate CtrlReset() and ResetMachineState()
|
|
|
|
void CtrlReset()
|
|
|
|
{
|
|
|
|
if (!IS_APPLE2)
|
|
|
|
{
|
|
|
|
// For A][ & A][+, reset doesn't reset the LC switches (UTAII:5-29)
|
|
|
|
MemResetPaging();
|
|
|
|
|
|
|
|
// For A][ & A][+, reset doesn't reset the video mode (UTAII:4-4)
|
2020-12-28 16:25:29 +00:00
|
|
|
GetVideo().VideoResetState(); // Switch Alternate char set off
|
2020-11-29 21:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (IsAppleIIeOrAbove(GetApple2Type()) || IsCopamBase64A(GetApple2Type()))
|
|
|
|
{
|
|
|
|
// For A][ & A][+, reset doesn't reset the annunciators (UTAIIe:I-5)
|
|
|
|
// Base 64A: on RESET does reset to ROM page 0 (GH#807)
|
|
|
|
MemAnnunciatorReset();
|
|
|
|
}
|
|
|
|
|
2021-01-17 10:48:06 +00:00
|
|
|
GetPravets().Reset();
|
2022-03-11 22:17:03 +00:00
|
|
|
GetCardMgr().Reset(false);
|
2020-11-29 21:11:05 +00:00
|
|
|
KeybReset();
|
2021-02-13 16:56:29 +00:00
|
|
|
MB_Reset(false);
|
2020-11-29 21:11:05 +00:00
|
|
|
#ifdef USE_SPEECH_API
|
|
|
|
g_Speech.Reset();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CpuReset();
|
2020-12-24 15:08:50 +00:00
|
|
|
GetFrame().g_bFreshReset = true;
|
2020-11-29 21:11:05 +00:00
|
|
|
}
|