Make harddisk a class (#995)
. Add user-protection when unchecking HDD controller (as images aren't restored on a 'cancel') . Fix possible crash when removing (via Config->Disk) either Disk2 card(s5) or HDD card(s7), then cancelling during emulation . Fix m_buf[] size
This commit is contained in:
parent
830030ee05
commit
ff7c9dc185
15 changed files with 523 additions and 526 deletions
|
@ -35,6 +35,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
|
||||
#include "Disk.h"
|
||||
#include "FourPlay.h"
|
||||
#include "Harddisk.h"
|
||||
#include "MouseInterface.h"
|
||||
#include "SAM.h"
|
||||
#include "SerialComms.h"
|
||||
|
@ -64,7 +65,7 @@ void CardManager::InsertInternal(UINT slot, SS_CARDTYPE type)
|
|||
m_slot[slot] = new DummyCard(type);
|
||||
break;
|
||||
case CT_GenericHDD:
|
||||
m_slot[slot] = new DummyCard(type);
|
||||
m_slot[slot] = new HarddiskInterfaceCard(slot);
|
||||
break;
|
||||
case CT_GenericClock:
|
||||
m_slot[slot] = new DummyCard(type);
|
||||
|
|
|
@ -34,13 +34,13 @@ public:
|
|||
Card& GetRef(UINT slot)
|
||||
{
|
||||
SS_CARDTYPE t=QuerySlot(slot);
|
||||
_ASSERT((t==CT_SSC || t==CT_MouseInterface || t==CT_Disk2 || t == CT_FourPlay || t == CT_SNESMAX || t == CT_SAM) && m_slot[slot]);
|
||||
_ASSERT((t==CT_GenericHDD || t==CT_SSC || t==CT_MouseInterface || t==CT_Disk2 || t == CT_FourPlay || t == CT_SNESMAX || t == CT_SAM) && m_slot[slot]);
|
||||
return *m_slot[slot];
|
||||
}
|
||||
Card* GetObj(UINT slot)
|
||||
{
|
||||
SS_CARDTYPE t=QuerySlot(slot);
|
||||
_ASSERT(t==CT_SSC || t==CT_MouseInterface || t==CT_Disk2 || t == CT_FourPlay || t == CT_SNESMAX || t == CT_SAM);
|
||||
_ASSERT(t == CT_GenericHDD || t==CT_SSC || t==CT_MouseInterface || t==CT_Disk2 || t == CT_FourPlay || t == CT_SNESMAX || t == CT_SAM);
|
||||
return m_slot[slot];
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ INT_PTR CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARA
|
|||
if (m_PropertySheetHelper.GetConfigOld().m_Slot[SLOT7] != m_PropertySheetHelper.GetConfigNew().m_Slot[SLOT7])
|
||||
{
|
||||
if (m_PropertySheetHelper.GetConfigOld().m_Slot[SLOT7] == CT_GenericHDD || m_PropertySheetHelper.GetConfigNew().m_Slot[SLOT7] == CT_GenericHDD)
|
||||
HD_SetEnabled(m_PropertySheetHelper.GetConfigOld().m_Slot[SLOT7] == CT_GenericHDD);
|
||||
m_PropertySheetHelper.SetSlot(SLOT7, m_PropertySheetHelper.GetConfigOld().m_Slot[SLOT7]);
|
||||
}
|
||||
DlgCANCEL(hWnd);
|
||||
break;
|
||||
|
@ -149,11 +149,20 @@ INT_PTR CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARA
|
|||
case IDC_HDD_ENABLE:
|
||||
{
|
||||
const BOOL checked = IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE) ? TRUE : FALSE;
|
||||
m_PropertySheetHelper.GetConfigNew().m_Slot[SLOT7] = checked ? CT_GenericHDD : CT_Empty;
|
||||
// NB. Unusual as it creates slot object when checkbox is toggled (instead of after OK)
|
||||
// Needed as we need a HarddiskInterfaceCard object so that images can be inserted/ejected [*2]
|
||||
HD_SetEnabled(m_PropertySheetHelper.GetConfigNew().m_Slot[SLOT7] == CT_GenericHDD);
|
||||
EnableHDD(hWnd, checked);
|
||||
// Add some user-protection, as (currently) removing the HDD images can't be undone!
|
||||
if (checked || !checked && GetFrame().FrameMessageBox("This will unplug the HDD image(s)! Proceed?", "Eject/Unplug Warning", MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND) != IDNO)
|
||||
{
|
||||
m_PropertySheetHelper.GetConfigNew().m_Slot[SLOT7] = checked ? CT_GenericHDD : CT_Empty;
|
||||
// NB. Unusual as it creates slot object when checkbox is toggled (instead of after OK)
|
||||
// Needed as we need a HarddiskInterfaceCard object so that images can be inserted/ejected [*2]
|
||||
m_PropertySheetHelper.SetSlot(SLOT7, m_PropertySheetHelper.GetConfigNew().m_Slot[SLOT7]);
|
||||
InitComboHDD(hWnd, SLOT7); // disabling will remove the HDD images - so update drop-down to reflect this
|
||||
EnableHDD(hWnd, checked);
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckDlgButton(hWnd, IDC_HDD_ENABLE, BST_CHECKED);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDC_HDD_SWAP:
|
||||
|
@ -184,7 +193,7 @@ INT_PTR CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARA
|
|||
RegLoadString(TEXT(REG_CONFIG), REGVALUE_CIDERPRESSLOC, 1, PathToCiderPress, MAX_PATH, TEXT(""));
|
||||
SendDlgItemMessage(hWnd, IDC_CIDERPRESS_FILENAME ,WM_SETTEXT, 0, (LPARAM)PathToCiderPress);
|
||||
|
||||
CheckDlgButton(hWnd, IDC_HDD_ENABLE, HD_CardIsEnabled() ? BST_CHECKED : BST_UNCHECKED);
|
||||
CheckDlgButton(hWnd, IDC_HDD_ENABLE, (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD) ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
EnableHDD(hWnd, IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE));
|
||||
|
||||
|
@ -226,15 +235,19 @@ void CPageDisk::InitComboHDD(HWND hWnd, UINT /*slot*/)
|
|||
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_HDD1, m_defaultHDDOptions, -1);
|
||||
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_HDD2, m_defaultHDDOptions, -1);
|
||||
|
||||
if (!HD_GetFullName(HARDDISK_1).empty())
|
||||
if (GetCardMgr().QuerySlot(SLOT7) != CT_GenericHDD)
|
||||
return;
|
||||
HarddiskInterfaceCard& card = dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7));
|
||||
|
||||
if (!card.GetFullName(HARDDISK_1).empty())
|
||||
{
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_HDD1, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(HARDDISK_1).c_str());
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_HDD1, CB_INSERTSTRING, 0, (LPARAM)card.GetFullName(HARDDISK_1).c_str());
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_HDD1, CB_SETCURSEL, 0, 0);
|
||||
}
|
||||
|
||||
if (!HD_GetFullName(HARDDISK_2).empty())
|
||||
if (!card.GetFullName(HARDDISK_2).empty())
|
||||
{
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_HDD2, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(HARDDISK_2).c_str());
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_HDD2, CB_INSERTSTRING, 0, (LPARAM)card.GetFullName(HARDDISK_2).c_str());
|
||||
SendDlgItemMessage(hWnd, IDC_COMBO_HDD2, CB_SETCURSEL, 0, 0);
|
||||
}
|
||||
}
|
||||
|
@ -315,6 +328,11 @@ void CPageDisk::HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelected
|
|||
if (!IsDlgButtonChecked(hWnd, IDC_HDD_ENABLE))
|
||||
return;
|
||||
|
||||
_ASSERT(GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD);
|
||||
if (GetCardMgr().QuerySlot(SLOT7) != CT_GenericHDD)
|
||||
return;
|
||||
HarddiskInterfaceCard& card = dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7));
|
||||
|
||||
// Search from "select hard drive"
|
||||
DWORD dwOpenDialogIndex = (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_FINDSTRINGEXACT, -1, (LPARAM)&m_defaultHDDOptions[0]);
|
||||
DWORD dwComboSelection = (DWORD)SendDlgItemMessage(hWnd, comboSelected, CB_GETCURSEL, 0, 0);
|
||||
|
@ -324,7 +342,7 @@ void CPageDisk::HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelected
|
|||
if (dwComboSelection == dwOpenDialogIndex)
|
||||
{
|
||||
EnableHDD(hWnd, FALSE); // Prevent multiple Selection dialogs to be triggered
|
||||
bool bRes = HD_Select(driveSelected);
|
||||
bool bRes = card.Select(driveSelected);
|
||||
EnableHDD(hWnd, TRUE);
|
||||
|
||||
if (!bRes)
|
||||
|
@ -341,13 +359,13 @@ void CPageDisk::HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelected
|
|||
SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0);
|
||||
}
|
||||
|
||||
SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)HD_GetFullName(driveSelected).c_str());
|
||||
SendDlgItemMessage(hWnd, comboSelected, CB_INSERTSTRING, 0, (LPARAM)card.GetFullName(driveSelected).c_str());
|
||||
SendDlgItemMessage(hWnd, comboSelected, CB_SETCURSEL, 0, 0);
|
||||
|
||||
// If the HD was in the other combo, remove now
|
||||
DWORD comboOther = (comboSelected == IDC_COMBO_HDD1) ? IDC_COMBO_HDD2 : IDC_COMBO_HDD1;
|
||||
|
||||
DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)HD_GetFullName(driveSelected).c_str());
|
||||
DWORD duplicated = (DWORD)SendDlgItemMessage(hWnd, comboOther, CB_FINDSTRINGEXACT, -1, (LPARAM)card.GetFullName(driveSelected).c_str());
|
||||
if (duplicated != CB_ERR)
|
||||
{
|
||||
SendDlgItemMessage(hWnd, comboOther, CB_DELETESTRING, duplicated, 0);
|
||||
|
@ -361,7 +379,7 @@ void CPageDisk::HandleHDDCombo(HWND hWnd, UINT driveSelected, UINT comboSelected
|
|||
if (RemovalConfirmation(comboSelected))
|
||||
{
|
||||
// Unplug selected disk
|
||||
HD_Unplug(driveSelected);
|
||||
card.Unplug(driveSelected);
|
||||
// Remove drive from list
|
||||
SendDlgItemMessage(hWnd, comboSelected, CB_DELETESTRING, 0, 0);
|
||||
}
|
||||
|
@ -447,7 +465,10 @@ void CPageDisk::HandleHDDSwap(HWND hWnd)
|
|||
if (!RemovalConfirmation(IDC_HDD_SWAP))
|
||||
return;
|
||||
|
||||
if (!HD_ImageSwap())
|
||||
if (GetCardMgr().QuerySlot(SLOT7) != CT_GenericHDD)
|
||||
return;
|
||||
|
||||
if (!dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).ImageSwap())
|
||||
return;
|
||||
|
||||
InitComboHDD(hWnd, SLOT7);
|
||||
|
@ -482,7 +503,7 @@ UINT CPageDisk::RemovalConfirmation(UINT uCommand)
|
|||
|
||||
if (bMsgBox)
|
||||
{
|
||||
int nRes = GetFrame().FrameMessageBox(szText, TEXT("Eject/Unplug Warning"), MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND);
|
||||
int nRes = GetFrame().FrameMessageBox(szText, "Eject/Unplug Warning", MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND);
|
||||
if (nRes == IDNO)
|
||||
uCommand = 0;
|
||||
}
|
||||
|
|
|
@ -393,7 +393,7 @@ void CPropertySheetHelper::RestoreCurrentConfig(void)
|
|||
SetSlot(SLOT3, m_ConfigOld.m_Slot[SLOT3]);
|
||||
SetSlot(SLOT4, m_ConfigOld.m_Slot[SLOT4]);
|
||||
SetSlot(SLOT5, m_ConfigOld.m_Slot[SLOT5]);
|
||||
HD_SetEnabled(m_ConfigOld.m_Slot[SLOT7] == CT_GenericHDD);
|
||||
SetSlot(SLOT7, m_ConfigOld.m_Slot[SLOT7]);
|
||||
GetPropertySheet().SetTheFreezesF8Rom(m_ConfigOld.m_bEnableTheFreezesF8Rom);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,10 @@ Disk2InterfaceCard::Disk2InterfaceCard(UINT slot) :
|
|||
|
||||
ResetLogicStateSequencer();
|
||||
|
||||
// if created by user in Config->Disk, then MemInitializeIO() won't be called
|
||||
if (GetCxRomPeripheral())
|
||||
Initialize(GetCxRomPeripheral()); // During regular start-up, Initialize() will be called later by MemInitializeIO()
|
||||
|
||||
// Debug:
|
||||
#if LOG_DISK_NIBBLES_USE_RUNTIME_VAR
|
||||
m_bLogDisk_NibblesRW = false;
|
||||
|
@ -86,6 +90,9 @@ Disk2InterfaceCard::~Disk2InterfaceCard(void)
|
|||
{
|
||||
EjectDiskInternal(DRIVE_1);
|
||||
EjectDiskInternal(DRIVE_2);
|
||||
|
||||
// if destroyed by user in Config->Disk, then ensure that old object's reference is removed
|
||||
UnregisterIoHandler(m_slot);
|
||||
}
|
||||
|
||||
bool Disk2InterfaceCard::GetEnhanceDisk(void) { return m_enhanceDisk; }
|
||||
|
@ -1791,8 +1798,7 @@ void Disk2InterfaceCard::InitFirmware(LPBYTE pCxRomPeripheral)
|
|||
memcpy(pCxRomPeripheral + m_slot*APPLE_SLOT_SIZE, m_16SectorFirmware, DISK2_FW_SIZE);
|
||||
}
|
||||
|
||||
// TODO: LoadRom_Disk_Floppy()
|
||||
void Disk2InterfaceCard::Initialize(LPBYTE pCxRomPeripheral, UINT uSlot)
|
||||
void Disk2InterfaceCard::Initialize(LPBYTE pCxRomPeripheral)
|
||||
{
|
||||
bool res = GetFirmware(IDR_DISK2_13SECTOR_FW, m_13SectorFirmware);
|
||||
_ASSERT(res);
|
||||
|
@ -1807,10 +1813,7 @@ void Disk2InterfaceCard::Initialize(LPBYTE pCxRomPeripheral, UINT uSlot)
|
|||
// . Patching the firmware breaks the ADC checksum used by "The CIA Files" (Tricky Dick)
|
||||
// . In this case we can patch to compensate for an ADC or EOR checksum but not both (nickw)
|
||||
|
||||
_ASSERT(m_slot == uSlot);
|
||||
RegisterIoHandler(uSlot, &Disk2InterfaceCard::IORead, &Disk2InterfaceCard::IOWrite, NULL, NULL, this, NULL);
|
||||
|
||||
m_slot = uSlot;
|
||||
RegisterIoHandler(m_slot, &Disk2InterfaceCard::IORead, &Disk2InterfaceCard::IOWrite, NULL, NULL, this, NULL);
|
||||
|
||||
InitFirmware(pCxRomPeripheral);
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ public:
|
|||
virtual void Init(void) {};
|
||||
virtual void Reset(const bool powerCycle);
|
||||
|
||||
void Initialize(LPBYTE pCxRomPeripheral, UINT uSlot);
|
||||
void Initialize(LPBYTE pCxRomPeripheral);
|
||||
void Destroy(void); // no, doesn't "destroy" the disk image. DiskIIManagerShutdown()
|
||||
|
||||
void Boot(void);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,36 +23,111 @@ along with AppleWin; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "Card.h"
|
||||
#include "DiskImage.h"
|
||||
#include "DiskImageHelper.h"
|
||||
|
||||
// 1.19.0.0 Hard Disk Status/Indicator Light
|
||||
#define HD_LED 1
|
||||
enum HardDrive_e
|
||||
{
|
||||
HARDDISK_1 = 0,
|
||||
HARDDISK_2,
|
||||
NUM_HARDDISKS
|
||||
};
|
||||
|
||||
enum HardDrive_e
|
||||
class HardDiskDrive
|
||||
{
|
||||
public:
|
||||
HardDiskDrive(void)
|
||||
{
|
||||
HARDDISK_1 = 0,
|
||||
HARDDISK_2,
|
||||
NUM_HARDDISKS
|
||||
};
|
||||
clear();
|
||||
}
|
||||
~HardDiskDrive(void) {}
|
||||
|
||||
void HD_Destroy(void);
|
||||
bool HD_CardIsEnabled(void);
|
||||
void HD_SetEnabled(const bool bEnabled, bool updateRegistry = true);
|
||||
const std::string & HD_GetFullName(const int iDrive);
|
||||
const std::string & HD_GetFullPathName(const int iDrive);
|
||||
void HD_GetFilenameAndPathForSaveState(std::string& filename, std::string& path);
|
||||
void HD_Reset(void);
|
||||
void HD_Load_Rom(const LPBYTE pCxRomPeripheral, const UINT uSlot);
|
||||
bool HD_Select(const int iDrive);
|
||||
BOOL HD_Insert(const int iDrive, const std::string& pathname);
|
||||
void HD_Unplug(const int iDrive);
|
||||
bool HD_IsDriveUnplugged(const int iDrive);
|
||||
void HD_LoadLastDiskImage(const int iDrive);
|
||||
void clear()
|
||||
{
|
||||
m_imagename.clear();
|
||||
m_fullname.clear();
|
||||
m_strFilenameInZip.clear();
|
||||
m_imagehandle = NULL;
|
||||
m_bWriteProtected = false;
|
||||
//
|
||||
m_error = 0;
|
||||
m_memblock = 0;
|
||||
m_diskblock = 0;
|
||||
m_buf_ptr = 0;
|
||||
m_imageloaded = false;
|
||||
memset(m_buf, 0, sizeof(m_buf));
|
||||
m_status_next = DISK_STATUS_OFF;
|
||||
m_status_prev = DISK_STATUS_OFF;
|
||||
}
|
||||
|
||||
// 1.19.0.0 Hard Disk Status/Indicator Light
|
||||
void HD_GetLightStatus (Disk_Status_e *pDisk1Status_);
|
||||
bool HD_ImageSwap(void);
|
||||
// From FloppyDisk
|
||||
std::string m_imagename; // <FILENAME> (ie. no extension)
|
||||
std::string m_fullname; // <FILENAME.EXT> or <FILENAME.zip>
|
||||
std::string m_strFilenameInZip; // "" or <FILENAME.EXT> [not used]
|
||||
ImageInfo* m_imagehandle; // Init'd by HD_Insert() -> ImageOpen()
|
||||
bool m_bWriteProtected; // Needed for ImageOpen() [otherwise not used]
|
||||
//
|
||||
BYTE m_error; // NB. Firmware requires that b0=0 (OK) or b0=1 (Error)
|
||||
WORD m_memblock;
|
||||
UINT m_diskblock;
|
||||
WORD m_buf_ptr;
|
||||
bool m_imageloaded;
|
||||
BYTE m_buf[HD_BLOCK_SIZE];
|
||||
|
||||
std::string HD_GetSnapshotCardName(void);
|
||||
void HD_SaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
|
||||
bool HD_LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version, const std::string & strSaveStatePath);
|
||||
Disk_Status_e m_status_next;
|
||||
Disk_Status_e m_status_prev;
|
||||
};
|
||||
|
||||
class HarddiskInterfaceCard : public Card
|
||||
{
|
||||
public:
|
||||
HarddiskInterfaceCard(UINT slot);
|
||||
virtual ~HarddiskInterfaceCard(void);
|
||||
|
||||
virtual void Init(void) {}
|
||||
virtual void Reset(const bool powerCycle);
|
||||
|
||||
void Initialize(const LPBYTE pCxRomPeripheral);
|
||||
void Destroy(void);
|
||||
const std::string& GetFullName(const int iDrive);
|
||||
const std::string& HarddiskGetFullPathName(const int iDrive);
|
||||
void GetFilenameAndPathForSaveState(std::string& filename, std::string& path);
|
||||
bool Select(const int iDrive);
|
||||
BOOL Insert(const int iDrive, const std::string& pathname);
|
||||
void Unplug(const int iDrive);
|
||||
bool IsDriveUnplugged(const int iDrive);
|
||||
void LoadLastDiskImage(const int iDrive);
|
||||
|
||||
void GetLightStatus(Disk_Status_e* pDisk1Status);
|
||||
bool ImageSwap(void);
|
||||
|
||||
static std::string GetSnapshotCardName(void);
|
||||
void SaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
|
||||
bool LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version, const std::string& strSaveStatePath);
|
||||
|
||||
static BYTE __stdcall IORead(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles);
|
||||
static BYTE __stdcall IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles);
|
||||
|
||||
private:
|
||||
void CleanupDriveInternal(const int iDrive);
|
||||
void CleanupDrive(const int iDrive);
|
||||
void NotifyInvalidImage(TCHAR* pszImageFilename);
|
||||
void SaveLastDiskImage(const int drive);
|
||||
const std::string& DiskGetBaseName(const int iDrive);
|
||||
bool SelectImage(const int drive, LPCSTR pszFilename);
|
||||
void UpdateLightStatus(HardDiskDrive* pHDD);
|
||||
|
||||
void SaveSnapshotHDDUnit(YamlSaveHelper& yamlSaveHelper, UINT unit);
|
||||
bool LoadSnapshotHDDUnit(YamlLoadHelper& yamlLoadHelper, UINT unit);
|
||||
|
||||
//
|
||||
|
||||
BYTE m_unitNum; // b7=unit
|
||||
BYTE m_command;
|
||||
|
||||
bool m_saveDiskImage; // Save the DiskImage name to Registry
|
||||
UINT m_slot;
|
||||
|
||||
HardDiskDrive m_hardDiskDrive[NUM_HARDDISKS];
|
||||
};
|
||||
|
|
|
@ -1012,6 +1012,12 @@ void RegisterIoHandler(UINT uSlot, iofunction IOReadC0, iofunction IOWriteC0, io
|
|||
ExpansionRom[uSlot] = pExpansionRom;
|
||||
}
|
||||
|
||||
void UnregisterIoHandler(UINT uSlot)
|
||||
{
|
||||
RegisterIoHandler(uSlot, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
g_SlotInfo[uSlot].bHasCard = false;
|
||||
}
|
||||
|
||||
// From UTAIIe:5-28: Since INTCXROM==1 then state of SLOTC3ROM is not important
|
||||
static void IoHandlerCardsOut(void)
|
||||
{
|
||||
|
@ -1784,14 +1790,14 @@ void MemInitializeIO(void)
|
|||
}
|
||||
else if (GetCardMgr().QuerySlot(SLOT5) == CT_Disk2)
|
||||
{
|
||||
dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(SLOT5)).Initialize(pCxRomPeripheral, SLOT5); // $C500 : Disk][ card
|
||||
dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(SLOT5)).Initialize(pCxRomPeripheral); // $C500 : Disk][ card
|
||||
}
|
||||
|
||||
if (GetCardMgr().QuerySlot(SLOT6) == CT_Disk2)
|
||||
dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(SLOT6)).Initialize(pCxRomPeripheral, SLOT6); // $C600 : Disk][ card
|
||||
dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(SLOT6)).Initialize(pCxRomPeripheral); // $C600 : Disk][ card
|
||||
|
||||
if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
|
||||
HD_Load_Rom(pCxRomPeripheral, SLOT7); // $C700 : HDD f/w
|
||||
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).Initialize(pCxRomPeripheral);
|
||||
}
|
||||
|
||||
// Called by:
|
||||
|
|
|
@ -60,6 +60,7 @@ const UINT kMaxExMemoryBanks = 127; // 127 * aux mem(64K) + main mem(64K) = 8MB
|
|||
#endif
|
||||
|
||||
void RegisterIoHandler(UINT uSlot, iofunction IOReadC0, iofunction IOWriteC0, iofunction IOReadCx, iofunction IOWriteCx, LPVOID lpSlotParameter, BYTE* pExpansionRom);
|
||||
void UnregisterIoHandler(UINT uSlot);
|
||||
|
||||
void MemDestroy ();
|
||||
bool MemCheckSLOTC3ROM();
|
||||
|
|
|
@ -147,7 +147,10 @@ void Snapshot_GetDefaultFilenameAndPath(std::string& defaultFilename, std::strin
|
|||
{
|
||||
// Attempt to get a default filename/path based on harddisk plugged-in or floppy disk inserted
|
||||
// . Priority given to harddisk over floppy images
|
||||
HD_GetFilenameAndPathForSaveState(defaultFilename, defaultPath);
|
||||
|
||||
if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
|
||||
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).GetFilenameAndPathForSaveState(defaultFilename, defaultPath);
|
||||
|
||||
if (defaultFilename.empty())
|
||||
GetCardMgr().GetDisk2CardMgr().GetFilenameAndPathForSaveState(defaultFilename, defaultPath);
|
||||
}
|
||||
|
@ -370,11 +373,11 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion)
|
|||
GetCardMgr().Insert(slot, type);
|
||||
bRes = dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(slot)).LoadSnapshot(yamlLoadHelper, slot, cardVersion);
|
||||
}
|
||||
else if (card == HD_GetSnapshotCardName())
|
||||
else if (card == HarddiskInterfaceCard::GetSnapshotCardName())
|
||||
{
|
||||
type = CT_GenericHDD;
|
||||
GetCardMgr().Insert(slot, type);
|
||||
bRes = HD_LoadSnapshot(yamlLoadHelper, slot, cardVersion, g_strSaveStatePath);
|
||||
bRes = dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(slot)).LoadSnapshot(yamlLoadHelper, slot, cardVersion, g_strSaveStatePath);
|
||||
}
|
||||
else if (card == tfe_GetSnapshotCardName())
|
||||
{
|
||||
|
@ -496,9 +499,6 @@ static void Snapshot_LoadState_v2(void)
|
|||
MemReset(); // Also calls CpuInitialize()
|
||||
GetPravets().Reset();
|
||||
|
||||
HD_Reset();
|
||||
HD_SetEnabled(false); // Set disabled & also removes card from slot 7
|
||||
|
||||
KeybReset();
|
||||
GetVideo().VideoResetState();
|
||||
GetVideo().SetVideoRefreshRate(VR_60HZ); // Default to 60Hz as older save-states won't contain refresh rate
|
||||
|
@ -574,9 +574,6 @@ void Snapshot_LoadState()
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// todo:
|
||||
// . Uthernet card
|
||||
|
||||
void Snapshot_SaveState(void)
|
||||
{
|
||||
try
|
||||
|
@ -646,7 +643,7 @@ void Snapshot_SaveState(void)
|
|||
dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(SLOT6)).SaveSnapshot(yamlSaveHelper);
|
||||
|
||||
if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
|
||||
HD_SaveSnapshot(yamlSaveHelper);
|
||||
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).SaveSnapshot(yamlSaveHelper);
|
||||
|
||||
for (UINT slot = SLOT3; slot <= SLOT5; slot++)
|
||||
{
|
||||
|
|
|
@ -267,11 +267,6 @@ void LoadConfiguration(void)
|
|||
tfe_init(true);
|
||||
}
|
||||
}
|
||||
else if (slot == SLOT7)
|
||||
{
|
||||
if ((SS_CARDTYPE)dwTmp == CT_GenericHDD) // TODO: move this to when HarddiskInterfaceCard object is instantiated
|
||||
HD_SetEnabled(true, false);
|
||||
}
|
||||
}
|
||||
else // legacy (AppleWin 1.30.3 or earlier)
|
||||
{
|
||||
|
@ -296,7 +291,7 @@ void LoadConfiguration(void)
|
|||
else if (slot == SLOT5 && REGLOAD(TEXT(REGVALUE_SLOT5), &dwTmp))
|
||||
GetCardMgr().Insert(SLOT5, (SS_CARDTYPE)dwTmp);
|
||||
else if (slot == SLOT7 && REGLOAD(TEXT(REGVALUE_HDD_ENABLED), &dwTmp))
|
||||
HD_SetEnabled(dwTmp ? true : false);
|
||||
GetCardMgr().Insert(SLOT7, (SS_CARDTYPE)dwTmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,8 +309,11 @@ void LoadConfiguration(void)
|
|||
GetCurrentDirectory(sizeof(szFilename), szFilename);
|
||||
SetCurrentImageDir(szFilename);
|
||||
|
||||
HD_LoadLastDiskImage(HARDDISK_1);
|
||||
HD_LoadLastDiskImage(HARDDISK_2);
|
||||
if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
|
||||
{
|
||||
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).LoadLastDiskImage(HARDDISK_1);
|
||||
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).LoadLastDiskImage(HARDDISK_2);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
|
@ -401,16 +399,20 @@ static bool DoDiskInsert(const UINT slot, const int nDrive, LPCSTR szFileName)
|
|||
|
||||
static bool DoHardDiskInsert(const int nDrive, LPCSTR szFileName)
|
||||
{
|
||||
_ASSERT(GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD);
|
||||
if (GetCardMgr().QuerySlot(SLOT7) != CT_GenericHDD)
|
||||
return false;
|
||||
|
||||
if (szFileName[0] == '\0')
|
||||
{
|
||||
HD_Unplug(nDrive);
|
||||
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).Unplug(nDrive);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string strPathName = GetFullPath(szFileName);
|
||||
if (strPathName.empty()) return false;
|
||||
|
||||
BOOL bRes = HD_Insert(nDrive, strPathName);
|
||||
BOOL bRes = dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).Insert(nDrive, strPathName);
|
||||
bool res = (bRes == TRUE);
|
||||
if (res)
|
||||
SetCurrentDir(strPathName);
|
||||
|
@ -454,7 +456,8 @@ void InsertHardDisks(LPCSTR szImageName_harddisk[NUM_HARDDISKS], bool& bBoot)
|
|||
if (!szImageName_harddisk[HARDDISK_1] && !szImageName_harddisk[HARDDISK_2])
|
||||
return;
|
||||
|
||||
HD_SetEnabled(true); // Enable the Harddisk controller card
|
||||
if (GetCardMgr().QuerySlot(SLOT7) != CT_GenericHDD)
|
||||
GetCardMgr().Insert(SLOT7, CT_GenericHDD); // Enable the Harddisk controller card
|
||||
|
||||
bool bRes = true;
|
||||
|
||||
|
@ -476,11 +479,6 @@ void InsertHardDisks(LPCSTR szImageName_harddisk[NUM_HARDDISKS], bool& bBoot)
|
|||
GetFrame().FrameMessageBox("Failed to insert harddisk(s) - see log file", "Warning", MB_ICONASTERISK | MB_OK);
|
||||
}
|
||||
|
||||
void UnplugHardDiskControllerCard(void)
|
||||
{
|
||||
HD_SetEnabled(false);
|
||||
}
|
||||
|
||||
void GetAppleWindowTitle()
|
||||
{
|
||||
switch (g_Apple2Type)
|
||||
|
@ -541,7 +539,8 @@ void GetAppleWindowTitle()
|
|||
void ResetMachineState()
|
||||
{
|
||||
GetCardMgr().GetDisk2CardMgr().Reset(true);
|
||||
HD_Reset();
|
||||
if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
|
||||
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).Reset(true);
|
||||
g_bFullSpeed = 0; // Might've hit reset in middle of InternalCpuExecute() - so beep may get (partially) muted
|
||||
|
||||
MemReset(); // calls CpuInitialize(), CNoSlotClock.Reset()
|
||||
|
@ -595,7 +594,8 @@ void CtrlReset()
|
|||
|
||||
GetPravets().Reset();
|
||||
GetCardMgr().GetDisk2CardMgr().Reset();
|
||||
HD_Reset();
|
||||
if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
|
||||
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).Reset(true);
|
||||
KeybReset();
|
||||
if (GetCardMgr().IsSSCInstalled())
|
||||
GetCardMgr().GetSSC()->CommReset();
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
void LoadConfiguration();
|
||||
void InsertFloppyDisks(const UINT slot, LPCSTR szImageName_drive[NUM_DRIVES], bool driveConnected[NUM_DRIVES], bool& bBoot);
|
||||
void InsertHardDisks(LPCSTR szImageName_harddisk[NUM_HARDDISKS], bool& bBoot);
|
||||
void UnplugHardDiskControllerCard(void);
|
||||
void GetAppleWindowTitle();
|
||||
|
||||
void CtrlReset();
|
||||
|
|
|
@ -782,7 +782,7 @@ static void RepeatInitialization(void)
|
|||
|
||||
if (g_cmdLine.bSlotEmpty[SLOT7])
|
||||
{
|
||||
HD_SetEnabled(false); // Disable HDD controller, and persist this to Registry/conf.ini (consistent with other '-sn empty' cmds)
|
||||
GetCardMgr().Remove(SLOT7); // Disable HDD controller, and persist this to Registry/conf.ini (consistent with other '-sn empty' cmds)
|
||||
Snapshot_UpdatePath(); // If save-state's filename is a harddisk, and the floppy is in the same path, then the filename won't be updated
|
||||
}
|
||||
}
|
||||
|
@ -821,7 +821,8 @@ static void RepeatInitialization(void)
|
|||
// Need to test if it's safe to call ResetMachineState(). In the meantime, just call Disk2Card's Reset():
|
||||
GetCardMgr().GetDisk2CardMgr().Reset(true); // Switch from a booting A][+ to a non-autostart A][, so need to turn off floppy motor
|
||||
LogFileOutput("Main: DiskReset()\n");
|
||||
HD_Reset(); // GH#515
|
||||
if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
|
||||
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).Reset(true); // GH#515
|
||||
LogFileOutput("Main: HDDReset()\n");
|
||||
|
||||
if (!g_bSysClkOK)
|
||||
|
@ -916,7 +917,7 @@ static void Shutdown(void)
|
|||
CloseHandle(g_hCustomRom);
|
||||
|
||||
if (g_cmdLine.bSlot7EmptyOnExit)
|
||||
UnplugHardDiskControllerCard();
|
||||
GetCardMgr().Remove(SLOT7);
|
||||
}
|
||||
|
||||
IPropertySheet& GetPropertySheet(void)
|
||||
|
|
|
@ -741,11 +741,9 @@ void Win32Frame::DrawStatusArea (HDC passdc, int drawflags)
|
|||
int y = buttony+BUTTONS*BUTTONCY+1;
|
||||
const bool bCaps = KeybGetCapsStatus();
|
||||
|
||||
#if HD_LED
|
||||
// 1.19.0.0 Hard Disk Status/Indicator Light
|
||||
Disk_Status_e eHardDriveStatus = DISK_STATUS_OFF;
|
||||
HD_GetLightStatus(&eHardDriveStatus);
|
||||
#endif
|
||||
if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
|
||||
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).GetLightStatus(&eHardDriveStatus);
|
||||
|
||||
if (g_bIsFullScreen)
|
||||
{
|
||||
|
@ -764,11 +762,9 @@ void Win32Frame::DrawStatusArea (HDC passdc, int drawflags)
|
|||
FrameDrawDiskStatus(dc);
|
||||
}
|
||||
|
||||
#if HD_LED
|
||||
SetTextAlign(dc, TA_RIGHT | TA_TOP);
|
||||
SetTextColor(dc, g_aDiskFullScreenColorsLED[ eHardDriveStatus ] );
|
||||
TextOut(dc,x+23,y+2,TEXT("H"),1);
|
||||
#endif
|
||||
|
||||
if (!IS_APPLE2)
|
||||
{
|
||||
|
@ -849,11 +845,8 @@ void Win32Frame::DrawStatusArea (HDC passdc, int drawflags)
|
|||
case A2TYPE_PRAVETS8A : DrawBitmapRect(dc,x+31,y+17,&rCapsLed,g_hCapsBitmapP8 [bCaps != 0]); break;
|
||||
}
|
||||
|
||||
#if HD_LED
|
||||
// 1.19.0.0 Hard Disk Status/Indicator Light
|
||||
RECT rDiskLed = {0,0,8,8};
|
||||
DrawBitmapRect(dc,x+12,y+18,&rDiskLed,g_hDiskWindowedLED[eHardDriveStatus]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -968,7 +961,8 @@ LRESULT Win32Frame::WndProc(
|
|||
DebugDestroy();
|
||||
if (!g_bRestart) {
|
||||
GetCardMgr().GetDisk2CardMgr().Destroy();
|
||||
HD_Destroy();
|
||||
if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
|
||||
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).Destroy();
|
||||
}
|
||||
PrintDestroy();
|
||||
if (GetCardMgr().IsSSCInstalled())
|
||||
|
|
Loading…
Add table
Reference in a new issue