Skip to content

runtime: overlay_region_floor game.toml key (follow-up to #160) - #242

Open
Alexbeav wants to merge 2 commits into
mstan:masterfrom
Alexbeav:pr/overlay-region-floor-toml
Open

runtime: overlay_region_floor game.toml key (follow-up to #160)#242
Alexbeav wants to merge 2 commits into
mstan:masterfrom
Alexbeav:pr/overlay-region-floor-toml

Conversation

@Alexbeav

Copy link
Copy Markdown
Contributor

Summary

#160 added the PSX_OVERLAY_REGION_FLOOR environment override for titles whose secondary EXEs load below the boot text end. This exposes the same floor as a [runtime] overlay_region_floor key in game.toml so a title can declare it without an environment variable (Gran Turismo: GTOS/GTMENU/GTMAIN load at 0x80010000). The commit also lets a bundled overlay toolchain use gcc when it is on PATH; that half can be split out if preferred.

Commits

  • d596b0e runtime: [runtime] overlay_region_floor config key; bundled toolchain drives gcc when available

Scope

6 files changed, 107 insertions(+), 31 deletions(-)

Validation

Cherry-picked from the Alexbeav/psxrecomp main line, where the same changes pass the recompiler/runtime/runtime-ui ctest gates with only the pre-existing failures (aot_overlay_discovery, release_zip, gte_register_access_test link). This branch was also built on mstan/master as of 01c647e with the same result.

… drives gcc when available

Two shipping gaps left Gran Turismo's gameplay and FMV code on the
interpreter (0.55-0.64x real time) even though the recompiled boot EXE was
fine:

1. The overlay region floor defaults to the boot EXE text end. GT's secondary
   EXEs (GTOS/GTMENU/GTMAIN/GTEND) all load at 0x80010000, inside that range,
   so they were never overlay-cache eligible. The only way to lower the floor
   was the PSX_OVERLAY_REGION_FLOOR env var, which a shipped package cannot
   carry. Add `[runtime] overlay_region_floor` (hex string or integer), applied
   before the env override with the same kernel-window clamp.

2. The bundled overlay_toolchain/ was only used to build the tcc command.
   A dev/production box with gcc on PATH but no game.toml autocompile command
   got no compiler at all. Treat the bundle as a gcc toolchain provider too:
   gcc counts as available when the bundle is present and a gcc/cc/clang is
   on PATH, and the same bundle then drives compile_overlays.py with
   --compiler gcc. One package yields gcc shards on a dev box and tcc shards
   on a toolchain-less player box.

Measured on GT1 (SCUS-94194), headless boot -> intro FMV -> attract, with the
floor at 0x10000 and gcc autocompile: 1.27-1.38x real time vs 0.55-0.64x;
SPU production 27 kHz -> 59 kHz (the FMV audio distortion was starvation).

(cherry picked from commit 0d226e5)
@mstan

mstan commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Small config robustness concern.

overlay_region_floor accepts integer TOML values, but the parser casts v.as_integer() directly to uint32_t and leaves validation to the later runtime clamp/mask. That means negative or very large TOML integers can silently wrap/mask into a different physical address instead of failing loudly.

I think we should reject integer values outside the intended PSX physical/kernel-safe range at parse time, matching the fail-loud style used by nearby config fields. Do you agree? The string hex path already goes through parse_hex; this is only about the raw integer branch.

Raw TOML integers were cast straight to uint32_t and left to the runtime
clamp/mask, so a negative or >32-bit value could wrap or be masked into a
different physical address silently. Reject those at parse time, and require
the (KSEG-stripped) value to name main RAM above the kernel window
(0x10000..0x1FFFFF), matching the fail-loud style of the nearby fields. The
hex-string path already goes through parse_hex and now shares the range check.
@Alexbeav

Copy link
Copy Markdown
Contributor Author

Agreed. Pushed 699022e: raw TOML integers are now validated at parse time — negative or >32-bit values are rejected, and the KSEG-stripped value must name main RAM above the kernel window (0x10000..0x1FFFFF physical), failing loud in the same style as debug_port. The hex-string path still goes through parse_hex and now shares the same range check. test_overlay_region_floor_config.py pins both rejections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants