mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 02:11:36 -04:00
b4b5d223e2
timers.c — timers_advance(cycles) replaces per-frame timers_tick(). Per-timer fractional accumulator + proper divisors: - Timer 0 dotclock approx (cycles/5) - Timer 1 HBlank clock (cycles/2146, ~263 HBlanks per NTSC frame) - Timer 2 SYSCLK or SYSCLK/8 per mode register bit 8..9 Target/overflow flags fire IRQ when bit 4/5 of mode is set. cdrom.c — cdrom_advance(cycles) replaces per-frame cdrom_tick(). Sector pacing from CPU clock: 451584 cycles at 1x, 225792 at 2x (SetMode bit 7). Whole-sector mode bit 5 prepends a 12-byte BCD-MSF header to the data buffer; SECTOR_BUFFER_SIZE = 12 + 2048. cdrom_trace ring: always-on CDROMTraceEntry[1<<16] capturing every register write, IRQ raise/mask, sector load, and command dispatch with the current func/PC/frame snapshot. Query via the new debug_server commands landed in a later commit. psx_cycles.c — psx_advance_cycles now drives cdrom_advance and timers_advance in addition to sio_advance. interrupts.c — legacy per-frame timers_tick + cdrom_tick now gated behind #ifndef PSX_ENABLE_BLOCK_CYCLES, so block-cycle builds use the cycle-paced path exclusively. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
90 lines
2.0 KiB
C
90 lines
2.0 KiB
C
#ifndef PSXRECOMP_V4_CDROM_H
|
|
#define PSXRECOMP_V4_CDROM_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
void cdrom_init(const char* cue_path);
|
|
|
|
/* MMIO read/write (0x1F801800-0x1F801803) */
|
|
uint32_t cdrom_read(uint32_t addr);
|
|
void cdrom_write(uint32_t addr, uint32_t value);
|
|
|
|
/* Advance CD-ROM state machine by guest CPU cycles. Sets i_stat IRQ_CDROM
|
|
* when a command completes or data is ready. */
|
|
void cdrom_advance(uint32_t cycles);
|
|
|
|
/* Legacy frame-paced entry point for interpreter/oracle builds. */
|
|
void cdrom_tick(void);
|
|
|
|
/* DMA channel 3 interface */
|
|
uint32_t cdrom_dma_read(void);
|
|
int cdrom_dma_ready(void);
|
|
|
|
typedef struct CDROMDebugState {
|
|
uint64_t seq;
|
|
uint8_t index_reg;
|
|
uint8_t stat_reg;
|
|
uint8_t irq_enable;
|
|
uint8_t irq_flag;
|
|
uint8_t seek_min;
|
|
uint8_t seek_sec;
|
|
uint8_t seek_sect;
|
|
uint8_t pending_cmd;
|
|
int has_disc;
|
|
int param_count;
|
|
int response_read;
|
|
int response_count;
|
|
int sector_read_pos;
|
|
int sector_available;
|
|
int reading;
|
|
int read_min;
|
|
int read_sec;
|
|
int read_sect;
|
|
int pending_pending;
|
|
int pending_delay;
|
|
int pending_phase;
|
|
uint32_t i_stat;
|
|
} CDROMDebugState;
|
|
|
|
typedef struct CDROMTraceEntry {
|
|
uint64_t seq;
|
|
uint32_t addr;
|
|
uint32_t val;
|
|
uint32_t func;
|
|
uint32_t pc;
|
|
uint32_t frame;
|
|
uint32_t i_stat;
|
|
uint8_t kind;
|
|
uint8_t width;
|
|
uint8_t index_reg;
|
|
uint8_t stat_reg;
|
|
uint8_t irq_enable;
|
|
uint8_t irq_flag;
|
|
uint8_t param_count;
|
|
uint8_t response_read;
|
|
uint8_t response_count;
|
|
uint8_t sector_available;
|
|
uint8_t pending_cmd;
|
|
uint8_t pending_pending;
|
|
uint8_t reading;
|
|
uint8_t pad;
|
|
int sector_read_pos;
|
|
int pending_delay;
|
|
} CDROMTraceEntry;
|
|
|
|
#define CDROM_TRACE_CAP (1 << 16)
|
|
|
|
void cdrom_debug_snapshot(CDROMDebugState* out);
|
|
uint64_t cdrom_debug_get_trace(const CDROMTraceEntry** out_entries);
|
|
void cdrom_debug_clear_trace(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* PSXRECOMP_V4_CDROM_H */
|