Fix for 128x32 displays during emulation

Clean up redundant if (screenLCD)
clean up to support variable LCD font height in future
This commit is contained in:
penfold42 2018-07-27 12:08:16 +10:00
parent 369e2ff800
commit 980712cfda
1 changed files with 38 additions and 39 deletions

View File

@ -32,6 +32,8 @@ static char buffer[256] = { 0 };
static u32 white = RGBA(0xff, 0xff, 0xff, 0xff); static u32 white = RGBA(0xff, 0xff, 0xff, 0xff);
static u32 red = RGBA(0xff, 0, 0, 0xff); static u32 red = RGBA(0xff, 0, 0, 0xff);
#define LCDFONTHEIGHT 16
bool DiskCaddy::Empty() bool DiskCaddy::Empty()
{ {
int x; int x;
@ -62,7 +64,7 @@ bool DiskCaddy::Empty()
snprintf(buffer, 256, "Saving"); snprintf(buffer, 256, "Saving");
screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), BkColour); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), BkColour);
y += 16; y += LCDFONTHEIGHT;
snprintf(buffer, 256, "%s ", disks[index].GetName()); snprintf(buffer, 256, "%s ", disks[index].GetName());
screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red);
screenLCD->SwapBuffers(); screenLCD->SwapBuffers();
@ -91,7 +93,7 @@ bool DiskCaddy::Empty()
snprintf(buffer, 256, "Saving"); snprintf(buffer, 256, "Saving");
screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), BkColour); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), BkColour);
y += 16; y += LCDFONTHEIGHT;
snprintf(buffer, 256, "Complete "); snprintf(buffer, 256, "Complete ");
screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red);
screenLCD->SwapBuffers(); screenLCD->SwapBuffers();
@ -130,7 +132,7 @@ bool DiskCaddy::Insert(const FILINFO* fileInfo, bool readOnly)
snprintf(buffer, 256, "Loading"); snprintf(buffer, 256, "Loading");
screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), BkColour); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), BkColour);
y += 16; y += LCDFONTHEIGHT;
snprintf(buffer, 256, "%s ", fileInfo->fname); snprintf(buffer, 256, "%s ", fileInfo->fname);
screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red);
screenLCD->SwapBuffers(); screenLCD->SwapBuffers();
@ -282,24 +284,22 @@ void DiskCaddy::ShowSelectedImage(u32 index)
if (screenLCD) if (screenLCD)
{ {
unsigned numberOfImages = GetNumberOfImages(); unsigned numberOfImages = GetNumberOfImages();
unsigned numberOfDisplayedImages = screenLCD->Height()/LCDFONTHEIGHT-1;
unsigned caddyIndex; unsigned caddyIndex;
if (screenLCD)
{
RGBA BkColour = RGBA(0, 0, 0, 0xFF); RGBA BkColour = RGBA(0, 0, 0, 0xFF);
//screenLCD->Clear(BkColour); //screenLCD->Clear(BkColour);
x = 0; x = 0;
y = 0; y = 0;
//snprintf(buffer, 256, "Emulating %d/%d ", index + 1, numberOfImages);
snprintf(buffer, 256, " D %d/%d ", index + 1, numberOfImages); snprintf(buffer, 256, " D %d/%d ", index + 1, numberOfImages);
screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), RGBA(0xff, 0xff, 0xff, 0xff)); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), RGBA(0xff, 0xff, 0xff, 0xff));
y += 16; y += LCDFONTHEIGHT;
if (numberOfImages > 3 && index > 2) if (numberOfImages > numberOfDisplayedImages && index > numberOfDisplayedImages-1)
{ {
if (numberOfImages - index < 3) if (numberOfImages - index < numberOfDisplayedImages)
caddyIndex = numberOfImages - 3; caddyIndex = numberOfImages - numberOfDisplayedImages;
else else
caddyIndex = index; caddyIndex = index;
} }
@ -316,14 +316,13 @@ void DiskCaddy::ShowSelectedImage(u32 index)
{ {
snprintf(buffer, 256, "%d %s ", caddyIndex + 1, name); snprintf(buffer, 256, "%d %s ", caddyIndex + 1, name);
screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), caddyIndex == index ? RGBA(0xff, 0xff, 0xff, 0xff) : BkColour); screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), caddyIndex == index ? RGBA(0xff, 0xff, 0xff, 0xff) : BkColour);
y += 16; y += LCDFONTHEIGHT;
} }
if (y >= screenLCD->Height()) if (y >= screenLCD->Height())
break; break;
} }
screenLCD->SwapBuffers(); screenLCD->SwapBuffers();
} }
}
} }
bool DiskCaddy::Update() bool DiskCaddy::Update()