From 4a30c5cc0184dfea39d199f9c41c4358ebda1d4e Mon Sep 17 00:00:00 2001 From: Alexandros Mandravillis Date: Wed, 19 Aug 2026 16:47:15 +0300 Subject: [PATCH] runtime: add PSX_OVERLAY_REGION_FLOOR override for streamed-over text ranges Some titles stream level code over pages inside their own static text range (Driver 2 streams mission code over its boot text), leaving those pages permanently diverged: below the overlay floor they are excluded from overlay capture and fall into single-instruction dispatch thrash (hundreds of thousands of one-instruction dispatches per window). PSX_OVERLAY_REGION_FLOOR lowers the floor per title so diverged text pages become overlay-cache candidates and chain through local flow. Value is clamped above the kernel window; default behavior is unchanged when the variable is unset. On Driver 2 this took text-blocked interpreter work from 278M to 37M instructions per window. --- runtime/src/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index 97c3ab5f..d8348e11 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp @@ -10897,6 +10897,20 @@ int main(int argc, char** argv) { uint32_t text_end = (gc.load_address + gc.text_size) & 0x1FFFFFFFu; if (text_end > 0x00010000u /* DIRTY_RAM_KERNEL_WINDOW_END */) g_overlay_region_floor = text_end; + /* PSX_OVERLAY_REGION_FLOOR: per-title override for games whose TEXT + * range is itself partially overwritten by streamed level data + * (Driver 2 streams mission code over pages inside its static text + * range). Lowering the floor routes those regions through local-flow + * chaining and makes them overlay-cache candidates, so live-byte + * closures can own them instead of single-instruction dispatch + * thrash. Clamped to stay above the kernel window. */ + { + const char* fenv = std::getenv("PSX_OVERLAY_REGION_FLOOR"); + if (fenv && fenv[0]) { + uint32_t v = (uint32_t)strtoul(fenv, nullptr, 0) & 0x1FFFFFFFu; + if (v >= 0x00010000u) g_overlay_region_floor = v; + } + } std::fprintf(stdout, "psxrecomp: overlay_region_floor = 0x%05X (game text end)\n", g_overlay_region_floor);