Merge pull request #53 from penfold42/alt-a

Alt-a to re load AutoMountImage
This commit is contained in:
Stephen White 2018-07-29 15:00:06 +10:00 committed by GitHub
commit 5491711446
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 12 deletions

View file

@ -41,6 +41,7 @@ extern Options options;
#define PNG_HEIGHT 200 #define PNG_HEIGHT 200
extern void GlobalSetDeviceID(u8 id); extern void GlobalSetDeviceID(u8 id);
extern void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowser);
unsigned char FileBrowser::LSTBuffer[FileBrowser::LSTBuffer_size]; unsigned char FileBrowser::LSTBuffer[FileBrowser::LSTBuffer_size];
@ -1007,6 +1008,10 @@ void FileBrowser::UpdateInputFolders()
if (inputMappings->BrowseBack()) if (inputMappings->BrowseBack())
PopFolder(); PopFolder();
} }
if (inputMappings->BrowseAutoLoad())
{
CheckAutoMountImage(EXIT_RESET, this);
}
} }
} }
@ -1321,8 +1326,11 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
} }
} }
void FileBrowser::AutoSelectImage(const char* image) void FileBrowser::SelectAutoMountImage(const char* image)
{ {
f_chdir("/1541");
RefreshFolderEntries();
FileBrowser::BrowsableList::Entry* current = 0; FileBrowser::BrowsableList::Entry* current = 0;
int index; int index;
int maxEntries = folder.entries.size(); int maxEntries = folder.entries.size();

View file

@ -168,7 +168,7 @@ public:
FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool displayPNGIcons, ScreenBase* screenMain, ScreenBase* screenLCD, float scrollHighlightRate); FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool displayPNGIcons, ScreenBase* screenMain, ScreenBase* screenLCD, float scrollHighlightRate);
void AutoSelectImage(const char* image); void SelectAutoMountImage(const char* image);
void DisplayRoot(); void DisplayRoot();
void Update(); void Update();

View file

