platform profile + gauge dev-composite (Milestone A: gauge renderer woken)

PLATFORM PROFILE (-platform pod|dev / BT_PLATFORM / run.cmd pod; default dev):
an env-preset selector, NOT a code fork -- it picks which environment the
existing video/gauge/input code reads.  dev = single 800x600 window + keyboard
(the working build); pod = RIO input + (on real hardware) the multi-surface
gauges/MFDs, mirroring content/SETENV.BAT (the pod path -- FindBestAdapterIndices
/ SVGA16 -- is left untouched).  The multi-surface needs the pod's 2 video cards,
so -platform pod does NOT auto-enable L4GAUGE on a dev box (stays bootable,
single-window).  Also fixes a real engine bug: SVGA16::BuildWindows
PostQuitMessage'd on a CreateDevice failure but fell through to a null-device
deref (segfault) -- now breaks (inert on the pod).

GAUGE DEV-COMPOSITE, Milestone A (option B; opt-in BT_DEV_GAUGES, default OFF):
wake the (dormant) gauge renderer so its CPU-rastered pixelBuffer can later be
composited into the dev window, WITHOUT touching the pod SVGA16 output path.
SVGA16 does no per-surface D3D in this mode (a DevGaugeComposite() gate forces
the no-surface path + short-circuits Update/Refresh).  Waking the never-exercised
gauge subsystem exposed 4 latent reconstruction bugs, each guarded:
SVGA16::Update / Refresh (empty mSurfaces[]), LBE4ControlsManager::MakeLinkedLamp
(NULL lamp manager), L4GaugeRenderer::NotifyOfNewInterestingEntity (garbage
warehouse chain).  It now boots STABLY; the gauge reconstruction is incomplete
(shadowed lamp-manager + warehouse members) -- Milestone B (the composite pass)
will reveal whether the content is real.  See docs/GAUGE_COMPOSITE.md.

