Possible fix for #170 (although I can't reproduce it)

This commit is contained in:
Stephen White 2020-01-25 18:21:08 +11:00
parent 40b5feb576
commit 126400806b

View file

@ -327,6 +327,8 @@ void DiskCaddy::Display()
for (caddyIndex = 0; caddyIndex < numberOfImages; ++caddyIndex) for (caddyIndex = 0; caddyIndex < numberOfImages; ++caddyIndex)
{ {
DiskImage* image = GetImage(caddyIndex); DiskImage* image = GetImage(caddyIndex);
if (image)
{
const char* name = image->GetName(); const char* name = image->GetName();
if (name) if (name)
{ {
@ -338,6 +340,7 @@ void DiskCaddy::Display()
} }
} }
} }
}
#endif #endif
ShowSelectedImage(0); ShowSelectedImage(0);
} }
@ -346,6 +349,10 @@ void DiskCaddy::ShowSelectedImage(u32 index)
{ {
DiskImage* image = GetImage(index); DiskImage* image = GetImage(index);
if (image == 0)
{
return;
}
u32 x; u32 x;
u32 y; u32 y;
#if not defined(EXPERIMENTALZERO) #if not defined(EXPERIMENTALZERO)
@ -398,6 +405,8 @@ void DiskCaddy::ShowSelectedImage(u32 index)
for (; caddyIndex < numberOfImages; ++caddyIndex) for (; caddyIndex < numberOfImages; ++caddyIndex)
{ {
DiskImage* image = GetImage(caddyIndex); DiskImage* image = GetImage(caddyIndex);
if (image)
{
const char* name = image->GetName(); const char* name = image->GetName();
if (name) if (name)
{ {
@ -410,6 +419,7 @@ void DiskCaddy::ShowSelectedImage(u32 index)
if (y >= screenLCD->Height()) if (y >= screenLCD->Height())
break; break;
} }
}
while (y < screenLCD->Height()) { while (y < screenLCD->Height()) {
memset(buffer, ' ', screenLCD->Width()/screenLCD->GetFontWidth()); memset(buffer, ' ', screenLCD->Width()/screenLCD->GetFontWidth());
screenLCD->PrintText(false, x, y, buffer, BkColour, BkColour); screenLCD->PrintText(false, x, y, buffer, BkColour, BkColour);
@ -432,6 +442,8 @@ bool DiskCaddy::Update()
x = screen->ScaleX(screenPosXCaddySelections); x = screen->ScaleX(screenPosXCaddySelections);
y = screen->ScaleY(screenPosYCaddySelections) + 16 + 16 * oldCaddyIndex; y = screen->ScaleY(screenPosYCaddySelections) + 16 + 16 * oldCaddyIndex;
DiskImage* image = GetImage(oldCaddyIndex); DiskImage* image = GetImage(oldCaddyIndex);
if (image)
{
const char* name = image->GetName(); const char* name = image->GetName();
if (name) if (name)
{ {
@ -441,6 +453,7 @@ bool DiskCaddy::Update()
screen->PrintText(false, x, y, buffer, grey, greyDark); screen->PrintText(false, x, y, buffer, grey, greyDark);
} }
} }
}
#endif #endif
oldCaddyIndex = caddyIndex; oldCaddyIndex = caddyIndex;