fix homebrew ROMS on GameCube, disallow compressed ROMs on Gamecube (not implemented anyways)

This commit is contained in:
dborth 2009-01-24 08:46:00 +00:00
parent 1af817ca93
commit c6667d1adb

View File

@ -125,11 +125,6 @@ void VMClose()
free(rombase); free(rombase);
rombase = NULL; rombase = NULL;
} }
if (romfile != NULL)
{
fclose(romfile);
romfile = NULL;
}
#endif #endif
} }
@ -287,13 +282,6 @@ int VMCPULoadROM(int method)
char msg[512]; char msg[512];
char filepath[MAXPATHLEN]; char filepath[MAXPATHLEN];
/** Fix VM **/
VMClose();
VMInit();
VMAllocGBA();
GBAROMSize = 0;
if(!ChangeInterface(method, NOTSILENT)) if(!ChangeInterface(method, NOTSILENT))
return 0; return 0;
@ -303,13 +291,7 @@ int VMCPULoadROM(int method)
case METHOD_USB: case METHOD_USB:
break; break;
case METHOD_DVD: default:
VMClose();
return 0; // not implemented
break;
case METHOD_SMB:
VMClose();
return 0; // not implemented return 0; // not implemented
break; break;
} }
@ -317,19 +299,35 @@ int VMCPULoadROM(int method)
if(!MakeFilePath(filepath, FILE_ROM, method)) if(!MakeFilePath(filepath, FILE_ROM, method))
return false; return false;
// loading compressed files via VM is not supported
if(!utilIsGBAImage(filepath))
{
WaitPrompt("Compressed GBA files are not supported!");
return 0;
}
// add device to filepath // add device to filepath
char fullpath[1024]; char fullpath[1024];
sprintf(fullpath, "%s%s", rootdir, filepath); sprintf(fullpath, "%s%s", rootdir, filepath);
if (romfile != NULL)
fclose(romfile);
romfile = fopen(fullpath, "rb"); romfile = fopen(fullpath, "rb");
if (romfile == NULL) if (romfile == NULL)
{ {
WaitPrompt("Error opening file!"); WaitPrompt("Error opening file!");
VMClose();
return 0; return 0;
} }
/** Fix VM **/
VMClose();
VMInit();
VMAllocGBA();
GBAROMSize = 0;
res = fread(rom, 1, (1 << VMSHIFTBITS), romfile); res = fread(rom, 1, (1 << VMSHIFTBITS), romfile);
if ( res != (1 << VMSHIFTBITS ) ) if ( res != (1 << VMSHIFTBITS ) )
{ {
@ -375,7 +373,7 @@ static void VMNewPage( int pageid )
sprintf(msg, "Seek error! - Offset %d / %08x %d\n", pageid, pageid << VMSHIFTBITS, res); sprintf(msg, "Seek error! - Offset %d / %08x %d\n", pageid, pageid << VMSHIFTBITS, res);
WaitPrompt(msg); WaitPrompt(msg);
VMClose(); VMClose();
return; ExitToLoader();
} }
VMAllocate( pageid ); VMAllocate( pageid );
@ -383,10 +381,13 @@ static void VMNewPage( int pageid )
res = fread( vmpage[pageid].pageptr, 1, 1 << VMSHIFTBITS, romfile ); res = fread( vmpage[pageid].pageptr, 1, 1 << VMSHIFTBITS, romfile );
if ( res != ( 1 << VMSHIFTBITS ) ) if ( res != ( 1 << VMSHIFTBITS ) )
{ {
sprintf(msg, "Error reading! %d bytes only\n", res); // Homebrew ROMS may not have the expected amount of data
// and then end up here - but they still work - so we won't throw an error
/*sprintf(msg, "Error reading! %d bytes only\n", res);
WaitPrompt(msg); WaitPrompt(msg);
VMClose(); VMClose();
return; ExitToLoader();*/
} }
//mftb(&end); //mftb(&end);
@ -425,6 +426,7 @@ u32 VMRead32( u32 address )
sprintf(msg, "VM32 : Unknown page type! (%d) [%d]", vmpage[pageid].pagetype, pageid); sprintf(msg, "VM32 : Unknown page type! (%d) [%d]", vmpage[pageid].pagetype, pageid);
WaitPrompt(msg); WaitPrompt(msg);
VMClose(); VMClose();
ExitToLoader();
return 0; return 0;
} }
} }
@ -456,6 +458,7 @@ u16 VMRead16( u32 address )
default: default:
WaitPrompt("VM16 : Unknown page type!"); WaitPrompt("VM16 : Unknown page type!");
VMClose(); VMClose();
ExitToLoader();
return 0; return 0;
} }
} }
@ -487,6 +490,7 @@ u8 VMRead8( u32 address )
default: default:
WaitPrompt("VM8 : Unknown page type!"); WaitPrompt("VM8 : Unknown page type!");
VMClose(); VMClose();
ExitToLoader();
return 0; return 0;
} }
} }