Files
BT412/reference/decomp/bt_l4_btl4app.cpp.c
arcattackandClaude Opus 4.8 7b7d465e5e Initial commit: bt411 -- standalone Windows BattleTech (Tesla 4.10 port)
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>
2026-07-05 21:03:40 -05:00

158 lines
4.5 KiB
C

// Recovered decompilation of functions attributed to bt_l4/btl4app.cpp
// (from BTL4OPT.EXE via embedded assert paths). Pseudocode — reconstruct against the header.
/* ---- @ 004d36f4 ---- */
int * __cdecl FUN_004d36f4(int param_1,int param_2)
{
int iVar1;
uint *puVar2;
undefined4 *puVar3;
int iVar4;
int *piVar5;
char *pcVar6;
char *pcVar7;
undefined4 uVar8;
undefined *puVar9;
char local_60 [2];
char acStack_5e [30];
undefined4 local_40;
undefined4 local_3c;
int *local_30;
uint *local_2c;
undefined4 *local_28;
uint *local_24;
undefined4 *local_20;
int *local_1c;
undefined4 *local_18;
undefined4 *local_14;
undefined4 *local_10;
int *local_c;
char *local_8;
piVar5 = (int *)0x0;
iVar1 = *(int *)(param_1 + 0x3c);
local_8 = (char *)0x0;
if (*(int *)(param_2 + 0x1c) == 0x45) {
piVar5 = FUN_0042d16c(param_2);
pcVar6 = s_ControlsMapper_0051ec39;
pcVar7 = local_60;
local_c = piVar5;
for (iVar4 = 3; iVar4 != 0; iVar4 = iVar4 + -1) {
*(undefined4 *)pcVar7 = *(undefined4 *)pcVar6;
pcVar6 = pcVar6 + 4;
pcVar7 = pcVar7 + 4;
}
*(undefined2 *)pcVar7 = *(undefined2 *)pcVar6;
pcVar7[2] = pcVar6[2];
local_40 = 0xf;
local_3c = 0x30;
if (*(int *)(iVar1 + 0xc98) == 2) {
local_10 = (undefined4 *)FUN_00402298(0x110);
if (local_10 == (undefined4 *)0x0) {
puVar3 = (undefined4 *)0x0;
}
else {
puVar3 = FUN_0047ac5c(local_10,local_c,0,local_60,&DAT_004fd318);
}
local_8 = s_Thrustmaster_0051ec48;
}
else if (*(int *)(iVar1 + 0xc98) == 4) {
local_14 = (undefined4 *)FUN_00402298(0x108);
if (local_14 == (undefined4 *)0x0) {
puVar3 = (undefined4 *)0x0;
}
else {
puVar3 = FUN_0047ad3c(local_14,local_c,0,local_60,&DAT_004fd364);
}
local_8 = &DAT_0051ec55;
}
else {
local_18 = (undefined4 *)FUN_00402298(0x108);
if (local_18 == (undefined4 *)0x0) {
puVar3 = (undefined4 *)0x0;
}
else {
puVar3 = FUN_0047aa78(local_18,local_c,0,local_60,&DAT_004fd2b0);
}
}
FUN_0042c630((int)local_c,puVar3);
}
else if (*(int *)(param_2 + 0x1c) == 0xbb9) {
piVar5 = FUN_004a2d48(param_2);
local_1c = piVar5;
FUN_00476eac(iVar1,0.05);
FUN_00476eec(iVar1,0.05);
FUN_00476f10(iVar1,0.05);
if (*(int *)(iVar1 + 0xc98) == 2) {
local_20 = (undefined4 *)FUN_00402298(0x1bc);
if (local_20 == (undefined4 *)0x0) {
puVar3 = (undefined4 *)0x0;
}
else {
puVar9 = &DAT_0051dc68;
uVar8 = 0x7dc;
local_24 = (uint *)FUN_00402298(0x10);
if (local_24 == (uint *)0x0) {
puVar2 = (uint *)0x0;
}
else {
puVar2 = FUN_00402460(local_24,s_ControlsMapper_0051ec58);
}
puVar2[3] = puVar2[3] + 1;
puVar3 = FUN_004d21d0(local_20,local_1c,0,(int *)puVar2,uVar8,puVar9);
}
local_8 = s_Thrustmaster_0051ec67;
}
else if (*(int *)(iVar1 + 0xc98) == 4) {
local_28 = (undefined4 *)FUN_00402298(0x1bc);
if (local_28 == (undefined4 *)0x0) {
puVar3 = (undefined4 *)0x0;
}
else {
puVar9 = &DAT_0051dcf0;
uVar8 = 0x7dc;
local_2c = (uint *)FUN_00402298(0x10);
if (local_2c == (uint *)0x0) {
puVar2 = (uint *)0x0;
}
else {
puVar2 = FUN_00402460(local_2c,s_ControlsMapper_0051ec74);
}
puVar2[3] = puVar2[3] + 1;
puVar3 = FUN_004d266c(local_28,local_1c,0,(int *)puVar2,uVar8,puVar9);
}
local_8 = &DAT_0051ec83;
}
else {
FUN_004dbb24(&DAT_00524e20,s______Mech_has_no_controls_mappin_0051ec86,(char *)0x0);
FUN_0040385c(s_BTL4Application__MakeViewpointEn_0051ecae,
s_d__tesla_bt_bt_l4_BTL4APP_CPP_0051ecd3,400);
puVar3 = (undefined4 *)0x0;
}
FUN_0049fe40((int)local_1c,puVar3);
(**(code **)(*local_1c + 0x38))(local_1c);
}
if (((local_8 != (char *)0x0) &&
(local_30 = (int *)FUN_00407064(*(int *)(DAT_004efc94 + 0x68),piVar5[0x6f],6),
local_30 != (int *)0x0)) &&
(local_30 = (int *)FUN_004070dc(*(int *)(param_1 + 0x68),*local_30,local_8),
local_30 != (int *)0x0)) {
iVar4 = local_30[1];
local_30[1] = local_30[1] + 1;
if (iVar4 == 0) {
FUN_00406cd0((int)local_30);
}
FUN_0047703c(iVar1,(int)piVar5,(int *)local_30[0xf]);
local_30[1] = local_30[1] + -1;
}
if (*(int **)(param_1 + 0x4c) != (int *)0x0) {
FUN_0046ff64(*(int **)(param_1 + 0x4c),&DAT_0051ecf1,piVar5);
}
return piVar5;
}