TPinballTable v2.

This commit is contained in:
oz 2020-12-25 16:46:06 +03:00
parent 3097edf526
commit 99fba56a34
18 changed files with 576 additions and 127 deletions

3
.gitignore vendored
View File

@ -258,4 +258,5 @@ paket-files/
# Python Tools for Visual Studio (PTVS) # Python Tools for Visual Studio (PTVS)
__pycache__/ __pycache__/
*.pyc *.pyc
/Ida

Binary file not shown.

View File

@ -39,3 +39,17 @@ int Sound::AddFactor(int a1, int a2)
{ {
return a1 + a2; return a1 + a2;
} }
void Sound::PlaySoundA(int a1, int a2, int a3, unsigned short a4, short a5)
{
}
CHAR* Sound::LoadWaveFile(LPCSTR lpName)
{
return nullptr;
}
LPCVOID Sound::FreeSound(LPCVOID pMem)
{
return nullptr;
}

View File

@ -11,4 +11,7 @@ public:
static void Close(); static void Close();
static int SubFactor(int a1, int a2); static int SubFactor(int a1, int a2);
static int AddFactor(int a1, int a2); static int AddFactor(int a1, int a2);
static void PlaySound(int a1, int a2, int a3, unsigned __int16 a4, __int16 a5);
static CHAR* LoadWaveFile(LPCSTR lpName);
static LPCVOID FreeSound(LPCVOID pMem);
}; };

View File

@ -1,2 +1,10 @@
#include "pch.h" #include "pch.h"
#include "TDemo.h" #include "TDemo.h"
#include "TPinballTable.h"
TDemo::TDemo(TPinballTable* table, int groupIndex)
: TCollisionComponent(table, groupIndex, false)
{
table->Demo = this;
}

View File

@ -5,7 +5,5 @@ class TDemo :
public TCollisionComponent public TCollisionComponent
{ {
public: public:
TDemo(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false) TDemo(TPinballTable* table, int groupIndex);
{
}
}; };

View File

