From 60e9f63607bd835fa37b13652ebc52193f45b8e8 Mon Sep 17 00:00:00 2001 From: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com> Date: Tue, 7 Sep 2021 10:09:07 +0300 Subject: [PATCH] Added Windows XP build configuration. Improved background blit for unform scaling. --- .gitignore | 8 +++ SpaceCadetPinball.sln | 10 ++- SpaceCadetPinball/SpaceCadetPinball.vcxproj | 78 +++++++++++++++++++++ SpaceCadetPinball/fullscrn.cpp | 14 ++-- SpaceCadetPinball/fullscrn.h | 4 +- SpaceCadetPinball/gdrv.cpp | 19 +++++ 6 files changed, 119 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 0e6b0e2..46f75c4 100644 --- a/.gitignore +++ b/.gitignore @@ -263,3 +263,11 @@ __pycache__/ /Export /DrMem /Doc private + +# Cmake stuff +/Libs +/out + +# WinXp stuff +DebugWinXp/ +ReleaseWinXp/ diff --git a/SpaceCadetPinball.sln b/SpaceCadetPinball.sln index 8586b4b..f50dccf 100644 --- a/SpaceCadetPinball.sln +++ b/SpaceCadetPinball.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.705 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31624.102 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SpaceCadetPinball", "SpaceCadetPinball\SpaceCadetPinball.vcxproj", "{F7B78CC7-6984-4F79-9486-ABCF87DF9F06}" EndProject @@ -11,6 +11,8 @@ Global Debug|x86 = Debug|x86 Release|x64 = Release|x64 Release|x86 = Release|x86 + ReleaseWinXp|x64 = ReleaseWinXp|x64 + ReleaseWinXp|x86 = ReleaseWinXp|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.Debug|x64.ActiveCfg = Debug|x64 @@ -21,6 +23,10 @@ Global {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.Release|x64.Build.0 = Release|x64 {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.Release|x86.ActiveCfg = Release|Win32 {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.Release|x86.Build.0 = Release|Win32 + {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.ReleaseWinXp|x64.ActiveCfg = ReleaseWinXp|x64 + {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.ReleaseWinXp|x64.Build.0 = ReleaseWinXp|x64 + {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.ReleaseWinXp|x86.ActiveCfg = ReleaseWinXp|Win32 + {F7B78CC7-6984-4F79-9486-ABCF87DF9F06}.ReleaseWinXp|x86.Build.0 = ReleaseWinXp|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SpaceCadetPinball/SpaceCadetPinball.vcxproj b/SpaceCadetPinball/SpaceCadetPinball.vcxproj index 1848094..3507d15 100644 --- a/SpaceCadetPinball/SpaceCadetPinball.vcxproj +++ b/SpaceCadetPinball/SpaceCadetPinball.vcxproj @@ -5,6 +5,14 @@ Debug Win32 + + ReleaseWinXp + Win32 + + + ReleaseWinXp + x64 + Release Win32 @@ -39,6 +47,13 @@ true NotSet + + Application + false + v141_xp + true + NotSet + Application true @@ -52,6 +67,13 @@ true NotSet + + Application + false + v141_xp + true + NotSet + @@ -63,12 +85,18 @@ + + + + + + true @@ -80,9 +108,15 @@ false + + false + false + + false + Use @@ -140,6 +174,27 @@ Comctl32.lib;Winmm.lib;Htmlhelp.lib;%(AdditionalDependencies) + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + pch.h + true + + + Windows + true + true + true + Comctl32.lib;Winmm.lib;Htmlhelp.lib;%(AdditionalDependencies) + + Use @@ -161,6 +216,27 @@ Comctl32.lib;Winmm.lib;Htmlhelp.lib;%(AdditionalDependencies) + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + pch.h + true + + + Windows + true + true + true + Comctl32.lib;Winmm.lib;Htmlhelp.lib;%(AdditionalDependencies) + + @@ -244,7 +320,9 @@ Create Create Create + Create Create + Create diff --git a/SpaceCadetPinball/fullscrn.cpp b/SpaceCadetPinball/fullscrn.cpp index 3779003..c7084e4 100644 --- a/SpaceCadetPinball/fullscrn.cpp +++ b/SpaceCadetPinball/fullscrn.cpp @@ -28,8 +28,8 @@ const resolution_info fullscrn::resolution_array[3] = }; float fullscrn::ScaleX = 1; float fullscrn::ScaleY = 1; -float fullscrn::OffsetX = 0; -float fullscrn::OffsetY = 0; +int fullscrn::OffsetX = 0; +int fullscrn::OffsetY = 0; void fullscrn::init(int width, int height, int isFullscreen, HWND winHandle, HMENU menuHandle, int changeDisplay) { @@ -450,13 +450,7 @@ void fullscrn::window_size_changed() if (options::Options.UniformScaling) { ScaleY = ScaleX = min(ScaleX, ScaleY); - OffsetX = floor((client.right - res->TableWidth * ScaleX) / 2); - OffsetY = floor((client.bottom - res->TableHeight * ScaleY) / 2); - auto dc = GetDC(hWnd); - if (dc) - { - BitBlt(dc, 0, 0, client.right, client.bottom, dc, 0, 0, BLACKNESS); - ReleaseDC(hWnd, dc); - } + OffsetX = static_cast(floor((client.right - res->TableWidth * ScaleX) / 2)); + OffsetY = static_cast(floor((client.bottom - res->TableHeight * ScaleY) / 2)); } } diff --git a/SpaceCadetPinball/fullscrn.h b/SpaceCadetPinball/fullscrn.h index bfaaf3a..ab752c2 100644 --- a/SpaceCadetPinball/fullscrn.h +++ b/SpaceCadetPinball/fullscrn.h @@ -30,8 +30,8 @@ public: static const resolution_info resolution_array[3]; static float ScaleX; static float ScaleY; - static float OffsetX; - static float OffsetY; + static int OffsetX; + static int OffsetY; static void init(int width, int height, int isFullscreen, HWND winHandle, HMENU menuHandle, int changeDisplay); static void shutdown(); diff --git a/SpaceCadetPinball/gdrv.cpp b/SpaceCadetPinball/gdrv.cpp index 72acb48..1a6d9b6 100644 --- a/SpaceCadetPinball/gdrv.cpp +++ b/SpaceCadetPinball/gdrv.cpp @@ -317,6 +317,25 @@ void gdrv::blit(gdrv_bitmap8* bmp, int xSrc, int ySrcOff, int xDest, int yDest, void gdrv::blat(gdrv_bitmap8* bmp, int xDest, int yDest) { HDC dc = winmain::_GetDC(hwnd); + + // Black background for uniform scaling + if (fullscrn::OffsetX > 0 || fullscrn::OffsetY > 0) + { + const auto rop = BLACKNESS; + RECT client{}; + GetClientRect(hwnd, &client); + if (fullscrn::OffsetX > 0) + { + BitBlt(dc, 0, 0, fullscrn::OffsetX, client.bottom, dc, 0, 0, rop); + BitBlt(dc, client.right - fullscrn::OffsetX, 0, client.right, client.bottom, dc, 0, 0, rop); + } + else + { + BitBlt(dc, 0, 0, client.right, fullscrn::OffsetY, dc, 0, 0, rop); + BitBlt(dc, 0, client.bottom - fullscrn::OffsetY, client.right, client.bottom, dc, 0, 0, rop); + } + } + SelectPalette(dc, palette_handle, 0); RealizePalette(dc); SetStretchBltMode(dc, stretchMode);