12 Commits

Author SHA1 Message Date
sp00nz 5e4c67f32d docs: add RECOMP_PHYS_RAM_ALIAS to the environment-variables page
#286 added the switch without a row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 12:20:27 -08:00
sp00nz 8fcd750952 Merge pull request #320 from Tzeentchnet: kernel: add opt-in widescreen and 480p EEPROM flags 2026-11-20 12:01:30 -08:00
sp00nz f8a3d497ca Merge pull request #268 from maxiumpro: kernel: split large free heap blocks 2026-11-20 12:00:42 -08:00
sp00nz 111ee47911 Merge pull request #341 from rtaranu: apu: pace the voice processor one frame at a time
# Conflicts:
#	docs/runtime/environment-variables.md
2026-11-20 11:49:16 -08:00
rtaranu 4d2c1093f2 apu: RECOMP_APU_SSL_ADVANCE passes a stream voice through an empty list
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>
2026-11-15 19:18:54 -05:00
rtaranu b0fcb2d37b apu: pace the voice processor one frame at a time (RECOMP_APU_PACE_FRAMES)
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>
2026-11-15 19:16:42 -05:00
Kenneth Peters cf5a4db827 kernel: add opt-in widescreen and 480p flags
Keep the NTSC 4:3 480i/60 default while allowing titles to see independent widescreen and progressive-scan EEPROM capabilities. Cover both single queries and XC_MAX_OS copies with synthetic combinations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-07 19:36:49 -08:00
Misael 9d65200021 kernel: split large free heap blocks
heap_alloc_locked handed a freed block out whole to the next request,
however small. Kung Fu Chaos frees its 6.8 MB streaming buffers when a
load is backed out of with B; the next small requests each took one whole
(15 MB of slack in the [HEAP] exhausted report), the reload's 6.8 MB
malloc returned 0, and the next match crashed on the empty resource.
A block with at least 64 KB to spare is now split (heap_carve_block,
factored out of heap_carve_free; it clears `named` like the rest) and the
rest stays free. Small slack keeps the old behaviour. RECOMP_HEAP_SPLIT=0:
off.

tests/memory_regressions: the default and contig-avoid-image modes now
expect the split (a 16-byte request takes 16 bytes of a freed 2 MB); a new
heap-split-off mode keeps the whole-block check under RECOMP_HEAP_SPLIT=0.
All six modes pass; with RECOMP_HEAP_SPLIT=0 forced, the default mode
fails both split checks.

Tested on Kung Fu Chaos (apexJCL fork, same allocator): 3 of 3 unattended
cancel-and-reenter runs without a crash, the large block reused at the
same address.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 11:24:58 -06:00
sp00nz f3239cf7e3 docs: add the v0.17.0 switches to the environment-variables page
RECOMP_WAIT_LOG (#247), RECOMP_TEX_BILINEAR/ANISO (#253),
RECOMP_STRIP_ALT_WINDING (#249), RECOMP_PB_CONST_FAST (#273),
RECOMP_CS_MODE=guest (#260); RECOMP_RASTER_THREADS on POSIX (#242),
RECOMP_VBLANK=0 is off (#263), RECOMP_FULLSCREEN in SDL (#282).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 23:21:30 -08:00
BearddOddity 309bfbedfc docs: list every RECOMP_* switch in one page, and link it from the index
docs/INDEX.md stays the one index. Every page gets one navigation line under
its title that points back to it, and runtime/ gets a reference page for the
environment variables.

docs/runtime/environment-variables.md lists every RECOMP_* switch the runtime
and tools read: its default, its effect and the source file that reads it,
grouped as bring-up, kernel, pushbuffer executor, video, audio and input.
Fifty-one of them were not in the docs at all. docs/INDEX.md links it from
"Start Here".

No page is renamed, moved or rewritten, and no other index is added.

Checked: every RECOMP_* name read by getenv, env_on, apu_env_on, env_int or
xa2_env_int in src/, tools/, templates/ and include/ is on the page, and
every name on the page is in the source. All relative links in docs/ resolve
(0 broken, as at v0.16.0). The 34 existing pages change by insertion only:
68 lines added, none removed. docs/INDEX.md gains one line.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 04:59:55 -05:00
carlos a1862e0fdc video, apu: SDL2 framebuffer window and SDL2 audio device on POSIX
POSIX hosts had neither: fb_present.c is Win32 GDI with POSIX stubs, and
the xa2_* audio backend was stubbed inactive. A macOS or Linux build ran
with no picture and no sound.

fb_present_sdl.c is the framebuffer window for POSIX, opt-in with the same
RECOMP_FB_WINDOW switch. AppKit only runs on the main thread, so the shape
is inverted: a title hands its boot sequence to xbox_HostWindowMain(),
which keeps the window and the one SDL event loop on the main thread and
runs the guest on a pthread (at least the main stack; same QoS on macOS).
The flip copies the finished surface into one of three slots and publishes
it under a short mutex, so the executor never waits for the window. Same
640x480 surface convention and title bar as the GDI window. Without the
switch, headless, or with no display, the guest runs on the calling thread
as before. While the main thread pumps events, xinput_device.c only reads
the controllers.

apu_sdl2.c implements the xa2_* contract over SDL_QueueAudio, with the
XAudio2 backend's buffer size and depth (1024 x 3, a period refused while
the queue is full; SDL's queue does not count the buffer the device is
playing, so it is refused at two). RECOMP_HEADLESS=1 takes SDL's dummy driver unless
SDL_AUDIODRIVER is set.

SDL's SIGINT/SIGTERM handlers only post an SDL_QUIT that nothing reads
without a window, so every SDL entry point keeps the default handlers.

docs/runtime/README.md shows the POSIX main() a title needs: a
SIGSEGV/SIGBUS handler that calls xbox_PosixMmioFault, and the boot
sequence handed to xbox_HostWindowMain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 16:59:37 -07:00
sp00nz ef5ad3a734 Initial release: Xbox static recompilation toolkit
Complete toolchain for statically recompiling original Xbox (2001-2005) games
into native Windows executables. Includes:

- XBE parser, x86 disassembler, function identifier, and x86-to-C lifter
- 6-step pipeline documentation (parse, disassemble, identify, lift, runtime, debug)
- 8 technical deep dives (register model, memory layout, ICALLs, D3D, kernel, SEH, etc.)
- 3 Xbox format references (XBE, kernel exports, disc images)
- Runtime templates (recomp_types.h, xbox_memory.h, kernel_stubs.h)
- Candidate game analysis for future recompilation targets

Proven on Burnout 3: Takedown — 22,097 functions lifted from machine code to C.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 02:27:26 -08:00