Clean, self-contained extraction of the BattleTech-specific work from the
reverse-engineering workspace -- engine + game + content + build, with nothing
from Red Planet or the raw archive dumps. Builds green (Win32) and runs the
single-player drive->animate->target->fire->damage->destroy loop out of the box.
Layout:
engine/ MUNGA + MUNGA_L4 shared 2007 engine, carrying our BT render/loader
work (bgfload/L4D3D/L4VIDEO: BSL bit-slice decode, LOD/ground/shadow
models) + image codec; the minimal rp/ headers the audio HAL needs
game/ reconstructed BT logic + surviving-original BT source + fwd shims
+ WinMain launcher
content/ full runtime tree (BTL4.RES, VIDEO/, GAUGE/, AUDIO/, eggs, BTDPL.INI)
docs/ format specs + reconstruction ledgers
reference/ raw Ghidra pseudocode (recon source-of-truth) + decomp exporter
tools/ MP console emulator + map/resource scanners
One top-level CMake builds munga_engine lib + bt410_l4 game lib + btl4.exe.
All paths relativized (186 fwd shims + ~437 CMake abs paths -> repo-relative);
DXSDK is the one external, overridable via -DDXSDK. Verified: builds to a
byte-identical 2.27MB exe and runs combat (TARGET DESTROYED, 0 crashes) against
the bundled content.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
245 lines
6.3 KiB
C++
245 lines
6.3 KiB
C++
#include "munga.h"
|
|
#pragma hdrstop
|
|
|
|
#include "cammppr.h"
|
|
|
|
//#############################################################################
|
|
// Shared Data Support
|
|
//
|
|
CameraControlsMapper::SharedData
|
|
CameraControlsMapper::DefaultData(
|
|
CameraControlsMapper::GetClassDerivations(),
|
|
CameraControlsMapper::GetMessageHandlers(),
|
|
CameraControlsMapper::GetAttributeIndex(),
|
|
CameraControlsMapper::StateCount
|
|
);
|
|
|
|
Derivation* CameraControlsMapper::GetClassDerivations()
|
|
{
|
|
static Derivation classDerivations(Subsystem::GetClassDerivations(), "CameraControlsMapper");
|
|
return &classDerivations;
|
|
}
|
|
|
|
//#############################################################################
|
|
// Messaging Support
|
|
//
|
|
const Receiver::HandlerEntry
|
|
CameraControlsMapper::MessageHandlerEntries[]=
|
|
{
|
|
MESSAGE_ENTRY(CameraControlsMapper, Keypress),
|
|
MESSAGE_ENTRY(CameraControlsMapper, DirectorMode),
|
|
MESSAGE_ENTRY(CameraControlsMapper, IncrementCamera),
|
|
MESSAGE_ENTRY(CameraControlsMapper, DecrementCamera),
|
|
MESSAGE_ENTRY(CameraControlsMapper, CreateCameraInstance),
|
|
MESSAGE_ENTRY(CameraControlsMapper, DeleteCameraInstance),
|
|
MESSAGE_ENTRY(CameraControlsMapper, OutputCameraInstances)
|
|
};
|
|
|
|
CameraControlsMapper::MessageHandlerSet& CameraControlsMapper::GetMessageHandlers()
|
|
{
|
|
static CameraControlsMapper::MessageHandlerSet messageHandlers(ELEMENTS(CameraControlsMapper::MessageHandlerEntries), CameraControlsMapper::MessageHandlerEntries, Subsystem::GetMessageHandlers());
|
|
return messageHandlers;
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
void
|
|
CameraControlsMapper::KeypressMessageHandler(
|
|
ReceiverDataMessageOf<ControlsKey> *message
|
|
)
|
|
{
|
|
Check(this);
|
|
Check(message);
|
|
|
|
switch (message->dataContents)
|
|
{
|
|
case 'd':
|
|
case 'D':
|
|
{
|
|
ReceiverDataMessageOf<ControlsButton>
|
|
button_message2(
|
|
CameraControlsMapper::DirectorModeMessageID,
|
|
sizeof(ReceiverDataMessageOf<ControlsButton>),
|
|
1
|
|
);
|
|
Dispatch(&button_message2);
|
|
break;
|
|
}
|
|
|
|
case 'o':
|
|
case 'O':
|
|
{
|
|
ReceiverDataMessageOf<ControlsButton>
|
|
button_message2(
|
|
CameraControlsMapper::OutputCameraInstancesMessageID,
|
|
sizeof(ReceiverDataMessageOf<ControlsButton>),
|
|
1
|
|
);
|
|
Dispatch(&button_message2);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
void
|
|
CameraControlsMapper::DirectorModeMessageHandler(
|
|
ReceiverDataMessageOf<ControlsButton> *message
|
|
)
|
|
{
|
|
if (message->dataContents > 0)
|
|
{
|
|
CameraShip *camera = GetEntity();
|
|
Check(camera);
|
|
if(camera->GetSimulationState() != CameraShip::ConfigureCamerasState)
|
|
{
|
|
camera->SetPerformance(&CameraShip::DriveCamera);
|
|
camera->SetSimulationState(CameraShip::ConfigureCamerasState);
|
|
CameraInstance *cam = camera->GetCurrentCamera();
|
|
Check(cam);
|
|
//DEBUG_STREAM << cam->GetCameraName() << std::endl << std::flush;
|
|
}
|
|
else
|
|
{
|
|
camera->SetPerformance(&CameraShip::FollowGoal);
|
|
camera->SetSimulationState(CameraShip::DefaultState);
|
|
camera->lastSwitch = Now();
|
|
}
|
|
}
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
void
|
|
CameraControlsMapper::IncrementCameraMessageHandler(
|
|
ReceiverDataMessageOf<ControlsButton> *message
|
|
)
|
|
{
|
|
if(message->dataContents > 0)
|
|
{
|
|
CameraShip *camera = GetEntity();
|
|
Check(camera);
|
|
camera->IncrementCameraInstance();
|
|
}
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
void
|
|
CameraControlsMapper::DecrementCameraMessageHandler(
|
|
ReceiverDataMessageOf<ControlsButton> *message
|
|
)
|
|
{
|
|
if (message->dataContents > 0)
|
|
{
|
|
CameraShip *camera = GetEntity();
|
|
Check(camera);
|
|
camera->DecrementCameraInstance();
|
|
}
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
void
|
|
CameraControlsMapper::CreateCameraInstanceMessageHandler(
|
|
ReceiverDataMessageOf<ControlsButton> *message
|
|
)
|
|
{
|
|
if (message->dataContents > 0)
|
|
{
|
|
CameraShip *camera = GetEntity();
|
|
Check(camera);
|
|
camera->CreateCameraInstance();
|
|
}
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
void
|
|
CameraControlsMapper::DeleteCameraInstanceMessageHandler(
|
|
ReceiverDataMessageOf<ControlsButton> *message
|
|
)
|
|
{
|
|
if (message->dataContents > 0)
|
|
{
|
|
CameraShip *camera = GetEntity();
|
|
Check(camera);
|
|
camera->DeleteCameraInstance();
|
|
}
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
void
|
|
CameraControlsMapper::OutputCameraInstancesMessageHandler(
|
|
ReceiverDataMessageOf<ControlsButton> *message
|
|
)
|
|
{
|
|
if (message->dataContents > 0)
|
|
{
|
|
CameraShip *camera = GetEntity();
|
|
Check(camera);
|
|
camera->OutputCameraList();
|
|
}
|
|
}
|
|
|
|
//#############################################################################
|
|
// Attribute Support
|
|
//
|
|
const CameraControlsMapper::IndexEntry
|
|
CameraControlsMapper::AttributePointers[]=
|
|
{
|
|
ATTRIBUTE_ENTRY(CameraControlsMapper, StickPosition, stickPosition),
|
|
ATTRIBUTE_ENTRY(CameraControlsMapper, ThrottlePosition, throttlePosition),
|
|
ATTRIBUTE_ENTRY(CameraControlsMapper, PedalsPosition, pedalsPosition),
|
|
ATTRIBUTE_ENTRY(CameraControlsMapper, ReverseThrust, reverseThrust),
|
|
ATTRIBUTE_ENTRY(CameraControlsMapper, DriveCamera, driveCamera),
|
|
ATTRIBUTE_ENTRY(CameraControlsMapper, SlideOrClamp, slideOrClamp)
|
|
};
|
|
|
|
CameraControlsMapper::AttributeIndexSet& CameraControlsMapper::GetAttributeIndex()
|
|
{
|
|
static CameraControlsMapper::AttributeIndexSet attributeIndex(ELEMENTS(CameraControlsMapper::AttributePointers),
|
|
CameraControlsMapper::AttributePointers,
|
|
Subsystem::GetAttributeIndex()
|
|
);
|
|
return attributeIndex;
|
|
}
|
|
|
|
//#############################################################################
|
|
// Construction and Destruction
|
|
//
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
CameraControlsMapper::CameraControlsMapper(
|
|
CameraShip *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource,
|
|
SharedData &shared_data
|
|
):
|
|
Subsystem(owner, subsystem_ID, subsystem_resource, shared_data)
|
|
{
|
|
stickPosition.x = 0.0f;
|
|
stickPosition.y = 0.0f;
|
|
throttlePosition = 0.0f;
|
|
pedalsPosition = 0.0f;
|
|
driveCamera = 0;
|
|
slideOrClamp = 0;
|
|
reverseThrust = 0;
|
|
Check_Fpu();
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
CameraControlsMapper::~CameraControlsMapper()
|
|
{
|
|
}
|
|
|
|
Logical
|
|
CameraControlsMapper::TestInstance() const
|
|
{
|
|
return IsDerivedFrom(*GetClassDerivations());
|
|
}
|