From d15641e57f0028a85584782068d36eb86b72805c Mon Sep 17 00:00:00 2001 From: penfold42 Date: Fri, 27 Jul 2018 23:43:49 +1000 Subject: [PATCH 1/3] Alt-A from browser load the automountimage --- src/FileBrowser.cpp | 5 +++++ src/InputMappings.cpp | 4 ++++ src/InputMappings.h | 6 ++++++ src/main.cpp | 8 +------- src/types.h | 7 +++++++ 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index 3e92ce5..a2aeec3 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -41,6 +41,7 @@ extern Options options; #define PNG_HEIGHT 200 extern void GlobalSetDeviceID(u8 id); +extern void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowser); unsigned char FileBrowser::LSTBuffer[FileBrowser::LSTBuffer_size]; @@ -982,6 +983,10 @@ void FileBrowser::UpdateInputFolders() if (inputMappings->BrowseBack()) PopFolder(); } + if (inputMappings->BrowseAutoLoad()) + { + CheckAutoMountImage(EXIT_RESET, this); + } } } diff --git a/src/InputMappings.cpp b/src/InputMappings.cpp index 17c0d1a..6da1d1c 100644 --- a/src/InputMappings.cpp +++ b/src/InputMappings.cpp @@ -179,6 +179,8 @@ bool InputMappings::CheckKeyboardBrowseMode() // SetKeyboardFlag(PAGEDOWN_LCD_FLAG); else if (keyboard->KeyHeld(KEY_N) && keyboard->KeyEitherAlt() ) SetKeyboardFlag(NEWD64_FLAG); + else if (keyboard->KeyHeld(KEY_A) && keyboard->KeyEitherAlt() ) + SetKeyboardFlag(AUTOLOAD_FLAG); else { unsigned index; @@ -206,6 +208,8 @@ void InputMappings::CheckKeyboardEmulationMode(unsigned numberOfImages, unsigned SetKeyboardFlag(PREV_FLAG); else if (keyboard->KeyHeld(KEY_PAGEDOWN)) SetKeyboardFlag(NEXT_FLAG); + else if (keyboard->KeyHeld(KEY_A) && keyboard->KeyEitherAlt() ) + SetKeyboardFlag(AUTOLOAD_FLAG); else if (numberOfImages > 1) { unsigned index; diff --git a/src/InputMappings.h b/src/InputMappings.h index e884681..50bd586 100644 --- a/src/InputMappings.h +++ b/src/InputMappings.h @@ -38,6 +38,7 @@ #define PAGEUP_LCD_FLAG (1 << 13) #define NEWD64_FLAG (1 << 14) +#define AUTOLOAD_FLAG (1 << 15) // dont exceed 32!! class InputMappings : public Singleton @@ -148,6 +149,11 @@ public: return KeyboardFlag(NEWD64_FLAG); } + inline bool BrowseAutoLoad() + { + return KeyboardFlag(AUTOLOAD_FLAG); + } + // Used by the 2 cores so need to be volatile //volatile static unsigned directDiskSwapRequest; static unsigned directDiskSwapRequest; diff --git a/src/main.cpp b/src/main.cpp index 5e34d83..9e0895d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -102,12 +102,6 @@ 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 @@ -654,7 +648,7 @@ void GlobalSetDeviceID(u8 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(); if (autoMountImageName[0] != 0) diff --git a/src/types.h b/src/types.h index 22aa7dc..c50a902 100644 --- a/src/types.h +++ b/src/types.h @@ -16,4 +16,11 @@ typedef enum { LCD_1106_128x64, } LCD_MODEL; +typedef enum { + EXIT_UNKNOWN, + EXIT_RESET, + EXIT_CD, + EXIT_KEYBOARD +} EXIT_TYPE; + #endif From 94f579fc08329a46dacdfe6449f59b7a9e3b1971 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Fri, 27 Jul 2018 23:56:42 +1000 Subject: [PATCH 2/3] Alt-A now works from any folder --- src/FileBrowser.cpp | 5 ++++- src/FileBrowser.h | 2 +- src/main.cpp | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index a2aeec3..c957b66 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -1287,8 +1287,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; int index; int maxEntries = folder.entries.size(); diff --git a/src/FileBrowser.h b/src/FileBrowser.h index 68da5e1..b311501 100644 --- a/src/FileBrowser.h +++ b/src/FileBrowser.h @@ -168,7 +168,7 @@ public: 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 Update(); diff --git a/src/main.cpp b/src/main.cpp index 9e0895d..89b7e9f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -657,7 +657,7 @@ void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowser) { case EXIT_UNKNOWN: case EXIT_RESET: - fileBrowser->AutoSelectImage(autoMountImageName); + fileBrowser->SelectAutoMountImage(autoMountImageName); break; case EXIT_CD: case EXIT_KEYBOARD: From f807a9cdc08c58d4adf9e2b1bf6b0e8f8165be33 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Sun, 29 Jul 2018 00:35:17 +1000 Subject: [PATCH 3/3] Alt-a will autoload image during emulation --- src/InputMappings.cpp | 4 ++++ src/InputMappings.h | 16 ++++++++++++++++ src/main.cpp | 7 +++++-- src/types.h | 3 ++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/InputMappings.cpp b/src/InputMappings.cpp index 6da1d1c..69f8beb 100644 --- a/src/InputMappings.cpp +++ b/src/InputMappings.cpp @@ -181,6 +181,8 @@ bool InputMappings::CheckKeyboardBrowseMode() 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 { unsigned index; @@ -210,6 +212,8 @@ void InputMappings::CheckKeyboardEmulationMode(unsigned numberOfImages, unsigned 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) { unsigned index; diff --git a/src/InputMappings.h b/src/InputMappings.h index 50bd586..ef127c1 100644 --- a/src/InputMappings.h +++ b/src/InputMappings.h @@ -39,6 +39,7 @@ #define NEWD64_FLAG (1 << 14) #define AUTOLOAD_FLAG (1 << 15) +#define FAKERESET_FLAG (1 << 16) // dont exceed 32!! class InputMappings : public Singleton @@ -96,6 +97,16 @@ public: 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() { return KeyboardFlag(ENTER_FLAG)/* | UartFlag(ENTER_FLAG)*/ | ButtonFlag(ENTER_FLAG); @@ -154,6 +165,11 @@ public: return KeyboardFlag(AUTOLOAD_FLAG); } + inline bool BrowseFakeReset() + { + return KeyboardFlag(FAKERESET_FLAG); + } + // Used by the 2 cores so need to be volatile //volatile static unsigned directDiskSwapRequest; static unsigned directDiskSwapRequest; diff --git a/src/main.cpp b/src/main.cpp index 89b7e9f..58d2887 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -656,6 +656,7 @@ void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowser) switch (reset_reason) { case EXIT_UNKNOWN: + case EXIT_AUTOLOAD: case EXIT_RESET: fileBrowser->SelectAutoMountImage(autoMountImageName); break; @@ -939,6 +940,7 @@ void emulator() bool exitEmulation = inputMappings->Exit(); bool nextDisk = inputMappings->NextDisk(); bool prevDisk = inputMappings->PrevDisk(); + bool exitDoAutoLoad = inputMappings->AutoLoad(); if (nextDisk) { @@ -971,7 +973,7 @@ void emulator() else resetCount = 0; - if (!emulating || (resetCount > 10) || exitEmulation) + if (!emulating || (resetCount > 10) || exitEmulation || exitDoAutoLoad) { // Clearing the caddy now // - will write back all changed/dirty/written to disk images now @@ -995,8 +997,9 @@ void emulator() } if (exitEmulation) exitReason = EXIT_KEYBOARD; + if (exitDoAutoLoad) + exitReason = EXIT_AUTOLOAD; 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. diff --git a/src/types.h b/src/types.h index c50a902..ba55c88 100644 --- a/src/types.h +++ b/src/types.h @@ -20,7 +20,8 @@ typedef enum { EXIT_UNKNOWN, EXIT_RESET, EXIT_CD, - EXIT_KEYBOARD + EXIT_KEYBOARD, + EXIT_AUTOLOAD } EXIT_TYPE; #endif