9c67dddd83 Display diagnostics + -fps/-tcoop; native multi-monitor MFD ruled out
Four-monitor MFD bring-up on the new bench (MR_new: AMD FirePro W4100, 4 outputs,
Win10). Adds permanent display diagnostics, a Release-capable frame pacing logger,
a self-locating AppCompat shim installer, and settles -- empirically -- whether
dgVoodoo2 can be dropped for the multi-monitor MFD modes. It cannot.

WHY THIS WAS HARD
-----------------
CHSH_Device::InitFirst/InitSecond discarded EVERY HRESULT (SetCooperativeLevel,
SetDisplayMode, CreateSurface, GetAttachedSurface, QueryInterface, CreateDevice)
and returned true unconditionally. A panel that failed to open produced no error,
no crash and no log entry -- the monitor just stayed on the desktop. SPEW is
compiled out of shipping builds, so none of it was visible. Restoring that
visibility is what unblocked everything else.

DIAGNOSTICS ADDED (keep these)
------------------------------
* VideoCard.cpp -- LogDisplayDevices() writes gos-displays.txt next to the exe:
  NumDevices/NumHWDevices/NumMonitors, every DirectDraw device with its
  hw_rasterization flag, the role assignment (FullScreenDevice / g_nNonDualHead /
  g_nDualHead / g_nDualHead2 / g_nMFD1 / g_nMFD2), per-slot -tmon APPLIED/REJECTED
  (previously silent), and whether mode 4's "BOTH mfd1 and mfd2" requirement is met.
* render.cpp -- HSH_LogInit()/HSH_CheckHR()/HSH_HRName() log every DirectDraw call
  in the panel init path with its HRESULT decoded by name (27 DDERR_* codes, all
  verified present and collision-free against build-env/dx7asdk/include/ddraw.h).
  Each line is opened/appended/closed individually so the log survives a crash.
* WinMain.cpp -- GOS_LogFrameRate() writes gos-fps.txt: per second, frame count,
  average fps, 1% low (mean of the worst 1% of frames), worst frame in ms, and a
  count of frames exceeding 2x average ("hitches"). Average fps alone cannot
  distinguish 60fps from 60fps-with-a-dropped-frame-every-second; the 1% low can.
  The engine's own FrameRate readout is #ifdef LAB_ONLY (MWMission.cpp) so it only
  exists in MW4pro.exe; this works in Release, which is what runs on the pods.

NEW SWITCHES (both documented in -help)
---------------------------------------
* -fps    Enable the frame pacing report. Off by default: the gate is the first
          statement in GOS_LogFrameRate, so an unflagged run does no arithmetic
          and does not even create the file. The file handle is held open for the
          process lifetime -- opening/closing it every second would put a syscall
          of unpredictable latency on the render thread, i.e. the measurement tool
          perturbing what it measures.
* -tcoop <0-5>  Selects the SetCooperativeLevel form used by the radar/MFD panels.
          0 = legacy (unchanged shipped behaviour, remains the default).
          Exists so every candidate fix could be compared on real hardware without
          a rebuild between attempts.

CRASH-SAFETY FIX
----------------
hsh_initialized was set unconditionally after panel init, so a failed panel left
null surfaces and a null IDirect3DDevice7 behind and the per-frame path called
straight through them. Now:
  - all four InitSecond overrides (CMR/CRadar/CMFD/CMFDRight) bail on base failure,
  - CMFD_Device::InitFirst reports its real result instead of always returning true,
  - hsh_initialized is only set when the panels genuinely came up.
A display failure now leaves the game running without MFDs instead of bombing to
desktop. Crash signature for the record: `call [ecx+0x44]` with ECX=0 is
IDirectDrawSurface7::GetDC on a never-created surface (vtable offset confirmed
against the DX7 header), reported as "Attempt to read from address 0x00000044".

