From 02aaf1533fdfb3db499bb5d275f6c1af99e96d7a Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 9 Dec 2023 12:49:13 -0500 Subject: [PATCH] Increased `ISLE` accuracy (#319) * Improve WndProc accuracy * Another accuracy fix for `WndProc` --- ISLE/isleapp.cpp | 74 ++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 1d4d4641..8d1fe268 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -24,6 +24,10 @@ #include +// Might be static functions of IsleApp +BOOL FindExistingInstance(void); +BOOL StartDirectSound(void); + // FUNCTION: ISLE 0x401000 IsleApp::IsleApp() { @@ -169,9 +173,6 @@ void IsleApp::SetupVideoFlags( } } -BOOL FindExistingInstance(void); -BOOL StartDirectSound(void); - // FUNCTION: ISLE 0x401610 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { @@ -389,52 +390,46 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } return DefWindowProcA(hWnd, uMsg, wParam, lParam); case WM_DISPLAYCHANGE: - if (g_isle && VideoManager() && g_isle->m_fullScreen && VideoManager()->GetDirect3D() && - VideoManager()->GetDirect3D()->GetDeviceModeFinder()) { - int targetWidth = LOWORD(lParam); - int targetHeight = HIWORD(lParam); - int targetDepth = wParam; + if (g_isle && VideoManager() && g_isle->m_fullScreen && VideoManager()->GetDirect3D()) { + if (VideoManager()->GetDirect3D()->GetDeviceModeFinder()) { + int targetDepth = wParam; + int targetWidth = LOWORD(lParam); + int targetHeight = HIWORD(lParam); - if (g_waitingForTargetDepth) { - g_waitingForTargetDepth = 0; - g_targetDepth = targetDepth; - } - else { - BOOL valid = FALSE; - if (targetWidth == g_targetWidth && targetHeight == g_targetHeight && g_targetDepth == targetDepth) { - valid = TRUE; + if (g_waitingForTargetDepth) { + g_waitingForTargetDepth = 0; + g_targetDepth = targetDepth; } + else { + BOOL valid = FALSE; - if (g_rmDisabled) { - if (valid) { - g_reqEnableRMDevice = 1; + if (g_targetWidth == targetWidth && g_targetHeight == targetHeight && + g_targetDepth == targetDepth) { + valid = TRUE; + } + + if (g_rmDisabled) { + if (valid) { + g_reqEnableRMDevice = 1; + } + } + else if (!valid) { + g_rmDisabled = 1; + Lego()->StartTimer(); + VideoManager()->DisableRMDevice(); } - } - else if (!valid) { - g_rmDisabled = 1; - Lego()->StartTimer(); - VideoManager()->DisableRMDevice(); } } } return DefWindowProcA(hWnd, uMsg, wParam, lParam); - case WM_SETCURSOR: - if (g_isle) { - HCURSOR hCursor = g_isle->m_cursorCurrent; - if (hCursor == g_isle->m_cursorBusy || hCursor == g_isle->m_cursorNo || !hCursor) { - SetCursor(hCursor); - return 0; - } - } - break; case WM_KEYDOWN: // While this probably should be (HIWORD(lParam) & KF_REPEAT), this seems // to be what the assembly is actually doing if (lParam & (KF_REPEAT << 16)) { return DefWindowProcA(hWnd, uMsg, wParam, lParam); } - keyCode = wParam; type = c_notificationKeyPress; + keyCode = wParam; break; case WM_MOUSEMOVE: g_mousemoved = 1; @@ -457,6 +452,13 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return 0; } break; + case WM_SETCURSOR: + if (g_isle && (g_isle->m_cursorCurrent == g_isle->m_cursorBusy || + g_isle->m_cursorCurrent == g_isle->m_cursorNo || !g_isle->m_cursorCurrent)) { + SetCursor(g_isle->m_cursorCurrent); + return 0; + } + break; default: return DefWindowProcA(hWnd, uMsg, wParam, lParam); } @@ -812,10 +814,8 @@ inline void IsleApp::Tick(BOOL sleepIfNotNextFrame) } this->m_gameStarted = 1; } - return; } - - if (sleepIfNotNextFrame != 0) + else if (sleepIfNotNextFrame != 0) Sleep(0); }