@ -187,6 +187,10 @@ bool InputMappings::CheckKeyboardBrowseMode()
// SetKeyboardFlag(PAGEDOWN_LCD_FLAG); // SetKeyboardFlag(PAGEDOWN_LCD_FLAG);
else if (keyboard->KeyHeld(KEY_N) && keyboard->KeyEitherAlt() ) else if (keyboard->KeyHeld(KEY_N) && keyboard->KeyEitherAlt() )
SetKeyboardFlag(NEWD64_FLAG); SetKeyboardFlag(NEWD64_FLAG);
else if (keyboard->KeyHeld(KEY_A) && keyboard->KeyEitherAlt() )
SetKeyboardFlag(AUTOLOAD_FLAG);
else if (keyboard->KeyHeld(KEY_R) && keyboard->KeyEitherAlt() )
SetKeyboardFlag(FAKERESET_FLAG);
else else
{ {
unsigned index; unsigned index;
@ -214,6 +218,10 @@ void InputMappings::CheckKeyboardEmulationMode(unsigned numberOfImages, unsigned
SetKeyboardFlag(PREV_FLAG); SetKeyboardFlag(PREV_FLAG);
else if (keyboard->KeyHeld(KEY_PAGEDOWN)) else if (keyboard->KeyHeld(KEY_PAGEDOWN))
SetKeyboardFlag(NEXT_FLAG); SetKeyboardFlag(NEXT_FLAG);
else if (keyboard->KeyHeld(KEY_A) && keyboard->KeyEitherAlt() )
SetKeyboardFlag(AUTOLOAD_FLAG);
else if (keyboard->KeyHeld(KEY_R) && keyboard->KeyEitherAlt() )
SetKeyboardFlag(FAKERESET_FLAG);
else if (numberOfImages > 1) else if (numberOfImages > 1)
{ {
unsigned index; unsigned index;

View file

@ -38,6 +38,8 @@
#define PAGEUP_LCD_FLAG (1 << 13) #define PAGEUP_LCD_FLAG (1 << 13)
#define NEWD64_FLAG (1 << 14) #define NEWD64_FLAG (1 << 14)
#define AUTOLOAD_FLAG (1 << 15)
#define FAKERESET_FLAG (1 << 16)
// dont exceed 32!! // dont exceed 32!!
class InputMappings : public Singleton<InputMappings> class InputMappings : public Singleton<InputMappings>
@ -98,6 +100,16 @@ public:
return KeyboardFlag(PREV_FLAG)/* | UartFlag(PREV_FLAG)*/ | ButtonFlag(PREV_FLAG); return KeyboardFlag(PREV_FLAG)/* | UartFlag(PREV_FLAG)*/ | ButtonFlag(PREV_FLAG);
} }
inline bool AutoLoad()
{
return KeyboardFlag(AUTOLOAD_FLAG);
}
inline bool FakeReset()
{
return KeyboardFlag(FAKERESET_FLAG);
}
inline bool BrowseSelect() inline bool BrowseSelect()
{ {
return KeyboardFlag(ENTER_FLAG)/* | UartFlag(ENTER_FLAG)*/ | ButtonFlag(ENTER_FLAG); return KeyboardFlag(ENTER_FLAG)/* | UartFlag(ENTER_FLAG)*/ | ButtonFlag(ENTER_FLAG);
@ -151,6 +163,16 @@ public:
return KeyboardFlag(NEWD64_FLAG); return KeyboardFlag(NEWD64_FLAG);
} }
inline bool BrowseAutoLoad()
{
return KeyboardFlag(AUTOLOAD_FLAG);
}
inline bool BrowseFakeReset()
{
return KeyboardFlag(FAKERESET_FLAG);
}
// Used by the 2 cores so need to be volatile // Used by the 2 cores so need to be volatile
//volatile static unsigned directDiskSwapRequest; //volatile static unsigned directDiskSwapRequest;
static unsigned directDiskSwapRequest; static unsigned directDiskSwapRequest;

View file

@ -102,12 +102,6 @@ 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; EXIT_TYPE exitReason = EXIT_UNKNOWN;
// Hooks required for USPi library // Hooks required for USPi library
@ -654,7 +648,7 @@ void GlobalSetDeviceID(u8 id)
SetVIAsDeviceID(id); SetVIAsDeviceID(id);
} }
static void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowser) void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowser)
{ {
const char* autoMountImageName = options.GetAutoMountImageName(); const char* autoMountImageName = options.GetAutoMountImageName();
if (autoMountImageName[0] != 0) if (autoMountImageName[0] != 0)
@ -662,8 +656,9 @@ static void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowse
switch (reset_reason) switch (reset_reason)
{ {
case EXIT_UNKNOWN: case EXIT_UNKNOWN:
case EXIT_AUTOLOAD:
case EXIT_RESET: case EXIT_RESET:
fileBrowser->AutoSelectImage(autoMountImageName); fileBrowser->SelectAutoMountImage(autoMountImageName);
break; break;
case EXIT_CD: case EXIT_CD:
case EXIT_KEYBOARD: case EXIT_KEYBOARD:
@ -945,6 +940,7 @@ void emulator()
bool exitEmulation = inputMappings->Exit(); bool exitEmulation = inputMappings->Exit();
bool nextDisk = inputMappings->NextDisk(); bool nextDisk = inputMappings->NextDisk();
bool prevDisk = inputMappings->PrevDisk(); bool prevDisk = inputMappings->PrevDisk();
bool exitDoAutoLoad = inputMappings->AutoLoad();
if (nextDisk) if (nextDisk)
{ {
@ -977,7 +973,7 @@ void emulator()
else else
resetCount = 0; resetCount = 0;
if (!emulating || (resetCount > 10) || exitEmulation) if (!emulating || (resetCount > 10) || exitEmulation || exitDoAutoLoad)
{ {
// Clearing the caddy now // Clearing the caddy now
// - will write back all changed/dirty/written to disk images now // - will write back all changed/dirty/written to disk images now
@ -1001,8 +997,9 @@ void emulator()
} }
if (exitEmulation) if (exitEmulation)
exitReason = EXIT_KEYBOARD; exitReason = EXIT_KEYBOARD;
if (exitDoAutoLoad)
exitReason = EXIT_AUTOLOAD;
break; break;
} }
if (cycleCount < FAST_BOOT_CYCLES) // cycleCount is used so we can quickly get through 1541's self test code. This will make the emulated 1541 responsive to commands asap. if (cycleCount < FAST_BOOT_CYCLES) // cycleCount is used so we can quickly get through 1541's self test code. This will make the emulated 1541 responsive to commands asap.

View file

@ -16,4 +16,12 @@ typedef enum {
LCD_1106_128x64, LCD_1106_128x64,
} LCD_MODEL; } LCD_MODEL;
typedef enum {
EXIT_UNKNOWN,
EXIT_RESET,
EXIT_CD,
EXIT_KEYBOARD,
EXIT_AUTOLOAD
} EXIT_TYPE;
#endif #endif