Verified: default DEV un-regressed (combat DESTROYED, 0 crashes); pod path
untouched; BT_DEV_GAUGES boots stable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
arcattack
2026-07-06 10:18:40 -05:00
co-authored by Claude Opus 4.8
parent 8b36440d05
commit c13e72d0ba
7 changed files with 314 additions and 11 deletions
+75 -6
View File
@@ -217,18 +217,87 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
return 0;
}
// Environment defaults (dev box: keyboard controls, single window).
if (getenv("L4CONTROLS") == NULL) putenv("L4CONTROLS=KEYBOARD");
// Renderer config: the real BattleTech DPL environment (paths/fog/lights/
// ambient/projection + cached shapes). RP set L4DPLCFG=RPDPL.INI; BT's is
// BTDPL.INI (in the pod BT dir). Without this, DPLReadEnvironment falls back
// to dpldflt.ini and the cavern world never gets its environment.
// ---------------------------------------------------------------------------
// PLATFORM PROFILE -- dev (default) vs pod. This is NOT a code fork: the
// profile just selects WHICH environment preset the existing video/gauge/input
// code reads (the pod multi-surface path already exists -- FindBestAdapterIndices
// / SVGA16::BuildWindows / L4GaugeRenderer -- gated on these env vars).
// dev = single 800x600 window + keyboard (no L4GAUGE -> MakeGaugeRenderer
// returns NULL, btl4app.cpp:353). The working dev build.
// pod = multi-surface gauges/MFDs (L4GAUGE set) + RIO cockpit I/O, mirroring
// content/SETENV.BAT (the authentic pod preset). The `if getenv==NULL`
// guard lets a real pod environment (SETENV.BAT) override every value.
// Select with env BT_PLATFORM=pod|dev (robust; primary) or a `-platform pod`
// launcher arg. ⚠ A FULL pod run needs the pod's 2 adapters / 7 monitors + RIO
// & plasma serial + GAUGE\L4GAUGE.INI (Phase-8, on real hardware). On a dev box
// `-platform pod` ATTEMPTS the path (FindBestAdapterIndices degrades to the
// primary adapter) -- selectable for bring-up, not fully validated off-pod.
// ---------------------------------------------------------------------------
int gBTPlatformPod = 0;
{
const char *pe = getenv("BT_PLATFORM");
if (pe && _stricmp(pe, "pod") == 0) gBTPlatformPod = 1;
// Convenience: also accept a raw `-platform pod` on the command line,
// parsed off lpCmdLine independently of L4Application::ParseCommandLine.
const char *pf = lpCmdLine ? strstr(lpCmdLine, "-platform") : 0;
if (pf)
{
char pv[16] = { 0 };
if (sscanf(pf + 9, " %15s", pv) == 1 && _stricmp(pv, "pod") == 0)
gBTPlatformPod = 1;
}
}
if (gBTPlatformPod)
{
// POD profile. RIO cockpit input, which falls back to KEYBOARD when the
// serial port isn't present (e.g. a dev box: "RIO initialization failed!
// Shutting Down Serial Port!" -> keyboard).
if (getenv("L4CONTROLS") == NULL) putenv("L4CONTROLS=RIO,KEYBOARD");
// The multi-surface gauges/MFDs are a POD-HARDWARE capability: each surface
// needs its OWN fullscreen D3D device on one of the pod's 2 video cards
// (separate adapters), which can't be created on a typical dev box -- the
// L4GaugeRenderer/SVGA16 path bails there. So `-platform pod` does NOT
// auto-enable them; it stays bootable everywhere as single-window + the pod
// INPUT profile. On the REAL pod the gauges come from content/SETENV.BAT
// (which sets L4GAUGE + the gauge/adapter env); the existing, untouched
// FindBestAdapterIndices / SVGA16 / L4GaugeRenderer path then runs.
// To force-test the surfaces off-pod, set L4GAUGE explicitly (needs >=2 real
// display ADAPTERS, not just monitors). FOLLOW-UP for a dev-visible pod HUD:
// composite the MFDs/gauges into the single window ("MFD compositing on dev").
if (getenv("L4GAUGE") != NULL && getenv("L4PLASMA") == NULL)
putenv("L4PLASMA=com2"); // only when the pod env already asked for gauges
}
else
{
// DEV profile (default): keyboard controls, single 800x600 window.
if (getenv("L4CONTROLS") == NULL) putenv("L4CONTROLS=KEYBOARD");
}
// Shared renderer/config defaults (both profiles). L4DPLCFG=BTDPL.INI gives
// DPLReadEnvironment the real BT environment (paths/fog/lights/ambient) instead
// of the dpldflt.ini fallback.
if (getenv("L4DPLCFG") == NULL) putenv("L4DPLCFG=BTDPL.INI");
if (getenv("DPLARG") == NULL) putenv("DPLARG=1");
if (getenv("MULTISAMPLE") == NULL) putenv("MULTISAMPLE=0");
if (getenv("TARGETFPS") == NULL) putenv("TARGETFPS=60");
if (getenv("MAXPARTICLES")== NULL) putenv("MAXPARTICLES=8192");
// DEV-COMPOSITE GAUGES (opt-in, default OFF): BT_DEV_GAUGES wakes the (otherwise
// dormant) gauge renderer so the pod's gauges/MFDs render + can be composited into
// the dev window. Setting L4GAUGE makes MakeGaugeRenderer build the renderer; on a
// dev box the pod multi-surface (SVGA16 per-adapter fullscreen devices) stays at 0
// surfaces (guarded in SVGA16::Update), and a composite pass in the main renderer
// blits the CPU-rastered pixelBuffer as a window inset. See docs/GAUGE_COMPOSITE.md.
if (getenv("BT_DEV_GAUGES") != NULL && getenv("L4GAUGE") == NULL)
putenv("L4GAUGE=640x480x16");
std::cout << "[boot] platform profile: "
<< (gBTPlatformPod ? "POD (RIO cockpit input; multi-surface gauges/MFDs via pod hardware or explicit L4GAUGE)"
: "DEV (single window + keyboard)")
<< std::endl << std::flush;
// DEBUG (bring-up, default OFF): force the player mech to walk full-ahead with
// no keypress so locomotion + camera-follow can be verified in a headless run.
// BT_FORCE_THROTTLE may carry a VALUE: +1 full run, ~0.3 walk, -1 reverse (default 1.0).