OLED support added

OLED support added back in with extra update call to refresh the display on single core devices.
New macro added to allow 1581 tests in the Pi Zero experimental build.
This commit is contained in:
Alexander Martinelle 2019-09-21 17:24:09 +02:00
parent 9b38fc6d32
commit 58be6a8079
8 changed files with 58 additions and 81 deletions

View File

@ -53,7 +53,7 @@ bool DiskCaddy::Empty()
snprintf(buffer, 256, "Saving %s\r\n", disks[index].GetName());
screen->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red);
}
#endif
if (screenLCD)
{
RGBA BkColour = RGBA(0, 0, 0, 0xFF);
@ -68,7 +68,6 @@ bool DiskCaddy::Empty()
screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red);
screenLCD->SwapBuffers();
}
#endif
}
disks[index].Close();
}
@ -84,7 +83,7 @@ bool DiskCaddy::Empty()
snprintf(buffer, 256, "Saving Complete \r\n");
screen->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red);
}
#endif
if (screenLCD)
{
RGBA BkColour = RGBA(0, 0, 0, 0xFF);
@ -99,7 +98,6 @@ bool DiskCaddy::Empty()
screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red);
screenLCD->SwapBuffers();
}
#endif
}
disks.clear();
@ -125,6 +123,7 @@ bool DiskCaddy::Insert(const FILINFO* fileInfo, bool readOnly)
snprintf(buffer, 256, "Loading %s\r\n", fileInfo->fname);
screen->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red);
}
#endif
if (screenLCD)
{
@ -140,7 +139,6 @@ bool DiskCaddy::Insert(const FILINFO* fileInfo, bool readOnly)
screenLCD->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red);
screenLCD->SwapBuffers();
}
#endif
u32 bytesRead;
SetACTLed(true);
f_read(&fp, DiskImage::readBuffer, READBUFFER_SIZE, &bytesRead);
@ -303,6 +301,8 @@ void DiskCaddy::ShowSelectedImage(u32 index)
snprintf(buffer, 256, "*");
screen->PrintText(false, x, y, buffer, white, red);
}
#endif
if (screenLCD)
{
unsigned numberOfImages = GetNumberOfImages();
@ -351,7 +351,6 @@ void DiskCaddy::ShowSelectedImage(u32 index)
}
screenLCD->SwapBuffers();
}
#endif
}
bool DiskCaddy::Update()
@ -368,15 +367,16 @@ bool DiskCaddy::Update()
y = screen->ScaleY(screenPosYCaddySelections) + 16 + 16 * oldCaddyIndex;
snprintf(buffer, 256, " ");
screen->PrintText(false, x, y, buffer, red, red);
}
#endif
oldCaddyIndex = caddyIndex;
ShowSelectedImage(oldCaddyIndex);
}
if (screenLCD)
{
}
#endif
return true;
}
return false;

View File

@ -30,15 +30,17 @@ public:
: selectedIndex(0)
#if not defined(EXPERIMENTALZERO)
, screen(0)
, screenLCD(0)
#endif
, screenLCD(0)
{
}
#if defined(EXPERIMENTALZERO)
void SetScreen() { }
#else
void SetScreen(Screen* screen, ScreenBase* screenLCD) { this->screen = screen; this->screenLCD = screenLCD; }
void SetScreen(Screen* screen, ScreenBase* screenLCD)
{
#if not defined(EXPERIMENTALZERO)
this->screen = screen;
#endif
this->screenLCD = screenLCD;
}
bool Empty();
@ -46,6 +48,9 @@ public:
DiskImage* GetCurrentDisk()
{
#if defined(EXPERIMENTALZERO)
Update();
#endif
if (selectedIndex < disks.size())
return &disks[selectedIndex];
@ -55,6 +60,7 @@ public:
DiskImage* NextDisk()
{
selectedIndex = (selectedIndex + 1) % (u32)disks.size();
auto ret = GetCurrentDisk();
return GetCurrentDisk();
}
@ -108,8 +114,8 @@ private:
u32 oldCaddyIndex;
#if not defined(EXPERIMENTALZERO)
ScreenBase* screen;
ScreenBase* screenLCD;
#endif
ScreenBase* screenLCD;
};
#endif

View File

