Files
BT411/engine/MUNGA/STYLE.H
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

139 lines
2.6 KiB
C++

#pragma once
#include <stdio.h>
#if !defined(DEBUG_STREAM)
#define DEBUG_STREAM std::cout
#endif
#if !defined(Verify)
#if !defined(DEBUG_LEVEL)
#define DEBUG_LEVEL 0
#endif
#if DEBUG_LEVEL<1
#include "debugoff.h"
#elif DEBUG_LEVEL<2
#include "debug1on.h"
#elif DEBUG_LEVEL<3
#include "debug2on.h"
#else
#include "debug3on.h"
#endif
#endif
#if defined(__BCPLUSPLUS__)
extern int _matherr(struct exception *a);
#endif
extern int Fpu_Ok();
extern void Verify_Failed(char *message, char *file, int line);
//extern void Fail_To_Debugger(char *message, char *file, int line);
//extern void PostQuitMessage(int exit_code);
class Signature
{
private:
#if DEBUG_LEVEL>0
enum Mark
{
ok,
destroyed,
corrupted,
noMagic=(int)0xAB135795L,
magic=(int)0xFFED1231L
} mark;
#endif
protected:
Signature();
~Signature();
public:
friend int Is_Signature_Bad(const volatile Signature *p);
};
#if defined(USE_SIGNATURE)
#define SIGNATURED : public Signature
#else
#define SIGNATURED
#define Is_Signature_Bad(p) (false)
#endif
//#############
//# MACROS #
//#############
#define ELEMENTS(Array) (sizeof(Array)/sizeof(*Array))
#if defined(TEST_CLASS)
#define Test(c)\
if (!(c))\
{\
DEBUG_STREAM << __FILE__"(" << __LINE__ << "): "#c" failed!\07\n";\
return false;\
}
#define Test_And_Dump(c, v)\
if (!(c))\
{\
DEBUG_STREAM << __FILE__"(" << __LINE__ << "): "#c" failed!\07\n";\
DEBUG_STREAM << __FILE__"(" << __LINE__ << "): "#v" = " << (v) << '\n';\
return false;\
}
#define Test_Message(m) (DEBUG_STREAM << m)
#define Test_Branch_On() Fail("First visit of branch")
#define Test_Branch_Off()
#else
#define Test(c)
#define Test_And_Dump(c,v)
#define Test_Message(m)
#endif
//################
//# ENUMERATIONS #
//################
enum
{
False = 0,
True = 1
};
//###########
//# CASTING #
//###########
#define SKIPPY_CAST(Type,var) (*((Type*)&(var)))
//#############
//# TEMPLATES #
//#############
//#include <crtdbg.h>
#define SMALL (1e-4f)
#define Abs(value) ((value>0) ? value : -value)
#define Clamp(v,f,c) (v = ((v<f) ? f : ((v>c) ? c : v)))
#define Max_Clamp(v,c) (v = ((v>c) ? c : v))
#define Is_Many_Bits(value) (Lowbit(value)^value)
#define Low_Bit(value) (value & (-value))
#define Min_Clamp(v,f) (v = ((v<f) ? f : v))
#define Max(a,b) ((a>b) ? a : b)
#define Min(a,b) ((a<b) ? a : b)
#define Sgn(value) ((value<-SMALL) ? -1 : value>SMALL)
//############
//# TYPEDEFS #
//############
typedef int Logical;
typedef unsigned __int8 Byte;
typedef unsigned __int16 Word;
typedef unsigned __int32 LWord;
typedef int Enumeration;
#include "memreg.h"