The reconstructed tree now produces a runnable binary with the authentic 1995 toolchain (BC4.52 / tlink32 / DPMI32): - BTL4.CPP main TU reconstructed from the 4.11 Ghidra decomp (FUN_0040109c) + the 4.10 binary's own string pool + surviving RPL4TOOL.CPP house style; probe_main.cpp scaffold retired (BTL4.NOTES.md documents every decoded call) - L4NET.CPP staged: L4NetworkManager ctor/dtor + 10 vtable-pulled virtuals (standalone-benign ones no-op, network ones Fail loudly) + NetNub client globals (Net_Common_Ptr=NULL routes L4File to its plain-DOS path) - build410.sh: libs now built in the AUTHENTIC makefile member order (MUNGA.MAK / mungal4.mak / BT.MAK / BTL4.MAK). Order is load-bearing: tlink emits static-init records in module pull order, and alphabetical order booted into a null-vptr crash (IcomManager::ClassDerivations constructing before parent NetworkClient::ClassDerivations). Also fixed stage_link to the proven 32-bit lib set (SOSDBXC+SOSMBXC, no WATTCPLG) - BOXTREE.HPP MemoryBlock unify, BTL4GRND notify stubs, remaining engine backfills (audio/gauge/resource/stream TUs) that closed the deep ledger Smoke test (DOSBox-X + 32RTM, copy of the pod BT tree, our exe swapped in): BattleTech v4.10 BTL4Application::BTL4Application l4net.cpp(22): L4NetworkManager -- l4net.cpp not yet reconstructed Static init, main, -egg parse, BTL4.RES load (version 1.0.6 check passes), ApplicationManager and the BTL4Application ctor chain all execute real reconstructed code; boot halts at the first staged Fail() as designed. Next brick: the real l4net.cpp body. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
205 lines
4.3 KiB
C++
205 lines
4.3 KiB
C++
# if !defined(MUNGA_HPP)
|
|
# include <munga.hpp>
|
|
# endif
|
|
#pragma hdrstop
|
|
|
|
# if !defined(CONTROLS_HPP)
|
|
# include <controls.hpp>
|
|
# endif
|
|
# if !defined(GAUGREND_HPP)
|
|
# include <gaugrend.hpp>
|
|
# endif
|
|
|
|
|
|
#if defined(__BCPLUSPLUS__)
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
#if DEBUG_LEVEL>0
|
|
int _matherr(struct exception *a)
|
|
{
|
|
switch (a->type)
|
|
{
|
|
case DOMAIN:
|
|
DEBUG_STREAM << "Domain" << flush;
|
|
break;
|
|
case SING:
|
|
DEBUG_STREAM << "Singularity" << flush;
|
|
break;
|
|
case UNDERFLOW:
|
|
DEBUG_STREAM << "Underflow" << flush;
|
|
break;
|
|
case OVERFLOW:
|
|
DEBUG_STREAM << "Overflow" << flush;
|
|
break;
|
|
case TLOSS:
|
|
DEBUG_STREAM << "Loss of Precision" << flush;
|
|
break;
|
|
}
|
|
DEBUG_STREAM << " error occurred in " << a->name << endl << flush;
|
|
DEBUG_STREAM << "arg1 = " << a->arg1 << endl << flush;
|
|
DEBUG_STREAM << "arg2 = " << a->arg2 << endl << flush;
|
|
DEBUG_STREAM << "retval = " << a->retval << endl << flush << flush;
|
|
return 0;
|
|
}
|
|
#else
|
|
int _matherr(struct exception *)
|
|
{
|
|
_fpreset();
|
|
return 1;
|
|
}
|
|
#endif
|
|
|
|
extern "C" void _pure_error_()
|
|
{
|
|
Fail("Pure virtual function called");
|
|
}
|
|
#endif
|
|
|
|
|
|
//
|
|
//#############################################################################
|
|
// Fpu_Ok
|
|
//
|
|
// returns True if fpu has no errors, False if errors found
|
|
//#############################################################################
|
|
//
|
|
int
|
|
Fpu_Ok()
|
|
{
|
|
unsigned int s =
|
|
_status87() &
|
|
(
|
|
SW_INVALID |
|
|
// SW_DENORMAL |
|
|
SW_ZERODIVIDE |
|
|
SW_OVERFLOW
|
|
// SW_UNDERFLOW |
|
|
//VERIFY: SW_STACKFAULT
|
|
);
|
|
if (s)
|
|
{
|
|
DEBUG_STREAM << "ERROR: FPU status=" << flush;
|
|
|
|
if (s & SW_INVALID)
|
|
{
|
|
DEBUG_STREAM << "invalid " << flush;
|
|
}
|
|
if (s & SW_DENORMAL)
|
|
{
|
|
DEBUG_STREAM << "denormalized " << flush;
|
|
}
|
|
if (s & SW_ZERODIVIDE)
|
|
{
|
|
DEBUG_STREAM << "zeroDivide " << flush;
|
|
}
|
|
if (s & SW_OVERFLOW)
|
|
{
|
|
DEBUG_STREAM << "overflow " << flush;
|
|
}
|
|
if (s & SW_UNDERFLOW)
|
|
{
|
|
DEBUG_STREAM << "underflow " << flush;
|
|
}
|
|
/*if (s & SW_STACKFAULT)
|
|
{
|
|
DEBUG_STREAM << "stackFault" << flush;
|
|
}*/
|
|
DEBUG_STREAM << "\n" << flush << flush;
|
|
return False;
|
|
}
|
|
else
|
|
{
|
|
return True;
|
|
}
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
static Logical AlreadyFailed=False;
|
|
|
|
void Verify_Failed(char *Message, char *File, int Line)
|
|
{
|
|
if (!AlreadyFailed)
|
|
{
|
|
AlreadyFailed = True;
|
|
|
|
DEBUG_STREAM << File << "(" << Line << "): Failed " << Message << "\n" << flush;
|
|
#if defined(USE_PROFILE_ANALYSIS)
|
|
Analysis_Named_Status();
|
|
#endif
|
|
DEBUG_STREAM << "Failing to debugger\n" << flush << flush;
|
|
SystemClock::timer.Shutdown();
|
|
ControlsManager::Shutdown();
|
|
GaugeRenderer::EmergencyShutdown();
|
|
*(int*)(0xFFFFFFFF) = 0;
|
|
}
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
void
|
|
Fail_To_Debugger(char *Message, char *File, int Line)
|
|
{
|
|
if (!AlreadyFailed)
|
|
{
|
|
AlreadyFailed = True;
|
|
|
|
DEBUG_STREAM << File << "(" << Line << "): " << Message << "\n" << flush;
|
|
#if defined(USE_PROFILE_ANALYSIS)
|
|
Analysis_Named_Status();
|
|
#endif
|
|
DEBUG_STREAM << "Failing to debugger\n" << flush << flush;
|
|
SystemClock::timer.Shutdown();
|
|
ControlsManager::Shutdown();
|
|
GaugeRenderer::EmergencyShutdown();
|
|
*(int*)(0xFFFFFFFF) = 0;
|
|
}
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
#if defined(USE_SIGNATURE)
|
|
Signature::Signature()
|
|
{
|
|
#if DEBUG_LEVEL>0
|
|
mark = magic;
|
|
#endif
|
|
}
|
|
|
|
Signature::~Signature()
|
|
{
|
|
#if DEBUG_LEVEL>0
|
|
mark = noMagic;
|
|
#endif
|
|
}
|
|
|
|
int
|
|
Is_Signature_Bad(const volatile Signature *p)
|
|
{
|
|
#if DEBUG_LEVEL>0
|
|
if (p->mark == Signature::magic)
|
|
{
|
|
return Signature::ok;
|
|
}
|
|
else if (p->mark == Signature::noMagic)
|
|
{
|
|
return Signature::destroyed;
|
|
}
|
|
else
|
|
{
|
|
return Signature::corrupted;
|
|
}
|
|
#else
|
|
return False;
|
|
#endif
|
|
}
|
|
#endif
|