1
0
mirror of https://github.com/parasyte/alt64 synced 2024-11-02 00:05:03 -04:00

refactored loadnesrom

removes file fragmentation issue
This commit is contained in:
Robin Jones 2017-10-17 23:56:46 +01:00
parent 8045aea0e0
commit cada1f7375

View File

@ -1272,26 +1272,52 @@ void rom_load_y(void)
void loadnesrom(display_context_t disp, u8 *rom_path)
{
FatRecord rec_tmpf;
FRESULT result;
FIL emufile;
UINT emubytesread;
result = f_open(&emufile, "/ED64/neon64bu.rom", FA_READ);
if (fatFindRecord("/ED64/neon64bu.rom", &rec_tmpf, 0) == 0) //filename already exists?
if (result == FR_OK)
{
u8 resp = 0;
int emufsize = f_size(&emufile);
//load nes emulator
resp = fatOpenFileByName("/ED64/neon64bu.rom", 0); //err if not found ^^
resp = sdRead(file.sector, (void *)0xb0000000, file.sec_available);
result =
f_read (
&emufile, /* [IN] File object */
(void *)0xb0000000, /* [OUT] Buffer to store read data */
emufsize, /* [IN] Number of bytes to read */
&emubytesread /* [OUT] Number of bytes read */
);
result = f_close(&emufile);
//load nes rom
resp = fatOpenFileByName(rom_path, 0); //err if not found ^^
resp = sdRead(file.sector, (void *)0xb0200000, file.sec_available);
FIL romfile;
UINT rombytesread;
result = f_open(&romfile, rom_path, FA_READ);
if (result == FR_OK)
{
int romfsize = f_size(&romfile);
result =
f_read (
&romfile, /* [IN] File object */
(void *)0xb0200000, /* [OUT] Buffer to store read data */
romfsize, /* [IN] Number of bytes to read */
&rombytesread /* [OUT] Number of bytes read */
);
result = f_close(&romfile);
boot_cic = CIC_6102;
boot_save = 0; //save off/cpak
force_tv = 0; //no force
cheats_on = 0; //cheats off
checksum_fix_on = 0;
bootRom(disp, 1);
boot_cic = CIC_6102;
boot_save = 0; //save off/cpak
force_tv = 0; //no force
cheats_on = 0; //cheats off
checksum_fix_on = 0;
bootRom(disp, 1);
}
}
}