APPCOMPAT SHIM INSTALLER (new)
------------------------------
build-env/set-appcompat.ps1 + set-appcompat.bat. Self-locating via $PSScriptRoot:
applies DWM8And16BitMitigation to the MW4 executables sitting next to it, wherever
that install lives. HKCU always, HKLM too when elevated (the HKLM value format
differs -- it carries a leading "$" marker -- so the two must not be interchanged).
Verifies by reading back; detects the HIGHDPIAWARE-only entry that SUPPRESSES the
automatic shim; supports -Remove and -WhatIfOnly. deploy-mw4.ps1 now ships both
files into every deployment.

This matters because the layer is keyed on the executable's FULL PATH -- any copy
of an install to another folder or machine silently loses it, and the resulting
error is actively misleading (see below).

WHAT WE LEARNED
---------------
* The AppCompat shim SYNTHESISES 16-bit display modes. Proved directly: the crash
  dump shows "16 bit modes :" EMPTY without it and fully populated with it. MW4
  renders at bitdepth=16 and modern GPUs expose no 16-bit modes at all.
* Without the shim, GameOS reports "Another application is preventing use of full
  screen mode" (GOS_DXRASTERIZER_NOFULLSCREEN, DXRasterizer.cpp ~1125). That is a
  catch-all fired after every SetDisplayMode attempt fails -- it even scans for
  NetMeeting -- and it sends you looking for a conflicting program that does not
  exist. The real cause is the missing shim.
* Exclusive fullscreen DOES work on Win10 with the system ddraw.dll and dgVoodoo2
  physically removed, once the shim is applied to that exe path.
* Windowed mode works natively with no shim at all: the windowed path sets
  Environment.bitDepth = DesktopBpp (32), so there is no mode switch. Verified for
  the console/shell; a full mission windowed is still untested.
* Native DirectDraw enumerates all four W4100 outputs, so dgVoodoo2 was never
  needed for device enumeration.
* The engine is 4:3 ONLY. ImageHlp.cpp ~464 asserts the complete supported set:
  640x480, 512x384, 800x600, 960x720, 1024x768, 1280x1024 (5:4), 1600x1200. No
  16:9 mode and no aspect correction anywhere in the codebase. On a 16:9 monitor
  the scaler must adapt: plain stretch distorts geometry, keep-aspect pillarboxes.
* -2dt is not a recognised switch anywhere in the codebase, despite appearing in
  production ctcl.ini launch lines. Completely inert.
* NumHWDevices (5) can exceed NumDevices (4): it counts D3D device-enumeration
  callbacks, and an adapter exposing both a HAL and a T&L HAL yields two. Benign.

WHAT WE TRIED AND WHY IT FAILED
-------------------------------
The panel cooperative-level call was genuinely wrong -- a latent 2002 bug. Every
panel asked to be BOTH the process focus window AND its own device window, on the
one shared hWindow, after the main device had already taken exclusive mode on it.
The main device (DXRasterizer.cpp ~1027) already uses the correct two-call idiom
(SETFOCUSWINDOW alone, then EXCLUSIVE|FULLSCREEN) -- tagged //sanghoon, the same
author. The panels never were.

Results on real hardware, no dgVoodoo2, shim applied, -tmfds 4:

  -tcoop 0  SETFOCUSWINDOW|CREATEDEVICEWINDOW|ALLOWREBOOT|EXCLUSIVE|FULLSCREEN
            -> DDERR_EXCLUSIVEMODEALREADYSET
  -tcoop 1  CREATEDEVICEWINDOW|EXCLUSIVE|FULLSCREEN (no focus claim)
            -> DDERR_INVALIDPARAMS (CREATEDEVICEWINDOW needs a focus window)
  -tcoop 2  SETFOCUSWINDOW, then CREATEDEVICEWINDOW|EXCLUSIVE|FULLSCREEN
            -> DDERR_INVALIDPARAMS
  -tcoop 3  SETFOCUSWINDOW, then EXCLUSIVE|FULLSCREEN
            -> first panel collides, but that collision STEALS exclusive mode from
               the main display, after which panels 2 and 3 fully initialise (the
               radar reached CreateDevice(HAL) = DD_OK -- a secondary panel running
               entirely on native DirectDraw). Side effect: the desktop was left at
               1920x1080 16bpp. Not viable.
  -tcoop 4  EXCLUSIVE|FULLSCREEN only          -> EXCLUSIVEMODEALREADYSET, all panels
  -tcoop 5  ALLOWREBOOT|EXCLUSIVE|FULLSCREEN   -> EXCLUSIVEMODEALREADYSET, all panels

