Had to remove the CBM font.

This commit is contained in:
Stephen White 2018-05-21 19:12:59 +10:00
parent 6dc9452b2a
commit c94ce4c519
6 changed files with 76 additions and 11 deletions

View File

@ -746,7 +746,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
char name[17] = { 0 }; char name[17] = { 0 };
unsigned char buffer[260] = { 0 }; unsigned char buffer[260] = { 0 };
int charIndex; int charIndex;
u32 fontHeight = screen.GetCBMFontHeight();
u32 x = 0; u32 x = 0;
u32 y = 0; u32 y = 0;
char bufferOut[128] = { 0 }; char bufferOut[128] = { 0 };
@ -799,7 +799,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
x += 8; x += 8;
bits <<= 1; bits <<= 1;
} }
y += 8; y += fontHeight;
} }
for (; bamTrack < lastTrackUsed; ++bamTrack) for (; bamTrack < lastTrackUsed; ++bamTrack)
{ {
@ -810,7 +810,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
screen.PrintText(true, x, y, bufferOut, usedColour, bgColour); screen.PrintText(true, x, y, bufferOut, usedColour, bgColour);
x += 8; x += 8;
} }
y += 8; y += fontHeight;
} }
x = 0; x = 0;
y = 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]); 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); screen.PrintText(true, x, y, bufferOut, bgColour, textColour);
x = 0; x = 0;
y += 8; y += fontHeight;
if (track != 0) if (track != 0)
{ {
@ -879,7 +879,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
modifier = screen2petscii(60); modifier = screen2petscii(60);
snprintf(bufferOut, 128, "%s%c", fileTypes[fileType & 7], modifier); snprintf(bufferOut, 128, "%s%c", fileTypes[fileType & 7], modifier);
screen.PrintText(true, x, y, bufferOut, textColour, bgColour); screen.PrintText(true, x, y, bufferOut, textColour, bgColour);
y += 8; y += fontHeight;
} }
entryOffset += 32; entryOffset += 32;
} }
@ -895,7 +895,7 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
//DEBUG_LOG("%d blocks free\r\n", blocksFree); //DEBUG_LOG("%d blocks free\r\n", blocksFree);
snprintf(bufferOut, 128, "%d BLOCKS FREE.\r\n", blocksFree); snprintf(bufferOut, 128, "%d BLOCKS FREE.\r\n", blocksFree);
screen.PrintText(true, x, y, bufferOut, textColour, bgColour); screen.PrintText(true, x, y, bufferOut, textColour, bgColour);
y += 8; y += fontHeight;
} }
DisplayStatusBar(); DisplayStatusBar();

View File

