fix incorrect file loading

This commit is contained in:
dborth 2008-10-03 05:24:51 +00:00
parent 29e6ef31e5
commit 91cc202511
2 changed files with 9 additions and 9 deletions

View File

@ -139,6 +139,8 @@ int GCMemROM(int method, int size)
{ {
if(biosSize > 0) if(biosSize > 0)
WaitPrompt("FDS BIOS file is invalid!"); WaitPrompt("FDS BIOS file is invalid!");
return 0; // BIOS not loaded, do not load game
} }
free(tmpbuffer); free(tmpbuffer);
} }

View File

@ -231,8 +231,7 @@ int
LoadBufferFromFAT (char * sbuffer, char *filepath, bool silent) LoadBufferFromFAT (char * sbuffer, char *filepath, bool silent)
{ {
FILE *handle; FILE *handle;
int boffset = 0; int size = 0;
int read = 0;
handle = fopen (filepath, "rb"); handle = fopen (filepath, "rb");
@ -247,15 +246,14 @@ LoadBufferFromFAT (char * sbuffer, char *filepath, bool silent)
return 0; return 0;
} }
/*** This is really nice, just load the file and decode it ***/ // Just load the file up
while ((read = fread (savebuffer + boffset, 1, 1024, handle)) > 0) fseek(handle, 0, SEEK_END); // go to end of file
{ size = ftell(handle); // get filesize
boffset += read; fseek(handle, 0, SEEK_SET); // go to start of file
} fread (sbuffer, 1, size, handle);
fclose (handle); fclose (handle);
return boffset; return size;
} }
/**************************************************************************** /****************************************************************************