refactored loadnesrom
removes file fragmentation issue
This commit is contained in:
parent
8045aea0e0
commit
cada1f7375
54
src/main.c
54
src/main.c
@ -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);
|
||||||
|
|
||||||
|
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_cic = CIC_6102;
|
||||||
boot_save = 0; //save off/cpak
|
boot_save = 0; //save off/cpak
|
||||||
force_tv = 0; //no force
|
force_tv = 0; //no force
|
||||||
cheats_on = 0; //cheats off
|
cheats_on = 0; //cheats off
|
||||||
checksum_fix_on = 0;
|
checksum_fix_on = 0;
|
||||||
|
|
||||||
bootRom(disp, 1);
|
bootRom(disp, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user