From: notaz Date: Sat, 17 Sep 2022 20:28:46 +0000 (+0300) Subject: cdrom: treat seek the same as other commands X-Git-Tag: r24~299 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=480e570b6f27909ecdb3f7b2769171b7a7b7f484;p=pcsx_rearmed.git cdrom: treat seek the same as other commands much simpler this way --- diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index f168a0fc..3159e90b 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -243,8 +243,8 @@ static void sec2msf(unsigned int s, u8 *msf) { new_dyna_set_event(PSXINT_CDR, eCycle); \ } -// cdrPlaySeekReadInterrupt -#define CDRPLAYSEEKREAD_INT(eCycle, isFirst) { \ +// cdrPlayReadInterrupt +#define CDRPLAYREAD_INT(eCycle, isFirst) { \ u32 e_ = eCycle; \ psxRegs.interrupt |= (1 << PSXINT_CDREAD); \ if (isFirst) \ @@ -578,32 +578,13 @@ static void cdrReadInterrupt(void); static void cdrPrepCdda(s16 *buf, int samples); static void cdrAttenuate(s16 *buf, int samples, int stereo); -void cdrPlaySeekReadInterrupt(void) +void cdrPlayReadInterrupt(void) { if (cdr.Reading) { cdrReadInterrupt(); return; } - if (!cdr.Play && (cdr.StatP & STATUS_SEEK)) { - if (cdr.Stat) { - CDR_LOG_I("cdrom: seek stat hack\n"); - CDRPLAYSEEKREAD_INT(0x1000, 1); - return; - } - SetResultSize(1); - cdr.StatP |= STATUS_ROTATING; - SetPlaySeekRead(cdr.StatP, 0); - cdr.Result[0] = cdr.StatP; - cdr.Stat = Complete; - setIrq(0x1002); - - Find_CurTrack(cdr.SetSectorPlay); - ReadTrack(cdr.SetSectorPlay); - cdr.TrackChanged = FALSE; - return; - } - if (!cdr.Play) return; CDR_LOG( "CDDA - %d:%d:%d\n", @@ -642,7 +623,7 @@ void cdrPlaySeekReadInterrupt(void) // update for CdlGetlocP/autopause generate_subq(cdr.SetSectorPlay); - CDRPLAYSEEKREAD_INT(cdReadTime, 0); + CDRPLAYREAD_INT(cdReadTime, 0); } #define CMD_PART2 0x100 @@ -797,7 +778,7 @@ void cdrInterrupt(void) { // BIOS player - set flag again cdr.Play = TRUE; - CDRPLAYSEEKREAD_INT(cdReadTime + seekTime, 1); + CDRPLAYREAD_INT(cdReadTime + seekTime, 1); start_rotating = 1; break; @@ -988,7 +969,7 @@ void cdrInterrupt(void) { case CdlSeekP: StopCdda(); StopReading(); - SetPlaySeekRead(cdr.StatP, STATUS_SEEK); + SetPlaySeekRead(cdr.StatP, STATUS_SEEK | STATUS_ROTATING); seekTime = cdrSeekTime(cdr.SetSector); memcpy(cdr.SetSectorPlay, cdr.SetSector, 4); @@ -1005,10 +986,20 @@ void cdrInterrupt(void) { Rockman X5 = 0.5-4x - fix capcom logo */ - CDRPLAYSEEKREAD_INT(cdReadTime + seekTime, 1); + second_resp_time = cdReadTime + seekTime; start_rotating = 1; break; + case CdlSeekL + CMD_PART2: + case CdlSeekP + CMD_PART2: + SetPlaySeekRead(cdr.StatP, 0); + cdr.Stat = Complete; + + Find_CurTrack(cdr.SetSectorPlay); + ReadTrack(cdr.SetSectorPlay); + cdr.TrackChanged = FALSE; + break; + case CdlTest: case CdlTest + CMD_WHILE_NOT_READY: switch (cdr.Param[0]) { @@ -1103,7 +1094,7 @@ void cdrInterrupt(void) { // - fixes new game ReadTrack(cdr.SetSectorPlay); - CDRPLAYSEEKREAD_INT(((cdr.Mode & 0x80) ? (cdReadTime) : cdReadTime * 2) + seekTime, 1); + CDRPLAYREAD_INT(((cdr.Mode & 0x80) ? (cdReadTime) : cdReadTime * 2) + seekTime, 1); SetPlaySeekRead(cdr.StatP, STATUS_SEEK); start_rotating = 1; @@ -1297,7 +1288,7 @@ static void cdrReadInterrupt(void) ReadTrack(cdr.SetSectorPlay); } - CDRPLAYSEEKREAD_INT((cdr.Mode & MODE_SPEED) ? (cdReadTime / 2) : cdReadTime, 0); + CDRPLAYREAD_INT((cdr.Mode & MODE_SPEED) ? (cdReadTime / 2) : cdReadTime, 0); } /* @@ -1636,7 +1627,7 @@ int cdrFreeze(void *f, int Mode) { if (!Config.Cdda) CDR_play(cdr.SetSectorPlay); if (psxRegs.interrupt & (1 << PSXINT_CDRPLAY_OLD)) - CDRPLAYSEEKREAD_INT((cdr.Mode & 0x80) ? (cdReadTime / 2) : cdReadTime, 1); + CDRPLAYREAD_INT((cdr.Mode & 0x80) ? (cdReadTime / 2) : cdReadTime, 1); } if ((cdr.freeze_ver & 0xffffff00) != 0x63647200) { diff --git a/libpcsxcore/cdrom.h b/libpcsxcore/cdrom.h index 52bd21c0..ee0b4d4b 100644 --- a/libpcsxcore/cdrom.h +++ b/libpcsxcore/cdrom.h @@ -48,7 +48,7 @@ extern "C" { void cdrReset(); void cdrInterrupt(void); -void cdrPlaySeekReadInterrupt(void); +void cdrPlayReadInterrupt(void); void cdrLidSeekInterrupt(void); void cdrDmaInterrupt(void); void LidInterrupt(void); diff --git a/libpcsxcore/new_dynarec/emu_if.c b/libpcsxcore/new_dynarec/emu_if.c index aa093564..86bf0d27 100644 --- a/libpcsxcore/new_dynarec/emu_if.c +++ b/libpcsxcore/new_dynarec/emu_if.c @@ -55,7 +55,7 @@ typedef void (irq_func)(); static irq_func * const irq_funcs[] = { [PSXINT_SIO] = sioInterrupt, [PSXINT_CDR] = cdrInterrupt, - [PSXINT_CDREAD] = cdrPlaySeekReadInterrupt, + [PSXINT_CDREAD] = cdrPlayReadInterrupt, [PSXINT_GPUDMA] = gpuInterrupt, [PSXINT_MDECOUTDMA] = mdec1Interrupt, [PSXINT_SPUDMA] = spuInterrupt, diff --git a/libpcsxcore/r3000a.c b/libpcsxcore/r3000a.c index ba22d45f..818cc91a 100644 --- a/libpcsxcore/r3000a.c +++ b/libpcsxcore/r3000a.c @@ -138,7 +138,7 @@ void psxBranchTest() { if (psxRegs.interrupt & (1 << PSXINT_CDREAD)) { // cdr read if ((psxRegs.cycle - psxRegs.intCycle[PSXINT_CDREAD].sCycle) >= psxRegs.intCycle[PSXINT_CDREAD].cycle) { psxRegs.interrupt &= ~(1 << PSXINT_CDREAD); - cdrPlaySeekReadInterrupt(); + cdrPlayReadInterrupt(); } } if (psxRegs.interrupt & (1 << PSXINT_GPUDMA)) { // gpu dma