Commit Graph

937 Commits

Author SHA1 Message Date
Matthew Stanley 76a53d9090 Invalidate per-PC code caches when a savestate replaces RAM
Several consumers cache a classification of the instruction at a given PC and
key that cache on g_dirty_ram_code_gen, per the contract stated where the
counter is defined (runtime/src/memory.c): "Consumers that cache per-PC
classifications of RAM instructions compare against this and re-derive after any
code change - a cached kind must never survive an overlay reload." Today that
counter is bumped from exactly two places, both on the instrumented store path:
a page's clean->dirty transition, and dirty_ram_mark_executable_range().

A savestate restore reaches neither. BS_SEC_RAM applies a raw memcpy over all
2 MB, so code identity at any address can change completely while no page makes
a clean->dirty transition and no executable range is marked. Every cache keyed
on the generation therefore keeps serving verdicts derived from the PREVIOUS
contents. The overlay loader's negative "no native owner" cache is the damaging
one, because overlay_loader_dispatch() consults it before rediscovery, so one
stale entry can pin an address to the wrong implementation for the rest of the
run.

Note the same restore already invalidates psx_kernel_bless_note_range(), so the
path is aware it must invalidate downstream caches - it only ever did one of
them.

Fix: add dirty_ram_invalidate_code_caches() and call it after the BS_SEC_RAM
memcpy. dirty_ram_set_bitmap_words() (the BS_SEC_DIRTY apply path) calls it too,
since a wholesale bitmap replacement changes which addresses are RAM-resident
code by the same argument. Bumping the generation is sufficient by construction:
each cache stores the generation it was derived under and re-derives on
mismatch, so this fixes every consumer at once instead of patching them
individually.

