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>
245 lines
5.3 KiB
C++
245 lines
5.3 KiB
C++
#pragma once
|
|
|
|
#include "style.h"
|
|
#include "audio.h"
|
|
#include "audmidi.h"
|
|
#include "vchain.h"
|
|
#include "audtime.h"
|
|
|
|
//##########################################################################
|
|
//####################### AudioControlEvent ##########################
|
|
//##########################################################################
|
|
|
|
class AudioControlEvent:
|
|
public Plug
|
|
{
|
|
friend MemoryStream&
|
|
MemoryStream_Read(
|
|
MemoryStream *stream,
|
|
AudioControlEvent *control_event
|
|
);
|
|
|
|
friend MemoryStream&
|
|
MemoryStream_Write(
|
|
MemoryStream *stream,
|
|
const AudioControlEvent *control_event
|
|
);
|
|
|
|
public:
|
|
AudioControlEvent(
|
|
AudioTick start_tick,
|
|
AudioControlID audio_control_ID,
|
|
AudioControlValue audio_control_value
|
|
);
|
|
AudioControlEvent();
|
|
~AudioControlEvent();
|
|
|
|
Logical
|
|
AudioControlEvent::TestInstance() const;
|
|
|
|
AudioTick
|
|
GetStartTick()
|
|
{return startTick;}
|
|
|
|
void
|
|
Send(AudioComponent *audio_component);
|
|
|
|
Logical
|
|
Chase(AudioComponent *audio_component);
|
|
|
|
public:
|
|
friend std::ostream& operator << (std::ostream &strm, const AudioControlEvent &control_event);
|
|
|
|
// private: // HACK
|
|
AudioTick
|
|
startTick;
|
|
AudioControlID
|
|
audioControlID;
|
|
AudioControlValue
|
|
audioControlValue;
|
|
};
|
|
|
|
//##########################################################################
|
|
//####################### AudioControlSequence #######################
|
|
//##########################################################################
|
|
|
|
class AudioControlSequence:
|
|
public AudioComponent
|
|
{
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Construction, Destruction, and Testing
|
|
//
|
|
public:
|
|
AudioControlSequence(
|
|
PlugStream *stream,
|
|
Entity *entity
|
|
);
|
|
void
|
|
AudioControlSequenceX(
|
|
AudioComponent *audio_component,
|
|
Entity *entity,
|
|
Logical is_looped,
|
|
AudioDivisionsPerBeat divisions_per_beat,
|
|
AudioTempo tempo,
|
|
Logical dump_value
|
|
);
|
|
~AudioControlSequence();
|
|
|
|
Logical
|
|
TestInstance() const;
|
|
|
|
//
|
|
//--------------------------------------------------------------------
|
|
// BuildFromPage
|
|
//--------------------------------------------------------------------
|
|
//
|
|
static void
|
|
BuildFromPage(
|
|
PlugStream *stream,
|
|
NameList *name_list,
|
|
ClassID class_ID,
|
|
ObjectID object_ID
|
|
);
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Sequence methods
|
|
//
|
|
public:
|
|
//
|
|
//--------------------------------------------------------------------
|
|
// Controller methods
|
|
//--------------------------------------------------------------------
|
|
//
|
|
void
|
|
ReceiveControl(
|
|
AudioControlID control_ID,
|
|
AudioControlValue control_value
|
|
);
|
|
|
|
//
|
|
//--------------------------------------------------------------------
|
|
// Sequence control
|
|
//--------------------------------------------------------------------
|
|
//
|
|
void
|
|
StartSequence();
|
|
void
|
|
RunSequence();
|
|
void
|
|
StopSequence();
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Private methods
|
|
//
|
|
private:
|
|
Logical
|
|
IsEventReady(AudioControlEvent *audio_control_event);
|
|
Scalar
|
|
CalculateEventSeconds(AudioControlEvent *audio_control_event);
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Private data
|
|
//
|
|
private:
|
|
typedef SChainOf<AudioControlEvent*>
|
|
AudioControlEventSocket;
|
|
typedef SChainIteratorOf<AudioControlEvent*>
|
|
AudioControlEventIterator;
|
|
|
|
Logical isLooped;
|
|
Logical isRunning;
|
|
AudioTime startTime;
|
|
AudioDivisionsPerBeat divisionsPerBeat;
|
|
AudioTempo tempo;
|
|
|
|
SlotOf<AudioComponent*>
|
|
audioComponentSocket;
|
|
|
|
AudioControlEventSocket
|
|
audioControlEventSocket;
|
|
AudioControlEventIterator
|
|
*audioControlEventIterator;
|
|
|
|
#if DEBUG_LEVEL>0
|
|
Logical
|
|
dumpValue;
|
|
#endif
|
|
};
|
|
|
|
//##########################################################################
|
|
//################### CreateAudioControlEventStream ##################
|
|
//##########################################################################
|
|
|
|
class CreateAudioControlEventStream:
|
|
public MidiParse
|
|
{
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Construction, Destruction, and Testing
|
|
//
|
|
public:
|
|
CreateAudioControlEventStream();
|
|
~CreateAudioControlEventStream();
|
|
|
|
Logical
|
|
TestInstance() const;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Parsing
|
|
//
|
|
public:
|
|
void
|
|
Parse(
|
|
MemoryStream *input_stream,
|
|
MemoryStream *output_stream,
|
|
SignedLongWord tempo=100
|
|
);
|
|
AudioDivisionsPerBeat
|
|
GetDivisionsPerBeat()
|
|
{return divisionsPerBeat;}
|
|
AudioTempo
|
|
GetTempo()
|
|
{return tempo;}
|
|
CollectionSize
|
|
GetNumberOfEvents();
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Implementations
|
|
//
|
|
private:
|
|
SignedWord
|
|
Mf_getc();
|
|
void
|
|
Mf_error(char *);
|
|
|
|
void
|
|
Mf_header(SignedWord,SignedWord,SignedWord);
|
|
void
|
|
Mf_on(SignedWord,SignedWord,SignedWord);
|
|
void
|
|
Mf_off(SignedWord,SignedWord,SignedWord);
|
|
void
|
|
Mf_tempo(SignedLongWord);
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Private data
|
|
//
|
|
private:
|
|
typedef VChainOf<AudioControlEvent*, AudioTick>
|
|
AudioControlEventSocket;
|
|
typedef VChainIteratorOf<AudioControlEvent*, AudioTick>
|
|
AudioControlEventIterator;
|
|
|
|
MemoryStream
|
|
*inputStream;
|
|
MemoryStream
|
|
*outputStream;
|
|
|
|
AudioDivisionsPerBeat
|
|
divisionsPerBeat;
|
|
AudioTempo
|
|
tempo;
|
|
|
|
AudioControlEventSocket
|
|
audioControlEventSocket;
|
|
};
|