@ -1,10 +1,13 @@
#pragma once #pragma once
#include "control.h" struct render_sprite_type_struct;
#include "render.h" struct component_control;
#include "TZmapList.h"
class TPinballTable; class TPinballTable;
class TZmapList;
enum class message_code
{
};
class TPinballComponent class TPinballComponent
{ {
@ -16,7 +19,6 @@ public:
virtual void put_scoring(int scoreId, int value); virtual void put_scoring(int scoreId, int value);
virtual int get_scoring(int score1); virtual int get_scoring(int score1);
int VfTable;
__int8 UnknownBaseFlag1; __int8 UnknownBaseFlag1;
__int8 UnknownBaseFlag2; __int8 UnknownBaseFlag2;
int MessageField; int MessageField;

View File

@ -5,7 +5,10 @@
#include "control.h" #include "control.h"
#include "loader.h" #include "loader.h"
#include "memory.h" #include "memory.h"
#include "pb.h"
#include "pinball.h" #include "pinball.h"
#include "render.h"
#include "Sound.h"
#include "TBall.h" #include "TBall.h"
#include "TBlocker.h" #include "TBlocker.h"
#include "TBumper.h" #include "TBumper.h"
@ -14,6 +17,7 @@
#include "TFlagSpinner.h" #include "TFlagSpinner.h"
#include "TGate.h" #include "TGate.h"
#include "THole.h" #include "THole.h"
#include "timer.h"
#include "TKickback.h" #include "TKickback.h"
#include "TKickout.h" #include "TKickout.h"
#include "TLight.h" #include "TLight.h"
@ -32,48 +36,50 @@
#include "TTimer.h" #include "TTimer.h"
#include "TTripwire.h" #include "TTripwire.h"
#include "TWall.h" #include "TWall.h"
#include "TPlunger.h"
#include "TFlipper.h"
#include "TDrain.h"
int TPinballTable::score_multipliers[5] = {1, 2, 3, 5, 10};
TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false) TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
{ {
int shortArrLength; int shortArrLength;
//this->VfTable = (int)&TPinballTable::`vftable';
ListP1 = new objlist_class(32, 16); ListP1 = new objlist_class(32, 16);
ListP2 = new objlist_class(3, 1); ListP2 = new objlist_class(3, 1);
this->Score1 = nullptr; CurScoreStruct = nullptr;
this->ScoreBallcount = nullptr; ScoreBallcount = nullptr;
this->ScorePlayerNumber1 = nullptr; ScorePlayerNumber1 = nullptr;
this->UnknownP10 = 0; UnknownP10 = 0;
this->UnknownBaseFlag2 = 1; UnknownBaseFlag2 = 1;
this->UnknownP83 = 0; TiltLockFlag = 0;
this->UnknownP14 = 0; EndGameTimeoutTimer = 0;
this->UnknownP13 = 0; LightShowTimer = 0;
this->UnknownP80 = 0; ReplayTimer = 0;
this->UnknownP15 = 0; TiltTimeoutTimer = 0;
this->UnknownP77 = 0; MultiballFlag = 0;
TBall* ballObj = new TBall(this); auto ballObj = new TBall(this);
ListP2->Add(ballObj); ListP2->Add(ballObj);
if (ballObj) if (ballObj)
ballObj->UnknownBaseFlag2 = 0; ballObj->UnknownBaseFlag2 = 0;
new TTableLayer(this); new TTableLayer(this);
this->LightGroup = new TLightGroup(this, 0); LightGroup = new TLightGroup(this, 0);
auto score1 = score::create("score1", render::background_bitmap); auto score1 = score::create("score1", render::background_bitmap);
this->Score1 = score1; CurScoreStruct = score1;
this->Score2 = score1; PlayerScores[0].ScoreStruct = score1;
int scoreIndex = 1; for (int scoreIndex = 1; scoreIndex < 4; scoreIndex++)
auto scorePtr = &this->Score3_x3_at7;
do
{ {
*scorePtr = score::dup(this->Score1, scoreIndex++); PlayerScores[scoreIndex].ScoreStruct = score::dup(CurScoreStruct, scoreIndex);
scorePtr += 7;
} }
while (scoreIndex < 4);
this->CurrentPlayer = 0; CurrentPlayer = 0;
this->UnknownP73 = 3; MaxBallCount = 3;
this->ScoreBallcount = (int*)score::create("ballcount1", render::background_bitmap); ScoreBallcount = score::create("ballcount1", render::background_bitmap);
this->ScorePlayerNumber1 = (int*)score::create("player_number1", render::background_bitmap); ScorePlayerNumber1 = score::create("player_number1", render::background_bitmap);
int groupIndexObjects = loader::query_handle("table_objects"); int groupIndexObjects = loader::query_handle("table_objects");
short* shortArr = loader::query_iattribute(groupIndexObjects, 1025, &shortArrLength); short* shortArr = loader::query_iattribute(groupIndexObjects, 1025, &shortArrLength);
@ -92,17 +98,17 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
new TWall(this, groupIndex); new TWall(this, groupIndex);
break; break;
case 1001: case 1001:
this->Plunger = new TPlunger(this, groupIndex); Plunger = new TPlunger(this, groupIndex);
break; break;
case 1002: case 1002:
new TLight(this, groupIndex); new TLight(this, groupIndex);
//((objlist_class*)(this->LightGroup + 42))->Add(light); //((objlist_class*)(LightGroup + 42))->Add(light);
break; break;
case 1003: case 1003:
this->FlipperL = new TFlipper(this, groupIndex); FlipperL = new TFlipper(this, groupIndex);
break; break;
case 1004: case 1004:
this->FlipperR = new TFlipper(this, groupIndex); FlipperR = new TFlipper(this, groupIndex);
break; break;
case 1005: case 1005:
new TBumper(this, groupIndex); new TBumper(this, groupIndex);
@ -111,7 +117,7 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
new TPopupTarget(this, groupIndex); new TPopupTarget(this, groupIndex);
break; break;
case 1007: case 1007:
this->Drain = new TDrain(this, groupIndex); Drain = new TDrain(this, groupIndex);
break; break;
case 1011: case 1011:
new TBlocker(this, groupIndex); new TBlocker(this, groupIndex);
@ -191,19 +197,10 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
TPinballTable::~TPinballTable() TPinballTable::~TPinballTable()
{ {
scoreStruct** scorePtr = &Score2; for (int scoreIndex = 0; scoreIndex < 4; scoreIndex++)
int index = 4;
do
{ {
if (*scorePtr) memory::free(PlayerScores[scoreIndex].ScoreStruct);
{
memory::free(*scorePtr);
*scorePtr = nullptr;
}
scorePtr += 7;
--index;
} }
while (index);
if (ScorePlayerNumber1) if (ScorePlayerNumber1)
{ {
memory::free(ScorePlayerNumber1); memory::free(ScorePlayerNumber1);
@ -260,6 +257,66 @@ TPinballComponent* TPinballTable::find_component(int groupIndex)
return nullptr; return nullptr;
} }
int TPinballTable::AddScore(int score)
{
if (this->ScoreSpecial3Flag)
{
this->ScoreSpecial3 += score;
if (this->ScoreSpecial3 > 5000000)
this->ScoreSpecial3 = 5000000;
}
if (this->ScoreSpecial2Flag)
{
this->ScoreSpecial2 += score;
if (this->ScoreSpecial2 > 5000000)
this->ScoreSpecial2 = 5000000;
}
int addedScore = this->ScoreAdded + score * score_multipliers[this->ScoreMultiplier];
this->CurScore += addedScore;
if (this->CurScore > 1000000000)
{
++this->CurScoreE9;
this->CurScore = this->CurScore - 1000000000;
}
score::set(this->CurScoreStruct, this->CurScore);
return addedScore;
}
void TPinballTable::ChangeBallCount(int count)
{
BallCount = count;
if (count <= 0)
{
score::erase(ScoreBallcount, 1);
}
else
{
score::set(ScoreBallcount, MaxBallCount - count + 1);
score::update(ScoreBallcount);
}
}
void TPinballTable::tilt(float time)
{
TPinballTable* this2 = this;
if (!this->TiltLockFlag && !this->UnknownP10)
{
pinball::InfoTextBox->Clear();
pinball::MissTextBox->Clear();
pinball::InfoTextBox->Display(pinball::get_rc_string(35, 0), -1.0);
loader::play_sound(this2->SoundIndex3);
this2->TiltTimeoutTimer = timer::set(30.0, this2, TPinballTable::tilt_timeout);
for (int i = 0; i < ListP1->Count(); i++)
{
static_cast<TPinballComponent*>(ListP1->Get(i))->Message(1011, time);
}
this2->LightGroup->Message(8, 0);
this2->TiltLockFlag = 1;
control::table_control_handler(1011);
}
}
void TPinballTable::port_draw() void TPinballTable::port_draw()
{ {
@ -268,3 +325,341 @@ void TPinballTable::port_draw()
static_cast<TPinballComponent*>(ListP1->Get(index))->port_draw(); static_cast<TPinballComponent*>(ListP1->Get(index))->port_draw();
} }
} }
int TPinballTable::Message(int code, float value)
{
LPSTR rc_text;
switch (code)
{
case 1000:
if (!TiltLockFlag)
{
FlipperL->Message(1, value);
}
break;
case 1001:
if (!TiltLockFlag)
{
FlipperL->Message(2, value);
}
break;
case 1002:
if (!TiltLockFlag)
{
FlipperR->Message(1, value);
}
break;
case 1003:
if (!TiltLockFlag)
{
FlipperR->Message(2, value);
}
break;
case 1004:
case 1005:
Plunger->Message(code, value);
break;
case 1008:
case 1009:
case 1010:
for (int i = 0; i < ListP1->Count(); i++)
{
static_cast<TPinballComponent*>(ListP1->Get(i))->Message(code, value);
}
break;
case 1012:
LightGroup->Message(14, 0.0);
if (TiltLockFlag)
{
TiltLockFlag = 0;
if (TiltTimeoutTimer)
timer::kill(TiltTimeoutTimer);
TiltTimeoutTimer = 0;
}
break;
case 1013:
LightGroup->Message(34, 0.0);
LightGroup->Message(20, 0.0);
Plunger->Message(1016, 0.0);
if (Demo->UnknownBaseFlag2)
rc_text = pinball::get_rc_string(30, 0);
else
rc_text = pinball::get_rc_string(26, 0);
pinball::InfoTextBox->Display(rc_text, -1.0);
if (Demo)
Demo->Message(1014, 0.0);
break;
case 1014:
if (EndGameTimeoutTimer)
{
timer::kill(EndGameTimeoutTimer);
EndGame_timeout(0, this);
pb::mode_change(1);
}
if (LightShowTimer)
{
timer::kill(LightShowTimer);
LightShowTimer = 0;
Message(1013, 0.0);
}
else
{
UnknownP6 = 0;
Message(1024, 0.0);
/*v8 = (char*)this2->ListP2.ListPtr->Array[0];
*(float*)(v8 + 46) = 0.0;
*(float*)(v8 + 42) = 0.0;
*(_DWORD*)(v8 + 50) = -1085485875;*/
auto playerCount = static_cast<int>(floor(value));
PlayerCount = playerCount;
if (playerCount >= 1)
{
if (playerCount > 4)
PlayerCount = 4;
}
else
{
PlayerCount = 1;
}
auto plr1Score = PlayerScores[0].ScoreStruct;
CurrentPlayer = 0;
CurScoreStruct = plr1Score;
CurScore = 0;
score::set(plr1Score, 0);
ScoreMultiplier = 0;
for (int plrIndex = 1; plrIndex < PlayerCount; ++plrIndex)
{
auto scorePtr = &PlayerScores[plrIndex];
score::set(scorePtr->ScoreStruct, 0);
scorePtr->Score = 0;
scorePtr->ScoreE9Part = 0;
scorePtr->BallCount = MaxBallCount;
scorePtr->ExtraBalls = ExtraBalls;
scorePtr->BallLockedCounter = BallLockedCounter;
scorePtr->Unknown2 = ScoreSpecial3;
}
BallCount = MaxBallCount;
Sound::Idle();
ChangeBallCount(BallCount);
score::set(ScorePlayerNumber1, CurrentPlayer + 1);
score::update(ScorePlayerNumber1);
Sound::Idle();
for (auto scoreIndex = 4 - PlayerCount; scoreIndex > 0; scoreIndex--)
{
score::set(PlayerScores[scoreIndex].ScoreStruct, -1);
}
Sound::Idle();
ScoreSpecial3Flag = 0;
ScoreSpecial2Flag = 0;
UnknownP71 = 0;
pinball::InfoTextBox->Clear();
Sound::Idle();
pinball::MissTextBox->Clear();
Sound::Idle();
LightGroup->Message(28, 0.2f);
auto time = loader::play_sound(SoundIndex1);
LightShowTimer = timer::set(time, this, LightShow_timeout);
}
break;
case 1018:
if (ReplayTimer)
timer::kill(ReplayTimer);
ReplayTimer = timer::set(floor(value), this, replay_timer_callback);
ReplayActiveFlag = 1;
break;
case 1021:
{
if (PlayerCount <= 1)
{
char* textboxText;
if (Demo->UnknownBaseFlag2)
textboxText = pinball::get_rc_string(30, 0);
else
textboxText = pinball::get_rc_string(26, 0);
pinball::InfoTextBox->Display(textboxText, -1.0);
break;
}
auto nextPlayer = (CurrentPlayer + 1) % PlayerCount;
auto nextScorePtr = &PlayerScores[nextPlayer];
if (nextScorePtr->BallCount <= 0)
break;
PlayerScores[CurrentPlayer].Score = CurScore;
PlayerScores[CurrentPlayer].ScoreE9Part = CurScoreE9;
PlayerScores[CurrentPlayer].BallCount = BallCount;
PlayerScores[CurrentPlayer].ExtraBalls = ExtraBalls;
PlayerScores[CurrentPlayer].BallLockedCounter = BallLockedCounter;
PlayerScores[CurrentPlayer].Unknown2 = ScoreSpecial3;
CurScore = nextScorePtr->Score;
CurScoreE9 = nextScorePtr->ScoreE9Part;
BallCount = nextScorePtr->BallCount;
ExtraBalls = nextScorePtr->ExtraBalls;
BallLockedCounter = nextScorePtr->BallLockedCounter;
ScoreSpecial3 = nextScorePtr->Unknown2;
CurScoreStruct = nextScorePtr->ScoreStruct;
score::set(CurScoreStruct, CurScore);
CurScoreStruct->DirtyFlag = true;
ChangeBallCount(BallCount);
score::set(ScorePlayerNumber1, nextPlayer + 1);
score::update(ScorePlayerNumber1);
for (int i = 0; i < ListP1->Count(); i++)
{
static_cast<TPinballComponent*>(ListP1->Get(i))->Message(1020, static_cast<float>(nextPlayer));
}
char* textboxText = nullptr;
switch (nextPlayer)
{
case 0:
if (Demo->UnknownBaseFlag2)
textboxText = pinball::get_rc_string(30, 0);
else
textboxText = pinball::get_rc_string(26, 0);
break;
case 1:
if (Demo->UnknownBaseFlag2)
textboxText = pinball::get_rc_string(31, 0);
else
textboxText = pinball::get_rc_string(27, 0);
break;
case 2:
if (Demo->UnknownBaseFlag2)
textboxText = pinball::get_rc_string(32, 0);
else
textboxText = pinball::get_rc_string(28, 0);
break;
case 3:
if (Demo->UnknownBaseFlag2)
textboxText = pinball::get_rc_string(33, 0);
else
textboxText = pinball::get_rc_string(29, 0);
break;
default:
break;
}
if (textboxText != nullptr)
pinball::InfoTextBox->Display(textboxText, -1);
ScoreSpecial3Flag = 0;
ScoreSpecial2Flag = 0;
UnknownP71 = 0;
CurrentPlayer = nextPlayer;
}
break;
case 1022:
loader::play_sound(SoundIndex2);
pinball::MissTextBox->Clear();
pinball::InfoTextBox->Display(pinball::get_rc_string(34, 0), -1.0);
EndGameTimeoutTimer = timer::set(3.0, this, EndGame_timeout);
break;
case 1024:
for (int i = 0; i < ListP1->Count(); i++)
{
static_cast<TPinballComponent*>(ListP1->Get(i))->Message(1024, 0);
}
if (ReplayTimer)
timer::kill(ReplayTimer);
ReplayTimer = 0;
if (LightShowTimer)
{
timer::kill(LightShowTimer);
LightGroup->Message(34, 0.0);
}
LightShowTimer = 0;
ScoreMultiplier = 0;
ScoreAdded = 0;
ScoreSpecial1 = 0;
ScoreSpecial2 = 10000;
ScoreSpecial2Flag = 0;
ScoreSpecial3 = 20000;
ScoreSpecial3Flag = 0;
UnknownP71 = 0;
ExtraBalls = 0;
UnknownP75 = 0;
BallLockedCounter = 0;
MultiballFlag = 0;
UnknownP78 = 0;
ReplayActiveFlag = 0;
ReplayTimer = 0;
TiltLockFlag = 0;
break;
default: break;
}
control::table_control_handler(code);
return 0;
}
void TPinballTable::EndGame_timeout(int timerId, void* caller)
{
auto table = static_cast<TPinballTable*>(caller);
table->EndGameTimeoutTimer = 0;
pb::end_game();
for (int i = 0; i < table->ListP1->Count(); i++)
{
static_cast<TPinballComponent*>(table->ListP1->Get(i))->Message(1022, 0);
}
if (table->Demo)
table->Demo->Message(1022, 0.0);
control::handler(67, pinball::MissTextBox);
pinball::InfoTextBox->Display(pinball::get_rc_string(24, 0), -1.0);
}
void TPinballTable::LightShow_timeout(int timerId, void* caller)
{
auto table = static_cast<TPinballTable*>(caller);
table->LightShowTimer = 0;
table->Message(1013, 0.0);
}
void TPinballTable::replay_timer_callback(int timerId, void* caller)
{
auto table = static_cast<TPinballTable*>(caller);
table->ReplayActiveFlag = 0;
table->ReplayTimer = 0;
}
void TPinballTable::tilt_timeout(int timerId, void* caller)
{
auto table = static_cast<TPinballTable*>(caller);
objlist_struct1* v2; // eax
void** v3; // edi
int v4; // ebx
char v5; // [esp+14h] [ebp-Ch]
table->TiltTimeoutTimer = 0;
if (table->TiltLockFlag)
{
/*v2 = table->ListP2.ListPtr;
v3 = v2->Array;
if (v2->Count > 0)
{
v4 = v2->Count;
do
{
(*(void(__stdcall**)(void*, char*, char*, _DWORD, _DWORD))(*(_DWORD*)table->Drain + 20))(
*v3,
&v5,
&v5,
0.0,
0);
++v3;
--v4;
} while (v4);
}*/
}
}

View File

@ -1,11 +1,26 @@
#pragma once #pragma once
#include "objlist_class.h"
#include "score.h"
#include "TDrain.h"
#include "TFlipper.h"
#include "TLightGroup.h"
#include "TPinballComponent.h" #include "TPinballComponent.h"
#include "TPlunger.h"
struct scoreStruct;
class TFlipper;
class TPlunger;
class TDrain;
class TDemo;
class objlist_class;
class TLightGroup;
struct score_struct_super
{
scoreStruct* ScoreStruct;
int Score;
int ScoreE9Part;
int Unknown2;
int BallCount;
int ExtraBalls;
int BallLockedCounter;
};
class TPinballTable : public TPinballComponent class TPinballTable : public TPinballComponent
{ {
@ -14,56 +29,38 @@ public:
~TPinballTable(); ~TPinballTable();
TPinballComponent* find_component(LPCSTR componentName); TPinballComponent* find_component(LPCSTR componentName);
TPinballComponent* find_component(int groupIndex); TPinballComponent* find_component(int groupIndex);
int AddScore(int score);
void ChangeBallCount(int count);
void tilt(float time);
void port_draw() override; void port_draw() override;
int Message(int code, float value) override;
static void EndGame_timeout(int timerId, void* caller);
static void LightShow_timeout(int timerId, void* caller);
static void replay_timer_callback(int timerId, void* caller);
static void tilt_timeout(int timerId, void* caller);
TFlipper* FlipperL; TFlipper* FlipperL;
TFlipper* FlipperR; TFlipper* FlipperR;
scoreStruct* Score1; scoreStruct* CurScoreStruct;
int* ScoreBallcount; scoreStruct* ScoreBallcount;
int* ScorePlayerNumber1; scoreStruct* ScorePlayerNumber1;
int UnknownP6; int UnknownP6;
int SoundIndex1; int SoundIndex1;
int SoundIndex2; int SoundIndex2;
int SoundIndex3; int SoundIndex3;
int UnknownP10; int UnknownP10;
int UnknownP11; int CurScore;
int UnknownP12; int CurScoreE9;
int UnknownP13; int LightShowTimer;
int UnknownP14; int EndGameTimeoutTimer;
int UnknownP15; int TiltTimeoutTimer;
scoreStruct* Score2; score_struct_super PlayerScores[4];
int UnknownP17;
int UnknownP18;
int UnknownP19;
int UnknownP20;
int UnknownP21;
int UnknownP22;
scoreStruct* Score3_x3_at7;
int UnknownP24;
int UnknownP25;
int UnknownP26;
int UnknownP27;
int UnknownP28;
int UnknownP29;
int UnknownP30;
int UnknownP31;
int UnknownP32;
int UnknownP33;
int UnknownP34;
int UnknownP35;
int UnknownP36;
int UnknownP37;
int UnknownP38;
int UnknownP39;
int UnknownP40;
int UnknownP41;
int UnknownP42;
int UnknownP43;
int PlayerCount; int PlayerCount;
int CurrentPlayer; int CurrentPlayer;
TPlunger* Plunger; TPlunger* Plunger;
TDrain* Drain; TDrain* Drain;
int UnknownP48; TDemo* Demo;
int XOffset; int XOffset;
int YOffset; int YOffset;
int Width; int Width;
@ -77,24 +74,27 @@ public:
float CollisionCompOffset; float CollisionCompOffset;
int UnknownP62; int UnknownP62;
int UnknownP63; int UnknownP63;
int UnknownP64; int ScoreMultiplier;
int UnknownP65; int ScoreAdded;
int UnknownP66; int ScoreSpecial1;
int UnknownP67; int ScoreSpecial2;
int UnknownP68; int ScoreSpecial2Flag;
int UnknownP69; int ScoreSpecial3;
int UnknownP70; int ScoreSpecial3Flag;
int UnknownP71; int UnknownP71;
int UnknownP72; int BallCount;
int UnknownP73; int MaxBallCount;
int UnknownP74; int ExtraBalls;
int UnknownP75; int UnknownP75;
int UnknownP76; int BallLockedCounter;
int UnknownP77; int MultiballFlag;
int UnknownP78; int UnknownP78;
int UnknownP79; int ReplayActiveFlag;
int UnknownP80; int ReplayTimer;
int UnknownP81; int UnknownP81;
int UnknownP82; int UnknownP82;
int UnknownP83; int TiltLockFlag;
private:
static int score_multipliers[5];
}; };

View File

@ -3,6 +3,7 @@
#include "loader.h" #include "loader.h"
#include "proj.h" #include "proj.h"
#include "render.h"
#include "TLine.h" #include "TLine.h"
#include "TPinballTable.h" #include "TPinballTable.h"

View File

@ -3,14 +3,16 @@
#include "TEdgeManager.h" #include "TEdgeManager.h"
class TPinballTable;
class TEdgeManager;
struct gdrv_bitmap8;
class TTableLayer : class TTableLayer :
public TCollisionComponent public TCollisionComponent
{ {
public: public:
static TEdgeManager *edge_manager; static TEdgeManager* edge_manager;
TTableLayer(TPinballTable* table); TTableLayer(TPinballTable* table);
~TTableLayer() override; ~TTableLayer() override;

View File

@ -1,6 +1,9 @@
#include "pch.h" #include "pch.h"
#include "TTextBox.h" #include "TTextBox.h"
#include "control.h"
#include "loader.h" #include "loader.h"
#include "render.h"
#include "score.h" #include "score.h"
#include "timer.h" #include "timer.h"

View File

@ -1,5 +1,7 @@
#include "pch.h" #include "pch.h"
#include "control.h" #include "control.h"
#include "objlist_class.h"
#include "TPinballTable.h" #include "TPinballTable.h"
int control_bump_scores1[] = {500, 1000, 1500, 2000}; int control_bump_scores1[] = {500, 1000, 1500, 2000};
@ -500,6 +502,8 @@ component_tag* control::simple_components[142]
&control_soundwave7_tag &control_soundwave7_tag
}; };
int control::table_control_flag;
void control::make_links(TPinballTable* table) void control::make_links(TPinballTable* table)
{ {
@ -558,7 +562,8 @@ void control::handler(int code, TPinballComponent* cmp)
{ {
cmp->put_scoring(scoreInd, control->Scores[scoreInd]); cmp->put_scoring(scoreInd, control->Scores[scoreInd]);
++scoreInd; ++scoreInd;
} while (scoreInd < control->ScoreCount); }
while (scoreInd < control->ScoreCount);
} }
control->ControlFunc(code, cmp); control->ControlFunc(code, cmp);
} }
@ -796,3 +801,12 @@ void control::MultiplierTargetControl(int code, TPinballComponent* caller)
void control::BallDrainControl(int code, TPinballComponent* caller) void control::BallDrainControl(int code, TPinballComponent* caller)
{ {
} }
void control::table_control_handler(int code)
{
if (code == 1011)
{
table_control_flag = 0;
control_lite77_tag.Component->Message(7, 0.0);
}
}

View File

@ -30,6 +30,7 @@ public:
static TPinballTable* TableG; static TPinballTable* TableG;
static component_info score_components[88]; static component_info score_components[88];
static component_tag* simple_components[142]; static component_tag* simple_components[142];
static int table_control_flag;
static void make_links(TPinballTable* table); static void make_links(TPinballTable* table);
static TPinballComponent* make_component_link(component_tag* tag); static TPinballComponent* make_component_link(component_tag* tag);
@ -93,4 +94,6 @@ public:
static void MedalTargetControl(int code, TPinballComponent* caller); static void MedalTargetControl(int code, TPinballComponent* caller);
static void MultiplierTargetControl(int code, TPinballComponent* caller); static void MultiplierTargetControl(int code, TPinballComponent* caller);
static void BallDrainControl(int code, TPinballComponent* caller); static void BallDrainControl(int code, TPinballComponent* caller);
static void table_control_handler(int code);
}; };

