X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=libpcsxcore%2Fcdrom.c;h=24fd9c92018d172ccce0b9788126ca6032694f97;hp=4e312fd69082055024b948016d4c64d9d4bb2c6d;hb=c9c7a925d158284eb3febf3cccc9789e94231430;hpb=bf4df3ba5781db5600f1ffb3c34e4d76ef490474 diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index 4e312fd6..24fd9c92 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -46,6 +46,7 @@ cdrStruct cdr; static unsigned char *pTransfer; +static s16 read_buf[CD_FRAMESIZE_RAW/2]; /* CD-ROM magic numbers */ #define CdlSync 0 /* nocash documentation : "Uh, actually, returns error code 40h = Invalid Command...?" */ @@ -382,7 +383,7 @@ static void ReadTrack(const u8 *time) { CDR_LOG("ReadTrack *** %02x:%02x:%02x\n", tmp[0], tmp[1], tmp[2]); - cdr.RErr = CDR_readTrack(tmp); + cdr.NoErr = CDR_readTrack(tmp); memcpy(cdr.Prev, tmp, 3); if (CheckSBI(time)) @@ -434,8 +435,7 @@ static void cdrPlayInterrupt_Autopause() u32 abs_lev_max = 0; boolean abs_lev_chselect; u32 i; - s16 read_buf[CD_FRAMESIZE_RAW/2]; - + if ((cdr.Mode & MODE_AUTOPAUSE) && cdr.TrackChanged) { CDR_LOG( "CDDA STOP\n" ); @@ -450,9 +450,8 @@ static void cdrPlayInterrupt_Autopause() StopCdda(); } - else if (cdr.Mode & MODE_REPORT) { + else if (((cdr.Mode & MODE_REPORT) || cdr.FastForward || cdr.FastBackward)) { CDR_readCDDA(cdr.SetSectorPlay[0], cdr.SetSectorPlay[1], cdr.SetSectorPlay[2], (u8 *)read_buf); - cdr.Result[0] = cdr.StatP; cdr.Result[1] = cdr.subq.Track; cdr.Result[2] = cdr.subq.Index; @@ -533,6 +532,12 @@ void cdrPlayInterrupt() cdrPlayInterrupt_Autopause(); if (!cdr.Play) return; + + if (CDR_readCDDA && !cdr.Muted && cdr.Mode & MODE_REPORT) { + cdrAttenuate((u8 *)read_buf, CD_FRAMESIZE_RAW / 4, 1); + if (SPU_playCDDAchannel) + SPU_playCDDAchannel((u8 *)read_buf, CD_FRAMESIZE_RAW); + } cdr.SetSectorPlay[2]++; if (cdr.SetSectorPlay[2] == 75) { @@ -607,6 +612,10 @@ void cdrInterrupt() { // XXX: wrong, should seek instead.. cdr.Seeked = SEEK_DONE; } + + cdr.FastBackward = 0; + cdr.FastForward = 0; + if (cdr.SetlocPending) { memcpy(cdr.SetSectorPlay, cdr.SetSector, 4); cdr.SetlocPending = 0; @@ -671,9 +680,7 @@ void cdrInterrupt() { cdr.Stat = Complete; // GameShark CD Player: Calls 2x + Play 2x - if( cdr.FastForward == 0 ) cdr.FastForward = 2; - else cdr.FastForward++; - + cdr.FastForward = 1; cdr.FastBackward = 0; break; @@ -681,9 +688,7 @@ void cdrInterrupt() { cdr.Stat = Complete; // GameShark CD Player: Calls 2x + Play 2x - if( cdr.FastBackward == 0 ) cdr.FastBackward = 2; - else cdr.FastBackward++; - + cdr.FastBackward = 1; cdr.FastForward = 0; break; @@ -950,7 +955,22 @@ void cdrInterrupt() { case CdlReadS: if (cdr.SetlocPending) { seekTime = abs(msf2sec(cdr.SetSectorPlay) - msf2sec(cdr.SetSector)) * (cdReadTime / 200); - if(seekTime > 1000000) seekTime = 1000000; + /* + * Gameblabla : + * It was originally set to 1000000 for Driver, however it is not high enough for Worms Pinball + * and was unreliable for that game. + * I also tested it against Mednafen and Driver's titlescreen music starts 25 frames later, not immediatly. + * + * Obviously, this isn't perfect but right now, it should be a bit better. + * Games to test this against if you change that setting : + * - Driver (titlescreen music delay and retry mission) + * - Worms Pinball (Will either not boot or crash in the memory card screen) + * - Viewpoint (short pauses if the delay in the ingame music is too long) + * + * It seems that 3386880 * 5 is too much for Driver's titlescreen and it starts skipping. + * However, 1000000 is not enough for Worms Pinball to reliably boot. + */ + if(seekTime > 3386880 * 2) seekTime = 3386880 * 2; memcpy(cdr.SetSectorPlay, cdr.SetSector, 4); cdr.SetlocPending = 0; cdr.m_locationChanged = TRUE; @@ -982,22 +1002,29 @@ void cdrInterrupt() { - fixes cutscenes C-12 - Final Resistance - doesn't like seek */ + + /* + By nicolasnoble from PCSX Redux : + "It LOOKS like this logic is wrong, therefore disabling it with `&& false` for now. + For "PoPoLoCrois Monogatari II", the game logic will soft lock and will never issue GetLocP to detect + the end of its XA streams, as it seems to assume ReadS will not return a status byte with the SEEK + flag set. I think the reasonning is that since it's invalid to call GetLocP while seeking, the game + tries to protect itself against errors by preventing from issuing a GetLocP while it knows the + last status was "seek". But this makes the logic just softlock as it'll never get a notification + about the fact the drive is done seeking and the read actually started. + + In other words, this state machine here is probably wrong in assuming the response to ReadS/ReadN is + done right away. It's rather when it's done seeking, and the read has actually started. This probably + requires a bit more work to make sure seek delays are processed properly. + Checked with a few games, this seems to work fine." + + Gameblabla additional notes : + This still needs the "+ seekTime" that PCSX Redux doesn't have for the Driver "retry" mission error. + */ + cdr.StatP |= STATUS_READ; + cdr.StatP &= ~STATUS_SEEK; - if (cdr.Seeked != SEEK_DONE) { - cdr.StatP |= STATUS_SEEK; - cdr.StatP &= ~STATUS_READ; - - // Crusaders of Might and Magic - use short time - // - fix cutscene speech (startup) - - // ??? - use more accurate seek time later - CDREAD_INT(((cdr.Mode & 0x80) ? (cdReadTime / 2) : cdReadTime * 1) + seekTime); - } else { - cdr.StatP |= STATUS_READ; - cdr.StatP &= ~STATUS_SEEK; - - CDREAD_INT((cdr.Mode & 0x80) ? (cdReadTime / 2) : cdReadTime * 1); - } + CDREAD_INT(((cdr.Mode & 0x80) ? (cdReadTime) : cdReadTime * 2) + seekTime); cdr.Result[0] = cdr.StatP; start_rotating = 1; @@ -1121,9 +1148,9 @@ void cdrReadInterrupt() { buf = CDR_getBuffer(); if (buf == NULL) - cdr.RErr = -1; + cdr.NoErr = 0; - if (cdr.RErr == -1) { + if (!cdr.NoErr) { CDR_LOG_I("cdrReadInterrupt() Log: err\n"); memset(cdr.Transfer, 0, DATA_SIZE); cdr.Stat = DiskError; @@ -1531,9 +1558,7 @@ void cdrReset() { cdr.DriveState = DRIVESTATE_STANDBY; cdr.StatP = STATUS_ROTATING; pTransfer = cdr.Transfer; - cdr.SetlocPending = 0; - cdr.m_locationChanged = FALSE; - + // BIOS player - default values cdr.AttenuatorLeftToLeft = 0x80; cdr.AttenuatorLeftToRight = 0x00;