diff --git a/Doc/FuncStats.xlsx b/Doc/FuncStats.xlsx
index 11912f7..f815ea9 100644
Binary files a/Doc/FuncStats.xlsx and b/Doc/FuncStats.xlsx differ
diff --git a/SpaceCadetPinball/SpaceCadetPinball.cpp b/SpaceCadetPinball/SpaceCadetPinball.cpp
index 4c5b028..8f7d047 100644
--- a/SpaceCadetPinball/SpaceCadetPinball.cpp
+++ b/SpaceCadetPinball/SpaceCadetPinball.cpp
@@ -17,15 +17,16 @@
#include "winmain.h"
int main()
-{
- std::cout << "Hello World!\n";
+{
{
// Testing with UI
char cmdLine[1]{};
pb::init();
- WinMain(pinball::hinst, 0, cmdLine, 10);
+ WinMain(winmain::hinst, 0, cmdLine, 10);
+ return 0;
}
-
+
+ std::cout << "Hello World!\n";
gdrv::init(0, 0);
auto dib = gdrv::DibCreate(8, 1, 1);
gdrv::DibSetUsage(dib, 0, 1);
diff --git a/SpaceCadetPinball/SpaceCadetPinball.vcxproj b/SpaceCadetPinball/SpaceCadetPinball.vcxproj
index a394ae6..1a1a3c5 100644
--- a/SpaceCadetPinball/SpaceCadetPinball.vcxproj
+++ b/SpaceCadetPinball/SpaceCadetPinball.vcxproj
@@ -206,6 +206,7 @@
+
@@ -271,6 +272,7 @@
+
diff --git a/SpaceCadetPinball/SpaceCadetPinball.vcxproj.filters b/SpaceCadetPinball/SpaceCadetPinball.vcxproj.filters
index 1876e8d..146dbad 100644
--- a/SpaceCadetPinball/SpaceCadetPinball.vcxproj.filters
+++ b/SpaceCadetPinball/SpaceCadetPinball.vcxproj.filters
@@ -207,6 +207,9 @@
Header Files
+
+ Header Files\TPinballComponent
+
@@ -380,6 +383,9 @@
Source Files
+
+ Source Files\TPinballComponent
+
diff --git a/SpaceCadetPinball/TPinballComponent.cpp b/SpaceCadetPinball/TPinballComponent.cpp
index 982e5d9..a8ba002 100644
--- a/SpaceCadetPinball/TPinballComponent.cpp
+++ b/SpaceCadetPinball/TPinballComponent.cpp
@@ -87,10 +87,10 @@ TPinballComponent::~TPinballComponent()
}
-int TPinballComponent::Message(int message1, float message2)
+int TPinballComponent::Message(int code, float value)
{
- MessageField = message1;
- if (message1 == 1024)
+ MessageField = code;
+ if (code == 1024)
MessageField = 0;
return 0;
}
@@ -108,3 +108,7 @@ int TPinballComponent::get_scoring(int score1)
{
return 0;
}
+
+void TPinballComponent::control_handler(int code, TPinballComponent* cmp)
+{
+}
diff --git a/SpaceCadetPinball/TPinballComponent.h b/SpaceCadetPinball/TPinballComponent.h
index 3bdc99f..875eda7 100644
--- a/SpaceCadetPinball/TPinballComponent.h
+++ b/SpaceCadetPinball/TPinballComponent.h
@@ -9,10 +9,11 @@ class TPinballComponent
public:
TPinballComponent(TPinballTable* table, int groupIndex, bool loadVisuals);
virtual ~TPinballComponent();
- virtual int Message(int message1, float message2);
+ virtual int Message(int code, float value);
virtual void port_draw();
virtual void put_scoring(int score1, int score2);
virtual int get_scoring(int score1);
+ static void control_handler(int code, TPinballComponent* cmp);
int VfTable;
__int8 UnknownBaseFlag1;
diff --git a/SpaceCadetPinball/TTextBox.cpp b/SpaceCadetPinball/TTextBox.cpp
index 6eb2a78..53b9d89 100644
--- a/SpaceCadetPinball/TTextBox.cpp
+++ b/SpaceCadetPinball/TTextBox.cpp
@@ -1,16 +1,231 @@
#include "pch.h"
#include "TTextBox.h"
+#include "loader.h"
+#include "score.h"
+#include "timer.h"
-int TTextBox::Message(int a2, float a3)
+TTextBox::TTextBox(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, true)
+{
+ OffsetX = 0;
+ OffsetY = 0;
+ Width = 0;
+ Height = 0;
+ BgBmp = render::background_bitmap;
+ Font = score::msg_fontp;
+ Message1 = nullptr;
+ Message2 = nullptr;
+ Timer = 0;
+
+ if (groupIndex > 0)
+ {
+ int arrLength;
+ auto dimensions = loader::query_iattribute(groupIndex, 1500, &arrLength);
+ OffsetX = dimensions[0];
+ OffsetY = dimensions[1];
+ Width = dimensions[2];
+ Height = dimensions[3];
+ }
+}
+
+TTextBox::~TTextBox()
+{
+ if (Timer)
+ {
+ if (Timer != -1)
+ timer::kill(Timer);
+ Timer = 0;
+ }
+ while (Message1)
+ {
+ TTextBoxMessage* message = Message1;
+ TTextBoxMessage* nextMessage = message->NextMessage;
+ delete message;
+ Message1 = nextMessage;
+ }
+}
+
+int TTextBox::Message(int code, float value)
{
return 0;
}
+void TTextBox::TimerExpired(int a2, TTextBox* tb)
+{
+ TTextBoxMessage* message = tb->Message1;
+ tb->Timer = 0;
+ if (message)
+ {
+ TTextBoxMessage* nextMessage = message->NextMessage;
+ delete message;
+ tb->Message1 = nextMessage;
+ tb->Draw();
+ control_handler(60, tb);
+ }
+}
+
void TTextBox::Clear()
{
+ gdrv_bitmap8* bmp = BgBmp;
+ if (bmp)
+ gdrv::copy_bitmap(
+ &render::vscreen,
+ Width,
+ Height,
+ OffsetX,
+ OffsetY,
+ bmp,
+ OffsetX,
+ OffsetY);
+ else
+ gdrv::fill_bitmap(&render::vscreen, Width, Height, OffsetX, OffsetY, 0);
+ gdrv::blit(
+ &render::vscreen,
+ OffsetX,
+ OffsetY,
+ OffsetX + render::vscreen.XPosition,
+ OffsetY + render::vscreen.YPosition,
+ Width,
+ Height);
+ if (Timer)
+ {
+ if (Timer != -1)
+ timer::kill(Timer);
+ Timer = 0;
+ }
+ while (Message1)
+ {
+ TTextBoxMessage* message = Message1;
+ TTextBoxMessage* nextMessage = message->NextMessage;
+ delete message;
+ Message1 = nextMessage;
+ }
}
void TTextBox::Display(char* text, float time)
{
+ if (!text)
+ return;
+
+ if (Message1 && !strcmp(text, Message2->Text))
+ {
+ Message2->Refresh(time);
+ if (Message2 == Message1)
+ {
+ if (Timer && Timer != -1)
+ timer::kill(Timer);
+ if (time == -1.0)
+ Timer = -1;
+ else
+ Timer = timer::set(time, (int)this, (int)TimerExpired);
+ }
+ }
+ else
+ {
+ if (Timer == -1)
+ Clear();
+
+ auto message = new TTextBoxMessage(text, time);
+ if (message)
+ {
+ if (message->Text)
+ {
+ if (Message1)
+ Message2->NextMessage = message;
+ else
+ Message1 = message;
+ Message2 = message;
+ if (Timer == 0)
+ Draw();
+ }
+ else
+ {
+ delete message;
+ }
+ }
+ }
+}
+
+void TTextBox::Draw()
+{
+ TTextBoxMessage* nextMessage = nullptr;
+ auto this2 = this;
+
+ auto bmp = BgBmp;
+ if (bmp)
+ gdrv::copy_bitmap(
+ &render::vscreen,
+ Width,
+ Height,
+ OffsetX,
+ OffsetY,
+ bmp,
+ OffsetX,
+ OffsetY);
+ else
+ gdrv::fill_bitmap(&render::vscreen, Width, Height, OffsetX, OffsetY, 0);
+
+ while (this2->Message1)
+ {
+ auto message = this2->Message1;
+ if (message->Time == -1.0)
+ {
+ nextMessage = message->NextMessage;
+ if (!message->NextMessage)
+ {
+ this2->Timer = -1;
+ LABEL_18:
+ auto font = this2->Font;
+ if (!font)
+ {
+ gdrv::blit(
+ &render::vscreen,
+ this2->OffsetX,
+ this2->OffsetY,
+ this2->OffsetX + render::vscreen.XPosition,
+ this2->OffsetY + render::vscreen.YPosition,
+ this2->Width,
+ this2->Height);
+ gdrv::grtext_draw_ttext_in_box(
+ this2->Message1->Text,
+ render::vscreen.XPosition + this2->OffsetX,
+ render::vscreen.YPosition + this2->OffsetY,
+ this2->Width,
+ this2->Height,
+ 255);
+ return;
+ }
+ }
+ }
+ else
+ {
+ auto timeLeft = (this2->Message1->TimeLeft());
+ if (timeLeft >= -2.0f)
+ {
+ int timer;
+ if (timeLeft >= 0.25f)
+ {
+ timer = timer::set(timeLeft, (int)this2, (int)TimerExpired);
+ }
+ else
+ {
+ timer = timer::set(0.25, (int)this2, (int)TimerExpired);
+ }
+ this2->Timer = timer;
+ goto LABEL_18;
+ }
+ nextMessage = message->NextMessage;
+ }
+ delete message;
+ this2->Message1 = nextMessage;
+ }
+
+ gdrv::blit(
+ &render::vscreen,
+ this2->OffsetX,
+ this2->OffsetY,
+ this2->OffsetX + render::vscreen.XPosition,
+ this2->OffsetY + render::vscreen.YPosition,
+ this2->Width,
+ this2->Height);
}
diff --git a/SpaceCadetPinball/TTextBox.h b/SpaceCadetPinball/TTextBox.h
index bd85f56..da54dea 100644
--- a/SpaceCadetPinball/TTextBox.h
+++ b/SpaceCadetPinball/TTextBox.h
@@ -1,15 +1,28 @@
#pragma once
+#include "score.h"
#include "TPinballComponent.h"
+#include "TTextBoxMessage.h"
class TTextBox :
public TPinballComponent
{
public:
- TTextBox(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, true)
- {
- }
+ int OffsetX;
+ int OffsetY;
+ int Width;
+ int Height;
+ int Timer;
+ gdrv_bitmap8* BgBmp;
+ score_msg_font_type* Font;
+ TTextBoxMessage* Message1;
+ TTextBoxMessage* Message2;
- int Message(int a2, float a3) override;
+ TTextBox(TPinballTable* table, int groupIndex);
+ ~TTextBox() override;
+ int Message(int code, float value) override;
void Clear();
void Display(char* text, float time);
+ void Draw();
+
+ static void TimerExpired(int a2, TTextBox* tb);
};
diff --git a/SpaceCadetPinball/TTextBoxMessage.cpp b/SpaceCadetPinball/TTextBoxMessage.cpp
new file mode 100644
index 0000000..7f3b9b5
--- /dev/null
+++ b/SpaceCadetPinball/TTextBoxMessage.cpp
@@ -0,0 +1,37 @@
+#include "pch.h"
+#include "TTextBoxMessage.h"
+#include "memory.h"
+#include "pb.h"
+
+TTextBoxMessage::TTextBoxMessage(char* text, float time)
+{
+ NextMessage = nullptr;
+ Time = time;
+ EndTicks = pb::time_ticks + static_cast(time * 1000.0f);
+ if (text)
+ {
+ const auto textLen = strlen(text) + 1;
+ Text = memory::allocate(textLen);
+ if (Text)
+ strcpy_s(Text, textLen, text);
+ }
+ else
+ Text = nullptr;
+}
+
+TTextBoxMessage::~TTextBoxMessage()
+{
+ if (Text)
+ memory::free(Text);
+}
+
+float TTextBoxMessage::TimeLeft() const
+{
+ return static_cast(EndTicks - pb::time_ticks) * 0.001f;
+}
+
+void TTextBoxMessage::Refresh(float time)
+{
+ this->Time = time;
+ this->EndTicks = pb::time_ticks + static_cast(time * 1000.0f);
+}
diff --git a/SpaceCadetPinball/TTextBoxMessage.h b/SpaceCadetPinball/TTextBoxMessage.h
new file mode 100644
index 0000000..25b71e7
--- /dev/null
+++ b/SpaceCadetPinball/TTextBoxMessage.h
@@ -0,0 +1,14 @@
+#pragma once
+class TTextBoxMessage
+{
+public:
+ TTextBoxMessage* NextMessage;
+ char* Text;
+ float Time;
+ int EndTicks;
+
+ TTextBoxMessage(char* text, float time);
+ ~TTextBoxMessage();
+ float TimeLeft() const;
+ void Refresh(float time);
+};
diff --git a/SpaceCadetPinball/gdrv.cpp b/SpaceCadetPinball/gdrv.cpp
index 0145dc7..7173603 100644
--- a/SpaceCadetPinball/gdrv.cpp
+++ b/SpaceCadetPinball/gdrv.cpp
@@ -1,6 +1,7 @@
#include "pch.h"
#include "gdrv.h"
#include "memory.h"
+#include "pinball.h"
#include "winmain.h"
HPALETTE gdrv::palette_handle = nullptr;
@@ -10,6 +11,9 @@ LOGPALETTEx256 gdrv::current_palette{};
int gdrv::sequence_handle;
HDC gdrv::sequence_hdc;
int gdrv::use_wing = 0;
+int gdrv::grtext_blue = 0;
+int gdrv::grtext_green = 0;
+int gdrv::grtext_red = -1;
int gdrv::init(HINSTANCE hInst, HWND hWnd)
@@ -390,3 +394,30 @@ void gdrv::copy_bitmap_w_transparency(gdrv_bitmap8* dstBmp, int width, int heigh
dstPtr += dstBmp->Stride - width;
}
}
+
+
+void gdrv::grtext_draw_ttext_in_box(LPCSTR text, int xOff, int yOff, int width, int height, int a6)
+{
+ tagRECT rc{};
+
+ HDC dc = GetDC(hwnd);
+ rc.left = xOff;
+ rc.right = width + xOff;
+ rc.top = yOff;
+ rc.bottom = height + yOff;
+ if (grtext_red < 0)
+ {
+ grtext_blue = 255;
+ grtext_green = 255;
+ grtext_red = 255;
+ const char* fontColor = pinball::get_rc_string(189, 0);
+ if (fontColor)
+ sscanf_s(fontColor, "%d %d %d", &grtext_red, &grtext_green, &grtext_blue);
+ }
+ int prevMode = SetBkMode(dc, 1);
+ COLORREF color = SetTextColor(dc, (grtext_red) | (grtext_green << 8) | (grtext_blue << 16));
+ DrawTextA(dc, text, lstrlenA(text), &rc, 0x810u);
+ SetBkMode(dc, prevMode);
+ SetTextColor(dc, color);
+ ReleaseDC(hwnd, dc);
+}
diff --git a/SpaceCadetPinball/gdrv.h b/SpaceCadetPinball/gdrv.h
index 697e84e..d1cd47f 100644
--- a/SpaceCadetPinball/gdrv.h
+++ b/SpaceCadetPinball/gdrv.h
@@ -42,8 +42,6 @@ class gdrv
{
public:
static HPALETTE palette_handle;
- static HINSTANCE hinst;
- static HWND hwnd;
static LOGPALETTEx256 current_palette;
static int sequence_handle;
static HDC sequence_hdc;
@@ -70,5 +68,11 @@ public:
int srcXOff, int srcYOff);
static void copy_bitmap_w_transparency(gdrv_bitmap8* dstBmp, int width, int height, int xOff, int yOff,
gdrv_bitmap8* srcBmp, int srcXOff, int srcYOff);
+ static void grtext_draw_ttext_in_box(LPCSTR text, int xOff, int yOff, int width, int height, int a6);
private:
+ static HWND hwnd;
+ static HINSTANCE hinst;
+ static int grtext_blue;
+ static int grtext_green;
+ static int grtext_red;
};
diff --git a/SpaceCadetPinball/options.cpp b/SpaceCadetPinball/options.cpp
index d9fcb62..d591afa 100644
--- a/SpaceCadetPinball/options.cpp
+++ b/SpaceCadetPinball/options.cpp
@@ -6,6 +6,7 @@
#include "midi.h"
#include "pinball.h"
#include "Sound.h"
+#include "winmain.h"
LPCSTR options::OptionsRegPath;
LPSTR options::OptionsRegPathCur;
@@ -68,7 +69,7 @@ void options::init(HMENU menuHandle)
if (MenuHandle)
{
DeleteMenu(MenuHandle, 0x195u, 0);
- DrawMenuBar(pinball::hwnd_frame);
+ DrawMenuBar(winmain::hwnd_frame);
}
}
memory::free(tmpBuf);
@@ -240,7 +241,7 @@ void options::toggle(UINT uIDCheckItem)
void options::keyboard()
{
- DialogBoxParamA(pinball::hinst, "KEYMAPPER", pinball::hwnd_frame, KeyMapDlgProc, 0);
+ DialogBoxParamA(winmain::hinst, "KEYMAPPER", winmain::hwnd_frame, KeyMapDlgProc, 0);
}
INT_PTR _stdcall options::KeyMapDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
diff --git a/SpaceCadetPinball/pb.cpp b/SpaceCadetPinball/pb.cpp
index 0f766c6..b1e1cca 100644
--- a/SpaceCadetPinball/pb.cpp
+++ b/SpaceCadetPinball/pb.cpp
@@ -58,7 +58,7 @@ int pb::init()
}
render::init(nullptr, zMin, zScaler, tableSize[0], tableSize[1]);
- gdrv::fill_bitmap(&render::vscreen, render::vscreen.Width, render::vscreen.Height, 0, 0, 0xff); // temp
+ gdrv::fill_bitmap(&render::vscreen, render::vscreen.Width, render::vscreen.Height, 0, 0, (char)0xff); // temp
gdrv::copy_bitmap(
&render::vscreen,
backgroundBmp->Width,
@@ -323,7 +323,7 @@ void pb::keydown(int key)
case 'M':
char buffer[20];
sprintf_s(buffer, "%ld", memory::use_total);
- MessageBoxA(pinball::hwnd_frame, buffer, "Mem:", 0x2000u);
+ MessageBoxA(winmain::hwnd_frame, buffer, "Mem:", 0x2000u);
break;
case 'R':
cheat_bump_rank();
diff --git a/SpaceCadetPinball/pinball.cpp b/SpaceCadetPinball/pinball.cpp
index 23001b2..2554b0f 100644
--- a/SpaceCadetPinball/pinball.cpp
+++ b/SpaceCadetPinball/pinball.cpp
@@ -1,6 +1,7 @@
#include "pch.h"
#include "pinball.h"
#include "memory.h"
+#include "winmain.h"
int pinball::quickFlag = 0;
@@ -8,17 +9,14 @@ TTextBox* pinball::InfoTextBox;
TTextBox* pinball::MissTextBox;
char pinball::getRcBuffer[6 * 256];
int pinball::rc_string_slot = 0;
-HINSTANCE pinball::hinst;
char pinball::WindowName[2]{};
int pinball::LeftShift = -1;
int pinball::RightShift = -1;
-HWND pinball::hwnd_frame = nullptr;
-
char* pinball::get_rc_string(int uID, int a2)
{
char* result = &getRcBuffer[256 * rc_string_slot];
- if (!LoadStringA(hinst, uID, &getRcBuffer[256 * rc_string_slot], 255))
+ if (!LoadStringA(winmain::hinst, uID, &getRcBuffer[256 * rc_string_slot], 255))
*result = 0;
if (++rc_string_slot >= 6)
rc_string_slot = 0;
@@ -28,7 +26,7 @@ char* pinball::get_rc_string(int uID, int a2)
int pinball::get_rc_int(int uID, int* dst)
{
char buffer[50];
- int result = LoadStringA(hinst, uID, buffer, 255);
+ int result = LoadStringA(winmain::hinst, uID, buffer, 255);
if (!result)
return result;
*dst = atoi(buffer);
diff --git a/SpaceCadetPinball/pinball.h b/SpaceCadetPinball/pinball.h
index c794450..403a43b 100644
--- a/SpaceCadetPinball/pinball.h
+++ b/SpaceCadetPinball/pinball.h
@@ -7,11 +7,9 @@ public:
static int quickFlag;
static TTextBox* InfoTextBox;
static TTextBox* MissTextBox;
- static HINSTANCE hinst;
static char WindowName[2];
static int RightShift;
static int LeftShift;
- static HWND hwnd_frame;
static char* get_rc_string(int uID, int a2);
static int get_rc_int(int uID, int* dst);
diff --git a/SpaceCadetPinball/score.cpp b/SpaceCadetPinball/score.cpp
index e6c42ab..5f5a2eb 100644
--- a/SpaceCadetPinball/score.cpp
+++ b/SpaceCadetPinball/score.cpp
@@ -4,6 +4,7 @@
#include "memory.h"
#include "partman.h"
+score_msg_font_type* score::msg_fontp;
int score::init()
{
diff --git a/SpaceCadetPinball/score.h b/SpaceCadetPinball/score.h
index 50e22eb..0424d9f 100644
--- a/SpaceCadetPinball/score.h
+++ b/SpaceCadetPinball/score.h
@@ -22,9 +22,15 @@ struct scoreStruct
char* Bitmap8Bit10;
};
+struct score_msg_font_type
+{
+
+};
+
class score
{
public:
+ static score_msg_font_type* msg_fontp;
static int init();
static scoreStruct* create(LPCSTR fieldName, gdrv_bitmap8* renderBgBmp);
static scoreStruct* dup(scoreStruct* score, int scoreIndex);
diff --git a/SpaceCadetPinball/timer.cpp b/SpaceCadetPinball/timer.cpp
index b277614..636ee58 100644
--- a/SpaceCadetPinball/timer.cpp
+++ b/SpaceCadetPinball/timer.cpp
@@ -36,3 +36,13 @@ int timer::init(int count)
timer_struct.buffer2 = buf;
return 0;
}
+
+int timer::kill(int timer)
+{
+ return 0;
+}
+
+int timer::set(float time, int caller, int callback)
+{
+ return 0;
+}
diff --git a/SpaceCadetPinball/timer.h b/SpaceCadetPinball/timer.h
index 3c596a1..0e427e5 100644
--- a/SpaceCadetPinball/timer.h
+++ b/SpaceCadetPinball/timer.h
@@ -14,6 +14,8 @@ class timer
{
public:
static int init(int count);
+ static int kill(int timer);
+ static int set(float time, int caller, int callback);
private:
static timer_struct timer_struct;
diff --git a/SpaceCadetPinball/winmain.cpp b/SpaceCadetPinball/winmain.cpp
index 1aa2b94..d1d046e 100644
--- a/SpaceCadetPinball/winmain.cpp
+++ b/SpaceCadetPinball/winmain.cpp
@@ -9,15 +9,30 @@
#include "pb.h"
#include "Sound.h"
-int winmain::return_value = 0, winmain::bQuit = 0, winmain::activated;
-DWORD winmain::then, winmain::now;
-UINT winmain::iFrostUniqueMsg;
-gdrv_bitmap8 winmain::gfr_display{};
-int winmain::DispFrameRate = 1, winmain::DispGRhistory = 1, winmain::single_step = 0;
-int winmain::has_focus = 1, winmain::last_mouse_x, winmain::last_mouse_y, winmain::mouse_down, winmain::no_time_loss;
-char winmain::DatFileName[300]{};
+HINSTANCE winmain::hinst = nullptr;
+HWND winmain::hwnd_frame = nullptr;
HCURSOR winmain::mouse_hsave;
+int winmain::return_value = 0;
+int winmain::bQuit = 0;
+int winmain::activated;
+int winmain::DispFrameRate = 1;
+int winmain::DispGRhistory = 0;
+int winmain::single_step = 0;
+int winmain::has_focus = 1;
+int winmain::last_mouse_x;
+int winmain::last_mouse_y;
+int winmain::mouse_down;
+int winmain::no_time_loss;
+
+DWORD winmain::then;
+DWORD winmain::now;
+UINT winmain::iFrostUniqueMsg;
+
+gdrv_bitmap8 winmain::gfr_display{};
+char winmain::DatFileName[300]{};
+
+
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
return winmain::WinMain(hInstance, hPrevInstance, lpCmdLine, nShowCmd);
@@ -41,7 +56,7 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
}
options::set_int(regSpaceCadet, "Table Version", 1u);
- GetModuleFileNameA(pinball::hinst, tmpBuf, 0x1F4u);
+ GetModuleFileNameA(hinst, tmpBuf, 0x1F4u);
options::set_string(regSpaceCadet, "Table Exe", tmpBuf);
options::set_string(regSpaceCadet, "Table Name", pinball::get_rc_string(169, 0));
options::set_string(nullptr, "Last Table Played", regSpaceCadet);
@@ -92,7 +107,7 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
--memory::critical_allocation;
pinball::quickFlag = strstr(lpCmdLine, "-quick") != nullptr;
- pinball::hinst = hInstance;
+ hinst = hInstance;
options::get_string(regSpaceCadet, "Pinball Data", DatFileName, pinball::get_rc_string(168, 0), 300);
iFrostUniqueMsg = RegisterWindowMessageA("PinballThemeSwitcherUniqueMsgString");
@@ -132,7 +147,7 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
lstrcpyA(windowName, pinball::get_rc_string(38, 0));
windowHandle = CreateWindowExA(0, windowClass, windowName, 0x3CA0000u, 0, 0, 640, 480, nullptr, nullptr, hInstance,
nullptr);
- pinball::hwnd_frame = windowHandle;
+ hwnd_frame = windowHandle;
if (!windowHandle)
{
PostQuitMessage(0);
@@ -150,9 +165,9 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
options::menu_check(0x193u, 1);
}
- ShowWindow(pinball::hwnd_frame, nShowCmd);
+ ShowWindow(hwnd_frame, nShowCmd);
fullscrn::set_screen_mode(options::Options.FullScreen);
- UpdateWindow(pinball::hwnd_frame);
+ UpdateWindow(hwnd_frame);
/*if (tmpBuf) //Close splash
{
@@ -163,8 +178,8 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
pinball::adjust_priority(options::Options.PriorityAdj);
const auto startTime = timeGetTime();
MSG wndMessage{};
- while (timeGetTime() >= startTime && timeGetTime() - startTime < 2000)
- PeekMessageA(&wndMessage, pinball::hwnd_frame, 0, 0, 1u);
+ while (timeGetTime() >= startTime && timeGetTime() - startTime < 0)// Don't wait for now, was 2000
+ PeekMessageA(&wndMessage, hwnd_frame, 0, 0, 1u);
if (strstr(lpCmdLine, "-demo"))
pb::toggle_demo();
@@ -185,7 +200,7 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
{
char buf[60];
sprintf_s(buf, "Frames/sec = %02.02f", 300.0f / (static_cast(curTime - prevTime) * 0.001f));
- SetWindowTextA(pinball::hwnd_frame, buf);
+ SetWindowTextA(hwnd_frame, buf);
if (DispGRhistory)
{
@@ -326,10 +341,10 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
pb::window_size(&width, &height);
auto prevCursor = SetCursor(LoadCursorA(nullptr, (LPCSTR)IDC_WAIT));
- gdrv::init(pinball::hinst, hWnd);
+ gdrv::init(hinst, hWnd);
auto voiceCount = options::get_int(nullptr, "Voices", 8);
- if (!Sound::Init(pinball::hinst, voiceCount, nullptr))
+ if (!Sound::Init(hinst, voiceCount, nullptr))
options::menu_set(0xC9u, 0);
Sound::Activate();
@@ -417,10 +432,10 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
case VK_ESCAPE:
if (options::Options.FullScreen)
options::toggle(0x193u);
- SendMessageA(pinball::hwnd_frame, 0x112u, 0xF020u, 0);
+ SendMessageA(hwnd_frame, 0x112u, 0xF020u, 0);
break;
case VK_F1:
- help_introduction(pinball::hinst, hWnd);
+ help_introduction(hinst, hWnd);
break;
case VK_F2:
new_game();
@@ -465,6 +480,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
case SC_MOVE:
if (fullscrn::screen_mode)
return 0;
+ break;
case SC_MINIMIZE:
if (!single_step)
pause();
@@ -513,20 +529,20 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
"%s %s%lX %s%lX",
tmpBuf,
"select=",
- (int)pinball::hwnd_frame,
+ (int)hwnd_frame,
"confirm=",
- (int)pinball::hwnd_frame
- * (int)pinball::hwnd_frame
- * (int)pinball::hwnd_frame
- * (int)pinball::hwnd_frame
- * (int)pinball::hwnd_frame
- * (int)pinball::hwnd_frame
- * (int)pinball::hwnd_frame);
+ (int)hwnd_frame
+ * (int)hwnd_frame
+ * (int)hwnd_frame
+ * (int)hwnd_frame
+ * (int)hwnd_frame
+ * (int)hwnd_frame
+ * (int)hwnd_frame);
if (static_cast(WinExec(cmdLine, 5u)) < 32)
{
auto caption = pinball::get_rc_string(170, 0);
auto text = pinball::get_rc_string(171, 0);
- MessageBoxA(pinball::hwnd_frame, text, caption, 0x2010u);
+ MessageBoxA(hwnd_frame, text, caption, 0x2010u);
}
memory::free(tmpBuf);
}
@@ -547,7 +563,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
case 301:
if (!single_step)
pause();
- help_introduction(pinball::hinst, hWnd);
+ help_introduction(hinst, hWnd);
return DefWindowProcA(hWnd, Msg, wParam, lParam);
case 0x6A:
pb::end_game();
@@ -572,7 +588,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
case 0x66u:
if (!single_step)
pause();
- a_dialog(pinball::hinst, hWnd);
+ a_dialog(hinst, hWnd);
return DefWindowProcA(hWnd, Msg, wParam, lParam);
case 0x67u:
if (!single_step)
@@ -655,7 +671,7 @@ int winmain::ProcessWindowMessages()
}
return 1;
}
- GetMessageA(&Msg, pinball::hwnd_frame, 0, 0);
+ GetMessageA(&Msg, hwnd_frame, 0, 0);
TranslateMessage(&Msg);
DispatchMessageA(&Msg);
if (Msg.message == 18)
diff --git a/SpaceCadetPinball/winmain.h b/SpaceCadetPinball/winmain.h
index b916b28..83019ed 100644
--- a/SpaceCadetPinball/winmain.h
+++ b/SpaceCadetPinball/winmain.h
@@ -6,6 +6,8 @@ class winmain
public:
static char DatFileName[300];
static int single_step;
+ static HINSTANCE hinst;
+ static HWND hwnd_frame;
static int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);
static LRESULT CALLBACK message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);