x64 build - no collision bug found(

Either lost in decompilation or introduced in x64 port.
This commit is contained in:
oz 2021-01-29 16:42:05 +03:00
parent 6756c54d3b
commit cd4679194c
19 changed files with 100 additions and 79 deletions

View File

@ -43,14 +43,14 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@ -114,6 +114,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>Comctl32.lib;Winmm.lib;Htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -153,6 +154,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>Comctl32.lib;Winmm.lib;Htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -3,7 +3,7 @@
struct gdrv_bitmap8;
struct __declspec(align(4)) flasher_type
struct flasher_type
{
render_sprite_type_struct* Sprite;
gdrv_bitmap8* BmpArr[2];
@ -15,7 +15,7 @@ struct __declspec(align(4)) flasher_type
};
struct __declspec(align(4)) TLight_player_backup
struct TLight_player_backup
{
int MessageField;
int BmpIndex1;

View File

@ -33,13 +33,13 @@ HANDLE WaveMix::ConfigureInit(MIXCONFIG* lpConfig)
{
MIXCONFIG mixConfig{};
memset(&mixConfig, 0, 0x1Cu);
unsigned int copySize = 30;
memset(&mixConfig, 0, sizeof(MIXCONFIG));
unsigned int copySize = sizeof(MIXCONFIG);
mixConfig.RegistryKey = nullptr;
mixConfig.wSize = 30;
mixConfig.wSize = sizeof(MIXCONFIG);
if (lpConfig)
{
if (lpConfig->wSize < 30u)
if (lpConfig->wSize < sizeof(MIXCONFIG))
copySize = lpConfig->wSize;
memcpy(&mixConfig, lpConfig, copySize);
}
@ -63,7 +63,7 @@ HANDLE WaveMix::ConfigureInit(MIXCONFIG* lpConfig)
if (GetPrivateProfileIntA("general", "ShowDevices", 0, FileName))
ShowWaveOutDevices();
auto globals = static_cast<GLOBALS*>(LocalAlloc(0x40u, 0x1C0u));
auto globals = static_cast<GLOBALS*>(LocalAlloc(0x40u, sizeof(GLOBALS)));
Globals = globals;
if (!globals)
return nullptr;
@ -262,7 +262,7 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
return nullptr;
}
auto mixWave = static_cast<MIXWAVE*>(GlobalLock(GlobalAlloc(0x2040u, 0x42u)));
auto mixWave = static_cast<MIXWAVE*>(GlobalLock(GlobalAlloc(0x2040u, sizeof(MIXWAVE))));
if (!mixWave)
{
if (ShowDebugDialogs)
@ -1180,7 +1180,7 @@ int WaveMix::Configure(GLOBALS* hMixSession, HWND hWndParent, MIXCONFIG* lpConfi
if (!mixConfig)
{
mixConfigLocal.wSize = 30;
mixConfigLocal.wSize = sizeof(MIXCONFIG);
mixConfigLocal.dwFlags = 1023;
GetConfig(static_cast<GLOBALS*>(hMixSession), &mixConfigLocal);
auto dialog = MakeSettingsDlgTemplate();
@ -1821,7 +1821,7 @@ int WaveMix::Settings_OnInitDialog(HWND hWnd, int wParam, MIXCONFIG* lpMixconfig
GetWindowTextA(hWnd, String, 256);
wsprintfA(string_buffer, String, 2, 81);
SetWindowTextA(hWnd, string_buffer);
SetWindowLongA(hWnd, -21, (LONG)lpMixconfig);
SetWindowLongPtr(hWnd, -21, reinterpret_cast<LONG_PTR>(lpMixconfig));
SendMessageA(GetDlgItem(hWnd, 1000), 0xF1u, lpMixconfig->wChannels > 1u, 0);
SendMessageA(GetDlgItem(hWnd, 1001), 0xF1u, lpMixconfig->ResetMixDefaultFlag != 0, 0);
SendMessageA(GetDlgItem(hWnd, 1004), 0xF1u, lpMixconfig->GoodWavePos != 0, 0);
@ -1880,7 +1880,7 @@ int WaveMix::Settings_OnInitDialog(HWND hWnd, int wParam, MIXCONFIG* lpMixconfig
int WaveMix::Settings_OnCommand(HWND hWnd, int command, int lParam, int wParam)
{
auto userData = (MIXCONFIG*)GetWindowLongA(hWnd, -21);
auto userData = reinterpret_cast<MIXCONFIG*>(GetWindowLongPtrA(hWnd, -21));
if (command == 1)
{
if (userData)

View File

@ -109,7 +109,7 @@ int fullscrn::enableFullscreen()
if (trick)
{
GetWindowRect(GetDesktopWindow(), &Rect);
SetWindowPos(hWnd, (HWND)((int)HWND_MESSAGE | 0x2), 0, 0, Rect.right - Rect.left + 1,
SetWindowPos(hWnd, (HWND)-1, 0, 0, Rect.right - Rect.left + 1,
Rect.bottom - Rect.top + 1, 8u);
}
SmthFullScrnFlag2 = 1;
@ -126,7 +126,7 @@ int fullscrn::enableFullscreen()
}
GetWindowRect(GetDesktopWindow(), &Rect);
disableWindowFlagsDisDlg();
SetWindowPos(hWnd, (HWND)0xFFFFFFFE, 0, 0, Rect.right - Rect.left + 1, Rect.bottom - Rect.top + 1, 8u);
SetWindowPos(hWnd, (HWND)-1, 0, 0, Rect.right - Rect.left + 1, Rect.bottom - Rect.top + 1, 8u);
return 0;
}
@ -138,7 +138,7 @@ int fullscrn::disableFullscreen()
SmthFullScrnFlag2 = 1;
ChangeDisplaySettingsA(nullptr, 4u);
if (trick)
SetWindowPos(hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x13u);
SetWindowPos(hWnd, (HWND)-1, 0, 0, 0, 0, 0x13u);
}
setWindowFlagsDisDlg();
SetWindowPos(

View File

@ -4,12 +4,10 @@ enum class BitmapType : char
{
None = 0,
RawBitmap = 1,
DibBitmap=2,
DibBitmap = 2,
};
#pragma pack(push, 1)
struct __declspec(align(1)) gdrv_bitmap8
struct gdrv_bitmap8
{
BITMAPINFO* Dib;
char* BmpBufPtr2;
@ -22,8 +20,6 @@ struct __declspec(align(1)) gdrv_bitmap8
int XPosition;
int YPosition;
};
#pragma pack(pop)
struct LOGPALETTEx256
{
@ -36,7 +32,6 @@ struct LOGPALETTEx256
}
};
static_assert(sizeof(gdrv_bitmap8) == 37, "Wrong size of gdrv_bitmap8");
class gdrv
{

View File

@ -22,18 +22,18 @@ struct soundListStruct
char* PtrToSmth;
};
struct __declspec(align(4)) visualKickerStruct
struct visualKickerStruct
{
float Threshold;
float Boost;
float ThrowBallMult;
vector_type ThrowBallAcceleration;
vector_type ThrowBallAcceleration;
float ThrowBallAngleMult;
int HardHitSoundId;
};
struct __declspec(align(4)) visualStruct
struct visualStruct
{
float Smoothness;
float Elasticity;
@ -69,7 +69,7 @@ public:
static float play_sound(int soundIndex);
static datFileStruct* loader_table;
private:
static errorMsg loader_errors[];
static errorMsg loader_errors[];
static datFileStruct* sound_record_table;
static int sound_count;
static int loader_sound_count;

View File

@ -10,7 +10,7 @@ struct vector_type
};
struct __declspec(align(4)) rectangle_type
struct rectangle_type
{
int XPosition;
int YPosition;
@ -24,7 +24,7 @@ struct circle_type
float RadiusSq;
};
struct __declspec(align(4)) ray_type
struct ray_type
{
vector_type Origin;
vector_type Direction;
@ -35,7 +35,7 @@ struct __declspec(align(4)) ray_type
int FieldFlag;
};
struct __declspec(align(4)) line_type
struct line_type
{
vector_type PerpendicularL;
vector_type Direction;
@ -59,7 +59,7 @@ struct wall_point_type
float Y1;
};
struct __declspec(align(4)) ramp_plane_type
struct ramp_plane_type
{
vector_type BallCollisionOffset;
vector_type2 V1;
@ -84,7 +84,8 @@ public:
static void cross(vector_type* vec1, vector_type* vec2, vector_type* dstVec);
static float magnitude(vector_type* vec);
static void vector_add(vector_type* vec1Dst, vector_type* vec2);
static float basic_collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float elasticity, float smoothness,
static float basic_collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float elasticity,
float smoothness,
float threshold, float boost);
static float Distance_Squared(vector_type vec1, vector_type vec2);
static float DotProduct(vector_type* vec1, vector_type* vec2);

View File

@ -6,7 +6,6 @@ struct objlist_struct1
int Count;
void* Array[1];
};
static_assert(sizeof(objlist_struct1) == 12, "Wrong size of objlist_struct1");
class objlist_class
{

View File

@ -1,7 +1,7 @@
#pragma once
#include "pinball.h"
struct __declspec(align(4)) optionsStruct
struct optionsStruct
{
int Sounds;
int Music;

View File

@ -2,8 +2,9 @@
#include "partman.h"
#include "gdrv.h"
#include "memory.h"
#include "zdrv.h"
short partman::_field_size[] =
short partman::_field_size[] =
{
2, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0
};
@ -14,6 +15,7 @@ datFileStruct* partman::load_records(LPCSTR lpFileName)
_OFSTRUCT ReOpenBuff{};
datFileHeader header{};
dat8BitBmpHeader bmpHeader{};
dat16BitBmpHeader zMapHeader{};
const HFILE fileHandle = OpenFile(lpFileName, &ReOpenBuff, 0);
if (fileHandle == -1)
@ -90,11 +92,11 @@ datFileStruct* partman::load_records(LPCSTR lpFileName)
{
auto entryType = static_cast<datFieldTypes>(_lread_char(fileHandle));
entryData->EntryType = entryType;
int fieldSize = _field_size[static_cast<int>(entryType)];
if (fieldSize < 0)
{
fieldSize = _lread_long(fileHandle);
}
if (entryType == datFieldTypes::Bitmap8bit)
{
_hread(fileHandle, &bmpHeader, sizeof(dat8BitBmpHeader));
@ -117,6 +119,18 @@ datFileStruct* partman::load_records(LPCSTR lpFileName)
bmp->XPosition = bmpHeader.XPosition;
bmp->YPosition = bmpHeader.YPosition;
}
else if (entryType == datFieldTypes::Bitmap16bit)
{
_hread(fileHandle, &zMapHeader, sizeof(dat16BitBmpHeader));
int length = fieldSize - sizeof(dat16BitBmpHeader);
auto zmap = reinterpret_cast<zmap_header_type*>(memory::allocate(sizeof(zmap_header_type) + length));
zmap->Width = zMapHeader.Width;
zmap->Height = zMapHeader.Height;
zmap->Stride = zMapHeader.Stride;
_hread(fileHandle, zmap->ZBuffer, length);
entryData->Buffer = reinterpret_cast<char*>(zmap);
}
else
{
char* entryBuffer = static_cast<char*>(memory::allocate(fieldSize));

View File

@ -89,6 +89,22 @@ struct dat8BitBmpHeader
static_assert(sizeof(dat8BitBmpHeader) == 14, "Wrong size of dat8BitBmpHeader");
#pragma pack(push, 1)
struct __declspec(align(1)) dat16BitBmpHeader
{
__int16 Width;
__int16 Height;
__int16 Stride;
int Unknown0;
__int16 Unknown1_0;
__int16 Unknown1_1;
};
#pragma pack(pop)
static_assert(sizeof(dat16BitBmpHeader) == 14, "Wrong size of zmap_header_type");
class partman
{
public:

View File

@ -37,7 +37,7 @@ int pinball::get_rc_int(int uID, int* dst)
void pinball::FindShiftKeys()
{
signed int i;
int rightShift;
int rightShift;
CHAR stringBuf[20];
RightShift = -1;
@ -80,26 +80,32 @@ void pinball::FindShiftKeys()
}
HANDLE pinball::adjust_priority(int priority)
void pinball::adjust_priority(int priority)
{
HANDLE result = GetCurrentThread();
auto thread = GetCurrentThread();
switch (priority)
{
case -2:
return (HANDLE)SetThreadPriority(result, -2);
SetThreadPriority(thread, -2);
break;
case -1:
return (HANDLE)SetThreadPriority(result, -1);
SetThreadPriority(thread, -1);
break;
case 0:
return (HANDLE)SetThreadPriority(result, 0);
SetThreadPriority(thread, 0);
break;
case 1:
return (HANDLE)SetThreadPriority(result, 1);
SetThreadPriority(thread, 1);
break;
case 2:
return (HANDLE)SetThreadPriority(result, 2);
SetThreadPriority(thread, 2);
break;
case 3:
result = (HANDLE)SetThreadPriority(result, 15);
SetThreadPriority(thread, 15);
break;
default:
break;
}
return result;
}
int pinball::make_path_name(LPSTR lpFilename, LPCSTR lpString2, int nSize)

View File

@ -20,7 +20,7 @@ public:
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);
static void adjust_priority(int priority);
static int make_path_name(LPSTR lpFilename, LPCSTR lpString2, int nSize = 0x12Cu);
private:
static char getRcBuffer[256 * 6];

View File

@ -18,9 +18,9 @@ void render::init(gdrv_bitmap8* bmp, float zMin, float zScaler, int width, int h
zscaler = zScaler;
zmin = zMin;
zmax = 4294967300.0f / zScaler + zMin;
sprite_list = (render_sprite_type_struct**)memory::allocate(0xFA0u);
dirty_list = (render_sprite_type_struct**)memory::allocate(0xFA0u);
ball_list = (render_sprite_type_struct**)memory::allocate(0x50u);
sprite_list = reinterpret_cast<render_sprite_type_struct**>(memory::allocate(1000 * sizeof(void*)));
dirty_list = reinterpret_cast<render_sprite_type_struct**>(memory::allocate(1000 * sizeof(void*)));
ball_list = reinterpret_cast<render_sprite_type_struct**>(memory::allocate(20 * sizeof(void*)));
gdrv::create_bitmap(&vscreen, width, height);
zdrv::create_zmap(&zscreen, width, height);
zdrv::fill(&zscreen, zscreen.Width, zscreen.Height, 0, 0, 0xFFFF);
@ -542,7 +542,7 @@ void render::build_occlude_list()
if (!curSprite->UnknownFlag && curSprite->BoundingRect.Width != -1)
{
if (!spriteArr)
spriteArr = reinterpret_cast<render_sprite_type_struct**>(memory::allocate(0xFA0u));
spriteArr = reinterpret_cast<render_sprite_type_struct**>(memory::allocate(1000 * sizeof(void*)));
int occludeCount = 0;
auto spritePtr2 = sprite_list;
for (int i = 0; i < many_sprites; ++i, ++spritePtr2)
@ -561,7 +561,7 @@ void render::build_occlude_list()
if (occludeCount)
{
curSprite->SpriteArray = reinterpret_cast<render_sprite_type_struct**>(memory::realloc(
spriteArr, 4 * occludeCount));
spriteArr, sizeof(void*) * occludeCount));
curSprite->SpriteCount = occludeCount;
spriteArr = nullptr;
}

View File

@ -10,7 +10,7 @@ enum class VisualType : char
Ball = 2
};
struct __declspec(align(4)) render_sprite_type_struct
struct render_sprite_type_struct
{
rectangle_type BmpRect;
gdrv_bitmap8* Bmp;
@ -28,8 +28,6 @@ struct __declspec(align(4)) render_sprite_type_struct
};
static_assert(sizeof(render_sprite_type_struct) == 0x5c, "Wrong size render_sprite_type_struct");
class render
{
public:

View File

@ -12,7 +12,7 @@ splash_struct* splash::splash_screen(HINSTANCE hInstance, LPCSTR bmpName1, LPCST
WNDCLASSA WndClass{};
tagRECT Rect{};
auto splashStruct = reinterpret_cast<splash_struct*>(memory::allocate(0x1B0u));
auto splashStruct = reinterpret_cast<splash_struct*>(memory::allocate(sizeof(splash_struct)));
if (!splashStruct)
return nullptr;
@ -43,7 +43,7 @@ splash_struct* splash::splash_screen(HINSTANCE hInstance, LPCSTR bmpName1, LPCST
return nullptr;
}
SetWindowLongA(windowHandle, 0, reinterpret_cast<LONG>(splashStruct));
SetWindowLongPtrA(windowHandle, -21, reinterpret_cast<LONG_PTR>(splashStruct));
GetWindowRect(GetDesktopWindow(), &Rect);
splash_bitmap_setup(splashStruct);
//MoveWindow(splashStruct->WindowHandle, 0, 0, Rect.right - Rect.left, Rect.bottom - Rect.top, 0);
@ -62,7 +62,7 @@ splash_struct* splash::splash_screen(HINSTANCE hInstance, LPCSTR bmpName1, LPCST
void splash::splash_bitmap_setup(splash_struct* splashStruct)
{
HBITMAP bmpHandle2;
BITMAP bmp;
BITMAP bmp{};
HBITMAP bmpHandle1 = nullptr;
HDC desktopDC = GetDC(GetDesktopWindow());
@ -92,7 +92,7 @@ void splash::splash_bitmap_setup(splash_struct* splashStruct)
{
SelectObject(splashStruct->DrawingContext, bmpHandle2);
DeleteObject(bmpHandle1);
GetObjectA(splashStruct->Bitmap, 24, &bmp);
GetObjectA(splashStruct->Bitmap, sizeof(BITMAP), &bmp);
splashStruct->Width = bmp.bmWidth;
splashStruct->Height = bmp.bmHeight;
return;
@ -224,8 +224,8 @@ void splash::splash_paint(splash_struct* splashStruct, HDC dc)
splashStruct->Height, splashStruct->DrawingContext, 0, 0, SRCCOPY);*/
/*Mod - less intrusive splash*/
BitBlt(dc, 0, 0, splashStruct->Width, splashStruct->Height,
splashStruct->DrawingContext, 0, 0, SRCCOPY);
BitBlt(dc, 0, 0, splashStruct->Width, splashStruct->Height,
splashStruct->DrawingContext, 0, 0, SRCCOPY);
}
}
@ -274,7 +274,7 @@ LRESULT splash::splash_message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LPARA
{
case WM_PAINT:
{
auto splashStruct = reinterpret_cast<splash_struct*>(GetWindowLongA(hWnd, 0));
auto splashStruct = reinterpret_cast<splash_struct*>(GetWindowLongPtrA(hWnd, -21));
BeginPaint(hWnd, &Paint);
EndPaint(hWnd, &Paint);
auto dc = GetDC(hWnd);

View File

@ -1,6 +1,6 @@
#pragma once
struct __declspec(align(4)) timer_struct
struct timer_struct
{
int TargetTime;
void* Caller;

View File

@ -313,7 +313,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
SetForegroundWindow(hWnd);
return 0;
}
if (Msg <= WM_ACTIVATEAPP)
{
switch (Msg)
@ -532,20 +532,15 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
{
char cmdLine[0x1F4u];
options::get_string(nullptr, "Shell Exe", tmpBuf, pinball::WindowName, 500);
auto iHwnd = reinterpret_cast<size_t>(hwnd_frame);
sprintf_s(
cmdLine,
"%s %s%lX %s%lX",
tmpBuf,
"select=",
(int)hwnd_frame,
iHwnd,
"confirm=",
(int)hwnd_frame
* (int)hwnd_frame
* (int)hwnd_frame
* (int)hwnd_frame
* (int)hwnd_frame
* (int)hwnd_frame
* (int)hwnd_frame);
iHwnd * iHwnd * iHwnd * iHwnd * iHwnd * iHwnd * iHwnd);
if (static_cast<int>(WinExec(cmdLine, 5u)) < 32)
{
auto caption = pinball::get_rc_string(170, 0);

View File

@ -1,8 +1,7 @@
#pragma once
#include "gdrv.h"
#pragma pack(push, 1)
struct __declspec(align(1)) zmap_header_type
struct zmap_header_type
{
__int16 Width;
__int16 Height;
@ -12,10 +11,6 @@ struct __declspec(align(1)) zmap_header_type
unsigned __int16 ZBuffer[1];
};
#pragma pack(pop)
static_assert(sizeof(zmap_header_type) == 16, "Wrong size of zmap_header_type");
class zdrv
{
public: