1
0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-11-07 03:12:58 +01:00

winmain v2.

fullscrn, pb v1.
This commit is contained in:
oz 2020-11-06 16:56:32 +03:00
parent 473ed6b9d9
commit 7db64ae1c6
21 changed files with 960 additions and 312 deletions

View File

@ -136,6 +136,7 @@ int main2(int argc, const char* argv[])
}
free(fdat);
return 0;
}

View File

@ -0,0 +1,6 @@
#include "pch.h"
#include "Sound.h"
void Sound::Enable(int a1, int a2, int a3)
{
}

View File

@ -0,0 +1,6 @@
#pragma once
class Sound
{public:
static void Enable(int a1, int a2, int a3);
};

View File

@ -19,7 +19,7 @@ int main()
pinball::hinst = GetModuleHandleA(nullptr);
char cmdLine[1];
WinMain(pinball::hinst, 0, cmdLine, 0);
WinMain(pinball::hinst, 0, cmdLine, 10);
objlist_class d = objlist_class(2, 4);
for (int i = 0; i < 100; i++)

View File

@ -55,6 +55,49 @@ END
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
MENU_1 MENU
BEGIN
POPUP "&Game"
BEGIN
MENUITEM "&New Game\tF2", 101
MENUITEM "&Launch Ball", 401
MENUITEM "&Pause/Resume Game\tF3", 402
MENUITEM SEPARATOR
MENUITEM "&High Scores...", 103
MENUITEM "&Demo", 404
MENUITEM "E&xit", 105
END
POPUP "&Options"
BEGIN
MENUITEM "&Full Screen\tF4", 403
MENUITEM "Select &Table", 405
POPUP "Select &Players"
BEGIN
MENUITEM "&1 Player", 408
MENUITEM "&2 Players", 409
MENUITEM "&3 Players", 410
MENUITEM "&4 Players", 411
END
MENUITEM SEPARATOR
MENUITEM "&Sounds", 201
MENUITEM "&Music", 202
MENUITEM SEPARATOR
MENUITEM "P&layer Controls...\tF8", 406
END
POPUP "&Help"
BEGIN
MENUITEM "&Help Topics\tF1", 301
MENUITEM SEPARATOR
MENUITEM "&About Pinball", 102
END
END
/////////////////////////////////////////////////////////////////////////////
//
// String Table
@ -78,6 +121,10 @@ BEGIN
IDS_STRING114 "Hyperspace Bonus Available"
IDS_STRING115 "Jackpot Awarded\n%ld"
IDS_STRING116 "Jackpot Activated"
END
STRINGTABLE
BEGIN
IDS_STRING117 "Multiball"
IDS_STRING118 "Ramp Bonus Awarded"
IDS_STRING119 "Light Added"
@ -94,6 +141,10 @@ BEGIN
IDS_STRING130 "Player 4"
IDS_STRING131 "Demo\nPlayer 1"
IDS_STRING132 "Demo\nPlayer 2"
END
STRINGTABLE
BEGIN
IDS_STRING133 "Demo\nPlayer 3"
IDS_STRING134 "Demo\nPlayer 4"
IDS_STRING135 "Game Over"
@ -110,6 +161,10 @@ BEGIN
IDS_STRING146 "Gravity Well"
IDS_STRING147 "Time Warp Forward"
IDS_STRING148 "Time Warp Backward"
END
STRINGTABLE
BEGIN
IDS_STRING149 "Maelstrom!"
IDS_STRING150 "Wormhole"
IDS_STRING151 "Awaiting Deployment"
@ -126,6 +181,10 @@ BEGIN
IDS_STRING162 "Launch Training"
IDS_STRING163 "Re-Entry Training"
IDS_STRING164 "Science"
END
STRINGTABLE
BEGIN
IDS_STRING165 "Stray Comet"
IDS_STRING166 "Black Hole"
IDS_STRING167 "Space Radiation"
@ -142,6 +201,10 @@ BEGIN
IDS_STRING178 "Mission Accepted\n%ld"
IDS_STRING179 "Mission Completed\n%ld"
IDS_STRING180 "%s Mission Selected"
END
STRINGTABLE
BEGIN
IDS_STRING181 "Black Hole\n%ld"
IDS_STRING182 "Gravity Normalized\n%ld"
IDS_STRING183 "Gravity Well\n%ld"
@ -158,6 +221,10 @@ BEGIN
IDS_STRING194 "Wormhole Opened"
IDS_STRING195 "Crash Bonus\n%ld"
IDS_STRING196 "Replay Ball"
END
STRINGTABLE
BEGIN
IDS_STRING197 "Re-Deploy"
IDS_STRING198 "Player 1 Shoot Again"
IDS_STRING199 "Player 2 Shoot Again"
@ -174,6 +241,10 @@ BEGIN
IDS_STRING210 "Mission Aborted"
IDS_STRING211 "Launches Left: %d"
IDS_STRING212 "Launch Training Passed"
END
STRINGTABLE
BEGIN
IDS_STRING213 "Re-Entries Left: %d"
IDS_STRING214 "Re-Entry Training Passed"
IDS_STRING215 "Drop Targets\nLeft: %d"
@ -190,6 +261,10 @@ BEGIN
IDS_STRING226 "Targets\nLeft: %d"
IDS_STRING227 "Xenomorphs Destroyed"
IDS_STRING228 "Upgrade Flags"
END
STRINGTABLE
BEGIN
IDS_STRING229 "Hyperspace Launch"
IDS_STRING230 "Survivors Rescued"
IDS_STRING231 "Aliens Repelled"
@ -206,6 +281,10 @@ BEGIN
IDS_STRING242 "Plague Eliminated"
IDS_STRING243 "Hit Yellow Wormhole"
IDS_STRING244 "Hit Red Wormhole"
END
STRINGTABLE
BEGIN
IDS_STRING245 "Hit Green Wormhole"
IDS_STRING246 "Plans Recovered"
IDS_STRING247 "Rebound Hits\nLeft: %d"
@ -221,6 +300,10 @@ BEGIN
IDS_STRING257 "pinball.mid"
IDS_STRING258 "1 UseBitmapFont"
IDS_STRING259 "90 Left Flipper Key"
END
STRINGTABLE
BEGIN
IDS_STRING260 "191 Right Flipper Key"
IDS_STRING261 "32 Plunger Key"
IDS_STRING262 "88 Bump Left Key"
@ -237,6 +320,10 @@ BEGIN
IDS_STRING273 "Promotion to %s"
IDS_STRING274 "Demotion to %s"
IDS_STRING275 "Upgrade Attack Bumpers"
END
STRINGTABLE
BEGIN
IDS_STRING276 "Fill Left Hazard Banks"
IDS_STRING277 "HIGH SCORE"
IDS_STRING278 "pinball.chm"

