From: notaz Date: Mon, 31 Dec 2012 23:48:16 +0000 (+0200) Subject: sbi: update according to Nocash doc X-Git-Tag: r18~21 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eaa895dc8ff02d63cf52b5d0faf0d8272a96a822;p=pcsx_rearmed.git sbi: update according to Nocash doc no idea if it's correct though --- diff --git a/libpcsxcore/ppf.c b/libpcsxcore/ppf.c index 6fcd5bc1..0d80107b 100644 --- a/libpcsxcore/ppf.c +++ b/libpcsxcore/ppf.c @@ -339,7 +339,7 @@ unsigned char *sbi_sectors; int LoadSBI(const char *fname, int sector_count) { char buffer[16]; FILE *sbihandle; - u8 sbitime[3]; + u8 sbitime[3], t; int s; sbihandle = fopen(fname, "rb"); @@ -352,9 +352,22 @@ int LoadSBI(const char *fname, int sector_count) { // 4-byte SBI header fread(buffer, 1, 4, sbihandle); - while (!feof(sbihandle)) { - fread(sbitime, 1, 3, sbihandle); - fread(buffer, 1, 11, 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)