Glass cockpit refit: one mode resolver, one button geometry, and a cockpit that scales

Replicates the RP412 cockpit line into BT411's own architecture -- porting the
geometry and keeping our renderers, so BT_SHOT single-frame verification stays
intact.

MODE RESOLVER.  Where the secondary displays go was decided in TWO places with
duplicated precedence, and the boot banner read NEITHER -- it announced
"per-display cockpit windows" for every glass boot, surround included.  The
split had also broken BT_COCKPIT=0: documented as the dock-bottom opt-out, the
profile block converted it to BT_GLASS_PANELS=1, so the docked strip was
UNREACHABLE under the glass profile.  One resolver now, consumed by the banner,
the pad-panel decision and the window sizing; BT_GLASS_PANELS is explicit-only;
dock/window modes auto-raise BT_PAD_PANEL so the button field always has a home.

L4RIOBANK -- one button geometry.  Both renderers carried their own copy and had
drifted: an MFD button was 156x138 reaching under the glass in the exploded
window and a 76x24 sliver entirely OUTSIDE the glass in the surround.  One
module owns it now, both are consumers, placement stays per-renderer.  The pod's
under-glass rule (RP412 L4MFDVIEW): reach half the glass in behind the display,
leave a lamp strip clearing the edge, paint buttons first and imagery over --
so the lamp reads as a bar and practically the whole display is the press
target.  The strip scales off the display's SHORT axis (the map is portrait)
with a readable floor.  Retired L4GLASSWIN's three local placers and seven
layout constants.

LAMP FLASH DECODE was wrong [T1].  BTLampBrightnessOf returned max(state1,
state2) and blanked on the alternate phase; RIO::LampState (L4RIO.h [T0]) says
solid shows state 1 and flashing ALTERNATES the two.  Agrees only when one state
is Off -- true for the Panic lamp, which is why it survived -- but L4LAMP.cpp:252
commands flashFast + state1Dim + state2Bright, a dim->bright pulse that rendered
as a hard bright->off blink.  Three copies existed (l4vb16.h, L4GLASSWIN,
L4PADPANEL), all three wrong; the two locals now forward to the one fixed inline.

