From 6daa97aaaf868d2d5d2bb7e2a36aff64e6c82bdd Mon Sep 17 00:00:00 2001 From: "crediar@rypp.net" Date: Wed, 2 Jul 2014 08:34:53 +0000 Subject: [PATCH] *Added the FatFS link map feature which should greatly decrease load times git-svn-id: svn://localhost/Users/andi/Downloads/code/DML@41 be6c1b03-d731-4111-a574-e37d80d43941 --- DVD.c | 35 ++++++++++++++++++++++++++--------- global.h | 2 +- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/DVD.c b/DVD.c index d12d8af..9faa61d 100644 --- a/DVD.c +++ b/DVD.c @@ -8,15 +8,28 @@ extern FIL GameFile; extern u32 FSTMode; static u8 *FSTable ALIGNED(32); -u32 ApploaderSize=0; -u32 dolOffset=0; -u32 FSTableSize=0; -u32 FSTableOffset=0; -u32 FCEntry=0; +u32 ApploaderSize = 0; +u32 dolOffset = 0; +u32 FSTableSize = 0; +u32 FSTableOffset = 0; + +u32 FCEntry=0; FileCache FC[FILECACHE_MAX]; -u32 FCState[FILECACHE_MAX]; +u32 FCState[FILECACHE_MAX]; +DWORD LTable[1024]; +static void DVDCreateLinkMap( FIL *File ) +{ + GameFile.cltbl = LTable; + GameFile.cltbl[0] = sizeof(LTable); + + s32 fres = f_lseek( &GameFile, CREATE_LINKMAP ); + if( fres == FR_NOT_ENOUGH_CORE ) + { + GameFile.cltbl = NULL; + } +} s32 DVDSelectGame( void ) { char *str = (char*)malloca( 256, 32 ); @@ -74,6 +87,8 @@ s32 DVDSelectGame( void ) return -3; } + DVDCreateLinkMap(&GameFile); + f_lseek( &GameFile, 0 ); f_read( &GameFile, (void*)0, 0x20, &read ); @@ -115,7 +130,7 @@ u32 FSTInit( void ) f_lseek( &fd, 0x0420 ); f_read( &fd, rbuf, 0x20, &read ); - dolOffset = *(u32*)(rbuf); + dolOffset = *(u32*)(rbuf); FSTableOffset = *(u32*)(rbuf+4); FSTableSize = *(u32*)(rbuf+8); @@ -250,9 +265,11 @@ void FSTRead( char *Buffer, u32 Length, u32 Offset ) f_open( &(FC[FCEntry].File), Path, FA_READ ); - FC[FCEntry].Size = fe[i].FileLength; + FC[FCEntry].Size = fe[i].FileLength; FC[FCEntry].Offset = fe[i].FileOffset; - FCState[FCEntry] = 0x23; + FCState[FCEntry] = 0x23; + + DVDCreateLinkMap(&(FC[FCEntry].File)); f_lseek( &(FC[FCEntry].File), nOffset ); f_read( &(FC[FCEntry].File), Buffer, Length, &read ); diff --git a/global.h b/global.h index 7b91a1c..224e436 100644 --- a/global.h +++ b/global.h @@ -15,7 +15,7 @@ #define PADHOOK 1 #define CONFIG_VERSION 0x00000002 -#define DML_VERSION 0x0002000a +#define DML_VERSION 0x0002000B #define DI_SUCCESS 1 #define DI_ERROR 2