Full migration of the 2236-line monolithic CLAUDE.md into the progressive-context knowledge graph (per spark-lesson / expert-seed.md), so the deep RE knowledge loads on-demand instead of every session. ZERO CONTEXT LOST: - docs/PROGRESS_LOG.md = the complete old CLAUDE.md, VERBATIM (byte-identical) -- the lossless safety net + the "full detail" quick-lookup fallback. - 18 context/*.md topic files (1343 lines) digest every section (§1-3 -> project-overview, §4 -> content-archives, §5 -> asset-formats/bgf-format, §5a -> source-completeness, §5b/§8 -> wintesla-port, §7/§10 -> locomotion, §10a -> build-and-run, §10b -> reconstruction-method, §10c -> combat-damage + reconstruction-gotchas, §10d -> subsystems, render notes -> rendering, gauges -> gauges-hud, MP -> multiplayer, §9 -> open-questions). - reference/glossary.yaml (53 terms). decomp-reference.md = the offsets/ClassIDs/addresses hub. CLAUDE.md (160 lines) = router: identity, answer/reason protocols, quick-lookup table, evidence tiers (T0 engine-truth / T1 decompiled+verified / T2 reconstructed+runtime / T3 guarded / T4 hypothesis), conventions + DO-NOT (the systemic bug classes), structure. Retains the load-bearing work directives (build recipe pointer, "keep current" mandate). Knowledge graph validates CLEAN (scratchpad/checkctx.py -- all [[links]] + quick-lookup + docs refs resolve; [[name]] -> topic file or glossary term). docs/*.md ledgers stay as the detailed logs; context/*.md are the curated digests that route into them. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
69 lines
4.1 KiB
Markdown
69 lines
4.1 KiB
Markdown
---
|
|
id: build-and-run
|
|
title: "Build / Run / Debug — recipe, repo layout, env gates"
|
|
status: established
|
|
source_sections: "PROGRESS_LOG.md §10a, §10a-bis; README.md"
|
|
related_topics: [wintesla-port, decomp-reference, reconstruction-method]
|
|
key_terms: [BTL4OPT, cdb, BTL4.RES, EGG, WinTesla]
|
|
---
|
|
|
|
# Build / Run / Debug
|
|
|
|
The one top-level `CMakeLists.txt` builds `munga_engine` (engine) + `bt410_l4` (reconstructed BT
|
|
game lib) + `btl4.exe`. Full recipe + repo-layout map: `docs/PROGRESS_LOG.md §10a / §10a-bis` +
|
|
`README.md`. Env-gate table: [[decomp-reference]] §6.
|
|
|
|
## Build (Win32 / VS2019 BuildTools — the DXSDK link libs are Lib/x86)
|
|
```
|
|
# configure once:
|
|
cmake -S C:\git\bt411 -B C:\git\bt411\build -G "Visual Studio 16 2019" -A Win32 \
|
|
-DCMAKE_GENERATOR_INSTANCE="C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools"
|
|
# build:
|
|
cmake --build C:\git\bt411\build --config Debug
|
|
```
|
|
- Links DXSDK d3d9/d3dx9/dinput8 + OpenAL/libsndfile (`engine/lib/`). DXSDK June 2010 at
|
|
`C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\` (overridable `-DDXSDK`). [T2]
|
|
- Linker uses **`/FORCE`** — tolerates header-defined globals + the **dead offline-factory
|
|
unresolved externals in mech3.cpp** (`Mech::CreateSubsystemStream` references `void*`-signature
|
|
`CreateStreamedSubsystem` for every class; never called at runtime). ⚠ `/FORCE` also HIDES real
|
|
unresolved symbols as runtime AVs — see [[reconstruction-gotchas]] §6. [T2]
|
|
- Editing an `engine/` file rebuilds the engine lib automatically (one project). A NEW member on a
|
|
`DPLRenderer`/`d3d_OBJECT` class needs the game objs that embed its layout recompiled — delete
|
|
stale objs if layout-mismatch corruption appears. [T2]
|
|
- ⚠ Kill the running exe before rebuilding (`taskkill //F //IM btl4.exe`) or you get LNK1104.
|
|
|
|
## Run
|
|
```
|
|
run\run.cmd [EGG] # default DEV.EGG; cd's to content\ and runs btl4.exe -egg <EGG>
|
|
```
|
|
- **cwd MUST be `content\`** — the engine resolves `BTL4.RES`, `VIDEO\`, `BTDPL.INI`, eggs relative
|
|
to cwd (the `loadTables` gotcha: `L4VIDEO.cpp:849` `fopen("VIDEO\\REPLACEMATS.tbl")` is relative +
|
|
unchecked → fread on NULL if cwd is wrong). Logs to `btl4.log` in `content\` (or `BT_LOG=<file>`). [T2]
|
|
- Interactive: **WASD** drive, **Space/Ctrl** fire, **X** all-stop. Default egg = `DEV.EGG`
|
|
(map=grass, time=day). Swap mech via the egg's `vehicle=` (bhk1/madcat/…). The code path is
|
|
mech-agnostic (verified — Mad Cat booted + fought with zero code changes). [T2]
|
|
|
|
## Debug (cdb x86)
|
|
`"C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\cdb.exe"`. Pattern for a faulting stack (cwd
|
|
= content\): `-g -c ".lines;sxe av;g;kp 24;q"` with `BT_ASSERT_TO_DEBUGGER=1`. Debug CRT fills fresh
|
|
heap **0xCDCDCDCD** (uninit) + freed **0xFEEEFEEE** — invaluable for "was this ever constructed?".
|
|
`BT_HEAPCHECK=1` = whole-heap validation every alloc/free (O(n²) at mission load — SLOW). To attach
|
|
to a frozen abort dialog: `cdb -p <pid> -c ".lines;~*kp 30;q"`. [T2]
|
|
|
|
## Repo layout (bt411)
|
|
- **`engine/MUNGA/` + `engine/MUNGA_L4/`** — the shared 2007 MUNGA engine + Win32/D3D9 HAL (carries
|
|
our BT render/loader work: bgfload/L4D3D/L4VIDEO + the image codec). `engine/shim/` (ATL),
|
|
`engine/lib/` (OpenAL/libsndfile), `engine/rp/` (RP *headers* the audio HAL includes).
|
|
- **`game/reconstructed/`** — the reconstructed BT source (the bulk).
|
|
- **`game/original/BT/` + `BT_L4/`** — surviving original BT `.cpp` + **all BT headers** (the include path).
|
|
- **`game/fwd/`** — ~186 forwarding shims (`#include <EXPLODE.hpp>` → `../../engine/MUNGA/<NAME>.h`).
|
|
- **`game/btl4main.cpp`** — the WinMain launcher.
|
|
- **`content/`** — the runtime tree (BTL4.RES, VIDEO/, GAUGE/, AUDIO/, eggs, BTDPL.INI). Run cwd.
|
|
- **`reference/decomp/`** — the raw Ghidra pseudocode (`all/part_*.c`) — the source-of-truth.
|
|
- **`docs/`** — the detailed ledgers (incl. `PROGRESS_LOG.md`, the full pre-restructure CLAUDE.md).
|
|
- **`tools/`** — btconsole.py, disas2.py, map/res scanners. **`context/`** — this knowledge base.
|
|
|
|
## Key Relationships
|
|
- Base: [[wintesla-port]] (the engine build recipe).
|
|
- Verify loop: [[reconstruction-method]]; env gates: [[decomp-reference]] §6.
|