Merge pull request #40 from penfold42/automountescape

Escape will now exit an automounted image without re-autoloading it
This commit is contained in:
Stephen White 2018-07-15 18:16:27 +10:00 committed by GitHub
commit f20105f011
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -102,6 +102,14 @@ unsigned int screenHeight = 768;
const char* termainalTextRed = "\E[31m";
const char* termainalTextNormal = "\E[0m";
typedef enum {
EXIT_UNKNOWN,
EXIT_RESET,
EXIT_CD,
EXIT_KEYBOARD
} EXIT_TYPE;
EXIT_TYPE exitReason = EXIT_UNKNOWN;
// Hooks required for USPi library
extern "C"
{
@ -631,13 +639,23 @@ static void SetVIAsDeviceID(u8 id)
if (id & 2) pi1541.VIA[0].GetPortB()->SetInput(VIAPORTPINS_DEVSEL1, true);
}
static void CheckAutoMountImage(bool CD_, FileBrowser* fileBrowser)
{
if (CD_ == false)
static void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowser)
{
const char* autoMountImageName = options.GetAutoMountImageName();
if (autoMountImageName[0] != 0)
{
switch (reset_reason)
{
case EXIT_UNKNOWN:
case EXIT_RESET:
fileBrowser->AutoSelectImage(autoMountImageName);
break;
case EXIT_CD:
case EXIT_KEYBOARD:
break;
default:
break;
}
}
}
@ -651,7 +669,6 @@ void emulator()
bool selectedViaIECCommands = false;
InputMappings* inputMappings = InputMappings::Instance();
FileBrowser* fileBrowser;
bool CD_ = false;
roms.lastManualSelectedROMIndex = 0;
@ -691,7 +708,7 @@ void emulator()
{
m_IEC_Commands.SimulateIECBegin();
CheckAutoMountImage(CD_, fileBrowser);
CheckAutoMountImage(exitReason, fileBrowser);
while (!emulating)
{
@ -704,7 +721,7 @@ void emulator()
fileBrowser->DisplayRoot();
IEC_Bus::Reset();
m_IEC_Commands.SimulateIECBegin();
CheckAutoMountImage(false, fileBrowser);
CheckAutoMountImage(EXIT_UNKNOWN, fileBrowser);
break;
case IEC_Commands::NONE:
{
@ -843,7 +860,7 @@ void emulator()
// Exit full emulation back to IEC commands level simulation.
snoopIndex = 0;
emulating = false;
CD_ = true;
exitReason = EXIT_CD;
}
}
else
@ -960,8 +977,10 @@ void emulator()
fileBrowser->DisplayRoot();//m_IEC_Commands.ChangeToRoot(); // TO CHECK
emulating = false;
resetWhileEmulating = true;
if (reset || exitEmulation)
CD_ = false;
if (reset)
exitReason = EXIT_RESET;
if (exitEmulation)
exitReason = EXIT_KEYBOARD;
break;
}