View File

@ -3,6 +3,7 @@
#include "memory.h" #include "memory.h"
#include "partman.h" #include "partman.h"
#include "pinball.h" #include "pinball.h"
#include "Sound.h"
#include "zdrv.h" #include "zdrv.h"
@ -132,7 +133,7 @@ void loader::unload()
soundListStruct* soundListPtr = &sound_list[1]; soundListStruct* soundListPtr = &sound_list[1];
do do
{ {
//Sound_FreeSound(soundListPtr->WavePtr); Sound::FreeSound(soundListPtr->WavePtr);
++index; ++index;
++soundListPtr; ++soundListPtr;
} }
@ -166,7 +167,7 @@ int loader::get_sound_id(int groupIndex)
if (!sound_list[soundIndex].Loaded && !sound_list[soundIndex].WavePtr) if (!sound_list[soundIndex].Loaded && !sound_list[soundIndex].WavePtr)
{ {
int soundGroupId = sound_list[soundIndex].GroupIndex; int soundGroupId = sound_list[soundIndex].GroupIndex;
sound_list[soundIndex].Volume = 0.0; sound_list[soundIndex].Duration = 0.0;
if (soundGroupId > 0 && !pinball::quickFlag) if (soundGroupId > 0 && !pinball::quickFlag)
{ {
__int16* value = (__int16*)partman::field(loader_table, soundGroupId, datFieldTypes::ShortValue); __int16* value = (__int16*)partman::field(loader_table, soundGroupId, datFieldTypes::ShortValue);
@ -174,9 +175,9 @@ int loader::get_sound_id(int groupIndex)
{ {
const CHAR* fileName = partman::field(loader_table, soundGroupId, datFieldTypes::String); const CHAR* fileName = partman::field(loader_table, soundGroupId, datFieldTypes::String);
HFILE hFile = _lopen(fileName, 0); HFILE hFile = _lopen(fileName, 0);
sound_list[soundIndex].Volume = (float)((double)(_llseek(hFile, 0, 2)) * 0.0000909090909090909); sound_list[soundIndex].Duration = (float)((double)_llseek(hFile, 0, 2) * 0.0000909090909090909);
_lclose(hFile); _lclose(hFile);
//sound_list[soundIndex4].WavePtr = Sound_LoadWaveFile(lpName); sound_list[soundIndex].WavePtr = Sound::LoadWaveFile(fileName);
} }
} }
} }
@ -320,12 +321,12 @@ int loader::material(int groupIndex, visualStruct* visual)
} }
double loader::play_sound(int soundIndex) float loader::play_sound(int soundIndex)
{ {
if (soundIndex <= 0) if (soundIndex <= 0)
return 0.0; return 0.0;
//Sound_PlaySound(sound_list[soundIndex].WavePtr, 0, 7, 5, 0); Sound::PlaySound((int)sound_list[soundIndex].WavePtr, 0, 7, 5, 0);
return sound_list[soundIndex].Volume; return sound_list[soundIndex].Duration;
} }
int loader::state_id(int groupIndex, int groupIndexOffset) int loader::state_id(int groupIndex, int groupIndexOffset)

