From 746c9efb1d4124c711784143aba1a17c67202ee7 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Wed, 30 May 2018 20:38:14 +1000 Subject: [PATCH] Added option to specify which file LOAD"*" will actually load. --- src/iec_commands.cpp | 15 +++++++++++++++ src/iec_commands.h | 3 +++ src/main.cpp | 2 ++ src/options.cpp | 5 +++++ src/options.h | 3 +++ 5 files changed, 28 insertions(+) diff --git a/src/iec_commands.cpp b/src/iec_commands.cpp index 35a341b..7de995a 100644 --- a/src/iec_commands.cpp +++ b/src/iec_commands.cpp @@ -232,6 +232,7 @@ IEC_Commands::IEC_Commands() deviceID = 8; usingVIC20 = false; Reset(); + starFileName = 0; } void IEC_Commands::Reset(void) @@ -1810,6 +1811,20 @@ void IEC_Commands::OpenFile() text = ParseNextName(text, filemode, true); } + if (starFileName && starFileName[0] != 0 && filename[0] == '*') + { + char cwd[1024]; + if (f_getcwd(cwd, 1024) == FR_OK) + { + if (strcasecmp(cwd, "/1541") == 0) + { + DEBUG_LOG("use star %s\r\n", starFileName); + strncpy(filename, starFileName, sizeof(filename) - 1); + } + } + } + + if (toupper(filetype[0]) == 'L') { //DEBUG_LOG("Rel file\r\n"); diff --git a/src/iec_commands.h b/src/iec_commands.h index e441a6b..5f35dd0 100644 --- a/src/iec_commands.h +++ b/src/iec_commands.h @@ -77,6 +77,7 @@ public: const char* GetNameOfImageSelected() const { return selectedImageName; } const FILINFO* GetImageSelected() const { return &filInfoSelectedImage; } + void SetStarFileName(const char* fileName) { starFileName = fileName; } protected: enum ATNSequence { @@ -164,5 +165,7 @@ protected: char selectedImageName[256]; FILINFO filInfoSelectedImage; + + const char* starFileName; }; #endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 2797f92..1ebf65b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1204,6 +1204,8 @@ extern "C" f_chdir("/1541"); m_IEC_Commands.SetDeviceId(deviceID); + m_IEC_Commands.SetStarFileName(options.GetStarFileName()); + SetVIAsDeviceID(deviceID); pi1541.drive.SetVIA(&pi1541.VIA[1]); diff --git a/src/options.cpp b/src/options.cpp index ed16748..e3b1ea7 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -137,6 +137,7 @@ Options::Options(void) , screenHeight(768) { strcpy(ROMFontName, "chargen"); + starFileName[0] = 0; ROMName[0] = 0; ROMNameSlot2[0] = 0; ROMNameSlot3[0] = 0; @@ -257,6 +258,10 @@ void Options::Process(char* buffer) { strncpy(ROMFontName, pValue, 255); } + else if ((strcasecmp(pOption, "StarFileName") == 0)) + { + strncpy(starFileName, pValue, 255); + } else if ((strcasecmp(pOption, "ROM") == 0) || (strcasecmp(pOption, "ROM1") == 0)) { strncpy(ROMName, pValue, 255); diff --git a/src/options.h b/src/options.h index 8d2266d..d21a66c 100644 --- a/src/options.h +++ b/src/options.h @@ -48,6 +48,7 @@ public: unsigned int GetOnResetChangeToStartingFolder() const { return onResetChangeToStartingFolder; } const char* GetRomFontName() const { return ROMFontName; } const char* GetRomName(int index) const; + const char* GetStarFileName() const { return starFileName; } unsigned int GetExtraRAM() const { return extraRAM; } unsigned int GetRAMBOard() const { return enableRAMBOard; } unsigned int GetDisableSD2IECCommands() const { return disableSD2IECCommands; } @@ -86,6 +87,8 @@ private: unsigned int screenWidth; unsigned int screenHeight; + char starFileName[256]; + char ROMFontName[256]; char ROMName[256]; char ROMNameSlot2[256];