@ -82,7 +82,6 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b
if (entryIndex < list->entries.size())
{
FileBrowser::BrowsableList::Entry* entry = &list->entries[entryIndex];
#if not defined(EXPERIMENTALZERO)
if (screen->IsLCD())
{
// pre-clear line on OLED
@ -112,10 +111,8 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b
{
snprintf(buffer2, 256, "%s", entry->filImage.fname);
}
#endif
int len = strlen(buffer2 + highlightScrollOffset);
strncpy(buffer1, buffer2 + highlightScrollOffset, sizeof(buffer1));
#if not defined(EXPERIMENTALZERO)
if (!screen->IsLCD())
{
// space pad the remainder of the line (but not on OLED)
@ -123,56 +120,44 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b
buffer1[len++] = ' ';
buffer1[columnsMax] = 0;
}
#endif
if (selected)
{
if (entry->filImage.fattrib & AM_DIR)
{
#if not defined(EXPERIMENTALZERO)
screen->PrintText(false, x, y, buffer1, palette[VIC2_COLOUR_INDEX_LBLUE], RGBA(0xff, 0xff, 0xff, 0xff));
#endif
}
else
{
colour = RGBA(0xff, 0, 0, 0xff);
if (entry->filImage.fattrib & AM_RDO)
colour = palette[VIC2_COLOUR_INDEX_RED];
#if not defined(EXPERIMENTALZERO)
screen->PrintText(false, x, y, buffer1, colour, RGBA(0xff, 0xff, 0xff, 0xff));
#endif
}
}
else
{
if (entry->filImage.fattrib & AM_DIR)
{
#if not defined(EXPERIMENTALZERO)
screen->PrintText(false, x, y, buffer1, palette[VIC2_COLOUR_INDEX_LBLUE], BkColour);
#endif
}
else
{
colour = palette[VIC2_COLOUR_INDEX_LGREY];
if (entry->filImage.fattrib & AM_RDO)
colour = palette[VIC2_COLOUR_INDEX_PINK];
#if not defined(EXPERIMENTALZERO)
screen->PrintText(false, x, y, buffer1, colour, BkColour);
#endif
}
}
}
else // line is blank, write spaces
{
memset(buffer1, ' ', columnsMax);
#if not defined(EXPERIMENTALZERO)
screen->PrintText(false, x, y, buffer1, BkColour, BkColour);
#endif
}
}
void FileBrowser::BrowsableListView::Refresh()
{
#if not defined(EXPERIMENTALZERO)
u32 index;
u32 entryIndex;
u32 x = positionX;
@ -197,7 +182,6 @@ void FileBrowser::BrowsableListView::Refresh()
}
screen->SwapBuffers();
#endif
}
void FileBrowser::BrowsableListView::RefreshHighlightScroll()
@ -205,7 +189,6 @@ void FileBrowser::BrowsableListView::RefreshHighlightScroll()
char buffer2[256] = { 0 };
FileBrowser::BrowsableList::Entry* entry = list->current;
#if not defined(EXPERIMENTALZERO)
if (screen->IsMonocrome())
{
if (entry->filImage.fattrib & AM_DIR)
@ -268,7 +251,6 @@ void FileBrowser::BrowsableListView::RefreshHighlightScroll()
screen->RefreshRows(rowIndex, 1);
}
#endif
}
bool FileBrowser::BrowsableListView::CheckBrowseNavigation(bool pageOnly)
@ -516,11 +498,14 @@ FileBrowser::FileBrowser(InputMappings* inputMappings, DiskCaddy* diskCaddy, ROM
, displayPNGIcons(displayPNGIcons)
#if not defined(EXPERIMENTALZERO)
, screenMain(screenMain)
, screenLCD(screenLCD)
#endif
, screenLCD(screenLCD)
, scrollHighlightRate(scrollHighlightRate)
, displayingDevices(false)
{
folder.scrollHighlightRate = scrollHighlightRate;
#if not defined(EXPERIMENTALZERO)
u32 columns = screenMain->ScaleX(80);
u32 rows = (int)(38.0f * screenMain->GetScaleY());
@ -530,7 +515,6 @@ FileBrowser::FileBrowser(InputMappings* inputMappings, DiskCaddy* diskCaddy, ROM
if (rows < 1)
rows = 1;
folder.scrollHighlightRate = scrollHighlightRate;
folder.AddView(screenMain, inputMappings, columns, rows, positionX, positionY, false);
positionX = screenMain->ScaleX(1024 - 320);
@ -538,17 +522,17 @@ FileBrowser::FileBrowser(InputMappings* inputMappings, DiskCaddy* diskCaddy, ROM
caddySelections.AddView(screenMain, inputMappings, columns, rows, positionX, positionY, false);
#endif
if (screenLCD)
{
columns = screenLCD->Width() / 8;
rows = screenLCD->Height() / screenLCD->GetFontHeight();
positionX = 0;
positionY = 0;
u32 columns = screenLCD->Width() / 8;
u32 rows = screenLCD->Height() / screenLCD->GetFontHeight();
u32 positionX = 0;
u32 positionY = 0;
folder.AddView(screenLCD, inputMappings, columns, rows, positionX, positionY, true);
}
#endif
}
u32 FileBrowser::Colour(int index)
@ -709,7 +693,6 @@ void FileBrowser::DeviceSwitched()
m_IEC_Commands.SetDisplayingDevices(displayingDevices);
FolderChanged();
}
#if not defined(EXPERIMENTALZERO)
/*
void FileBrowser::RefeshDisplayForBrowsableList(FileBrowser::BrowsableList* browsableList, int xOffset, bool showSelected)
{
@ -788,7 +771,6 @@ void FileBrowser::RefeshDisplayForBrowsableList(FileBrowser::BrowsableList* brow
}
}
*/
#endif
void FileBrowser::RefeshDisplay()
{
#if not defined(EXPERIMENTALZERO)
@ -800,11 +782,9 @@ void FileBrowser::RefeshDisplay()
screenMain->DrawRectangle(0, 0, (int)screenMain->Width(), 17, bgColour);
screenMain->PrintText(false, 0, 0, buffer, textColour, bgColour);
}
#if not defined(EXPERIMENTALZERO)
//u32 offsetX = screenMain->ScaleX(1024 - 320);
//RefeshDisplayForBrowsableList(&folder, 0);
//RefeshDisplayForBrowsableList(&caddySelections, offsetX, false);
#endif
folder.RefreshViews();
caddySelections.RefreshViews();
@ -816,14 +796,14 @@ void FileBrowser::RefeshDisplay()
u32 y = screenMain->ScaleY(STATUS_BAR_POSITION_Y);
screenMain->PrintText(false, 0, y, folder.searchPrefix, textColour, bgColour);
}
#else
folder.RefreshViews();
caddySelections.RefreshViews();
#endif
}
bool FileBrowser::CheckForPNG(const char* filename, FILINFO& filIcon)
{
#if defined(EXPERIMENTALZERO)
return false;
#else
bool foundValid = false;
filIcon.fname[0] = 0;
@ -845,7 +825,6 @@ bool FileBrowser::CheckForPNG(const char* filename, FILINFO& filIcon)
}
}
return foundValid;
#endif
}
void FileBrowser::DisplayPNG(FILINFO& filIcon, int x, int y)
@ -1457,11 +1436,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
char name[17] = { 0 };
unsigned char buffer[260] = { 0 };
int charIndex;
#if defined(EXPERIMENTALZERO)
u32 fontHeight = 16;
#else
u32 fontHeight = screenMain->GetFontHeightDirectoryDisplay();
#endif
u32 x = 0;
u32 y = 0;
char bufferOut[128] = { 0 };

