Skip to content

Commit

Permalink
Fix for AppleWin-Test:
Browse files Browse the repository at this point in the history
. don't load floppy/harddisk images (in Registry's Config) if also loading a save-state via cmd-line.
. done to prevent MessageBox alerts when deleted disk images can't be found.
Info: Registry contains refs to disk images, but on test clean-up, the images get deleted.
  • Loading branch information
tomcw committed Dec 11, 2021
1 parent 177c9fe commit 1670e0d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
12 changes: 8 additions & 4 deletions source/Utilities.cpp
Expand Up @@ -88,8 +88,11 @@ static void LoadConfigOldJoystick_v1(const UINT uJoyNum)
JoySetJoyType(uJoyNum, uNewJoyType);
}

//Reads configuration from the registry entries
void LoadConfiguration(void)
// 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)
{
DWORD dwComputerType = 0;
eApple2Type apple2Type = A2TYPE_APPLE2EENHANCED;
Expand Down Expand Up @@ -309,7 +312,7 @@ void LoadConfiguration(void)
GetCurrentDirectory(sizeof(szFilename), szFilename);
SetCurrentImageDir(szFilename);

if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
if (loadImages && GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
{
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).LoadLastDiskImage(HARDDISK_1);
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).LoadLastDiskImage(HARDDISK_2);
Expand All @@ -323,7 +326,8 @@ void LoadConfiguration(void)
GetCurrentDirectory(sizeof(szFilename), szFilename);
SetCurrentImageDir(szFilename);

GetCardMgr().GetDisk2CardMgr().LoadLastDiskImage();
if (loadImages)
GetCardMgr().GetDisk2CardMgr().LoadLastDiskImage();

// Do this after populating the slots with Disk II controller(s)
DWORD dwEnhanceDisk;
Expand Down
2 changes: 1 addition & 1 deletion source/Utilities.h
Expand Up @@ -4,7 +4,7 @@
#include "Harddisk.h"


void LoadConfiguration();
void LoadConfiguration(bool loadImages);
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 GetAppleWindowTitle();
Expand Down
7 changes: 5 additions & 2 deletions source/Windows/AppleWin.cpp
Expand Up @@ -674,8 +674,11 @@ static void RepeatInitialization(void)
// NB. g_OldAppleWinVersion needed by LoadConfiguration() -> Config_Load_Video()
const bool bShowAboutDlg = CheckOldAppleWinVersion(); // Post: g_OldAppleWinVersion

LoadConfiguration();
LogFileOutput("Main: LoadConfiguration()\n");
{
bool loadImages = g_cmdLine.szSnapshotName == NULL; // don't load floppy/harddisk images if a snapshot is to be loaded later on
LoadConfiguration(loadImages);
LogFileOutput("Main: LoadConfiguration()\n");
}

if (g_cmdLine.model != A2TYPE_MAX)
SetApple2Type(g_cmdLine.model);
Expand Down

0 comments on commit 1670e0d

Please sign in to comment.