mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 10:19:47 -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>
30 lines
653 B
C
30 lines
653 B
C
#ifndef PSXRECOMP_V4_TIMERS_H
|
|
#define PSXRECOMP_V4_TIMERS_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define TIMER_BASE 0x1F801100
|
|
|
|
void timers_init(void);
|
|
|
|
/* MMIO read/write for 0x1F801100..0x1F80112F.
|
|
* Accepts 16-bit or 32-bit access (caller zero-extends). */
|
|
uint32_t timers_read(uint32_t addr);
|
|
void timers_write(uint32_t addr, uint32_t value);
|
|
|
|
/* Advance all timers by guest CPU cycles. Used by native block-cycle builds. */
|
|
void timers_advance(uint32_t cycles);
|
|
|
|
/* Legacy coarse tick used by interpreter/oracle builds. */
|
|
void timers_tick(int cycles);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* PSXRECOMP_V4_TIMERS_H */
|