Files
psxrecomp/runtime/include/boot_state.h
T
Matthew Stanley b29065aa56 Add dispatch hit counter and fast boot with BIOS snapshot
dispatch_stats TCP command: g_dispatch_static_hits incremented on every
binary-search hit in generated dispatch; exposed alongside miss_total and
miss_unique so static coverage ratio is measurable numerically.

fast_boot = true in [runtime]: first launch runs BIOS normally (logos
visible) and captures full system state at game handoff to
fast_boot_<bios_cksum>_<entry_pc>.bin adjacent to the BIOS. Every
subsequent launch restores the snapshot and dispatches directly to the
game entry PC — no BIOS execution, instant start.

Snapshot captures: CPU (gpr/hi/lo/cop0/gte), RAM (2 MB), scratchpad,
dirty-RAM bitmap, i_stat/i_mask, timer state. GPU/SPU/VRAM not included
(game reinitialises). Display-disabled vblanks now clear SDL to black so
the window never shows OS-background white during game crt0 setup.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-05-30 10:40:54 -07:00

65 lines
1.8 KiB
C

#ifndef PSX_BOOT_STATE_H
#define PSX_BOOT_STATE_H
#include <stdint.h>
#include "cpu_state.h"
#ifdef __cplusplus
extern "C" {
#endif
#define BOOT_STATE_MAGIC 0x50535842u /* "PSXB" */
#define BOOT_STATE_VERSION 1u
/* Serialized header — written verbatim to disk, followed by 2 MB RAM blob. */
typedef struct {
uint32_t magic;
uint32_t version;
uint32_t bios_checksum; /* sum of all uint32_t words in BIOS ROM */
uint32_t entry_pc;
uint32_t gpr[32];
uint32_t pc;
uint32_t hi, lo;
uint32_t cop0[32];
uint32_t gte_data[32];
uint32_t gte_ctrl[32];
uint32_t i_stat;
uint32_t i_mask;
uint16_t timer_counter[3];
uint8_t _pad0[2];
uint32_t timer_mode[3];
uint16_t timer_target[3];
uint8_t _pad1[2];
int32_t timer_irq_line[3];
uint32_t timer_frac[3];
uint8_t scratchpad[1024];
uint32_t dirty_bitmap[16]; /* 512 4 KB pages / 32 bits per word */
uint8_t _pad2[4];
} BootStateHeader;
/* Save full system state at game handoff. Returns 1 on success. */
int boot_state_save(const CPUState* cpu, uint32_t bios_checksum,
uint32_t entry_pc, const char* path);
/* Load and validate snapshot; restores CPU/RAM/hardware. Returns 1 if valid. */
int boot_state_load(const char* path, uint32_t bios_checksum,
uint32_t entry_pc, CPUState* cpu);
/* Register a deferred capture: when boot_state_trigger_capture() is called
* (from fntrace at game-start), serialize state to path. One-shot. */
void boot_state_set_capture(const char* path, uint32_t bios_checksum,
uint32_t entry_pc);
/* Called from fntrace when game entry PC first fires. */
void boot_state_trigger_capture(const CPUState* cpu);
#ifdef __cplusplus
}
#endif
#endif /* PSX_BOOT_STATE_H */