View File

@ -96,7 +96,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>Comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Comctl32.lib;Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -154,15 +154,19 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="DatParser.h" />
<ClInclude Include="fullscrn.h" />
<ClInclude Include="loader.h" />
<ClInclude Include="memory.h" />
<ClInclude Include="objlist_class.h" />
<ClInclude Include="options.h" />
<ClInclude Include="partman.h" />
<ClInclude Include="pb.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="pinball.h" />
<ClInclude Include="render.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="score.h" />
<ClInclude Include="Sound.h" />
<ClInclude Include="TBall.h" />
<ClInclude Include="TBlocker.h" />
<ClInclude Include="TBumper.h" />
@ -198,11 +202,13 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="DatParser.cpp" />
<ClCompile Include="fullscrn.cpp" />
<ClCompile Include="loader.cpp" />
<ClCompile Include="memory.cpp" />
<ClCompile Include="objlist_class.cpp" />
<ClCompile Include="options.cpp" />
<ClCompile Include="partman.cpp" />
<ClCompile Include="pb.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
@ -210,7 +216,9 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="pinball.cpp" />
<ClCompile Include="render.cpp" />
<ClCompile Include="score.cpp" />
<ClCompile Include="Sound.cpp" />
<ClCompile Include="SpaceCadetPinball.cpp" />
<ClCompile Include="TBall.cpp" />
<ClCompile Include="TBlocker.cpp" />

