cdrom: replace resched hack with another one
authornotaz <notasas@gmail.com>
Sun, 26 Jun 2011 19:56:05 +0000 (22:56 +0300)
committernotaz <notasas@gmail.com>
Thu, 7 Jul 2011 21:15:08 +0000 (00:15 +0300)
almost certainly wrong but hopefully better.

libpcsxcore/cdrom.c

index c667ac4..87a7c19 100644 (file)
@@ -1902,9 +1902,13 @@ void cdrWrite3(unsigned char rt) {
                // - Final Fantasy Tactics
                // - various other games
 
-               if (cdr.Irq) // rearmed guesswork hack
                if (cdr.Reading && !cdr.ResultReady) {
-                       CDREAD_INT((cdr.Mode & MODE_SPEED) ? (cdReadTime / 2) : cdReadTime);
+                       int left = psxRegs.intCycle[PSXINT_CDREAD].sCycle + psxRegs.intCycle[PSXINT_CDREAD].cycle - psxRegs.cycle;
+                       int time = (cdr.Mode & MODE_SPEED) ? (cdReadTime / 2) : cdReadTime;
+                       if (left < time / 2) { // rearmed guesswork hack
+                               //printf("-- resched %d -> %d\n", left, time / 2);
+                               CDREAD_INT(time / 2);
+                       }
                }
 
                return;