From ea071f0b466e630f8c09a91e32c0bc2017853c5a Mon Sep 17 00:00:00 2001 From: penfold42 Date: Mon, 23 Jul 2018 09:06:11 +1000 Subject: [PATCH 1/5] code cleanup --- src/iec_commands.cpp | 3 --- src/main.cpp | 22 ++++++++++------------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/iec_commands.cpp b/src/iec_commands.cpp index 0d70a2c..c3af2de 100644 --- a/src/iec_commands.cpp +++ b/src/iec_commands.cpp @@ -1100,9 +1100,6 @@ void IEC_Commands::New(void) { FILINFO filInfo; - if(!(strstr(filenameNew, ".d64") || strstr(filenameNew, ".D64"))) - strcat(filenameNew, ".d64"); - int ret = CreateD64(filenameNew, ID, true); if (ret==0) diff --git a/src/main.cpp b/src/main.cpp index 9a3b4b4..e6cda8c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -737,17 +737,14 @@ void emulator() CheckAutoMountImage(EXIT_UNKNOWN, fileBrowser); break; case IEC_Commands::NONE: - { - fileBrowser->Update(); + fileBrowser->Update(); - // Check selections made via FileBrowser - if (fileBrowser->SelectionsMade()) - emulating = BeginEmulating(fileBrowser, fileBrowser->LastSelectionName()); - } + // Check selections made via FileBrowser + if (fileBrowser->SelectionsMade()) + emulating = BeginEmulating(fileBrowser, fileBrowser->LastSelectionName()); break; case IEC_Commands::IMAGE_SELECTED: - { - // Check selections made via FileBrowser + // Check selections made via IEC commands (like fb64) fileBrowserSelectedName = m_IEC_Commands.GetNameOfImageSelected(); @@ -769,8 +766,10 @@ void emulator() DEBUG_LOG("IEC mounting %s\r\n", filInfoSelected->fname); bool readOnly = (filInfoSelected->fattrib & AM_RDO) != 0; - if (diskCaddy.Insert(filInfoSelected, readOnly)) emulating = BeginEmulating(fileBrowser, filInfoSelected->fname); - else fileBrowserSelectedName = 0; + if (diskCaddy.Insert(filInfoSelected, readOnly)) + emulating = BeginEmulating(fileBrowser, filInfoSelected->fname); + else + fileBrowserSelectedName = 0; } else { @@ -781,8 +780,7 @@ void emulator() m_IEC_Commands.Reset(); selectedViaIECCommands = true; - } - break; + break; case IEC_Commands::DIR_PUSHED: fileBrowser->FolderChanged(); break; From 4469165e8af2c55e212c65935b139298725ba8b2 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Mon, 30 Jul 2018 20:04:54 +1000 Subject: [PATCH 2/5] Add ' R' to readonly file in filebrowser oled display --- src/FileBrowser.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index d5918bb..f3049b6 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -102,10 +102,17 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b } else { + char ROstring[8] = { 0 }; + if (entry->filImage.fattrib & AM_RDO) + strncpy (ROstring, " R", 8); if (entry->caddyIndex != -1) - snprintf(buffer2, 256, "%d>%s", entry->caddyIndex, entry->filImage.fname); + snprintf(buffer2, 256, "%d>%s%s" + , entry->caddyIndex + , entry->filImage.fname + , ROstring + ); else - snprintf(buffer2, 256, "%s", entry->filImage.fname); + snprintf(buffer2, 256, "%s%s", entry->filImage.fname, ROstring); } } else From 0ddf2a6e0ab42eb50b44c8e0d5364b0b2e1ab4b2 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Mon, 30 Jul 2018 22:24:07 +1000 Subject: [PATCH 3/5] In browser on oled, add '<' for readonly files fix potential out by error/buffer overflow --- src/FileBrowser.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index f3049b6..6768a7e 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -88,8 +88,8 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b RGBA BkColour = RGBA(0, 0, 0, 0xFF); //palette[VIC2_COLOUR_INDEX_BLUE]; u32 columnsMax = columns; - if (columnsMax > sizeof(buffer1)) - columnsMax = sizeof(buffer1); + if (columnsMax > sizeof(buffer1)-1) + columnsMax = sizeof(buffer1)-1; if (entryIndex < list->entries.size()) { @@ -104,7 +104,7 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b { char ROstring[8] = { 0 }; if (entry->filImage.fattrib & AM_RDO) - strncpy (ROstring, " R", 8); + strncpy (ROstring, "<", 8); if (entry->caddyIndex != -1) snprintf(buffer2, 256, "%d>%s%s" , entry->caddyIndex @@ -157,7 +157,7 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b } else { - memset(buffer1, ' ', 80); + memset(buffer1, ' ', columnsMax); screen->PrintText(false, x, y, buffer1, BkColour, BkColour); } } @@ -203,10 +203,17 @@ void FileBrowser::BrowsableListView::RefreshHighlightScroll() } else { + char ROstring[8] = { 0 }; + if (entry->filImage.fattrib & AM_RDO) + strncpy (ROstring, "<", 8); if (entry->caddyIndex != -1) - snprintf(buffer2, 256, "%d>%s", entry->caddyIndex, entry->filImage.fname); + snprintf(buffer2, 256, "%d>%s%s" + , entry->caddyIndex + , entry->filImage.fname + , ROstring + ); else - snprintf(buffer2, 256, "%s", entry->filImage.fname); + snprintf(buffer2, 256, "%s%s", entry->filImage.fname, ROstring); } } else From 62216afe2a2fcd69574d39ce97c637cbafb5c282 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Mon, 30 Jul 2018 22:41:05 +1000 Subject: [PATCH 4/5] In browser on oled, add '<' for readonly files Also: - fix potential out by error/buffer overflow - code formatting cleanup - remove superfluous *.d64 filename check --- src/FileBrowser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index 6768a7e..9dcb9b9 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -528,7 +528,7 @@ void FileBrowser::FolderChanged() void FileBrowser::DisplayRoot() { - f_chdir("\\1541"); + f_chdir("/1541"); FolderChanged(); } From a6e6a01b2684de101345711414ccfe175ccf1167 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Wed, 1 Aug 2018 14:56:27 +1000 Subject: [PATCH 5/5] Cleanup deviceID change code --- src/main.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bd5f501..44bd790 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -635,17 +635,12 @@ static void PlaySoundDMA() write32(DMA0_BASE + DMA_CS, DMA_ACTIVE); } -static void SetVIAsDeviceID(u8 id) -{ - pi1541.VIA[0].GetPortB()->SetInput(VIAPORTPINS_DEVSEL0, id & 1); - pi1541.VIA[0].GetPortB()->SetInput(VIAPORTPINS_DEVSEL1, id & 2); -} - void GlobalSetDeviceID(u8 id) { deviceID = id; m_IEC_Commands.SetDeviceId(id); - SetVIAsDeviceID(id); + pi1541.VIA[0].GetPortB()->SetInput(VIAPORTPINS_DEVSEL0, id & 1); + pi1541.VIA[0].GetPortB()->SetInput(VIAPORTPINS_DEVSEL1, id & 2); } void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowser) @@ -796,7 +791,6 @@ void emulator() case IEC_Commands::DEVICEID_CHANGED: GlobalSetDeviceID( m_IEC_Commands.GetDeviceId() ); fileBrowser->ShowDeviceAndROM(); - SetVIAsDeviceID(deviceID); // Let the emulated VIA know break; default: break; @@ -1344,10 +1338,9 @@ extern "C" f_chdir("/1541"); - m_IEC_Commands.SetDeviceId(deviceID); m_IEC_Commands.SetStarFileName(options.GetStarFileName()); - SetVIAsDeviceID(deviceID); + GlobalSetDeviceID(deviceID); pi1541.drive.SetVIA(&pi1541.VIA[1]); pi1541.VIA[0].GetPortB()->SetPortOut(0, IEC_Bus::PortB_OnPortOut);