A heap page below 64 MB is now named by its alias in the first RAM mirror
(va + the RAM size). bus_resolve passed that alias through as a guest
address, and guest_ok admits RAM only below the mapped size (64 MB on a
retail map), so every DMA to such a buffer was skipped. XAPI's pad report
buffer is a heap block named through MmGetPhysicalAddress: on Splinter Cell
the pad was dead from the first menu.
bus_resolve now folds the alias back to the heap address, as mcpx_apu_phys
does, decoding from the address alone, so the OHCI and the APU agree on what
an alias means. With the fold, Splinter Cell's pad also keeps working in
levels, where without the alias the report buffer fell below the contiguous
allocator's high-water mark and went to the window.
Found and tested by rtaranu on Splinter Cell (Windows, retail 64 MB map).
Co-authored-by: rtaranu <23201034+rtaranu@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MmGetPhysicalAddress returned the identity for heap addresses, and the
contiguous window hands out the same numbers below 64 MB, so one physical
number could mean two different pages. The RAM-name record lets the APU tell
them apart until a named heap page and a live window buffer hold the same
number at once: then one of them always reads the other's bytes.
Def Jam: Fight for NY hit it when a translation's string table (21 KB larger)
moved a named heap block over the window buffer of the music stream. The
stream read RAM for those pages: about 1,300 one-slice gaps a minute in the
opening scene, heard as crackling. Padding the English table by the same
amount does the same, so any change in heap layout can.
A heap page below 64 MB is now named va + the RAM size, its alias in the
first RAM mirror, which is also where the console's memory controller wraps
such an address. The window keeps the low numbers to itself, the APU
resolves the alias to RAM directly, and the NV2A executor and the OHCI, which
find it above the window's high-water mark, read it as a guest address in
the mirror. With no first mirror, or RECOMP_PHYS_RAM_ALIAS=0, the old
identity and record remain.
tests/apu_phys checks the alias contract, including a window page under a
named heap page, and runs the record's checks again with the switch off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With fog on, W fog on a pre-transformed vertex whose RHW is 0 gives an
infinite distance. Linear fog turned that into factor 0, so every 2D
quad came out as the flat fog colour (MechAssault's movies and menus).
The hardware gives no fog in LINEAR and EXP and full fog in the other
modes (xemu vsh.c).
tests/nv2a_rhw0_quad leaves fog on with D3D's final combiner and checks
the quad in LINEAR and EXP (unfogged) and EXP2 (fully fogged).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pre-transformed vertex sent with RHW 0 (2D quads, Bink movies) comes
out of the runtime's program with oPos.w = 1/0 = +inf. The clip test saw
a non-finite distance and dropped the triangle without counting it, so
MechAssault's movies and menus drew nothing on the software renderer.
Treat +inf like 0 and draw it with w = 1. xemu instead clamps w into
[2^-64, 2^64]; for a quad whose corners share one w the result is the
same.
tests/nv2a_rhw0_quad draws a quad whose program w is +inf through the
executor's own rasteriser and checks its centre pixel.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
heap_insert_free reuses an empty slot for the piece left behind a carved
block. The empty slots after it kept addresses from inside the carved block,
which can be below the new piece's, and heap_block_at binary-searches the
table by address. Lookups then found the free remainder instead of the live
block: DOAX's replayed intro movie had its sound ring at the front of such a
block, the second half resolved to a free block that was never named, and
the APU read those pages from the window rather than the RAM the title
wrote (stale audio every lap, a loud hiss). Raise those slots to the new
piece's address.
tests/memory_regressions case 2c carves the front of a merged run and
looks up the carved block's second half.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MmAllocateContiguousMemoryEx ignored its Protect argument, and neither
allocation path reset a page's protection. A title that marks its own
block read-only with MmSetAddressProtect, frees it and allocates again
gets the same pages back still read-only, and the allocator's zeroing
faults on them. MechAssault crashed this way after destroying a building.
The allocator now makes the pages writable before zeroing them, the
pinned-range path zeroes before applying the protection, and both
MmAllocateContiguousMemory paths apply what the caller asked for (Xbox
protection flags as MmSetAddressProtect maps them; the cache bits are
dropped there already).
tests/memory_regressions case 9: protect, free, allocate again, through
the allocator and through a pinned physical range. Without the fix the
test process faults in the zeroing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xemu keeps a stream voice whose next segment list is empty on that list
for good, repeating its done notification every frame, and replays a
finished list the title has not refilled yet. DirectSound (XDK 5849)
refills the list that just finished and expects the voice to go on
through an empty one: starved for a moment, it puts the next packet in
the other list. Under xemu's rule that packet waited behind the empty
list, played after later segments or again, and DirectSound's lists stayed
out of step with the voice for the rest of the stream.
Burnout 3's attract-mode trailer starves its stream voice in about half
of all runs (the next movie packet comes late once), and from then on
dropped 15-40 ms at every packet to the end of the movie. With the switch
the voice misses a few frames once and carries on: four trailer runs,
two with a starved moment, one 5 ms dip each.
Opt-in, as one title shows it so far. tests/apu_vp covers both rules;
with the switch's code taken out, the four checks of the new rule fail.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No frame means no idle-voice trap, so a title that stops a voice and waits
for it to be retired (DirectSound's StopEx, then GetStatus) waits it all:
in a 13-minute Burnout 3 session one stop took 102 ms (a visible hitch)
where 5000 others took under 3.1 ms. The line says what the frame thread
did meanwhile -- passes with the front end trapped, the sequencer held, the
device queue full, and time asleep in throttle -- with the start on the
host's QueryPerformanceCounter in ms, to match other host-timed logs. At
most 50 lines; silent through a headless race.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The frame thread paced per 256-sample EP period: the eight 32-sample
frames ran back to back and the thread slept out the rest, where the
hardware runs one every 0.67 ms. A title that stops a voice and spins until
the voice walk retires it (DirectSound's StopEx, then GetStatus) waited for
the next bunch, up to 7 ms each; Burnout 3's crash mode stops ~900 sounds
in 5 minutes.
DMFBMX2/xboxrecomp#21 spread the frames over the period. Here that alone
changes nothing: the device queue sits at its low mark, where pace_step
allows a 42 ms render-ahead, so the frames still bunch. Instead each frame
is due an eighth of a span after the last, and the queue, read where a
period starts, sets the span: 3/4 of a period at or below low, 9/8 above
mid-band, at once below half of low, none at high. The stall fallback is
shared with pace_step (pace_watch_stall). =0 keeps period pacing.
Tests (apu_monitor): next-frame wait 6.0 -> 1.0 ms max with a smooth and a
512-sample-buffer device, queue in band, no underruns, rate kept; a 1 s
device stall drops periods and recovers. Burnout 3 headless race: stops
over 1 ms 46 -> 33, mean 3.2 -> 1.2 ms, max 6.5 -> 1.7 ms; no dropouts in
the race or in four intro-trailer recordings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The voice-list walk raises one idle-voice trap per frame, and always on
the first idle voice it meets. A voice the title leaves listed after its
notice then takes every trap, and the idle voices behind it are never
reported. DirectSound frees a multi-voice stream only on its last voice's
notice and ignores the others: MechAssault spun for ever stopping its menu
music (voice 0xF2 trapped about 2,700 times a second, 0xF4 never).
The walk now notes the idle voices it passes and, after it, traps on the
first one after the voice trapped last time, wrapping round to the first.
Still one trap at a time. The voice trapped last is kept in the VP state
(vp.idle_trap_last, cleared by mcpx_apu_vp_reset).
tests/apu_vp idle_traps_take_turns: two idle voices listed, the ISR
resuming between frames; the traps must alternate. Without the fix the
second voice never comes up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Some false function starts pass every check: a "call" decoded from data
whose target lands mid-instruction in a real function and cuts it in two,
or a coincidental address match. No heuristic rules them out without
losing real functions elsewhere. A seed file entry
{"start": "0x...", "not_function": true} now keeps the address from ever
being proposed as a start (FunctionDetector._add_candidate), and the marks
are an option in the cache key, the way observed seeds are (adds nothing
to the key when there are none).
Splinter Cell (one entry) and Dead or Alive Xtreme Beach Volleyball (four)
use it for false starts found after a regen.
tools/disasm/test_not_function_seeds.py: a marked call target is not a
function, the seed file loader splits the entries, and the cache misses
when the marks change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MSVC's memcpy/memmove dispatch their lead bytes through
`jmp [eax*4 + LeadUpVec - 4]` with eax 1..3, so slot 0 at the
displacement is padding or the previous jmp's tail, not a pointer.
resync_jump_tables measured nothing there and dropped the table, so the
function ended at its own dispatch: every arm after the table became an
indirect call no function covered. MechAssault's memmove (0x001D0580)
ended at 0x001D05E4 instead of 0x001D08BD, the boot stack was corrupted by
the first unaligned copy, and the tail was split into false starts. The
lifter already reads such a table one slot on; measure it there too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>