mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-12-19 20:33:03 -05:00
timer v1, ready.
winmain uninit. message_handler tweaks.
This commit is contained in:
parent
fe66d33768
commit
090beefd07
23 changed files with 327 additions and 121 deletions
Binary file not shown.
|
@ -1,9 +1,9 @@
|
|||
#include "pch.h"
|
||||
#include "Sound.h"
|
||||
|
||||
int Sound::Init(HINSTANCE hInstance, int voices, void(__stdcall* someFuncPtr)(int, int, int))
|
||||
int Sound::Init(HINSTANCE hInstance, int voices, void (__stdcall* someFuncPtr)(int, int, int))
|
||||
{
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Sound::Enable(int a1, int a2, int a3)
|
||||
|
@ -29,3 +29,13 @@ void Sound::Deactivate()
|
|||
void Sound::Close()
|
||||
{
|
||||
}
|
||||
|
||||
int Sound::SubFactor(int a1, int a2)
|
||||
{
|
||||
return a1 - a2;
|
||||
}
|
||||
|
||||
int Sound::AddFactor(int a1, int a2)
|
||||
{
|
||||
return a1 + a2;
|
||||
}
|
||||
|
|
|
@ -9,4 +9,6 @@ public:
|
|||
static void Activate();
|
||||
static void Deactivate();
|
||||
static void Close();
|
||||
static int SubFactor(int a1, int a2);
|
||||
static int AddFactor(int a1, int a2);
|
||||
};
|
||||
|
|
|
@ -64,36 +64,36 @@ MENU_1 MENU
|
|||
BEGIN
|
||||
POPUP "&Game"
|
||||
BEGIN
|
||||
MENUITEM "&New Game\tF2", 101
|
||||
MENUITEM "&Launch Ball", 401
|
||||
MENUITEM "&Pause/Resume Game\tF3", 402
|
||||
MENUITEM "&New Game\tF2", Menu1_New_Game
|
||||
MENUITEM "&Launch Ball", Menu1_Launch_Ball
|
||||
MENUITEM "&Pause/Resume Game\tF3", Menu1_Pause_Resume_Game
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&High Scores...", 103
|
||||
MENUITEM "&Demo", 404
|
||||
MENUITEM "E&xit", 105
|
||||
MENUITEM "&High Scores...", Menu1_High_Scores
|
||||
MENUITEM "&Demo", Menu1_Demo
|
||||
MENUITEM "E&xit", Menu1_Exit
|
||||
END
|
||||
POPUP "&Options"
|
||||
BEGIN
|
||||
MENUITEM "&Full Screen\tF4", 403
|
||||
MENUITEM "Select &Table", 405
|
||||
MENUITEM "&Full Screen\tF4", Menu1_Full_Screen
|
||||
MENUITEM "Select &Table", Menu1_Select_Table
|
||||
POPUP "Select &Players"
|
||||
BEGIN
|
||||
MENUITEM "&1 Player", 408
|
||||
MENUITEM "&2 Players", 409
|
||||
MENUITEM "&3 Players", 410
|
||||
MENUITEM "&4 Players", 411
|
||||
MENUITEM "&1 Player", Menu1_1Player
|
||||
MENUITEM "&2 Players", Menu1_2Players
|
||||
MENUITEM "&3 Players", Menu1_3Players
|
||||
MENUITEM "&4 Players", Menu1_4Players
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Sounds", 201
|
||||
MENUITEM "&Music", 202
|
||||
MENUITEM "&Sounds", Menu1_Sounds
|
||||
MENUITEM "&Music", Menu1_Music
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "P&layer Controls...\tF8", 406
|
||||
MENUITEM "P&layer Controls...\tF8", Menu1_Player_Controls
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&Help Topics\tF1", 301
|
||||
MENUITEM "&Help Topics\tF1", Menu1_Help_Topics
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&About Pinball", 102
|
||||
MENUITEM "&About Pinball", Menu1_About_Pinball
|
||||
END
|
||||
END
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
|
|
|
@ -219,7 +219,7 @@ TPinballTable::~TPinballTable()
|
|||
{
|
||||
//if (i)
|
||||
//(*(void(__thiscall**)(TLightGroup*, int))(*(_DWORD*)i + 16))(i, 1);
|
||||
if (!ListP1->Count())
|
||||
//if (!ListP1->Count())
|
||||
break;
|
||||
}
|
||||
delete ListP2;
|
||||
|
|
|
@ -1,2 +1,8 @@
|
|||
#include "pch.h"
|
||||
#include "TRamp.h"
|
||||
|
||||
|
||||
void TRamp::port_draw()
|
||||
{
|
||||
TCollisionComponent::port_draw();
|
||||
}
|
||||
|
|
|
@ -8,4 +8,6 @@ public:
|
|||
TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
|
||||
{
|
||||
}
|
||||
|
||||
void port_draw() override;
|
||||
};
|
||||
|
|
|
@ -50,8 +50,9 @@ int TTextBox::Message(int code, float value)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void TTextBox::TimerExpired(int a2, TTextBox* tb)
|
||||
void TTextBox::TimerExpired(int timerId, void* caller)
|
||||
{
|
||||
auto tb = static_cast<TTextBox*>(caller);
|
||||
TTextBoxMessage* message = tb->Message1;
|
||||
tb->Timer = 0;
|
||||
if (message)
|
||||
|
@ -117,7 +118,7 @@ void TTextBox::Display(char* text, float time)
|
|||
if (time == -1.0)
|
||||
Timer = -1;
|
||||
else
|
||||
Timer = timer::set(time, (int)this, (int)TimerExpired);
|
||||
Timer = timer::set(time, this, TimerExpired);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -205,11 +206,11 @@ void TTextBox::Draw()
|
|||
int timer;
|
||||
if (timeLeft >= 0.25f)
|
||||
{
|
||||
timer = timer::set(timeLeft, (int)this2, (int)TimerExpired);
|
||||
timer = timer::set(timeLeft, this2, TimerExpired);
|
||||
}
|
||||
else
|
||||
{
|
||||
timer = timer::set(0.25, (int)this2, (int)TimerExpired);
|
||||
timer = timer::set(0.25, this2, TimerExpired);
|
||||
}
|
||||
this2->Timer = timer;
|
||||
goto LABEL_18;
|
||||
|
|
|
@ -24,5 +24,5 @@ public:
|
|||
void Display(char* text, float time);
|
||||
void Draw();
|
||||
|
||||
static void TimerExpired(int a2, TTextBox* tb);
|
||||
static void TimerExpired(int timerId, void* tb);
|
||||
};
|
||||
|
|
|
@ -3,20 +3,25 @@
|
|||
|
||||
MCIERROR midi::play_pb_theme(int flag)
|
||||
{
|
||||
return MCIERROR();
|
||||
return MCIERROR();
|
||||
}
|
||||
|
||||
MCIERROR midi::music_stop()
|
||||
{
|
||||
return MCIERROR();
|
||||
return MCIERROR();
|
||||
}
|
||||
|
||||
int midi::music_init(HWND hwnd)
|
||||
{
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
MCIERROR midi::restart_midi_seq(int param)
|
||||
{
|
||||
return MCIERROR();
|
||||
return MCIERROR();
|
||||
}
|
||||
|
||||
MCIERROR midi::music_shutdown()
|
||||
{
|
||||
return MCIERROR();
|
||||
}
|
||||
|
|
|
@ -6,4 +6,5 @@ public:
|
|||
static MCIERROR music_stop();
|
||||
static int music_init(HWND hwnd);
|
||||
static MCIERROR restart_midi_seq(int param);
|
||||
static MCIERROR music_shutdown();
|
||||
};
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "memory.h"
|
||||
#include "midi.h"
|
||||
#include "pinball.h"
|
||||
#include "resource.h"
|
||||
#include "Sound.h"
|
||||
#include "winmain.h"
|
||||
|
||||
|
@ -68,7 +69,7 @@ void options::init(HMENU menuHandle)
|
|||
{
|
||||
if (MenuHandle)
|
||||
{
|
||||
DeleteMenu(MenuHandle, 0x195u, 0);
|
||||
DeleteMenu(MenuHandle, Menu1_Select_Table, 0);
|
||||
DrawMenuBar(winmain::hwnd_frame);
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +77,20 @@ void options::init(HMENU menuHandle)
|
|||
}
|
||||
}
|
||||
|
||||
void options::uninit()
|
||||
{
|
||||
set_int(nullptr, "Sounds", Options.Sounds);
|
||||
set_int(nullptr, "Music", Options.Music);
|
||||
set_int(nullptr, "FullScreen", Options.FullScreen);
|
||||
set_int(nullptr, "Players", Options.Players);
|
||||
set_int(nullptr, "Left Flippper key", Options.LeftFlipperKey);
|
||||
set_int(nullptr, "Right Flipper key", Options.RightFlipperKey);
|
||||
set_int(nullptr, "Plunger key", Options.PlungerKey);
|
||||
set_int(nullptr, "Left Table Bump key", Options.LeftTableBumpKey);
|
||||
set_int(nullptr, "Right Table Bump key", Options.RightTableBumpKey);
|
||||
set_int(nullptr, "Bottom Table Bump key", Options.BottomTableBumpKey);
|
||||
}
|
||||
|
||||
void options::path_init(LPCSTR regPath)
|
||||
{
|
||||
char* buf = memory::allocate(lstrlenA(regPath) + 1);
|
||||
|
@ -207,13 +222,13 @@ void options::toggle(UINT uIDCheckItem)
|
|||
int newValue;
|
||||
switch (uIDCheckItem)
|
||||
{
|
||||
case 0xC9u:
|
||||
case Menu1_Sounds:
|
||||
newValue = Options.Sounds == 0;
|
||||
Options.Sounds = Options.Sounds == 0;
|
||||
Sound::Enable(0, 7, newValue);
|
||||
menu_check(uIDCheckItem, newValue);
|
||||
return;
|
||||
case 0xCAu:
|
||||
case Menu1_Music:
|
||||
newValue = Options.Music == 0;
|
||||
Options.Music = Options.Music == 0;
|
||||
if (!newValue)
|
||||
|
@ -222,7 +237,7 @@ void options::toggle(UINT uIDCheckItem)
|
|||
midi::play_pb_theme(0);
|
||||
menu_check(uIDCheckItem, newValue);
|
||||
return;
|
||||
case 0x193u:
|
||||
case Menu1_Full_Screen:
|
||||
newValue = Options.FullScreen == 0;
|
||||
Options.FullScreen = Options.FullScreen == 0;
|
||||
fullscrn::set_screen_mode(newValue);
|
||||
|
@ -232,7 +247,7 @@ void options::toggle(UINT uIDCheckItem)
|
|||
if (uIDCheckItem > 407 && uIDCheckItem <= 411)
|
||||
{
|
||||
Options.Players = uIDCheckItem - 407;
|
||||
menu_check(0x198u, uIDCheckItem == 408);
|
||||
menu_check(0x198u, Options.Players == 1);
|
||||
menu_check(0x199u, Options.Players == 2);
|
||||
menu_check(0x19Au, Options.Players == 3);
|
||||
menu_check(0x19Bu, Options.Players == 4);
|
||||
|
|
|
@ -27,6 +27,7 @@ class options
|
|||
{
|
||||
public:
|
||||
static void init(HMENU menuHandle);
|
||||
static void uninit();
|
||||
static void path_init(LPCSTR regPath);
|
||||
static void path_uninit();
|
||||
static int get_int(LPCSTR optPath, LPCSTR lpValueName, int defaultValue);
|
||||
|
|
|
@ -58,7 +58,8 @@ 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, (char)0xff); // temp
|
||||
gdrv::fill_bitmap(&render::vscreen, render::vscreen.Width, render::vscreen.Height, 0, 0,
|
||||
static_cast<char>(0xff)); // temp
|
||||
gdrv::copy_bitmap(
|
||||
&render::vscreen,
|
||||
backgroundBmp->Width,
|
||||
|
@ -91,6 +92,21 @@ int pb::init()
|
|||
return 0;
|
||||
}
|
||||
|
||||
int pb::uninit()
|
||||
{
|
||||
score::unload_msg_font();
|
||||
loader::unload();
|
||||
partman::unload_records(record_table);
|
||||
//high_score_write(highscore_table, (int)&pb_state);
|
||||
if (MainTable)
|
||||
delete MainTable;
|
||||
MainTable = nullptr;
|
||||
gdrv::get_focus();
|
||||
timer::uninit();
|
||||
render::uninit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pb::reset_table()
|
||||
{
|
||||
if (MainTable)
|
||||
|
@ -166,7 +182,7 @@ int pb::frame(int time)
|
|||
v2 = 0.0;
|
||||
nudge_count = v2;
|
||||
}*/
|
||||
//timer::check();
|
||||
timer::check();
|
||||
render::update();
|
||||
//score::update(MainTable->Score1);
|
||||
/*if (!MainTable->UnknownP83)
|
||||
|
|
|
@ -12,6 +12,7 @@ public:
|
|||
static TPinballTable* MainTable;
|
||||
|
||||
static int init();
|
||||
static int uninit();
|
||||
static void reset_table();
|
||||
static void firsttime_setup();
|
||||
static void paint();
|
||||
|
|
|
@ -25,7 +25,7 @@ char* pinball::get_rc_string(int uID, int a2)
|
|||
|
||||
int pinball::get_rc_int(int uID, int* dst)
|
||||
{
|
||||
char buffer[50];
|
||||
char buffer[255];
|
||||
int result = LoadStringA(winmain::hinst, uID, buffer, 255);
|
||||
if (!result)
|
||||
return result;
|
||||
|
@ -38,7 +38,7 @@ void pinball::FindShiftKeys()
|
|||
{
|
||||
signed int i; // esi
|
||||
int rightShift; // eax
|
||||
CHAR stringBuf[10]; // [esp+Ch] [ebp-18h]
|
||||
CHAR stringBuf[20]; // [esp+Ch] [ebp-18h]
|
||||
|
||||
RightShift = -1;
|
||||
LeftShift = -1;
|
||||
|
|
|
@ -104,10 +104,14 @@
|
|||
#define IDS_STRING200 99
|
||||
#define IDS_STRING201 100
|
||||
#define IDS_STRING202 101
|
||||
#define Menu1_New_Game 101
|
||||
#define IDS_STRING203 102
|
||||
#define Menu1_About_Pinball 102
|
||||
#define IDS_STRING204 103
|
||||
#define Menu1_High_Scores 103
|
||||
#define IDS_STRING205 104
|
||||
#define IDS_STRING206 105
|
||||
#define Menu1_Exit 105
|
||||
#define IDS_STRING207 106
|
||||
#define IDS_STRING208 107
|
||||
#define IDS_STRING209 108
|
||||
|
@ -191,13 +195,27 @@
|
|||
#define IDS_STRING287 187
|
||||
#define IDS_STRING288 188
|
||||
#define IDS_STRING289 189
|
||||
#define Menu1_Sounds 201
|
||||
#define Menu1_Music 202
|
||||
#define Menu1_Help_Topics 301
|
||||
#define Menu1_Launch_Ball 401
|
||||
#define Menu1_Pause_Resume_Game 402
|
||||
#define Menu1_Full_Screen 403
|
||||
#define Menu1_Demo 404
|
||||
#define Menu1_Select_Table 405
|
||||
#define Menu1_Player_Controls 406
|
||||
#define Menu1_1Player 408
|
||||
#define Menu1_2Players 409
|
||||
#define Menu1_3Players 410
|
||||
#define Menu1_4Players 411
|
||||
#define ID_GAME_D 40003
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 201
|
||||
#define _APS_NEXT_COMMAND_VALUE 40002
|
||||
#define _APS_NEXT_COMMAND_VALUE 40004
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
|
|
|
@ -54,3 +54,7 @@ HRSRC score::load_msg_font(LPCSTR lpName)
|
|||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void score::unload_msg_font()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ struct scoreStruct
|
|||
|
||||
struct score_msg_font_type
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
class score
|
||||
|
@ -35,4 +34,5 @@ public:
|
|||
static scoreStruct* create(LPCSTR fieldName, gdrv_bitmap8* renderBgBmp);
|
||||
static scoreStruct* dup(scoreStruct* score, int scoreIndex);
|
||||
static HRSRC load_msg_font(LPCSTR lpName);
|
||||
static void unload_msg_font();
|
||||
};
|
||||
|
|
|
@ -2,47 +2,152 @@
|
|||
#include "timer.h"
|
||||
|
||||
#include "memory.h"
|
||||
#include "pb.h"
|
||||
|
||||
timer_struct timer::timer_struct;
|
||||
int timer::setCount;
|
||||
timer_struct timer::timerStruct{};
|
||||
int timer::set_count;
|
||||
|
||||
int timer::init(int count)
|
||||
{
|
||||
char* buf; // eax
|
||||
int index; // edx
|
||||
int* v4; // ecx
|
||||
|
||||
buf = memory::allocate(20 * count);
|
||||
timer_struct.buffer1 = buf;
|
||||
auto buf = (timer_sub_struct*)memory::allocate(sizeof(timer_sub_struct) * count);
|
||||
timerStruct.TimerMem = buf;
|
||||
if (!buf)
|
||||
return 1;
|
||||
timer_struct.target = 0;
|
||||
index = count - 1;
|
||||
timer_struct.count = count;
|
||||
setCount = 1;
|
||||
if (count - 1 > 0)
|
||||
timerStruct.Count = 0;
|
||||
timerStruct.MaxCount = count;
|
||||
set_count = 1;
|
||||
|
||||
for (int index = 0; index < count - 1; index++)
|
||||
buf[index].NextTimer = &buf[index + 1];
|
||||
buf[count - 1].NextTimer = nullptr;
|
||||
|
||||
timerStruct.NextTimer = nullptr;
|
||||
timerStruct.LastTimer = buf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void timer::uninit()
|
||||
{
|
||||
if (timerStruct.TimerMem)
|
||||
memory::free(timerStruct.TimerMem);
|
||||
timerStruct.TimerMem = nullptr;
|
||||
}
|
||||
|
||||
int timer::kill(int timerId)
|
||||
{
|
||||
timer_sub_struct* next = timerStruct.NextTimer;
|
||||
int index = 0;
|
||||
timer_sub_struct* current = nullptr;
|
||||
if (timerStruct.Count <= 0)
|
||||
return 0;
|
||||
while (timerId != next->TimerId)
|
||||
{
|
||||
v4 = (int*)(buf + 12);
|
||||
do
|
||||
{
|
||||
*v4 = (int)(v4 + 2);
|
||||
v4 += 5;
|
||||
--index;
|
||||
}
|
||||
while (index);
|
||||
++index;
|
||||
current = next;
|
||||
next = next->NextTimer;
|
||||
if (index >= timerStruct.Count)
|
||||
return 0;
|
||||
}
|
||||
*(int*)&buf[20 * count - 8] = 0;
|
||||
timer_struct.target2 = 0;
|
||||
timer_struct.buffer2 = buf;
|
||||
return 0;
|
||||
if (current)
|
||||
current->NextTimer = next->NextTimer;
|
||||
else
|
||||
timerStruct.NextTimer = next->NextTimer;
|
||||
|
||||
--timerStruct.Count;
|
||||
next->NextTimer = timerStruct.LastTimer;
|
||||
timerStruct.LastTimer = next;
|
||||
return timerId;
|
||||
}
|
||||
|
||||
int timer::kill(int timer)
|
||||
int timer::set(float time, void* caller, void (* callback)(int, void*))
|
||||
{
|
||||
return 0;
|
||||
if (timerStruct.Count >= timerStruct.MaxCount)
|
||||
return 0;
|
||||
|
||||
/*timerStruct.LastTimer->NextTimer = nullptr;
|
||||
timerStruct.LastTimer = timerStruct.LastTimer->NextTimer;*/
|
||||
|
||||
auto lastNext = timerStruct.LastTimer->NextTimer;
|
||||
timerStruct.LastTimer->NextTimer = nullptr;
|
||||
timerStruct.LastTimer = lastNext;
|
||||
|
||||
auto prev = timerStruct.NextTimer;
|
||||
auto current = timerStruct.NextTimer;
|
||||
|
||||
auto targetTime = pb::time_ticks + static_cast<int>(time * 1000.0f);
|
||||
for (int index = 0; index < timerStruct.Count && targetTime >= current->TargetTime; ++index)
|
||||
{
|
||||
prev = current;
|
||||
current = current->NextTimer;
|
||||
}
|
||||
|
||||
auto last = timerStruct.LastTimer;
|
||||
if (current != prev)
|
||||
{
|
||||
timerStruct.LastTimer->NextTimer = prev->NextTimer;
|
||||
prev->NextTimer = last;
|
||||
}
|
||||
else
|
||||
{
|
||||
timerStruct.LastTimer->NextTimer = timerStruct.NextTimer;
|
||||
timerStruct.NextTimer = last;
|
||||
}
|
||||
|
||||
last->Caller = caller;
|
||||
last->Callback = callback;
|
||||
last->TimerId = set_count;
|
||||
last->TargetTime = targetTime;
|
||||
timerStruct.Count++;
|
||||
|
||||
set_count++;
|
||||
if (set_count <= 0)
|
||||
set_count = 1;
|
||||
return last->TimerId;
|
||||
}
|
||||
|
||||
int timer::set(float time, int caller, int callback)
|
||||
int timer::check()
|
||||
{
|
||||
return 0;
|
||||
timer_sub_struct curCopy{};
|
||||
timer_sub_struct* current = timerStruct.NextTimer;
|
||||
int index = 0;
|
||||
if (timerStruct.NextTimer)
|
||||
{
|
||||
while (pb::time_ticks >= current->TargetTime)
|
||||
{
|
||||
--timerStruct.Count;
|
||||
memcpy(&curCopy, current, sizeof curCopy);
|
||||
timer_sub_struct** nextPtr = ¤t->NextTimer;
|
||||
current = current->NextTimer;
|
||||
timerStruct.NextTimer = current;
|
||||
*nextPtr = timerStruct.LastTimer;
|
||||
timerStruct.LastTimer = current;
|
||||
if (curCopy.Callback != nullptr)
|
||||
{
|
||||
curCopy.Callback(curCopy.TimerId, curCopy.Caller);
|
||||
current = timerStruct.NextTimer;
|
||||
}
|
||||
++index;
|
||||
if (index > 1)
|
||||
break;
|
||||
if (!current)
|
||||
return index;
|
||||
}
|
||||
while (current && pb::time_ticks >= current->TargetTime + 100)
|
||||
{
|
||||
--timerStruct.Count;
|
||||
memcpy(&curCopy, current, sizeof curCopy);
|
||||
timer_sub_struct** nextPtr = ¤t->NextTimer;
|
||||
current = current->NextTimer;
|
||||
timerStruct.NextTimer = current;
|
||||
*nextPtr = timerStruct.LastTimer;
|
||||
timerStruct.LastTimer = current;
|
||||
if (curCopy.Callback != nullptr)
|
||||
{
|
||||
curCopy.Callback(curCopy.TimerId, curCopy.Caller);
|
||||
current = timerStruct.NextTimer;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
struct __declspec(align(4)) timer_sub_struct
|
||||
{
|
||||
int TargetTime;
|
||||
void* Caller;
|
||||
void (* Callback)(int, void*);
|
||||
timer_sub_struct* NextTimer;
|
||||
int TimerId;
|
||||
};
|
||||
|
||||
struct __declspec(align(4)) timer_struct
|
||||
{
|
||||
int target2;
|
||||
int count;
|
||||
int target;
|
||||
char* buffer2;
|
||||
char* buffer1;
|
||||
timer_sub_struct* NextTimer;
|
||||
int MaxCount;
|
||||
int Count;
|
||||
timer_sub_struct* LastTimer;
|
||||
timer_sub_struct* TimerMem;
|
||||
};
|
||||
|
||||
|
||||
|
@ -14,10 +23,12 @@ class timer
|
|||
{
|
||||
public:
|
||||
static int init(int count);
|
||||
static int kill(int timer);
|
||||
static int set(float time, int caller, int callback);
|
||||
static void uninit();
|
||||
static int kill(int timerId);
|
||||
static int set(float time, void* caller, void (* callback)(int, void*));
|
||||
static int check();
|
||||
|
||||
private:
|
||||
static timer_struct timer_struct;
|
||||
static int setCount;
|
||||
static timer_struct timerStruct;
|
||||
static int set_count;
|
||||
};
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "options.h"
|
||||
#include "pb.h"
|
||||
#include "Sound.h"
|
||||
#include "resource.h"
|
||||
|
||||
HINSTANCE winmain::hinst = nullptr;
|
||||
HWND winmain::hwnd_frame = nullptr;
|
||||
|
@ -68,6 +69,7 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
if (tmpBuf2)
|
||||
{
|
||||
char Buffer[40];
|
||||
bool setOption = false;
|
||||
for (int i = 0; i < 32700; ++i)
|
||||
{
|
||||
sprintf_s(Buffer, "Table%d", i);
|
||||
|
@ -76,12 +78,15 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
break;
|
||||
options::get_string(tmpBuf, "Table Name", tmpBuf2, pinball::WindowName, 500);
|
||||
if (!lstrcmpA(tmpBuf2, pinball::get_rc_string(169, 0)))
|
||||
goto LABEL_15;
|
||||
{
|
||||
setOption = false;
|
||||
break;
|
||||
}
|
||||
if (!*tmpBuf2)
|
||||
break;
|
||||
}
|
||||
options::set_string(nullptr, Buffer, regSpaceCadet);
|
||||
LABEL_15:
|
||||
if (setOption)
|
||||
options::set_string(nullptr, Buffer, regSpaceCadet);
|
||||
memory::free(tmpBuf2);
|
||||
}
|
||||
memory::free(tmpBuf);
|
||||
|
@ -111,7 +116,8 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
options::get_string(regSpaceCadet, "Pinball Data", DatFileName, pinball::get_rc_string(168, 0), 300);
|
||||
|
||||
iFrostUniqueMsg = RegisterWindowMessageA("PinballThemeSwitcherUniqueMsgString");
|
||||
auto windowHandle = FindWindowA(pinball::get_rc_string(167, 0), nullptr);
|
||||
auto windowClass = pinball::get_rc_string(167, 0);
|
||||
auto windowHandle = FindWindowA(windowClass, nullptr);
|
||||
if (windowHandle)
|
||||
{
|
||||
SendMessageA(windowHandle, iFrostUniqueMsg, 0, 0);
|
||||
|
@ -126,7 +132,6 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
picce.dwICC = 5885;
|
||||
InitCommonControlsEx(&picce);
|
||||
|
||||
auto windowClass = pinball::get_rc_string(167, 0);
|
||||
WNDCLASSA WndClass{};
|
||||
WndClass.style = 4104;
|
||||
WndClass.lpfnWndProc = message_handler;
|
||||
|
@ -178,7 +183,7 @@ 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 < 0)// Don't wait for now, was 2000
|
||||
while (timeGetTime() >= startTime && timeGetTime() - startTime < 0) // Don't wait for now, was 2000
|
||||
PeekMessageA(&wndMessage, hwnd_frame, 0, 0, 1u);
|
||||
|
||||
if (strstr(lpCmdLine, "-demo"))
|
||||
|
@ -277,7 +282,7 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
{
|
||||
fillChar = -7;
|
||||
}
|
||||
gdrv::fill_bitmap(&gfr_display, 1, 10, 299u - someTimeCounter, 0, fillChar);
|
||||
gdrv::fill_bitmap(&gfr_display, 1, 10, 299 - someTimeCounter, 0, fillChar);
|
||||
}
|
||||
--someTimeCounter;
|
||||
then = now;
|
||||
|
@ -286,6 +291,15 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
}
|
||||
}
|
||||
|
||||
gdrv::destroy_bitmap(&gfr_display);
|
||||
options::uninit();
|
||||
midi::music_shutdown();
|
||||
pb::uninit();
|
||||
Sound::Close();
|
||||
gdrv::uninit();
|
||||
DestroyWindow(hwnd_frame);
|
||||
options::path_uninit();
|
||||
UnregisterClassA(windowClass, hinst);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
@ -499,23 +513,18 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
|
|||
no_time_loss = 1;
|
||||
switch (wParam)
|
||||
{
|
||||
case 0x191u:
|
||||
case Menu1_Launch_Ball:
|
||||
end_pause();
|
||||
pb::launch_ball();
|
||||
break;
|
||||
case 0x192u:
|
||||
case Menu1_Pause_Resume_Game:
|
||||
pause();
|
||||
break;
|
||||
case 0x193u:
|
||||
if (!single_step)
|
||||
pause();
|
||||
options::toggle(wParam);
|
||||
break;
|
||||
case 0x194u:
|
||||
case Menu1_Demo:
|
||||
end_pause();
|
||||
pb::toggle_demo();
|
||||
break;
|
||||
case 0x195u:
|
||||
case Menu1_Select_Table:
|
||||
{
|
||||
if (!single_step)
|
||||
pause();
|
||||
|
@ -548,55 +557,53 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 0x196u:
|
||||
if (!single_step)
|
||||
pause();
|
||||
options::keyboard();
|
||||
break;
|
||||
case 0x198u:
|
||||
case 0x199u:
|
||||
case 0x19Au:
|
||||
case 0x19Bu:
|
||||
case Menu1_1Player:
|
||||
case Menu1_2Players:
|
||||
case Menu1_3Players:
|
||||
case Menu1_4Players:
|
||||
options::toggle(wParam);
|
||||
new_game();
|
||||
break;
|
||||
case 301:
|
||||
case Menu1_Help_Topics:
|
||||
if (!single_step)
|
||||
pause();
|
||||
help_introduction(hinst, hWnd);
|
||||
return DefWindowProcA(hWnd, Msg, wParam, lParam);
|
||||
case 0x6A:
|
||||
break;
|
||||
case 106: // End game button?
|
||||
pb::end_game();
|
||||
return DefWindowProcA(hWnd, Msg, wParam, lParam);
|
||||
case 201:
|
||||
case 202:
|
||||
break;
|
||||
case Menu1_Full_Screen:
|
||||
case Menu1_Sounds:
|
||||
case Menu1_Music:
|
||||
if (!single_step)
|
||||
pause();
|
||||
options::toggle(wParam);
|
||||
break;
|
||||
case 204:
|
||||
case Menu1_Player_Controls:
|
||||
case 204: // Second controls button?
|
||||
if (!single_step)
|
||||
pause();
|
||||
options::keyboard();
|
||||
break;
|
||||
case 0x69u:
|
||||
PostMessageA(hWnd, 0x12u, 0, 0);
|
||||
return DefWindowProcA(hWnd, Msg, wParam, lParam);
|
||||
case 0x65u:
|
||||
case Menu1_Exit:
|
||||
PostMessageA(hWnd, WM_QUIT, 0, 0);
|
||||
break;
|
||||
case Menu1_New_Game:
|
||||
new_game();
|
||||
return DefWindowProcA(hWnd, Msg, wParam, lParam);
|
||||
case 0x66u:
|
||||
break;
|
||||
case Menu1_About_Pinball:
|
||||
if (!single_step)
|
||||
pause();
|
||||
a_dialog(hinst, hWnd);
|
||||
return DefWindowProcA(hWnd, Msg, wParam, lParam);
|
||||
case 0x67u:
|
||||
break;
|
||||
case Menu1_High_Scores:
|
||||
if (!single_step)
|
||||
pause();
|
||||
pb::high_scores();
|
||||
return DefWindowProcA(hWnd, Msg, wParam, lParam);
|
||||
case 1:
|
||||
break;
|
||||
case 1: // Unknown button
|
||||
midi::restart_midi_seq(lParam);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue