Files
BT411/game/reconstructed/btl4mppr.hpp
T
Joe DiPrimaandClaude Fable 5 611b1a8bbd #118: the PANIC BUTTON ejects -- keypad-bank routing + the 0x17/0x19 id bug
Two finds close the press path the operator field-tested:

1. The pod's guarded PANIC key reports through the PILOT KEYPAD bank -- the
   binary's ONLY panic press binding is keyboardGroup[KeyboardPilot].Add(
   mode 0x200000, mech, 0x19) (FUN_004d266c); there is NO buttonGroup[0x3d]
   consumer (0x3d is the lamp address). The desktop Panic click now ALSO
   lands as a pilot-keypad key (PadRIO::EmitButton -> EmitKeypad), so the
   armed-mode binding fires; a healthy press stays a mode-masked no-op,
   exactly the pod behaviour.

2. KeypressMessageID resolved to 0x17 via enum-chain arithmetic; the binary
   passes LITERAL 0x19 (two mapper ids are unreconstructed). The armed
   keypad send arrived at the Mech as msg 0x17 -- no handler, silently
   swallowed. Pinned to 0x19 (Mech::EjectPilot's id on the OWNER receiver --
   the collision is the design).

Verified headless through the REAL click seam (BT_BTNTEST=61): generators
killed -> panic-arm ON -> screen-click Panic -> [lbe4key] unit 0 mode
0x650421 -> PUNCH-OUT. Also: IsDisabled eject refusals now log; [padkey]/
[lbe4key] seam tracing under BT_PAD_LOG.

Still open (cosmetic): the flashing eject slot on the engineering MFD shows
no graphic -- the streamed page element's pixmap is unreconstructed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-03 17:31:16 -05:00

410 lines
17 KiB
C++

