Correct a bug on displaying caddy content when using 8bit height font
(like CBM font) This time, with the correct y coordinate usage.
This commit is contained in:
parent
39e737e935
commit
e8e0b8428b
4 changed files with 260 additions and 260 deletions
|
@ -298,7 +298,7 @@ void DiskCaddy::ShowSelectedImage(u32 index)
|
||||||
if (screenLCD)
|
if (screenLCD)
|
||||||
{
|
{
|
||||||
unsigned numberOfImages = GetNumberOfImages();
|
unsigned numberOfImages = GetNumberOfImages();
|
||||||
unsigned numberOfDisplayedImages = screenLCD->Height()/screenLCD->GetFontHeight()-1;
|
unsigned numberOfDisplayedImages = (screenLCD->Height()/screenLCD->GetFontHeight())-1;
|
||||||
unsigned caddyIndex;
|
unsigned caddyIndex;
|
||||||
|
|
||||||
RGBA BkColour = RGBA(0, 0, 0, 0xFF);
|
RGBA BkColour = RGBA(0, 0, 0, 0xFF);
|
||||||
|
|
212
src/DiskCaddy.h
212
src/DiskCaddy.h
|
@ -1,107 +1,107 @@
|
||||||
// Pi1541 - A Commodore 1541 disk drive emulator
|
// Pi1541 - A Commodore 1541 disk drive emulator
|
||||||
// Copyright(C) 2018 Stephen White
|
// Copyright(C) 2018 Stephen White
|
||||||
//
|
//
|
||||||
// This file is part of Pi1541.
|
// This file is part of Pi1541.
|
||||||
//
|
//
|
||||||
// Pi1541 is free software : you can redistribute it and/or modify
|
// Pi1541 is free software : you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
// (at your option) any later version.
|
// (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Pi1541 is distributed in the hope that it will be useful,
|
// Pi1541 is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pi1541. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pi1541. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#ifndef DISKCADDY_H
|
#ifndef DISKCADDY_H
|
||||||
#define DISKCADDY_H
|
#define DISKCADDY_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "DiskImage.h"
|
#include "DiskImage.h"
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
|
|
||||||
class DiskCaddy
|
class DiskCaddy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DiskCaddy()
|
DiskCaddy()
|
||||||
: selectedIndex(0)
|
: selectedIndex(0)
|
||||||
, screen(0)
|
, screen(0)
|
||||||
, screenLCD(0)
|
, screenLCD(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetScreen(Screen* screen, ScreenBase* screenLCD) { this->screen = screen; this->screenLCD = screenLCD; }
|
void SetScreen(Screen* screen, ScreenBase* screenLCD) { this->screen = screen; this->screenLCD = screenLCD; }
|
||||||
|
|
||||||
bool Empty();
|
bool Empty();
|
||||||
|
|
||||||
bool Insert(const FILINFO* fileInfo, bool readOnly);
|
bool Insert(const FILINFO* fileInfo, bool readOnly);
|
||||||
|
|
||||||
DiskImage* GetCurrentDisk()
|
DiskImage* GetCurrentDisk()
|
||||||
{
|
{
|
||||||
if (selectedIndex < disks.size())
|
if (selectedIndex < disks.size())
|
||||||
return &disks[selectedIndex];
|
return &disks[selectedIndex];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiskImage* NextDisk()
|
DiskImage* NextDisk()
|
||||||
{
|
{
|
||||||
selectedIndex = (selectedIndex + 1) % (u32)disks.size();
|
selectedIndex = (selectedIndex + 1) % (u32)disks.size();
|
||||||
return GetCurrentDisk();
|
return GetCurrentDisk();
|
||||||
}
|
}
|
||||||
|
|
||||||
DiskImage* PrevDisk()
|
DiskImage* PrevDisk()
|
||||||
{
|
{
|
||||||
--selectedIndex;
|
--selectedIndex;
|
||||||
if ((int)selectedIndex < 0)
|
if ((int)selectedIndex < 0)
|
||||||
selectedIndex += (u32)disks.size();
|
selectedIndex += (u32)disks.size();
|
||||||
return GetCurrentDisk();
|
return GetCurrentDisk();
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GetNumberOfImages() const { return disks.size(); }
|
u32 GetNumberOfImages() const { return disks.size(); }
|
||||||
u32 GetSelectedIndex() const { return selectedIndex; }
|
u32 GetSelectedIndex() const { return selectedIndex; }
|
||||||
|
|
||||||
DiskImage* GetImage(unsigned index) { return &disks[index]; }
|
DiskImage* GetImage(unsigned index) { return &disks[index]; }
|
||||||
DiskImage* SelectImage(unsigned index)
|
DiskImage* SelectImage(unsigned index)
|
||||||
{
|
{
|
||||||
if (selectedIndex != index && index < disks.size())
|
if (selectedIndex != index && index < disks.size())
|
||||||
{
|
{
|
||||||
selectedIndex = index;
|
selectedIndex = index;
|
||||||
return GetCurrentDisk();
|
return GetCurrentDisk();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DiskImage* SelectFirstImage()
|
DiskImage* SelectFirstImage()
|
||||||
{
|
{
|
||||||
if (disks.size())
|
if (disks.size())
|
||||||
{
|
{
|
||||||
selectedIndex = 0;
|
selectedIndex = 0;
|
||||||
return GetCurrentDisk();
|
return GetCurrentDisk();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display();
|
void Display();
|
||||||
bool Update();
|
bool Update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool InsertD64(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
bool InsertD64(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
||||||
bool InsertG64(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
bool InsertG64(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
||||||
bool InsertNIB(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
bool InsertNIB(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
||||||
bool InsertNBZ(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
bool InsertNBZ(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
||||||
bool InsertD81(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
bool InsertD81(const FILINFO* fileInfo, unsigned char* diskImageData, unsigned size, bool readOnly);
|
||||||
|
|
||||||
void ShowSelectedImage(u32 index);
|
void ShowSelectedImage(u32 index);
|
||||||
|
|
||||||
std::vector<DiskImage> disks;
|
std::vector<DiskImage> disks;
|
||||||
u32 selectedIndex;
|
u32 selectedIndex;
|
||||||
u32 oldCaddyIndex;
|
u32 oldCaddyIndex;
|
||||||
|
|
||||||
Screen* screen;
|
ScreenBase* screen;
|
||||||
ScreenBase* screenLCD;
|
ScreenBase* screenLCD;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -181,7 +181,7 @@ void FileBrowser::BrowsableListView::Refresh()
|
||||||
entryIndex = offset + index;
|
entryIndex = offset + index;
|
||||||
|
|
||||||
RefreshLine(entryIndex, x, y, /*showSelected && */list->currentIndex == entryIndex);
|
RefreshLine(entryIndex, x, y, /*showSelected && */list->currentIndex == entryIndex);
|
||||||
y += 16;
|
y += screen->GetFontHeight ();
|
||||||
}
|
}
|
||||||
|
|
||||||
screen->SwapBuffers();
|
screen->SwapBuffers();
|
||||||
|
@ -248,7 +248,7 @@ void FileBrowser::BrowsableListView::RefreshHighlightScroll()
|
||||||
int rowIndex = list->currentIndex - offset;
|
int rowIndex = list->currentIndex - offset;
|
||||||
|
|
||||||
u32 y = positionY;
|
u32 y = positionY;
|
||||||
y += rowIndex * 16;
|
y += rowIndex * screen->GetFontHeight ();
|
||||||
|
|
||||||
RefreshLine(list->currentIndex, 0, y, true);
|
RefreshLine(list->currentIndex, 0, y, true);
|
||||||
|
|
||||||
|
|
|
@ -1,152 +1,152 @@
|
||||||
// Pi1541 - A Commodore 1541 disk drive emulator
|
// Pi1541 - A Commodore 1541 disk drive emulator
|
||||||
// Copyright(C) 2018 Stephen White
|
// Copyright(C) 2018 Stephen White
|
||||||
//
|
//
|
||||||
// This file is part of Pi1541.
|
// This file is part of Pi1541.
|
||||||
//
|
//
|
||||||
// Pi1541 is free software : you can redistribute it and/or modify
|
// Pi1541 is free software : you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
// (at your option) any later version.
|
// (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Pi1541 is distributed in the hope that it will be useful,
|
// Pi1541 is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Pi1541. If not, see <http://www.gnu.org/licenses/>.
|
// along with Pi1541. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "ScreenLCD.h"
|
#include "ScreenLCD.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "ssd_logo.h"
|
#include "ssd_logo.h"
|
||||||
|
|
||||||
extern unsigned char* CBMFont;
|
extern unsigned char* CBMFont;
|
||||||
|
|
||||||
void ScreenLCD::Open(u32 widthDesired, u32 heightDesired, u32 colourDepth, int BSCMaster, int LCDAddress, int LCDFlip, LCD_MODEL LCDType, bool luseCBMFont)
|
void ScreenLCD::Open(u32 widthDesired, u32 heightDesired, u32 colourDepth, int BSCMaster, int LCDAddress, int LCDFlip, LCD_MODEL LCDType, bool luseCBMFont)
|
||||||
{
|
{
|
||||||
bpp = 1;
|
bpp = 1;
|
||||||
|
|
||||||
if (widthDesired < 128)
|
if (widthDesired < 128)
|
||||||
widthDesired = 128;
|
widthDesired = 128;
|
||||||
if (heightDesired < 32)
|
if (heightDesired < 32)
|
||||||
heightDesired = 32;
|
heightDesired = 32;
|
||||||
if (widthDesired > 128)
|
if (widthDesired > 128)
|
||||||
widthDesired = 128;
|
widthDesired = 128;
|
||||||
if (heightDesired > 64)
|
if (heightDesired > 64)
|
||||||
heightDesired = 64;
|
heightDesired = 64;
|
||||||
|
|
||||||
width = widthDesired;
|
width = widthDesired;
|
||||||
height = heightDesired;
|
height = heightDesired;
|
||||||
useCBMFont = luseCBMFont;
|
useCBMFont = luseCBMFont;
|
||||||
|
|
||||||
ssd1306 = new SSD1306(BSCMaster, LCDAddress, width, height, LCDFlip, LCDType);
|
ssd1306 = new SSD1306(BSCMaster, LCDAddress, width, height, LCDFlip, LCDType);
|
||||||
ssd1306->ClearScreen();
|
ssd1306->ClearScreen();
|
||||||
ssd1306->RefreshScreen();
|
ssd1306->RefreshScreen();
|
||||||
ssd1306->DisplayOn();
|
ssd1306->DisplayOn();
|
||||||
|
|
||||||
opened = true;
|
opened = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLCD::DrawRectangle(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLCD::ScrollArea(u32 x1, u32 y1, u32 x2, u32 y2)
|
void ScreenLCD::ScrollArea(u32 x1, u32 y1, u32 x2, u32 y2)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLCD::Clear(RGBA colour)
|
void ScreenLCD::Clear(RGBA colour)
|
||||||
{
|
{
|
||||||
ssd1306->ClearScreen();
|
ssd1306->ClearScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLCD::ClearInit(RGBA colour)
|
void ScreenLCD::ClearInit(RGBA colour)
|
||||||
{
|
{
|
||||||
ssd1306->InitHardware();
|
ssd1306->InitHardware();
|
||||||
ssd1306->ClearScreen();
|
ssd1306->ClearScreen();
|
||||||
ssd1306->SetContrast(ssd1306->GetContrast());
|
ssd1306->SetContrast(ssd1306->GetContrast());
|
||||||
ssd1306->DisplayOn();
|
ssd1306->DisplayOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLCD::SetContrast(u8 value)
|
void ScreenLCD::SetContrast(u8 value)
|
||||||
{
|
{
|
||||||
ssd1306->SetContrast(value);
|
ssd1306->SetContrast(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLCD::WriteChar(bool petscii, u32 x, u32 y, unsigned char c, RGBA colour)
|
void ScreenLCD::WriteChar(bool petscii, u32 x, u32 y, unsigned char c, RGBA colour)
|
||||||
{
|
{
|
||||||
if (opened)
|
if (opened)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLCD::PlotPixel(u32 x, u32 y, RGBA colour)
|
void ScreenLCD::PlotPixel(u32 x, u32 y, RGBA colour)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLCD::PlotImage(u32* image, int x, int y, int w, int h)
|
void ScreenLCD::PlotImage(u32* image, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLCD::PlotRawImage(const u8* image, int x, int y, int w, int h)
|
void ScreenLCD::PlotRawImage(const u8* image, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
if (x==0 && y==0 && w==128 && h==64)
|
if (x==0 && y==0 && w==128 && h==64)
|
||||||
{
|
{
|
||||||
ssd1306->PlotImage(image);
|
ssd1306->PlotImage(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 ScreenLCD::PrintText(bool petscii, u32 x, u32 y, char *ptr, RGBA TxtColour, RGBA BkColour, bool measureOnly, u32* width, u32* height)
|
u32 ScreenLCD::PrintText(bool petscii, u32 x, u32 y, char *ptr, RGBA TxtColour, RGBA BkColour, bool measureOnly, u32* width, u32* height)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
ssd1306->PlotText(UseCBMFont(), petscii, x >> 3, y >> 4, ptr, (BkColour & 0xffffff) != 0);
|
ssd1306->PlotText(UseCBMFont(), petscii, x >> 3, y / GetFontHeight (), ptr, (BkColour & 0xffffff) != 0);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 ScreenLCD::MeasureText(bool petscii, char *ptr, u32* width, u32* height)
|
u32 ScreenLCD::MeasureText(bool petscii, char *ptr, u32* width, u32* height)
|
||||||
{
|
{
|
||||||
return PrintText(petscii, 0, 0, ptr, 0, 0, true, width, height);
|
return PrintText(petscii, 0, 0, ptr, 0, 0, true, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 ScreenLCD::GetFontHeight()
|
u32 ScreenLCD::GetFontHeight()
|
||||||
{
|
{
|
||||||
if (CBMFont && useCBMFont)
|
if (CBMFont && useCBMFont)
|
||||||
return 8;
|
return 8;
|
||||||
else
|
else
|
||||||
return 16;
|
return 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLCD::RefreshScreen()
|
void ScreenLCD::RefreshScreen()
|
||||||
{
|
{
|
||||||
ssd1306->RefreshScreen();
|
ssd1306->RefreshScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLCD::SwapBuffers()
|
void ScreenLCD::SwapBuffers()
|
||||||
{
|
{
|
||||||
ssd1306->RefreshScreen();
|
ssd1306->RefreshScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenLCD::RefreshRows(u32 start, u32 amountOfRows)
|
void ScreenLCD::RefreshRows(u32 start, u32 amountOfRows)
|
||||||
{
|
{
|
||||||
if (ssd1306)
|
if (ssd1306)
|
||||||
{
|
{
|
||||||
if (UseCBMFont())
|
if (UseCBMFont())
|
||||||
ssd1306->RefreshTextRows(start, amountOfRows);
|
ssd1306->RefreshTextRows(start, amountOfRows);
|
||||||
else
|
else
|
||||||
ssd1306->RefreshTextRows(start*2, amountOfRows*2);
|
ssd1306->RefreshTextRows(start*2, amountOfRows*2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScreenLCD::IsLCD()
|
bool ScreenLCD::IsLCD()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScreenLCD::UseCBMFont()
|
bool ScreenLCD::UseCBMFont()
|
||||||
{
|
{
|
||||||
return (CBMFont && useCBMFont);
|
return (CBMFont && useCBMFont);
|
||||||
}
|
}
|
Loading…
Reference in a new issue