enable Wall warnings by default
[pcsx_rearmed.git] / libpcsxcore / cdriso.c
index 1e9aded..eb92281 100644 (file)
@@ -22,6 +22,7 @@
 #include "plugins.h"
 #include "cdrom.h"
 #include "cdriso.h"
+#include "ppf.h"
 
 #ifdef _WIN32
 #include <process.h>
@@ -685,6 +686,25 @@ static int opensubfile(const char *isoname) {
        return 0;
 }
 
+static int opensbifile(const char *isoname) {
+       char            sbiname[MAXPATHLEN];
+       int             s;
+
+       strncpy(sbiname, isoname, sizeof(sbiname));
+       sbiname[MAXPATHLEN - 1] = '\0';
+       if (strlen(sbiname) >= 4) {
+               strcpy(sbiname + strlen(sbiname) - 4, ".sbi");
+       }
+       else {
+               return -1;
+       }
+
+       fseek(cdHandle, 0, SEEK_END);
+       s = ftell(cdHandle) / 2352;
+
+       return LoadSBI(sbiname, s);
+}
+
 static void PrintTracks(void) {
        int i;
 
@@ -730,6 +750,9 @@ static long CALLBACK ISOopen(void) {
        if (!subChanMixed && opensubfile(GetIsoFile()) == 0) {
                SysPrintf("[+sub]");
        }
+       if (opensbifile(GetIsoFile()) == 0) {
+               SysPrintf("[+sbi]");
+       }
 
        SysPrintf(".\n");
 
@@ -765,6 +788,7 @@ static long CALLBACK ISOclose(void) {
                }
        }
        numtracks = 0;
+       UnloadSBI();
 
        return 0;
 }
@@ -809,7 +833,7 @@ static long CALLBACK ISOgetTD(unsigned char track, unsigned char *buffer) {
                unsigned int sect;
                unsigned char time[3];
                sect = msf2sec(ti[numtracks].start) + msf2sec(ti[numtracks].length);
-               sec2msf(sect, time);
+               sec2msf(sect, (char *)time);
                buffer[2] = time[0];
                buffer[1] = time[1];
                buffer[0] = time[2];
@@ -889,7 +913,7 @@ static long CALLBACK ISOplay(unsigned char *time) {
                return 0;
 
        // find the track
-       sect = msf2sec(time);
+       sect = msf2sec((char *)time);
        for (i = numtracks; i > 1; i--)
                if (msf2sec(ti[i].start) <= sect + 2 * 75)
                        break;