CONCLUSION: on modern Windows only ONE DirectDraw object per process may hold
exclusive fullscreen. The main display takes it; every secondary panel is refused.
XP allowed multiple. dgVoodoo2 allows it because it is a full reimplementation of
ddraw and is not bound by that rule -- it is not papering over a bug we can fix.

=> dgVoodoo2 CANNOT be removed for -tmfds 1/3/4 by correcting these flags. The
default stays -tcoop 0. The switch is retained because it is how this was settled
and it will re-settle it on different hardware.

The only native path is a borderless windowed panel design (DDSCL_NORMAL + clipper
per monitor, no exclusive mode anywhere). Assessment and staged plan are recorded
in CLAUDE.md STEP 10; not started.

WORKING 4-MONITOR CONFIG (with dgVoodoo2)
-----------------------------------------
dgVoodoo2 Scaling mode MUST be "Stretched, Keep Aspect Ratio". Plain "Stretched"
fails silently: main and radar go fullscreen black, both MFD monitors keep showing
the desktop, and every DirectDraw call still returns DD_OK -- the devices are alive
but dgVoodoo2 never drives those outputs. Diagnosed with a temporary per-panel
colour-flash test (since removed), which also established that device index maps
1:1 to physical monitor on this bench, so -tmon 1,2,3,4 equals auto-detection.
Confirmed working end to end: all three secondary panels present, full mission
played.

KNOWN GAP: the working dgVoodoo.conf is still not versioned in the repo (removed
in 0ceba9c7), so a fresh deploy will reproduce the silent MFD failure.

Behaviour with no new switches supplied is unchanged from the previous build
except on failure paths, which now degrade gracefully instead of crashing.

Co-authored-by: Claude Opus 5 (Anthropic) <noreply@anthropic.com>
Co-authored-by: GitHub Copilot <copilot@github.com>
2026-07-25 18:22:31 -05:00
2026-07-25 08:54:28 -05:00
2026-06-26 10:40:23 -05:00

BattleTech: FireStorm — workspace layout

⚠️ Setting up a new machine? Read RECOVERY.md BEFORE cloning this repo. The clone only comes out byte-exact if long paths, core.autocrlf=false, and Git LFS are configured first — cloning without them silently corrupts line endings, truncates deep VC98/MFC paths, and leaves LFS placeholders instead of the real binaries.

This is the working tree for the FireStorm total-conversion built on the MechWarrior 4 (Gameleap / GameOS) engine. Only three trees feed the build/deploy; everything else is output (regenerable), design reference, or archived clutter. See CLAUDE.md for the full build/runtime reconstruction notes.

Folder map

