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>
107 lines
3.0 KiB
C
107 lines
3.0 KiB
C
// Recovered decompilation of functions attributed to bt/powersub.cpp
|
|
// (from BTL4OPT.EXE via embedded assert paths). Pseudocode — reconstruct against the header.
|
|
|
|
/* ---- @ 004b0f74 ---- */
|
|
|
|
int * __cdecl
|
|
FUN_004b0f74(int *param_1,int param_2,undefined4 param_3,char *param_4,undefined4 param_5,
|
|
int param_6,int param_7)
|
|
|
|
{
|
|
char cVar1;
|
|
uint uVar2;
|
|
uint uVar3;
|
|
int *piVar4;
|
|
char *pcVar5;
|
|
char *pcVar6;
|
|
int *piVar7;
|
|
int local_8;
|
|
|
|
FUN_004adda0(param_1,param_2,param_3,param_4,param_5,param_6,param_7);
|
|
*param_1 = (int)&PTR_FUN_0050f9d8;
|
|
FUN_004b1bb1(param_1 + 0x74,0);
|
|
FUN_0041b9ec(param_1 + 0x99,5);
|
|
FUN_0041b9ec(param_1 + 0xae,3);
|
|
local_8 = 0;
|
|
if (*(int *)(param_4 + 0xfc) < *(int *)(param_2 + 0x124)) {
|
|
local_8 = *(int *)(*(int *)(param_2 + 0x128) + *(int *)(param_4 + 0xfc) * 4);
|
|
}
|
|
else {
|
|
FUN_0040385c(s_Bad_voltageSourceIndex_to_connec_0050f700,s_d__tesla_bt_bt_POWERSUB_CPP_0050f72d,
|
|
0x264);
|
|
}
|
|
if (((*(uint *)(param_2 + 0x28) & 0xc) == 0) && ((*(uint *)(param_2 + 0x28) & 0x100) != 0)) {
|
|
param_1[7] = (int)PTR_FUN_0050f5b0;
|
|
param_1[8] = DAT_0050f5b4;
|
|
param_1[9] = DAT_0050f5b8;
|
|
if (local_8 == 0) {
|
|
FUN_0040385c(s_Master_PoweredSubsystem_is_missi_0050f749,
|
|
s_d__tesla_bt_bt_POWERSUB_CPP_0050f780,0x272);
|
|
}
|
|
else {
|
|
FUN_004b0dd8((int)param_1,local_8);
|
|
}
|
|
}
|
|
else if (((*(uint *)(param_2 + 0x28) & 0xc) == 4) && (local_8 != 0)) {
|
|
FUN_004b0dd8((int)param_1,local_8);
|
|
}
|
|
param_1[0xc3] = *(int *)(param_4 + 0x100);
|
|
param_1[0xc5] = *(int *)(param_4 + 0x18c);
|
|
param_1[0xc6] = param_1[0xc5];
|
|
FUN_0041bbd8((int)(param_1 + 0x99),4);
|
|
FUN_0041bbd8((int)(param_1 + 0xae),1);
|
|
param_1[0xc4] = 0x3f800000;
|
|
param_1[0x77] = *(int *)(param_4 + 0x104);
|
|
param_1[0x78] = *(int *)(param_4 + 0x108);
|
|
uVar2 = 0xffffffff;
|
|
pcVar5 = param_4 + 0x10c;
|
|
do {
|
|
pcVar6 = pcVar5;
|
|
if (uVar2 == 0) break;
|
|
uVar2 = uVar2 - 1;
|
|
pcVar6 = pcVar5 + 1;
|
|
cVar1 = *pcVar5;
|
|
pcVar5 = pcVar6;
|
|
} while (cVar1 != '\0');
|
|
uVar2 = ~uVar2;
|
|
piVar4 = (int *)(pcVar6 + -uVar2);
|
|
piVar7 = param_1 + 0x79;
|
|
for (uVar3 = uVar2 >> 2; uVar3 != 0; uVar3 = uVar3 - 1) {
|
|
*piVar7 = *piVar4;
|
|
piVar4 = piVar4 + 1;
|
|
piVar7 = piVar7 + 1;
|
|
}
|
|
for (uVar2 = uVar2 & 3; uVar2 != 0; uVar2 = uVar2 - 1) {
|
|
*(char *)piVar7 = (char)*piVar4;
|
|
piVar4 = (int *)((int)piVar4 + 1);
|
|
piVar7 = (int *)((int)piVar7 + 1);
|
|
}
|
|
uVar2 = 0xffffffff;
|
|
pcVar5 = param_4 + 0x14c;
|
|
do {
|
|
pcVar6 = pcVar5;
|
|
if (uVar2 == 0) break;
|
|
uVar2 = uVar2 - 1;
|
|
pcVar6 = pcVar5 + 1;
|
|
cVar1 = *pcVar5;
|
|
pcVar5 = pcVar6;
|
|
} while (cVar1 != '\0');
|
|
uVar2 = ~uVar2;
|
|
piVar4 = (int *)(pcVar6 + -uVar2);
|
|
piVar7 = param_1 + 0x89;
|
|
for (uVar3 = uVar2 >> 2; uVar3 != 0; uVar3 = uVar3 - 1) {
|
|
*piVar7 = *piVar4;
|
|
piVar4 = piVar4 + 1;
|
|
piVar7 = piVar7 + 1;
|
|
}
|
|
for (uVar2 = uVar2 & 3; uVar2 != 0; uVar2 = uVar2 - 1) {
|
|
*(char *)piVar7 = (char)*piVar4;
|
|
piVar4 = (int *)((int)piVar4 + 1);
|
|
piVar7 = (int *)((int)piVar7 + 1);
|
|
}
|
|
return param_1;
|
|
}
|
|
|
|
|
|
|