From 980712cfda794efb17d7f35a3dc067a0fd01d368 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Fri, 27 Jul 2018 12:08:16 +1000 Subject: [PATCH 1/9] Fix for 128x32 displays during emulation Clean up redundant if (screenLCD) clean up to support variable LCD font height in future --- src/DiskCaddy.cpp | 77 +++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/src/DiskCaddy.cpp b/src/DiskCaddy.cpp index 871cfac..04f01e8 100644 --- a/src/DiskCaddy.cpp +++ b/src/DiskCaddy.cpp @@ -32,6 +32,8 @@ static char buffer[256] = { 0 }; static u32 white = RGBA(0xff, 0xff, 0xff, 0xff); static u32 red = RGBA(0xff, 0, 0, 0xff); +#define LCDFONTHEIGHT 16 + bool DiskCaddy::Empty() { int x; @@ -62,7 +64,7 @@ bool DiskCaddy::Empty() snprintf(buffer, 256, "Saving"); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), BkColour); - y += 16; + y += LCDFONTHEIGHT; snprintf(buffer, 256, "%s ", disks[index].GetName()); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red); screenLCD->SwapBuffers(); @@ -91,7 +93,7 @@ bool DiskCaddy::Empty() snprintf(buffer, 256, "Saving"); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), BkColour); - y += 16; + y += LCDFONTHEIGHT; snprintf(buffer, 256, "Complete "); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red); screenLCD->SwapBuffers(); @@ -130,7 +132,7 @@ bool DiskCaddy::Insert(const FILINFO* fileInfo, bool readOnly) snprintf(buffer, 256, "Loading"); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), BkColour); - y += 16; + y += LCDFONTHEIGHT; snprintf(buffer, 256, "%s ", fileInfo->fname); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red); screenLCD->SwapBuffers(); @@ -282,47 +284,44 @@ void DiskCaddy::ShowSelectedImage(u32 index) if (screenLCD) { unsigned numberOfImages = GetNumberOfImages(); + unsigned numberOfDisplayedImages = screenLCD->Height()/LCDFONTHEIGHT-1; unsigned caddyIndex; - if (screenLCD) + RGBA BkColour = RGBA(0, 0, 0, 0xFF); + //screenLCD->Clear(BkColour); + x = 0; + y = 0; + + snprintf(buffer, 256, " D %d/%d ", index + 1, numberOfImages); + screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), RGBA(0xff, 0xff, 0xff, 0xff)); + y += LCDFONTHEIGHT; + + if (numberOfImages > numberOfDisplayedImages && index > numberOfDisplayedImages-1) { - RGBA BkColour = RGBA(0, 0, 0, 0xFF); - //screenLCD->Clear(BkColour); - x = 0; - y = 0; - - //snprintf(buffer, 256, "Emulating %d/%d ", index + 1, numberOfImages); - snprintf(buffer, 256, " D %d/%d ", index + 1, numberOfImages); - screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), RGBA(0xff, 0xff, 0xff, 0xff)); - y += 16; - - if (numberOfImages > 3 && index > 2) - { - if (numberOfImages - index < 3) - caddyIndex = numberOfImages - 3; - else - caddyIndex = index; - } + if (numberOfImages - index < numberOfDisplayedImages) + caddyIndex = numberOfImages - numberOfDisplayedImages; else - { - caddyIndex = 0; - } - - for (; caddyIndex < numberOfImages; ++caddyIndex) - { - DiskImage* image = GetImage(caddyIndex); - const char* name = image->GetName(); - if (name) - { - snprintf(buffer, 256, "%d %s ", caddyIndex + 1, name); - screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), caddyIndex == index ? RGBA(0xff, 0xff, 0xff, 0xff) : BkColour); - y += 16; - } - if (y >= screenLCD->Height()) - break; - } - screenLCD->SwapBuffers(); + caddyIndex = index; } + else + { + caddyIndex = 0; + } + + for (; caddyIndex < numberOfImages; ++caddyIndex) + { + DiskImage* image = GetImage(caddyIndex); + const char* name = image->GetName(); + if (name) + { + snprintf(buffer, 256, "%d %s ", caddyIndex + 1, name); + screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), caddyIndex == index ? RGBA(0xff, 0xff, 0xff, 0xff) : BkColour); + y += LCDFONTHEIGHT; + } + if (y >= screenLCD->Height()) + break; + } + screenLCD->SwapBuffers(); } } From d15641e57f0028a85584782068d36eb86b72805c Mon Sep 17 00:00:00 2001 From: penfold42 Date: Fri, 27 Jul 2018 23:43:49 +1000 Subject: [PATCH 2/9] 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 3/9] 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 4/9] 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 From b1998612c49bf73c94b0df1e5d3051a70349e516 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Sun, 29 Jul 2018 00:50:56 +1000 Subject: [PATCH 5/9] update options.txt with supported OLED displays --- options.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/options.txt b/options.txt index 8ecff4d..0b1edd5 100644 --- a/options.txt +++ b/options.txt @@ -60,6 +60,8 @@ GraphIEC = 1 // If you are using a LCD screen then specify it here //LCDName = ssd1306_128x64 +//LCDName = ssd1306_128x32 +//LCDName = sh1106_128x64 // If you are using a LCD screen and you would like PageUp and PageDown keys to work with it then specify this option //KeyboardBrowseLCDScreen = 1 From 5ac2fe8c4595b3e51dfe230b60370503e8ae0b6b Mon Sep 17 00:00:00 2001 From: Stephen White Date: Sun, 29 Jul 2018 14:22:14 +1000 Subject: [PATCH 6/9] Buttons in browse mode can change the selected ROM Holding down the first button and pressing one of the other buttons will select different ROMs (if they have been specified in the options.txt file) --- src/FileBrowser.cpp | 121 ++++++++++++++++++++++++++++-------------- src/FileBrowser.h | 3 ++ src/InputMappings.cpp | 14 +++-- src/InputMappings.h | 3 ++ src/iec_bus.cpp | 10 ++-- 5 files changed, 102 insertions(+), 49 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index 3e92ce5..b814393 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -386,6 +386,7 @@ FileBrowser::FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, u8* deviceID, bool di , deviceID(deviceID) , displayPNGIcons(displayPNGIcons) , buttonChangedDevice(false) + , buttonSelectROM(false) , screenMain(screenMain) , screenLCD(screenLCD) , scrollHighlightRate(scrollHighlightRate) @@ -825,14 +826,12 @@ void FileBrowser::UpdateInputFolders() { if (inputMappings->BrowseSelect()) { - DEBUG_LOG("DEv8\r\n"); GlobalSetDeviceID(8); ShowDeviceAndROM(); buttonChangedDevice = true; } else if (inputMappings->BrowseUp()) { - DEBUG_LOG("DEv9\r\n"); GlobalSetDeviceID(9); ShowDeviceAndROM(); buttonChangedDevice = true; @@ -850,6 +849,29 @@ void FileBrowser::UpdateInputFolders() buttonChangedDevice = true; } } + else if (IEC_Bus::GetInputButtonHeld(0)) + { + if (inputMappings->BrowseUp()) + { + SelectROM(0); + buttonSelectROM = true; + } + else if (inputMappings->BrowseDown()) + { + SelectROM(1); + buttonSelectROM = true; + } + else if (inputMappings->BrowseBack()) + { + SelectROM(2); + buttonSelectROM = true; + } + else if (inputMappings->BrowseInsert()) + { + SelectROM(3); + buttonSelectROM = true; + } + } else { if (folder.entries.size() > 0) @@ -859,49 +881,56 @@ void FileBrowser::UpdateInputFolders() if (inputMappings->BrowseSelect()) { - FileBrowser::BrowsableList::Entry* current = folder.current; - if (current) + if (buttonSelectROM) { - if (current->filImage.fattrib & AM_DIR) + buttonSelectROM = false; + } + else + { + FileBrowser::BrowsableList::Entry* current = folder.current; + if (current) { - if (strcmp(current->filImage.fname, "..") == 0) + if (current->filImage.fattrib & AM_DIR) { - PopFolder(); - } - else if (strcmp(current->filImage.fname, ".") != 0) - { - f_chdir(current->filImage.fname); - RefreshFolderEntries(); - } - dirty = true; - } - else - { - if (strcmp(current->filImage.fname, "..") == 0) - { - PopFolder(); - } - else if (DiskImage::IsDiskImageExtention(current->filImage.fname)) - { - DiskImage::DiskType diskType = DiskImage::GetDiskImageTypeViaExtention(current->filImage.fname); - - // Should also be able to create a LST file from all the images currently selected in the caddy - if (diskType == DiskImage::LST) + if (strcmp(current->filImage.fname, "..") == 0) { - selectionsMade = SelectLST(current->filImage.fname); + PopFolder(); } - else + else if (strcmp(current->filImage.fname, ".") != 0) { - // Add the current selected - AddToCaddy(current); - selectionsMade = FillCaddyWithSelections(); + f_chdir(current->filImage.fname); + RefreshFolderEntries(); } - - if (selectionsMade) - lastSelectionName = current->filImage.fname; - dirty = true; } + else + { + if (strcmp(current->filImage.fname, "..") == 0) + { + PopFolder(); + } + else if (DiskImage::IsDiskImageExtention(current->filImage.fname)) + { + DiskImage::DiskType diskType = DiskImage::GetDiskImageTypeViaExtention(current->filImage.fname); + + // Should also be able to create a LST file from all the images currently selected in the caddy + if (diskType == DiskImage::LST) + { + selectionsMade = SelectLST(current->filImage.fname); + } + else + { + // Add the current selected + AddToCaddy(current); + selectionsMade = FillCaddyWithSelections(); + } + + if (selectionsMade) + lastSelectionName = current->filImage.fname; + + dirty = true; + } + } } } } @@ -957,12 +986,8 @@ void FileBrowser::UpdateInputFolders() || keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 1]) || keyboard->KeyPressed(FileBrowser::SwapKeys[keySetIndexBase + 2])) { - if ( (keySetIndex < ROMs::MAX_ROMS) && (roms->ROMValid[keySetIndex]) ) + if (SelectROM(keySetIndex)) { - roms->currentROMIndex = keySetIndex; - roms->lastManualSelectedROMIndex = keySetIndex; - DEBUG_LOG("Swap ROM %d %s\r\n", keySetIndex, roms->ROMNames[keySetIndex]); - ShowDeviceAndROM(); } else if ( (keySetIndex >= 7) && (keySetIndex <= 10 ) ) { @@ -985,6 +1010,20 @@ void FileBrowser::UpdateInputFolders() } } +bool FileBrowser::SelectROM(u32 index) +{ + if ((index < ROMs::MAX_ROMS) && (roms->ROMValid[index])) + { + roms->currentROMIndex = index; + roms->lastManualSelectedROMIndex = index; + DEBUG_LOG("Swap ROM %d %s\r\n", index, roms->ROMNames[index]); + ShowDeviceAndROM(); + return true; + } + return false; +} + + bool FileBrowser::SelectLST(const char* filenameLST) { bool validImage = false; diff --git a/src/FileBrowser.h b/src/FileBrowser.h index 68da5e1..a2212a6 100644 --- a/src/FileBrowser.h +++ b/src/FileBrowser.h @@ -217,6 +217,8 @@ private: bool CheckForPNG(const char* filename, FILINFO& filIcon); void DisplayPNG(); + bool SelectROM(u32 index); + enum State { State_Folders, @@ -231,6 +233,7 @@ private: u8* deviceID; bool displayPNGIcons; bool buttonChangedDevice; + bool buttonSelectROM; BrowsableList caddySelections; diff --git a/src/InputMappings.cpp b/src/InputMappings.cpp index 17c0d1a..2a4ccc6 100644 --- a/src/InputMappings.cpp +++ b/src/InputMappings.cpp @@ -35,15 +35,18 @@ InputMappings::InputMappings() : keyboardBrowseLCDScreen(false) , insertButtonPressedPrev(false) , insertButtonPressed(false) + , enterButtonPressedPrev(false) + , enterButtonPressed(false) { } bool InputMappings::CheckButtonsBrowseMode() { buttonFlags = 0; - if (IEC_Bus::GetInputButtonPressed(0)) - SetButtonFlag(ENTER_FLAG); - else if (IEC_Bus::GetInputButtonRepeating(1)) + //if (IEC_Bus::GetInputButtonPressed(0)) + // SetButtonFlag(ENTER_FLAG); + //else + if (IEC_Bus::GetInputButtonRepeating(1)) SetButtonFlag(UP_FLAG); else if (IEC_Bus::GetInputButtonRepeating(2)) SetButtonFlag(DOWN_FLAG); @@ -57,6 +60,11 @@ bool InputMappings::CheckButtonsBrowseMode() SetButtonFlag(INSERT_FLAG); insertButtonPressedPrev = insertButtonPressed; + enterButtonPressed = !IEC_Bus::GetInputButtonReleased(0); + if (enterButtonPressedPrev && !enterButtonPressed) + SetButtonFlag(ENTER_FLAG); + enterButtonPressedPrev = enterButtonPressed; + return buttonFlags != 0; } diff --git a/src/InputMappings.h b/src/InputMappings.h index e884681..780ce77 100644 --- a/src/InputMappings.h +++ b/src/InputMappings.h @@ -53,6 +53,9 @@ protected: bool insertButtonPressedPrev; bool insertButtonPressed; + bool enterButtonPressedPrev; + bool enterButtonPressed; + //inline void SetUartFlag(unsigned flag) { uartFlags |= flag; } //inline bool UartFlag(unsigned flag) { return (uartFlags & flag) != 0; } inline void SetKeyboardFlag(unsigned flag) { keyboardFlags |= flag; } diff --git a/src/iec_bus.cpp b/src/iec_bus.cpp index 1d70734..f669716 100644 --- a/src/iec_bus.cpp +++ b/src/iec_bus.cpp @@ -51,12 +51,12 @@ bool IEC_Bus::ignoreReset = false; u32 IEC_Bus::myOutsGPFSEL1 = 0; u32 IEC_Bus::myOutsGPFSEL0 = 0; -bool IEC_Bus::InputButton[5]; -bool IEC_Bus::InputButtonPrev[5]; -u32 IEC_Bus::validInputCount[5]; +bool IEC_Bus::InputButton[5] = { 0 }; +bool IEC_Bus::InputButtonPrev[5] = { 0 }; +u32 IEC_Bus::validInputCount[5] = { 0 }; u32 IEC_Bus::inputRepeatThreshold[5]; -u32 IEC_Bus::inputRepeat[5]; -u32 IEC_Bus::inputRepeatPrev[5]; +u32 IEC_Bus::inputRepeat[5] = { 0 }; +u32 IEC_Bus::inputRepeatPrev[5] = { 0 }; m6522* IEC_Bus::VIA = 0; From 09cfc4ec865b75f5b73cc28f0bb20d41f2bc770b Mon Sep 17 00:00:00 2001 From: Stephen White Date: Sun, 29 Jul 2018 15:55:46 +1000 Subject: [PATCH 7/9] Whilst in browse mode pressing Alt-W toggles write protection on a disk image. --- src/FileBrowser.cpp | 18 ++++++++++++++++++ src/InputMappings.cpp | 2 ++ src/InputMappings.h | 6 ++++++ 3 files changed, 26 insertions(+) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index d2b6372..23f977f 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -977,6 +977,24 @@ void FileBrowser::UpdateInputFolders() m_IEC_Commands.CreateD64(newFileName, "42", true); FolderChanged(); } + else if (inputMappings->BrowseWriteProtect()) + { + FileBrowser::BrowsableList::Entry* current = folder.current; + if (current) + { + if (current->filImage.fattrib & AM_RDO) + { + current->filImage.fattrib &= ~AM_RDO; + f_chmod(current->filImage.fname, 0, AM_RDO); + } + else + { + current->filImage.fattrib |= AM_RDO; + f_chmod(current->filImage.fname, AM_RDO, AM_RDO); + } + dirty = true; + } + } else { unsigned keySetIndex; diff --git a/src/InputMappings.cpp b/src/InputMappings.cpp index 61bdccc..9cb5140 100644 --- a/src/InputMappings.cpp +++ b/src/InputMappings.cpp @@ -191,6 +191,8 @@ bool InputMappings::CheckKeyboardBrowseMode() SetKeyboardFlag(AUTOLOAD_FLAG); else if (keyboard->KeyHeld(KEY_R) && keyboard->KeyEitherAlt() ) SetKeyboardFlag(FAKERESET_FLAG); + else if (keyboard->KeyHeld(KEY_W) && keyboard->KeyEitherAlt()) + SetKeyboardFlag(WRITEPROTECT_FLAG); else { unsigned index; diff --git a/src/InputMappings.h b/src/InputMappings.h index 004ea50..ffce76e 100644 --- a/src/InputMappings.h +++ b/src/InputMappings.h @@ -40,6 +40,7 @@ #define NEWD64_FLAG (1 << 14) #define AUTOLOAD_FLAG (1 << 15) #define FAKERESET_FLAG (1 << 16) +#define WRITEPROTECT_FLAG (1 << 17) // dont exceed 32!! class InputMappings : public Singleton @@ -173,6 +174,11 @@ public: return KeyboardFlag(FAKERESET_FLAG); } + inline bool BrowseWriteProtect() + { + return KeyboardFlag(WRITEPROTECT_FLAG); + } + // Used by the 2 cores so need to be volatile //volatile static unsigned directDiskSwapRequest; static unsigned directDiskSwapRequest; From ef7dfb19072cc26b2be7310c7c2ad950e8ead4b2 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Sun, 29 Jul 2018 16:47:32 +1000 Subject: [PATCH 8/9] The AutoMountImage can now handle .LST files. --- src/FileBrowser.cpp | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index 23f977f..5f380be 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -1349,24 +1349,31 @@ void FileBrowser::SelectAutoMountImage(const char* image) f_chdir("/1541"); RefreshFolderEntries(); - FileBrowser::BrowsableList::Entry* current = 0; - int index; - int maxEntries = folder.entries.size(); - - for (index = 0; index < maxEntries; ++index) + if (SelectLST(image)) { - current = &folder.entries[index]; - if (strcasecmp(current->filImage.fname, image) == 0) - { - break; - } + selectionsMade = true; } - - if (index != maxEntries) + else { - ClearSelections(); - caddySelections.entries.push_back(*current); - selectionsMade = FillCaddyWithSelections(); + FileBrowser::BrowsableList::Entry* current = 0; + int index; + int maxEntries = folder.entries.size(); + + for (index = 0; index < maxEntries; ++index) + { + current = &folder.entries[index]; + if (strcasecmp(current->filImage.fname, image) == 0) + { + break; + } + } + + if (index != maxEntries) + { + ClearSelections(); + caddySelections.entries.push_back(*current); + selectionsMade = FillCaddyWithSelections(); + } } } From dc1b700c8e9857c00959a2cafa04f7b9a4835f24 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Sun, 29 Jul 2018 17:15:29 +1000 Subject: [PATCH 9/9] Fixed myth_s1[system_3_1989](radwar)(pal) loading issue. --- src/main.cpp | 62 ++++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 58d2887..75de5c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -930,42 +930,16 @@ void emulator() IEC_Bus::RefreshOuts(); // Now output all outputs. } - // We have now output so HERE is where the next phi2 cycle starts. - pi1541.Update(); - // Other core will check the uart (as it is slow) (could enable uart irqs - will they execute on this core?) inputMappings->CheckKeyboardEmulationMode(numberOfImages, numberOfImagesMax); inputMappings->CheckButtonsEmulationMode(); bool exitEmulation = inputMappings->Exit(); - bool nextDisk = inputMappings->NextDisk(); - bool prevDisk = inputMappings->PrevDisk(); bool exitDoAutoLoad = inputMappings->AutoLoad(); - if (nextDisk) - { - pi1541.drive.Insert(diskCaddy.PrevDisk()); - } - else if (prevDisk) - { - pi1541.drive.Insert(diskCaddy.NextDisk()); - } - else if (numberOfImages > 1 && inputMappings->directDiskSwapRequest != 0) - { - for (caddyIndex = 0; caddyIndex < numberOfImagesMax; ++caddyIndex) - { - if (inputMappings->directDiskSwapRequest & (1 << caddyIndex)) - { - DiskImage* diskImage = diskCaddy.SelectImage(caddyIndex); - if (diskImage && diskImage != pi1541.drive.GetDiskImage()) - { - pi1541.drive.Insert(diskImage); - break; - } - } - } - inputMappings->directDiskSwapRequest = 0; - } + // We have now output so HERE is where the next phi2 cycle starts. + pi1541.Update(); + bool reset = IEC_Bus::IsReset(); if (reset) @@ -1023,6 +997,36 @@ void emulator() while (ctAfter == ctBefore); } ctBefore = ctAfter; + + if (numberOfImages > 1) + { + bool nextDisk = inputMappings->NextDisk(); + bool prevDisk = inputMappings->PrevDisk(); + if (nextDisk) + { + pi1541.drive.Insert(diskCaddy.PrevDisk()); + } + else if (prevDisk) + { + pi1541.drive.Insert(diskCaddy.NextDisk()); + } + else if (inputMappings->directDiskSwapRequest != 0) + { + for (caddyIndex = 0; caddyIndex < numberOfImagesMax; ++caddyIndex) + { + if (inputMappings->directDiskSwapRequest & (1 << caddyIndex)) + { + DiskImage* diskImage = diskCaddy.SelectImage(caddyIndex); + if (diskImage && diskImage != pi1541.drive.GetDiskImage()) + { + pi1541.drive.Insert(diskImage); + break; + } + } + } + inputMappings->directDiskSwapRequest = 0; + } + } } } }