Installed JDK 21 + Ghidra 12.1.2 (no admin, %LOCALAPPDATA%\bt411-tools beside DXSDK/cmake; runner uses 8.3 SHORT paths because Ghidra's .bat expands %JAVA_HOME% unquoted and the profile has a space). New tooling: reference/ghidra_scripts/ExportGaps.java -- ExportAll's exact output contract PLUS a gap-fill pass (force disassembly + createFunction at E8 call targets outside functions, data->code pointers at a plausible prologue, and the census's discovered starts; iterated to a fixpoint, logged to gapfill_report.tsv). tools/ghidra_reexport.sh (headless runner, 'reprocess' mode) and tools/gapdiff.py (score two censused exports); gapcensus.py now censuses any export dir. Results: 6267 -> 6472 functions (+205 created in 2 rounds: 195 census starts, 6 call targets, 4 data pointers; 56.1KB newly covered), ZERO decompile failures. Dark real code 90.4 -> 40.8 KB (54.8% recovered); game-side dark 53.1 -> 21.1 KB; regions 428 -> 321. EVERY historically dark function now has pseudocode -- including @0x4c05c4 VehicleDead, the absence that opened this issue. VALIDATION: the new pseudocode confirms this week's hand reconstruction of the crouch field-for-field (mapPosture/duckState/squatCapable/myomerEff/ novice gate/SetLegAnimation/ForceUpdate/stability alarm) -- and exposed one branch the raw pass missed: AIRBORNE AUTO-RISE (mode 3|4 && legState 1 -> forced squ), now implemented in mech4.cpp and re-benched un-regressed. PROMOTION: the re-export is canonical reference/decomp/; the previous export is preserved at reference/decomp/archive_2025export/ so old `part_0NN.c:LINE` citations still resolve (addresses are stable across both; line/shard membership is NOT -- cite @ADDR). New lead recorded: @0x4c0904 is the MASTER BTPlayer Performance (team resolution, EndMission console post, score heartbeat) -- our @0x4c083c PlayerSimulation attribution needs a re-check. KB: source-completeness, gotcha #20 (the rule is cheap now -- look it up), CLAUDE.md router/layout. Log: phases/phase-04-gap-census.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
127 lines
9.1 KiB
Markdown
127 lines
9.1 KiB
Markdown
---
|
|
id: source-completeness
|
|
title: "Source Completeness — the gating blocker + the decompilation route"
|
|
status: established
|
|
source_sections: "PROGRESS_LOG.md §5a; docs/BT_SOURCE_STATUS.md"
|
|
related_topics: [wintesla-port, reconstruction-method, decomp-reference, open-questions]
|
|
key_terms: [BTL4OPT, decomp, oracle, WinTesla, BT]
|
|
open_questions:
|
|
- "Backfill the missing 1995 engine headers/TUs (vdata.hpp first) by back-dating the WinTesla/BT412 versions — the compile-closure blocker"
|
|
---
|
|
|
|
# Source Completeness — the gating blocker
|
|
|
|
The archive has the **engine and all headers, but NOT the BT game's implementation `.cpp`.**
|
|
This is THE gating fact that shapes the whole project. Full map: `docs/BT_SOURCE_STATUS.md`.
|
|
|
|
## What's present vs missing (verified across all 3 zips + the WinTesla archive)
|
|
- **MUNGA engine** (shared): ~183 `.cpp` — largely complete (renderer, MOVER/JMOVER, math, scene),
|
|
BUT NOT gapless: a 2026-07-19 header-vs-impl audit + compile bootstrap found missing engine
|
|
`.cpp` (PLAYER, NETWORK, GRAPH2D, OBJSTRM, SCNROLE, EXPLODE, L4SPLR, L4APP + ~15 smaller) AND at
|
|
least one missing engine HEADER (`vdata.hpp`, included by plug.hpp — exists only as the drifted
|
|
WinTesla/BT412 `VDATA.h`). `CODE/BT/MUNGA` is a PARTIAL BT-drift overlay (69 files) over the
|
|
fuller `CODE/RP/MUNGA` (305); a 1995 build needs the merged BT-over-RP view. [T1]
|
|
- **BT game `.hpp` headers: PARTIAL, not complete** (2026-07-19 correction — the old "all headers
|
|
present" claim was WRONG): only 17 of ~36 bt-side `.hpp` survive (mech.hpp, mech2-4, heat.hpp,
|
|
mechmppr.hpp, torso.hpp, gyro.hpp, hud.hpp, myomers.hpp, powersub.hpp, btplayer.hpp are
|
|
reconstruction-only), and BTL4VID.HPP/BTL4MPPR.HPP are missing on the btl4 side. `BT.HPP`'s
|
|
`NO_PRECOMPILED_HEADERS` gate skips the missing mech/btplayer/mechsub includes, which is why
|
|
TUs outside the mech family still compile-close. [T1]
|
|
- **BT game logic `.cpp`: MISSING** — `mech`, `mech2/3/4`, `mechsub`, `mechmppr`, `mechtech`, `heat`,
|
|
`sensor`, `gyro`, `torso`, `myomers`, `hud`, `mechweap`, `powersub`, `btplayer`, and the main app
|
|
`btl4` are all absent. Only ~10 BT `.cpp` survive (BTCNSL/BTMSSN/BTREG/BTSCNRL/BTTEAM/BTTOOL +
|
|
GAUSS/PPC + BTL4ARND/BTL4MODE). [T1]
|
|
- **RP can't backfill BT** — RP's game source is gutted the same way; only shared *engine*
|
|
game-logic survives. [T1]
|
|
|
|
## Consequence — routes forward
|
|
**Route A is CLOSED (2026-07-19): per the user, Nick holds NO assets beyond what's already been
|
|
provided.** The decompile-and-reconstruct route is THE route: (behavioral) the WinTesla-hosted
|
|
port in `game/reconstructed/`, and (literal) `TeslaRel410/restoration/source410/` — both fed by
|
|
the decomp + the manifest. [T1]
|
|
|
|
## The binary is a near-ideal decompile target
|
|
`btrel410.exe` is a PKZIP self-extractor; inside is **`BTL4OPT.EXE`** (1.24 MB, clean uncompressed
|
|
PE32). CORRECTION (2026-07-19 [T1]): the DOS-extender is **Borland PowerPack DPMI32**, not Phar
|
|
Lap TNT — proven by `OPT.MAK` (`-Tpe`, STARTUP `c0x32.obj + dpmi32.lib + cw32.lib`) + the archived
|
|
`32STUB.EXE`/`32RTM.EXE`/`DPMI32VM.OVL`. It retains **class names, `Class::Method` strings, and
|
|
source-file paths in asserts** (`d:\tesla_bt\bt\mech.cpp`) — confirming the missing modules ARE in
|
|
the binary. No COFF symbol table (naming comes from those strings). Extracted to
|
|
`reference/decomp/`. [T1]
|
|
|
|
## THE TOOLCHAIN IS IN HAND (2026-07-19) [T1]
|
|
**Borland C++ 4.52** identified by BYTE-MATCH: the archived fleet `CW32.LIB` (`CODE/RP`) is
|
|
identical to the 4.52 install's and differs from 4.5's. Installed at `TeslaRel410/BORLAND/BC45/`
|
|
(the 4.5 CD was disposed per the user). BCC32/TLINK32/TLIB/MAKE all run NATIVELY on Win11
|
|
(hello-world compiled+linked+ran). **`CODE/BT/OPT.MAK` is the shipped binary's exact recipe**:
|
|
`BCC = bcc32` (NOT bcc32i — that was only EXAMPLE.CFG), `-DLBE4;DEBUG_LEVEL=0;DEBUG_STREAM=cout`,
|
|
`-5 -a4 -ff -k- -V -Jg -x- -RT- -O2 -Ot -Oc -Og -O -Ol -Z -Ob -Oe -Oi -Om -Op -Ov`, PCH via
|
|
`-H=btopt.csm`; link `-Tpe -ax` + c0x32/dpmi32/cw32. Gaps: TASM32 absent (separate product;
|
|
only JOYSTICK.ASM needs it); compile bootstrap of original BTL4MODE.CPP parses deep into the real
|
|
headers but stops at the missing `vdata.hpp` closure (see What's-missing above). Source paths for
|
|
a build: include order = `CODE/BT/*` OVER `CODE/RP/*` (BT drift wins), roots per `BTL4.PTH` /
|
|
`EXAMPLE.CFG` (all under the archive: LIBDPL/SOS/NETNUB in `CODE/BT/MUNGA_L4/`). [T1]
|
|
|
|
## The mountain, measured (2026-07-18) — the per-TU manifest
|
|
`tools/manifest410.py` → **`reference/BT410_SOURCE_MANIFEST.md`**: every image function
|
|
attributed to its original TU via the makefile link order (BT.MAK/BTL4.MAK — census + the
|
|
tlink32 lib order), Fail() path+line anchors, CLASSMAP seeds, and a monotone-in-link-order DP
|
|
over data-section cluster affinity. **The missing BT game code = 917 functions / ~230 KB**
|
|
(bt.lib 482 fn/153 KB + btl4.lib 435 fn/76 KB) out of 6267 image functions; DP extents match
|
|
every independently-known TU boundary. [T1 region totals / T3 unanchored boundaries]
|
|
Corrections/leads: the **`.TCP` files are TEST-CLASS files** (debug self-test bodies with
|
|
SOME shipped code — minor partial survivors for heat, gnrator, emitter, projweap, ammobin,
|
|
projtile, missile); toolchain = **Borland BCC/tlib/tlink32** (from the makefiles;
|
|
`TeslaRel410/BORLAND/` placeholder is EMPTY — no byte-match compiler archived yet, though
|
|
`CODE/RP` keeps C0X32.OBJ/CW32.LIB/32STUB.EXE); `TeslaRel410/sda4` + `CODE/` swept — NO BT
|
|
`.cpp` there; PVCS conventions (sda4 install) ⇒ **`.CPV`/`.HPV`/`.TCV` are the grep
|
|
targets** for future drive dumps. Full log: `phases/phase-03-bt410-source-manifest.md`.
|
|
|
|
## The literal 4.10 tree — `TeslaRel410/restoration/source410/` (started 2026-07-18)
|
|
The archival-grade recreation of the missing TUs in 1995 house style against the surviving
|
|
1995 engine headers (distinct from OUR WinTesla port). Rules + status in its README; every
|
|
file carries a `.NOTES.md` evidence sidecar; binary `Fail()` file:line records are treated
|
|
as LINE CONSTRAINTS. **Pilot complete: `BT_L4/BTL4APP.CPP`** — 12/12 functions, all decomp
|
|
constants resolved to named 1995 expressions (`ApplicationID` BTL4=1 + an unreleased `BTW4`
|
|
slot in APPMSG.HPP; `ModeInitial`=0x50421; `AddModeMask` inlines byte-exact), Fail lands on
|
|
its recorded line 400 exactly. [T1/T3 per the sidecar]
|
|
|
|
## Why reconstruction is viable (THREE anchors)
|
|
1. **All BT headers** = exact class layouts, vtable order, signatures (the answer key).
|
|
2. **The working WinTesla engine** to compile against ([[wintesla-port]]).
|
|
3. **Red Planet's parallel implementations** as a live reference (`VTV`≈mech, `VTVMPPR`≈mechmppr,
|
|
`WEAPSYS`≈mech weapons, `RP_L4` app≈BT app).
|
|
Plus `BTL4OPT.EXE` as a behavioral **oracle** (run under cdb / read the decomp). Result =
|
|
behavior-equivalent **reconstruction**, NOT original source. [T2]
|
|
|
|
## THE GAP CENSUS + RE-EXPORT (2026-08-06, #60) — BOTH HALVES DONE [T1]
|
|
**The export was REBUILT 2026-08-06** (Ghidra 12.1.2 headless + `ExportGaps.java`'s gap-fill
|
|
pass): index coverage **87.3% → 93.5%**, dark real code **90.4 KB → 40.8 KB (54.8% recovered)**,
|
|
game-side dark 53.1 → 21.1 KB, functions 6,267 → **6,472** (+205, zero decompile failures).
|
|
Every historically-bitten dark function now has pseudocode — including `@0x4c05c4` VehicleDead,
|
|
the absence that opened #60. The re-export CONFIRMED the crouch reconstruction field-for-field
|
|
and revealed one branch the raw pass missed (airborne auto-rise, fixed same day).
|
|
⚠ **The old export is archived at `reference/decomp/archive_2025export/`** — addresses are
|
|
stable across both, but `part_0NN.c:LINE` citations only resolve against the archive. Cite
|
|
`@ADDR`, not part/line. Pipeline: `tools/ghidra_reexport.sh` → `tools/gapcensus.py` →
|
|
`tools/gapdiff.py`. Toolchain (JDK 21 + Ghidra 12.1.2) lives in `%LOCALAPPDATA%\bt411-tools`;
|
|
the runner MUST use 8.3 short paths (Ghidra's .bat expands %JAVA_HOME% unquoted and the user
|
|
profile has a space). Full log: `phases/phase-04-gap-census.md`.
|
|
|
|
### The original inventory (part 1, same day) [T1]
|
|
`tools/gapcensus.py` → `reference/decomp/GAP_CENSUS.md` + `gap_census.tsv` (regenerate after
|
|
any re-export; it censuses whatever dir you point it at). As found BEFORE the re-export: .text
|
|
892 KB, index 87.3%, **428 dark regions = 90 KB of real code** (indexed-but-unexported = 0 —
|
|
the gap class is purely "not indexed"), game-side dark ≈ 54 KB with 159 regions never touched.
|
|
Current numbers are in the header above. Validation: all six historically-bitten dark
|
|
addresses (VehicleDead, ToggleLamp, death tail, master-perf, myomer integrator, duck consumer)
|
|
land inside census regions. Top uncharted leads + method: `phases/phase-04-gap-census.md`.
|
|
**RULE (gotcha §20):** consult the census BEFORE any "absent from the export/binary" claim —
|
|
if the address falls in a dark region, the claim needs byte-scan evidence, not export silence.
|
|
(The second half — the re-export — landed the same day; see the header.)
|
|
|
|
## Key Relationships
|
|
- Feeds: [[reconstruction-method]] (the loop that fills the gap), [[decomp-reference]].
|
|
- Route A closed 2026-07-19 (Nick holds nothing further); gated now only on reconstruction labor + the engine-closure backfill.
|
|
- Built atop: [[wintesla-port]].
|