A title that polls its pad a few times a second -- Burnout 3 under the
software rasteriser -- read "down" and "a" in the same report, which
landed it in the wrong menu. Lines read together now fire one after
another with a 200 ms release between them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fixed timeline cannot navigate a menu on a rasterised run: how long a
screen takes to appear depends on how much the software rasteriser has
to draw, so the same script lands its presses on different screens from
one run to the next. Burnout 3's title screen arrived at 37 s in one run
and past 44 s in the next, and the START meant for it went nowhere.
RECOMP_PAD_LIVE=<file> polls the file every 50 ms and presses each new
line -- <button>[+<button>...][:<hold ms>] -- the moment it is read.
With RECOMP_FB_DUMP that closes the loop: look at the frame, append a
press, look again. Finished steps are compacted away, so a long session
does not run out of slots.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RECOMP_PAD_PRESS pulses one digital mask forever. That gets a title past
a "press Start" screen and no further: menus want A, which is an analog
button on the Xbox pad, and they want presses in order.
RECOMP_PAD_SCRIPT takes a timeline, <ms>:<button>[+<button>...][:<hold>],
comma separated or from a file with @path. Times count from the first
report the title asks for, so from enumeration rather than process
start. Digital buttons (up down left right start back lthumb rthumb) set
report byte 2; a b x y black white lt rt report fully pressed. Every
step prints as it fires, so the run log records what was pressed when.
Holds default to 150 ms, but a title rendered through the software
rasteriser polls input a few times a second, and a short press lands
between polls: Burnout 3 ignored 150 ms presses there and took 1200 ms
ones. Opt-in, like RECOMP_PAD_PRESS.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The XDK's USB stack assumes the kernel keeps physical page 0 for it.
XPP carves its host controller structures from a private 0xFE0-byte
arena ending at 0x80001000 without any allocation call (sub_00365454
in Burnout 3). The contiguous bump allocator started at 0x80000000, so
the title's first MmAllocateContiguousMemory -- XAPI's launch data
page -- got the same page, and whichever wrote last won.
Timing decided which. With kernel logging slowing the title down, the
pad enumerated; without it the hub DPC reached the root port reset
with a device whose parent pointer had been overwritten and either
stopped there or faulted in sub_003675E0 walking it.
The allocator now starts one page in. Three fast Burnout 3 runs out of
three enumerate the pad (port reset, SET_CONFIGURATION, XID descriptor)
with no fault; before, none did.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A host controller is a bus master, so HcHCCA, HcControlHeadED, the ED
and TD links and the buffer pointers are all physical. On hardware
physical P and the contiguous window's 0x80000000 + P are the same
bytes; here the window is separate storage. A driver that builds its
descriptors in MmAllocateContiguousMemory and converts them with
MmGetPhysicalAddress -- the documented way -- therefore handed the
walker addresses that named nothing it wrote.
Burnout 3's XPP does exactly that: descriptors at 0x825B50C0 written to
HcControlHeadED as 0x025B50C0. Every ED read back as zeroes, the
controller saw an empty list, and enumeration waited forever. (DDS9's
driver writes window addresses directly, which guest_ok already took.)
bus_resolve() maps an address below the contiguous allocator's
high-water mark into the window, as dma_resolve() does for pushbuffer
surface offsets, except inside the loaded image: drivers also point
transfers at their own statics (Burnout 3's first GET_DESCRIPTOR reads
into 0x0041A904), and a real kernel never hands out contiguous memory
that overlaps the image.
With it Burnout 3 enumerates the pad end to end: GET_DESCRIPTOR,
SET_ADDRESS, GET_DESCRIPTOR(config), SET_CONFIGURATION, the XID
descriptor, then input reports.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RECOMP_APU_DSP_ACK stands in for the GP DSP clearing DirectSound's
command word. It ran from mcpx_apu_dsp_frame, i.e. only inside se_frame,
which the frame thread skips while FECTL is trapped or halted. On
hardware the GP runs regardless of the front end's method mode.
DirectSound posts a command only after the previous one is cleared, so
once the gate closed it waited forever. Burnout 3 hit it with the
pushbuffer executor on: acked at init, then stuck in sub_002F805E
polling the same doorbell before posting command 2.
The poll now runs every frame-thread iteration, ahead of the gate. Only
titles that set RECOMP_APU_DSP_ACK are affected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MSVC's CRT memcpy/memmove dispatch unaligned lead and trail bytes as
and eax, 3 ; 1..3 on this path, never 0
jmp [eax*4 + LeadUpVec - 4]
sub ecx, 4 ; -4..-1 when fewer than 4 dwords remain
jmp [ecx*4 + TrailUpVec + 16]
Reading forward from the displacement finds the jmp's own bytes in the
first form and the code after the table in the second, so both were
lifted as unresolvable indirect tail jumps. At runtime the target is
not a function, the ICALL is skipped, and memcpy returns without
copying whenever the destination is unaligned.
The emitted switch compares the loaded value against its arms instead
of indexing, so only the set of arms matters. When slot 0 is not an arm,
the lifter now also tries the slots after it and the slots below it,
and CFG recovery's census tries skipping slot 0. A census entry stays
authoritative: the lifter never rediscovers arms recovery rejected.
Surfaced in Burnout 3: its memcpy's jump-table arms were reached as
indirect targets, and feeding them back as seeds split memcpy and sent
XAPI down its dashboard-update path. Any title linking the MSVC CRT
has these two jumps (Half-Life 2 still carries one such ITAIL).
tools/recomp/test_switch_table_offset_index.py covers both forms; it
fails without the change. pytest tools/: 562 -> 564 passed, 17 skipped
before and after.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RECOMP_AC97_READY made the whole 512 KB APU aperture PAGE_NOACCESS so
register accesses reach the APU model. Only the first 0x30000 of that
is registers and the VP. 0x30000-0x7FFFF is the GP and EP DSPs' own
X/Y/P memory, which is plain RAM on hardware and which the model does
not implement at all: mcpx_apu_dispatch_mmio drops writes there and
mcpx_apu_mmio_read returns 0.
So trapping it bought nothing and cost a fault on any access the MMIO
decoder cannot emulate. Burnout 3's DirectSound bulk-copies DSP memory
with rep movsd, which the lifter lowers to a host memcpy; that faulted
at guest 0xFE830B78 inside the CRT with no way to resume, right after
the DSP doorbell ack let DirectSoundCreate proceed.
Trap the register and VP range only. GP/EP now keep what the title
writes, which is closer to hardware than the old read-as-zero. Only
titles that set RECOMP_AC97_READY see a difference.
Surfaced bringing Burnout 3 up on the toolkit runtime: with this, its
RenderWare audio device creates and the boot continues past engine
start instead of faulting on the NULL device.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xbox_MemoryLayoutInit reserves base + 28 mirrors as one range and then
releases the head slice with VirtualFree(base, size, MEM_RELEASE). Win32
cannot release part of a reservation: MEM_RELEASE with a nonzero size is
ERROR_INVALID_PARAMETER. Both frees fail, the base view never maps at the
span, and the whole span stays reserved for the life of the process.
At the default 64 MB map that is 1.8 GB, which the OS places at
0x80000000 -- the host range the contiguous window needs. The window
then fails with error 487 and the first read of the kernel page inside
it faults in xbox_MemoryLayoutInit. Half-Life 2 never saw it because its
768 MB map pushes the span above 4 GB.
Surfaced bringing Burnout 3 (64 MB map) up on the toolkit runtime. Any
title that keeps the default map size hits it.
The span path only works on POSIX, where the shim's VirtualFree unmaps a
sub-range, so it is now compiled there only. Windows falls straight to
the fixed-base loop it was already using after the span failed. Doing
the span on Windows needs placeholder reservations (VirtualAlloc2).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xboxrecomp is MIT, and a fix ported from a GPL project relicenses it by
accident -- very hard to untangle once it has shipped. Say so up front,
and ask for provenance in the PR.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The fused test+jcc emitted its inline condition from the raw test while
the snapshot beside it was now cmp X,0, so every fused test/jcc tested
X & 0 -- 11 conformance vector mismatches. Build the condition from the
same normalised form.
getenv without <stdlib.h> is implicit int on MSVC, which truncates the
pointer on x64 (C4013). #128 carries the same fix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- #89: guest-buffer floor was g_fs_base, which is per-thread; a worker
thread's TIB sits high, so its reads into the image were refused
- #92: watch_is_code used one title's section end; use g_xbox_code_lo/hi
- #100: a negative --force-return value emitted 0x-1U
- #106: Alt+F4 stopped closing the window; pass sys keys through
- #116: an iret anywhere aborted the whole build; a linear sweep reads
one out of data in Wreckless. It lifts as a RECOMP_UNIMPL marker now
- #122: the fused test+jcc path snapshotted test X,X but recorded
cmp X,0, so a later jl compared X with itself; regression test added
- #125: __builtin_return_address does not exist in MSVC
- #96: holdoff comment still said 20 ms
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A recovered arm was accepted once any instruction terminated it. An arm
could still run off its range, call a missing or empty body, or read flags
the dispatcher set, which a new C entry starts cleared. Each of those
misbehaves silently. Check every path, call and branch, and the flags read
on entry; otherwise leave the arm unresolved so dispatch stops loudly.
A function list can cut one function at its own switch, so some arms land
past the dispatching entry's end. The lifter then emits the indexed jump as
an indirect tail call and the runtime dispatches the selected arm by
address. An arm at a function start resolves; any other arm has no
generated body, and the runtime stops on an unresolved address.
After CFG ownership settles, recover each such arm's reachable code, up to
its table, as a function of its own. A table is read only up to the next
indexed jump's table, so arms of an adjacent switch are not picked up. An
arm that branches to code with no generated body is left unresolved: that
branch would become a call to an empty stub, and a loud unresolved dispatch
is better than a silently skipped arm. Existing bodies are unchanged.
In Dead or Alive Xtreme Beach Volleyball, leaving the View Collection
screen reached 0xDE030, the shared exit of a split 4-way switch.