Repository navigation
Working on the Code
How engine hooks, codegen and the source tree are organised. Source: larecomp_config.toml, larecomp_manifest.toml, src/mc_engine/hooks/. Building is covered in the README.
rexglue codegen reads larecomp_manifest.toml, which names the game's default.xex and includes larecomp_config.toml. It writes C++ to generated/, which is then compiled together with the hand-written code in src/. generated/ is not in the repository: every clone makes its own from its own game files.
| File | Holds |
|---|---|
larecomp_manifest.toml |
SDK version, project name, the XEX to read, the output folder, the included config files |
larecomp_config.toml |
[vector_math] choices, [functions] hints and every [[midasm_hook]]
|
tools/release/lar-rxsdk.pin |
The LAR-RXSDK commit the project is pinned to |
[functions] tells codegen about guest functions: a name, and where needed a size, keyed by address.
[functions]
0x8244FEC0 = { name = "mc_Sleep", size = 0x8 }
0x823F32E8 = { name = "rex_sub_823F32E8" }Engine patches are [[midasm_hook]] entries in larecomp_config.toml, implemented in src/mc_engine/hooks/, one file per category:
[[midasm_hook]]
name = "MCLAFixedStepPath"
address = 0x821BDB90
after_instruction = true
registers = ["r3", "f11"]The hook function takes only the registers named in registers, by reference, with ordinary C++ linkage. Not extern "C", not (ctx, base). Float registers arrive as PPCRegister& with the value in .f64. Returning bool drives jump_address_on_true and return_on_true.
| Key | Meaning |
|---|---|
address |
Guest address the hook is placed at |
name |
The C++ function to call |
registers |
Registers handed to the function, in order |
after_instruction |
Run after the instruction at address instead of before it |
jump_address_on_true |
When the function returns true, continue at this guest address |
return_on_true |
When the function returns true, return from the guest function |
return |
Return from the guest function after the hook |
A hook that skips the intro when a setting is on:
[[midasm_hook]]
address = 0x822C2F08
name = "SkipIntro"
jump_address_on_true = 0x822C2F7Cbool SkipIntro() {
return larecomp::settings::skip_intro.Get();
}Some hook files also define empty versions of their hooks for the XEO3 build (REXGLUE_HAS_XEO3_TARGET).
A recompiled function can be replaced by defining its name in src/. The original stays callable with the __imp__ prefix (src/mc_engine/hooks/frame_pacing.cpp):
REX_EXTERN(__imp__rex_sub_822C1FA8);
extern "C" REX_FUNC(rex_sub_822C1FA8) {
mc::guest_timing::EnterUpdate();
__imp__rex_sub_822C1FA8(ctx, base);
mc::guest_timing::EndUpdate();
}src/larecomp_guest.h is the way in; its header comment explains each part.
| Helper | Use |
|---|---|
larecomp::guest::Membase() |
Host pointer to the base of guest memory. Null when no title is loaded, including during shutdown, so test it. |
larecomp::guest::AddressSpace() |
Address translation, heaps, page protection and system heap allocation |
larecomp::guest::Call<R>(fn, args) |
Run a recompiled function on the calling guest thread, with cleared registers that are restored afterwards |
larecomp::guest::ThreadFile |
The same, for a caller that sets registers by hand |
Guest memory is big-endian. src/mcla_rage_types.h has read and write helpers and the game's structures.
Settings are REX_SETTING members of the owners in src/settings/generated/ (one header per category) and src/settings/larecomp_app_settings.h. Despite the folder name, those headers are ordinary source in the repository, unlike the top-level generated/.
REX_SETTING(bool, skip_intro, false, "Skip the intro videos to prevent graphical issues.", rex::kRequiresRestart);Read it with larecomp::settings::skip_intro.Get(). A new setting also goes in settings_meta.inc and manifest.json in src/settings/generated/. It must then be one of these, which tools/check_settings_exposure.py checks:
- a pause menu row, or a launcher row listed in
tools/settings_exposure.toml; - on the exception list in that file;
- tagged
rex::kDebugOnly.
python tools\check_settings_exposure.pyTests are small executables named larecomp_*_test. Those declared EXCLUDE_FROM_ALL are not part of a normal build: build the one you need by target name and run it. For the one below, exit code 0 means it passed.
cmake --build out/build/win-amd64-relwithdebinfo --target larecomp_watch_table_testtools/static_analysis/static_analysis.py --new-only is an optional analysis of the hand-written C++ that needs LLVM 23 (documentation/STATIC-ANALYSIS.md).
| CMake option | Default | Effect |
|---|---|---|
LARECOMP_GPU |
ON |
Build the native (Plume) renderer |
LARECOMP_CPU_LEVEL |
baseline |
x86-64-v3 compiles with AVX2, FMA and BMI2; the program then does not start on older CPUs |
LARECOMP_DEV_TOOLS |
OFF |
Developer tools: the compare keys and the SDK's console key. Not for a release build |
LARECOMP_ASAN |
OFF |
AddressSanitizer for the Windows host and Plume (clang-cl, x64) |
After changing hooks or hints:
<sdk-install>\bin\rexglue.exe codegen larecomp_manifest.toml
cmake --build out/build/win-amd64-relwithdebinfoPass the manifest, not the config. The manifest includes the config and sets up module dependencies.
Never edit anything in generated/. Codegen rewrites the whole directory. Hooks survive regeneration because they live in the config and in src/mc_engine/hooks/; hand edits do not.
larecomp/
README.md
documentation/
RUNNING.md # run and debug quick reference
DEBUG.md # the hidden debug menu and developer switches
TECHNICAL_NOTES.md # engine findings, corrections, gotchas
src/
larecomp_app.h # paths, cvars, GPU flags, stub sweep
mc_engine/ # hooks, pause menu, HUD, music, mod loader, online
gpu/ # the native renderer (Plume)
native_gfx/ # guest side of the renderer's driver
settings/ # setting declarations and the launcher export
settings_ui/ # exports the settings description the launcher reads
shaderpack/ # builds the shaders from the game files
citypack/ # builds the ray tracing city data
isoinstaller/ # first-run ISO install wizard
saveporter/ # Xenia and RPCS3 save import
discord_rpc/
mcla_rage_types.h # big-endian RAGE structs, offsets static_asserted
assets/
gamecontrollerdb.txt # SDL controller mappings, copied next to the exe
thirdparty/ # submodules (Plume, LAR-XenosRecomp, libmspack and others)
tools/ # build checks and offline tools
generated/ # REGENERATED BY CODEGEN, never hand-edit
larecomp_manifest.toml # codegen entry point
larecomp_config.toml # function hints and hook declarations
| Symptom | What to do |
|---|---|
| The build cannot find the generated sources on a fresh clone | Run codegen |
CMake says thirdparty/... is missing
|
Run git submodule update --init --recursive
|
A change in larecomp_config.toml has no effect |
Run codegen again, then build |
| A hand edit disappears | It was made in the top-level generated/; move it to a hook |
The code is GPL-3.0-only with additional terms; read the README before reusing any of it.
LARecomp
Settings
Game Features
Mods
Content Modding
Development
Online
Server Hosting