View File

@ -16,7 +16,7 @@ struct soundListStruct
char* WavePtr; char* WavePtr;
int GroupIndex; int GroupIndex;
int Loaded; int Loaded;
float Volume; float Duration;
char* PtrToSmth; char* PtrToSmth;
}; };
@ -66,7 +66,7 @@ public:
static char* query_name(int groupIndex); static char* query_name(int groupIndex);
static float* query_float_attribute(int groupIndex, int groupIndexOffset, int firstValue); static float* query_float_attribute(int groupIndex, int groupIndexOffset, int firstValue);
static __int16* query_iattribute(int groupIndex, int firstValue, int* arraySize); static __int16* query_iattribute(int groupIndex, int firstValue, int* arraySize);
static double play_sound(int soundIndex); static float play_sound(int soundIndex);
static datFileStruct* loader_table; static datFileStruct* loader_table;
private: private:
static errorMsg loader_errors[]; static errorMsg loader_errors[];

View File

@ -13,6 +13,8 @@
#include "timer.h" #include "timer.h"
#include "winmain.h" #include "winmain.h"
#include "resource.h" #include "resource.h"
#include "TLightGroup.h"
#include "TPlunger.h"
TPinballTable* pb::MainTable = nullptr; TPinballTable* pb::MainTable = nullptr;
datFileStruct* pb::record_table = nullptr; datFileStruct* pb::record_table = nullptr;
@ -355,19 +357,19 @@ void pb::keydown(int key)
} }
if (key == options::Options.LeftTableBumpKey) if (key == options::Options.LeftTableBumpKey)
{ {
if (!MainTable->UnknownP83) if (!MainTable->TiltLockFlag)
nudge::nudge_right(); nudge::nudge_right();
return; return;
} }
if (key == options::Options.RightTableBumpKey) if (key == options::Options.RightTableBumpKey)
{ {
if (!MainTable->UnknownP83) if (!MainTable->TiltLockFlag)
nudge::nudge_left(); nudge::nudge_left();
return; return;
} }
if (key == options::Options.BottomTableBumpKey) if (key == options::Options.BottomTableBumpKey)
{ {
if (!MainTable->UnknownP83) if (!MainTable->TiltLockFlag)
nudge::nudge_up(); nudge::nudge_up();
return; return;
} }

