From c41ea162a250a0bd1b4e21412c99244236154795 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Sun, 24 Jun 2018 14:37:11 +1000 Subject: [PATCH] Added the option to auto mount a disk image (when resetting) This will enable poeple to use AR6, EFL or FC3 to load fb64. To do so create a disk image with FB64 on it. copy it to the SD card's 1541 folder. add the line "autoMountImage = fb.d64" to options.txt. Now whenever the drive is reset it will automatically mount the disk image. As it is emulating people can use their cart of choice to load it. Once loaded they can simply back out of the image and browse the SD card as usual. --- src/FileBrowser.cpp | 4 ++-- src/FileBrowser.h | 2 +- src/main.cpp | 18 +++++++++++++++++- src/options.cpp | 5 +++++ src/options.h | 2 ++ 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index 34b5ffc..27e9f82 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -1079,7 +1079,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI } } -void FileBrowser::AutoSelectTestImage() +void FileBrowser::AutoSelectImage(const char* image) { FileBrowser::BrowsableList::Entry* current = 0; int index; @@ -1088,7 +1088,7 @@ void FileBrowser::AutoSelectTestImage() for (index = 0; index < maxEntries; ++index) { current = &folder.entries[index]; - if (strcmp(current->filImage.fname, "someimage.g64") == 0) + if (strcasecmp(current->filImage.fname, image) == 0) { break; } diff --git a/src/FileBrowser.h b/src/FileBrowser.h index 7e314d0..bcef365 100644 --- a/src/FileBrowser.h +++ b/src/FileBrowser.h @@ -135,7 +135,7 @@ public: FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, unsigned deviceID, bool displayPNGIcons, ScreenBase* screenMain, ScreenBase* screenLCD); - void AutoSelectTestImage(); + void AutoSelectImage(const char* image); void DisplayRoot(); void UpdateInput(); diff --git a/src/main.cpp b/src/main.cpp index acfc0de..7e935b7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -593,6 +593,16 @@ 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) + { + const char* autoMountImageName = options.GetAutoMountImageName(); + if (autoMountImageName[0] != 0) + fileBrowser->AutoSelectImage(autoMountImageName); + } +} + void emulator() { bool oldLED = false; @@ -603,6 +613,7 @@ void emulator() bool selectedViaIECCommands = false; InputMappings* inputMappings = InputMappings::Instance(); FileBrowser* fileBrowser; + bool CD_ = false; roms.lastManualSelectedROMIndex = 0; @@ -642,6 +653,8 @@ void emulator() { m_IEC_Commands.SimulateIECBegin(); + CheckAutoMountImage(CD_, fileBrowser); + while (!emulating) { IEC_Commands::UpdateAction updateAction = m_IEC_Commands.SimulateIECUpdate(); @@ -653,10 +666,10 @@ void emulator() fileBrowser->DisplayRoot(); IEC_Bus::Reset(); m_IEC_Commands.SimulateIECBegin(); + CheckAutoMountImage(false, fileBrowser); break; case IEC_Commands::NONE: { - //fileBrowser->AutoSelectTestImage(); fileBrowser->UpdateInput(); // Check selections made via FileBrowser @@ -791,6 +804,7 @@ void emulator() // Exit full emulation back to IEC commands level simulation. snoopIndex = 0; emulating = false; + CD_ = true; } } else @@ -902,6 +916,8 @@ void emulator() fileBrowser->DisplayRoot();//m_IEC_Commands.ChangeToRoot(); // TO CHECK emulating = false; resetWhileEmulating = true; + if (reset || exitEmulation) + CD_ = false; break; } diff --git a/src/options.cpp b/src/options.cpp index 3d8e538..c776e9b 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -145,6 +145,7 @@ Options::Options(void) , i2cLcdFlip(0) , keyboardBrowseLCDScreen(0) { + autoMountImageName[0] = 0; strcpy(ROMFontName, "chargen"); starFileName[0] = 0; ROMName[0] = 0; @@ -186,6 +187,10 @@ void Options::Process(char* buffer) { strncpy(ROMFontName, pValue, 255); } + else if ((strcasecmp(pOption, "AutoMountImage") == 0)) + { + strncpy(autoMountImageName, pValue, 255); + } ELSE_CHECK_DECIMAL_OPTION(deviceID) ELSE_CHECK_DECIMAL_OPTION(onResetChangeToStartingFolder) ELSE_CHECK_DECIMAL_OPTION(extraRAM) diff --git a/src/options.h b/src/options.h index 9c9844a..1d1481e 100644 --- a/src/options.h +++ b/src/options.h @@ -46,6 +46,7 @@ public: inline unsigned int GetDeviceID() const { return deviceID; } inline unsigned int GetOnResetChangeToStartingFolder() const { return onResetChangeToStartingFolder; } + inline const char* GetAutoMountImageName() const { return autoMountImageName; } inline const char* GetRomFontName() const { return ROMFontName; } const char* GetRomName(int index) const; inline const char* GetStarFileName() const { return starFileName; } @@ -119,6 +120,7 @@ private: char starFileName[256]; char LCDName[256]; + char autoMountImageName[256]; char ROMFontName[256]; char ROMName[256]; char ROMNameSlot2[256];