Files
mitch030504--Wiicompiled_VR…/translator
iChris4andClaude Opus 5 c8eaa52727 Merge upstream/main into openxr-work (reverse-Z fix adapted for VR)
Brings in patchzyy/Wiicompiled main: os_sleep parked-thread fix (#195),
HTTPS Retro WFC payload (#198), macOS build guide (#177), and the
reverse-Z depth fix (#134).

Conflicts were in aurora-main/lib/gfx/common.cpp and lib/gx/shader.cpp,
both from #134, which lands squarely on the VR stereo replay path.

#134 makes UseReversedZ genuinely reversed: the near/far correction now
applies exactly once, inside effective_projection(), instead of being
applied there AND per-vertex in the shader (the double application had
been cancelling out, so "reversed" Z silently behaved like forward Z).
Three pieces of the VR path were built against that old behaviour and
would have broken silently, so they are adapted here:

- shader.cpp exact-screen-depth parked the virtual screen at -0.5*w
  specifically so the shader's following negation would land it at
  +0.5*w. With that negation gone it now writes +0.5*w directly; keeping
  the minus sign would park the screen at NDC -0.5, outside the clip
  volume, discarding every 2D/HUD draw.

- stereo_replay.hpp backend_ndc_depth_row re-applied the correction to
  the projection it was handed. That projection is effective_projection()
  output, which now already carries it, so the function is a pass-through
  of the Z row and no longer depends on the reversed-Z setting; the dead
  bool parameter is dropped. Re-applying it would invert the virtual
  screen's depth ordering, so 2D layers meant to sit on top would lose
  the depth test to the ones behind them.

- shader_info.cpp stages the host depth window for that exact-depth path.
  It now uses the same reversed-Z remap as upstream's new SetViewport
  code, since frag_depth is written directly and has to reproduce the
  window the fixed viewport transform would have applied. Restricted
  depth windows (how the game forces an element in front of everything)
  are exactly the 2D draws the virtual screen carries.

The SetViewport resolution keeps upstream's remap but retains the
ordering/clamp guard our version had: for any ordered guest range the
result is identical to upstream, and it avoids handing WebGPU
minDepth > maxDepth for the swapped pair MKW is known to emit. The VR eye
replay reuses these recorded values, so the guard covers that path too.

Test updates:
- stereo_replay_test now asserts the composed Z row against the staged
  projection's own Z row rather than against the helper's output, so it
  actually catches a re-introduced double correction (verified: it fails
  when the old negation is put back; the previous self-consistent form
  passed).
- gx_fifo_test's clearDepthValue expectation followed #134's deliberate
  clear_depth_value() inversion, expressed through UseReversedZ rather
  than hardcoded. Upstream changed the behaviour without updating this
  test, so it fails on upstream/main as-is.

Verified: aurora suite 247 passed with the same 2 failures that already
fail on the pre-merge branch (IndexedPaletteHistoryKeepsAbsoluteVertexSlots,
PacksOneUniformWhenBothHalvesNeedInitialValue - both pre-existing, unrelated
to depth); shader.cpp and common.cpp compile clean; translator suite 577
passed. Not yet validated on-device in VR.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-10 04:19:51 +02:00
..
2026-09-03 15:08:50 +02:00
2026-08-23 17:10:50 +02:00

Wiicompiled Static Recompiler

The translator parses GameCube/Wii DOL files, decodes PowerPC instructions, lifts them through IR/SSA and type inference, and emits C++ that is compiled into a native executable together with a runtime in runtime/. Project-specific paths and addresses are supplied through a versioned YAML manifest, so the translator itself contains no game-specific data.

Translating a DOL does not exempt you from owning the game it came from.

How translating a DOL works

A project manifest (YAML) names the input DOL and pins its layout; everything else is derived.

Translation is four commands:

  1. translate-recursive <entry-point> --project <manifest> - walks the call graph from the entry point, decodes every reachable function, and emits C++ (plus JSON metadata describing what was emitted).

  2. generate-data-init --project <manifest> - writes the embedded .data/.rodata/.sdata section initializer and RuntimeConfig.h.

  3. emit-build-shards --project <manifest> - emits the CMake build graph (shards.cmake) covering both generated sources and runtime/src.

  4. CMake + Ninja with Clang compiles runtime/ plus the generated output into one executable.

Discovery is purely recursive from the entry point unless the manifest provides an optional function_map (one hexaddr name per line) that seeds additional function boundaries. Unsupported instructions fail translation by default.

See projects/examples/generic-dol.yml for a minimal manifest driven by RECOMP_GENERIC_DOL.

Prerequisites

Tool Notes
.NET 8 SDK Builds and runs the translator.
CMake ≥ 3.16 and Ninja Configures and drives the native build.
Clang / LLVM The shipped build uses LLVM-MinGW targeting x86-64-v3. MSVC is not the tested path.

Build the CLI once and invoke the assembly directly:

dotnet build translator/src/Translator.Cli/Translator.Cli.csproj -c Release
$translator = 'translator/src/Translator.Cli/bin/Release/net8.0/Translator.Cli.dll'

Manifest essentials

  • inputs.dol.path - the DOL to translate; optional SHA-256 pinning rejects wrong revisions.
  • memory.base / size - guest address space.
  • memory.sda_base / sda2_base - the r13/r2 Small Data Area bases your DOL's boot code installs (lis/ori pairs in __init_registers). Required by any command that writes RuntimeConfig.h; the translator does not guess them.
  • translation.function_map.path - optional symbol map used as the discovery oracle.
  • translation.allow_unsupported_instructions - off by default; enabling it emits runtime traps instead of failing, and such a build can never ship.
  • translation.entry_observer - optional header, C symbol, and entry-point list for a read-only host observer. Its callback must accept (uint32_t, const CpuContext*); the translator materializes the complete guest context before every direct or transitive path that can reach it.

Relative paths resolve from workspace_root, which itself resolves from the manifest directory.

Commands

  • info [--project path]
  • translate-recursive <address> --project path
  • generate-data-init --project path
  • emit-base-manifest --project path
  • emit-build-shards --project path
  • translate-mod --project path [--profile name] ... - static Kamek/Pulsar module translation

Any command prints its own option list with --help.

Test

dotnet test translator/Translator.sln -c Release