From cb04179fc9ce167d2ab5093754bbbfdc7127b159 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Sat, 15 Dec 2018 15:44:37 +1100 Subject: [PATCH] Added option to lowercase all filenames passed back to FB* --- src/iec_commands.cpp | 15 ++++++++++++--- src/iec_commands.h | 5 +++++ src/main.cpp | 1 + src/options.cpp | 2 ++ src/options.h | 5 +++++ 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/iec_commands.cpp b/src/iec_commands.cpp index e39a930..dd91908 100644 --- a/src/iec_commands.cpp +++ b/src/iec_commands.cpp @@ -243,6 +243,7 @@ IEC_Commands::IEC_Commands() starFileName = 0; C128BootSectorName = 0; displayingDevices = false; + lowercaseBrowseModeFilenames = false; } void IEC_Commands::Reset(void) @@ -1602,6 +1603,14 @@ void IEC_Commands::SendError() while (!finalByte); } +u8 IEC_Commands::GetFilenameCharacter(u8 value) +{ + if (lowercaseBrowseModeFilenames) + value = tolower(value); + + return ascii2petscii(value); +} + void IEC_Commands::AddDirectoryEntry(Channel& channel, const char* name, u16 blocks, int fileType) { u8* data = channel.buffer + channel.cursor; @@ -1640,20 +1649,20 @@ void IEC_Commands::AddDirectoryEntry(Channel& channel, const char* name, u16 blo do { - data[index + i++] = ascii2petscii(*name++); + data[index + i++] = GetFilenameCharacter(*name++); } while (!(*name == 0x22 || *name == 0 || i == CBM_NAME_LENGTH_MINUS_D64)); for (int extIndex = 0; extIndex < 4; ++extIndex) { - data[index + i++] = ascii2petscii(*extName++); + data[index + i++] = GetFilenameCharacter(*extName++); } } else { do { - data[index + i++] = ascii2petscii(*name++); + data[index + i++] = GetFilenameCharacter(*name++); } while (!(*name == 0x22 || *name == 0 || i == CBM_NAME_LENGTH)); } diff --git a/src/iec_commands.h b/src/iec_commands.h index cb04db4..fdf0030 100644 --- a/src/iec_commands.h +++ b/src/iec_commands.h @@ -72,6 +72,8 @@ public: void SetDeviceId(u8 id) { deviceID = id; } u8 GetDeviceId() { return deviceID; } + void SetLowercaseBrowseModeFilenames(bool value) { lowercaseBrowseModeFilenames = value; } + void SetAutoBootFB128(bool autoBootFB128) { this->autoBootFB128 = autoBootFB128; } void Set128BootSectorName(const char* SectorName) { @@ -165,6 +167,8 @@ protected: bool SendBuffer(Channel& channel, bool eoi); + u8 GetFilenameCharacter(u8 value); + UpdateAction updateAction; u8 commandCode; bool receivedCommand : 1; @@ -188,6 +192,7 @@ protected: const char* C128BootSectorName; bool displayingDevices; + bool lowercaseBrowseModeFilenames; }; #endif diff --git a/src/main.cpp b/src/main.cpp index 9733ed7..def4e72 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1051,6 +1051,7 @@ void emulator() m_IEC_Commands.SetAutoBootFB128(options.AutoBootFB128()); m_IEC_Commands.Set128BootSectorName(options.Get128BootSectorName()); + m_IEC_Commands.SetLowercaseBrowseModeFilenames(options.LowercaseBrowseModeFilenames()); emulating = IEC_COMMANDS; diff --git a/src/options.cpp b/src/options.cpp index 0d32241..0d3af35 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -139,6 +139,7 @@ Options::Options(void) , splitIECLines(0) , ignoreReset(0) , autoBootFB128(0) + , lowercaseBrowseModeFilenames(0) , screenWidth(1024) , screenHeight(768) , i2cBusMaster(1) @@ -223,6 +224,7 @@ void Options::Process(char* buffer) ELSE_CHECK_DECIMAL_OPTION(invertIECOutputs) ELSE_CHECK_DECIMAL_OPTION(splitIECLines) ELSE_CHECK_DECIMAL_OPTION(ignoreReset) + ELSE_CHECK_DECIMAL_OPTION(lowercaseBrowseModeFilenames) ELSE_CHECK_DECIMAL_OPTION(autoBootFB128) ELSE_CHECK_DECIMAL_OPTION(screenWidth) ELSE_CHECK_DECIMAL_OPTION(screenHeight) diff --git a/src/options.h b/src/options.h index 8b1972a..8a11bee 100644 --- a/src/options.h +++ b/src/options.h @@ -73,6 +73,9 @@ public: inline unsigned int AutoBootFB128() const { return autoBootFB128; } inline const char* Get128BootSectorName() const { return C128BootSectorName; } + inline unsigned int LowercaseBrowseModeFilenames() const { return lowercaseBrowseModeFilenames; } + + inline unsigned int ScreenWidth() const { return screenWidth; } inline unsigned int ScreenHeight() const { return screenHeight; } @@ -126,6 +129,8 @@ private: unsigned int ignoreReset; unsigned int autoBootFB128; + unsigned int lowercaseBrowseModeFilenames; + unsigned int screenWidth; unsigned int screenHeight;