31 Commits

Author SHA1 Message Date
ClydeyEXE bb57de16f9 Add a per-tick state probe and a frame-rate comparison tool
RECOMP_TICK_PROBE=<file> wraps UGameEngine::Tick (sub_000C91B0) and writes
the frame delta, level time and the player's pawn every tick, plus named
properties found through the classes' reflection data.
tools/tick_rates.py boots straight into a match at several RECOMP_FPS_LIMIT
values, plays a fixed pad sequence and tabulates jump, run, dodge, turn,
fire, projectile and clock measures by rate.

Refs #20
2026-11-12 20:46:07 +00:00
ClydeyEXE 1371caffdb Present with tearing allowed, report frame-time lows, offer a limit under the refresh
With vsync off the swap chain is now made with DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING where Windows
supports it, kept for ResizeBuffers, and presents with DXGI_PRESENT_ALLOW_TEARING, so a window is no
longer held to the display's refresh. RECOMP_PRESENT_TEARING=0 is the old path. ab.py --direct,
corridor, no bots, 3 runs a side, RivaTuner closed: tearing off 164.8-246.9 fps (two of three runs
held at 165 for most windows), on 239.4-246.2, p99 5.3 against 7.7 ms. 7 bots: 143.6 to 149.2 fps
(+3.9%, 95% CI -1% to +10%), 1% low 10.2 ms both. F11 fullscreen (2560x1440) holds 249 fps, and
six screen grabs show no black or broken frames; vsync on still holds 164.7.

[FRAMES] now ends with the 1% and 0.1% lows: the mean time of the slowest 1% and 0.1% of the
window's frames, at least one each. Presenting to the window, a frame is timed from one Present
call to the next, after the limit's wait, rather than from where the walker reaches present, which
made an even 160 fps limit read p99 7.9 ms; it reads 6.3 now. check_run.py parses both forms.
ab.py reports the lows, and its "walker ms" is now the walker's whole CPU time a frame: "other
walker cpu" alone read about -2.2 with GPU vertex programs, as d3d11 and present are wall times.

The panel's frame limits add one about 3% under the display's refresh (160 at 165 Hz), read when
the presenter starts and when the limit is changed. At 160 the 1% low is 6.5 ms against 6.25.

The walker's time in NtUserEnumDisplayDevices is not the game's: prof.py's new --callers finds
RivaTuner's RTSSHooks64.dll calling NvAPI there, and with RivaTuner running a frame took about
235 ms every 9 s, the walker inside Present. With it closed there are none.

Refs #28
2026-11-12 19:43:38 +00:00
ClydeyEXE 1d9402e738 Name the game's unnamed functions in profiles, and count exceptions with RECOMP_EXC_STATS
The game's sources had no /Zi, so the PDB named only public functions and an address in a static one took
the name of the public before it. The 5-8% "sscanf" (earlier "printf") of game-thread profiles was
recomp_fp_round24, the x87 PC=24 rounding helper, of which every generated file has its own copy. The game
target now builds with /Zi: full rebuild 381 to 389 s, PDB 4.9 to 32 MB, same code.

tools/prof.py places each address in its function by the exe's .pdata first (a chunk MSVC split off a
function counts as that function), so an address in a function with no name of its own reads
"symbol+0xOFF?" instead of a wrong name. It reads the thread list once a second instead of every sweep:
415 sweeps in 40 s became 1,735. --lines sets how many functions it lists per thread.

RECOMP_EXC_STATS=1 counts every exception from 15 s after start and logs an [EXC] line every 10 s by code,
thread, host address and guest address. With 7 bots: 12,000-19,000 a second, all access violations on
trapped device registers. Most are on the game thread in DirectSound's voice-processor command routine
(sub_002FBDD2, DSOUND section): a free-count poll at 0xFE820010, then about 20 register writes at
0xFE820160 and 0xFE820400-0xFE82043C per call, 5,000-7,600 faults a second. Two guest USB threads fault
on the OHCI registers at 0xFED00000 about 1,500 times a second between them (and the game thread
140); guest threads share the game thread's host core. A bare trapped access costs about 1 us here
before any handler runs.

Refs #3
2026-11-12 15:38:23 +00:00
ClydeyEXE c58293f8c5 Stop the bench driver pressing A into the spawn, and look up the spawn hook's caller by function
A quarter to a half of ab.py --direct runs looked like a spawn one start along the corridor (scene 5.3).
It was the same start every time: the rating draws, the PlayerStart and the settled position matched
in hits and misses. A on the "press fire" scoreboard starts a 3-4 s countdown, and A is also jump. The
driver pressed every 2.5 s, so its second press landed on the spawn, and when it came just after it the
player jumped and landed in another pose with the camera set differently for the rest of the run
(31 of 33 misses had a press after the spawn). drive_match.py now presses again only after 6 s, and not
at all once the game logs the spawn rating.

