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>
172 lines
3.4 KiB
C++
172 lines
3.4 KiB
C++
#pragma once
|
|
|
|
#include "scalar.h"
|
|
|
|
class Time;
|
|
|
|
//##########################################################################
|
|
//######################## System Clock ##############################
|
|
//##########################################################################
|
|
|
|
class SystemClock SIGNATURED
|
|
{
|
|
friend class Time;
|
|
|
|
public:
|
|
friend float Get_Frame_Percent_Used();
|
|
friend volatile Time& Now();
|
|
friend double HiResNow();
|
|
friend __int64 HiResNowTicks();
|
|
friend __int64 HiResCounterFreq();
|
|
static void TogglePause();
|
|
|
|
SystemClock();
|
|
~SystemClock() { Shutdown(); }
|
|
static SystemClock timer;
|
|
void Shutdown();
|
|
static long GetTicksPerSecond() { return ticksPerSecond; }
|
|
|
|
protected:
|
|
long pauseStart;
|
|
long pauseTime;
|
|
static long ticksPerSecond;
|
|
static __int64 perfCounterFreq;
|
|
|
|
static long GetRTC();
|
|
static double GetHiRes();
|
|
static __int64 GetHiResTicks();
|
|
};
|
|
|
|
//##########################################################################
|
|
//############################ Time ##################################
|
|
//##########################################################################
|
|
|
|
class Time
|
|
{
|
|
public:
|
|
long ticks;
|
|
static Time Null;
|
|
|
|
#if defined(USE_SIGNATURE)
|
|
friend int Is_Signature_Bad(const volatile Time *p);
|
|
#endif
|
|
|
|
Time() {}
|
|
Time(const volatile Time &t) : ticks(t.ticks) {}
|
|
Time(const Time &t) : ticks(t.ticks) {}
|
|
Time(SystemClock&) : ticks(0) {}
|
|
|
|
Time& operator=(const volatile Time &t)
|
|
{
|
|
Check_Pointer(this);
|
|
Check(&t);
|
|
ticks = t.ticks;
|
|
return *this;
|
|
}
|
|
Time& operator=(long t)
|
|
{
|
|
Check_Pointer(this);
|
|
ticks = t;
|
|
return *this;
|
|
}
|
|
Time& operator=(Scalar t)
|
|
{
|
|
Check_Pointer(this);
|
|
ticks = Float_To_Time(t);
|
|
return *this;
|
|
}
|
|
|
|
operator Scalar() const volatile
|
|
{
|
|
Check(this);
|
|
return Time_To_Float(ticks);
|
|
}
|
|
operator long() const volatile
|
|
{
|
|
Check(this);
|
|
return ticks;
|
|
}
|
|
|
|
Scalar operator-(const volatile Time &t) const volatile
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
return Time_To_Float(ticks - t.ticks);
|
|
}
|
|
|
|
Time& operator+=(const volatile Time &t)
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
ticks += t.ticks;
|
|
return *this;
|
|
}
|
|
Time& operator+=(Scalar t)
|
|
{
|
|
Check(this);
|
|
ticks += Float_To_Time(t);
|
|
return *this;
|
|
}
|
|
Time& operator+=(long t)
|
|
{
|
|
Check(this);
|
|
ticks += t;
|
|
return *this;
|
|
}
|
|
Time& operator-=(const volatile Time &t)
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
ticks -= t.ticks;
|
|
return *this;
|
|
}
|
|
Time& operator-=(Scalar t)
|
|
{
|
|
Check(this);
|
|
ticks -= Float_To_Time(t);
|
|
return *this;
|
|
}
|
|
|
|
Logical operator<(const volatile Time &t) const volatile
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
return ticks < t.ticks;
|
|
}
|
|
Logical operator<=(const volatile Time &t) const volatile
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
return ticks <= t.ticks;
|
|
}
|
|
Logical operator>(const volatile Time &t) const volatile
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
return ticks > t.ticks;
|
|
}
|
|
Logical operator>=(const volatile Time &t) const volatile
|
|
{
|
|
Check(this);
|
|
Check(&t);
|
|
return ticks >= t.ticks;
|
|
}
|
|
|
|
friend std::ostream& operator <<(std::ostream& stream, const volatile Time& t)
|
|
{
|
|
Check(&t);
|
|
return stream << t.ticks;
|
|
}
|
|
|
|
Logical TestInstance() const volatile;
|
|
static Logical TestClass();
|
|
|
|
private:
|
|
static long Float_To_Time(Scalar t) { return (long)(t * SystemClock::ticksPerSecond + 0.5f); }
|
|
static Scalar Time_To_Float(long t) { return (Scalar)(t / (float)SystemClock::ticksPerSecond); }
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Time functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
void Convert_From_Ascii(const char *str, Time *time);
|