Escape will now exit an automounted image without re-autoloading it

This commit is contained in:
penfold42 2018-07-13 18:04:37 +10:00
parent 2bc501dd85
commit c6c79d9c81

View file

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