Merge pull request #66 from penfold42/rompath
Search /roms/ for drive and chargen files
This commit is contained in:
commit
83f6d5fae1
1 changed files with 52 additions and 32 deletions
46
src/main.cpp
46
src/main.cpp
|
@ -1067,8 +1067,15 @@ static bool AttemptToLoadROM(char* ROMName)
|
||||||
FIL fp;
|
FIL fp;
|
||||||
FRESULT res;
|
FRESULT res;
|
||||||
|
|
||||||
res = f_open(&fp, ROMName, FA_READ);
|
char ROMName2[256] = "/roms/";
|
||||||
if (res == FR_OK)
|
|
||||||
|
if (ROMName[0] != '/') // not a full path, prepend /roms/
|
||||||
|
strncat (ROMName2, ROMName, 240);
|
||||||
|
else
|
||||||
|
ROMName2[0] = 0;
|
||||||
|
|
||||||
|
if ( (FR_OK == f_open(&fp, ROMName, FA_READ))
|
||||||
|
|| (FR_OK == f_open(&fp, ROMName2, FA_READ)) )
|
||||||
{
|
{
|
||||||
u32 bytesRead;
|
u32 bytesRead;
|
||||||
SetACTLed(true);
|
SetACTLed(true);
|
||||||
|
@ -1182,22 +1189,28 @@ static void CheckOptions()
|
||||||
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;
|
|
||||||
|
|
||||||
deviceID = (u8)options.GetDeviceID();
|
deviceID = (u8)options.GetDeviceID();
|
||||||
DEBUG_LOG("DeviceID = %d\r\n", deviceID);
|
DEBUG_LOG("DeviceID = %d\r\n", deviceID);
|
||||||
|
|
||||||
ROMName = options.GetRomFontName();
|
const char* FontROMName = options.GetRomFontName();
|
||||||
if (ROMName)
|
if (FontROMName)
|
||||||
{
|
{
|
||||||
|
char FontROMName2[256] = "/roms/";
|
||||||
|
|
||||||
|
if (FontROMName[0] != '/') // not a full path, prepend /roms/
|
||||||
|
strncat (FontROMName2, FontROMName, 240);
|
||||||
|
else
|
||||||
|
FontROMName2[0] = 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);
|
if ( (FR_OK == f_open(&fp, FontROMName, FA_READ))
|
||||||
if (res == FR_OK)
|
|| (FR_OK == f_open(&fp, FontROMName2, FA_READ)) )
|
||||||
{
|
{
|
||||||
u32 bytesRead;
|
u32 bytesRead;
|
||||||
|
|
||||||
screen.Clear(COLOUR_BLACK);
|
screen.Clear(COLOUR_BLACK);
|
||||||
snprintf(tempBuffer, tempBufferSize, "Loading ROM %s\r\n", ROMName);
|
snprintf(tempBuffer, tempBufferSize, "Loading Font ROM %s\r\n", FontROMName);
|
||||||
screen.MeasureText(false, tempBuffer, &widthText, &heightText);
|
screen.MeasureText(false, tempBuffer, &widthText, &heightText);
|
||||||
xpos = (widthScreen - widthText) >> 1;
|
xpos = (widthScreen - widthText) >> 1;
|
||||||
ypos = (heightScreen - heightText) >> 1;
|
ypos = (heightScreen - heightText) >> 1;
|
||||||
|
@ -1221,11 +1234,19 @@ static void CheckOptions()
|
||||||
{
|
{
|
||||||
roms.ROMValid[ROMIndex] = false;
|
roms.ROMValid[ROMIndex] = false;
|
||||||
const char* ROMName = options.GetRomName(ROMIndex);
|
const char* ROMName = options.GetRomName(ROMIndex);
|
||||||
if (ROMName[0])
|
char ROMName2[256] = "/roms/";
|
||||||
{
|
|
||||||
|
if (ROMName[0] == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (ROMName[0] != '/') // not a full path, prepend /roms/
|
||||||
|
strncat (ROMName2, ROMName, 240);
|
||||||
|
else
|
||||||
|
ROMName2[0] = 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);
|
if ( (FR_OK == f_open(&fp, ROMName, FA_READ))
|
||||||
if (res == FR_OK)
|
|| (FR_OK == f_open(&fp, ROMName2, FA_READ)) )
|
||||||
{
|
{
|
||||||
u32 bytesRead;
|
u32 bytesRead;
|
||||||
|
|
||||||
|
@ -1249,7 +1270,6 @@ static void CheckOptions()
|
||||||
//DEBUG_LOG("Read ROM %s from options\r\n", ROMName);
|
//DEBUG_LOG("Read ROM %s from options\r\n", ROMName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (roms.ROMValid[0] == false && !(AttemptToLoadROM("d1541.rom") || AttemptToLoadROM("dos1541") || AttemptToLoadROM("d1541II") || AttemptToLoadROM("Jiffy.bin")))
|
if (roms.ROMValid[0] == false && !(AttemptToLoadROM("d1541.rom") || AttemptToLoadROM("dos1541") || AttemptToLoadROM("d1541II") || AttemptToLoadROM("Jiffy.bin")))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue