From 3e83a573494a9f93882123cb551bc5e283714653 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Mon, 11 Jun 2018 19:31:24 +1000 Subject: [PATCH] Each disk write back is now displayed on screen(s) when modified images are unmounted. --- src/DiskCaddy.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++ src/DiskCaddy.h | 11 +-------- src/DiskImage.h | 2 ++ src/main.cpp | 4 +++ 4 files changed, 70 insertions(+), 10 deletions(-) diff --git a/src/DiskCaddy.cpp b/src/DiskCaddy.cpp index 1f89cfc..f4c6453 100644 --- a/src/DiskCaddy.cpp +++ b/src/DiskCaddy.cpp @@ -32,6 +32,69 @@ static char buffer[256] = { 0 }; static u32 white = RGBA(0xff, 0xff, 0xff, 0xff); static u32 red = RGBA(0xff, 0, 0, 0xff); +void DiskCaddy::Empty() +{ + int x; + int y; + int index; + for (index = 0; index < (int)disks.size(); ++index) + { + if (disks[index].IsDirty()) + { + if (screen) + { + x = screen->ScaleX(screenPosXCaddySelections); + y = screen->ScaleY(screenPosYCaddySelections); + + snprintf(buffer, 256, "Saving %s\r\n", disks[index].GetName()); + screen->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red); + } + + if (screenLCD) + { + RGBA BkColour = RGBA(0, 0, 0, 0xFF); + screenLCD->Clear(BkColour); + x = 0; + y = 0; + + snprintf(buffer, 256, "Saving"); + screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), BkColour); + y += 16; + snprintf(buffer, 256, "%s ", disks[index].GetName()); + screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red); + screenLCD->SwapBuffers(); + } + } + disks[index].Close(); + } + if (screen) + { + x = screen->ScaleX(screenPosXCaddySelections); + y = screen->ScaleY(screenPosYCaddySelections); + + snprintf(buffer, 256, "Saving Complete \r\n"); + screen->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red); + } + + if (screenLCD) + { + RGBA BkColour = RGBA(0, 0, 0, 0xFF); + screenLCD->Clear(BkColour); + x = 0; + y = 0; + + snprintf(buffer, 256, "Saving"); + screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), BkColour); + y += 16; + snprintf(buffer, 256, "Complete "); + screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red); + screenLCD->SwapBuffers(); + } + + disks.clear(); + selectedIndex = 0; +} + bool DiskCaddy::Insert(const FILINFO* fileInfo, bool readOnly) { int x; diff --git a/src/DiskCaddy.h b/src/DiskCaddy.h index 081cc85..d86e5e0 100644 --- a/src/DiskCaddy.h +++ b/src/DiskCaddy.h @@ -35,16 +35,7 @@ public: void SetScreen(Screen* screen, ScreenBase* screenLCD) { this->screen = screen; this->screenLCD = screenLCD; } - void Empty() - { - int index; - for (index = 0; index < (int)disks.size(); ++index) - { - disks[index].Close(); - } - disks.clear(); - selectedIndex = 0; - } + void Empty(); bool Insert(const FILINFO* fileInfo, bool readOnly); diff --git a/src/DiskImage.h b/src/DiskImage.h index efe3b91..3f2d60b 100644 --- a/src/DiskImage.h +++ b/src/DiskImage.h @@ -113,6 +113,8 @@ public: unsigned LastTrackUsed(); + bool IsDirty() const { return dirty; } + static unsigned char readBuffer[READBUFFER_SIZE]; private: diff --git a/src/main.cpp b/src/main.cpp index e35158b..2e686bb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -868,6 +868,10 @@ void emulator() // - TDOO: need to display the image names as they write back // - pass in a call back function? diskCaddy.Empty(); + IEC_Bus::WaitMicroSeconds(2 * 1000000); + + fileBrowser->ClearSelections(); + fileBrowser->RefeshDisplay(); // Just redisplay the current folder. IEC_Bus::WaitUntilReset(); //DEBUG_LOG("6502 resetting\r\n");