The FRand/Rand hook no longer walks the script stack on every call until the spawn: it reads the
calling UFunction from the FFrame and looks it up in a small cache, and only a RandRange call walks one
frame up (49 walks with 7 bots, 0.34 ms each, was about 270 at 2.1 ms).

Seed 1 corridor view: 31 of 56 runs with no bots and 13 of 14 with 7 before; 12 of 12 and 12 of 12
after, and 6 of 6 in an A/A of 3 a side (100.5-102.2 fps, B/A +0.8%).
2026-11-12 09:16:14 +00:00
ClydeyEXE de9996b22c Boot A/B runs straight into the corridor spawn, with no menus or rerolls
ab.py and drive_match.py take --direct: the game boots from RECOMP_CMDLINE into a CTF-Aqueduct match with
no bots and no limits, A skips the logos, and RECOMP_BENCH_SPAWN fixes the spawn. That is a hook on the script
FRand and Rand natives which, only while RatePlayerStart runs, answers from a private seeded sequence, and
turns itself off once the spawn is chosen. Seed 1 is the corridor view in every run so far. A run takes
83-85 s with --secs 60 (about 4 minutes through the menus), and the A/A spread is 1.0% a run (was 3.5%),
so 3 a side detects about 3%. Bench runs force 4:3, so they no longer depend on the saved video settings,
and --bots N gives real load.
2026-11-11 23:02:02 +00:00
ClydeyEXE 3118c84aa0 Update the toolkit to xboxrecomp v0.17.0
Our patches are rebased onto it. Where upstream now does what a patch did, upstream's version is kept: the
DirectSound sequencer-restart hold, and vertex programs decoded once per upload (with our nv2a_vsh_prepare kept
on top, so the transform pool doesn't race the first decode). The lifter fixes cut untranslated instructions
from 83 to 8, and the corridor view runs 10% faster (69.3 to 76.3 fps median, walker 9.45 to 8.21 ms a frame).

Fixes #30
2026-11-11 21:21:47 +00:00
ClydeyEXE 7d14bca0e5 Centre widescreen menus, keep movies 4:3, and fix the crosshair and pop-ups
From a played session with RECOMP_WIDE_LOG=1 (new: logs each flush's
widgets, where they sit and how far they moved):

- Menus (the flush returning to 0x135340) move to the middle whole, at their
  shape, and the HUD's flush is treated the same while a menu is drawn. Their
  background and bars fill the width: vertices at x 639-640 now reach the new
  edge, and pieces on the left edge stay.
- The canvas is no longer reported to the script as 853 wide, only drawn that
  wide. The Begin Match? pop-up is placed from ClipX and the rest in fixed
  pixels, so a wider ClipX pulled it apart.
- The first-person crosshair comes from its own flush (0x9A173), now spread
  with the HUD. Widgets between the top and bottom HUD strips stay with the
  middle (the combo wheel by the crosshair) unless wholly in an outer third.
- Full-screen movies are drawn without the canvas, so a 16:9 widescreen frame
  with no canvas for 250 ms is shown 4:3 with black side bars (boot logos).

drive_match compares menus in the middle 3/4 and the match HUD with its thirds
put back together. It passes in 4:3 and 16:9 widescreen.

Part of #9.
2026-11-06 22:09:42 +00:00
ClydeyEXE cb59439f38 Spread the widescreen HUD to the screen's edges, and open the window 16:9
The Aspect row's third choice is now "16:9 (widescreen)", and the HUD row is
gone. Squeezing the HUD into the middle 4:3 is replaced by a canvas 853 wide:

- The canvas's per-frame update (sub_00099350) makes a 640x480 canvas 480 x
  16/9 wide and maps it onto the whole picture. UC2's HUD and menu script
  place everything in fixed 640x480 pixels, so they keep their shape and lay
  out from the left.
- The canvas flush (sub_00142960) moves vertices on the old right edge
  (x = 640) to the new one, so full-width bars, fades and tints fill the
  screen. For the match HUD only (the flush returning to 0x135302; menus come
  from 0x135340), quads that touch are grouped into widgets, and each stays
  left, moves to the middle or to the right edge by which third its middle is
  in. The crosshair is centred, the radar and scores sit on the right, and the
  scoreboard, wider than 400 pixels, is centred whole.

A plain window now takes the picture's shape when it opens and when Aspect
changes, instead of opening 4:3 and letterboxing 16:9.

Checked on frames from CTF-Aqueduct: main menu, pre-match scoreboard, match
HUD. drive_match passes in 4:3 and 16:9 widescreen.

Part of #9.
2026-11-06 21:25:48 +00:00
ClydeyEXE fac0f5e8a2 Add a wider 16:9 view, with the HUD kept 4:3 in the middle
The settings panel's Aspect row gains "16:9 (wider view)": the picture is
stretched to 16:9 as before, and the game's scene projection is narrowed by
3/4 across (sub_001379C0, its only caller being the scene set-up), so the
horizontal field of view widens and the vertical one stays. The game inverts
that matrix itself, so its own culling follows. Only 4:3 views are changed;
a square 16.5-degree view is left alone.

A new HUD row keeps the canvas (HUD, menus, scoreboard) in the middle 4:3 by
squeezing the canvas-to-screen matrix for each flush (sub_00142960), or leaves
it full width. 4:3 and "16:9 (stretched)" are unchanged; the default is 4:3.

drive_match.py now saves frames as shown and compares only the middle 4:3
when the HUD is kept there; sheet.py reads its PNG frames.

Part of #9.
2026-11-06 20:04:22 +00:00
ClydeyEXE 68720920a8 Compare two settings or builds over interleaved runs in a fixed heavy view
An idle match's fps depends on where the player spawns: 65 to 158 fps on
CTF-Aqueduct, from at least seven spawn points. tools/ab.py forfeits and
re-enters until the player spawns looking down the long corridor (the heavy
view in #1), measures only windows with nothing moving in view, and reports
each side's median and spread, a bootstrap 95% interval and a Mann-Whitney p.

In that view runs vary by about 3.5%, against about 30% with any spawn. A
same-settings test showed no difference (95% CI -4% to +7%, 3 a side); a
50 fps frame limit on B came out 26% slower (CI 26-28%).

drive_match.py gains the forfeit-and-re-enter step and an optional exe
path; its behaviour for existing callers is unchanged.
2026-11-05 23:19:11 +00:00
ClydeyEXE 8453fdd9d4 Refuse to build while the game is running, as the exe is locked 2026-11-05 20:53:57 +00:00
ClydeyEXE a76e7d8586 Drive scripted matches by screen state, and check runs from their logs
tools/drive_match.py presses each button only once the screen it is meant
for is up, read from file opens in the log or the game window matched
against local reference frames, and backs out of a wrong menu to retry.
It reached the CTF-Aqueduct match in 6 of 6 final runs at about 49 s,
against about 127 s for the timed route.

tools/check_run.py reads a log and says whether the run worked: match
reached, crash, watchdog as timer or hang, menu and match fps, hitches
and failed opens, with an exit code.

run_match.ps1 no longer sets RECOMP_FLIP_PACING, which skewed match fps.

Fixes #13
2026-11-04 23:10:50 +00:00
ClydeyEXE c99226dc81 Stamp the build's version into the log
The first line of play_log.txt is now the version, so a bug report says which build it came from. It is
`git describe` at build time, with "-modified" when tracked files have changes (the toolkit, which always shows as
changed, is left out). A GitHub source zip has no history, so tools/version.txt is filled in by git as the zip is
made (export-subst). The update notice in #22 needs this.
2026-11-03 16:51:22 +00:00
ClydeyEXE 2d62f6c54d Fix setup bugs found in review: zip re-clone, bracketed paths, build exit
A zip install deleted and re-cloned the toolkit on every run, because the
hook line had landed between the toolkit check and its else. Disc paths with
[brackets] failed Test-Path's wildcard matching; they now use -LiteralPath. A
failed build's BUILD_EXIT=-1 did not match the exit pattern and crashed with
a raw error, and a missing build.log now stops with a message too. winget's
3010/1641 restart codes now end setup with "restart and run again".

check_files.py also blocks XBE tool output and logs, .gitignore covers
run*.txt and *.log, and the README's disk space figure is corrected.
2026-11-03 00:32:19 +00:00
ClydeyEXE 1df4294f4b Drop the XBE-derived JSONs from docs/ and move the kernel .def into tools/
docs/functions.json, kernel_imports.json and xbe.json were output from
discover.py and xbeinfo.py run on the game's XBE. Nothing reads them, and
anyone with the game can regenerate them. xboxkrnl.exe.def is an input to
discover.py, so it now sits beside it.
2026-11-03 00:21:53 +00:00
ClydeyEXE 7b3c52767b Add a pre-commit file check, and tidy the repo for going public
tools/check_files.py refuses game data, generated code, game, image and
binary file types, files over 5 MB, and any file containing the local
default.xbe's certificate keys, without printing them. .githooks/pre-commit
runs it on staged files and setup turns the hook on; CI runs it on every
tracked file, and also checks that setup's toolkit pin matches the
submodule.

Personal rules and machine quirks move from CLAUDE.md to a gitignored
CLAUDE.local.md. CLAUDE.md and BUILDING.md no longer say
default_analysis.json holds keys: it does not, the parser's output does.
BUILDING.md's manual steps use build\venv and create build/ first, HISTORY.md
names the rewritten commit and drops "the owner", and the README notes the
CC0 file and where play_log.txt is.
2026-11-03 00:20:34 +00:00
ClydeyEXE d05c1b4da8 Slim the README for players and fix the setup's disassembler step
The README now has the disclaimer, a status table, three-step getting
started, controls and credits. The build by hand, setup and play options and
run-time settings move to docs/BUILDING.md.

setup.ps1 quotes the --extra-sections list, which PowerShell otherwise passed
as an array, and sends the XBE parser's output, which includes the
certificate keys, to build/xbe_parser.log. Tested end to end from a git
archive of the repo: toolkit clone, extraction, recompile and build in about
20 minutes, with generated C identical to an existing checkout's.
2026-11-02 23:09:15 +00:00
ClydeyEXE 5d414c4b81 Install missing tools and work from a source zip in setup
setup.ps1 now installs Git, Python 3.12 and the VS 2022 Build Tools (C++,
CMake, Ninja) with winget after one question, clones the pinned toolkit when
the repo came as a zip without its submodule, asks for the disc image in a
file dialog, accepts an extracted disc folder, numbers its steps and can put
a desktop shortcut down. Setup.cmd and Play.cmd in the root run it and the
game with a double-click.
2026-11-02 22:53:39 +00:00
ClydeyEXE 03711c0121 Add a one-command setup script
tools/setup.ps1 -Iso <path> checks for Git, Python and MSVC with CMake and
Ninja, applies the toolkit patches unless they are already in, installs the
Python packages into build\venv, extracts and verifies the dump against the
supported SHA-1, runs the recompiler and builds. Steps whose output exists are
skipped, so a rerun carries on after a failure.

build.cmd now finds Visual Studio with vswhere, preferring 2022, instead of a
fixed Build Tools path, and lets Ninja pick the job count. The README opens
with a quick start that uses the script.
2026-11-02 22:39:28 +00:00
ClydeyEXE 77dcf109e8 Add an in-game settings panel, internal resolution and a frame limiter
F1 (or Back+Start) opens a panel drawn over the frame: internal resolution
1x-4x, a frame limit, vsync, smooth or sharp scaling, an FPS counter, and an
option to skip boot's fixed 9 s of waits. While it is open the game sees its
pads at rest. Choices persist in %LOCALAPPDATA%\xboxrecomp\ucc2_video.ini.

Render targets are now made at the chosen scale, with the viewport, scissor
and depth-bias slope scaled to match; 2x ran a scripted match at the same
rate as 1x. The limiter holds presents on a high-resolution timer: 60.0 fps
with p99 20 ms, where flip pacing leaked and alternated frame lengths.

[HITCH] lines now also sample the title's main thread and unwind its stack.
That showed both long boot frames are the title sleeping (sub_00019BB0).
2026-11-02 17:34:12 +00:00
ClydeyEXE e1c0bc81bd Log frame times, and make the 60 fps limit opt-in
[FRAMES] gives the spread of present-to-present times every 10 s and splits
the walker thread's time into D3D11 calls, readback, other CPU and idle; a
frame over 100 ms gets a [HITCH] line. The owner prefers the uncapped rate,
and the flip hold leaked in matches anyway, so play.ps1 sets it only with
-Limit60.
2026-11-02 15:14:50 +00:00
ClydeyEXE b5f9b40e7f Hold flips to the vblank, capping matches at 60 fps
The scripts now set RECOMP_FLIP_PACING=1. Two 300 s scripted matches held
60.0 fps throughout with =1 and with =edge. =1 is used because edge makes a
late frame wait for the next vblank, which would turn 45 fps into 30.
2026-11-02 11:21:41 +00:00
ClydeyEXE 915224d061 Draw 8-bit shadow maps, which stops the black boxes
The vertex-program path dropped triangles for 1-byte surfaces, so the shadow
maps UC2 draws into B8 surfaces stayed black, and the pass that projects them
darkened its whole frustum. Those triangles now reach the back end, which reads
such a target as luminance.

Also add tools/play.ps1 -DrawLog, and shorten the scripted press of down, which
skipped to the System Link menu now that menus run faster.
2026-11-02 01:24:10 +00:00
ClydeyEXE 54aa6084fb Stop the USB race and the DSP resets that chopped the audio
XPP crashes came from USB submits and DPC completions racing over transfer
descriptors with nothing keeping them apart, so the scripts now set
RECOMP_DISPATCH_GATE=1.

DirectSound checks EP program memory for a word only a running EP program
writes, and without it reset the DSP about 50 times a second, stalling 10 ms
each time. About half of all audio periods came out silent. The DSP stub now
writes the word, and a stopped sequencer no longer produces silent periods.
2026-11-02 00:39:00 +00:00
ClydeyEXE 70708c936c Add CLAUDE.md and split long-lived notes out of the handoff
CLAUDE.md holds commands and rules, HISTORY.md past fixes, and HANDOFF.md only
current state. tools/update_patches.ps1 regenerates the toolkit patch and proves
it rebuilds the toolkit byte for byte. Line endings are now LF in the working
tree, CRLF for .cmd, which stops git's warning on every commit.
2026-11-01 23:30:20 +00:00
ClydeyEXE db588d8e11 Capture the playtest and hand over for the 60 fps work
Records what the owner saw in their playtest and what the log shows, and puts the
next work in order, starting with measuring frame times. Corrects an earlier note:
the crashes blamed on audio decoding are in XPP, the USB and controller stack.
Adds tools/build.cmd, tools/dis.py and tools/frame_trace.py, and documents the
settings the game now needs.
2026-11-01 23:23:12 +00:00
ClydeyEXE fa399b1001 Run D3D's pushbuffer fixups, which stops the flicker
D3D runs recorded pushbuffers by jumping into them, and a trap on NO_OPERATION
patches the recording's tail with the return address. Without it every tail
returned to where its first use came from, so old commands replayed and frames
were spliced together. recomp_manual.c now applies the fixups at the same point
in the stream.

D3D also patches those NO_OPERATIONs while GET says the GPU has not reached them,
so GET has to be exact: tools now use RECOMP_PB_WALK=dma. Strips alternate winding,
which culling had to account for. Guest threads go on one core, as on the console.
2026-11-01 22:52:59 +00:00
ClydeyEXE 6d3b08111b Draw on the GPU through a Direct3D 11 back end
Menus go from about 6 fps to 45-60, gameplay from 7 to about 30-45. The
gameplay picture is still wrong: some frames have spiky geometry.

The executor now acks kicks mid-walk, so game and GPU no longer take turns,
and follows the ring's jump instead of losing commands at each wrap. Fence
waits give up only when GET stops moving. Adds profiling and test tools.
2026-11-01 21:52:20 +00:00
ClydeyEXE 89199c97c9 Reach a match with C++ exception dispatch
The runtime returned from every throw, so code ran on after them. Loading a match
throws "Can't resolve package name" in normal use, which ended in a garbage file
name and the dirty disc screen. Replace _CxxThrowException with a dispatcher that
walks fs:[0], reads the MSVC tables, runs destructors, and longjmps to a wrapper
that runs the catch funclet and its continuation. tools/add_eh_entries.py makes
the continuations into entry points.

GetVisibilityTestResult waited for a report the executor never writes, freezing
map load, so it now reports everything visible.

A scripted Instant Action reaches gameplay on CTF-Aqueduct, with HUD and radar, and
ran 540 s with no fatal screen at about 11 fps. The world is mostly black in play.

Also update the handoff for a fresh start, fix the README's log redirect, which
captured nothing from this GUI exe, and ignore stderr.txt.
2026-11-01 20:18:23 +00:00
ClydeyEXE 45fe615ae1 Add handoff notes and watchdog mapping tool 2026-11-01 17:11:23 +00:00
ClydeyEXE e74d8fd2a0 Project scaffold, XBE tooling and function discovery
Adds the XISO extractor, XBE parser with section digest checks, kernel import
naming, a first-pass function discovery tool and a CMake smoke build. Game data
stays in the gitignored assets/ folder.
2026-11-01 14:59:55 +00:00