From: notaz Date: Sun, 29 Oct 2023 21:54:58 +0000 (+0200) Subject: cdrom: simplify getStatus X-Git-Tag: r24~76 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=commitdiff_plain;h=2f59faba23ff29fd7679d217947d1574d271b5a6 cdrom: simplify getStatus --- diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index ecf42409..c352b168 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -60,7 +60,6 @@ static boolean multifile = FALSE; static unsigned char cdbuffer[CD_FRAMESIZE_RAW]; static unsigned char subbuffer[SUB_FRAMESIZE]; -static boolean playing = FALSE; static boolean cddaBigEndian = FALSE; /* Frame offset into CD image where pregap data would be found if it was there. * If a game seeks there we must *not* return subchannel data since it's @@ -68,8 +67,6 @@ static boolean cddaBigEndian = FALSE; * XXX: there could be multiple pregaps but PSX dumps only have one? */ static unsigned int pregapOffset; -static unsigned int cddaCurPos; - // compressed image stuff static struct { unsigned char buff_raw[16][CD_FRAMESIZE_RAW]; @@ -219,7 +216,8 @@ static int parsetoc(const char *isofile) { // check if it's really a TOC named as a .cue if (fgets(linebuf, sizeof(linebuf), fi) != NULL) { token = strtok(linebuf, " "); - if (token && strncmp(token, "CD", 2) != 0 && strcmp(token, "CATALOG") != 0) { + if (token && strncmp(token, "CD", 2) != 0) { + // && strcmp(token, "CATALOG") != 0) - valid for a real .cue fclose(fi); return -1; } @@ -1337,7 +1335,8 @@ static void PrintTracks(void) { for (i = 1; i <= numtracks; i++) { SysPrintf(_("Track %.2d (%s) - Start %.2d:%.2d:%.2d, Length %.2d:%.2d:%.2d\n"), - i, (ti[i].type == DATA ? "DATA" : "AUDIO"), + i, (ti[i].type == DATA ? "DATA" : + (ti[i].type == CDDA ? "AUDIO" : "UNKNOWN")), ti[i].start[0], ti[i].start[1], ti[i].start[2], ti[i].length[0], ti[i].length[1], ti[i].length[2]); } @@ -1484,7 +1483,6 @@ static long CALLBACK ISOclose(void) { fclose(subHandle); subHandle = NULL; } - playing = FALSE; cddaHandle = NULL; if (compr_img != NULL) { @@ -1616,13 +1614,11 @@ static boolean CALLBACK ISOreadTrack(unsigned char *time) { // sector: byte 0 - minute; byte 1 - second; byte 2 - frame // does NOT uses bcd format static long CALLBACK ISOplay(unsigned char *time) { - playing = TRUE; return 0; } // stops cdda audio static long CALLBACK ISOstop(void) { - playing = FALSE; return 0; } @@ -1653,22 +1649,10 @@ static unsigned char* CALLBACK ISOgetBufferSub(int sector) { } static long CALLBACK ISOgetStatus(struct CdrStat *stat) { - u32 sect; - CDR__getStatus(stat); - if (playing) { - stat->Type = 0x02; - stat->Status |= 0x80; - } - else { - // BIOS - boot ID (CD type) - stat->Type = ti[1].type; - } - - // relative -> absolute time - sect = cddaCurPos; - sec2msf(sect, (char *)stat->Time); + // BIOS - boot ID (CD type) + stat->Type = ti[1].type; return 0; } @@ -1678,6 +1662,7 @@ long CALLBACK ISOreadCDDA(unsigned char m, unsigned char s, unsigned char f, uns unsigned char msf[3] = {m, s, f}; unsigned int track, track_start = 0; FILE *handle = cdHandle; + unsigned int cddaCurPos; int ret; cddaCurPos = msf2sec((char *)msf); diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index 6f4e3eb4..83f8c1c1 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -1132,6 +1132,8 @@ void cdrInterrupt(void) { cdr.Result[1] |= 0x80; } cdr.Result[0] |= (cdr.Result[1] >> 4) & 0x08; + CDR_LOG_I("CdlID: %02x %02x %02x %02x\n", cdr.Result[0], + cdr.Result[1], cdr.Result[2], cdr.Result[3]); /* This adds the string "PCSX" in Playstation bios boot screen */ memcpy((char *)&cdr.Result[4], "PCSX", 4); diff --git a/libpcsxcore/plugins.h b/libpcsxcore/plugins.h index b106028c..269ef18a 100644 --- a/libpcsxcore/plugins.h +++ b/libpcsxcore/plugins.h @@ -120,9 +120,9 @@ typedef long (CALLBACK* CDRplay)(unsigned char *); typedef long (CALLBACK* CDRstop)(void); typedef long (CALLBACK* CDRsetfilename)(char *); struct CdrStat { - uint32_t Type; - uint32_t Status; - unsigned char Time[3]; + uint32_t Type; // DATA, CDDA + uint32_t Status; // same as cdr.StatP + unsigned char Time_[3]; // unused }; typedef long (CALLBACK* CDRgetStatus)(struct CdrStat *); typedef char* (CALLBACK* CDRgetDriveLetter)(void);