X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fppf.c;h=0d80107b5cc50b97bcfe19c5b6b0d686384e10e1;hp=45c8733c4753374fc535bc815eb5134e0b1d0aac;hb=650adfd2da779ba8855623362c2900583e22931e;hpb=ef79bbde537d6b9c745a7d86cb9df1d04c35590d diff --git a/libpcsxcore/ppf.c b/libpcsxcore/ppf.c index 45c8733c..0d80107b 100644 --- a/libpcsxcore/ppf.c +++ b/libpcsxcore/ppf.c @@ -190,6 +190,8 @@ void BuildPPFCache() { FreePPFCache(); + if (CdromId[0] == '\0') return; + // Generate filename in the format of SLUS_123.45 buffer[0] = toupper(CdromId[0]); buffer[1] = toupper(CdromId[1]); @@ -330,3 +332,58 @@ void BuildPPFCache() { SysPrintf(_("Loaded PPF %d.0 patch: %s.\n"), method + 1, szPPF); } + +// redump.org SBI files, slightly different handling from PCSX-Reloaded +unsigned char *sbi_sectors; + +int LoadSBI(const char *fname, int sector_count) { + char buffer[16]; + FILE *sbihandle; + u8 sbitime[3], t; + int s; + + sbihandle = fopen(fname, "rb"); + if (sbihandle == NULL) + return -1; + + sbi_sectors = calloc(1, sector_count / 8); + if (sbi_sectors == NULL) + return -1; + + // 4-byte SBI header + fread(buffer, 1, 4, sbihandle); + while (1) { + s = fread(sbitime, 1, 3, sbihandle); + if (s != 3) + break; + fread(&t, 1, 1, sbihandle); + switch (t) { + default: + case 1: + s = 10; + break; + case 2: + case 3: + s = 3; + break; + } + fseek(sbihandle, s, SEEK_CUR); + + s = MSF2SECT(btoi(sbitime[0]), btoi(sbitime[1]), btoi(sbitime[2])); + if (s < sector_count) + sbi_sectors[s >> 3] |= 1 << (s&7); + else + SysPrintf(_("SBI sector %d >= %d?\n"), s, sector_count); + } + + fclose(sbihandle); + + return 0; +} + +void UnloadSBI(void) { + if (sbi_sectors) { + free(sbi_sectors); + sbi_sectors = NULL; + } +}