View File

@ -3,6 +3,7 @@
#include "loader.h" #include "loader.h"
#include "memory.h" #include "memory.h"
#include "partman.h" #include "partman.h"
#include "render.h"
#include "TDrain.h" #include "TDrain.h"
#include "winmain.h" #include "winmain.h"
@ -15,12 +16,13 @@ int score::init()
scoreStruct* score::create(LPCSTR fieldName, gdrv_bitmap8* renderBgBmp) scoreStruct* score::create(LPCSTR fieldName, gdrv_bitmap8* renderBgBmp)
{ {
scoreStruct* score = (scoreStruct*)memory::allocate(sizeof(scoreStruct)); auto score = reinterpret_cast<scoreStruct*>(memory::allocate(sizeof(scoreStruct)));
if (!score) if (!score)
return nullptr; return nullptr;
score->Score = -9999; score->Score = -9999;
score->BackgroundBmp = renderBgBmp; score->BackgroundBmp = renderBgBmp;
__int16* shortArr = (__int16*)partman::field_labeled(loader::loader_table, fieldName, datFieldTypes::ShortArray); auto shortArr = reinterpret_cast<__int16*>(partman::field_labeled(loader::loader_table, fieldName,
datFieldTypes::ShortArray));
if (!shortArr) if (!shortArr)
{ {
memory::free(score); memory::free(score);