diff --git a/src/include/86box/nv/vid_nv3.h b/src/include/86box/nv/vid_nv3.h index 1a2f75d0b..f95d1c5f4 100644 --- a/src/include/86box/nv/vid_nv3.h +++ b/src/include/86box/nv/vid_nv3.h @@ -193,6 +193,7 @@ extern const device_config_t nv3_config[]; #define NV3_PRMIO_END 0x7FFF #define NV3_PTIMER_START 0x9000 // Programmable Interval Timer #define NV3_PTIMER_INTR 0x9100 +#define NV3_PTIMER_INTR_ALARM 0 // Alarm interrupt #define NV3_PTIMER_INTR_EN 0x9140 #define NV3_PTIMER_NUMERATOR 0x9200 #define NV3_PTIMER_DENOMINATOR 0x9210 @@ -301,6 +302,7 @@ extern const device_config_t nv3_config[]; #define NV3_PGRAPH_INTR_1 0x400104 #define NV3_PGRAPH_INTR_EN_0 0x400140 // Interrupt Control for PGRAPH #1 #define NV3_PGRAPH_INTR_EN_0_VBLANK 8 // Fired every frame +#define NV3_PGRAPH_INTR_EN_0_VBLANK_ENABLED 0x1 // Is the vblank interrupt enabled? //todo: add what this does #define NV3_PGRAPH_INTR_EN_1 0x400180 // Interrupt Control for PGRAPH #2 (it can receive two at onc) diff --git a/src/video/nv/nv3/subsystems/nv3_ptimer.c b/src/video/nv/nv3/subsystems/nv3_ptimer.c index 1a6c9d73d..1acebc98f 100644 --- a/src/video/nv/nv3/subsystems/nv3_ptimer.c +++ b/src/video/nv/nv3/subsystems/nv3_ptimer.c @@ -48,14 +48,28 @@ void nv3_ptimer_init() nv_log("Done!\n"); } +// Handles the PTIMER alarm interrupt +void nv3_ptimer_interrupt(uint32_t num) +{ + nv3->ptimer.interrupt_enable |= (1 << num); + nv3_pmc_handle_interrupts(true); +} + +// Ticks the timer. +void nv3_ptimer_tick() +{ + if (nv3->ptimer.time >= nv3->ptimer.alarm) + { + nv3_ptimer_interrupt(NV3_PTIMER_INTR_ALARM); + } +} + uint32_t nv3_ptimer_read(uint32_t address) { - // before doing anything, check the subsystem enablement + // always enabled nv_register_t* reg = nv_get_register(address, ptimer_registers, sizeof(ptimer_registers)/sizeof(ptimer_registers[0])); - // todo: friendly logging - nv_log("NV3: PTIMER Read from 0x%08x", address); // if the register actually exists