From ca10026adebdb4e74364e8d503f6dd484d2abf3a Mon Sep 17 00:00:00 2001 From: Stephen White Date: Sun, 17 Nov 2019 14:54:30 +1100 Subject: [PATCH] Added option DisplayTracks Displays a rough layout of data for a disk image on the Pi's HDMI screen. --- src/FileBrowser.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++ src/options.cpp | 2 ++ src/options.h | 2 ++ 3 files changed, 53 insertions(+) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index ff841e9..5b2ff78 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -1473,6 +1473,55 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI ClearScreen(); + if (options.DisplayTracks()) + { + for (track = 0; track < HALF_TRACK_COUNT; track += 2) + { + int yoffset = screenMain->ScaleY(400); + unsigned index; + unsigned length = diskImage->TrackLength(track); + unsigned countSync = 0; + + u8 shiftReg = 0; + for (index = 0; index < length / 8; ++index) + { + RGBA colour; + unsigned count1s = 0; + bool sync = false; + + int bit; + + for (bit = 0; bit < 64; ++bit) + { + if (bit % 8 == 0) + shiftReg = diskImage->GetNextByte(track, index * 8 + bit / 8); + + if (shiftReg & 0x80) + { + count1s++; + countSync++; + if (countSync == 10) + sync = true; + } + else + { + countSync = 0; + } + shiftReg <<= 1; + } + + if (sync) + colour = RGBA(0xff, 0x00, 0x00, 0xFF); + else + colour = RGBA(0x00, (unsigned char)((float)count1s / 64.0f * 255.0f), 0x00, 0xFF); + + screenMain->DrawRectangle(index, (track >> 1) * 4 + yoffset, index + 1, (track >> 1) * 4 + 4 + yoffset, colour); + } + } + } + + track = 18; + if (diskImage->GetDecodedSector(track, sectorNo, buffer)) { track = buffer[0]; diff --git a/src/options.cpp b/src/options.cpp index 18ebba9..1e7ad3b 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -128,6 +128,7 @@ Options::Options(void) , disableSD2IECCommands(0) , supportUARTInput(0) , graphIEC(0) + , displayTracks(0) , quickBoot(0) , showOptions(0) , displayPNGIcons(0) @@ -218,6 +219,7 @@ void Options::Process(char* buffer) ELSE_CHECK_DECIMAL_OPTION(disableSD2IECCommands) ELSE_CHECK_DECIMAL_OPTION(supportUARTInput) ELSE_CHECK_DECIMAL_OPTION(graphIEC) + ELSE_CHECK_DECIMAL_OPTION(displayTracks) ELSE_CHECK_DECIMAL_OPTION(quickBoot) ELSE_CHECK_DECIMAL_OPTION(showOptions) ELSE_CHECK_DECIMAL_OPTION(displayPNGIcons) diff --git a/src/options.h b/src/options.h index c3c8249..374dda0 100644 --- a/src/options.h +++ b/src/options.h @@ -60,6 +60,7 @@ public: inline unsigned int GetSupportUARTInput() const { return supportUARTInput; } inline unsigned int GraphIEC() const { return graphIEC; } + inline unsigned int DisplayTracks() const { return displayTracks; } inline unsigned int QuickBoot() const { return quickBoot; } inline unsigned int ShowOptions() const { return showOptions; } inline unsigned int DisplayPNGIcons() const { return displayPNGIcons; } @@ -128,6 +129,7 @@ private: unsigned int disableSD2IECCommands; unsigned int supportUARTInput; unsigned int graphIEC; + unsigned int displayTracks; unsigned int quickBoot; unsigned int showOptions; unsigned int displayPNGIcons;