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) 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 //load nes emulator
resp = fatOpenFileByName("/ED64/neon64bu.rom", 0); //err if not found ^^ result =
resp = sdRead(file.sector, (void *)0xb0000000, file.sec_available); 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 //load nes rom
resp = fatOpenFileByName(rom_path, 0); //err if not found ^^ FIL romfile;
resp = sdRead(file.sector, (void *)0xb0200000, file.sec_available); UINT rombytesread;
result = f_open(&romfile, rom_path, FA_READ);
boot_cic = CIC_6102; if (result == FR_OK)
boot_save = 0; //save off/cpak {
force_tv = 0; //no force int romfsize = f_size(&romfile);
cheats_on = 0; //cheats off
checksum_fix_on = 0;
bootRom(disp, 1); 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);
}
} }
} }