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>
This commit is contained in:
arcattack
2026-07-05 21:03:40 -05:00
co-authored by Claude Opus 4.8
commit 7b7d465e5e
4192 changed files with 604371 additions and 0 deletions
+192
View File
@@ -0,0 +1,192 @@
#include "munga.h"
#pragma hdrstop
#include "plane.h"
#include "sphere.h"
#include "linmtrx.h"
#include "extntbox.h"
//
//#############################################################################
//#############################################################################
//
Plane::Plane(
const Point3D& p0,
const Point3D& p1,
const Point3D& p2
)
{
Vector3D v1,v2;
v1.Subtract(p1, p0);
v2.Subtract(p2, p1);
Vector3D axis;
axis.Cross(v1, v2);
Verify(!Small_Enough(axis.Length()));
normal = axis;
offset = -(normal * p0);
Verify(Small_Enough(DistanceTo(p1)));
Verify(Small_Enough(DistanceTo(p2)));
Check_Fpu();
}
//
//#############################################################################
//#############################################################################
//
Plane&
Plane::Multiply(
const Plane &p,
const LinearMatrix &m
)
{
Check_Pointer(this);
Check(&p);
Check(&m);
normal.x = p.normal.x*m(0,0) + p.normal.y*m(1,0) + p.normal.z*m(2,0);
normal.y = p.normal.x*m(0,1) + p.normal.y*m(1,1) + p.normal.z*m(2,1);
normal.z = p.normal.x*m(0,2) + p.normal.y*m(1,2) + p.normal.z*m(2,2);
offset =
p.normal.x*m(3,0) + p.normal.y*m(3,1) + p.normal.z*m(3,2) + p.offset;
return *this;
}
//
//#############################################################################
//#############################################################################
//
Logical
Plane::Contains(const Point3D &point) const
{
return normal * point <= offset;
}
//
//#############################################################################
//#############################################################################
//
Logical
Plane::ContainsSomeOf(const Sphere &sphere) const
{
return normal*sphere.center - offset <= sphere.radius;
}
//
//#############################################################################
//#############################################################################
//
Logical
Plane::ContainsAllOf(const Sphere &sphere) const
{
return offset - normal*sphere.center >= sphere.radius;
}
//
//#############################################################################
//#############################################################################
//
Logical
Plane::ContainsSomeOf(const ExtentBox &box) const
{
Check(this);
Check(&box);
Point3D test;
test.x = (normal.x > 0.0f) ? box.minX : box.maxX;
test.y = (normal.y > 0.0f) ? box.minY : box.maxY;
test.z = (normal.z > 0.0f) ? box.minZ : box.maxZ;
return Contains(test);
}
//
//#############################################################################
//#############################################################################
//
Logical
Plane::ContainsAllOf(const ExtentBox &box) const
{
Check(this);
Check(&box);
Point3D test;
test.x = (normal.x < 0.0f) ? box.minX : box.maxX;
test.y = (normal.y < 0.0f) ? box.minY : box.maxY;
test.z = (normal.z < 0.0f) ? box.minZ : box.maxZ;
return Contains(test);
}
//
//#############################################################################
//#############################################################################
//
Logical
Plane::Intersect(const Sphere &sphere) const
{
Scalar dist = normal*sphere.center - offset;
return Abs(dist) <= sphere.radius;
}
//
//#############################################################################
//#############################################################################
//
Logical
Plane::Intersect(const ExtentBox &box) const
{
if (!ContainsSomeOf(box))
{
return False;
}
Plane inverse(-normal.x, -normal.y, -normal.z, -offset);
return inverse.ContainsSomeOf(box);
}
//
//#############################################################################
//#############################################################################
//
std::ostream& operator<<(std::ostream& Stream, const Plane &A_Plane)
{
Stream << "\n\tPlane Normal: " << A_Plane.normal;
return Stream << "\n\tOffset: " << -A_Plane.offset;
}
//
//###########################################################################
//###########################################################################
//
Logical Plane::TestInstance() const
{
return True;
}
Scalar
Plane::CalculateX(Scalar y, Scalar z)
{
Check(this);
Verify(!Small_Enough(normal.x));
Scalar result = (offset - y*normal.y - z*normal.z)/normal.x;
Check_Fpu();
return result;
}
Scalar
Plane::CalculateY(Scalar x, Scalar z)
{
Check(this);
Verify(!Small_Enough(normal.y));
Scalar result = (offset - x*normal.x - z*normal.z)/normal.y;
Check_Fpu();
return result;
}
Scalar
Plane::CalculateZ(Scalar x, Scalar y)
{
Check(this);
Verify(!Small_Enough(normal.z));
Scalar result = (offset - x*normal.x - y*normal.y)/normal.z;
Check_Fpu();
return result;
}