Look in /roms/ for roms (in addition to /)
This commit is contained in:
parent
07143696fe
commit
aed4baee1c
1 changed files with 41 additions and 28 deletions
69
src/main.cpp
69
src/main.cpp
|
@ -1067,8 +1067,15 @@ static bool AttemptToLoadROM(char* ROMName)
|
|||
FIL fp;
|
||||
FRESULT res;
|
||||
|
||||
res = f_open(&fp, ROMName, FA_READ);
|
||||
if (res == FR_OK)
|
||||
char ROMName2[256] = "/roms/";
|
||||
|
||||
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;
|
||||
SetACTLed(true);
|
||||
|
@ -1191,8 +1198,7 @@ static void CheckOptions()
|
|||
if (ROMName)
|
||||
{
|
||||
//DEBUG_LOG("%d Rom Name = %s\r\n", ROMIndex, ROMName);
|
||||
res = f_open(&fp, ROMName, FA_READ);
|
||||
if (res == FR_OK)
|
||||
if (FR_OK == f_open(&fp, ROMName, FA_READ))
|
||||
{
|
||||
u32 bytesRead;
|
||||
|
||||
|
@ -1221,33 +1227,40 @@ static void CheckOptions()
|
|||
{
|
||||
roms.ROMValid[ROMIndex] = false;
|
||||
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);
|
||||
if ( (FR_OK == f_open(&fp, ROMName, FA_READ))
|
||||
|| (FR_OK == f_open(&fp, ROMName2, FA_READ)) )
|
||||
{
|
||||
//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, roms.ROMImages[ROMIndex], ROMs::ROM_SIZE, &bytesRead);
|
||||
SetACTLed(false);
|
||||
if (res == FR_OK && bytesRead == ROMs::ROM_SIZE)
|
||||
{
|
||||
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, roms.ROMImages[ROMIndex], ROMs::ROM_SIZE, &bytesRead);
|
||||
SetACTLed(false);
|
||||
if (res == FR_OK && bytesRead == ROMs::ROM_SIZE)
|
||||
{
|
||||
strncpy(roms.ROMNames[ROMIndex], ROMName, 255);
|
||||
roms.ROMValid[ROMIndex] = true;
|
||||
roms.UpdateLongestRomNameLen( strlen(roms.ROMNames[ROMIndex]) );
|
||||
}
|
||||
f_close(&fp);
|
||||
//DEBUG_LOG("Read ROM %s from options\r\n", ROMName);
|
||||
strncpy(roms.ROMNames[ROMIndex], ROMName, 255);
|
||||
roms.ROMValid[ROMIndex] = true;
|
||||
roms.UpdateLongestRomNameLen( strlen(roms.ROMNames[ROMIndex]) );
|
||||
}
|
||||
f_close(&fp);
|
||||
//DEBUG_LOG("Read ROM %s from options\r\n", ROMName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue