diff --git a/Doc/FuncStats.xlsx b/Doc/FuncStats.xlsx
index aef5d36..8c060c7 100644
Binary files a/Doc/FuncStats.xlsx and b/Doc/FuncStats.xlsx differ
diff --git a/SpaceCadetPinball/SpaceCadetPinball.vcxproj b/SpaceCadetPinball/SpaceCadetPinball.vcxproj
index 461b1b6..f6176d6 100644
--- a/SpaceCadetPinball/SpaceCadetPinball.vcxproj
+++ b/SpaceCadetPinball/SpaceCadetPinball.vcxproj
@@ -185,6 +185,7 @@
+
@@ -253,6 +254,7 @@
+
diff --git a/SpaceCadetPinball/SpaceCadetPinball.vcxproj.filters b/SpaceCadetPinball/SpaceCadetPinball.vcxproj.filters
index e380a02..88cec46 100644
--- a/SpaceCadetPinball/SpaceCadetPinball.vcxproj.filters
+++ b/SpaceCadetPinball/SpaceCadetPinball.vcxproj.filters
@@ -216,6 +216,9 @@
Header Files
+
+ Header Files\TPinballComponent
+
@@ -398,6 +401,9 @@
Source Files
+
+ Source Files\TPinballComponent
+
diff --git a/SpaceCadetPinball/TEdgeManager.cpp b/SpaceCadetPinball/TEdgeManager.cpp
new file mode 100644
index 0000000..65e1609
--- /dev/null
+++ b/SpaceCadetPinball/TEdgeManager.cpp
@@ -0,0 +1,6 @@
+#include "pch.h"
+#include "TEdgeManager.h"
+
+void TEdgeManager::edges_insert_square(float a1, float a2, float a3, float a4, TEdgeSegment* a5, field_effect_type* a6)
+{
+}
diff --git a/SpaceCadetPinball/TEdgeManager.h b/SpaceCadetPinball/TEdgeManager.h
new file mode 100644
index 0000000..9a92d3f
--- /dev/null
+++ b/SpaceCadetPinball/TEdgeManager.h
@@ -0,0 +1,20 @@
+#pragma once
+#include "TCollisionComponent.h"
+#include "TEdgeSegment.h"
+
+struct field_effect_type
+{
+ char* Flag2Ptr;
+ int Unknown1;
+ TCollisionComponent* CollisionComp;
+};
+
+class TEdgeManager
+{
+public:
+ TEdgeManager(float a2, float a3, float a4, float a5)
+ {
+ }
+
+ static void edges_insert_square(float a1, float a2, float a3, float a4, TEdgeSegment* a5, field_effect_type* a6);
+};
diff --git a/SpaceCadetPinball/TPinballTable.cpp b/SpaceCadetPinball/TPinballTable.cpp
index d81afd6..e9d49e1 100644
--- a/SpaceCadetPinball/TPinballTable.cpp
+++ b/SpaceCadetPinball/TPinballTable.cpp
@@ -56,9 +56,8 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
ListP2->Add(ballObj);
if (ballObj)
ballObj->UnknownBaseFlag2 = 0;
- TTableLayer* tableLayerObj = new TTableLayer(this);
- TLightGroup* lightGroupObj = new TLightGroup(this, 0);
- this->LightGroup = lightGroupObj;
+ new TTableLayer(this);
+ this->LightGroup = new TLightGroup(this, 0);
auto score1 = score::create("score1", render::background_bitmap);
this->Score1 = score1;
@@ -71,7 +70,7 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
scorePtr += 7;
}
while (scoreIndex < 4);
- this->UnknownP45 = 0;
+ this->CurrentPlayer = 0;
this->UnknownP73 = 3;
this->ScoreBallcount = (int*)score::create("ballcount1", render::background_bitmap);
this->ScorePlayerNumber1 = (int*)score::create("player_number1", render::background_bitmap);
@@ -192,7 +191,6 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
TPinballTable::~TPinballTable()
{
- //this->VfTable = (TPinballComponent_vtbl*)&TPinballTable::`vftable';
scoreStruct** scorePtr = &Score2;
int index = 4;
do
@@ -216,12 +214,10 @@ TPinballTable::~TPinballTable()
memory::free(ScoreBallcount);
ScoreBallcount = nullptr;
}
- for (auto i = LightGroup; ; i = static_cast(ListP1->Get(0)))
+ delete LightGroup;
+ while (ListP1->Count() > 0)
{
- //if (i)
- //(*(void(__thiscall**)(TLightGroup*, int))(*(_DWORD*)i + 16))(i, 1);
- //if (!ListP1->Count())
- break;
+ delete static_cast(ListP1->Get(0));
}
delete ListP2;
delete ListP1;
diff --git a/SpaceCadetPinball/TPinballTable.h b/SpaceCadetPinball/TPinballTable.h
index e78d0ad..155e1e8 100644
--- a/SpaceCadetPinball/TPinballTable.h
+++ b/SpaceCadetPinball/TPinballTable.h
@@ -22,9 +22,9 @@ public:
int* ScoreBallcount;
int* ScorePlayerNumber1;
int UnknownP6;
- int UnknownP7;
- int UnknownP8;
- int UnknownP9;
+ int SoundIndex1;
+ int SoundIndex2;
+ int SoundIndex3;
int UnknownP10;
int UnknownP11;
int UnknownP12;
@@ -59,21 +59,21 @@ public:
int UnknownP41;
int UnknownP42;
int UnknownP43;
- int UnknownP44;
- int UnknownP45;
+ int PlayerCount;
+ int CurrentPlayer;
TPlunger* Plunger;
TDrain* Drain;
int UnknownP48;
int XOffset;
int YOffset;
- int UnknownP51;
- int UnknownP52;
+ int Width;
+ int Height;
objlist_class* ListP1;
objlist_class* ListP2;
TLightGroup* LightGroup;
- int UnknownP58;
- int UnknownP59;
- int UnknownP60;
+ float TableAngleMult;
+ float TableAngle1;
+ float TableAngle2;
float CollisionCompOffset;
int UnknownP62;
int UnknownP63;
diff --git a/SpaceCadetPinball/TTableLayer.cpp b/SpaceCadetPinball/TTableLayer.cpp
index eaa0981..8b1d864 100644
--- a/SpaceCadetPinball/TTableLayer.cpp
+++ b/SpaceCadetPinball/TTableLayer.cpp
@@ -1,2 +1,103 @@
#include "pch.h"
#include "TTableLayer.h"
+
+#include "loader.h"
+#include "proj.h"
+#include "TLine.h"
+#include "TPinballTable.h"
+
+TEdgeManager* TTableLayer::edge_manager;
+
+TTableLayer::TTableLayer(TPinballTable* table): TCollisionComponent(table, -1, false)
+{
+ visualStruct visual{};
+ rectangle_type rect{};
+
+ auto groupIndex = loader::query_handle("table");
+ loader::query_visual(groupIndex, 0, &visual);
+
+ auto projCenter = loader::query_float_attribute(groupIndex, 0, 700);
+ proj::recenter(projCenter[0], projCenter[1]);
+ render::set_background_zmap(visual.ZMap, 0, 0);
+
+ auto bmp = visual.Bitmap;
+ VisBmp = visual.Bitmap;
+ rect.XPosition = 0;
+ rect.YPosition = 0;
+ rect.Width = bmp->Width;
+ rect.Height = bmp->Height;
+ render::create_sprite(VisualType::None, bmp, visual.ZMap, 0, 0, &rect);
+
+ PinballTable->SoundIndex1 = visual.SoundIndex4;
+ PinballTable->SoundIndex2 = visual.SoundIndex3;
+ PinballTable->SoundIndex3 = visual.Kicker.SoundIndex;
+
+ auto tableAngleArr = loader::query_float_attribute(groupIndex, 0, 305);
+ if (tableAngleArr)
+ {
+ PinballTable->TableAngleMult = tableAngleArr[0];
+ PinballTable->TableAngle1 = tableAngleArr[1];
+ PinballTable->TableAngle2 = tableAngleArr[2];
+ }
+ else
+ {
+ PinballTable->TableAngleMult = 25.0f;
+ PinballTable->TableAngle1 = 0.5f;
+ PinballTable->TableAngle2 = 1.570796f;
+ }
+
+ auto table3 = PinballTable;
+ Angle1 = cos(table3->TableAngle2) * sin(table3->TableAngle1) * table3->TableAngleMult;
+ Angle2 = sin(table3->TableAngle2) * sin(table3->TableAngle1) * table3->TableAngleMult;
+ auto angleMultArr = loader::query_float_attribute(groupIndex, 0, 701);
+ if (angleMultArr)
+ AngleMult = *angleMultArr;
+ else
+ AngleMult = 0.2f;
+
+ table->XOffset = bmp->XPosition;
+ table->YOffset = bmp->YPosition;
+ table->Width = bmp->Width;
+ table->Height = bmp->Height;
+ UnknownC7F = visual.Kicker.Unknown1F;
+ UnknownC6F = 15.0f;
+
+ auto visArrPtr = visual.FloatArr;
+ Unknown1F = min(visArrPtr[0], min(visArrPtr[2], visArrPtr[4]));
+ Unknown2F = min(visArrPtr[1], min(visArrPtr[3], visArrPtr[5]));
+ Unknown3F = max(visArrPtr[0], max(visArrPtr[2], visArrPtr[4]));
+ Unknown4F = max(visArrPtr[1], max(visArrPtr[3], visArrPtr[5]));
+ auto a2 = Unknown4F - Unknown2F;
+ auto a1 = Unknown3F - Unknown1F;
+ edge_manager = new TEdgeManager(Unknown1F, Unknown2F, a1, a2);
+
+ for (auto visFloatArrCount = visual.FloatArrCount; visFloatArrCount > 0; visFloatArrCount--)
+ {
+ auto line = new TLine(this,
+ &UnknownBaseFlag2,
+ visual.Flag,
+ visArrPtr[2],
+ visArrPtr[3],
+ visArrPtr[0],
+ visArrPtr[1]);
+ if (line)
+ {
+ line->place_in_grid();
+ EdgeList->Add(line);
+ }
+
+ visArrPtr += 2;
+ }
+
+ Field.Unknown1 = -1;
+ Field.Flag2Ptr = &UnknownBaseFlag2;
+ Field.CollisionComp = this;
+ TEdgeManager::edges_insert_square(Unknown2F, Unknown1F, Unknown4F, Unknown3F, nullptr,
+ &Field);
+}
+
+TTableLayer::~TTableLayer()
+{
+ if (edge_manager)
+ delete edge_manager;
+}
diff --git a/SpaceCadetPinball/TTableLayer.h b/SpaceCadetPinball/TTableLayer.h
index 70ba35c..dd9d88c 100644
--- a/SpaceCadetPinball/TTableLayer.h
+++ b/SpaceCadetPinball/TTableLayer.h
@@ -1,11 +1,27 @@
#pragma once
#include "TCollisionComponent.h"
+#include "TEdgeManager.h"
+
+
+
class TTableLayer :
public TCollisionComponent
{
public:
- TTableLayer(TPinballTable* table) : TCollisionComponent(table, -1, false)
- {
- }
+ static TEdgeManager *edge_manager;
+
+ TTableLayer(TPinballTable* table);
+ ~TTableLayer() override;
+
+ gdrv_bitmap8* VisBmp;
+ float Unknown1F;
+ float Unknown2F;
+ float Unknown3F;
+ float Unknown4F;
+ float Angle1;
+ float Angle2;
+ int Unknown7;
+ float AngleMult;
+ field_effect_type Field;
};
diff --git a/SpaceCadetPinball/loader.cpp b/SpaceCadetPinball/loader.cpp
index cb4eb14..79bf608 100644
--- a/SpaceCadetPinball/loader.cpp
+++ b/SpaceCadetPinball/loader.cpp
@@ -88,7 +88,7 @@ void loader::default_vsi(visualStruct* visual)
visual->Kicker.SoundIndex = 0;
visual->Unknown1F = 0.94999999f;
visual->Unknown2F = 0.60000002f;
- visual->FloatArrSizeDiv8Sub2 = 0;
+ visual->FloatArrCount = 0;
visual->SoundIndex2 = 0;
visual->Bitmap = 0;
visual->ZMap = 0;
@@ -545,23 +545,23 @@ LABEL_33:
nextFloatVal = floatArr + 1;
if (*floatArr != 600.0)
return 0;
- visual2->FloatArrSizeDiv8Sub2 = (partman::field_size(loader_table, groupIndexSum3, datFieldTypes::FloatArray) >> 2)/ 2- 2;
+ visual2->FloatArrCount = (partman::field_size(loader_table, groupIndexSum3, datFieldTypes::FloatArray) >> 2)/ 2- 2;
floatVal = (__int64)(floor(*nextFloatVal) - 1.0);
floatArrPtr = nextFloatVal + 1;
if ((int)floatVal)
{
if ((int)floatVal == 1)
{
- visual2->FloatArrSizeDiv8Sub2 = 2;
+ visual2->FloatArrCount = 2;
}
- else if ((int)floatVal != visual2->FloatArrSizeDiv8Sub2)
+ else if ((int)floatVal != visual2->FloatArrCount)
{
return error(8, 18);
}
}
else
{
- visual2->FloatArrSizeDiv8Sub2 = 1;
+ visual2->FloatArrCount = 1;
}
visual2->FloatArr = floatArrPtr;
return 0;
diff --git a/SpaceCadetPinball/loader.h b/SpaceCadetPinball/loader.h
index 8fdd3af..ed50d8d 100644
--- a/SpaceCadetPinball/loader.h
+++ b/SpaceCadetPinball/loader.h
@@ -37,7 +37,7 @@ struct __declspec(align(4)) visualStruct
{
float Unknown1F;
float Unknown2F;
- int FloatArrSizeDiv8Sub2;
+ int FloatArrCount;
float* FloatArr;
int SoundIndex2;
visualKickerStruct Kicker;