THE COCKPIT SCALES.  The fixed canvas was stretched into whatever the client
area was, so a window dragged to a different shape squashed the instruments (the
projection was aspect-corrected in task #20; the panels never were).  Now one
uniform scale, centred, leftover black.  D3D9 applies it as a Present
destination rect, which DISCARD forbids -- so the WINDOWED swap effect becomes
COPY when the surround is up and multisampling is off.  The click mapping had to
follow (mapping against the full client drifts the hit test off every button by
the bar width), as did the world aspect (under a uniform scale it is the view
rect's own).  -fit / -windowed-fullscreen: borderless over the monitor.

 - ordering trap: the first WM_SIZE beats the device, so a -fit boot logged
   aspect=3.14 and applied it on frame 1.  The letterbox INTENT is decided in
   btl4main; L4VIDEO only confirms or withdraws it.

PLAYER-TUNABLE DISPLAYS.  BT_MFD_SCALE (+ _UL/_UC/_UR/_LL/_LR), BT_RADAR_SCALE,
BT_RADAR_POS (CENTER/LEFT/RIGHT/MIDLEFT/MIDRIGHT).  The surround BANDS derive
from the resolved sizes -- that is why the sizes could not stay constants: the
band a display hangs in has to grow with it or the canvas clips it.  100%
reproduces the historical L276 R276 T223 B336 exactly.  A corner map goes flush
to the CANVAS edge and the lower MFD slides beside it (measuring off the view
edge overlapped them by 232px).

MAP LEGEND GRID -- measured, not inherited.  scratchpad/measurelegend.py over a
native capture: top 3, cell 102, pitch 107 of 640.  RP412's map is 13 + 6x102 @
105 -- same cell height, different top and pitch, so its numbers do NOT
transfer.  Our old even division had the pitch right by luck and sat 3px high of
the labels.

environ.ini.  It was read ~300 lines into WinMain, AFTER the platform-profile
block had run its getenv()s -- so every setting the profile reads was silently
ignored FROM THE FILE and only worked as a real env var.  It also putenv()'d
comments verbatim.  Now loaded immediately after the first-breath line, comments
skipped, the real environment WINS over the file, and a fully documented default
is written on first run (the bindings.txt convention: untracked, so
extract-over-top never clobbers a player's settings).

VERIFICATION HARNESS (new, reusable): BT_RIOBANK_LOG=1 dumps every bank;
checkbank.py proves no address is SHADOWED (an address whose rect is covered by
earlier buttons is dead however big it looks -- the overlapping under-glass banks
make that a live hazard); clickbank.py posts a real click at every button centre.

Verified: 72/72 placed, 0 shadowed, 72/72 dispatched in BOTH modes, after a
resize, at 150%/135%, and at 75%+BOTTOMRIGHT; wide/tall drags and -fit
undistorted on a 3440x1440; exploded/dock/pod/dev un-regressed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-26 02:23:40 -05:00
co-authored by Claude Opus 5
parent 1cda880c6d
commit 61563c9efe
15 changed files with 1670 additions and 282 deletions
+45 -2
View File
@@ -3419,6 +3419,34 @@ DPLRenderer::DPLRenderer(
mPresentParams.MultiSampleQuality--;
}
mPresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
//
// COCKPIT LETTERBOX (2026-07-26): the fixed canvas is fitted into the client
// at Present time via a destination rect, which DISCARD forbids -- COPY is
// the swap effect that takes one. Windowed + surround only, and only with
// multisampling off (COPY cannot multisample). Full contract: l4vb16.h.
//
// btl4main sets the INTENT (it has to: the first WM_SIZE beats the device
// here); this is where it becomes real, or gets withdrawn.
{
extern int gBTGaugeCockpit;
extern int gBTCockpitLetterbox;
if (!fullscreen && gBTGaugeCockpit && gBTCockpitLetterbox &&
mPresentParams.MultiSampleType == D3DMULTISAMPLE_NONE)
mPresentParams.SwapEffect = D3DSWAPEFFECT_COPY;
else
gBTCockpitLetterbox = 0; // withdrawn -- the canvas stretches
// only meaningful when there IS a cockpit canvas to fit
if (gBTGaugeCockpit)
DEBUG_STREAM << "[cockpit] letterbox " << (gBTCockpitLetterbox ? "ON" : "off")
<< " (swap effect "
<< (mPresentParams.SwapEffect == D3DSWAPEFFECT_COPY ? "COPY" : "DISCARD")
<< (mPresentParams.MultiSampleType != D3DMULTISAMPLE_NONE
? "; multisampling on -- COPY unavailable, canvas stretches to the client"
: "")
<< ")\n" << std::flush;
}
mPresentParams.hDeviceWindow = hWnd;
mPresentParams.Flags = 0;
mPresentParams.FullScreen_RefreshRateInHz = (fullscreen)?60:D3DPRESENT_RATE_DEFAULT;
@@ -8799,7 +8827,11 @@ void DPLRenderer::ExecuteImplementation(RendererComplexity, RendererOrigin::Inte
// DIAG (turn-hitch hunt): draw CPU is _rt0..here; Present blocks on the GPU.
LARGE_INTEGER _rt1; QueryPerformanceCounter(&_rt1);
hr = mDevice->Present(NULL, NULL, NULL, NULL);
// COCKPIT LETTERBOX: uniform-scale the canvas into the client (NULL = the
// old full-client stretch, which is what every non-cockpit run gets).
RECT _ckDestStorage;
const RECT *_ckDest = BTCockpitPresentDest(mPresentParams.hDeviceWindow, &_ckDestStorage);
hr = mDevice->Present(NULL, _ckDest, NULL, NULL);
// The wait-screen overlay stands down PERMANENTLY the moment the first
// REAL scene frame presents (user report 2026-07-22: the launch handoff
// briefly interleaved idle-overlay presents with game frames = flicker).
@@ -9125,7 +9157,12 @@ void DPLRenderer::ExecuteIdle()
}
backbuffer->Release();
}
HRESULT present_hr = mDevice->Present(NULL, NULL, NULL, NULL);
// same letterbox as the scene present -- the wait overlay paints into
// this backbuffer, so it has to land in the same rect
RECT wait_dest_storage;
const RECT *wait_dest =
BTCockpitPresentDest(mPresentParams.hDeviceWindow, &wait_dest_storage);
HRESULT present_hr = mDevice->Present(NULL, wait_dest, NULL, NULL);
static int s_wait_path_logged = 0;
if (!s_wait_path_logged)
{
@@ -9772,12 +9809,18 @@ static float BTWorldAspectOf(int client_w, int client_h)
// ON-SCREEN aspect = (viewW/canvasW * client_w) / (viewH/canvasH * client_h).
extern int gBTGaugeCockpit;
extern int gBTCockpitCanvasW, gBTCockpitCanvasH;
extern int gBTCockpitLetterbox;
if (gBTGaugeCockpit && gBTCockpitCanvasW > 0 && gBTCockpitCanvasH > 0)
{
BTCockpitLayout L;
BTCockpitComputeLayout(gBTCockpitCanvasW, gBTCockpitCanvasH, &L);
if (L.viewW > 0 && L.viewH > 0)
{
// LETTERBOXED: the canvas is scaled UNIFORMLY, so the view's
// on-screen aspect is just its own -- the client no longer enters
// into it (2026-07-26).
if (gBTCockpitLetterbox)
return (float)L.viewW / (float)L.viewH;
float w = (float)L.viewW * (float)client_w / (float)gBTCockpitCanvasW;
float h = (float)L.viewH * (float)client_h / (float)gBTCockpitCanvasH;
if (h > 0.0f) return w / h;