View File

@ -147,6 +147,18 @@
<ClInclude Include="options.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Sound.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pb.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="render.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="fullscrn.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
@ -272,6 +284,18 @@
<ClCompile Include="options.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Sound.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pb.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="render.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="fullscrn.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Natvis Include="NatvisFile.natvis" />

View File

@ -7,7 +7,7 @@
#include "TPinballComponent.h"
#include "TPlunger.h"
class TPinballTable:TPinballComponent
class TPinballTable : public TPinballComponent
{
public:
TPinballTable();
@ -97,4 +97,3 @@ public:
int UnknownP82;
int UnknownP83;
};

View File

@ -0,0 +1,159 @@
#include "pch.h"
#include "fullscrn.h"
int fullscrn::screen_mode;
HWND fullscrn::hWnd;
tagRECT fullscrn::PubRect1;
int fullscrn::fullscrn_flag1;
int fullscrn::display_changed;
int fullscrn::ChangeDisplay, fullscrn::SmthFullScrnFlag2;
int fullscrn::trick;
int fullscrn::MenuEnabled;
HMENU fullscrn::MenuHandle;
int fullscrn::xDest, fullscrn::yDest;
int fullscrn::set_screen_mode(int isFullscreen)
{
int result = isFullscreen;
if (isFullscreen == screen_mode)
return result;
screen_mode = isFullscreen;
if (isFullscreen)
{
if (IsWindowVisible(hWnd))
GetWindowRect(hWnd, &PubRect1);
enableFullscreen();
BYTE1(fullscrn_flag1) |= 0x80u;
InvalidateRect(hWnd, nullptr, 1);
set_menu_mode(0);
result = disableWindowFlagsDisDlg();
}
else
{
disableFullscreen();
BYTE1(fullscrn_flag1) |= 0x80u;
InvalidateRect(hWnd, nullptr, 1);
set_menu_mode(1);
result = RedrawWindow(nullptr, nullptr, nullptr, 0x185u);
}
return result;
}
int fullscrn::disableWindowFlagsDisDlg()
{
long style = GetWindowLongA(hWnd, -16);
return SetWindowLongA(hWnd, -16, style & 0xFF3FFFFF);
}
int fullscrn::setWindowFlagsDisDlg()
{
int style = GetWindowLongA(hWnd, -16);
return SetWindowLongA(hWnd, -16, style | 0xC00000);
}
int fullscrn::enableFullscreen()
{
tagRECT Rect{}; // [esp+Ch] [ebp-B0h]
DEVMODEA DevMode{}; // [esp+1Ch] [ebp-A0h]
if (ChangeDisplay && !display_changed)
{
DevMode.dmSize = 156;
DevMode.dmFields = 1835008;
DevMode.dmPelsWidth = 640;
DevMode.dmPelsHeight = 480;
DevMode.dmBitsPerPel = 8;
disableWindowFlagsDisDlg();
if (trick)
{
GetWindowRect(GetDesktopWindow(), &Rect);
SetWindowPos(hWnd, (HWND)((int)HWND_MESSAGE | 0x2), 0, 0, Rect.right - Rect.left + 1,
Rect.bottom - Rect.top + 1, 8u);
}
SmthFullScrnFlag2 = 1;
LONG changeDispResult = ChangeDisplaySettingsA(&DevMode, 4u);
if (changeDispResult == 1)
{
BYTE2(DevMode.dmFields) &= 0xFBu;
SmthFullScrnFlag2 = 1;
changeDispResult = ChangeDisplaySettingsA(&DevMode, 4u);
}
display_changed = changeDispResult == 0;
if (changeDispResult == 0)
return 1;
}
GetWindowRect(GetDesktopWindow(), &Rect);
disableWindowFlagsDisDlg();
SetWindowPos(hWnd, (HWND)0xFFFFFFFE, 0, 0, Rect.right - Rect.left + 1, Rect.bottom - Rect.top + 1, 8u);
return 0;
}
int fullscrn::disableFullscreen()
{
if (display_changed)
{
display_changed = 0;
SmthFullScrnFlag2 = 1;
ChangeDisplaySettingsA(nullptr, 4u);
if (trick)
SetWindowPos(hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x13u);
}
setWindowFlagsDisDlg();
SetWindowPos(
hWnd,
nullptr,
PubRect1.left,
PubRect1.top,
PubRect1.right - PubRect1.left,
PubRect1.bottom - PubRect1.top,
0x14u);
return 0;
}
bool fullscrn::set_menu_mode(int menuEnabled)
{
BOOL result; // eax
MenuEnabled = menuEnabled;
GetWindowCenter();
if (MenuEnabled)
{
fullscrn_flag1 |= 2u;
InvalidateRect(hWnd, nullptr, 1);
result = SetMenu(hWnd, MenuHandle);
}
else
{
fullscrn_flag1 |= 1u;
InvalidateRect(hWnd, nullptr, 1);
result = SetMenu(hWnd, nullptr);
}
return result;
}
void fullscrn::GetWindowCenter()
{
int yDestLoc; // eax
HWND v1; // eax
struct tagRECT Rect; // [esp+4h] [ebp-10h]
int dword_1025094 = 0, dword_1025098 = 0; // tmp, from render
if (screen_mode)
{
v1 = GetDesktopWindow();
GetWindowRect(v1, &Rect);
xDest = (Rect.right - dword_1025094 - Rect.left) / 2;
yDestLoc = (Rect.bottom - dword_1025098 - Rect.top) / 2;
}
else
{
xDest = 0;
yDestLoc = GetSystemMetrics(15);
}
yDest = yDestLoc;
if (MenuEnabled)
yDest -= GetSystemMetrics(15);
}

