Added better support for composite video.

The Pi's video resolution can now be specified in the options file.
The screen layout will scale.
The smallest resolution is 320x240.
This commit is contained in:
Stephen White 2018-05-27 19:56:53 +10:00
parent 37f65f1c40
commit 43022d2de8
7 changed files with 179 additions and 129 deletions

View File

@ -41,10 +41,11 @@ bool DiskCaddy::Insert(const FILINFO* fileInfo, bool readOnly)
{ {
if (screen) if (screen)
{ {
int y = screenPosYCaddySelections; int x = screen->ScaleX(screenPosXCaddySelections);
int y = screen->ScaleY(screenPosYCaddySelections);
snprintf(buffer, 256, "Loading %s\r\n", fileInfo->fname); snprintf(buffer, 256, "Loading %s\r\n", fileInfo->fname);
screen->PrintText(false, screenPosXCaddySelections, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red); screen->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red);
} }
u32 bytesRead; u32 bytesRead;
@ -149,10 +150,11 @@ void DiskCaddy::Display()
{ {
unsigned numberOfImages = GetNumberOfImages(); unsigned numberOfImages = GetNumberOfImages();
unsigned caddyIndex; unsigned caddyIndex;
int y = screenPosYCaddySelections; int x = screen->ScaleX(screenPosXCaddySelections);
int y = screen->ScaleY(screenPosYCaddySelections);
snprintf(buffer, 256, "Emulating\r\n"); snprintf(buffer, 256, "Emulating\r\n");
screen->PrintText(false, screenPosXCaddySelections, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red); screen->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red);
y += 16; y += 16;
for (caddyIndex = 0; caddyIndex < numberOfImages; ++caddyIndex) for (caddyIndex = 0; caddyIndex < numberOfImages; ++caddyIndex)
@ -162,7 +164,7 @@ void DiskCaddy::Display()
if (name) if (name)
{ {
snprintf(buffer, 256, "%d %s\r\n", caddyIndex + 1, name); snprintf(buffer, 256, "%d %s\r\n", caddyIndex + 1, name);
screen->PrintText(false, screenPosXCaddySelections, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red); screen->PrintText(false, x, y, buffer, RGBA(0xff, 0xff, 0xff, 0xff), red);
y += 16; y += 16;
} }
} }
@ -173,8 +175,8 @@ void DiskCaddy::Display()
void DiskCaddy::ShowSelectedImage(u32 index) void DiskCaddy::ShowSelectedImage(u32 index)
{ {
u32 x = screenPosXCaddySelections - 16; u32 x = screen->ScaleX(screenPosXCaddySelections) - 16;
u32 y = screenPosYCaddySelections + 16 + 16 * index; u32 y = screen->ScaleY(screenPosYCaddySelections) + 16 + 16 * index;
snprintf(buffer, 256, "*"); snprintf(buffer, 256, "*");
screen->PrintText(false, x, y, buffer, white, red); screen->PrintText(false, x, y, buffer, white, red);
} }
@ -188,8 +190,8 @@ bool DiskCaddy::Update()
{ {
if (screen) if (screen)
{ {
x = screenPosXCaddySelections - 16; x = screen->ScaleX(screenPosXCaddySelections) - 16;
y = screenPosYCaddySelections + 16 + 16 * oldCaddyIndex; y = screen->ScaleY(screenPosYCaddySelections) + 16 + 16 * oldCaddyIndex;
snprintf(buffer, 256, " "); snprintf(buffer, 256, " ");
screen->PrintText(false, x, y, buffer, red, red); screen->PrintText(false, x, y, buffer, red, red);
oldCaddyIndex = caddyIndex; oldCaddyIndex = caddyIndex;

View File

@ -98,6 +98,9 @@ FileBrowser::FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, unsigned deviceID, bo
, deviceID(deviceID) , deviceID(deviceID)
, displayPNGIcons(displayPNGIcons) , displayPNGIcons(displayPNGIcons)
{ {
maxOnScreen = (int)(38.0f * screen.GetScaleY());
if (maxOnScreen < 1)
maxOnScreen = 1;
} }
u32 FileBrowser::Colour(int index) u32 FileBrowser::Colour(int index)
@ -216,6 +219,8 @@ void FileBrowser::RefeshDisplayForBrowsableList(FileBrowser::BrowsableList* brow
if (terminal) if (terminal)
printf("\E[2J\E[f"); printf("\E[2J\E[f");
u32 maxCharacters = screen.ScaleX(80);
for (index = 0; index < maxOnScreen; ++index) for (index = 0; index < maxOnScreen; ++index)
{ {
entryIndex = browsableList->offset + index; entryIndex = browsableList->offset + index;
@ -223,8 +228,8 @@ void FileBrowser::RefeshDisplayForBrowsableList(FileBrowser::BrowsableList* brow
if (entryIndex < browsableList->entries.size()) if (entryIndex < browsableList->entries.size())
{ {
FileBrowser::BrowsableList::Entry* entry = &browsableList->entries[entryIndex]; FileBrowser::BrowsableList::Entry* entry = &browsableList->entries[entryIndex];
snprintf(buffer2, 81, "%s", entry->filImage.fname); snprintf(buffer2, maxCharacters + 1, "%s", entry->filImage.fname);
memset(buffer1, ' ', 80); memset(buffer1, ' ', maxCharacters);
buffer1[127] = 0; buffer1[127] = 0;
strncpy(buffer1, buffer2, strlen(buffer2)); strncpy(buffer1, buffer2, strlen(buffer2));
if (showSelected && browsableList->currentIndex == entryIndex) if (showSelected && browsableList->currentIndex == entryIndex)
@ -288,8 +293,9 @@ void FileBrowser::RefeshDisplay()
screen.PrintText(false, 0, 0, buffer, textColour, bgColour); screen.PrintText(false, 0, 0, buffer, textColour, bgColour);
} }
u32 offsetX = screen.ScaleX(1024 - 320);
RefeshDisplayForBrowsableList(&folder, 0); RefeshDisplayForBrowsableList(&folder, 0);
RefeshDisplayForBrowsableList(&caddySelections, 1024 - 320, false); RefeshDisplayForBrowsableList(&caddySelections, offsetX, false);
DisplayPNG(); DisplayPNG();
DisplayStatusBar(); DisplayStatusBar();
@ -362,7 +368,9 @@ void FileBrowser::DisplayPNG()
if (displayPNGIcons && folder.current) if (displayPNGIcons && folder.current)
{ {
FileBrowser::BrowsableList::Entry* current = folder.current; FileBrowser::BrowsableList::Entry* current = folder.current;
DisplayPNG(current->filIcon, 1024 - 320, 426); u32 x = screen.ScaleX(1024 - 320);
u32 y = screen.ScaleY(666) - 240;
DisplayPNG(current->filIcon, x, y);
} }
} }
@ -709,7 +717,7 @@ void FileBrowser::UpdateInputDiskCaddy()
void FileBrowser::DisplayStatusBar() void FileBrowser::DisplayStatusBar()
{ {
u32 x = 0; u32 x = 0;
u32 y = STATUS_BAR_POSITION_Y; u32 y = screen.ScaleY(STATUS_BAR_POSITION_Y);
char bufferOut[128]; char bufferOut[128];
snprintf(bufferOut, 256, "LED 0 Motor 0 Track 00.0 ATN 0 DAT 0 CLK 0"); snprintf(bufferOut, 256, "LED 0 Motor 0 Track 00.0 ATN 0 DAT 0 CLK 0");
@ -727,7 +735,7 @@ void FileBrowser::ShowDeviceAndROM()
char buffer[256]; char buffer[256];
u32 textColour = RGBA(0, 0, 0, 0xff); u32 textColour = RGBA(0, 0, 0, 0xff);
u32 bgColour = RGBA(0xff, 0xff, 0xff, 0xff); u32 bgColour = RGBA(0xff, 0xff, 0xff, 0xff);
u32 y = STATUS_BAR_POSITION_Y; u32 y = screen.ScaleY(STATUS_BAR_POSITION_Y);
snprintf(buffer, 256, "Device %d %s \r\n", deviceID, roms->ROMNames[roms->currentROMIndex]); snprintf(buffer, 256, "Device %d %s \r\n", deviceID, roms->ROMNames[roms->currentROMIndex]);
screen.PrintText(false, 43 * 8, y, buffer, textColour, bgColour); screen.PrintText(false, 43 * 8, y, buffer, textColour, bgColour);
@ -755,6 +763,7 @@ 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 BAMOffsetX = screen.ScaleX(400);
ClearScreen(); ClearScreen();
@ -780,7 +789,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
if ((bamTrack + 1) != 18) if ((bamTrack + 1) != 18)
blocksFree += buffer[BAM_OFFSET + bamTrack * BAM_ENTRY_SIZE]; blocksFree += buffer[BAM_OFFSET + bamTrack * BAM_ENTRY_SIZE];
x = 400; x = BAMOffsetX;
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[BAM_OFFSET + 1 + (bit >> 3) + bamTrack * BAM_ENTRY_SIZE];
@ -803,7 +812,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
} }
for (; bamTrack < lastTrackUsed; ++bamTrack) for (; bamTrack < lastTrackUsed; ++bamTrack)
{ {
x = 400; x = BAMOffsetX;
for (int bit = 0; bit < DiskImage::SectorsPerTrack[bamTrack]; bit++) for (int bit = 0; bit < DiskImage::SectorsPerTrack[bamTrack]; bit++)
{ {
snprintf(bufferOut, 128, "%c", screen2petscii(87)); snprintf(bufferOut, 128, "%c", screen2petscii(87));
@ -904,7 +913,11 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
{ {
FILINFO filIcon; FILINFO filIcon;
if (CheckForPNG(filenameForIcon, filIcon)) if (CheckForPNG(filenameForIcon, filIcon))
DisplayPNG(filIcon, 1024 - 320, 0); {
x = screen.ScaleX(1024) - 320;
y = screen.ScaleY(0);
DisplayPNG(filIcon, x, y);
}
} }
} }

View File

@ -41,11 +41,23 @@ static const int BitFontWth = 8;
void Screen::Open(u32 widthDesired, u32 heightDesired, u32 colourDepth) void Screen::Open(u32 widthDesired, u32 heightDesired, u32 colourDepth)
{ {
if (widthDesired < 320)
widthDesired = 320;
if (heightDesired < 240)
heightDesired = 240;
if (widthDesired > 1024)
widthDesired = 1024;
if (heightDesired > 720)
heightDesired = 720;
rpi_mailbox_property_t* mp; rpi_mailbox_property_t* mp;
//int width = 0; //int width = 0;
//int height = 0; //int height = 0;
//int depth = 0; //int depth = 0;
scaleX = (float)widthDesired / 1024.0f;
scaleY = (float)heightDesired / 768.0f;
RPI_PropertyInit(); RPI_PropertyInit();
RPI_PropertyAddTag(TAG_GET_PHYSICAL_SIZE); RPI_PropertyAddTag(TAG_GET_PHYSICAL_SIZE);
RPI_PropertyAddTag(TAG_GET_VIRTUAL_SIZE); RPI_PropertyAddTag(TAG_GET_VIRTUAL_SIZE);
@ -230,7 +242,7 @@ void Screen::WriteChar(bool petscii, u32 x, u32 y, unsigned char c, RGBA colour)
int yoffs = (y + py) * pitch; int yoffs = (y + py) * pitch;
for (int px = 0; px < 8; ++px) for (int px = 0; px < 8; ++px)
{ {
if (x + px > width) if (x + px >= width)
continue; continue;
int pixel_offset = ((px + x) * (bpp >> 3)) + yoffs; int pixel_offset = ((px + x) * (bpp >> 3)) + yoffs;
@ -244,6 +256,8 @@ void Screen::WriteChar(bool petscii, u32 x, u32 y, unsigned char c, RGBA colour)
void Screen::PlotPixel(u32 x, u32 y, RGBA colour) void Screen::PlotPixel(u32 x, u32 y, RGBA colour)
{ {
if (x < 0 || y < 0 || x >= width || y >= height)
return;
int pixel_offset = (x * (bpp >> 3)) + (y * pitch); int pixel_offset = (x * (bpp >> 3)) + (y * pitch);
(this->*Screen::plotPixelFn)(pixel_offset, colour); (this->*Screen::plotPixelFn)(pixel_offset, colour);
} }

View File

@ -66,6 +66,12 @@ public:
u32 GetCBMFontHeight(); u32 GetCBMFontHeight();
float GetScaleX() const { return scaleX; }
float GetScaleY() const { return scaleY; }
u32 ScaleX(u32 x) { return (u32)((float)x * scaleX); }
u32 ScaleY(u32 y) { return (u32)((float)y * scaleY); }
private: private:
typedef void (Screen::*PlotPixelFunction)(u32 pixel_offset, RGBA Colour); typedef void (Screen::*PlotPixelFunction)(u32 pixel_offset, RGBA Colour);
@ -85,6 +91,9 @@ private:
u32 bpp; u32 bpp;
u32 pitch; u32 pitch;
volatile u8* framebuffer; volatile u8* framebuffer;
float scaleX;
float scaleY;
}; };
#endif #endif

View File

@ -84,6 +84,7 @@ DiskCaddy diskCaddy;
Pi1541 pi1541; Pi1541 pi1541;
CEMMCDevice m_EMMC; CEMMCDevice m_EMMC;
Screen screen; Screen screen;
Options options;
const char* fileBrowserSelectedName; const char* fileBrowserSelectedName;
u8 deviceID = 8; u8 deviceID = 8;
IEC_Commands m_IEC_Commands; IEC_Commands m_IEC_Commands;
@ -99,6 +100,8 @@ bool invertIECInputs = false;
bool invertIECOutputs = true; bool invertIECOutputs = true;
bool splitIECLines = false; bool splitIECLines = false;
bool ignoreReset = false; bool ignoreReset = false;
unsigned int screenWidth = 1024;
unsigned int screenHeight = 768;
const char* termainalTextRed = "\E[31m"; const char* termainalTextRed = "\E[31m";
const char* termainalTextNormal = "\E[0m"; const char* termainalTextNormal = "\E[0m";
@ -279,7 +282,7 @@ void InitialiseHardware()
#endif #endif
RPI_AuxMiniUartInit(115200, 8); RPI_AuxMiniUartInit(115200, 8);
screen.Open(1024, 768, 16); screen.Open(screenWidth, screenHeight, 16);
RPI_PropertyInit(); RPI_PropertyInit();
RPI_PropertyAddTag(TAG_GET_MAX_CLOCK_RATE, ARM_CLK_ID); RPI_PropertyAddTag(TAG_GET_MAX_CLOCK_RATE, ARM_CLK_ID);
@ -326,9 +329,9 @@ void UpdateScreen()
RGBA atnColour = COLOUR_YELLOW; RGBA atnColour = COLOUR_YELLOW;
RGBA BkColour = FileBrowser::Colour(VIC2_COLOUR_INDEX_BLUE); RGBA BkColour = FileBrowser::Colour(VIC2_COLOUR_INDEX_BLUE);
int height = 60; int height = screen.ScaleY(60);
int screenHeight = 768; int screenHeight = screen.Height();
int screenWidthM1 = 1023; int screenWidthM1 = screen.Width() - 1;
int top, top2, top3; int top, top2, top3;
int bottom; int bottom;
int graphX = 0; int graphX = 0;
@ -343,7 +346,7 @@ void UpdateScreen()
while (1) while (1)
{ {
bool value; bool value;
u32 y = STATUS_BAR_POSITION_Y; u32 y = screen.ScaleY(STATUS_BAR_POSITION_Y);
//RPI_UpdateTouch(); //RPI_UpdateTouch();
//refreshUartStatusDisplay = false; //refreshUartStatusDisplay = false;
@ -923,11 +926,6 @@ static void LoadOptions()
{ {
FIL fp; FIL fp;
FRESULT res; FRESULT res;
u32 widthText, heightText;
u32 widthScreen = screen.Width();
u32 heightScreen = screen.Height();
u32 xpos, ypos;
const char* ROMName;
res = f_open(&fp, "options.txt", FA_READ); res = f_open(&fp, "options.txt", FA_READ);
if (res == FR_OK) if (res == FR_OK)
@ -938,10 +936,24 @@ static void LoadOptions()
SetACTLed(false); SetACTLed(false);
f_close(&fp); f_close(&fp);
Options options;
options.Process((char*)tempBuffer); options.Process((char*)tempBuffer);
screenWidth = options.ScreenWidth();
screenHeight = options.ScreenHeight();
}
}
static void CheckOptions()
{
FIL fp;
FRESULT res;
u32 widthText, heightText;
u32 widthScreen = screen.Width();
u32 heightScreen = screen.Height();
u32 xpos, ypos;
const char* ROMName;
deviceID = (u8)options.GetDeviceID(); deviceID = (u8)options.GetDeviceID();
DEBUG_LOG("DeviceID = %d\r\n", deviceID); DEBUG_LOG("DeviceID = %d\r\n", deviceID);
@ -1044,7 +1056,6 @@ static void LoadOptions()
} }
while (1); while (1);
} }
}
} }
extern "C" extern "C"
@ -1053,16 +1064,18 @@ extern "C"
{ {
FATFS fileSystem; FATFS fileSystem;
disk_setEMM(&m_EMMC);
m_EMMC.Initialize();
f_mount(&fileSystem, "", 1);
LoadOptions();
InitialiseHardware(); InitialiseHardware();
enable_MMU_and_IDCaches(); enable_MMU_and_IDCaches();
_enable_unaligned_access(); _enable_unaligned_access();
disk_setEMM(&m_EMMC);
m_EMMC.Initialize();
write32(ARM_GPIO_GPCLR0, 0xFFFFFFFF); write32(ARM_GPIO_GPCLR0, 0xFFFFFFFF);
f_mount(&fileSystem, "", 1);
DisplayLogo(); DisplayLogo();
snprintf(tempBuffer, tempBufferSize, "Copyright(C) 2018 Stephen White"); snprintf(tempBuffer, tempBufferSize, "Copyright(C) 2018 Stephen White");
screen.PrintText(false, 0, 200, tempBuffer, COLOUR_WHITE, COLOUR_BLACK); screen.PrintText(false, 0, 200, tempBuffer, COLOUR_WHITE, COLOUR_BLACK);
@ -1095,7 +1108,7 @@ extern "C"
onResetChangeToStartingFolder = false; onResetChangeToStartingFolder = false;
LoadOptions(); CheckOptions();
IEC_Bus::SetSplitIECLines(splitIECLines); IEC_Bus::SetSplitIECLines(splitIECLines);
IEC_Bus::SetInvertIECInputs(invertIECInputs); IEC_Bus::SetInvertIECInputs(invertIECInputs);
@ -1139,24 +1152,3 @@ extern "C"
#endif #endif
} }
} }
// Del everything in the Z:\MonCog\Builds folder
// Build a WegGL build into Z:\MonCog\Builds
// open cmd
// cd Z:\MonCog\firebase
// firebase init
// Y
// Hosting etc
// type "public"
// N
// overwrite 404 - N
// overwrite index - N
// Copy over new files
// firebase deploy
// Eject delays
// Remove asm commeted code from IEC_Bus
// TO CHECKs
// types
// TDOO: need to display the image names as they write back

View File

@ -132,6 +132,8 @@ Options::Options(void)
, invertIECOutputs(1) , invertIECOutputs(1)
, splitIECLines(0) , splitIECLines(0)
, ignoreReset(0) , ignoreReset(0)
, screenWidth(1024)
, screenHeight(768)
{ {
strcpy(ROMFontName, "chargen"); strcpy(ROMFontName, "chargen");
ROMName[0] = 0; ROMName[0] = 0;
@ -232,6 +234,18 @@ void Options::Process(char* buffer)
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE) if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
ignoreReset = nValue; ignoreReset = nValue;
} }
else if (strcasecmp(pOption, "screenWidth") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
screenWidth = nValue;
}
else if (strcasecmp(pOption, "screenHeight") == 0)
{
unsigned nValue = 0;
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
screenHeight = nValue;
}
else if ((strcasecmp(pOption, "Font") == 0)) else if ((strcasecmp(pOption, "Font") == 0))
{ {
strncpy(ROMFontName, pValue, 255); strncpy(ROMFontName, pValue, 255);

View File

@ -61,6 +61,9 @@ public:
unsigned int InvertIECOutputs() const { return invertIECOutputs; } unsigned int InvertIECOutputs() const { return invertIECOutputs; }
unsigned int IgnoreReset() const { return ignoreReset; } unsigned int IgnoreReset() const { return ignoreReset; }
unsigned int ScreenWidth() const { return screenWidth; }
unsigned int ScreenHeight() const { return screenHeight; }
static unsigned GetDecimal(char* pString); static unsigned GetDecimal(char* pString);
private: private:
@ -78,6 +81,9 @@ private:
unsigned int splitIECLines; unsigned int splitIECLines;
unsigned int ignoreReset; unsigned int ignoreReset;
unsigned int screenWidth;
unsigned int screenHeight;
char ROMFontName[256]; char ROMFontName[256];
char ROMName[256]; char ROMName[256];
char ROMNameSlot2[256]; char ROMNameSlot2[256];