Scope, stated honestly: this closes a real latent correctness gap in the load
path and is worth having on its own. It is NOT a fix for the separate,
still-open bug where loading a gameplay state into a process that never entered
that stage leaves the player unable to move - that was measured and the overlay
cache is demonstrably NOT its cause (the dirty bitmap is identical between a
working and a broken instance, and covers only the kernel window, so the
player's code is static-dispatched in both). No behaviour change for a process
that never loads a state.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-24 23:39:41 -07:00
Matthew Stanley 68667cd58b disc+bios: either file the user picks resolves, mounts, and verifies
Two path-resolution defects where the runtime silently accepted only one of
two equally-valid spellings of the same input.

1. Disc: picking the .cue threw away the disc's TOC.

normalize_disc_path_for_launch() swapped any .cue for its same-named .bin
unconditionally, and every disc entry point (game.toml, --disc, the cached
disc.cfg, the launcher's Change Disc, the first-run dialog) went through it.
That discarded the cue's table of contents -- every CD-DA track and pregap
with it -- even though iso_reader.cpp has full multi-FILE cue support that
the swap defeated before it was ever reached. In the other direction,
picking a redump audio-track bin mounted that track as the whole disc, which
cannot boot.

resolve_disc_path() (runtime/include/disc_path.h) now canonicalizes any pick:

  .cue that resolves            -> mount the cue (TOC intact)
  .cue with a missing bin       -> the payload it still names, else a
                                   stem-matched sibling image
  .bin/.iso/.img owned by a cue -> mount that cue
  bare image, no cue            -> mount it

identify_disc() resolves through the same code, so the header/serial/CRC32
verdict is read from the data track no matter which member was picked.

While here: the mount path and the verify path had two divergent private cue
parsers (quoted-only + case-sensitive vs quoted-or-bare + case-insensitive),
so they could disagree about the same file. Both now use one parser
(runtime/include/cue_sheet.h), which additionally handles CRLF, backslash
paths, and case-insensitive payload lookup for case-sensitive filesystems.

2. BIOS: the multi-BIOS rename made configs and dump folders incompatible.

SCPH*.toml name "US-PSX-SCPH1001.BIN" while every pre-existing dump folder,
bios.cfg and tools/regen_bios.sh default name "SCPH1001.BIN". Either
combination fataled with "cannot open BIOS file" despite the right ROM being
present. resolve_bios_rom() (recompiler/include/bios_rom_alias.h) matches on
the model token -- the last '-'-separated component of the stem -- so both
conventions resolve in both directions without a hardcoded alias table.
Applied at the config loader, the positional psxrecomp-bios CLI, and each
rung of the runtime's BIOS search.

The positional CLI also derived out_stem from the raw filename, so a
region-qualified ROM would have emitted US-PSX-SCPH1001_full.c -- a name
runtime.cmake cannot link. It now derives the model token.

Also fixes SCPH5552.toml, whose rom field omitted the bios/ directory that
its two siblings have.

Tests: test_disc_path_resolve (36 checks, five dump layouts) and
test_bios_rom_alias (15 checks, both directions + negative cases), both
registered in runtime/CMakeLists.txt. Registered the pre-existing
test_iso_reader_cdda, which was wired into no build.

Verified on real dumps: Ape Escape .cue and .bin both give
SCUS-94423 / NTSC-U / crc=C6F455BC; Tomba 2's multi-track dump gives
crc=1FB8C151 and a 2-track TOC from the .cue, the data bin, and the CD-DA
bin alike.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-24 22:17:52 -07:00
Matthew Stanley a8aa640b79 runtime: name the exact CLI flag when no file picker is available
On macOS/Linux there is no native GUI file picker, and in headless mode a
picker would block, so pick_runtime_file() bails when it can't resolve the
BIOS/disc interactively. The old message ("<title> requires a command-line
path on this platform") never said WHICH flag to pass, so a first-time
from-source user on Linux hit "no BIOS selected; exiting." with no idea what
to do.

Thread the responsible flag (--bios / --disc) into pick_runtime_file and print
an actionable message with the flag and a full example command, on both the
headless and the no-GUI-picker paths. Points at the game README's "Building
From Source" for the full run line.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-24 13:02:44 -07:00
Matthew Stanley bfa760f43b build: fail early with a clear message when recompiled game C is missing
The runtime links generated/<serial>_{full,dispatch}.c, produced by a separate
recompiler step run before the build. Those paths are marked GENERATED so cmake
configure succeeds before that step has run — which meant skipping generation
surfaced only as a raw "cc1: fatal error: <file>: No such file or directory"
deep in the build, with no hint that a step was skipped or what produces the file
(exactly the trap a from-source builder on a fresh checkout hits).

Add runtime/check_generated_sources.cmake and wire it into
psxrecomp_add_runtime_target as a build-time dependency of the runtime target:
a missing game source now aborts at build start with the files named and the
exact fix (build recompiler -> extract EXE -> generate -> rebuild), and configure
emits an early non-fatal warning. Framework-wide, so every game inherits it.

Also fix the docs/BUILDING.md "build and run a game" recompiler invocation (the
framework is a submodule at psxrecomp/, not ../psxrecomp/) and add the
recompiler-build step.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-24 09:36:14 -07:00
NyperYuhgard 2ebb2b1a6b Multi-Bios (seeds required) 2026-07-24 01:38:56 -05:00
Alex Vanderveen 09067f29dc fix title bar separator character 2026-07-23 19:05:30 -04:00
Matt Stanley 0920787d4b Merge pull request #74 from OpokXeno/fix/present-letterbox-uv-inset
present: fix short-band letterbox for native display modes + UV edge bleed
2026-07-23 13:11:58 -07:00
Matt Stanley 05f1f90206 Merge pull request #71 from ClaudioVarandas/feat/ws-cull-bltz-sites
recompiler: [widescreen.cull] bltz_sites (explicit left-edge funnel widen)
2026-07-23 12:02:29 -07:00
Matt Stanley b3eb802a49 Merge pull request #76 from mstan/codex/rmlui-latest
Remove stale RmlUi launcher remnants
2026-07-23 11:08:48 -07:00
Matthew Stanley f86087ad94 Remove stale RmlUi launcher remnants 2026-07-23 00:29:22 -07:00
Alex Vanderveen 2b2573bd82 fix(pgo): soft-exit on MinGW SIGTERM/SIGINT for .gcda flush
Windows CI train uses MSYS2 kill; without handlers atexit/gcov never runs.
Also handle console Ctrl+C/Break/Close.
2026-07-23 02:57:05 -04:00
Alex Vanderveen 0fe35cebad fix(pgo): soft-exit on SIGTERM/SIGINT so gcov flushes .gcda
Default signal termination skips atexit, so -fprofile-generate never
writes profiles when train scripts kill the process.
2026-07-23 02:41:31 -04:00
Alex Vanderveen 3cefe309f9 CI workflow bugifx 2026-07-23 01:50:54 -04:00
Alex Vanderveen 980d170850 fix(netplay): match recomp-ui join(guest_bind) ABI
UI now passes an in/out guest UDP bind (prefer 7778). Accept the 4th
argument, reject :0, and stop advertising ephemeral 0.0.0.0:0 on online
join so Windows CI links and online guests get a dialable endpoint.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-23 01:50:15 -04:00
Alex Vanderveen c34c1460e0 Merge remote-tracking branch 'refs/remotes/origin/master' 2026-07-23 01:27:44 -04:00
Alex Vanderveen 1347e49dfc patch FMV playback, fix artifact flicker on cutover to new video 2026-07-23 01:22:11 -04:00
Matthew Stanley cece00296a feat: add adaptive native widescreen
Add a resize-driven aspect option, keep native-wide culling and spawning hooks engaged across live aspect changes, and widen host GP0 draw-area pruning only for the active wide framebuffer.

Credit OpokXeno's independently discovered draw-area pruning fix documented in PR #73.

Co-authored-by: Opok <novelasevilliousesp@gmail.com>
2026-07-22 21:59:31 -07:00
Alex Vanderveen 1a73e9826c patch hosted lobby launch game 2026-07-23 00:44:53 -04:00
Alex Vanderveen 8a362a36ad build: drop lib/recomp-ui; games vendor UI at repo root
Discover recomp-ui from CMAKE_SOURCE_DIR/recomp-ui (or RECOMP_UI_ROOT).
Keep lib/recomp-net in the engine.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-23 00:27:15 -04:00
Alex Vanderveen 7dc96f265d bump version to master 2026-07-22 23:18:34 -04:00
Alex Vanderveen 8c995f2295 Merge pull request #75 from TechnicallyComputers/master
Synergy merge
2026-07-22 23:06:21 -04:00
Alex Vanderveen 993857fa36 Merge pull request #3 from mstan/master
merge
2026-07-22 23:05:35 -04:00
Opok d6a52cb9d8 present: fix short-band letterbox for native modes + UV edge bleed
Two present-path fixes:

1. The short GP1(07h)-band letterbox (MotK 128-line FMV) fired for any
   frame under 240 lines, which also catches games whose native display
   mode is short full-time (Xenogears runs 320x216): every 4:3
   menu/load and every FMV got a ~10% vertical squash. No numeric
   threshold separates the cases (216 < 224 too), so split by purpose:
   15-bit game frames never shrink (adjustment removed from
   gl_renderer_present_vram), and the FMV paths keep the correction
   only for genuinely windowed video bands (gl_renderer_present, and
   the SDL path gated on pin_43 && depth24_frame) with the band under
   80% of the 240-line field. MotK's 128-line FMV keeps its aspect fix;
   native 216/224-line display modes fill the rect as before.

2. present_target_quad mapped quad corners to texel edges, so with
   GL_LINEAR the outermost dest pixels blend the border texel with
   neighboring VRAM outside the content rect (visible 1-2px edge
   stripes with linear present filtering, e.g. menu frames showing the
   adjacent framebuffer). Center-map the UVs with a half-texel inset;
   interior sampling is unchanged. Covers both callers (canonical VRAM
   present and wide-FBO present).
2026-07-23 00:35:36 +02:00
Claudio Varandas 64ca4c3dba recompiler: [widescreen.cull] bltz_sites (explicit left-edge funnel widen)
Left-edge counterpart to slti_sites: emit psx_ws_cull_bltz at configured
bltz PCs. detect_cull_bltz_sites only classifies left-edge bltz for
auto_screen_x-qualified functions, so an X-only funnel wired via explicit
slti_sites had no left-edge widen. bltz_sites closes that gap. Identity at
4:3; regen-class.
2026-07-22 22:36:41 +01:00
Matthew Stanley ed5b1838b8 Merge pull request #68 from keeganatorr/Subdirectory-Linux-Fix 2026-07-22 12:29:09 -07:00
Matthew Stanley 280330e63f Test cross-platform boot path handling 2026-07-22 12:25:06 -07:00
Matt Stanley 7cc35bda7d Merge pull request #69 from mstan/fix/tomba-vulkan-renderer-fixes
Vulkan: fix draw-area batching and enable builds by default
2026-07-22 12:11:24 -07:00
Matthew Stanley 27de42d073 vulkan: fix draw-area batching and enable builds by default 2026-07-22 12:07:32 -07:00
Opok addf1490f6 Merge remote-tracking branch 'upstream/master' 2026-07-22 20:07:23 +02:00
Opok ce8f0ff549 Mark bios_emitter_fingerprint.sh executable 2026-07-22 19:32:42 +02:00
Keeganator e8c8b2b964 Fix psx executable linux subdirectory 2026-07-22 19:26:22 +10:00
Matthew Stanley e558c971ab runtime: restore native Tomba FMV overlays 2026-07-22 00:35:26 -07:00
Matthew Stanley 1ea7e28b10 runtime: fix debug cycle throttle symbols 2026-07-21 22:37:43 -07:00
Matthew Stanley d482ab67a2 runtime: resume compiled code after patched FMV entries 2026-07-21 22:32:07 -07:00
Matthew Stanley 6c914a763f runtime: quiet high-frequency diagnostics during FMV 2026-07-21 22:24:55 -07:00
Matthew Stanley f1bdefad20 runtime: batch faithful FMV load-cycle charges 2026-07-21 22:23:15 -07:00
Matt Stanley 985849dd9b Merge pull request #66 from mstan/fix/merged-submodule-pins
Finalize merged netplay dependency pins
2026-07-21 21:57:33 -07:00
Matthew Stanley 65845939bf build: finalize merged dependency pins 2026-07-21 21:57:18 -07:00
Matt Stanley 0194a70cc6 Merge pull request #65 from mstan/feat/recomp-ui-netplay-integration
Draft: integrate recomp-ui netplay flow
2026-07-21 21:55:38 -07:00
Matthew Stanley 87491cb035 launcher: integrate recomp-ui netplay flow 2026-07-21 21:39:28 -07:00
Matthew Stanley 0527806ce3 Repair netplay PR rebase for MotK bring-up 2026-07-21 21:38:05 -07:00
Alex Vanderveen b6850026a4 Restore missing cycle/icache link symbols for MotK.
Re-add watchdog/PC-sample fire wrappers and overlay icache_fetch_fn;
stop shadowing the inlined psx_advance_cycles with a missing extern.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 21:38:05 -07:00
Alex Vanderveen 30df7acaf2 Restore missing cycle/icache link symbols for MotK.
Re-add watchdog/PC-sample fire wrappers and overlay icache_fetch_fn;
pull inlined psx_advance_cycles via psx_cycles.h.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 21:38:05 -07:00
Alex Vanderveen fe7913cbca Fix psx_cycles / audio linkage for MotK CI.
Export service_to_now, rename advance to *_slow for the header inline,
and give g_audio_host_rate C linkage.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 21:38:05 -07:00
Alex Vanderveen 916b8ca7d3 Fix incomplete load/icache refactor for MotK CI.
Rename out-of-line load helpers to *_slow to match psx_cyc.h inlines,
declare psx_icache_fetch/reset, and wire overlay callbacks to slow paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 21:38:05 -07:00
Alex Vanderveen 6475162d80 Bump recomp-net for savestate/SRAM transfer APIs 2026-07-21 21:38:05 -07:00
Alex Vanderveen 0aa50e514f Update bios_emitter_fingerprint.sh 2026-07-21 21:38:05 -07:00
Alex Vanderveen 4eb1794abb Update regen_bios.sh 2026-07-21 21:38:05 -07:00
Alex Vanderveen 7cf9958135 FMV optimizations 2026-07-21 21:38:04 -07:00
Alex Vanderveen 0b890cdc13 lobby game version control 2026-07-21 21:38:04 -07:00