View File

@ -0,0 +1,31 @@
#pragma once
#define BYTEn(x, n) (*((unsigned char*)&(x)+n))
#define BYTE1(x) BYTEn(x, 1) // byte 1 (counting from 0)
#define BYTE2(x) BYTEn(x, 2)
class fullscrn
{
public:
static int screen_mode;
static HWND hWnd;
static tagRECT PubRect1;
static int fullscrn_flag1;
static int display_changed;
static int ChangeDisplay, SmthFullScrnFlag2;
static int trick;
static int set_screen_mode(int isFullscreen);
private :
static int MenuEnabled;
static HMENU MenuHandle;
static int xDest, yDest;
static void GetWindowCenter();
static int disableWindowFlagsDisDlg();
static int setWindowFlagsDisDlg();
static int enableFullscreen();
static int disableFullscreen();
static bool set_menu_mode(int menuEnabled);
};

View File

@ -1,9 +1,76 @@
#include "pch.h"
#include "options.h"
#include "memory.h"
#include "pinball.h"
#include "Sound.h"
LPCSTR options::OptionsRegPath;
LPSTR options::OptionsRegPathCur;
HMENU options::MenuHandle;
optionsStruct options::Options;
void options::init(HMENU menuHandle)
{
MenuHandle = menuHandle;
Options.Sounds = 1;
Options.Music = 0;
Options.FullScreen = 0;
Options.Average = 5;
Options.PriorityAdj = 2;
Options.LeftFlipperKey2 = 90;
Options.RightFlipperKey2 = 191;
Options.PlungerKey2 = 32;
Options.LeftTableBumpKey2 = 88;
Options.RightTableBumpKey2 = 190;
Options.BottomTableBumpKey2 = 38;
pinball::get_rc_int(159, &Options.LeftFlipperKey2);
pinball::get_rc_int(160, &Options.RightFlipperKey2);
pinball::get_rc_int(161, &Options.PlungerKey2);
pinball::get_rc_int(162, &Options.LeftTableBumpKey2);
pinball::get_rc_int(163, &Options.RightTableBumpKey2);
pinball::get_rc_int(164, &Options.BottomTableBumpKey2);
Options.LeftFlipperKey = Options.LeftFlipperKey2;
Options.RightFlipperKey = Options.RightFlipperKey2;
Options.PlungerKey = Options.PlungerKey2;
Options.LeftTableBumpKey = Options.LeftTableBumpKey2;
Options.RightTableBumpKey = Options.RightTableBumpKey2;
Options.Players = 1;
Options.BottomTableBumpKey = Options.BottomTableBumpKey2;
Options.Sounds = get_int(nullptr, "Sounds", Options.Sounds);
Options.Music = get_int(nullptr, "Music", Options.Music);
Options.Average = get_int(nullptr, "Average", Options.Average);
Options.FullScreen = get_int(nullptr, "FullScreen", Options.FullScreen);
Options.PriorityAdj = get_int(nullptr, "Priority_Adjustment", Options.PriorityAdj);
Options.Players = get_int(nullptr, "Players", Options.Players);
Options.LeftFlipperKey = get_int(nullptr, "Left Flippper key", Options.LeftFlipperKey);
Options.RightFlipperKey = get_int(nullptr, "Right Flipper key", Options.RightFlipperKey);
Options.PlungerKey = get_int(nullptr, "Plunger key", Options.PlungerKey);
Options.LeftTableBumpKey = get_int(nullptr, "Left Table Bump key", Options.LeftTableBumpKey);
Options.RightTableBumpKey = get_int(nullptr, "Right Table Bump key", Options.RightTableBumpKey);
Options.BottomTableBumpKey = get_int(nullptr, "Bottom Table Bump key", Options.BottomTableBumpKey);
menu_check(0xC9u, Options.Sounds);
Sound::Enable(0, 7, Options.Sounds);
menu_check(0xCAu, Options.Music);
menu_check(0x193u, Options.FullScreen);
menu_check(0x198u, Options.Players == 1);
menu_check(0x199u, Options.Players == 2);
menu_check(0x19Au, Options.Players == 3);
menu_check(0x19Bu, Options.Players == 4);
auto tmpBuf = memory::allocate(0x1F4u);
if (tmpBuf)
{
get_string(nullptr, "Shell Exe", tmpBuf, pinball::WindowName, 500);
if (!*tmpBuf)
{
if (MenuHandle)
{
DeleteMenu(MenuHandle, 0x195u, 0);
DrawMenuBar(pinball::hwnd_frame);
}
}
memory::free(tmpBuf);
}
}
void options::path_init(LPCSTR regPath)
{
@ -116,3 +183,12 @@ void options::set_string(LPCSTR optPath, LPCSTR lpValueName, LPCSTR value)
path_free();
}
}
HMENU options::menu_check(UINT uIDCheckItem, int value)
{
HMENU result = MenuHandle;
if (MenuHandle)
result = (HMENU)CheckMenuItem(MenuHandle, uIDCheckItem, value != 0 ? 8 : 0);
return result;
}

