Files
TeslaRel410/emulator/render-bridge/launch_live.ps1
T
CydandClaude Opus 4.8 b447e71864 launch_live.ps1: enlarge exploded cockpit windows +25% (0.75 scale)
Per user request, bumped the cockpit MFD/radar windows from 0.6 to 0.75 of
native 640x480 (MFD 384->480, radar 288->360 logical). Live-verified on the
secondary: MFDs now render 331x266 (was 267x218, ~+24% after the primary's DPI
downscale), radar 251x346, all six still fit the 1707x1067 secondary with
margin, renderer unchanged on the primary. No wire stall.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 11:37:43 -05:00

127 lines
7.1 KiB
PowerShell

# Turnkey LIVE bring-up: DOSBox-X pod (real vpxlog C012 device) teeing the wire
# on VPX_FIFOSOCK, with the RECONSTRUCTED renderer (live_render.py) riding it --
# no pentapus, no bridge, one window. The renderer is the emulated i860 firmware
# + GPU raster (emu860c), proven bit-identical to the offline reference.
#
# .\launch_live.ps1 # gauge_arena.conf, sound off, port 8621
# .\launch_live.ps1 -Conf <path> -Port N # pick mission / port
# .\launch_live.ps1 -Sound # enable AWE32 (adds ~4min SBK upload)
# .\launch_live.ps1 -PodOnly # start the pod only (connect renderer yourself)
#
# The reconstructed renderer connects as the SINGLE VPX_FIFOSOCK client (so this
# does NOT also launch Dave's live_bridge -- they cannot share the socket).
param(
[string]$Conf = "$PSScriptRoot\gauge_arena.conf",
[int]$Port = 8621,
[string]$Work = "$env:LOCALAPPDATA\Temp\vwe-live",
[switch]$Sound,
[switch]$PodOnly,
[switch]$Present, # live_render window (pygame)
[string]$Pin, # pre-load the full texture set from this
# .fifodump (bit-identical to offline;
# avoids grey/incomplete early textures
# while the live mission is still
# uploading them incrementally)
[switch]$Explode # pentapus cockpit instruments (radar +
# 5 mono MFDs, VDB decode) on the
# SECONDARY display; our 3D renderer
# stays the main view on the primary.
# NOTE: needs VPX_RENDER=1 (the cockpit
# windows live in the same thread as
# Dave's native render) -> re-adds the
# DOSBox-thread scene-graph decode that
# previously stalled wire delivery;
# measured below, revert if it bites.
)
$ErrorActionPreference = 'Stop'
New-Item -ItemType Directory -Force $Work | Out-Null
# --- exploded cockpit layout on the SECONDARY display -----------------------
# The pentapus's default layout is ~1980px wide; auto-fit it onto whatever the
# non-primary screen is (detected here, so it survives a monitor rearrange).
function Get-ExplodeEnv {
Add-Type -AssemblyName System.Windows.Forms
$screens = [System.Windows.Forms.Screen]::AllScreens
$sec = $screens | Where-Object { -not $_.Primary } | Select-Object -First 1
if (-not $sec) { $sec = $screens[0] } # single-monitor fallback
$b = $sec.Bounds
Write-Host ("exploded view -> secondary '{0}' {1}x{2} @ ({3},{4})" -f `
$sec.DeviceName, $b.Width, $b.Height, $b.X, $b.Y)
# local layout then offset onto the secondary; radar is portrait.
# g: 0=radar 5=LL 6=LR 7=UR 8=UC 9=UL (7/9 swapped per the pod). Sizes are
# requested logical px; Windows DPI-scaling on a HiDPI primary renders them
# ~0.7x on screen, so these run large to land right (user asked +25% over
# the first 0.6-scale pass -> 0.75 of native 640x480).
$m = 480; $n = 360 # MFD w,h (0.75 scale of 640x480)
$rw = 360; $rh = 480 # radar w,h (portrait)
$x0 = $b.X + 20; $y0 = $b.Y + 20
$col = @($x0, ($x0 + $m + 16), ($x0 + 2*($m + 16))) # 3 columns
$rowU = $y0; $rowL = $y0 + $n + 16
$rect = { param($x,$y,$w,$h) "$x,$y,$w,$h" }
$e = @{}
$e['VPX_WIN9'] = & $rect $col[0] $rowU $m $n # upper-left
$e['VPX_WIN8'] = & $rect $col[1] $rowU $m $n # upper-center
$e['VPX_WIN7'] = & $rect $col[2] $rowU $m $n # upper-right
$e['VPX_WIN5'] = & $rect $col[0] $rowL $m $n # lower-left
$e['VPX_WIN0'] = & $rect ($col[1] + [int](($m-$rw)/2)) ($rowL - 20) $rw $rh # radar center
$e['VPX_WIN6'] = & $rect $col[2] $rowL $m $n # lower-right
# park the DOSBox SVGA screen at the bottom-right of the secondary, clear
# of the cockpit cluster (it parks centered under this VPX_MAIN slot).
$e['VPX_MAIN'] = & $rect ($b.X + $b.Width - 360) ($b.Y + $b.Height - 520) 320 8
return $e
}
# stop a previous pod (the fifodump + socket are exclusive)
$pidfile = "$Work\pod_pid.txt"
if (Test-Path $pidfile) {
$old = Get-Process -Id (Get-Content $pidfile) -ErrorAction SilentlyContinue
if ($old) { Write-Host "stopping previous pod ($($old.Id))"; $old | Stop-Process -Force }
}
Remove-Item "$Work\live.fifodump", "$Work\pod_out.txt", "$Work\pod_err.txt" -ErrorAction SilentlyContinue
# --- the vpxlog C012 device env (host-side) ---
$env:VPXLOG = "$Work\vpxresp.txt"
$env:VPX_RESPOND = '1' # answer as the transputer would
$env:VPX_NOMAIN = '1' # no native Division window
$env:VPX_CLEAR = '0,0,0'
$env:VPX_FIFODUMP = "$Work\live.fifodump" # archival copy alongside the socket
$env:VPX_FIFOSOCK = "$Port" # the live tee our renderer rides
# By default VPX_RENDER/VPX_EXPLODE are OFF: VPX_RENDER starts rt_main inside
# dosbox-x, whose DOSBox-thread scene-graph decode contends with (and stalls)
# our FIFOSOCK-fed renderer. -Explode opts back in to get the cockpit VDB
# windows (radar + MFDs), which live in that same thread -- accepting the
# tradeoff, and positioning those windows on the secondary display.
Remove-Item Env:VPX_RENDER, Env:VPX_EXPLODE -ErrorAction SilentlyContinue
foreach ($v in 'VPX_MAIN','VPX_WIN0','VPX_WIN5','VPX_WIN6','VPX_WIN7','VPX_WIN8','VPX_WIN9') {
Remove-Item "Env:$v" -ErrorAction SilentlyContinue
}
if ($Explode) {
$env:VPX_EXPLODE = '1'
$env:VPX_RENDER = '1' # required: cockpit windows are in rt_main
(Get-ExplodeEnv).GetEnumerator() | ForEach-Object { Set-Item "Env:$($_.Key)" $_.Value }
}
if ($Sound) {
$env:VWE_AWE32 = '1'
$env:VWE_AWE_ROM = (Resolve-Path "$PSScriptRoot\..\roms\awe32.raw").Path
} else {
Remove-Item Env:VWE_AWE32, Env:VWE_AWE_ROM -ErrorAction SilentlyContinue
}
$dosbox = (Resolve-Path "$PSScriptRoot\..\src\src\dosbox-x.exe").Path
$p = Start-Process $dosbox -ArgumentList '-conf', $Conf `
-RedirectStandardError "$Work\pod_err.txt" `
-RedirectStandardOutput "$Work\pod_out.txt" -PassThru
$p.Id | Set-Content $pidfile
Write-Host "pod PID $($p.Id) conf=$([IO.Path]::GetFileName($Conf)) fifosock=:$Port work=$Work"
if ($Sound) { Write-Host "sound ON: boot adds ~4 min for the SoundFont upload" }
if (-not $PodOnly) {
$rl = Join-Path (Resolve-Path "$PSScriptRoot\..\firmware-decomp\emu860c").Path 'live_render.py'
$rendererArgs = @("`"$rl`"", "sock:$Port")
if ($Present) { $rendererArgs += '--present' }
if ($Pin) { $rendererArgs += '--pin'; $rendererArgs += "`"$(Resolve-Path $Pin)`"" }
Write-Host "connecting reconstructed renderer: python $rl sock:$Port"
Start-Sleep -Milliseconds 800 # let the device open the listener
& python @rendererArgs
}