1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-12-18 10:37:53 +01:00

Added FT demo data support.

Tested with .006 ,.020 RC2, there might be more versions out there.
Fixed mds2midi.
Ref #22.
This commit is contained in:
Muzychenko Andrey 2021-11-24 17:25:23 +03:00
parent 95007c9253
commit 919b537e28
7 changed files with 34 additions and 16 deletions

View file

@ -34,9 +34,12 @@ TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
ListBitmap = new std::vector<gdrv_bitmap8*>();
/*Full tilt: ball is ballN, where N[0,2] resolution*/
if (pb::FullTiltMode)
ballGroupName[4] = '0' + fullscrn::GetResolution();
auto groupIndex = loader::query_handle(ballGroupName);
if (groupIndex < 0)
{
ballGroupName[4] = '0' + fullscrn::GetResolution();
groupIndex = loader::query_handle(ballGroupName);
}
Offset = *loader::query_float_attribute(groupIndex, 0, 500);

View file

@ -54,11 +54,13 @@ TTableLayer::TTableLayer(TPinballTable* table): TCollisionComponent(table, -1, f
GraityDirX = cos(PinballTable->GravityAnglY) * sin(PinballTable->GravityAngleX) * PinballTable->GravityDirVectMult;
GraityDirY = sin(PinballTable->GravityAnglY) * sin(PinballTable->GravityAngleX) * PinballTable->GravityDirVectMult;
auto angleMultArr = loader::query_float_attribute(groupIndex, 0, 701);
/*Full tilt hack - GraityMult should be 0.2*/
if (angleMultArr && !pb::FullTiltMode)
if (!pb::FullTiltMode && !pb::FullTiltDemoMode)
{
auto angleMultArr = loader::query_float_attribute(groupIndex, 0, 701);
GraityMult = *angleMultArr;
}
else
GraityMult = 0.2f;

View file

@ -95,7 +95,7 @@ int fullscrn::GetResolution()
void fullscrn::SetResolution(int value)
{
if (!pb::FullTiltMode)
if (!pb::FullTiltMode || pb::FullTiltDemoMode)
value = 0;
assertm(value >= 0 && value <= 2, "Resolution value out of bounds");
resolution = value;
@ -103,7 +103,7 @@ void fullscrn::SetResolution(int value)
int fullscrn::GetMaxResolution()
{
return pb::FullTiltMode ? 2 : 0;
return pb::FullTiltMode && !pb::FullTiltDemoMode ? 2 : 0;
}
void fullscrn::window_size_changed()

View file

@ -56,6 +56,10 @@ int midi::music_init()
track1 = load_track("TABA1");
track2 = load_track("TABA2");
track3 = load_track("TABA3");
// FT demo .006 has only one music track, but it is nearly 9 min. long
if (!track1 && pb::FullTiltDemoMode)
track1 = load_track("DEMO");
}
else
{
@ -271,8 +275,7 @@ std::vector<uint8_t>* midi::MdsToMidi(std::string file)
// Delta time is in variable quantity, Big Endian
uint32_t deltaVarLen;
auto count = ToVariableLen(delta, deltaVarLen);
deltaVarLen = SwapByteOrderInt(deltaVarLen);
auto deltaData = reinterpret_cast<const uint8_t*>(&deltaVarLen) + 4 - count;
auto deltaData = reinterpret_cast<const uint8_t*>(&deltaVarLen);
midiBytes.insert(midiBytes.end(), deltaData, deltaData + count);
switch (event.iEvent >> 24)

View file

@ -86,6 +86,11 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode)
{
zMapResolution = LRead<uint8_t>(fileHandle);
fieldSize--;
// -1 means universal resolution, maybe. FT demo .006 is the only known user.
if (zMapResolution == 0xff)
zMapResolution = 0;
assertm(zMapResolution <= 2, "partman: zMap resolution out of bounds");
}

View file

@ -32,7 +32,7 @@ DatFile* pb::record_table = nullptr;
int pb::time_ticks = 0, pb::demo_mode = 0, pb::game_mode = 2;
float pb::mode_countdown_, pb::time_now = 0, pb::time_next = 0, pb::ball_speed_limit, pb::time_ticks_remainder = 0;
high_score_struct pb::highscore_table[5];
bool pb::FullTiltMode = false, pb::cheat_mode = false;
bool pb::FullTiltMode = false, pb::FullTiltDemoMode = false, pb::cheat_mode = false;
std::string pb::DatFileName;
@ -121,14 +121,16 @@ int pb::uninit()
void pb::SelectDatFile(std::array<char*, 2> dataSearchPaths)
{
DatFileName.clear();
FullTiltDemoMode = FullTiltMode = false;
std::string datFileNames[2]
std::string datFileNames[3]
{
"CADET.DAT",
options::get_string("Pinball Data", pinball::get_rc_string(168, 0))
options::get_string("Pinball Data", pinball::get_rc_string(168, 0)),
"DEMO.DAT",
};
// Default game data test order: CADET.DAT, PINBALL.DAT
// Default game data test order: CADET.DAT, PINBALL.DAT, DEMO.DAT
if (options::Options.Prefer3DPBGameData)
std::swap(datFileNames[0], datFileNames[1]);
for (auto path : dataSearchPaths)
@ -136,16 +138,19 @@ void pb::SelectDatFile(std::array<char*, 2> dataSearchPaths)
if (DatFileName.empty() && path)
{
pinball::BasePath = path;
for (int i = 0; i < 2; i++)
for (auto datFileName : datFileNames)
{
auto datFileName = datFileNames[i];
auto datFilePath = pinball::make_path_name(datFileName);
auto datFile = fopenu(datFilePath.c_str(), "r");
if (datFile)
{
fclose(datFile);
DatFileName = datFileName;
FullTiltMode = datFileName == "CADET.DAT";
if (datFileName == "CADET.DAT")
FullTiltMode = true;
if (datFileName == "DEMO.DAT")
FullTiltDemoMode = FullTiltMode = true;
printf("Loading game from: %s\n", datFilePath.c_str());
break;
}

View file

@ -40,7 +40,7 @@ public:
static DatFile* record_table;
static TPinballTable* MainTable;
static high_score_struct highscore_table[5];
static bool FullTiltMode;
static bool FullTiltMode, FullTiltDemoMode;
static std::string DatFileName;
static int init();