View File

@ -63,9 +63,7 @@ public:
BrowsableListView(BrowsableList* list, InputMappings* inputMappings, ScreenBase* screen, u32 columns, u32 rows, u32 positionX, u32 positionY, bool lcdPgUpDown)
: list(list)
, inputMappings(inputMappings)
#if not defined(EXPERIMENTALZERO)
, screen(screen)
#endif
, columns(columns)
, rows(rows)
, positionX(positionX)
@ -86,9 +84,7 @@ public:
BrowsableList* list;
u32 offset;
InputMappings* inputMappings;
#if not defined(EXPERIMENTALZERO)
ScreenBase* screen;
#endif
u32 columns;
u32 rows;
u32 positionX;
@ -215,14 +211,10 @@ private:
void RefreshFolderEntries();
void UpdateInputFolders();
#if not defined(EXPERIMENTALZERO)
//void UpdateInputDiskCaddy();
#endif
void UpdateCurrentHighlight();
#if not defined(EXPERIMENTALZERO)
//void RefeshDisplayForBrowsableList(FileBrowser::BrowsableList* browsableList, int xOffset, bool showSelected = true);
#endif
bool FillCaddyWithSelections();
bool AddToCaddy(FileBrowser::BrowsableList::Entry* current);
@ -256,8 +248,8 @@ private:
BrowsableList caddySelections;
#if not defined(EXPERIMENTALZERO)
ScreenBase* screenMain;
ScreenBase* screenLCD;
#endif
ScreenBase* screenLCD;
float scrollHighlightRate;
bool displayingDevices;

View File

@ -106,17 +106,17 @@ public:
#if defined(EXPERIMENTALZERO)
inline bool Exit()
{
return /*KeyboardFlag(ESC_FLAG) | UartFlag(ESC_FLAG) |*/ ButtonFlag(ESC_FLAG);
return ButtonFlag(ESC_FLAG);
}
inline bool NextDisk()
{
return /*KeyboardFlag(NEXT_FLAG) | UartFlag(NEXT_FLAG) |*/ ButtonFlag(NEXT_FLAG);
return ButtonFlag(NEXT_FLAG);
}
inline bool PrevDisk()
{
return /*KeyboardFlag(PREV_FLAG) | UartFlag(PREV_FLAG) |*/ ButtonFlag(PREV_FLAG);
return ButtonFlag(PREV_FLAG);
}
#else
inline bool Exit()

View File

