enable readahead cache for faster file access

This commit is contained in:
dborth 2008-10-03 06:58:21 +00:00
parent fcbefda1f5
commit cb83ca6688
3 changed files with 11 additions and 12 deletions

View File

@ -60,18 +60,17 @@ bool ChangeFATInterface(int method, bool silent)
{
devFound = true;
fatSetDefaultInterface(PI_INTERNAL_SD);
fatEnableReadAhead (PI_INTERNAL_SD, 6, 64);
}
#endif
if (!devFound && FatIsMounted(PI_SDGECKO_A))
{
devFound = true;
fatSetDefaultInterface(PI_SDGECKO_A);
}
if(!devFound && FatIsMounted(PI_SDGECKO_B))
{
devFound = true;
fatSetDefaultInterface(PI_SDGECKO_B);
}
if(!devFound)
{
@ -86,6 +85,7 @@ bool ChangeFATInterface(int method, bool silent)
{
devFound = true;
fatSetDefaultInterface(PI_USBSTORAGE);
fatEnableReadAhead (PI_USBSTORAGE, 6, 64);
}
else
{
@ -222,8 +222,7 @@ int
LoadBufferFromFAT (char *filepath, bool silent)
{
FILE *handle;
int boffset = 0;
int read = 0;
int size = 0;
handle = fopen (filepath, "rb");
@ -238,15 +237,15 @@ LoadBufferFromFAT (char *filepath, bool silent)
return 0;
}
/*** This is really nice, just load the file and decode it ***/
while ((read = fread (savebuffer + boffset, 1, 1024, handle)) > 0)
{
boffset += read;
}
fseek(handle, 0, SEEK_END); // go to end of file
size = ftell(handle); // get filesize
fseek(handle, 0, SEEK_SET); // go to start of file
fread (savebuffer, 1, size, handle);
fclose (handle);
fclose (handle);
return boffset;
return size;
}
/****************************************************************************

View File

@ -33,7 +33,7 @@ extern int offset;
extern int selection;
extern char currentdir[MAXPATHLEN];
extern int maxfiles;
extern char romFilename[512];
extern char ROMFilename[512];
void AllocSaveBuffer();
void FreeSaveBuffer();

View File

@ -74,7 +74,7 @@ int main()
}
// Initialize libFAT for SD and USB
fatInitDefault();
fatInit (8, false);
// Initialize DVD subsystem (GameCube only)
#ifdef HW_DOL