fix: wire cdrom_tick into vblank interval, fire IRQ on command completion

Two CDROM issues preventing BIOS from progressing past Sony logo:

1. cdrom_tick() was never called — delayed CDROM responses (GetStatus,
   Init, Pause) never completed because pending.delay was never
   decremented. Wired into psx_check_interrupts vblank interval.

2. exec_command() called set_irq() but not fire_cdrom_irq() for
   immediate responses (GetStat, SetLoc, Demute, etc.). The CDROM
   IRQ flag was set internally but i_stat bit 2 was never raised,
   so the BIOS exception handler never delivered CDROM events.

BIOS still stalls at same draw count — next bug in chain is EvCB
event delivery (TestEvent returns 0 because VBlank events aren't
being written to the event control block table).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matthew Stanley
2026-04-13 00:41:02 -07:00
parent a0ee4d43fd
commit 6ce012df3e
2 changed files with 6 additions and 0 deletions
+4
View File
@@ -286,6 +286,10 @@ static void exec_command(uint8_t cmd) {
}
param_count = 0;
/* Fire the CDROM IRQ for the immediate response.
* Delayed responses (pending) fire from process_pending(). */
fire_cdrom_irq();
}
static void process_pending(void) {
+2
View File
@@ -29,6 +29,7 @@
#include "sio.h"
#include "timers.h"
#include "gpu.h"
#include "cdrom.h"
#include "cpu_state.h"
#include <stdio.h>
#include <stdlib.h>
@@ -102,6 +103,7 @@ void psx_check_interrupts(CPUState* cpu) {
i_stat |= (1 << IRQ_VBLANK);
gpu_vblank_tick(); /* Toggle LCF (GPUSTAT bit 31) */
timers_tick(33868); /* ~1 NTSC frame worth of cycles */
cdrom_tick(); /* Process pending CDROM responses */
}
}