use bitmap view of the BAM (rather than characters)

scale bitmap view to PNG size

guess 40 track format for BAM display

rename ClearArea to DrawRectangle
This commit is contained in:
penfold42 2018-08-11 17:14:17 +10:00
parent 83f6d5fae1
commit 0115e66f09
6 changed files with 74 additions and 40 deletions

View File

@ -713,7 +713,7 @@ void FileBrowser::RefeshDisplay()
char buffer[1024]; char buffer[1024];
if (f_getcwd(buffer, 1024) == FR_OK) if (f_getcwd(buffer, 1024) == FR_OK)
{ {
screenMain->ClearArea(0, 0, (int)screenMain->Width(), 17, bgColour); screenMain->DrawRectangle(0, 0, (int)screenMain->Width(), 17, bgColour);
screenMain->PrintText(false, 0, 0, buffer, textColour, bgColour); screenMain->PrintText(false, 0, 0, buffer, textColour, bgColour);
} }
@ -801,8 +801,8 @@ void FileBrowser::DisplayPNG()
if (displayPNGIcons && folder.current) if (displayPNGIcons && folder.current)
{ {
FileBrowser::BrowsableList::Entry* current = folder.current; FileBrowser::BrowsableList::Entry* current = folder.current;
u32 x = screenMain->ScaleX(1024 - 320); u32 x = screenMain->ScaleX(1024) - PNG_WIDTH;
u32 y = screenMain->ScaleY(666) - 240; u32 y = screenMain->ScaleY(666) - PNG_HEIGHT;
DisplayPNG(current->filIcon, x, y); DisplayPNG(current->filIcon, x, y);
} }
} }
@ -1304,8 +1304,13 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
u32 usedColour = palette[VIC2_COLOUR_INDEX_RED]; u32 usedColour = palette[VIC2_COLOUR_INDEX_RED];
u32 freeColour = palette[VIC2_COLOUR_INDEX_LGREEN]; u32 freeColour = palette[VIC2_COLOUR_INDEX_LGREEN];
u32 thisColour = 0;
u32 BAMOffsetX = screenMain->ScaleX(400); u32 BAMOffsetX = screenMain->ScaleX(400);
u32 bmBAMOffsetX = screenMain->ScaleX(1024) - PNG_WIDTH;
u32 x_px = 0;
u32 y_px = 0;
ClearScreen(); ClearScreen();
if (diskImage->GetDecodedSector(track, sectorNo, buffer)) if (diskImage->GetDecodedSector(track, sectorNo, buffer))
@ -1319,49 +1324,78 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
//165,166 ($A5,$A6) $32,$41 ASCII chars "2A" DOS indicator //165,166 ($A5,$A6) $32,$41 ASCII chars "2A" DOS indicator
//167-170 ($A7-$AA) $A0 Shift Space //167-170 ($A7-$AA) $A0 Shift Space
//171-255 ($AB-$FF) $00 Not used, filled with zero (The bytes 180 to 191 can have the contents "blocks free" on many disks.) //171-255 ($AB-$FF) $00 Not used, filled with zero (The bytes 180 to 191 can have the contents "blocks free" on many disks.)
//AB-FF: Normally unused ($00), except for 40 track extended format,
// see the following two entries:
//AC-BF: DOLPHIN DOS track 36-40 BAM entries (only for 40 track)
//C0-D3: SPEED DOS track 36-40 BAM entries (only for 40 track)
strncpy(name, (char*)&buffer[144], 16); strncpy(name, (char*)&buffer[144], 16);
int blocksFree = 0; int blocksFree = 0;
int bamTrack; int bamTrack;
int lastTrackUsed = (int)diskImage->LastTrackUsed() >> 1; int lastTrackUsed = (int)diskImage->LastTrackUsed() >> 1; // 0..34 (or 39)
for (bamTrack = 0; bamTrack < 35; ++bamTrack) int bamOffset = BAM_OFFSET;
{ int guess40 = 0;
if ((bamTrack + 1) != 18)
blocksFree += buffer[BAM_OFFSET + bamTrack * BAM_ENTRY_SIZE];
x = BAMOffsetX; x_px = bmBAMOffsetX;
int x_size = PNG_WIDTH/lastTrackUsed;
int y_size = PNG_HEIGHT/21;
// try to guess the 40 track format
if (lastTrackUsed == 39)
{
int dolphin_sum = 0;
int speeddos_sum = 0;
for (int i=0; i<20; i++)
{
dolphin_sum += buffer[0xac+i];
speeddos_sum += buffer[0xc0+i];
}
if ( dolphin_sum == 0 && speeddos_sum != 0)
guess40 = 0xc0;
if ( dolphin_sum != 0 && speeddos_sum == 0)
guess40 = 0xac;
// debugging
//snprintf(bufferOut, 128, "LTU %d dd %d sd %d g40 %d", lastTrackUsed, dolphin_sum, speeddos_sum, guess40);
//screenMain->PrintText(false, x_px, PNG_HEIGHT+30, bufferOut, textColour, bgColour);
}
for (bamTrack = 0; bamTrack <= lastTrackUsed; ++bamTrack)
{
if (bamTrack >= 35)
bamOffset = guess40;
else
bamOffset = BAM_OFFSET;
if (bamOffset && (bamTrack + 1) != 18)
blocksFree += buffer[bamOffset + bamTrack * BAM_ENTRY_SIZE];
y_px = 0;
for (int bit = 0; bit < DiskImage::SectorsPerTrack[bamTrack]; bit++) for (int bit = 0; bit < DiskImage::SectorsPerTrack[bamTrack]; bit++)
{ {
u32 bits = buffer[BAM_OFFSET + 1 + (bit >> 3) + bamTrack * BAM_ENTRY_SIZE]; u32 bits = buffer[bamOffset + 1 + (bit >> 3) + bamTrack * BAM_ENTRY_SIZE];
bool used = (bits & (1 << (bit & 0x7))) == 0;
if (!used) if (!guess40 && bamTrack>= 35)
{ thisColour = 0;
snprintf(bufferOut, 128, "%c", screen2petscii(87)); else if (bits & (1 << (bit & 0x7)))
screenMain->PrintText(true, x, y, bufferOut, usedColour, bgColour); thisColour = freeColour;
}
else else
{ thisColour = usedColour;
snprintf(bufferOut, 128, "%c", screen2petscii(81));
screenMain->PrintText(true, x, y, bufferOut, freeColour, bgColour); // highight track 18
} if ((bamTrack + 1) == 18)
x += 8; screenMain->DrawRectangle(x_px, y_px, x_px+x_size, y_px+y_size, textColour);
screenMain->DrawRectangle(x_px+1, y_px+1, x_px+x_size-1, y_px+y_size-1, thisColour);
y_px += y_size;
bits <<= 1; bits <<= 1;
} }
y += fontHeight; x_px += x_size;
}
for (; bamTrack < lastTrackUsed; ++bamTrack)
{
x = BAMOffsetX;
for (int bit = 0; bit < DiskImage::SectorsPerTrack[bamTrack]; bit++)
{
snprintf(bufferOut, 128, "%c", screen2petscii(87));
screenMain->PrintText(true, x, y, bufferOut, usedColour, bgColour);
x += 8;
}
y += fontHeight;
} }
x = 0; x = 0;
y = 0; y = 0;
snprintf(bufferOut, 128, "0"); snprintf(bufferOut, 128, "0");

