mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-27 10:38:46 -04:00
11799d4189
Extend the overlay JIT cache below the 0x98000 floor to kernel RAM [0, 0x10000) — the BIOS part-2 image + install-at-runtime stubs (Rule 18), dominated by the SIO data-byte slot at 0xCF0 whose install-slot hook tail-dispatches the whole exception-handler tail into the interpreter on EVERY exception once installed. Window model (dirty_ram_interp.h): two capture/candidate windows — kernel [0, 0x10000) and overlay [0x98000, RAM); main-EXE text between them is statically recompiled, never captured. Interp local-flow gates intentionally stay overlay-only (kernel runs per-block in exception context; named constant documents this). - overlay_capture: per-window dirty-run enumeration, runs clamped at window edges (kernel CPU-write pages and main-EXE DMA pages can be adjacent; never merge them). - overlay_loader: dispatch lazy-load gate covers both windows; scan_cache_dir validates the <addr8>_<crc8>.dll shape explicitly (kernel region_start 0 is legal, zero-parse is no longer a sentinel). - classifier (compile_overlays.py): kernel-window-only DISPATCH_ROOT promotion — an orphan dispatch interior no rooted walk covers has no host to truncate and is a real execution root by construction (the static install-slot hooks tail-dispatch into it). One orphan per iteration so remaining orphans alias into the new host. Overlay regions stay ineligible (cross-variant per-PC evidence: 0xE889C class). - main_psx --overlay: 'dispatch_root' seed lines are trusted walk roots (exempt from the boundary re-check); seed range is now the loaded image's own bounds (the old hardcoded [0x80010000,0x80200000) window silently dropped kernel seeds). - overlay_api/loader/DLL preamble: route psx_restore_state_escape through OverlayCallbacks (appended last, by-value copy keeps old DLLs compatible) — exception-context kernel code longjmp-returns. Tomba verified (user-played: title -> LOAD list renders -> save loads -> overworld laps): kernel interp per-PC rows 3 -> 0 (was 0xCF0 = 61,775 dispatches / 2.71M insns at the LOAD screen alone, ~4.6M insns/session); host func [0xCF0,0xEA0) + 0xDF8/0xE08 aliases, audit clean; dispatch_native 357,763; dispatch_miss_total 0; interp aborts 0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
51 lines
1.7 KiB
C
51 lines
1.7 KiB
C
#ifndef OVERLAY_API_H
|
|
#define OVERLAY_API_H
|
|
|
|
/* Shared ABI between psx-runtime.exe and overlay DLLs.
|
|
*
|
|
* After LoadLibrary, the runtime calls overlay_init() with this struct.
|
|
* The DLL stores the pointers and routes all cross-module calls through them.
|
|
*/
|
|
|
|
#include "cpu_state.h"
|
|
#include <stdint.h>
|
|
|
|
typedef struct {
|
|
/* Core dispatch: routes call_by_address() and out-of-overlay jal */
|
|
void (*dispatch_call)(CPUState *cpu, uint32_t addr, uint32_t ra);
|
|
/* Interrupt check: called after every function return in overlay */
|
|
void (*check_interrupts)(CPUState *cpu);
|
|
/* GTE coprocessor 2 execution */
|
|
void (*gte_execute)(CPUState *cpu, uint32_t cmd);
|
|
/* MIPS syscall (break/syscall instructions) */
|
|
void (*psx_syscall)(CPUState *cpu, uint32_t code);
|
|
/* Unresolved dispatch target */
|
|
void (*psx_unknown_dispatch)(CPUState *cpu, uint32_t addr, uint32_t phys);
|
|
/* Debug instrumentation: called at every function entry (may be NULL) */
|
|
void (*log_call_entry)(uint32_t func_addr);
|
|
/* RestoreState/ReturnFromException longjmp escape (interrupts.c). The
|
|
* recompiler emits this at longjmp-return sites in exception-context
|
|
* kernel code (the install-slot / kernel-window class). Appended LAST:
|
|
* overlay_init copies the struct by value, so older DLLs built against
|
|
* the shorter struct simply never read this member. */
|
|
void (*psx_restore_state_escape)(void);
|
|
} OverlayCallbacks;
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Exported by every overlay DLL. Call once after LoadLibrary. */
|
|
#ifdef _WIN32
|
|
__declspec(dllexport)
|
|
#else
|
|
__attribute__((visibility("default")))
|
|
#endif
|
|
void overlay_init(const OverlayCallbacks *cbs);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* OVERLAY_API_H */
|