The 'mysterious flag pair' gating every master-only registration was never BT-specific state waiting on unreconstructed stream builders. It is the Entity base itself: InstanceBits=2 puts the instance field at mask 0xC (ReplicantInstance=4), DynamicBit=8 makes DynamicFlag 0x100 -- so the binary's (flags & 0xC)==0 && (flags & 0x100)!=0 reads 'a master-instance dynamic entity', spelled MasterInstance + DynamicFlag in the 1995 headers. Mover::DefaultFlags = DynamicFlag|MasterInstance, ENTITY.CPP:978 seeds simulationFlags from the MakeMessage's instanceFlags, and our spawn recipe has passed Mech::DefaultFlags since the boot ladder -- the authentic gate was live all along. The BT411 donor's 'MasterHeatSinkFlag' name was a fabrication that made an engine constant look like a missing subsystem feature (donor drift #12). Eleven sites flip from the GetInstance() mirror to the binary pair: the heat-family registrations (x4), powersub (x3), gyro, hud, myomers, emitter, and the Torso ctor's master/copy selection (@004b6b0c verbatim, isDamagedCopy set in both branches). The MECHWEAP score-post and MECH view gates are different families and stay as they are. Statically proven (DefaultFlags carries both bits) and mission-soaked clean. No [T2] divergence markers remain in the tree. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
181 lines
4.8 KiB
C++
181 lines
4.8 KiB
C++
//===========================================================================//
|
|
// File: hud.cpp //
|
|
// Project: BattleTech Brick: Mech subsystems //
|
|
// Contents: HUD -- head-up display / targeting reticle //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
|
|
// All Rights reserved worldwide //
|
|
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#include <bt.hpp>
|
|
#pragma hdrstop
|
|
|
|
#if !defined(HUD_HPP)
|
|
# include <hud.hpp>
|
|
#endif
|
|
|
|
#if !defined(MECH_HPP)
|
|
# include <mech.hpp>
|
|
#endif
|
|
|
|
static const Point3D HudZeroVector(0.0f, 0.0f, 0.0f);
|
|
|
|
Derivation
|
|
HUD::ClassDerivations(
|
|
PowerWatcher::ClassDerivations,
|
|
"HUD"
|
|
);
|
|
|
|
HUD::SharedData
|
|
HUD::DefaultData(
|
|
HUD::ClassDerivations,
|
|
Subsystem::MessageHandlers,
|
|
Subsystem::AttributeIndex,
|
|
Subsystem::StateCount
|
|
);
|
|
|
|
HUD::HUD(
|
|
Mech *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource,
|
|
SharedData &shared_data
|
|
):
|
|
PowerWatcher(owner, subsystem_ID, subsystem_resource, shared_data)
|
|
{
|
|
Check(owner);
|
|
Check_Pointer(subsystem_resource);
|
|
|
|
flickerRate = 0.0f;
|
|
rotationOfTorsoHorizontal = 0.0f;
|
|
torsoLimitRight = 0.0f;
|
|
torsoLimitLeft = 0.0f;
|
|
torsoSpeed = 0.0f;
|
|
rangeToTarget = 0.0f;
|
|
scratch1F0 = 0;
|
|
visible = True;
|
|
lockFlag = False;
|
|
hotBoxVector = HudZeroVector;
|
|
threatVector = HudZeroVector;
|
|
compassHeading = 0.0f;
|
|
blinkTimer = 0.0f;
|
|
flickerTimer = 0.0f;
|
|
blinkState = True;
|
|
transitionFlag = False;
|
|
previousHorizontal = 0.0f;
|
|
|
|
statusAlarm.Initialize(2);
|
|
|
|
freeAimSlew = 0.0f;
|
|
scratch290 = 0.0f;
|
|
horizontalTorsoOffset = 0.0f;
|
|
|
|
flickerRate = subsystem_resource->flickerRate;
|
|
horizontalMovementPerSecond = subsystem_resource->horizontalMovementPerSecond;
|
|
horizontalLimit = subsystem_resource->horizontalLimit;
|
|
|
|
//
|
|
// The torso-orientation source is a Mech link not yet live at
|
|
// construction time; HudSimulation refreshes these per-frame.
|
|
//
|
|
linkedEntity = 0;
|
|
flickerActive = 0;
|
|
|
|
//
|
|
// The master instance runs the HUD per-frame.
|
|
//
|
|
// The binary's master gate: MasterInstance + DynamicFlag -- the
|
|
// simulationFlags 0xC/0x100 pair, now decoded as engine enum identities
|
|
// (InstanceBits=2 makes InstanceMask 0xC; DynamicBit=8 makes DynamicFlag
|
|
// 0x100; Entity::DefaultFlags carries both, seeded from the MakeMessage).
|
|
if (
|
|
(owner->simulationFlags & Entity::InstanceMask) == Entity::MasterInstance &&
|
|
(owner->simulationFlags & Entity::DynamicFlag) != 0
|
|
)
|
|
{
|
|
SetPerformance(&HUD::HudSimulation);
|
|
}
|
|
|
|
Check_Fpu();
|
|
}
|
|
|
|
HUD::~HUD()
|
|
{
|
|
}
|
|
|
|
Logical
|
|
HUD::TestClass(Mech &)
|
|
{
|
|
return True;
|
|
}
|
|
|
|
Logical
|
|
HUD::TestInstance() const
|
|
{
|
|
return IsDerivedFrom(ClassDerivations);
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
// @004b7830 -- the per-frame HUD, PARTIAL: the base tick, the heat/voltage
|
|
// page gating and the blink are reconstructed (the donor's confident half);
|
|
// the reticle / target-lock / torso-horizon math (its blocks 4-6) survives
|
|
// only as summarised offsets in the recovered shard and stays STAGED --
|
|
// the page visibility is the cockpit-bound behaviour, and it is real.
|
|
//
|
|
// The blink comparison is >= (the decomp shard's literal != would toggle
|
|
// every tick through float inequality; the shard's own banner describes
|
|
// "compared against flickerRate; on expiry ... toggles").
|
|
//#############################################################################
|
|
//
|
|
void
|
|
HUD::HudSimulation(Scalar time_slice)
|
|
{
|
|
Check(this);
|
|
|
|
PowerWatcher::Simulation(time_slice);
|
|
|
|
//
|
|
// Page gating off our own mirrored alarms (the watchers, 5.3.109):
|
|
// a heat failure or an unpowered watched subsystem hides the page.
|
|
//
|
|
Logical
|
|
page_visible = True;
|
|
|
|
if (watchdogAlarm.GetLevel() != PoweredSubsystem::Ready)
|
|
{
|
|
page_visible = False;
|
|
}
|
|
if (heatAlarm.GetLevel() == HeatSink::FailureHeat)
|
|
{
|
|
page_visible = False;
|
|
}
|
|
|
|
//
|
|
// The blink.
|
|
//
|
|
if (transitionFlag == 0)
|
|
{
|
|
blinkTimer += time_slice;
|
|
if (blinkTimer >= flickerRate)
|
|
{
|
|
blinkTimer = 0.0f;
|
|
blinkState = (blinkState == 0);
|
|
}
|
|
}
|
|
else if (transitionFlag == 1)
|
|
{
|
|
blinkState = True;
|
|
}
|
|
|
|
visible = (page_visible && blinkState) ? 1 : 0;
|
|
|
|
//
|
|
// STAGED (donor blocks 4-6): engine/start flag mirror, target lock +
|
|
// sliding range + compass, and the torso-horizon slew -- summarised
|
|
// offsets only in the recovered shard (part_013.c @004b7830).
|
|
//
|
|
|
|
Check_Fpu();
|
|
}
|