View File

@ -146,7 +146,7 @@ void Screen::PlotPixel8(u32 pixel_offset, RGBA Colour)
framebuffer[pixel_offset++] = RED(Colour); framebuffer[pixel_offset++] = RED(Colour);
} }
void Screen::ClearArea(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour) void Screen::DrawRectangle(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour)
{ {
ClipRect(x1, y1, x2, y2); ClipRect(x1, y1, x2, y2);
@ -182,7 +182,7 @@ void Screen::ScrollArea(u32 x1, u32 y1, u32 x2, u32 y2)
void Screen::Clear(RGBA colour) void Screen::Clear(RGBA colour)
{ {
ClearArea(0, 0, width, height, colour); DrawRectangle(0, 0, width, height, colour);
} }
u32 Screen::GetFontHeight() u32 Screen::GetFontHeight()
@ -299,7 +299,7 @@ u32 Screen::PrintText(bool petscii, u32 x, u32 y, char *ptr, RGBA TxtColour, RGB
{ {
if (!measureOnly) if (!measureOnly)
{ {
ClearArea(xCursor, yCursor, xCursor + BitFontWth, yCursor + fontHeight, BkColour); DrawRectangle(xCursor, yCursor, xCursor + BitFontWth, yCursor + fontHeight, BkColour);
WriteChar(petscii, xCursor, yCursor, c, TxtColour); WriteChar(petscii, xCursor, yCursor, c, TxtColour);
} }
xCursor += BitFontWth; xCursor += BitFontWth;

View File

@ -32,7 +32,7 @@ public:
void Open(u32 width, u32 height, u32 colourDepth); void Open(u32 width, u32 height, u32 colourDepth);
void ClearArea(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour); void DrawRectangle(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour);
void Clear(RGBA colour); void Clear(RGBA colour);
void ScrollArea(u32 x1, u32 y1, u32 x2, u32 y2); void ScrollArea(u32 x1, u32 y1, u32 x2, u32 y2);

View File

@ -46,7 +46,7 @@ public:
{ {
} }
virtual void ClearArea(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour) = 0; virtual void DrawRectangle(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour) = 0;
virtual void Clear(RGBA colour) = 0; virtual void Clear(RGBA colour) = 0;
virtual void ScrollArea(u32 x1, u32 y1, u32 x2, u32 y2) = 0; virtual void ScrollArea(u32 x1, u32 y1, u32 x2, u32 y2) = 0;

View File

@ -47,7 +47,7 @@ void ScreenLCD::Open(u32 widthDesired, u32 heightDesired, u32 colourDepth, int B
opened = true; opened = true;
} }
void ScreenLCD::ClearArea(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour) void ScreenLCD::DrawRectangle(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour)
{ {
ClipRect(x1, y1, x2, y2); ClipRect(x1, y1, x2, y2);
} }

View File

@ -35,7 +35,7 @@ public:
void Open(u32 width, u32 height, u32 colourDepth, int BSCMaster, int LCDAddress, int LCDFlip, LCD_MODEL LCDType); void Open(u32 width, u32 height, u32 colourDepth, int BSCMaster, int LCDAddress, int LCDFlip, LCD_MODEL LCDType);
void ClearArea(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour); void DrawRectangle(u32 x1, u32 y1, u32 x2, u32 y2, RGBA colour);
void Clear(RGBA colour); void Clear(RGBA colour);
void ClearInit(RGBA colour); void ClearInit(RGBA colour);