diff --git a/FileBrowser.cpp b/FileBrowser.cpp
index 740bc78..123637a 100644
--- a/FileBrowser.cpp
+++ b/FileBrowser.cpp
@@ -746,7 +746,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
char name[17] = { 0 };
unsigned char buffer[260] = { 0 };
int charIndex;
-
+ u32 fontHeight = screen.GetCBMFontHeight();
u32 x = 0;
u32 y = 0;
char bufferOut[128] = { 0 };
@@ -799,7 +799,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
x += 8;
bits <<= 1;
}
- y += 8;
+ y += fontHeight;
}
for (; bamTrack < lastTrackUsed; ++bamTrack)
{
@@ -810,7 +810,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
screen.PrintText(true, x, y, bufferOut, usedColour, bgColour);
x += 8;
}
- y += 8;
+ y += fontHeight;
}
x = 0;
y = 0;
@@ -820,7 +820,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
snprintf(bufferOut, 128, "\"%s\" %c%c%c%c%c%c", name, buffer[162], buffer[163], buffer[164], buffer[165], buffer[166], buffer[167]);
screen.PrintText(true, x, y, bufferOut, bgColour, textColour);
x = 0;
- y += 8;
+ y += fontHeight;
if (track != 0)
{
@@ -879,7 +879,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
modifier = screen2petscii(60);
snprintf(bufferOut, 128, "%s%c", fileTypes[fileType & 7], modifier);
screen.PrintText(true, x, y, bufferOut, textColour, bgColour);
- y += 8;
+ y += fontHeight;
}
entryOffset += 32;
}
@@ -895,7 +895,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
//DEBUG_LOG("%d blocks free\r\n", blocksFree);
snprintf(bufferOut, 128, "%d BLOCKS FREE.\r\n", blocksFree);
screen.PrintText(true, x, y, bufferOut, textColour, bgColour);
- y += 8;
+ y += fontHeight;
}
DisplayStatusBar();
diff --git a/Screen.cpp b/Screen.cpp
index 538c618..7e881f9 100644
--- a/Screen.cpp
+++ b/Screen.cpp
@@ -17,7 +17,6 @@
// along with Pi1541. If not, see .
#include "Screen.h"
-#include "CBMFont.h"
#include
#include
#include
@@ -35,6 +34,8 @@ extern "C"
extern u32 RPi_CpuId;
+extern unsigned char* CBMFont;
+
static const int BitFontHt = 16;
static const int BitFontWth = 8;
@@ -182,20 +183,41 @@ void Screen::Clear(RGBA colour)
ClearArea(0, 0, width, height, colour);
}
+u32 Screen::GetCBMFontHeight()
+{
+ if (CBMFont)
+ return 8;
+ else
+ return BitFontHt;
+}
+
+static char vga2screen(char c)
+{
+ if ((u8)c == 160)
+ c = ' ';
+ else if ((u8)c == 209)
+ c = 'X';
+ else if ((u8)c == 215)
+ c = 'O';
+ return c;
+}
+
void Screen::WriteChar(bool petscii, u32 x, u32 y, unsigned char c, RGBA colour)
{
if (opened)
{
u32 fontHeight;
const unsigned char* fontBitMap;
- if (petscii)
+ if (petscii && CBMFont)
{
- fontBitMap = CMBFont;
+ fontBitMap = CBMFont;
fontHeight = 8;
c = petscii2screen(c);
}
else
{
+ if (petscii)
+ c = vga2screen(c);
fontBitMap = avpriv_vga16_font;
fontHeight = BitFontHt;
}
@@ -261,7 +283,7 @@ u32 Screen::PrintText(bool petscii, u32 x, u32 y, char *ptr, RGBA TxtColour, RGB
int len = 0;
u32 fontHeight;
- if (petscii) fontHeight = 8;
+ if (petscii && CBMFont) fontHeight = 8;
else fontHeight = BitFontHt;
if (width) *width = 0;
diff --git a/Screen.h b/Screen.h
index 13fcb10..c64fbbf 100644
--- a/Screen.h
+++ b/Screen.h
@@ -64,6 +64,8 @@ public:
u32 Width() const { return width; }
u32 Height() const { return height; }
+ u32 GetCBMFontHeight();
+
private:
typedef void (Screen::*PlotPixelFunction)(u32 pixel_offset, RGBA Colour);
diff --git a/main.cpp b/main.cpp
index 2393352..a240bc5 100644
--- a/main.cpp
+++ b/main.cpp
@@ -73,6 +73,10 @@ const long int tempBufferSize = 1024;
char tempBuffer[tempBufferSize];
ROMs roms;
+const long int CBMFont_size = 4096;
+unsigned char CBMFontData[4096];
+unsigned char* CBMFont = 0;
+
//u8 s_u8Memory[0x800];
u8 s_u8Memory[0xc000];
@@ -921,6 +925,7 @@ static void LoadOptions()
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)
@@ -957,13 +962,42 @@ static void LoadOptions()
if (!splitIECLines)
invertIECInputs = false;
+
+ ROMName = options.GetRomFontName();
+ if (ROMName)
+ {
+ //DEBUG_LOG("%d Rom Name = %s\r\n", ROMIndex, ROMName);
+ res = f_open(&fp, ROMName, FA_READ);
+ if (res == FR_OK)
+ {
+ u32 bytesRead;
+
+ screen.Clear(COLOUR_BLACK);
+ snprintf(tempBuffer, tempBufferSize, "Loading ROM %s\r\n", ROMName);
+ screen.MeasureText(false, tempBuffer, &widthText, &heightText);
+ xpos = (widthScreen - widthText) >> 1;
+ ypos = (heightScreen - heightText) >> 1;
+ screen.PrintText(false, xpos, ypos, tempBuffer, COLOUR_WHITE, COLOUR_RED);
+
+ SetACTLed(true);
+ res = f_read(&fp, CBMFontData, CBMFont_size, &bytesRead);
+ SetACTLed(false);
+ f_close(&fp);
+ if (res == FR_OK && bytesRead == CBMFont_size)
+ {
+ CBMFont = CBMFontData;
+ }
+ //DEBUG_LOG("Read ROM %s from options\r\n", ROMName);
+ }
+ }
+
int ROMIndex;
for (ROMIndex = ROMs::MAX_ROMS - 1; ROMIndex >= 0; --ROMIndex)
{
roms.ROMValid[ROMIndex] = false;
const char* ROMName = options.GetRomName(ROMIndex);
- if (ROMName[ROMIndex])
+ if (ROMName[0])
{
//DEBUG_LOG("%d Rom Name = %s\r\n", ROMIndex, ROMName);
res = f_open(&fp, ROMName, FA_READ);
diff --git a/options.cpp b/options.cpp
index 3e91583..d9e2d51 100644
--- a/options.cpp
+++ b/options.cpp
@@ -131,6 +131,7 @@ Options::Options(void)
, invertIECInputs(0)
, splitIECLines(0)
{
+ strcpy(ROMFontName, "chargen");
ROMName[0] = 0;
ROMNameSlot2[0] = 0;
ROMNameSlot3[0] = 0;
@@ -217,6 +218,10 @@ void Options::Process(char* buffer)
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
splitIECLines = nValue;
}
+ else if ((strcasecmp(pOption, "Font") == 0))
+ {
+ strncpy(ROMFontName, pValue, 255);
+ }
else if ((strcasecmp(pOption, "ROM") == 0) || (strcasecmp(pOption, "ROM1") == 0))
{
strncpy(ROMName, pValue, 255);
diff --git a/options.h b/options.h
index 6234c2d..7c740d3 100644
--- a/options.h
+++ b/options.h
@@ -46,6 +46,7 @@ public:
unsigned int GetDeviceID() const { return deviceID; }
unsigned int GetOnResetChangeToStartingFolder() const { return onResetChangeToStartingFolder; }
+ const char* GetRomFontName() const { return ROMFontName; }
const char* GetRomName(int index) const;
unsigned int GetExtraRAM() const { return extraRAM; }
unsigned int GetDisableSD2IECCommands() const { return disableSD2IECCommands; }
@@ -73,6 +74,7 @@ private:
unsigned int invertIECInputs;
unsigned int splitIECLines;
+ char ROMFontName[256];
char ROMName[256];
char ROMNameSlot2[256];
char ROMNameSlot3[256];