From eaa895dc8ff02d63cf52b5d0faf0d8272a96a822 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 1 Jan 2013 01:48:16 +0200 Subject: [PATCH] sbi: update according to Nocash doc no idea if it's correct though --- libpcsxcore/ppf.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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) -- 2.39.5