KeInsertQueueDpc pushed onto an unlocked ring, but DPCs are queued from
several host threads at once -- the USB and APU controller threads' ISRs
and the title itself. Two inserts could take the same slot and one DPC
was lost. A lost USB DPC is a done queue the driver never acknowledges:
the controller completes nothing more and the pad goes dead mid-game
(seen in Burnout 3 menus and races), and with two pads' traffic the
driver ended up walking a stale done list and faulting in its ISR.
The queue is now under a critical section, and a DPC already queued is
not queued again: the Inserted flag at KDPC+2 is set on insert, cleared
before the routine runs, and KeInsertQueueDpc returns FALSE while it is
set, as the kernel does. KeRemoveQueueDpc actually dequeues.
Verified: Burnout 3 two-player Road Rage, which crashed before, runs
with both pads responsive.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The OHCI model carried one gamepad and answered every endpoint descriptor
as that device, so a title saw one controller and greyed out its
split-screen modes. Now:
- pad state (address, configuration, control-pipe setup and data stage)
is per device, and an ED is routed by its function address -- address
0 being the one plugged pad not yet given an address;
- RECOMP_USB_PADS=1..4 plugs that many, one per root-hub port, each
arriving a second after the previous one is configured so the driver
enumerates them in turn (the port count grows to fit);
- pad n reads host XInput pad n; pad-script and live steps take a
"p2-" .. "p4-" prefix, and live presses serialise per pad, so two
players can hold their throttles at once.
Verified on Burnout 3: with two pads the game enables Multiplayer Race,
Road Rage, Team Crush and Double Impact, P2's pad picks its car, and both
halves of the split-screen race drive.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"The pad stopped responding" has two very different causes -- the title
stopped queueing reads on the interrupt endpoint, or it still reads and
the input is lost further up -- and the periodic transfer total cannot
tell them apart. The stats line now carries input reports served, control
setups, and OUT packets on endpoint 0 and elsewhere.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- usb_gamepad: pad-script steps take lleft/lright/lup/ldown and the same for
the right stick (full throw), for titles that steer or pick map locations
with the stick.
- ohci: an OUT packet on the rumble endpoint cleared the pending control
setup, so force feedback landing between a control request's stages broke
that request. Only endpoint 0 ends a control transfer now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ps3recomp window shows "<title> | FPS | draws"; this one said
"Xbox Recomp - Framebuffer" forever. The title name comes from the XBE
certificate (UTF-16 at cert+0x0C) when the image is loaded, FPS from
flips, and draws from the pushbuffer executor at each flip. Updated once a
second from the window thread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
surface_bpp() divided the pitch by the clip width, which is right only
while the clip spans the surface. Burnout 3 narrows the clip to a
250-pixel window to draw its option values: 2560 / 250 is 10 "bytes a
pixel", the rasteriser refused the surface, and the Race options screen's
Region/Track/Rivals boxes stayed empty. The colour format field gives it
directly; the pitch division remains the fallback for unknown formats,
and the presented/dumped surface records its own bpp. A bigger DXT block
cache (4096) and the first vertices of each program batch in the frame
trace come along.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Near-plane clipping: a triangle with any vertex behind the eye was dropped
whole -- a quarter of every race frame's triangles, the road under a chase
camera among them, which left a hole across the bottom of the view.
Vertices go back to clip space through the viewport constants (the D3D
epilogue has already divided x, y and z by w), are clipped against a small
positive w (Sutherland-Hodgman), re-projected and fanned.
Speed (Burnout 3 menus 3 -> 14 fps on 12 cores):
- an uncached getenv("RECOMP_PB_EXEC_VERBOSE") ran for every method and was
a quarter of the executor's time; pb_scan's per-segment getenv too;
- decoded DXT blocks are cached (direct-mapped, keyed on address and
contents) instead of re-decoded for every texel of every bilinear tap;
- combiner constants unpack once, not per pixel; barycentrics multiply by
1/area;
- big triangles (>= 8K pixels) are rasterised on a worker pool by
interleaved rows -- full-screen composites and blurs dominate a frame and
every pixel touches only its own depth and colour. RECOMP_RASTER_THREADS
sets the count (default cores - 4). Caches are thread-local.
- the periodic report prints guest fps.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SET_TEXTURE_FILTER is decoded per stage; TENT mag/min filtering samples
bilinearly (level 0 only), and texture coordinate wrap/clamp is
sign-aware so a tap left of texel 0 wraps or clamps correctly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Immediate mode (SET_VERTEX_DATA*) kept position, diffuse and texcoord 0
and ignored every other attribute, so a quad with a second texture
coordinate was dropped outright. Burnout 3 copies its rendered 3D scene
into the framebuffer with exactly such a quad (scene in stage 0, glow in
stage 1, through the combiners), so the frame never got the scene: the
race showed the HUD over its speed-blur passes, and the scene only in
alternate dumps.
All 16 attributes now hold their current inline value; 2F, 4F, 2S, 4S,
4UB and VERTEX3F/4F all update them (4UB byte order as xemu has it), and
completing attribute 0 emits a vertex carrying all sixteen as float4. The
inline buffer grows to 64K dwords to hold 1K such vertices per batch.
Frame trace: deleting the flag file re-arms it, and
RECOMP_FRAME_TRACE_METHODS=1 adds every method (less vertex data and
program uploads), which is what showed the dropped quad.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every pixel the NV2A writes goes through its register combiners; D3D's
fixed-function stages compile to them too. The executor stood in with
"stage 0 texel * diffuse", which is right for a menu quad and wrong for
any lit or multi-textured surface: Burnout 3's race came out unlit, with
a black sky, and its composite passes lost what their other stages carry.
- nv2a_combiner.c: up to eight general stages and the final combiner --
input mappings, dot products, mux (LSB/MSB), output scale/bias, blue to
alpha, per-stage or shared factors, V1+R0 sum and E*F product -- per
xemu's psh.c. tests/nv2a_combiner checks MODULATE, a final-combiner
lerp and an expand-normal dot product.
- Four texture stages, each with its own offset/format/size/address/
palette; the 0x1B00-0x1BFF block is decoded per stage.
- Texture shader modes per SET_SHADER_STAGE_PROGRAM: 2D/3D projective,
cube maps (face select, 128-byte-aligned face stride), pass-through,
clip plane (per-component discard). Bump/dot-product modes read zero.
- The fog unit (linear/exp/exp2, abs variants, FOG_PARAMS) and fog colour
feed the combiners' fog register; alpha test runs on the combiner
output, before the depth write.
- Unwritten program texture coordinates default to (0,0,0,1).
The combiner path takes over once a title writes COMBINER_CONTROL;
RECOMP_NO_COMBINERS restores the old path for comparison. The frame
trace prints each batch's stage textures and combiner words.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RECOMP_FRAME_TRACE now also prints c[112..115] for each vertex-program
batch (the composite transform, from which the camera can be recovered),
every SET_SURFACE_COLOR_OFFSET, FLIP_READ/WRITE, and each FLIP_STALL with
the surface it presents. That is how Burnout 3's race camera was shown to
be in the right place (its world was being culled, not missed) and how
its swap chain and post passes were mapped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GET_REPORT (0x17D0) was unhandled, so D3D's GetVisibilityTestResult saw
its slot (initialised to 0xFFFFFFFF) never complete. It now writes the
16-byte report -- timestamp, pixels that passed the depth test while
SET_ZPASS_PIXEL_COUNT_ENABLE was on, and 0 for done -- at the report DMA
offset; CLEAR_REPORT_VALUE resets the count.
SET_COLOR_MASK (0x0358) was ignored, so depth-only passes (occlusion
proxies, z-prepasses) painted the frame. Fully masked pixels now skip
shading; partial masks keep the masked channels.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A CALL runs a pushbuffer elsewhere in memory up to its RETURN and then
continues after the CALL. The walker skipped the CALL word and carried on,
so a called buffer never ran. D3D's RunPushBuffer and precompiled
geometry use exactly this. One level deep, as on the NV2A; jumps inside
a called buffer are followed under a word budget. The report now counts
calls followed.
Burnout 3 turned out not to use CALLs for its world (0 followed), so this
is correctness, not that title's fix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SET_VIEWPORT_OFFSET (0x0A20) and SET_VIEWPORT_SCALE (0x0AF0) were
unhandled. The GPU keeps them in the constant file at c[59] and c[58],
which is exactly where the D3D vertex-program epilogue reads them, so with
them dropped every 3D batch collapsed to the origin: no 3D anywhere, a
black car on the garage screen. They now write those constants.
Blending honoured only SRC_ALPHA/ONE_MINUS_SRC_ALPHA and wrote every other
pair opaque. It now takes the GL factor set (incl. constant colour) and
the ADD/SUBTRACT/REV_SUBTRACT/MIN/MAX equations.
Diagnostics, all cheap or opt-in:
- the report splits program-path triangles by fate (behind the eye,
degenerate/NaN, off-surface, drawn, depth-failed pixels), with the
position range, attribute formats and blend pairs seen;
- RECOMP_VSH_TRACE=<n> prints n sampled program batches: attributes,
raw inputs, key constants and outputs;
- RECOMP_FRAME_TRACE=<flag file> logs every batch and clear of the next
whole frame once the file exists: surface, texture, blend, depth and
pixels written. This is what showed Burnout 3's world drawing into its
six cube-map faces but not the main view.
Also reports draws per flip to the window title (fb_present).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With both a MAC and an ILU op in one instruction the ILU's temp write goes
to R1 whatever the temp field says. The interpreter only did that when the
MAC half also wrote a temp. The Xbox D3D screen-space epilogue is
`mul o[0].xyz` beside `rcc R1.x`, where the MAC writes no temp at all, so
the reciprocal went to R7, R1.x stayed 0, and every vertex of every 3D
batch landed on c[59].
Also adds nv2a_vsh_constant (read, for traces) and
nv2a_vsh_constant_component (the viewport methods write c[58]/c[59] a word
at a time). tests/nv2a_vsh runs the epilogue and fails on the old rule
with exactly the collapsed position (320, 240, 0).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The flip handed the window (and the BMP dump) the last surface drawn,
read with the current pitch and clip. Titles also draw small render
targets -- Burnout 3 draws 128x128 shadow/reflection maps at pitch 512,
often after the main scene -- so the presented frame was one of those
read at the framebuffer's pitch: horizontal noise over every race frame.
Track the largest surface drawn since the last flip together with its
pitch and clip, and present/dump that.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The software executor could only rasterise vertices that arrived in
screen space. A batch drawn with TRANSFORM_EXECUTION_MODE set to
"program" carries model-space positions, so every 3D scene -- and, it
turns out, Xbox D3D's own 2D passthrough -- was counted as "not screen
space" and skipped, or drawn at raw coordinates off the surface.
nv2a_vsh_interp.c runs the title's uploaded vertex program on the CPU.
Programs and constants are captured from the pushbuffer as the GPU
takes them (TRANSFORM_PROGRAM_LOAD/_PROGRAM, _CONSTANT_LOAD/_CONSTANT,
_PROGRAM_START, _CXT_WRITE_EN), so nothing about a title's D3D state
has to be known. MAC and ILU ops, swizzles, negation, write masks,
a0-relative constants, paired writes and the oPos/R12 alias are all
modelled; RECOMP_VSH_DUMP disassembles each distinct program.
Xbox D3D appends the viewport transform and divide by w to every
program, so oPos comes back in pixels with a depth and the clip-space
w, which the new triangle path uses for perspective-correct texturing.
That path also interpolates vertex colour, modulates the texel by it,
and tests/writes a host-side depth buffer per zeta surface (cleared by
CLEAR_SURFACE's Z bit to ZSTENCIL_CLEAR_VALUE). fetch_attr gains the
3D vertex formats: normalised and plain signed shorts, packed normals.
The encoding was checked against a real program, not assumed: Burnout
3's first upload disassembles to D3D's passthrough (oPos = v0 + c[191],
RCC of w, the c[58]/c[59] screen-space epilogue, oT0 = v1, oD0 = v2).
That check caught the output-bank bit being inverted (1 = o[], 0 = c[]).
Visible result in Burnout 3: the frontend's grid is the faint overlay
it should be instead of solid white lines, since the vertex colour's
alpha is finally applied; the name keyboard and menu text render.
Known gaps: no near-plane clipping (triangles with w <= 0 are dropped
and counted), texture replaced vs modulated is not taken from the
combiners, single texture stage, fixed-function mode not implemented.
RECOMP_NO_VSH restores the old behaviour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only four packed compares (cmpeq/lt/le/neqps) were lifted. Everything
else -- cmpltss above all -- fell to RECOMP_UNIMPL and left its
destination unchanged. RenderWare's frustum build normalises each side
plane as `cmpltss mask, len2; rsqrtss; andps mask`, so with the mask
stuck at zero every side plane came out (0,0,0,0) and every sector box
failed the frustum test: Burnout 3's race view drew the sky and nothing
else, while its axis-aligned cube-map cameras (built elsewhere) drew the
world. Found by tracing the empty per-group visibility flags back to the
camera's planes.
- All eight predicates, packed and scalar, named (cmpnless, ...) or by
immediate (cmpps/cmpss), through recomp_cmp_pred / XMM_CMP_PRED. SSE
compares no longer clear the tracked EFLAGS setter; they don't touch
EFLAGS.
- sqrtps/rsqrtps/rcpps compute all four lanes (were lane 0 only).
- A bare cmpsb/w/d or scasb/w/d is one iteration of the rep form, ecx
untouched, and sets the tracked flags. These were RECOMP_UNIMPL too;
MSVC unrolls short memcmps into `cmpsd; jne` chains. The translator
now declares _flags for any function with a string compare.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fcomi/fucomi/sahf treated an unordered result (g_fp_cmp == 2) as
"greater" -- ja/jae true on NaN, jp/jnp constants. Unordered now reads
as below, equal and parity, as the hardware sets ZF, PF and CF.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lahf lifted to a comment, so AH kept whatever EAX held. MSVC's "is this
float zero" test is `ucomiss x, 0; lahf; test ah, 0x44; jnp`, and it
answered at random. Burnout 3 guards a divide with exactly that: on 0 the
guard fell through, 0/0 became the player's position, and the race camera,
every matrix and the stunt readout ("-2147483648ft") went NaN. Found by
unmasking the SSE invalid exception and catching the first 0/0.
lahf now builds AH (SF ZF PF CF, bit 1 set; AF not modelled) from the
tracked flag setter through the same conditions the jcc forms use.
An unordered comiss/ucomiss sets ZF, PF and CF. The conditions used the
C relational operators, which are all false on NaN, and hardcoded
jp/jnp as "ordered". jb/jbe/je/jne/jp/jnp now include the unordered case
as the hardware does; ja/jae were already right.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RECOMP_FP_PC rounded with a plain (float) cast. The x87 under PC=24
narrows only the significand; the exponent keeps the register's range.
Outside float's range the cast turned a large intermediate into inf (and
inf*0 into NaN) and flushed a tiny one to zero, where the hardware carries
on. Values in float range still take the cast; the rest go through
frexp/ldexp.
tests/fp_precision checks the Burnout 3 compare case and both range ends.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The FPU stack is double-backed, which is right for PC=53 and near enough
for PC=64, but the Xbox runs PC=24, where every fadd/fsub/fmul/fdiv/fsqrt
result is rounded to float. Code that compares a freshly computed value
with the same value stored as a float depends on that rounding.
Burnout 3's sorted draw list re-inserts a node by walking forward while
v > next and back while v < prev. With v kept at double precision it sat
between its own float-stored copy and a neighbour and walked back and
forth forever: the race froze at the start line with the GPU idle.
Arithmetic results now go through RECOMP_FP_PC, which rounds to float
only when the guest control word selects 24-bit precision; other modes
are unchanged. Verified: BO3 gets past the start line and renders
in-race frames; lifter tests updated for the new emitted form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The APU now delivers its interrupt and resolves physical addresses through
the kernel (591dcb9), so xbox_apu on its own no longer links. Link the
xboxrecomp interface library, as the kernel tests do, and give the test
the recomp_lookup stubs a title would supply.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
irql_publish and the IRQL holder record added the layout's own offset,
xbox_GetMemoryOffset(), to guest addresses. Lifted code, and any host
that sets up guest memory itself, uses g_xbox_mem_offset; the two are the
same in a title but not in tests/kernel_irql_abi, which maps its own
memory. There the holder record read the guest stack at host 0x20000 and
the test crashed. Read through the offset everything else uses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Four problems, each of which stopped input or froze the frontend once
the pad and the APU were doing real work. To be split per PR.
IRQL (kernel_hal.c, kernel.h, kernel_bridge.c, call sites):
- Host threads that deliver ISRs and drain DPCs now run the routine at
its level (device level / DISPATCH_LEVEL) and restore the interrupted
level afterwards, as the kernel's dispatchers do. A routine returning
at raised IRQL used to leave the global depth at one, which held off
every later USB interrupt until the forced-delivery timeout.
- Every IRQL change is published to KPCR.Irql (fs:[0x24]). DirectSound's
lock reads that byte directly and skips its critical section at
raised IRQL; with it always 0 the DSOUND DPC blocked on the section.
- IRQL holder reports carry the guest return address and esp.
OHCI (ohci.c):
- One done queue per service pass across periodic, bulk and control.
The lists published one after another, so a rumble SET_REPORT on the
control pipe overwrote the input report's completion and the driver,
which re-arms the interrupt endpoint from it, stopped polling the pad.
- RECOMP_USB_STATS: a five-second line with transfer count, register
state, control and periodic ED state, and IRQL holders when raised.
APU (apu_core.c, apu_vp.c):
- The frame thread drops its lock and yields once per frame. Running
behind real time it never waited in throttle(), so the title starved
in voice_lock (critical sections are not fair).
- voice_process stops asking a voice that keeps returning no samples;
the loop could spin forever holding the lock.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
Two gaps, found together because together they stop DirectSound ever
reporting that a buffer has finished.
Physical addresses. The shim read every physical address as low RAM
(g_apu_ram_ptr + (addr & 0x3FFFFFF)). DirectSound builds its voice, SGE
and notifier structures in MmAllocateContiguousMemory and hands the APU
their physical addresses, which on hardware are the same bytes as the
contiguous window's 0x80000000 + P and here are not. The voice
processor walked zeroes, and each "voice done" notification landed in
ordinary RAM where DirectSound never looked. mcpx_apu_phys() resolves
them as dma_resolve (pushbuffer) and bus_resolve (OHCI) do: the image
stays the image, anything below the contiguous high-water mark is the
window.
The interrupt. update_irq called pci_irq_assert, an empty stub, and
nothing called update_irq when set_irq was raised in the first place.
The frame thread now does what xemu's does after each frame -- turn
set_irq into the line -- and delivers it to whatever is connected on
vector 5 (the APU's IRQ), the way the OHCI model delivers USB
interrupts: its own TIB, a worker stack for the call, the APU lock
dropped around it, and a bounded hold-off while a guest thread sits at
raised IRQL.
Burnout 3's frontend waits for a confirmation sound to stop
(IDirectSoundBuffer::GetStatus, polled with Sleep in between) before it
leaves the profile screens. It waited forever; with this the service
routine at 0x002F8E81 claims the interrupt and the title reaches its
main menu.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The periodic report is also when RECOMP_FB_DUMP writes a frame, and it
was fixed at ten seconds. Stepping a scripted pad through a menu needs
a picture per press, not one every ten seconds. Default unchanged;
floor 100 ms.
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>
Format 0x0B (SZ_I8_A8R8G8B8) had no case in sample_texture, so every P8
quad came out as the unsupported-format fill. Burnout 3 draws its title
logo (512x256) and its frontend header art this way, and both were
white boxes.
SET_TEXTURE_PALETTE (0x1B20, per stage like the rest of the block)
carries the CLUT's physical offset in the bits above the DMA and size
fields; it resolves through dma_resolve like a texture offset, and each
index looks up an A8R8G8B8 entry.
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>