C:\VWE\firestorm\
├─ Gameleap\                       The MW4/Gameleap 5.03 engine + game (the two live trees)
│  ├─ code\                        ⭐ SOURCE CODE — build mw4\Code\MechWarrior4.dsw in VC6
│  │  ├─ CoreTech\                 Reusable engine layer: GameOS, MLR renderer, gosFX,
│  │  │                            GOSScript, Stuff, Network, blade + engine tools
│  │  ├─ mw4\Code\                 The game itself: MW4 lib (AI, mechlab, HUD, shell),
│  │  │                            MW4Application (→MW4.exe), MW4GameEd2 (mission editor),
│  │  │                            scriptstrings/MissionLang (string DLLs), dedicated UI
│  │  ├─ mw4\Libraries\            mw4-local libs: Adept, stlport (build first), MLR,
│  │  │                            Compost, ImageLib, gosfx, server, stuff …
│  │  ├─ mw4\Binaries\             3DS Max export plug-ins (mech/prop .erf pipeline)
│  │  └─ rel.bin\ pro.bin\         Build OUTPUT: Release (MW4.exe, MW4pro.exe) / Profile
│  │     arm.bin\ dbg.bin\         (editor MW4Ed2.exe) / Armor / Debug — regenerable
│  └─ mw4\                         ⭐ GAME DATA source tree (editor also runs here in place
│     │                            via run-editor.bat; tool exes MapCreator/Tctd/NFOEditor…)
│     ├─ Content\                  All content sources: Mechs\, Maps\, Missions\, Skies\,
│     │                            Weapons\, WeaponSubsystems\, Subsystems\, Buildings\,
│     │                            Vehicles\, Effects\, textures\, Campaigns\, Tables\,
│     │                            Defines\, ABLScripts\ (mission/AI language),
│     │                            ShellScripts\ (menu/mechlab UI), *.build manifests
│     ├─ Resource\                 Packed .mw4 packages (output of `MW4pro -build`) +
│     │                            Missions\*.nfo (MP registration) + UserMissions\
│     ├─ hsh\                      Loose 2D art loaded at runtime: mech portraits, MFD
│     │                            target images, HUD/radar bitmaps, decals, fonts
│     ├─ Assets\ Stats\            Runtime support data (cursors, world stats)
│     └─ Movies\ fonts\ Notes\     Cinematics / font sources / dev notes (not deployed)
├─ build-env\                      ⭐ TOOLCHAIN — self-contained VC6 (VisualStudio6\),
│  │                               DX 7.0a + DX Media 6 SDKs, stlnative\ headers,
│  │                               ddrawcompat\ (editor viewport fix), .reg env files,
│  │                               build/deploy scripts (see below), build logs
├─ MW4\                            Runnable game deploy (output of deploy-mw4.ps1) —
│                                  regenerable; copy this to production
├─ BTFrstrm\                       FireStorm design data: MechInfo_5.04.xls (stat source
│                                  of truth), scriptaddmech.xls (add-mech row generator)
├─ Finished HUDS from J&J\         Per-mech HUD source art (MFD + Radar) awaiting
│                                  integration, ~13 chassis
├─ _UNUSED\                        Archived clutter — nothing read by the build (EXCEPT
│                                  worth knowing: Gameleap\EditorDocs\ = original map/
│                                  terrain/NFO/ABL tutorials)
├─ CLAUDE.md                       Full build/runtime reconstruction notes (the history)
├─ README.md                       This file — orientation + fresh-machine restore
├─ RECOVERY.md                     Disaster-recovery notes
├─ ADDING-A-MECH.md                Workflow: add a new 'Mech chassis
└─ ADDING-A-MAP.md                 Workflow: add a new map/mission

The folders that matter (build inputs)

Folder Role Notes
Gameleap\code\ Source code + compiled binaries C++ engine/game source (mw4\Code, CoreTech, mw4\Libraries). Build mw4\Code\MechWarrior4.dsw in VC6. Outputs land in rel.bin\ (Release MW4.exe, MW4pro.exe), pro.bin\ (editor MW4Ed2.exe), arm.bin\/dbg.bin\.
Gameleap\mw4\ Game data source The content tree the resource packer reads (Content\, and the generated resource\*.mw4, plus hsh\, Assets\, Stats\, runtime DLLs). This is the live data set — not GameleapCode5_03\Content (that was an old 2005 duplicate, now in _UNUSED).
build-env\ Toolchain + scripts Self-contained VC6 (VisualStudio6\), DirectX 7.0a + DX Media 6 SDKs, stlnative\, the .reg env files, and the deploy scripts.