//===========================================================================//
// File: btl4mppr.hpp //
// Project: BattleTech Brick: BattleTech LBE Application //
// Contents: The L4-application-side Mech controls mappers -- the platform //
// (cockpit-hardware) layer that wires physical Thrustmaster / RIO //
// panel inputs onto the in-Mech MechControlsMapper demands, the //
// target-range zoom, control/display modes and the pilot hotbox. //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
//
// RECONSTRUCTED -- no header survived for this TU. BTL4.MAK lists btl4mppr.obj
// and the class names are recovered from the .rdata string pool
// ("L4MechControlsMapper" @0051e1eb, "MechThrustmasterMapper" @0051e2b3,
// "MechRIOMapper" @0051e2e3). The shape mirrors the surviving Red Planet
// analog RP_L4\RPL4MPPR.h (L4VTVControlsMapper / VTVThrustmasterMapper /
// VTVRIOMapper) -- the only substitution is Mech for VTV and the in-Mech base
// MechControlsMapper (mechmppr.cpp) for VTVControlsMapper.
//
// Hierarchy (parallels RP exactly):
// Subsystem -> MechControlsMapper [mechmppr.cpp, already recovered]
// -> L4MechControlsMapper [this TU] ctor @004d17ac vtable @0051e440
// ├─ MechThrustmasterMapper ctor @004d21d0 vtable @0051e3f0
// └─ MechRIOMapper ctor @004d266c vtable @0051e3a0
//
#if !defined(BTL4MPPR_HPP)
# define BTL4MPPR_HPP
# if !defined(MECHMPPR_HPP)
# include <mechmppr.hpp>
# endif
class Mech;
class L4Lamp;
//
// ClassID stamped onto the in-Mech controls-mapper subsystem (the
// class_ID passed to the L4MechControlsMapper ctor). Recovered as 0x7dc
// (@004d21d0 / @004d266c call sites in btl4app.cpp).
//
enum { MechControlsMapperClassID = 0x7dc };
//##########################################################################
//#################### L4MechControlsMapper ##########################
//##########################################################################
//
// The platform-independent L4 layer. Adds the target-range "zoom"
// (exponential, driven from the panel), the mission-review mode watcher,
// and the configuration-time temporary event mappings. Pure-platform
// behaviour (which physical buttons do what) is supplied by the two
// derived mappers below.
//
class L4MechControlsMapper:
public MechControlsMapper
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Shared Data Support
//
public:
// WinTesla refactored the static derivation/handler objects behind
// Get* accessors (avoids static-init ordering bugs).
static Derivation *GetClassDerivations();
static SharedData DefaultData;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Messaging Support
//
public:
enum {
// PINNED to the binary literals (FUN_004d266c passes 0x19/0x1a
// straight into the group Adds; corrected 2026-08-03). The chain
// arithmetic (MechControlsMapper::NextMessageID) lands on 0x17 --
// TWO mapper ids between 0x16 ToggleVoiceAssist and 0x19 are
// unreconstructed -- and the mis-numbered Keypress send was
// SILENTLY swallowed by the Mech (no 0x17 handler), which is why
// the armed pilot-keypad press never ejected. Mech::EjectPilot is
// id 0x19 on the MECH's receiver: the panic-mode keypad binding
// sends THIS id to the OWNER, and the collision is the design.
KeypressMessageID = 0x19,
StringMatchMessageID, // 0x1a (unregistered; stringManager route)
NextMessageID
};
void
KeypressMessageHandler( // @004d1bf0
ReceiverDataMessageOf<ControlsKey> *message
);
protected:
static const HandlerEntry MessageHandlerEntries[];
static MessageHandlerSet& GetMessageHandlers();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Model Support
//
public:
void
InterpretControls(Scalar time_slice); // @004d196c
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Target-range "zoom"
//
public:
void
ZoomTargetRangeIn(), // @004d1b64
ZoomTargetRangeOut(); // @004d1b9c
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Control / display modes (Gitea #6 relabel -- the vtable pins the slots).
//
// The binary's L4 vtable @0051e440 (section_dump): +0x48 = @004d1acc,
// +0x4C = @004d1ae4. CycleControlModeMessageHandler (FUN_004afbe0)
// dispatches vtbl+0x48 with the new controlMode; CycleDisplayModeMessage-
// Handler (FUN_004afcac) dispatches vtbl+0x4C with the new displayMode.
// So @004d1ae4 -- the {0x40000,0x80000,0x100000} secondary-view mask swap
// the old reconstruction called "SetControlMode" (never called by anyone)
// -- is the NotifyOfDisplayModeChange OVERRIDE: the secondary screen's
// Damage / Critical / Heat schematic is selected by the DISPLAY mode
// (manual p13: the "'Mech status Info center", bottom left of the
// secondary screen), NOT by the BAS/MID/ADV control mode (manual p6: top
// right of the secondary screen). @004d1acc (NotifyOfControlModeChange)
// just forwards to the base no-op @004b048c -- a control-mode change
// never touches the secondary view.
//
public:
virtual void
NotifyOfControlModeChange(int new_mode); // @004d1acc (+0x48, chains base no-op)
virtual void
NotifyOfDisplayModeChange(int new_mode); // @004d1ae4 (+0x4C, secondary-view mask swap)
void
SetPresetMode(int group, int item); // @004d1b24 (preset mode-mask)
void
CyclePresetModeNow(int group); // PORT (Gitea #9): desktop J/K/L
// per-MFD page cycle; visits Quad +
// the POPULATED Eng pages only (the
// reachable set of the pod's streamed
// page buttons); body = SetPresetMode
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Configuration support (overrides the MechControlsMapper traps; task #6
// slot truth: @004d1840/+0x38 Enter, @004d18dc/+0x3C Exit, and the two
// RET-stub AddOrErase no-ops @004d195c/+0x40 / @004d1964/+0x44 that the
// old reconstruction mislabeled "NotifyOfControlModeChange /
// NotifyOfConfigurationModeChange". Only MechRIOMapper overrides the
// AddOrErase pair with real bodies -- a Thrustmaster cockpit cannot
// regroup. (The REAL NotifyOf* L4 overrides @004d1acc/@004d1ae4,
// vtable +0x48/+0x4C, are declared in the mode section above.)
//
public:
virtual void
EnterConfiguration( // @004d1840 (+0x38)
int held_element,
ControlsButton *destination,
Receiver *receiver,
Receiver::MessageID choose_message_id,
Receiver::MessageID configure_message_id,
Receiver::MessageID active_message_id
);
virtual void
ExitConfiguration(int held_element); // @004d18dc (+0x3C)
virtual void
AddOrErase( // @004d195c (+0x40, ret-stub no-op)
unsigned int button_ID,
Receiver *receiver,
Receiver::MessageID message_ID
);
virtual void
AddOrErase( // @004d1964 (+0x44, ret-stub no-op)
unsigned int button_ID,
ControlsButton *destination
);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction and Destruction Support
//
public:
L4MechControlsMapper( // @004d17ac
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
ClassID class_ID,
SharedData &shared_data = DefaultData
);
~L4MechControlsMapper(); // @004d1814
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Attribute Support (AUDIO_FIDELITY.md F20): the authored zoom-blip
// AudioScalarDeltaTrigger binds ControlsMapper/TargetRangeExponent -- the
// live @0x1a4 member that slews every frame. Chained to the parent index;
// Thrustmaster/RIO inherit this accessor.
//
public:
enum {
TargetRangeExponentAttributeID = MechControlsMapper::NextAttributeID,
L4NextAttributeID
};
static const IndexEntry AttributePointers[];
static AttributeIndexSet& GetAttributeIndex();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Protected data (object grows to >= 0x1bc)
//
protected:
Scalar
targetRangeExponentDemand, // @0x1a0 panel "zoom" demand (init 2.0, range 0..5)
targetRangeExponent; // @0x1a4 smoothed value -> mech target range (2^x)
int
previousEjectPermitted; // @0x1a8 last-seen mech ejectPermitted (@0x414) --
// the panic-arm edge detector (was mislabeled
// "mission-review flag"; corrected 2026-08-03)
//
// Per-platform input staging slots (filled by the derived ctor's
// controls-group .Add()s; the two platforms use them differently --
// Thrustmaster routes throttle scalars here, the RIO routes panel
// buttons here). Cleared to 0 by both derived ctors.
//
ControlsScalar
throttleForward; // @0x1ac
// NOTE (engine drift): the recovered code staged the reverse throttle in
// a ControlsScalar mapped to a "ScalarThrottleReverse" group that does
// NOT exist in the WinTesla LBE4ControlsManager. Reverse is a button in
// this engine generation, so this slot is a ControlsButton mapped to
// LBE4ControlsManager::ButtonThrottle1 (mirrors the era's L4MPPR.CPP).
ControlsButton
throttleReverse; // @0x1b0
ControlsScalar
leftPedal, // @0x1b4
rightPedal; // @0x1b8
};
//##########################################################################
//#################### MechThrustmasterMapper ########################
//##########################################################################
//
// Joystick + throttle + pedals "Thrustmaster" cockpit. Maps the analog
// throttle / pedal axes and the PC keyboard onto the Mech demands.
//
class MechThrustmasterMapper:
public L4MechControlsMapper
{
public:
static Derivation *GetClassDerivations(); // @0051dc78
static SharedData DefaultData; // @0051dcxx
typedef void
(MechThrustmasterMapper::*Performance)(Scalar time_slice);
void
InterpretControls(Scalar time_slice); // @004d2150
void
SetPerformance(Performance performance)
{
Check(this);
activePerformance = (Simulation::Performance)performance;
}
protected:
static const HandlerEntry MessageHandlerEntries[]; // {Keypress, 0x17}
static MessageHandlerSet MessageHandlers;
public:
MechThrustmasterMapper( // @004d21d0
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
ClassID class_ID,
SharedData &shared_data = DefaultData
);
~MechThrustmasterMapper(); // @004d22b4
Logical
TestInstance() const; // @004d22e0
};
//##########################################################################
//########################### MechRIOMapper ##########################
//##########################################################################
//
// The full "RIO" / Cockpit panel: aux-equipment quadrant buttons, target
// hotbox, target-range zoom, control-mode and preset selection.
//
class MechRIOMapper:
public L4MechControlsMapper
{
public:
static Derivation *GetClassDerivations(); // @0051dd00
static SharedData DefaultData; // @0051dcxx
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Messaging Support
//
public:
//
// GLASS INPUT-AUDIT FIX (2026-07-20): these ids are PINNED to the
// binary numbering. The old chain started at
// L4MechControlsMapper::NextMessageID (=0x19), which registered every
// RIO handler at 0x19..0x2a -- but the streamed "L4" .CTL EventMapping
// records carry the BINARY's ids, and the binary RIO table @0051dd30
// (section_dump) RE-REGISTERS the MechControlsMapper aux/zoom ids
// 3..0x13 with the RIO override handlers (that is the whole point of
// the derived table: same message, real body instead of the base FAIL
// trap). With the shifted ids every streamed MFD-bank/zoom button
// press found only the base ConfigureMappableMessageHandler ("[FAIL]
// Unhandled button mapping") -- ~38 of the 72 pod panel buttons dead
// (and, on a real pod with BT_BUTTON_TRAP, an abort()). Hotbox is
// 0x1a in the binary (table entry @0051de98); the ctor/handler pair
// was previously self-consistent at the wrong value (0x2a), so it
// worked by accident -- now it matches the binary.
// (Faithful-fidelity note: the binary RIO table also carries its OWN
// Keypress id: FIXED 2026-08-03 -- KeypressMessageID is now pinned to
// the binary's 0x19 (the old chain arithmetic landed on 0x17, and the
// panic-mode pilot-keypad send was silently swallowed by the Mech --
// no 0x17 handler -- so the armed eject press never fired). Remaining
// refinement: the ctor registers the shared L4 Keypress BODY
// (@004d1bf0); the RIO-specific body is @004d2514.)
//
enum {
Aux1QuadMessageID = MechControlsMapper::Aux1QuadMessageID, // 3
Aux1Eng1MessageID, Aux1Eng2MessageID, Aux1Eng3MessageID, Aux1Eng4MessageID,
Aux2QuadMessageID, Aux2Eng1MessageID, Aux2Eng2MessageID, Aux2Eng3MessageID, Aux2Eng4MessageID,
Aux3QuadMessageID, Aux3Eng1MessageID, Aux3Eng2MessageID, Aux3Eng3MessageID, Aux3Eng4MessageID,
ZoomInMessageID, // 0x12
ZoomOutMessageID, // 0x13
HotboxMessageID = 0x1a, // pilot-target select (@0051de98)
NextMessageID
};
static_assert(Aux1QuadMessageID == 0x03, "RIO Aux1Quad must be the binary id 3 (table @0051dd30)");
static_assert(Aux3Eng4MessageID == 0x11, "RIO Aux3Eng4 must be the binary id 0x11");
static_assert(ZoomInMessageID == 0x12 && ZoomOutMessageID == 0x13,
"RIO ZoomIn/ZoomOut must be the binary ids 0x12/0x13");
static_assert(HotboxMessageID == 0x1a, "RIO Hotbox must be the binary id 0x1a (@0051de98)");
void
Aux1QuadMessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d22fc
Aux1Eng1MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d231c
Aux1Eng2MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d233c
Aux1Eng3MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d235c
Aux1Eng4MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d237c
Aux2QuadMessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d239c
Aux2Eng1MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d23bc
Aux2Eng2MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d23dc
Aux2Eng3MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d23fc
Aux2Eng4MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d241c
Aux3QuadMessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d243c
Aux3Eng1MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d245c
Aux3Eng2MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d247c
Aux3Eng3MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d249c
Aux3Eng4MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d24bc
ZoomInMessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d24dc
ZoomOutMessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d24f8
HotboxMessageHandler(ReceiverDataMessageOf<ControlsButton> *message); // @004d2574
protected:
static const HandlerEntry MessageHandlerEntries[]; // @0051dd30
static MessageHandlerSet MessageHandlers;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Model Support
//
public:
typedef void
(MechRIOMapper::*Performance)(Scalar time_slice);
void
InterpretControls(Scalar time_slice); // @004d25c0
void
SetPerformance(Performance performance)
{
Check(this);
activePerformance = (Simulation::Performance)performance;
}
virtual void
AddOrErase( // @004d25e8 (+0x40 override)
unsigned int button_ID,
Receiver *target,
Receiver::MessageID message_ID
);
virtual void
AddOrErase( // @004d262c (+0x44 override)
unsigned int button_ID,
ControlsButton *destination
);
public:
MechRIOMapper( // @004d266c
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
ClassID class_ID,
SharedData &shared_data = DefaultData
);
~MechRIOMapper(); // @004d27cc
Logical
TestInstance() const; // @004d27f8
};
#endif