diff options
| author | SND\notaz_cp <SND\notaz_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-01-08 00:47:21 +0000 |
|---|---|---|
| committer | SND\notaz_cp <SND\notaz_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-01-08 00:47:21 +0000 |
| commit | c45d7d3e13fb8be3cf9414e70abd3ac5073f5ff7 (patch) | |
| tree | cae055901c9cba3f04fb1640bdae71bdfdc8b955 /libpcsxcore | |
| parent | 1309996b0e0f270dcb0dda6078da53a6adc50d3a (diff) | |
| download | pcsxr-c45d7d3e13fb8be3cf9414e70abd3ac5073f5ff7.tar.gz | |
ppf: accept optional filename argument
will allow to use .sbi files from redump.org without renaming
with later patch
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@82100 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'libpcsxcore')
| -rwxr-xr-x | libpcsxcore/misc.c | 2 | ||||
| -rwxr-xr-x | libpcsxcore/ppf.c | 59 | ||||
| -rwxr-xr-x | libpcsxcore/ppf.h | 3 |
3 files changed, 37 insertions, 27 deletions
diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index 297b1367..ecd96202 100755 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -347,7 +347,7 @@ int CheckCdrom() { SysPrintf(_("CD-ROM ID: %.9s\n"), CdromId); BuildPPFCache(); - LoadSBI(); + LoadSBI(NULL); return 0; } diff --git a/libpcsxcore/ppf.c b/libpcsxcore/ppf.c index fd8d32ec..66323780 100755 --- a/libpcsxcore/ppf.c +++ b/libpcsxcore/ppf.c @@ -337,38 +337,41 @@ void BuildPPFCache() { // redump.org SBI files static u8 sbitime[256][3], sbicount; -void LoadSBI() { +int LoadSBI(const char *filename) { FILE *sbihandle; char buffer[16], sbifile[MAXPATHLEN]; - if (CdromId[0] == '\0') return; - - // Generate filename in the format of SLUS_123.45.sbi - buffer[0] = toupper(CdromId[0]); - buffer[1] = toupper(CdromId[1]); - buffer[2] = toupper(CdromId[2]); - buffer[3] = toupper(CdromId[3]); - buffer[4] = '_'; - buffer[5] = CdromId[4]; - buffer[6] = CdromId[5]; - buffer[7] = CdromId[6]; - buffer[8] = '.'; - buffer[9] = CdromId[7]; - buffer[10] = CdromId[8]; - buffer[11] = '.'; - buffer[12] = 's'; - buffer[13] = 'b'; - buffer[14] = 'i'; - buffer[15] = '\0'; + if (filename == NULL) { + if (CdromId[0] == '\0') return -1; + + // Generate filename in the format of SLUS_123.45.sbi + buffer[0] = toupper(CdromId[0]); + buffer[1] = toupper(CdromId[1]); + buffer[2] = toupper(CdromId[2]); + buffer[3] = toupper(CdromId[3]); + buffer[4] = '_'; + buffer[5] = CdromId[4]; + buffer[6] = CdromId[5]; + buffer[7] = CdromId[6]; + buffer[8] = '.'; + buffer[9] = CdromId[7]; + buffer[10] = CdromId[8]; + buffer[11] = '.'; + buffer[12] = 's'; + buffer[13] = 'b'; + buffer[14] = 'i'; + buffer[15] = '\0'; + + sprintf(sbifile, "%s%s", Config.PatchesDir, buffer); + filename = sbifile; + } - sprintf(sbifile, "%s%s", Config.PatchesDir, buffer); + sbihandle = fopen(filename, "rb"); + if (sbihandle == NULL) return -1; // init sbicount = 0; - sbihandle = fopen(sbifile, "rb"); - if (sbihandle == NULL) return; - // 4-byte SBI header fread(buffer, 1, 4, sbihandle); while (!feof(sbihandle)) { @@ -378,7 +381,9 @@ void LoadSBI() { fclose(sbihandle); - SysPrintf(_("Loaded SBI file: %s.\n"), sbifile); + SysPrintf(_("Loaded SBI file: %s.\n"), filename); + + return 0; } boolean CheckSBI(const u8 *time) { @@ -394,3 +399,7 @@ boolean CheckSBI(const u8 *time) { return FALSE; } + +void UnloadSBI(void) { + sbicount = 0; +} diff --git a/libpcsxcore/ppf.h b/libpcsxcore/ppf.h index 4bd11b99..3f7e502c 100755 --- a/libpcsxcore/ppf.h +++ b/libpcsxcore/ppf.h @@ -27,8 +27,9 @@ void BuildPPFCache(); void FreePPFCache(); void CheckPPFCache(unsigned char *pB, unsigned char m, unsigned char s, unsigned char f); -void LoadSBI(); +int LoadSBI(const char *filename); boolean CheckSBI(const u8 *time); +void UnloadSBI(void); #ifdef __cplusplus } |
