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)
{
int y = screenPosYCaddySelections;
int x = screen->ScaleX(screenPosXCaddySelections);
int y = screen->ScaleY(screenPosYCaddySelections);
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;
@ -149,10 +150,11 @@ void DiskCaddy::Display()
{
unsigned numberOfImages = GetNumberOfImages();
unsigned caddyIndex;
int y = screenPosYCaddySelections;
int x = screen->ScaleX(screenPosXCaddySelections);
int y = screen->ScaleY(screenPosYCaddySelections);
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;
for (caddyIndex = 0; caddyIndex < numberOfImages; ++caddyIndex)
@ -162,7 +164,7 @@ void DiskCaddy::Display()
if (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;
}
}
@ -173,8 +175,8 @@ void DiskCaddy::Display()
void DiskCaddy::ShowSelectedImage(u32 index)
{
u32 x = screenPosXCaddySelections - 16;
u32 y = screenPosYCaddySelections + 16 + 16 * index;
u32 x = screen->ScaleX(screenPosXCaddySelections) - 16;
u32 y = screen->ScaleY(screenPosYCaddySelections) + 16 + 16 * index;
snprintf(buffer, 256, "*");
screen->PrintText(false, x, y, buffer, white, red);
}
@ -188,8 +190,8 @@ bool DiskCaddy::Update()
{
if (screen)
{
x = screenPosXCaddySelections - 16;
y = screenPosYCaddySelections + 16 + 16 * oldCaddyIndex;
x = screen->ScaleX(screenPosXCaddySelections) - 16;
y = screen->ScaleY(screenPosYCaddySelections) + 16 + 16 * oldCaddyIndex;
snprintf(buffer, 256, " ");
screen->PrintText(false, x, y, buffer, red, red);
oldCaddyIndex = caddyIndex;

View file

@ -98,6 +98,9 @@ FileBrowser::FileBrowser(DiskCaddy* diskCaddy, ROMs* roms, unsigned deviceID, bo
, deviceID(deviceID)
, displayPNGIcons(displayPNGIcons)
{
maxOnScreen = (int)(38.0f * screen.GetScaleY());
if (maxOnScreen < 1)
maxOnScreen = 1;
}
u32 FileBrowser::Colour(int index)
@ -216,6 +219,8 @@ void FileBrowser::RefeshDisplayForBrowsableList(FileBrowser::BrowsableList* brow
if (terminal)
printf("\E[2J\E[f");
u32 maxCharacters = screen.ScaleX(80);
for (index = 0; index < maxOnScreen; ++index)
{
entryIndex = browsableList->offset + index;
@ -223,8 +228,8 @@ void FileBrowser::RefeshDisplayForBrowsableList(FileBrowser::BrowsableList* brow
if (entryIndex < browsableList->entries.size())
{
FileBrowser::BrowsableList::Entry* entry = &browsableList->entries[entryIndex];
snprintf(buffer2, 81, "%s", entry->filImage.fname);
memset(buffer1, ' ', 80);
snprintf(buffer2, maxCharacters + 1, "%s", entry->filImage.fname);
memset(buffer1, ' ', maxCharacters);
buffer1[127] = 0;
strncpy(buffer1, buffer2, strlen(buffer2));
if (showSelected && browsableList->currentIndex == entryIndex)
@ -288,8 +293,9 @@ void FileBrowser::RefeshDisplay()
screen.PrintText(false, 0, 0, buffer, textColour, bgColour);
}
u32 offsetX = screen.ScaleX(1024 - 320);
RefeshDisplayForBrowsableList(&folder, 0);
RefeshDisplayForBrowsableList(&caddySelections, 1024 - 320, false);
RefeshDisplayForBrowsableList(&caddySelections, offsetX, false);
DisplayPNG();
DisplayStatusBar();
@ -362,7 +368,9 @@ void FileBrowser::DisplayPNG()
if (displayPNGIcons && 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()
{
u32 x = 0;
u32 y = STATUS_BAR_POSITION_Y;
u32 y = screen.ScaleY(STATUS_BAR_POSITION_Y);
char bufferOut[128];
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];
u32 textColour = RGBA(0, 0, 0, 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]);
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 freeColour = palette[VIC2_COLOUR_INDEX_LGREEN];
u32 BAMOffsetX = screen.ScaleX(400);
ClearScreen();
@ -780,7 +789,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
if ((bamTrack + 1) != 18)
blocksFree += buffer[BAM_OFFSET + bamTrack * BAM_ENTRY_SIZE];
x = 400;
x = BAMOffsetX;
for (int bit = 0; bit < DiskImage::SectorsPerTrack[bamTrack]; bit++)
{
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)
{
x = 400;
x = BAMOffsetX;
for (int bit = 0; bit < DiskImage::SectorsPerTrack[bamTrack]; bit++)
{
snprintf(bufferOut, 128, "%c", screen2petscii(87));
@ -904,7 +913,11 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
{
FILINFO 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)
{
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;
//int width = 0;
//int height = 0;
//int depth = 0;
scaleX = (float)widthDesired / 1024.0f;
scaleY = (float)heightDesired / 768.0f;
RPI_PropertyInit();
RPI_PropertyAddTag(TAG_GET_PHYSICAL_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;
for (int px = 0; px < 8; ++px)
{
if (x + px > width)
if (x + px >= width)
continue;
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)
{
if (x < 0 || y < 0 || x >= width || y >= height)
return;
int pixel_offset = (x * (bpp >> 3)) + (y * pitch);
(this->*Screen::plotPixelFn)(pixel_offset, colour);
}

View file

@ -66,6 +66,12 @@ public:
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:
typedef void (Screen::*PlotPixelFunction)(u32 pixel_offset, RGBA Colour);
@ -85,6 +91,9 @@ private:
u32 bpp;
u32 pitch;
volatile u8* framebuffer;
float scaleX;
float scaleY;
};
#endif

View file

@ -84,6 +84,7 @@ DiskCaddy diskCaddy;
Pi1541 pi1541;
CEMMCDevice m_EMMC;
Screen screen;
Options options;
const char* fileBrowserSelectedName;
u8 deviceID = 8;
IEC_Commands m_IEC_Commands;
@ -99,6 +100,8 @@ bool invertIECInputs = false;
bool invertIECOutputs = true;
bool splitIECLines = false;
bool ignoreReset = false;
unsigned int screenWidth = 1024;
unsigned int screenHeight = 768;
const char* termainalTextRed = "\E[31m";
const char* termainalTextNormal = "\E[0m";
@ -279,7 +282,7 @@ void InitialiseHardware()
#endif
RPI_AuxMiniUartInit(115200, 8);
screen.Open(1024, 768, 16);
screen.Open(screenWidth, screenHeight, 16);
RPI_PropertyInit();
RPI_PropertyAddTag(TAG_GET_MAX_CLOCK_RATE, ARM_CLK_ID);
@ -326,9 +329,9 @@ void UpdateScreen()
RGBA atnColour = COLOUR_YELLOW;
RGBA BkColour = FileBrowser::Colour(VIC2_COLOUR_INDEX_BLUE);
int height = 60;
int screenHeight = 768;
int screenWidthM1 = 1023;
int height = screen.ScaleY(60);
int screenHeight = screen.Height();
int screenWidthM1 = screen.Width() - 1;
int top, top2, top3;
int bottom;
int graphX = 0;
@ -343,7 +346,7 @@ void UpdateScreen()
while (1)
{
bool value;
u32 y = STATUS_BAR_POSITION_Y;
u32 y = screen.ScaleY(STATUS_BAR_POSITION_Y);
//RPI_UpdateTouch();
//refreshUartStatusDisplay = false;
@ -923,11 +926,6 @@ static void LoadOptions()
{
FIL fp;
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);
if (res == FR_OK)
@ -938,10 +936,24 @@ static void LoadOptions()
SetACTLed(false);
f_close(&fp);
Options options;
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();
DEBUG_LOG("DeviceID = %d\r\n", deviceID);
@ -1044,7 +1056,6 @@ static void LoadOptions()
}
while (1);
}
}
}
extern "C"
@ -1053,16 +1064,18 @@ extern "C"
{
FATFS fileSystem;
disk_setEMM(&m_EMMC);
m_EMMC.Initialize();
f_mount(&fileSystem, "", 1);
LoadOptions();
InitialiseHardware();
enable_MMU_and_IDCaches();
_enable_unaligned_access();
disk_setEMM(&m_EMMC);
m_EMMC.Initialize();
write32(ARM_GPIO_GPCLR0, 0xFFFFFFFF);
f_mount(&fileSystem, "", 1);
DisplayLogo();
snprintf(tempBuffer, tempBufferSize, "Copyright(C) 2018 Stephen White");
screen.PrintText(false, 0, 200, tempBuffer, COLOUR_WHITE, COLOUR_BLACK);
@ -1095,7 +1108,7 @@ extern "C"
onResetChangeToStartingFolder = false;
LoadOptions();
CheckOptions();
IEC_Bus::SetSplitIECLines(splitIECLines);
IEC_Bus::SetInvertIECInputs(invertIECInputs);
@ -1139,24 +1152,3 @@ extern "C"
#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)
, splitIECLines(0)
, ignoreReset(0)
, screenWidth(1024)
, screenHeight(768)
{
strcpy(ROMFontName, "chargen");
ROMName[0] = 0;
@ -232,6 +234,18 @@ void Options::Process(char* buffer)
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
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))
{
strncpy(ROMFontName, pValue, 255);

View file

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