Files
psxrecomp/runtime/include/autocompile.h
Matthew Stanley 739994cfcd Step 2.8: variant-capture automation (detect -> capture -> compile -> rescan)
Runtime detects an uncovered overlay/kernel variant by sustained dirty-RAM
interp pressure inside the capture windows (g_dirty_window_dispatches,
sampled every 600 vblanks; fires only at a coherent non-loading moment via
cdrom_load_in_progress, 60s cooldown, 16/session cap), writes the capture
JSON, and spawns the game.toml-configured compile command
([runtime] overlay_autocompile_cmd, cmd.exe /C, cwd=project root, child
output kept in an in-memory ring — no log files). On child exit 0 the emu
thread rescans the cache (overlay_loader_rescan: idempotent dir re-scan +
checked-regions reset) so the new DLL loads on the next dispatch and the
variant goes native in-session. Dedup is tool-side (existing-CRC skip);
pressure drops to zero once code is native, so the loop self-limits.

New TCP: autocompile_status / autocompile_run / overlay_rescan.
compile_dll now uses absolute native paths and reports exit codes.

VERIFIED live (user-played route): 2 auto-triggers fired, captures written,
child ran recompiler+audit (new variants 1E7DDE2C, A62D0A7C discovered and
audit-clean), rescan picked the compiled DLL up in-session. OPEN ISSUE: gcc
exits 1 with no output inside the spawned cmd.exe child (same absolute-path
command succeeds from an interactive shell) — compile step currently
completed manually; suspect child-env difference, to be isolated next
session.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-09 16:16:36 -07:00

38 lines
1.4 KiB
C

/* autocompile.h — background overlay compile for variant-capture automation
* (step 2.8). Spawns the configured compile command (compile_overlays.py
* invocation from game.toml [runtime] overlay_autocompile_cmd) after an
* automatic capture, collects its output into an in-memory ring (no log
* files — CLAUDE.md §3; read it via the autocompile_status TCP command),
* and on success has the emu thread rescan the overlay-DLL cache so the new
* variant goes native in-session, without a restart. */
#ifndef PSXRECOMP_AUTOCOMPILE_H
#define PSXRECOMP_AUTOCOMPILE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Store the command line + working directory. Empty cmd disables. */
void autocompile_configure(const char *cmd, const char *cwd);
int autocompile_configured(void);
/* 1 while a compile process is running. */
int autocompile_busy(void);
/* Kick a compile if configured and idle. Returns 1 if started. */
int autocompile_request(void);
/* Emu-thread tick: applies a finished compile (cache rescan on success).
* Must be called from the same thread that owns the overlay loader. */
void autocompile_poll_main(void);
/* JSON status blob for the debug server: state, run/fail counters, last
* exit code, and the output tail. Returns bytes written. */
int autocompile_status_json(char *out, int cap);
#ifdef __cplusplus
}
#endif
#endif /* PSXRECOMP_AUTOCOMPILE_H */