View File

@ -1,16 +1,45 @@
#pragma once
struct __declspec(align(4)) optionsStruct
{
int Sounds;
int Music;
int Average;
int FullScreen;
int PriorityAdj;
int Players;
int LeftFlipperKey;
int RightFlipperKey;
int PlungerKey;
int LeftTableBumpKey;
int RightTableBumpKey;
int BottomTableBumpKey;
int LeftFlipperKey2;
int RightFlipperKey2;
int PlungerKey2;
int LeftTableBumpKey2;
int RightTableBumpKey2;
int BottomTableBumpKey2;
};
class options
{
public:
static void init(HMENU menuHandle);
static void path_init(LPCSTR regPath);
static void path_uninit();
static int get_int(LPCSTR optPath, LPCSTR lpValueName, int defaultValue);
static void set_int(LPCSTR optPath, LPCSTR lpValueName, int data);
static void get_string(LPCSTR optPath, LPCSTR lpValueName, LPSTR lpString1, LPCSTR lpString2, int iMaxLength);
static void set_string(LPCSTR optPath, LPCSTR lpValueName, LPCSTR value);
static HMENU menu_check(UINT uIDCheckItem, int value);
static optionsStruct Options;
private:
static LPCSTR OptionsRegPath;
static LPSTR OptionsRegPathCur;
static LPCSTR path(LPCSTR regPath);
static void path_free();
static HMENU MenuHandle;
};

19
SpaceCadetPinball/pb.cpp Normal file
View File

