X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fcdriso.c;h=eb9228129486dabf4a6cddea211e4ad9953a28e9;hp=e68ecf3dd9362725d4ffbaae40ceec4ad2e7fb97;hb=ab948f7e6d437dddd070000f36489d7e983eb4ad;hpb=38b8102cdfde55d7afa20bf95c7698d39407379b diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index e68ecf3d..eb922812 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -22,6 +22,7 @@ #include "plugins.h" #include "cdrom.h" #include "cdriso.h" +#include "ppf.h" #ifdef _WIN32 #include @@ -159,6 +160,12 @@ static void *playthread(void *param) #else usleep(d * 1000); #endif + // HACK: stop feeding data while emu is paused + extern int stop; + if (stop) { + usleep(100000); + continue; + } t = GetTickCount() + CDDA_FRAMETIME; @@ -679,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; @@ -724,6 +750,9 @@ static long CALLBACK ISOopen(void) { if (!subChanMixed && opensubfile(GetIsoFile()) == 0) { SysPrintf("[+sub]"); } + if (opensbifile(GetIsoFile()) == 0) { + SysPrintf("[+sbi]"); + } SysPrintf(".\n"); @@ -733,6 +762,7 @@ static long CALLBACK ISOopen(void) { if (numtracks > 1 && ti[1].handle == NULL) { ti[1].handle = fopen(GetIsoFile(), "rb"); } + cddaCurOffset = cddaStartOffset = 0; return 0; } @@ -758,6 +788,7 @@ static long CALLBACK ISOclose(void) { } } numtracks = 0; + UnloadSBI(); return 0; } @@ -797,7 +828,17 @@ static long CALLBACK ISOgetTN(unsigned char *buffer) { // byte 1 - second // byte 2 - minute static long CALLBACK ISOgetTD(unsigned char track, unsigned char *buffer) { - if (numtracks > 0 && track <= numtracks) { + if (track == 0) { + // CD length according pcsxr-svn (done a bit different here) + unsigned int sect; + unsigned char time[3]; + sect = msf2sec(ti[numtracks].start) + msf2sec(ti[numtracks].length); + sec2msf(sect, (char *)time); + buffer[2] = time[0]; + buffer[1] = time[1]; + buffer[0] = time[2]; + } + else if (numtracks > 0 && track <= numtracks) { buffer[2] = ti[track].start[0]; buffer[1] = ti[track].start[1]; buffer[0] = ti[track].start[2]; @@ -872,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; @@ -920,13 +961,14 @@ static long CALLBACK ISOgetStatus(struct CdrStat *stat) { if (playing) { stat->Type = 0x02; stat->Status |= 0x80; - sec = (cddaStartOffset + cddaCurOffset) / CD_FRAMESIZE_RAW; - sec2msf(sec, (char *)stat->Time); } else { stat->Type = 0x01; } + sec = (cddaStartOffset + cddaCurOffset) / CD_FRAMESIZE_RAW; + sec2msf(sec, (char *)stat->Time); + return 0; }