more functions

This commit is contained in:
Robin Jones 2017-10-15 00:21:31 +01:00
parent a66f2b12f5
commit e805617d99

View File

@ -1109,15 +1109,22 @@ void loadgbrom(display_context_t disp, u8 *buff)
void loadmsx2rom(display_context_t disp, u8 *rom_path) void loadmsx2rom(display_context_t disp, u8 *rom_path)
{ {
//max 128kb rom
int max_ok = fatOpenFileByName(rom_path, 0);
int fsize = file.sec_available * 512; //fsize in bytes
if (fsize > 128 * 1024) FRESULT romresult;
FIL romfile;
UINT rombytesread;
romresult = f_open(&romfile, rom_path, FA_READ);
if (romresult == FR_OK)
{
int romfsize = f_size(&romfile);
//max 128KB rom
if (romfsize > 128 * 1024)
{ {
//error //error
drawShortInfoBox(disp, " error: rom > 128kB", 1); drawShortInfoBox(disp, " error: rom > 128KB", 1);
input_mapping = abort_screen; input_mapping = abort_screen;
return; return;
@ -1125,23 +1132,40 @@ void loadmsx2rom(display_context_t disp, u8 *rom_path)
else else
{ {
drawShortInfoBox(disp, " loading please wait", 0); drawShortInfoBox(disp, " loading please wait", 0);
input_mapping = none; //disable all
}
FatRecord rec_tmpf; FRESULT result;
if (fatFindRecord("/ED64/ultraMSX2.z64", &rec_tmpf, 0) == 0) //file exists? FIL file;
UINT bytesread;
result = f_open(&file, "/ED64/ultraMSX2.z64", FA_READ);
if (result == FR_OK)
{ {
u8 resp = 0; int fsize = f_size(&file);
//load nes emulator
resp = fatOpenFileByName("/ED64/ultraMSX2.z64", 0); //err if not found ^^ u8 buffer[romfsize + fsize];
result =
f_read (
&file, /* [IN] File object */
&buffer, /* [OUT] Buffer to store read data */
fsize, /* [IN] Number of bytes to read */
&bytesread /* [OUT] Number of bytes read */
);
result = f_close(&file);
romresult =
f_read (
&romfile, /* [IN] File object */
&buffer + 0x2df48, /* [OUT] Buffer to store read data */ //TODO: why is the offset this particular number
romfsize, /* [IN] Number of bytes to read */
&rombytesread /* [OUT] Number of bytes read */
);
result = f_close(&romfile);
int fsize = 1024 * 1024;
u8 buffer[fsize];
//injecting in buffer... slow but working :/
resp = fatReadFile(buffer, file.sec_available);
resp = fatOpenFileByName(rom_path, 0); //err if not found ^^
resp = fatReadFile(buffer + 0x2df48, file.sec_available);
dma_write_s(buffer, 0xb0000000, fsize); dma_write_s(buffer, 0xb0000000, fsize);
boot_cic = CIC_6102; boot_cic = CIC_6102;
@ -1151,21 +1175,30 @@ void loadmsx2rom(display_context_t disp, u8 *rom_path)
checksum_fix_on = 0; checksum_fix_on = 0;
checksum_sdram(); checksum_sdram();
bootRom(disp, 1); bootRom(disp, 1);
} }
}
}
} }
void loadggrom(display_context_t disp, u8 *rom_path) void loadggrom(display_context_t disp, u8 *rom_path) //TODO: this could be merged with MSX
{ {
//max 512kb rom
int max_ok = fatOpenFileByName(rom_path, 0);
int fsize = file.sec_available * 512; //fsize in bytes
if (fsize > 512 * 1024) FRESULT romresult;
FIL romfile;
UINT rombytesread;
romresult = f_open(&romfile, rom_path, FA_READ);
if (romresult == FR_OK)
{
int romfsize = f_size(&romfile);
//max 512KB rom
if (romfsize > 512 * 1024)
{ {
//error //error
drawShortInfoBox(disp, " error: rom > 512kB", 1);
drawShortInfoBox(disp, " error: rom > 512KB", 1);
input_mapping = abort_screen; input_mapping = abort_screen;
return; return;
@ -1173,23 +1206,40 @@ void loadggrom(display_context_t disp, u8 *rom_path)
else else
{ {
drawShortInfoBox(disp, " loading please wait", 0); drawShortInfoBox(disp, " loading please wait", 0);
input_mapping = none; //disable all
}
FatRecord rec_tmpf; FRESULT result;
if (fatFindRecord("/ED64/UltraSMS.z64", &rec_tmpf, 0) == 0) //file exists? FIL file;
UINT bytesread;
result = f_open(&file, "/ED64/UltraSMS.z64", FA_READ);
if (result == FR_OK)
{ {
u8 resp = 0; int fsize = f_size(&file);
//load nes emulator
resp = fatOpenFileByName("/ED64/UltraSMS.z64", 0); //err if not found ^^ u8 buffer[romfsize + fsize];
result =
f_read (
&file, /* [IN] File object */
&buffer, /* [OUT] Buffer to store read data */
fsize, /* [IN] Number of bytes to read */
&bytesread /* [OUT] Number of bytes read */
);
result = f_close(&file);
romresult =
f_read (
&romfile, /* [IN] File object */
&buffer + 0x1b410, /* [OUT] Buffer to store read data */ //TODO: why is the offset this particular number
romfsize, /* [IN] Number of bytes to read */
&rombytesread /* [OUT] Number of bytes read */
);
result = f_close(&romfile);
int fsize = 1024 * 1024;
u8 buffer[fsize];
//injecting in buffer... slow but working :/
resp = fatReadFile(buffer, file.sec_available);
resp = fatOpenFileByName(rom_path, 0); //err if not found ^^
resp = fatReadFile(buffer + 0x1b410, file.sec_available);
dma_write_s(buffer, 0xb0000000, fsize); dma_write_s(buffer, 0xb0000000, fsize);
boot_cic = CIC_6102; boot_cic = CIC_6102;
@ -1199,9 +1249,10 @@ void loadggrom(display_context_t disp, u8 *rom_path)
checksum_fix_on = 0; checksum_fix_on = 0;
checksum_sdram(); checksum_sdram();
bootRom(disp, 1); bootRom(disp, 1);
} }
}
}
} }
void rom_load_y(void) void rom_load_y(void)