@ -0,0 +1,19 @@
#include "pch.h"
#include "pb.h"
#include "render.h"
TPinballTable* pb::MainTable = nullptr;
void pb::reset_table()
{
if (MainTable)
MainTable->Message(1024, 0.0);
}
void pb::firsttime_setup()
{
render::blit = 0;
render::update();
render::blit = 1;
}

12
SpaceCadetPinball/pb.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include "TPinballTable.h"
class pb
{
public:
static void reset_table();
static void firsttime_setup();
private:
static TPinballTable* MainTable;
};

View File

@ -12,6 +12,11 @@ int pinball::rc_string_slot = 0;
HINSTANCE pinball::hinst;
char pinball::WindowName[2]{};
char pinball::DatFileName[300]{};
int pinball::LeftShift = -1;
int pinball::RightShift = -1;
HWND pinball::hwnd_frame = nullptr;
int pinball::has_focus = 1;
int pinball::single_step = 0;
char* pinball::get_rc_string(int uID, int a2)
@ -23,3 +28,82 @@ char* pinball::get_rc_string(int uID, int a2)
rc_string_slot = 0;
return result;
}
int pinball::get_rc_int(int uID, int* dst)
{
char buffer[50];
int result = LoadStringA(pinball::hinst, uID, buffer, 255);
if (!result)
return result;
*dst = atoi(buffer);
return 1;
}
void pinball::FindShiftKeys()
{
signed int i; // esi
int rightShift; // eax
CHAR stringBuf[10]; // [esp+Ch] [ebp-18h]
RightShift = -1;
LeftShift = -1;
for (i = 0; i < 256; ++i)
{
if (MapVirtualKeyA(i, 1u) == 16)
{
LeftShift = i;
break;
}
}
while (++i < 256)
{
if (MapVirtualKeyA(i, 1u) == 16)
{
RightShift = i;
break;
}
}
if (!GetKeyNameTextA(LeftShift << 16, stringBuf, 19) || !_strnicmp(stringBuf, "right", 5u))
{
rightShift = RightShift;
}
else
{
rightShift = LeftShift;
LeftShift = RightShift;
RightShift = rightShift;
}
if (GetKeyNameTextA(rightShift << 16, stringBuf, 19))
{
if (_strnicmp(stringBuf, "left", 4u) != 0)
{
auto tmp = LeftShift;
LeftShift = RightShift;
RightShift = tmp;
}
}
}
HANDLE pinball::adjust_priority(int priority)
{
HANDLE result = GetCurrentThread();
switch (priority)
{
case -2:
return (HANDLE)SetThreadPriority(result, -2);
case -1:
return (HANDLE)SetThreadPriority(result, -1);
case 0:
return (HANDLE)SetThreadPriority(result, 0);
case 1:
return (HANDLE)SetThreadPriority(result, 1);
case 2:
return (HANDLE)SetThreadPriority(result, 2);
case 3:
result = (HANDLE)SetThreadPriority(result, 15);
break;
}
return result;
}

View File

@ -11,7 +11,16 @@ public:
static HINSTANCE hinst;
static char WindowName[2];
static char DatFileName[300];
static int RightShift;
static int LeftShift;
static HWND hwnd_frame;
static int has_focus;
static int single_step;
static char* get_rc_string(int uID, int a2);
static int get_rc_int(int uID, int* dst);
static void FindShiftKeys();
static HANDLE adjust_priority(int priority);
private:
static char getRcBuffer[256 * 6];
static int rc_string_slot;

View File

@ -0,0 +1,8 @@
#include "pch.h"
#include "render.h"
int render::blit = 0;
void render::update()
{
}

View File

@ -0,0 +1,8 @@
#pragma once
class render
{
public:
static int blit;
static void update();
};

View File

@ -192,13 +192,12 @@
#define IDS_STRING288 188
#define IDS_STRING289 189
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_RESOURCE_VALUE 201
#define _APS_NEXT_COMMAND_VALUE 40002
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif

View File