Build / deploy scripts (in build-env\)

  • deploy-mw4.ps1 — packs resources from source (build-resources.ps1) then assembles the runnable game into c:\VWE\firestorm\MW4. Trims dev bloat, ships only the canonical game packages, optimizes mech BMPs to 256-color, applies the DirectDraw compat shim.
  • build-resources.ps1 — (re)packs resource\*.mw4 from Gameleap\mw4\Content using the in-exe compiler (MW4pro.exe -build). Called by the deploy; can be run standalone.
  • deploy-editor.ps1 — installs the mission editor in place into Gameleap\mw4 (the data tree it edits): drops MW4Ed2.exe + DDrawCompat there, neutralizes the DDraw-breaking DLLs, sets the shim, writes run-editor.bat. No separate editor directory. (build-resources.ps1 moves DDrawCompat aside while the builder runs, since it's fatal to MW4pro.exe.)
  • RESOURCE-BUILD.md — how the .mw4 packaging works.

Outputs (regenerable — safe to delete and rebuild)

  • MW4\ — runnable game deploy (from deploy-mw4.ps1). Move/copy this to production.
  • The editor has no separate output dir — it runs in place from Gameleap\mw4 via Gameleap\mw4\run-editor.bat (installed by deploy-editor.ps1).

Design / reference (not build inputs)

  • BTFrstrm\ — FireStorm design data: mech stat workbooks (MechInfo_*.xls, etc.).
  • Finished HUDS from J&J\ — per-mech HUD source art (MFD + Radar).

_UNUSED\ — archived clutter (nothing here is read by the build)

Moved here to reduce confusion. Safe to delete once you're comfortable. Contents:

  • Gameleap\{Archive, Drivers, EditorDocs, Notes, batch, utilities} — historical / original-machine utility data (the build only ever used Gameleap\mw4).
  • GameleapCode5_03\{Content, hsh} — stale 2005 duplicate data trees (superseded by Gameleap\mw4).
  • resource_fullbak\ — a one-off backup of the dev resource\ set taken during the from-scratch rebuild; redundant now that the dev tree is rebuilt.

TL;DR build flow

  1. Compile code: VC6 build Gameleap\code\mw4\Code\MechWarrior4.dswrel.bin\ / pro.bin\.
  2. Deploy game: build-env\deploy-mw4.ps1MW4\ (packs resources, assembles, optimizes).
  3. (Optional) Install editor: build-env\deploy-editor.ps1 → runs in place from Gameleap\mw4 (run-editor.bat).

On a fresh Windows machine

  1. Install Git for Windows (includes Git LFS) — or Git + git-lfs separately.
  2. Enable long paths before cloning (this tree has deep VC98/MFC paths > 260 chars):
    git config --global core.longpaths true
    git config --global core.autocrlf false
    git lfs install
    
    (Also enable the OS setting: HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled = 1.)
  3. Clone to the same location so the absolute paths baked into the toolchain config resolve:
    git clone https://gitea.mysticmachines.com/VWE/firestorm.git C:\VWE\firestorm
    
    git clone pulls LFS objects automatically. If any are missing: cd C:\VWE\firestorm && git lfs pull.

After restore — make it buildable / runnable

  • Build toolchain (VC6): import the registry config (ELEVATED), per build-env\README.md:
    reg import C:\VWE\firestorm\build-env\vc6-hklm-registration.reg
    reg import C:\VWE\firestorm\build-env\vc6-directories.reg
    
    Then build Gameleap\code\mw4\Code\MechWarrior4.dsw (see CLAUDE.md STEP 1/3), or just use the already-mirrored Gameleap\code\rel.bin / pro.bin binaries.
  • Run the game: build-env\deploy-mw4.ps1 reassembles C:\VWE\firestorm\MW4 and applies the Win11 DirectDraw compat shim; or run the already-mirrored C:\VWE\firestorm\MW4\MW4.exe after re-applying the shim (AppCompat is keyed on exe path, so a new machine needs it re-set — the deploy script does this).
  • Editor: Gameleap\mw4\run-editor.bat (installed in place; see CLAUDE.md STEP 9).

Notes

  • core.autocrlf=false — line endings are preserved byte-for-byte; keep it that way.
  • The mirror includes machine-specific bits (registry exports, deploy AppCompat). They restore the files, but registry/AppCompat state must be re-imported on the new machine (steps above).
  • See CLAUDE.md for the full build/runtime reconstruction history and README.md for the layout.
S
Description
No description provided
Readme
9.5 GiB
Languages
C 48.8%
C++ 36.9%
Rich Text Format 12.2%
HTML 0.6%
Visual Basic 6.0 0.5%
Other 0.5%