@ -93,7 +93,7 @@ extern u16 pc;
u8 read6502_1581(u16 address)
{
u8 value = 0;
#if not defined(EXPERIMENTALZERO)
#if defined(PI1581SUPPORT)
if (address & 0x8000)
{
value = roms.Read1581(address);
@ -129,7 +129,7 @@ u8 peek6502_1581(u16 address)
void write6502_1581(u16 address, const u8 value)
{
#if not defined(EXPERIMENTALZERO)
#if defined(PI1581SUPPORT)
if (address & 0x8000)
{
return;

View File

@ -2,7 +2,9 @@
#define DEFS_H
#include "debug.h"
#ifndef EXPERIMENTALZERO
#define PI1581SUPPORT 1
#endif
// Indicates a Pi with the 40 pin GPIO connector
// so that additional functionality (e.g. test pins) can be enabled
#if defined(RPIZERO) || defined(RPIBPLUS) || defined(RPI2) || defined(RPI3)

View File

@ -101,7 +101,7 @@ u8 s_u8Memory[0xc000];
int numberOfUSBMassStorageDevices = 0;
DiskCaddy diskCaddy;
Pi1541 pi1541;
#if not defined(EXPERIMENTALZERO)
#if defined(PI1581SUPPORT)
Pi1581 pi1581;
#endif
CEMMCDevice m_EMMC;
@ -250,7 +250,6 @@ void InitialiseHardware()
void InitialiseLCD()
{
#if not defined(EXPERIMENTALZERO)
FILINFO filLcdIcon;
int i2cBusMaster = options.I2CBusMaster();
@ -312,7 +311,6 @@ void InitialiseLCD()
screenLCD->RefreshScreen();
}
else
#endif
{
screenLCD = 0;
}
@ -612,7 +610,7 @@ EmulatingMode BeginEmulating(FileBrowser* fileBrowser, const char* filenameForIc
DiskImage* diskImage = diskCaddy.SelectFirstImage();
if (diskImage)
{
#if not defined(EXPERIMENTALZERO)
#if defined(PI1581SUPPORT)
if (diskImage->IsD81())
{
pi1581.Insert(diskImage);
@ -673,7 +671,7 @@ void GlobalSetDeviceID(u8 id)
deviceID = id;
m_IEC_Commands.SetDeviceId(id);
pi1541.SetDeviceID(id);
#if not defined(EXPERIMENTALZERO)
#if defined(PI1581SUPPORT)
pi1581.SetDeviceID(id);
#endif
}
@ -719,6 +717,8 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
if (numberOfImagesMax > 10)
numberOfImagesMax = 10;
diskCaddy.Display();
inputMappings->directDiskSwapRequest = 0;
// Force an update on all the buttons now before we start emulation mode.
IEC_Bus::ReadBrowseMode();
@ -1053,8 +1053,9 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
}
return exitReason;
}
#endif
#if defined(PI1581SUPPORT)
EXIT_TYPE Emulate1581(FileBrowser* fileBrowser)
{
EXIT_TYPE exitReason = EXIT_UNKNOWN;
@ -1251,11 +1252,7 @@ void emulator()
roms.lastManualSelectedROMIndex = 0;
#if defined(EXPERIMENTALZERO)
diskCaddy.SetScreen();
#else
diskCaddy.SetScreen(&screen, screenLCD);
#endif
fileBrowser = new FileBrowser(inputMappings, &diskCaddy, &roms, &deviceID, options.DisplayPNGIcons(), &screen, screenLCD, options.ScrollHighlightRate());
fileBrowser->DisplayRoot();
pi1541.Initialise();
@ -1405,7 +1402,7 @@ void emulator()
{
if (emulating == EMULATING_1541)
exitReason = Emulate1541(fileBrowser);
#if not defined(EXPERIMENTALZERO)
#if defined(PI1581SUPPORT)
else
exitReason = Emulate1581(fileBrowser);
#endif
@ -1865,8 +1862,14 @@ void DisplayMessage(int x, int y, bool LCD, const char* message, u32 textColour,
screenLCD->SwapBuffers();
core0RefreshingScreen.Release();
}
#else
RGBA BkColour = RGBA(0, 0, 0, 0xFF);
screenLCD->Clear(BkColour);
screenLCD->PrintText(false, x, y, (char*)message, textColour, backgroundColour);
screenLCD->SwapBuffers();
#endif
}
@ -1984,10 +1987,9 @@ extern "C"
pi1541.drive.SetVIA(&pi1541.VIA[1]);
pi1541.VIA[0].GetPortB()->SetPortOut(0, IEC_Bus::PortB_OnPortOut);
IEC_Bus::Initialise();
#if not defined(EXPERIMENTALZERO)
if (screenLCD)
screenLCD->ClearInit(0);
#endif
#ifdef HAS_MULTICORE
start_core(3, _spin_core);
start_core(2, _spin_core);