@ -1,17 +1,13 @@
#include "pch.h"
#include "winmain.h"
#include "fullscrn.h"
#include "memory.h"
#include "pinball.h"
#include "options.h"
#include "pb.h"
int iFrostUniqueMsg;
//HWND, UINT, WPARAM, LPARAM
//typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM LPARAM)
{
return 0;
}
int iFrostUniqueMsg, return_value = 0, bQuit = 0;
int check_expiration_date()
{
@ -86,7 +82,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
}
--memory::critical_allocation;
pinball::quickFlag = strstr(lpCmdLine, "-quick") != 0;
pinball::quickFlag = strstr(lpCmdLine, "-quick") != nullptr;
pinball::hinst = hInstance;
options::get_string(regSpaceCadet, "Pinball Data", pinball::DatFileName, pinball::get_rc_string(168, 0), 300);
@ -106,19 +102,104 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
picce.dwICC = 5885;
InitCommonControlsEx(&picce);
WNDCLASSA WndClass;
auto windowClass = pinball::get_rc_string(167, 0);
WNDCLASSA WndClass{};
WndClass.style = 4104;
WndClass.lpfnWndProc = message_handler;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hInstance = hInstance;
WndClass.hIcon = LoadIconA(hInstance, "ICON_1");
WndClass.hCursor = LoadCursorA(0, (LPCSTR)0x7F00);
WndClass.hCursor = LoadCursorA(nullptr, (LPCSTR)0x7F00);
WndClass.hbrBackground = (HBRUSH)16;
WndClass.lpszMenuName = "MENU_1";
WndClass.lpszClassName = pinball::get_rc_string(167, 0);
//auto tmpBuf = splash_screen((int)hInstance, "splash_bitmap", "splash_bitmap");
WndClass.lpszClassName = windowClass;
//auto tmpBuf = splash_screen((int)hInstance, "splash_bitmap", "splash_bitmap"); // No splash for now
RegisterClassA(&WndClass);
pinball::FindShiftKeys();
char windowName[40];
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;
if (!windowHandle)
{
PostQuitMessage(0);
return 0;
}
auto menuHandle = GetMenu(windowHandle);
options::init(menuHandle);
pb::reset_table();
pb::firsttime_setup();
if (strstr(lpCmdLine, "-fullscreen"))
{
options::Options.FullScreen = 1;
options::menu_check(0x193u, 1);
}
ShowWindow(pinball::hwnd_frame, nShowCmd);
fullscrn::set_screen_mode(options::Options.FullScreen);
UpdateWindow(pinball::hwnd_frame);
/*if (tmpBuf) //Close splash
{
splash_hide(tmpBuf);
splash_destroy(tmpBuf);
}*/
pinball::adjust_priority(options::Options.PriorityAdj);
auto getTimeFunc = timeGetTime;
const auto startTime = timeGetTime();
MSG wndMessage{};
while (timeGetTime() >= startTime && timeGetTime() - startTime < 2000)
PeekMessageA(&wndMessage, pinball::hwnd_frame, 0, 0, 1u);
while (true)
{
if (!ProcessWindowMessages() || bQuit)
break;
Sleep(8);
}
return return_value;
}
LRESULT CALLBACK message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
return DefWindowProcA(hWnd, Msg, wParam, lParam);
}
int ProcessWindowMessages()
{
MSG Msg{}; // [esp+8h] [ebp-1Ch]
if (pinball::has_focus && !pinball::single_step)
{
while (PeekMessageA(&Msg, nullptr, 0, 0, 1u))
{
TranslateMessage(&Msg);
DispatchMessageA(&Msg);
if (Msg.message == 18)
{
return_value = Msg.wParam;
return 0;
}
}
return 1;
}
GetMessageA(&Msg, pinball::hwnd_frame, 0, 0);
TranslateMessage(&Msg);
DispatchMessageA(&Msg);
if (Msg.message == 18)
{
return_value = Msg.wParam;
return 0;
}
return 1;
}
void winmain_memalloc_failure()

View File

@ -1,4 +1,6 @@
#pragma once
static int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);
static void winmain_memalloc_failure();
static LRESULT CALLBACK message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
int ProcessWindowMessages();