From 55984fbb085fee69d1ac003f331921c5797d0de9 Mon Sep 17 00:00:00 2001 From: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com> Date: Tue, 16 Feb 2021 19:03:45 +0300 Subject: [PATCH] Fixed x64 build warnings. Replaced __intN with intN_t. Some cleanup. --- SpaceCadetPinball/Sound.cpp | 2 +- SpaceCadetPinball/Sound.h | 2 +- SpaceCadetPinball/SpaceCadetPinball.cpp | 2 +- SpaceCadetPinball/TDemo.cpp | 2 +- SpaceCadetPinball/TEdgeSegment.cpp | 2 +- SpaceCadetPinball/TEdgeSegment.h | 2 +- SpaceCadetPinball/TLightGroup.cpp | 2 +- SpaceCadetPinball/TPinballComponent.h | 4 +- SpaceCadetPinball/WaveMix.cpp | 67 +++++++++-------- SpaceCadetPinball/WaveMix.h | 53 ++++++------- SpaceCadetPinball/control.cpp | 4 +- SpaceCadetPinball/fullscrn.cpp | 36 ++++----- SpaceCadetPinball/fullscrn.h | 12 +-- SpaceCadetPinball/gdrv.cpp | 2 +- SpaceCadetPinball/gdrv.h | 2 +- SpaceCadetPinball/loader.cpp | 26 +++---- SpaceCadetPinball/loader.h | 2 +- SpaceCadetPinball/midi.cpp | 2 +- SpaceCadetPinball/midi.h | 2 +- SpaceCadetPinball/options.cpp | 98 +++++++++++++------------ SpaceCadetPinball/options.h | 4 +- SpaceCadetPinball/partman.h | 22 +++--- SpaceCadetPinball/pb.cpp | 2 +- SpaceCadetPinball/pch.h | 1 + SpaceCadetPinball/render.h | 2 +- SpaceCadetPinball/score.cpp | 9 +-- SpaceCadetPinball/winmain.cpp | 22 +++--- SpaceCadetPinball/zdrv.cpp | 4 +- SpaceCadetPinball/zdrv.h | 10 +-- 29 files changed, 201 insertions(+), 199 deletions(-) diff --git a/SpaceCadetPinball/Sound.cpp b/SpaceCadetPinball/Sound.cpp index 6febff9..bd2f860 100644 --- a/SpaceCadetPinball/Sound.cpp +++ b/SpaceCadetPinball/Sound.cpp @@ -147,7 +147,7 @@ void Sound::Close() } } -void Sound::PlaySound(MIXWAVE* wavePtr, int minChannel, int maxChannel, unsigned int dwFlags, __int16 loops) +void Sound::PlaySound(MIXWAVE* wavePtr, int minChannel, int maxChannel, unsigned int dwFlags, int16_t loops) { MIXPLAYPARAMS mixParams{}; diff --git a/SpaceCadetPinball/Sound.h b/SpaceCadetPinball/Sound.h index ec427ff..c599fe5 100644 --- a/SpaceCadetPinball/Sound.h +++ b/SpaceCadetPinball/Sound.h @@ -10,7 +10,7 @@ public: static void Activate(); static void Deactivate(); static void Close(); - static void PlaySound(MIXWAVE* wavePtr, int minChannel, int maxChannel, unsigned int dwFlags, __int16 loops); + static void PlaySound(MIXWAVE* wavePtr, int minChannel, int maxChannel, unsigned int dwFlags, int16_t loops); static MIXWAVE* LoadWaveFile(LPCSTR lpName); static void FreeSound(MIXWAVE* wave); static void Flush(int channelFrom, int channelTo); diff --git a/SpaceCadetPinball/SpaceCadetPinball.cpp b/SpaceCadetPinball/SpaceCadetPinball.cpp index e5a423f..f7219c9 100644 --- a/SpaceCadetPinball/SpaceCadetPinball.cpp +++ b/SpaceCadetPinball/SpaceCadetPinball.cpp @@ -30,7 +30,7 @@ int main() gdrv::DibSetUsage(dib, 0, 1); auto d = objlist_class(2, 4); - for (int i = 0; i < 100; i++) + for (size_t i = 0; i < 100; i++) { d.Add((void*)i); } diff --git a/SpaceCadetPinball/TDemo.cpp b/SpaceCadetPinball/TDemo.cpp index c10e092..0618e12 100644 --- a/SpaceCadetPinball/TDemo.cpp +++ b/SpaceCadetPinball/TDemo.cpp @@ -100,7 +100,7 @@ void TDemo::Collision(TBall* ball, vector_type* nextPosition, vector_type* direc ball->Position.Y = nextPosition->Y; ball->RayMaxDistance -= coef; - switch (reinterpret_cast(edge->WallValue)) + switch (reinterpret_cast(edge->WallValue)) { case 1400: if (!FlipLeftTimer && !FlipLeftFlag) diff --git a/SpaceCadetPinball/TEdgeSegment.cpp b/SpaceCadetPinball/TEdgeSegment.cpp index 81dfa77..6c90935 100644 --- a/SpaceCadetPinball/TEdgeSegment.cpp +++ b/SpaceCadetPinball/TEdgeSegment.cpp @@ -19,7 +19,7 @@ void TEdgeSegment::port_draw() } TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* collComp, char* activeFlagPtr, - unsigned int collisionGroup, float offset, int wallValue) + unsigned int collisionGroup, float offset, size_t wallValue) { vector_type center{}, start{}, end{}, prevCenter{}, vec1{}, vec2{}, dstVec{}; TEdgeSegment* edge = nullptr; diff --git a/SpaceCadetPinball/TEdgeSegment.h b/SpaceCadetPinball/TEdgeSegment.h index 8ebde3a..b54d9de 100644 --- a/SpaceCadetPinball/TEdgeSegment.h +++ b/SpaceCadetPinball/TEdgeSegment.h @@ -28,5 +28,5 @@ public: virtual float FindCollisionDistance(ray_type* ray) = 0; static TEdgeSegment* install_wall(float* floatArr, TCollisionComponent* collComp, char* activeFlagPtr, - unsigned int collisionGroup, float offset, int wallValue); + unsigned int collisionGroup, float offset, size_t wallValue); }; diff --git a/SpaceCadetPinball/TLightGroup.cpp b/SpaceCadetPinball/TLightGroup.cpp index b41f4e2..3b6af07 100644 --- a/SpaceCadetPinball/TLightGroup.cpp +++ b/SpaceCadetPinball/TLightGroup.cpp @@ -19,7 +19,7 @@ TLightGroup::TLightGroup(TPinballTable* table, int groupIndex) : TPinballCompone { int count; Timer1TimeDefault = *loader::query_float_attribute(groupIndex, 0, 903); - __int16* groupIndArr = loader::query_iattribute(groupIndex, 1027, &count); + int16_t* groupIndArr = loader::query_iattribute(groupIndex, 1027, &count); for (int index = 0; index < count; ++groupIndArr) { auto comp = dynamic_cast(table->find_component(*groupIndArr)); diff --git a/SpaceCadetPinball/TPinballComponent.h b/SpaceCadetPinball/TPinballComponent.h index d23d0c5..839c570 100644 --- a/SpaceCadetPinball/TPinballComponent.h +++ b/SpaceCadetPinball/TPinballComponent.h @@ -28,8 +28,8 @@ public: void* operator new(size_t Size); void operator delete(void* p); - __int8 UnusedBaseFlag; - __int8 ActiveFlag; + char UnusedBaseFlag; + char ActiveFlag; int MessageField; char* GroupName; int Unknown4; diff --git a/SpaceCadetPinball/WaveMix.cpp b/SpaceCadetPinball/WaveMix.cpp index 0c58f36..89c4b1e 100644 --- a/SpaceCadetPinball/WaveMix.cpp +++ b/SpaceCadetPinball/WaveMix.cpp @@ -9,8 +9,8 @@ CHANNELNODE WaveMix::channel_nodes[MAXQUEUEDWAVES]; CHANNELNODE* WaveMix::free_channel_nodes; unsigned char WaveMix::volume_table[11][256]; int WaveMix::debug_flag; -void (*WaveMix::cmixit_ptr)(unsigned __int8* lpDest, unsigned __int8** rgWaveSrc, volume_struct* volume, int iNumWaves, - unsigned __int16 length); +void (*WaveMix::cmixit_ptr)(uint8_t* lpDest, uint8_t** rgWaveSrc, volume_struct* volume, int iNumWaves, + uint16_t length); HMODULE WaveMix::HModule; PCMWAVEFORMAT WaveMix::gpFormat = {{1u, 1u, 11025u, 11025u, 1u}, 8u}; char WaveMix::string_buffer[256] = "WaveMix V 2.3 by Angel M. Diaz, Jr. (c) Microsoft 1993-1995"; @@ -670,7 +670,7 @@ int WaveMix::Play(MIXPLAYPARAMS* lpMixPlayParams) memcpy(&channel->PlayParams, lpMixPlayParams, sizeof channel->PlayParams); channel->lpMixWave = channel->PlayParams.lpMixWave; channel->dwNumSamples = channel->PlayParams.lpMixWave->wh.dwBufferLength; - auto lpData = (unsigned __int8*)channel->PlayParams.lpMixWave->wh.lpData; + auto lpData = (uint8_t*)channel->PlayParams.lpMixWave->wh.lpData; channel->lpPos = lpData; channel->lpEnd = &lpData[channel->dwNumSamples - globals->PCM.wf.nBlockAlign]; channel->PlayParams.iChannel = iChannel; @@ -781,9 +781,8 @@ int WaveMix::Play(MIXPLAYPARAMS* lpMixPlayParams) if (curChannel->PlayParams.wLoops == 0xFFFF) curChannel->dwEndPos = -1; else - curChannel->dwEndPos = curChannel->dwStartPos + curChannel->dwNumSamples * (curChannel - ->PlayParams.wLoops + 1) - - globals2->PCM.wf.nBlockAlign; + curChannel->dwEndPos = curChannel->dwStartPos + curChannel->dwNumSamples * (curChannel->PlayParams. + wLoops + 1) - globals2->PCM.wf.nBlockAlign; } if (!remixFlag || !globals2->pfnRemix(wavePosition, nullptr)) @@ -1098,18 +1097,18 @@ int WaveMix::ReadRegistryForAppSpecificConfigs(MIXCONFIG* lpConfig) lpConfig->WaveBlockLen = static_cast(ReadRegistryInt(phkResult, "WaveBlockLen", 0)); lpConfig->CmixPtrDefaultFlag = 1; if ((dwFlags & 0x20) == 0) - lpConfig->ResetMixDefaultFlag = static_cast(ReadRegistryInt(phkResult, "Remix", 1)) != 2; + lpConfig->ResetMixDefaultFlag = static_cast(ReadRegistryInt(phkResult, "Remix", 1)) != 2; if ((dwFlags & 0x40) == 0) { int defaultGoodWavePos = DefaultGoodWavePos(lpConfig->wDeviceID); - lpConfig->GoodWavePos = static_cast(ReadRegistryInt( + lpConfig->GoodWavePos = static_cast(ReadRegistryInt( phkResult, "GoodWavePos", defaultGoodWavePos)) != 0; } if ((dwFlags & 0x100) == 0) lpConfig->ShowDebugDialogs = static_cast(ReadRegistryInt(phkResult, "ShowDebugDialogs", 0)); if ((dwFlags & 0x200) == 0) { - int defaultPauseBlocks = DefaultPauseBlocks(static_cast(lpConfig->WaveBlockCount)); + int defaultPauseBlocks = DefaultPauseBlocks(static_cast(lpConfig->WaveBlockCount)); lpConfig->PauseBlocks = static_cast(ReadRegistryInt(phkResult, "PauseBlocks", defaultPauseBlocks)); } lpConfig->dwFlags = 1023; @@ -1153,7 +1152,7 @@ int WaveMix::DefaultGoodWavePos(unsigned uDeviceID) int WaveMix::DefaultPauseBlocks(int waveBlocks) { int result; - if (GetVersion() < 0x80000000 || static_cast(GetVersion()) < 4u) + if (GetVersion() < 0x80000000 || static_cast(GetVersion()) < 4u) result = waveBlocks; else result = 0; @@ -1723,7 +1722,7 @@ DWORD WaveMix::AddFactor(DWORD a1, DWORD a2) dialog_template* WaveMix::MakeSettingsDlgTemplate() { - auto size = 0u; + size_t size = 0u; dialog_template* temp = MakeDlgTemplate(&size, 0x80C80080, 0, 0, 212, 132, L"WavMix32 Settings (Ver %X.%X Static)"); temp = AddDlgControl(&size, temp, 128, 65537, 1, 155, 5, 50, 14, L"&Ok"); temp = AddDlgControl(&size, temp, 128, 0x10000, 2, 155, 25, 50, 14, L"&Cancel"); @@ -1745,7 +1744,7 @@ dialog_template* WaveMix::MakeSettingsDlgTemplate() return AddDlgControl(&size, temp, 128, 65539, 1004, 55, 117, 75, 10, L"Good Get Position"); } -dialog_template* WaveMix::MakeDlgTemplate(unsigned* totalSize, unsigned style, short x, short y, short cx, short cy, +dialog_template* WaveMix::MakeDlgTemplate(size_t* totalSize, unsigned style, short x, short y, short cx, short cy, const wchar_t* String) { auto dlgSize = 2 * wcslen(String) + 24; @@ -1769,7 +1768,7 @@ dialog_template* WaveMix::MakeDlgTemplate(unsigned* totalSize, unsigned style, s return dlgTemplate; } -dialog_template* WaveMix::AddDlgControl(unsigned* totalSize, dialog_template* dlgTemplate, short idClass, +dialog_template* WaveMix::AddDlgControl(size_t* totalSize, dialog_template* dlgTemplate, short idClass, unsigned style, WORD id, short x, short y, short cx, short cy, const wchar_t* String) { @@ -1782,7 +1781,7 @@ dialog_template* WaveMix::AddDlgControl(unsigned* totalSize, dialog_template* dl *totalSize = *totalSize - (*totalSize & 3) + 4; GlobalUnlock(GlobalHandle(dlgTemplate2)); - unsigned int newSize = *totalSize; + auto newSize = *totalSize; HGLOBAL hGlobal = GlobalReAlloc(GlobalHandle(dlgTemplate2), newSize, 0x42u); dlgTemplate2 = static_cast(GlobalLock(hGlobal)); if (dlgTemplate2) @@ -1813,7 +1812,7 @@ void WaveMix::DestroySettingsDlgTemplate(LPCVOID pMem) } } -int WaveMix::Settings_OnInitDialog(HWND hWnd, int wParam, MIXCONFIG* lpMixconfig) +int WaveMix::Settings_OnInitDialog(HWND hWnd, WPARAM wParam, MIXCONFIG* lpMixconfig) { tagWAVEOUTCAPSA pwoc{}; CHAR String[256]; @@ -1878,7 +1877,7 @@ int WaveMix::Settings_OnInitDialog(HWND hWnd, int wParam, MIXCONFIG* lpMixconfig return 1; } -int WaveMix::Settings_OnCommand(HWND hWnd, int command, int lParam, int wParam) +int WaveMix::Settings_OnCommand(HWND hWnd, int command, LPARAM lParam, int wParam) { auto userData = reinterpret_cast(GetWindowLongPtrA(hWnd, -21)); if (command == 1) @@ -1937,9 +1936,9 @@ const char* WaveMix::GetOperatingSystemPrefix() { if (GetVersion() < 0x80000000) return "WinNT:"; - if (GetVersion() >= 0x80000000 && static_cast(GetVersion()) >= 4u) + if (GetVersion() >= 0x80000000 && static_cast(GetVersion()) >= 4u) return "Win95:"; - if (GetVersion() >= 0x80000000 && static_cast(GetVersion()) < 4u) + if (GetVersion() >= 0x80000000 && static_cast(GetVersion()) < 4u) return "Win31:"; return "OS_X"; /*The next big thing: waveOut on OSX*/ } @@ -1977,7 +1976,7 @@ void WaveMix::SaveConfigSettings(unsigned dwFlags) } if ((dwFlags & 2) != 0) { - wsprintfA(string_buffer, "%d", static_cast(11 * (Globals->PCM.wf.nSamplesPerSec / 0x2B11))); + wsprintfA(string_buffer, "%d", static_cast(11 * (Globals->PCM.wf.nSamplesPerSec / 0x2B11))); WritePrivateProfileStringA(Globals->szDevicePName, "SamplesPerSec", string_buffer, FileName); } if ((dwFlags & 4) != 0) @@ -2213,14 +2212,14 @@ HPSTR WaveMix::BitsPerSampleAlign(HPSTR lpInData, WORD nInBPS, WORD nOutBPS, DWO { if (nInBPS / 8u <= nOutBPS / 8u) { - auto dst = static_cast<__int16*>(dataBuf); + auto dst = static_cast(dataBuf); for (auto src = lpInData; dwNumSamples; --dwNumSamples) *dst++ = static_cast((*src++ - 128) * 256); } else { auto dst = static_cast(dataBuf); - for (auto src = reinterpret_cast<__int16*>(lpInData); dwNumSamples; --dwNumSamples) + for (auto src = reinterpret_cast(lpInData); dwNumSamples; --dwNumSamples) { *dst++ = static_cast(*src++ / 256 + 128); } @@ -2288,8 +2287,8 @@ HPSTR WaveMix::ChannelAlign(HPSTR lpInData, WORD nInChannels, WORD nOutChannels, } else { - auto src = reinterpret_cast<__int16*>(lpInData); - auto dst = reinterpret_cast<__int16*>(dataBuf); + auto src = reinterpret_cast(lpInData); + auto dst = reinterpret_cast(dataBuf); for (; dwNumSamples; --dwNumSamples, src += 2) { *dst++ = static_cast((src[0] + src[1]) / 2); @@ -2394,7 +2393,7 @@ void WaveMix::AvgSample(HPSTR lpOutData, HPSTR lpInData, unsigned nSkip, int nBy auto average = 0; for (auto avgIndex = nSkip; avgIndex; --avgIndex) { - average += static_cast(*src) - 128; + average += static_cast(*src) - 128; src += nChannels; } *dst++ = static_cast(average / nSkip + 128); @@ -2402,8 +2401,8 @@ void WaveMix::AvgSample(HPSTR lpOutData, HPSTR lpInData, unsigned nSkip, int nBy } else { - auto src = reinterpret_cast<__int16*>(lpInData); - auto dst = reinterpret_cast<__int16*>(lpOutData); + auto src = reinterpret_cast(lpInData); + auto dst = reinterpret_cast(lpOutData); for (auto channelIndex = nChannels; channelIndex; --channelIndex) { auto curSrc = src++; @@ -2422,8 +2421,8 @@ void WaveMix::RepSample(HPSTR lpOutData, HPSTR lpInData, unsigned nRep, int nByt { if (nBytesPerSample == 1) { - auto src = reinterpret_cast(lpInData); - auto dst = reinterpret_cast(lpOutData); + auto src = reinterpret_cast(lpInData); + auto dst = reinterpret_cast(lpOutData); for (auto channelIndex = nChannels; channelIndex; --channelIndex) { auto sample = *src; @@ -2442,8 +2441,8 @@ void WaveMix::RepSample(HPSTR lpOutData, HPSTR lpInData, unsigned nRep, int nByt } else { - auto src = reinterpret_cast<__int16*>(lpInData); - auto dst = reinterpret_cast<__int16*>(lpOutData); + auto src = reinterpret_cast(lpInData); + auto dst = reinterpret_cast(lpOutData); for (auto channelIndex2 = nChannels; channelIndex2; channelIndex2--) { auto sample = *src; @@ -2534,8 +2533,8 @@ void WaveMix::ResetWavePosIfNoChannelData() } } -void WaveMix::cmixit(unsigned __int8* lpDest, unsigned __int8** rgWaveSrc, volume_struct* volumeArr, int iNumWaves, - unsigned __int16 length) +void WaveMix::cmixit(uint8_t* lpDest, uint8_t** rgWaveSrc, volume_struct* volumeArr, int iNumWaves, + uint16_t length) { if (!length) return; @@ -2614,9 +2613,9 @@ LRESULT WaveMix::WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) INT_PTR WaveMix::SettingsDlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { if (Msg == WM_INITDIALOG) - return Settings_OnInitDialog(hWnd, wParam, (MIXCONFIG*)lParam); + return Settings_OnInitDialog(hWnd, wParam, reinterpret_cast(lParam)); if (Msg != WM_COMMAND) return 0; - Settings_OnCommand(hWnd, static_cast(wParam), lParam, HIWORD(wParam)); + Settings_OnCommand(hWnd, LOWORD(wParam), lParam, HIWORD(wParam)); return 1; } diff --git a/SpaceCadetPinball/WaveMix.h b/SpaceCadetPinball/WaveMix.h index f92794c..d089938 100644 --- a/SpaceCadetPinball/WaveMix.h +++ b/SpaceCadetPinball/WaveMix.h @@ -1,5 +1,6 @@ #pragma once + /* flag values for play params */ #define WMIX_QUEUEWAVE 0x00 #define WMIX_CLEARQUEUE 0x01 @@ -15,8 +16,8 @@ struct GLOBALS; struct volume_struct { - unsigned __int16 L; - unsigned __int16 R; + uint16_t L; + uint16_t R; }; @@ -59,14 +60,14 @@ struct MIXCONFIG DWORD dwFlags; WORD wChannels; WORD wSamplingRate; - unsigned __int16 WaveBlockCount; - unsigned __int16 WaveBlockLen; - __int16 CmixPtrDefaultFlag; - unsigned __int16 ResetMixDefaultFlag; - unsigned __int16 GoodWavePos; - unsigned __int16 wDeviceID; - unsigned __int16 PauseBlocks; - __int16 ShowDebugDialogs; + uint16_t WaveBlockCount; + uint16_t WaveBlockLen; + int16_t CmixPtrDefaultFlag; + uint16_t ResetMixDefaultFlag; + uint16_t GoodWavePos; + uint16_t wDeviceID; + uint16_t PauseBlocks; + int16_t ShowDebugDialogs; HKEY RegistryKey; }; @@ -88,14 +89,14 @@ struct PLAYQUEUE struct GLOBALS { WORD wMagic1; - __int16 unknown0; + int16_t unknown0; HWND hWndApp; int unknown2; HWAVEOUT hWaveOut; int fActive; int SettingsDialogActiveFlag; unsigned int wDeviceID; - char szDevicePName[96]; + char szDevicePName[96]; WAVEOUTCAPSA WaveoutCaps; volume_struct DefaultVolume; volume_struct ChannelVolume[MAXCHANNELS]; @@ -112,13 +113,13 @@ struct GLOBALS DWORD dwBaseTime; int fGoodGetPos; DWORD dwWaveOutPos; - void (*CmixPtr)(unsigned __int8* lpDest, unsigned __int8** rgWaveSrc, volume_struct* volume, int iNumWaves, - unsigned __int16 length); + void (*CmixPtr)(uint8_t* lpDest, uint8_t** rgWaveSrc, volume_struct* volume, int iNumWaves, + uint16_t length); int (* pfnRemix)(DWORD, CHANNELNODE*); DWORD (* pfnSampleAdjust)(DWORD, DWORD); CHANNELNODE* pWaitList; - __int16 wMagic2; - __int16 unknown112; + int16_t wMagic2; + int16_t unknown112; }; struct dialog_template @@ -182,16 +183,16 @@ private: static DWORD SubFactor(DWORD a1, DWORD a2); static DWORD AddFactor(DWORD a1, DWORD a2); static dialog_template* MakeSettingsDlgTemplate(); - static dialog_template* MakeDlgTemplate(unsigned* totalSize, unsigned style, __int16 x, __int16 y, __int16 cx, - __int16 cy, + static dialog_template* MakeDlgTemplate(size_t* totalSize, unsigned style, int16_t x, int16_t y, int16_t cx, + int16_t cy, const wchar_t* String); - static dialog_template* AddDlgControl(unsigned int* totalSize, dialog_template* dlgTemplate, __int16 idClass, + static dialog_template* AddDlgControl(size_t* totalSize, dialog_template* dlgTemplate, int16_t idClass, unsigned style, - WORD id, __int16 x, __int16 y, __int16 cx, __int16 cy, + WORD id, int16_t x, int16_t y, int16_t cx, int16_t cy, const wchar_t* String); static void DestroySettingsDlgTemplate(LPCVOID pMem); - static int Settings_OnInitDialog(HWND hWnd, int wParam, MIXCONFIG* lpMixconfig); - static int Settings_OnCommand(HWND hWnd, int command, int lParam, int wParam); + static int Settings_OnInitDialog(HWND hWnd, WPARAM wParam, MIXCONFIG* lpMixconfig); + static int Settings_OnCommand(HWND hWnd, int command, LPARAM lParam, int wParam); static int ReadRegistryToGetMachineSpecificInfSection(unsigned wDeviceId, LPSTR lpString1, int maxLength); static const char* GetOperatingSystemPrefix(); static unsigned int FigureOutDMABufferSize(unsigned int waveBlockLen, PCMWAVEFORMAT* pcm); @@ -215,8 +216,8 @@ private: static int HasCurrentOutputFormat(MIXWAVE* lpMixWave); static CHANNELNODE* GetChannelNode(); static void ResetWavePosIfNoChannelData(); - static void cmixit(unsigned __int8* lpDest, unsigned __int8** rgWaveSrc, volume_struct* volumeArr, int iNumWaves, - unsigned __int16 length); + static void cmixit(uint8_t* lpDest, uint8_t** rgWaveSrc, volume_struct* volumeArr, int iNumWaves, + uint16_t length); static LRESULT __stdcall WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); static INT_PTR __stdcall SettingsDlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); @@ -226,8 +227,8 @@ private: static CHANNELNODE* free_channel_nodes; static unsigned char volume_table[11][256]; static int debug_flag; - static void (*cmixit_ptr)(unsigned __int8* lpDest, unsigned __int8** rgWaveSrc, volume_struct* volume, - int iNumWaves, unsigned __int16 length); + static void (*cmixit_ptr)(uint8_t* lpDest, uint8_t** rgWaveSrc, volume_struct* volume, + int iNumWaves, uint16_t length); static HMODULE HModule; static GLOBALS *Globals, *GlobalsActive; static PCMWAVEFORMAT gpFormat; diff --git a/SpaceCadetPinball/control.cpp b/SpaceCadetPinball/control.cpp index 4484e98..56cf46c 100644 --- a/SpaceCadetPinball/control.cpp +++ b/SpaceCadetPinball/control.cpp @@ -1922,7 +1922,7 @@ void control::GravityWellKickoutControl(int code, TPinballComponent* caller) } case 64: { - auto score = reinterpret_cast(caller); + auto score = reinterpret_cast(caller); if (score) { sprintf_s(Buffer, pinball::get_rc_string(82, 0), score); @@ -2230,7 +2230,7 @@ void control::HyperspaceKickOutControl(int code, TPinballComponent* caller) case 4: { control_hyper_lights_tag.Component->Message(0, 0.0); - auto addedScore = TableG->AddScore(caller->get_scoring(4)); + size_t addedScore = TableG->AddScore(caller->get_scoring(4)); GravityWellKickoutControl(64, reinterpret_cast(addedScore)); break; } diff --git a/SpaceCadetPinball/fullscrn.cpp b/SpaceCadetPinball/fullscrn.cpp index 788955e..9554084 100644 --- a/SpaceCadetPinball/fullscrn.cpp +++ b/SpaceCadetPinball/fullscrn.cpp @@ -316,36 +316,32 @@ void fullscrn::activate(int flag) } } -void fullscrn::fillRect(int right, int bottom) +void fullscrn::fillRect(int right, int bottom, int left, int top) { - // Weird reg usage, should be zero - int v2 = 0; - int v3 = 0; - RECT rc; - HGDIOBJ brush = CreateSolidBrush(0); + auto brush = CreateSolidBrush(0); if (brush) { - HDC dc = winmain::_GetDC(hWnd); - HGDIOBJ brushHandle = SelectObject(dc, brush); + auto dc = winmain::_GetDC(hWnd); + auto prevBrush = SelectObject(dc, brush); if (dc) { - rc.right = right + v2 + 1; - rc.bottom = bottom + v3 + 1; - rc.left = v2; - rc.top = v3; - FillRect(dc, &rc, static_cast(brush)); + rc.right = left + right + 1; + rc.bottom = top + bottom + 1; + rc.left = left; + rc.top = top; + FillRect(dc, &rc, brush); ReleaseDC(hWnd, dc); } - SelectObject(dc, brushHandle); + SelectObject(dc, prevBrush); DeleteObject(brush); } } unsigned fullscrn::convert_mouse_pos(unsigned int mouseXY) { - unsigned __int16 x = mouseXY & 0xffFF - render::vscreen.XPosition; - unsigned __int16 y = (mouseXY >> 16) - render::vscreen.YPosition; + uint16_t x = mouseXY & 0xffFF - render::vscreen.XPosition; + uint16_t y = (mouseXY >> 16) - render::vscreen.YPosition; return x | y << 16; } @@ -369,7 +365,7 @@ void fullscrn::paint() if (fullscrn_flag1 & 1) { menuHeight = GetSystemMetrics(SM_CYMENU); - fillRect(WindowRect1.right - 1, menuHeight); + fillRect(WindowRect1.right - 1, menuHeight, 0, 0); } } else @@ -378,7 +374,7 @@ void fullscrn::paint() menuHeight = GetSystemMetrics(SM_CYMENU); else menuHeight = 0; - fillRect(WindowRect1.right, menuHeight + WindowRect1.bottom); + fillRect(WindowRect1.right, menuHeight + WindowRect1.bottom, 0, 0); } } render::paint(); @@ -430,8 +426,8 @@ int fullscrn::get_max_supported_resolution() int fullscrn::get_screen_resolution() { - auto height = static_cast(GetSystemMetrics(SM_CYSCREEN)); - return static_cast(GetSystemMetrics(SM_CXSCREEN)) | (height << 16); + auto height = static_cast(GetSystemMetrics(SM_CYSCREEN)); + return static_cast(GetSystemMetrics(SM_CXSCREEN)) | (height << 16); } void fullscrn::window_size_changed() diff --git a/SpaceCadetPinball/fullscrn.h b/SpaceCadetPinball/fullscrn.h index 78dd36c..bfaaf3a 100644 --- a/SpaceCadetPinball/fullscrn.h +++ b/SpaceCadetPinball/fullscrn.h @@ -8,11 +8,11 @@ struct resolution_info { - __int16 ScreenWidth; - __int16 ScreenHeight; - __int16 TableWidth; - __int16 TableHeight; - __int16 ResolutionMenuId; + int16_t ScreenWidth; + int16_t ScreenHeight; + int16_t TableWidth; + int16_t TableHeight; + int16_t ResolutionMenuId; }; class fullscrn @@ -62,5 +62,5 @@ private : static int setWindowFlagsDisDlg(); static int enableFullscreen(); static int disableFullscreen(); - static void fillRect(int right, int bottom); + static void fillRect(int right, int bottom, int left, int top); }; diff --git a/SpaceCadetPinball/gdrv.cpp b/SpaceCadetPinball/gdrv.cpp index a3b20da..55aaef8 100644 --- a/SpaceCadetPinball/gdrv.cpp +++ b/SpaceCadetPinball/gdrv.cpp @@ -40,7 +40,7 @@ void gdrv::get_focus() } -BITMAPINFO* gdrv::DibCreate(__int16 bpp, int width, int height) +BITMAPINFO* gdrv::DibCreate(int16_t bpp, int width, int height) { auto sizeBytes = height * (width * bpp / 8 + 3 & 0xFFFFFFFC); auto buf = GlobalAlloc(GHND, sizeBytes + sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); diff --git a/SpaceCadetPinball/gdrv.h b/SpaceCadetPinball/gdrv.h index 11892f7..6a5e1cc 100644 --- a/SpaceCadetPinball/gdrv.h +++ b/SpaceCadetPinball/gdrv.h @@ -45,7 +45,7 @@ public: static int init(HINSTANCE hInst, HWND hWnd); static int uninit(); static void get_focus(); - static BITMAPINFO* DibCreate(__int16 bpp, int width, int height); + static BITMAPINFO* DibCreate(int16_t bpp, int width, int height); static void DibSetUsage(BITMAPINFO* dib, HPALETTE hpal, int someFlag); static int create_bitmap_dib(gdrv_bitmap8* bmp, int width, int height); static int create_bitmap(gdrv_bitmap8* bmp, int width, int height); diff --git a/SpaceCadetPinball/loader.cpp b/SpaceCadetPinball/loader.cpp index ba5dfc8..4f8522d 100644 --- a/SpaceCadetPinball/loader.cpp +++ b/SpaceCadetPinball/loader.cpp @@ -89,7 +89,7 @@ void loader::loadfrom(datFileStruct* datFile) for (auto groupIndex = 0; groupIndex < datFile->NumberOfGroups; ++groupIndex) { - auto value = reinterpret_cast<__int16*>(partman::field(datFile, groupIndex, datFieldTypes::ShortValue)); + auto value = reinterpret_cast(partman::field(datFile, groupIndex, datFieldTypes::ShortValue)); if (value && *value == 202) { if (sound_count < 65) @@ -116,7 +116,7 @@ void loader::unload() int loader::get_sound_id(int groupIndex) { - __int16 soundIndex = 1; + int16_t soundIndex = 1; if (sound_count <= 1) { error(25, 26); @@ -139,7 +139,7 @@ int loader::get_sound_id(int groupIndex) sound_list[soundIndex].Duration = 0.0; if (soundGroupId > 0 && !pinball::quickFlag) { - auto value = reinterpret_cast<__int16*>(partman::field(loader_table, soundGroupId, + auto value = reinterpret_cast(partman::field(loader_table, soundGroupId, datFieldTypes::ShortValue)); if (value && *value == 202) { @@ -173,7 +173,7 @@ short loader::query_visual_states(int groupIndex) short result; if (groupIndex < 0) return error(0, 17); - auto shortArr = reinterpret_cast<__int16*>(partman::field(loader_table, groupIndex, datFieldTypes::ShortArray)); + auto shortArr = reinterpret_cast(partman::field(loader_table, groupIndex, datFieldTypes::ShortArray)); if (shortArr && *shortArr == 100) result = shortArr[1]; else @@ -192,7 +192,7 @@ char* loader::query_name(int groupIndex) return partman::field(loader_table, groupIndex, datFieldTypes::GroupName); } -__int16* loader::query_iattribute(int groupIndex, int firstValue, int* arraySize) +int16_t* loader::query_iattribute(int groupIndex, int firstValue, int* arraySize) { if (groupIndex < 0) { @@ -202,7 +202,7 @@ __int16* loader::query_iattribute(int groupIndex, int firstValue, int* arraySize for (auto skipIndex = 0;; ++skipIndex) { - auto shortArr = reinterpret_cast<__int16*>(partman::field_nth(loader_table, groupIndex, + auto shortArr = reinterpret_cast(partman::field_nth(loader_table, groupIndex, datFieldTypes::ShortArray, skipIndex)); if (!shortArr) break; @@ -239,7 +239,7 @@ float* loader::query_float_attribute(int groupIndex, int groupIndexOffset, int f skipIndex)); if (!floatArr) break; - if (static_cast<__int16>(floor(*floatArr)) == firstValue) + if (static_cast(floor(*floatArr)) == firstValue) return floatArr + 1; } @@ -268,7 +268,7 @@ float loader::query_float_attribute(int groupIndex, int groupIndexOffset, int fi datFieldTypes::FloatArray, skipIndex)); if (!floatArr) break; - if (static_cast<__int16>(floor(*floatArr)) == firstValue) + if (static_cast(floor(*floatArr)) == firstValue) return floatArr[1]; } @@ -282,7 +282,7 @@ int loader::material(int groupIndex, visualStruct* visual) { if (groupIndex < 0) return error(0, 21); - auto shortArr = reinterpret_cast<__int16*>(partman::field(loader_table, groupIndex, datFieldTypes::ShortValue)); + auto shortArr = reinterpret_cast(partman::field(loader_table, groupIndex, datFieldTypes::ShortValue)); if (!shortArr) return error(1, 21); if (*shortArr != 300) @@ -326,7 +326,7 @@ int loader::state_id(int groupIndex, int groupIndexOffset) auto visualState = query_visual_states(groupIndex); if (visualState <= 0) return error(12, 24); - auto shortArr = reinterpret_cast<__int16*>(partman::field(loader_table, groupIndex, datFieldTypes::ShortValue)); + auto shortArr = reinterpret_cast(partman::field(loader_table, groupIndex, datFieldTypes::ShortValue)); if (!shortArr) return error(1, 24); if (*shortArr != 200) @@ -337,7 +337,7 @@ int loader::state_id(int groupIndex, int groupIndexOffset) return groupIndex; groupIndex += groupIndexOffset; - shortArr = reinterpret_cast<__int16*>(partman::field(loader_table, groupIndex, datFieldTypes::ShortValue)); + shortArr = reinterpret_cast(partman::field(loader_table, groupIndex, datFieldTypes::ShortValue)); if (!shortArr) return error(1, 24); if (*shortArr != 201) @@ -349,7 +349,7 @@ int loader::kicker(int groupIndex, visualKickerStruct* kicker) { if (groupIndex < 0) return error(0, 20); - auto shortArr = reinterpret_cast<__int16*>(partman::field(loader_table, groupIndex, datFieldTypes::ShortValue)); + auto shortArr = reinterpret_cast(partman::field(loader_table, groupIndex, datFieldTypes::ShortValue)); if (!shortArr) return error(1, 20); if (*shortArr != 400) @@ -417,7 +417,7 @@ int loader::query_visual(int groupIndex, int groupIndexOffset, visualStruct* vis visual->ZMap->ZPtr2 = visual->ZMap->ZPtr1; } - auto shortArr = reinterpret_cast<__int16*>(partman::field(loader_table, stateId, datFieldTypes::ShortArray)); + auto shortArr = reinterpret_cast(partman::field(loader_table, stateId, datFieldTypes::ShortArray)); if (shortArr) { unsigned int shortArrSize = partman::field_size(loader_table, stateId, datFieldTypes::ShortArray); diff --git a/SpaceCadetPinball/loader.h b/SpaceCadetPinball/loader.h index 61c6bea..caf94f8 100644 --- a/SpaceCadetPinball/loader.h +++ b/SpaceCadetPinball/loader.h @@ -66,7 +66,7 @@ public: static char* query_name(int groupIndex); static float* query_float_attribute(int groupIndex, int groupIndexOffset, int firstValue); static float query_float_attribute(int groupIndex, int groupIndexOffset, int firstValue, float defVal); - static __int16* query_iattribute(int groupIndex, int firstValue, int* arraySize); + static int16_t* query_iattribute(int groupIndex, int firstValue, int* arraySize); static float play_sound(int soundIndex); static datFileStruct* loader_table; private: diff --git a/SpaceCadetPinball/midi.cpp b/SpaceCadetPinball/midi.cpp index 2f32050..289b5b5 100644 --- a/SpaceCadetPinball/midi.cpp +++ b/SpaceCadetPinball/midi.cpp @@ -61,7 +61,7 @@ int midi::music_init(HWND hwnd) return midi_seq1_open; } -MCIERROR midi::restart_midi_seq(int param) +MCIERROR midi::restart_midi_seq(LPARAM param) { if (pb::FullTiltMode) { diff --git a/SpaceCadetPinball/midi.h b/SpaceCadetPinball/midi.h index 8d4e430..a02ee79 100644 --- a/SpaceCadetPinball/midi.h +++ b/SpaceCadetPinball/midi.h @@ -55,7 +55,7 @@ public: static MCIERROR play_pb_theme(int flag); static MCIERROR music_stop(); static int music_init(HWND hwnd); - static MCIERROR restart_midi_seq(int param); + static MCIERROR restart_midi_seq(LPARAM param); static void music_shutdown(); private: static tagMCI_OPEN_PARMSA mci_open_info; diff --git a/SpaceCadetPinball/options.cpp b/SpaceCadetPinball/options.cpp index 5d2da3c..196263c 100644 --- a/SpaceCadetPinball/options.cpp +++ b/SpaceCadetPinball/options.cpp @@ -195,72 +195,74 @@ void options::path_free() int options::get_int(LPCSTR optPath, LPCSTR lpValueName, int defaultValue) { DWORD dwDisposition; + HKEY hKey; - HKEY result = (HKEY)defaultValue, Data = (HKEY)defaultValue; + auto result = defaultValue; if (!OptionsRegPath) - return defaultValue; - LPCSTR regPath = path(optPath); - if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, 0xF003Fu, nullptr, &result, &dwDisposition)) + return result; + + auto regPath = path(optPath); + if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisposition)) { - optPath = (LPCSTR)4; - RegQueryValueExA(result, lpValueName, nullptr, nullptr, (LPBYTE)&Data, (LPDWORD)&optPath); - RegCloseKey(result); + DWORD bufferSize = 4; + RegQueryValueExA(hKey, lpValueName, nullptr, nullptr, reinterpret_cast(&result), &bufferSize); + RegCloseKey(hKey); } path_free(); - return (int)Data; + return result; } void options::set_int(LPCSTR optPath, LPCSTR lpValueName, int data) { DWORD dwDisposition; + HKEY hKey; - if (OptionsRegPath) + if (!OptionsRegPath) + return; + + auto regPath = path(optPath); + if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisposition)) { - const CHAR* regPath = path(optPath); - if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, 0xF003Fu, nullptr, (PHKEY)&optPath, - &dwDisposition)) - { - RegSetValueExA((HKEY)optPath, lpValueName, 0, 4u, (const BYTE*)&data, 4u); - RegCloseKey((HKEY)optPath); - } - path_free(); + RegSetValueExA(hKey, lpValueName, 0, 4u, reinterpret_cast(&data), 4u); + RegCloseKey(hKey); } + path_free(); } -void options::get_string(LPCSTR optPath, LPCSTR lpValueName, LPSTR lpString1, LPCSTR lpString2, int iMaxLength) +void options::get_string(LPCSTR optPath, LPCSTR lpValueName, LPSTR dst, LPCSTR defaultValue, int iMaxLength) { - const CHAR* v5 = (const CHAR*)iMaxLength; - lstrcpynA(lpString1, lpString2, iMaxLength); - if (OptionsRegPath) + DWORD dwDisposition; + HKEY hKey; + + lstrcpynA(dst, defaultValue, iMaxLength); + if (!OptionsRegPath) + return; + + auto regPath = path(optPath); + if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisposition)) { - const CHAR* regPath = path(optPath); - if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, 0xF003Fu, nullptr, (PHKEY)&iMaxLength, - (LPDWORD)&optPath)) - { - lpString2 = v5; - RegQueryValueExA((HKEY)iMaxLength, lpValueName, nullptr, nullptr, (LPBYTE)lpString1, (LPDWORD)&lpString2); - RegCloseKey((HKEY)iMaxLength); - } - path_free(); + DWORD bufferSize = iMaxLength; + RegQueryValueExA(hKey, lpValueName, nullptr, nullptr, reinterpret_cast(dst), &bufferSize); + RegCloseKey(hKey); } + path_free(); } void options::set_string(LPCSTR optPath, LPCSTR lpValueName, LPCSTR value) { DWORD dwDisposition; + HKEY hKey; - if (OptionsRegPath) + if (!OptionsRegPath) + return; + + auto regPath = path(optPath); + if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisposition)) { - const CHAR* regPath = path(optPath); - if (!RegCreateKeyExA(HKEY_CURRENT_USER, regPath, 0, nullptr, 0, 0xF003Fu, nullptr, (PHKEY)&optPath, - &dwDisposition)) - { - int v4 = lstrlenA(value); - RegSetValueExA((HKEY)optPath, lpValueName, 0, 1u, (const BYTE*)value, v4 + 1); - RegCloseKey((HKEY)optPath); - } - path_free(); + RegSetValueExA(hKey, lpValueName, 0, 1u, LPBYTE(value), lstrlenA(value) + 1); + RegCloseKey(hKey); } + path_free(); } @@ -408,7 +410,7 @@ INT_PTR _stdcall options::KeyMapDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPAR { short vk = *vkPtr; auto vk2And = vk & 0x4000; - auto vkChar = static_cast(vk); + auto vkChar = static_cast(vk); unsigned short maxVk; if (vk2And) @@ -487,17 +489,17 @@ INT_PTR _stdcall options::KeyMapDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPAR case KEYMAPPER_Ok: { auto ind = SendDlgItemMessageA(hDlg, KEYMAPPER_FlipperL, CB_GETCURSEL, 0, 0); - keyBindings[0] = SendDlgItemMessageA(hDlg, KEYMAPPER_FlipperL, CB_GETITEMDATA, ind, 0); + keyBindings[0] = static_cast(SendDlgItemMessageA(hDlg, KEYMAPPER_FlipperL, CB_GETITEMDATA, ind, 0)); ind = SendDlgItemMessageA(hDlg, KEYMAPPER_FlipperR, CB_GETCURSEL, 0, 0); - keyBindings[1] = SendDlgItemMessageA(hDlg, KEYMAPPER_FlipperR, CB_GETITEMDATA, ind, 0); + keyBindings[1] = static_cast(SendDlgItemMessageA(hDlg, KEYMAPPER_FlipperR, CB_GETITEMDATA, ind, 0)); ind = SendDlgItemMessageA(hDlg, KEYMAPPER_Plunger, CB_GETCURSEL, 0, 0); - keyBindings[2] = SendDlgItemMessageA(hDlg, KEYMAPPER_Plunger, CB_GETITEMDATA, ind, 0); + keyBindings[2] = static_cast(SendDlgItemMessageA(hDlg, KEYMAPPER_Plunger, CB_GETITEMDATA, ind, 0)); ind = SendDlgItemMessageA(hDlg, KEYMAPPER_BumpLeft, CB_GETCURSEL, 0, 0); - keyBindings[3] = SendDlgItemMessageA(hDlg, KEYMAPPER_BumpLeft, CB_GETITEMDATA, ind, 0); + keyBindings[3] = static_cast(SendDlgItemMessageA(hDlg, KEYMAPPER_BumpLeft, CB_GETITEMDATA, ind, 0)); ind = SendDlgItemMessageA(hDlg, KEYMAPPER_BumpRight, CB_GETCURSEL, 0, 0); - keyBindings[4] = SendDlgItemMessageA(hDlg, KEYMAPPER_BumpRight, CB_GETITEMDATA, ind, 0); + keyBindings[4] = static_cast(SendDlgItemMessageA(hDlg, KEYMAPPER_BumpRight, CB_GETITEMDATA, ind, 0)); ind = SendDlgItemMessageA(hDlg, KEYMAPPER_BumpBottom, CB_GETCURSEL, 0, 0); - keyBindings[5] = SendDlgItemMessageA(hDlg, KEYMAPPER_BumpBottom, CB_GETITEMDATA, ind, 0); + keyBindings[5] = static_cast(SendDlgItemMessageA(hDlg, KEYMAPPER_BumpBottom, CB_GETITEMDATA, ind, 0)); auto sameKeyBound = 0; auto index = 1; @@ -569,7 +571,7 @@ INT_PTR _stdcall options::KeyMapDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPAR } -LPSTR options::get_vk_key_name(unsigned __int16 vk, LPSTR keyName) +LPSTR options::get_vk_key_name(uint16_t vk, LPSTR keyName) { LONG scanCode = MapVirtualKeyA(vk, MAPVK_VK_TO_VSC) << 16; if (vk >= 0x21u && vk <= 0x2Eu) diff --git a/SpaceCadetPinball/options.h b/SpaceCadetPinball/options.h index c7c94da..73b4353 100644 --- a/SpaceCadetPinball/options.h +++ b/SpaceCadetPinball/options.h @@ -35,7 +35,7 @@ public: 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 get_string(LPCSTR optPath, LPCSTR lpValueName, LPSTR dst, LPCSTR defaultValue, int iMaxLength); static void set_string(LPCSTR optPath, LPCSTR lpValueName, LPCSTR value); static void menu_check(UINT uIDCheckItem, int check); static void menu_set(UINT uIDEnableItem, int enable); @@ -45,7 +45,7 @@ public: static void keyboard(); static INT_PTR _stdcall KeyMapDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); - static LPSTR get_vk_key_name(unsigned __int16 vk, LPSTR keyName); + static LPSTR get_vk_key_name(uint16_t vk, LPSTR keyName); static optionsStruct Options; private: diff --git a/SpaceCadetPinball/partman.h b/SpaceCadetPinball/partman.h index 7ce0bd8..b3bfc0c 100644 --- a/SpaceCadetPinball/partman.h +++ b/SpaceCadetPinball/partman.h @@ -1,6 +1,6 @@ #pragma once -enum class datFieldTypes : __int16 +enum class datFieldTypes : int16_t { ShortValue = 0, //, does not have the 32bits size value, but a 16bits value(see above). @@ -57,7 +57,7 @@ struct datEntryData struct datGroupData { - __int16 EntryCount; + int16_t EntryCount; datEntryData Entries[1]; }; @@ -73,10 +73,10 @@ struct datFileStruct struct dat8BitBmpHeader { char Resolution; - __int16 Width; - __int16 Height; - __int16 XPosition; - __int16 YPosition; + int16_t Width; + int16_t Height; + int16_t XPosition; + int16_t YPosition; int Size; bmp8Flags Flags; @@ -94,12 +94,12 @@ static_assert(sizeof(dat8BitBmpHeader) == 14, "Wrong size of dat8BitBmpHeader"); #pragma pack(push, 1) struct __declspec(align(1)) dat16BitBmpHeader { - __int16 Width; - __int16 Height; - __int16 Stride; + int16_t Width; + int16_t Height; + int16_t Stride; int Unknown0; - __int16 Unknown1_0; - __int16 Unknown1_1; + int16_t Unknown1_0; + int16_t Unknown1_1; }; #pragma pack(pop) diff --git a/SpaceCadetPinball/pb.cpp b/SpaceCadetPinball/pb.cpp index 75915c8..346ca73 100644 --- a/SpaceCadetPinball/pb.cpp +++ b/SpaceCadetPinball/pb.cpp @@ -480,7 +480,7 @@ void pb::keydown(int key) break; case 'M': char buffer[20]; - sprintf_s(buffer, "%ld", memory::use_total); + sprintf_s(buffer, "%zu", memory::use_total); MessageBoxA(winmain::hwnd_frame, buffer, "Mem:", 0x2000u); break; case 'R': diff --git a/SpaceCadetPinball/pch.h b/SpaceCadetPinball/pch.h index dcbdb38..3cee88d 100644 --- a/SpaceCadetPinball/pch.h +++ b/SpaceCadetPinball/pch.h @@ -16,6 +16,7 @@ #include #include #include +#include #include /*For control template*/ //#include diff --git a/SpaceCadetPinball/render.h b/SpaceCadetPinball/render.h index 22115eb..88173bd 100644 --- a/SpaceCadetPinball/render.h +++ b/SpaceCadetPinball/render.h @@ -17,7 +17,7 @@ struct render_sprite_type_struct zmap_header_type* ZMap; char UnknownFlag; VisualType VisualType; - __int16 Depth; + int16_t Depth; rectangle_type BmpRectCopy; int ZMapOffestY; int ZMapOffestX; diff --git a/SpaceCadetPinball/score.cpp b/SpaceCadetPinball/score.cpp index cc4ebcd..75e1499 100644 --- a/SpaceCadetPinball/score.cpp +++ b/SpaceCadetPinball/score.cpp @@ -27,7 +27,7 @@ scoreStruct* score::create(LPCSTR fieldName, gdrv_bitmap8* renderBgBmp) /*Full tilt: score box dimensions index is offset by resolution*/ auto dimensionsId = partman::record_labeled(pb::record_table, fieldName) + fullscrn::GetResolution(); - auto dimensions = reinterpret_cast<__int16*>(partman::field(loader::loader_table, dimensionsId, + auto dimensions = reinterpret_cast(partman::field(loader::loader_table, dimensionsId, datFieldTypes::ShortArray)); if (!dimensions) { @@ -76,7 +76,7 @@ void score::load_msg_font_3DPB(LPCSTR lpName) if (!resGlobal) return; - auto rcData = static_cast<__int16*>(LockResource(resGlobal)); + auto rcData = static_cast(LockResource(resGlobal)); auto fontp = memory::allocate(); msg_fontp = fontp; @@ -163,7 +163,7 @@ void score::load_msg_font_FT(LPCSTR lpName) return; memset(msg_fontp, 0, sizeof(score_msg_font_type)); - auto gapArray = reinterpret_cast<__int16*>(partman::field(pb::record_table, groupIndex, datFieldTypes::ShortArray)); + auto gapArray = reinterpret_cast(partman::field(pb::record_table, groupIndex, datFieldTypes::ShortArray)); if (gapArray) msg_fontp->GapWidth = gapArray[fullscrn::GetResolution()]; else @@ -249,8 +249,7 @@ void score::update(scoreStruct* score) if (score->Score >= 0) { _ltoa_s(score->Score, scoreBuf, 10); - int len = strlen(scoreBuf); - for (int index = len - 1; index >= 0; index--) + for (ptrdiff_t index = strlen(scoreBuf) - 1; index >= 0; index--) { unsigned char curChar = scoreBuf[index]; curChar -= '0'; diff --git a/SpaceCadetPinball/winmain.cpp b/SpaceCadetPinball/winmain.cpp index 93494fa..cbea73a 100644 --- a/SpaceCadetPinball/winmain.cpp +++ b/SpaceCadetPinball/winmain.cpp @@ -343,6 +343,8 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { + int wParamI = static_cast(wParam); + if (Msg == iFrostUniqueMsg) { if (IsIconic(hWnd)) @@ -478,11 +480,11 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP } return DefWindowProcA(hWnd, Msg, wParam, lParam); case WM_KEYUP: - pb::keyup(wParam); + pb::keyup(wParamI); return DefWindowProcA(hWnd, Msg, wParam, lParam); case WM_KEYDOWN: if (!(lParam & 0x40000000)) - pb::keydown(wParam); + pb::keydown(wParamI); switch (wParam) { case VK_ESCAPE: @@ -507,6 +509,8 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP pause(); options::keyboard(); break; + default: + break; } if (!pb::cheat_mode) return DefWindowProcA(hWnd, Msg, wParam, lParam); @@ -578,7 +582,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP auto iHwnd = reinterpret_cast(hwnd_frame); sprintf_s( cmdLine, - "%s %s%lX %s%lX", + "%s %s%zX %s%zX", tmpBuf, "select=", iHwnd, @@ -598,7 +602,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP case Menu1_2Players: case Menu1_3Players: case Menu1_4Players: - options::toggle(wParam); + options::toggle(wParamI); new_game(); break; case Menu1_MaximumResolution: @@ -606,7 +610,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP case Menu1_800x600: case Menu1_1024x768: case Menu1_WindowUniformScale: - options::toggle(wParam); + options::toggle(wParamI); break; case Menu1_Help_Topics: if (!single_step) @@ -621,7 +625,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP case Menu1_Music: if (!single_step) pause(); - options::toggle(wParam); + options::toggle(wParamI); break; case Menu1_Player_Controls: case 204: // Second controls button? @@ -659,7 +663,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP { mouse_down = 1; mouse_hsave = SetCursor(nullptr); - auto mouseXY = fullscrn::convert_mouse_pos(lParam); + auto mouseXY = fullscrn::convert_mouse_pos(static_cast(lParam)); last_mouse_x = mouseXY & 0xffFFu; last_mouse_y = mouseXY >> 16; SetCapture(hWnd); @@ -733,7 +737,7 @@ int winmain::ProcessWindowMessages() DispatchMessageA(&Msg); if (Msg.message == 18) { - return_value = Msg.wParam; + return_value = static_cast(Msg.wParam); return 0; } } @@ -744,7 +748,7 @@ int winmain::ProcessWindowMessages() DispatchMessageA(&Msg); if (Msg.message == 18) { - return_value = Msg.wParam; + return_value = static_cast(Msg.wParam); return 0; } return 1; diff --git a/SpaceCadetPinball/zdrv.cpp b/SpaceCadetPinball/zdrv.cpp index a269bfd..2109bb0 100644 --- a/SpaceCadetPinball/zdrv.cpp +++ b/SpaceCadetPinball/zdrv.cpp @@ -36,7 +36,7 @@ int zdrv::destroy_zmap(zmap_header_type* zmap) return 0; } -void zdrv::fill(zmap_header_type* zmap, int width, int height, int xOff, int yOff, unsigned __int16 fillWord) +void zdrv::fill(zmap_header_type* zmap, int width, int height, int xOff, int yOff, uint16_t fillWord) { auto dstPtr = &zmap->ZPtr1[zmap->Stride * (zmap->Height - height - yOff) + xOff]; for (int y = height; y > 0; --y) @@ -92,7 +92,7 @@ void zdrv::paint(int width, int height, gdrv_bitmap8* dstBmp, int dstBmpXOff, in void zdrv::paint_flat(int width, int height, gdrv_bitmap8* dstBmp, int dstBmpXOff, int dstBmpYOff, zmap_header_type* zMap, int dstZMapXOff, int dstZMapYOff, gdrv_bitmap8* srcBmp, int srcBmpXOff, - int srcBmpYOff, unsigned __int16 depth) + int srcBmpYOff, uint16_t depth) { int dstHeightAbs = abs(dstBmp->Height); int srcHeightAbs = abs(srcBmp->Height); diff --git a/SpaceCadetPinball/zdrv.h b/SpaceCadetPinball/zdrv.h index 6a5040f..e9c4fd5 100644 --- a/SpaceCadetPinball/zdrv.h +++ b/SpaceCadetPinball/zdrv.h @@ -6,9 +6,9 @@ struct zmap_header_type int Width; int Height; int Stride; - unsigned __int16* ZPtr1; - unsigned __int16* ZPtr2; - unsigned __int16 ZBuffer[1]; + uint16_t* ZPtr1; + uint16_t* ZPtr2; + uint16_t ZBuffer[1]; }; class zdrv @@ -17,13 +17,13 @@ public: static int pad(int width); static int create_zmap(zmap_header_type* zmap, int width, int height); static int destroy_zmap(zmap_header_type* zmap); - static void fill(zmap_header_type* zmap, int width, int height, int xOff, int yOff, unsigned __int16 fillWord); + static void fill(zmap_header_type* zmap, int width, int height, int xOff, int yOff, uint16_t fillWord); static void paint(int width, int height, gdrv_bitmap8* dstBmp, int dstBmpXOff, int dstBmpYOff, zmap_header_type* dstZMap, int dstZMapXOff, int dstZMapYOff, gdrv_bitmap8* srcBmp, int srcBmpXOff, int srcBmpYOff, zmap_header_type* srcZMap, int srcZMapXOff, int srcZMapYOff); static void paint_flat(int width, int height, gdrv_bitmap8* dstBmp, int dstBmpXOff, int dstBmpYOff, zmap_header_type* zMap, int dstZMapXOff, int dstZMapYOff, gdrv_bitmap8* srcBmp, - int srcBmpXOff, int srcBmpYOff, unsigned __int16 depth); + int srcBmpXOff, int srcBmpYOff, uint16_t depth); static void paint_spliced_bmp(int xPos, int yPos, gdrv_bitmap8* dstBmp, zmap_header_type* dstZmap, gdrv_bitmap8* srcBmp); };