@ -17,7 +17,6 @@
// along with Pi1541. If not, see <http://www.gnu.org/licenses/>. // along with Pi1541. If not, see <http://www.gnu.org/licenses/>.
#include "Screen.h" #include "Screen.h"
#include "CBMFont.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -35,6 +34,8 @@ extern "C"
extern u32 RPi_CpuId; extern u32 RPi_CpuId;
extern unsigned char* CBMFont;
static const int BitFontHt = 16; static const int BitFontHt = 16;
static const int BitFontWth = 8; static const int BitFontWth = 8;
@ -182,20 +183,41 @@ void Screen::Clear(RGBA colour)
ClearArea(0, 0, width, height, 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) void Screen::WriteChar(bool petscii, u32 x, u32 y, unsigned char c, RGBA colour)
{ {
if (opened) if (opened)
{ {
u32 fontHeight; u32 fontHeight;
const unsigned char* fontBitMap; const unsigned char* fontBitMap;
if (petscii) if (petscii && CBMFont)
{ {
fontBitMap = CMBFont; fontBitMap = CBMFont;
fontHeight = 8; fontHeight = 8;
c = petscii2screen(c); c = petscii2screen(c);
} }
else else
{ {
if (petscii)
c = vga2screen(c);
fontBitMap = avpriv_vga16_font; fontBitMap = avpriv_vga16_font;
fontHeight = BitFontHt; fontHeight = BitFontHt;
} }
@ -261,7 +283,7 @@ u32 Screen::PrintText(bool petscii, u32 x, u32 y, char *ptr, RGBA TxtColour, RGB
int len = 0; int len = 0;
u32 fontHeight; u32 fontHeight;
if (petscii) fontHeight = 8; if (petscii && CBMFont) fontHeight = 8;
else fontHeight = BitFontHt; else fontHeight = BitFontHt;
if (width) *width = 0; if (width) *width = 0;

View File

@ -64,6 +64,8 @@ public:
u32 Width() const { return width; } u32 Width() const { return width; }
u32 Height() const { return height; } u32 Height() const { return height; }
u32 GetCBMFontHeight();
private: private:
typedef void (Screen::*PlotPixelFunction)(u32 pixel_offset, RGBA Colour); typedef void (Screen::*PlotPixelFunction)(u32 pixel_offset, RGBA Colour);

View File

@ -73,6 +73,10 @@ const long int tempBufferSize = 1024;
char tempBuffer[tempBufferSize]; char tempBuffer[tempBufferSize];
ROMs roms; ROMs roms;
const long int CBMFont_size = 4096;
unsigned char CBMFontData[4096];
unsigned char* CBMFont = 0;
//u8 s_u8Memory[0x800]; //u8 s_u8Memory[0x800];
u8 s_u8Memory[0xc000]; u8 s_u8Memory[0xc000];
@ -921,6 +925,7 @@ static void LoadOptions()
u32 widthScreen = screen.Width(); u32 widthScreen = screen.Width();
u32 heightScreen = screen.Height(); u32 heightScreen = screen.Height();
u32 xpos, ypos; 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)
@ -957,13 +962,42 @@ static void LoadOptions()
if (!splitIECLines) if (!splitIECLines)
invertIECInputs = false; 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; int ROMIndex;
for (ROMIndex = ROMs::MAX_ROMS - 1; ROMIndex >= 0; --ROMIndex) for (ROMIndex = ROMs::MAX_ROMS - 1; ROMIndex >= 0; --ROMIndex)
{ {
roms.ROMValid[ROMIndex] = false; roms.ROMValid[ROMIndex] = false;
const char* ROMName = options.GetRomName(ROMIndex); const char* ROMName = options.GetRomName(ROMIndex);
if (ROMName[ROMIndex]) if (ROMName[0])
{ {
//DEBUG_LOG("%d Rom Name = %s\r\n", ROMIndex, ROMName); //DEBUG_LOG("%d Rom Name = %s\r\n", ROMIndex, ROMName);
res = f_open(&fp, ROMName, FA_READ); res = f_open(&fp, ROMName, FA_READ);

View File

@ -131,6 +131,7 @@ Options::Options(void)
, invertIECInputs(0) , invertIECInputs(0)
, splitIECLines(0) , splitIECLines(0)
{ {
strcpy(ROMFontName, "chargen");
ROMName[0] = 0; ROMName[0] = 0;
ROMNameSlot2[0] = 0; ROMNameSlot2[0] = 0;
ROMNameSlot3[0] = 0; ROMNameSlot3[0] = 0;
@ -217,6 +218,10 @@ void Options::Process(char* buffer)
if ((nValue = GetDecimal(pValue)) != INVALID_VALUE) if ((nValue = GetDecimal(pValue)) != INVALID_VALUE)
splitIECLines = nValue; splitIECLines = nValue;
} }
else if ((strcasecmp(pOption, "Font") == 0))
{
strncpy(ROMFontName, pValue, 255);
}
else if ((strcasecmp(pOption, "ROM") == 0) || (strcasecmp(pOption, "ROM1") == 0)) else if ((strcasecmp(pOption, "ROM") == 0) || (strcasecmp(pOption, "ROM1") == 0))
{ {
strncpy(ROMName, pValue, 255); strncpy(ROMName, pValue, 255);

View File

@ -46,6 +46,7 @@ public:
unsigned int GetDeviceID() const { return deviceID; } unsigned int GetDeviceID() const { return deviceID; }
unsigned int GetOnResetChangeToStartingFolder() const { return onResetChangeToStartingFolder; } unsigned int GetOnResetChangeToStartingFolder() const { return onResetChangeToStartingFolder; }
const char* GetRomFontName() const { return ROMFontName; }
const char* GetRomName(int index) const; const char* GetRomName(int index) const;
unsigned int GetExtraRAM() const { return extraRAM; } unsigned int GetExtraRAM() const { return extraRAM; }
unsigned int GetDisableSD2IECCommands() const { return disableSD2IECCommands; } unsigned int GetDisableSD2IECCommands() const { return disableSD2IECCommands; }
@ -73,6 +74,7 @@ private:
unsigned int invertIECInputs; unsigned int invertIECInputs;
unsigned int splitIECLines; unsigned int splitIECLines;
char ROMFontName[256];
char ROMName[256]; char ROMName[256];
char ROMNameSlot2[256]; char ROMNameSlot2[256];
char ROMNameSlot3[256]; char ROMNameSlot3[256];