Files
BT411/context/source-completeness.md
T
Joe DiPrimaandClaude Fable 5 e69c0d7aa8 #60 GAP CENSUS: the export dark-region inventory (tool + report + KB)
tools/gapcensus.py (deterministic): index-vs-.text interval math, export
cross-check, function-start discovery inside dark regions (E8 call targets +
data-section code pointers), pad exclusion, TU attribution, repo-citation
flags. Output: reference/decomp/GAP_CENSUS.md + gap_census.tsv.

Headline: .text 892KB, index covers 87.3%; 428 dark regions = 90KB REAL code
(indexed-but-unexported = 0 -- the gap class is purely 'never indexed').
Game-side dark ~54KB: 66 regions visited by past digs, 159 NEVER TOUCHED.
Validation: all six historically-bitten dark addresses (VehicleDead,
ToggleLamp, death tail, master-perf, myomer integrator, duck consumer) land
inside census regions; the two most-cited regions are the two that produced
the most reconstructions.

Top uncharted leads (spot-checked real code): the ~9KB l4splr|btmssn cluster
(dispatch-table state machine -- likely BTMission's unexported heart); the
613B btplayer hole before the ctor (mission-review id-0x18 sender suspect);
btl4app tails; heat|mechmppr + mechweap|btplayer boundaries. Full log:
phases/phase-04-gap-census.md. Re-export half deferred (no local Ghidra;
scripts ready). KB: source-completeness census section + CLAUDE.md lookup
row + decomp-reference tools entry; consult the census BEFORE any 'absent
from the export' claim (gotcha #20).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-06 10:34:02 -05:00

114 lines
8.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 (2026-08-06, #60) — the dark-region inventory [T1]
`tools/gapcensus.py``reference/decomp/GAP_CENSUS.md` + `gap_census.tsv` (regenerate after
any re-export). Headline: .text 892 KB; the index covers 87.3%; **428 dark regions = 90 KB of
real code Ghidra never made into functions** (indexed-but-unexported = 0 — the gap class is
purely "not indexed"). Game-side (bt/ + bt_l4/ + boundary) dark ≈ 54 KB: 66 regions already
visited by past digs, **159 never touched**. 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.
Second half still open: a Ghidra re-export (scripts ready in `reference/ghidra_scripts/`; no
local install) forcing disassembly at the 332 discovered starts would convert most of it.
## 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]].