cdrom: treat seek the same as other commands
authornotaz <notasas@gmail.com>
Sat, 17 Sep 2022 20:28:46 +0000 (23:28 +0300)
committernotaz <notasas@gmail.com>
Sat, 17 Sep 2022 20:28:46 +0000 (23:28 +0300)
much simpler this way

libpcsxcore/cdrom.c
libpcsxcore/cdrom.h
libpcsxcore/new_dynarec/emu_if.c
libpcsxcore/r3000a.c

index f168a0f..3159e90 100644 (file)
@@ -243,8 +243,8 @@ static void sec2msf(unsigned int s, u8 *msf) {
        new_dyna_set_event(PSXINT_CDR, eCycle); \
 }
 
        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) \
        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);
 
 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.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",
        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);
 
        // update for CdlGetlocP/autopause
        generate_subq(cdr.SetSectorPlay);
 
-       CDRPLAYSEEKREAD_INT(cdReadTime, 0);
+       CDRPLAYREAD_INT(cdReadTime, 0);
 }
 
 #define CMD_PART2           0x100
 }
 
 #define CMD_PART2           0x100
@@ -797,7 +778,7 @@ void cdrInterrupt(void) {
                        // BIOS player - set flag again
                        cdr.Play = TRUE;
 
                        // BIOS player - set flag again
                        cdr.Play = TRUE;
 
-                       CDRPLAYSEEKREAD_INT(cdReadTime + seekTime, 1);
+                       CDRPLAYREAD_INT(cdReadTime + seekTime, 1);
                        start_rotating = 1;
                        break;
 
                        start_rotating = 1;
                        break;
 
@@ -988,7 +969,7 @@ void cdrInterrupt(void) {
                case CdlSeekP:
                        StopCdda();
                        StopReading();
                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);
 
                        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
                        */
                        Rockman X5 = 0.5-4x
                        - fix capcom logo
                        */
-                       CDRPLAYSEEKREAD_INT(cdReadTime + seekTime, 1);
+                       second_resp_time = cdReadTime + seekTime;
                        start_rotating = 1;
                        break;
 
                        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]) {
                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);
 
                        // - 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;
 
                        SetPlaySeekRead(cdr.StatP, STATUS_SEEK);
                        start_rotating = 1;
@@ -1297,7 +1288,7 @@ static void cdrReadInterrupt(void)
                ReadTrack(cdr.SetSectorPlay);
        }
 
                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))
                        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) {
                }
 
                if ((cdr.freeze_ver & 0xffffff00) != 0x63647200) {
index 52bd21c..ee0b4d4 100644 (file)
@@ -48,7 +48,7 @@ extern "C" {
 void cdrReset();
 
 void cdrInterrupt(void);
 void cdrReset();
 
 void cdrInterrupt(void);
-void cdrPlaySeekReadInterrupt(void);
+void cdrPlayReadInterrupt(void);
 void cdrLidSeekInterrupt(void);
 void cdrDmaInterrupt(void);
 void LidInterrupt(void);
 void cdrLidSeekInterrupt(void);
 void cdrDmaInterrupt(void);
 void LidInterrupt(void);
index aa09356..86bf0d2 100644 (file)
@@ -55,7 +55,7 @@ typedef void (irq_func)();
 static irq_func * const irq_funcs[] = {
        [PSXINT_SIO]    = sioInterrupt,
        [PSXINT_CDR]    = cdrInterrupt,
 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,
        [PSXINT_GPUDMA] = gpuInterrupt,
        [PSXINT_MDECOUTDMA] = mdec1Interrupt,
        [PSXINT_SPUDMA] = spuInterrupt,
index ba22d45..818cc91 100644 (file)
@@ -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);
                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
                        }
                }
                if (psxRegs.interrupt & (1 << PSXINT_GPUDMA)) { // gpu dma