Increased ISLE accuracy (#319)

* Improve WndProc accuracy

* Another accuracy fix for `WndProc`
This commit is contained in:
Christian Semmler 2023-12-09 12:49:13 -05:00 committed by GitHub
parent 7a0558f99d
commit 02aaf1533f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,6 +24,10 @@
#include <dsound.h> #include <dsound.h>
// Might be static functions of IsleApp
BOOL FindExistingInstance(void);
BOOL StartDirectSound(void);
// FUNCTION: ISLE 0x401000 // FUNCTION: ISLE 0x401000
IsleApp::IsleApp() IsleApp::IsleApp()
{ {
@ -169,9 +173,6 @@ void IsleApp::SetupVideoFlags(
} }
} }
BOOL FindExistingInstance(void);
BOOL StartDirectSound(void);
// FUNCTION: ISLE 0x401610 // FUNCTION: ISLE 0x401610
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{ {
@ -389,11 +390,11 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
return DefWindowProcA(hWnd, uMsg, wParam, lParam); return DefWindowProcA(hWnd, uMsg, wParam, lParam);
case WM_DISPLAYCHANGE: case WM_DISPLAYCHANGE:
if (g_isle && VideoManager() && g_isle->m_fullScreen && VideoManager()->GetDirect3D() && if (g_isle && VideoManager() && g_isle->m_fullScreen && VideoManager()->GetDirect3D()) {
VideoManager()->GetDirect3D()->GetDeviceModeFinder()) { if (VideoManager()->GetDirect3D()->GetDeviceModeFinder()) {
int targetDepth = wParam;
int targetWidth = LOWORD(lParam); int targetWidth = LOWORD(lParam);
int targetHeight = HIWORD(lParam); int targetHeight = HIWORD(lParam);
int targetDepth = wParam;
if (g_waitingForTargetDepth) { if (g_waitingForTargetDepth) {
g_waitingForTargetDepth = 0; g_waitingForTargetDepth = 0;
@ -401,7 +402,9 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
else { else {
BOOL valid = FALSE; BOOL valid = FALSE;
if (targetWidth == g_targetWidth && targetHeight == g_targetHeight && g_targetDepth == targetDepth) {
if (g_targetWidth == targetWidth && g_targetHeight == targetHeight &&
g_targetDepth == targetDepth) {
valid = TRUE; valid = TRUE;
} }
@ -417,24 +420,16 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
} }
} }
}
return DefWindowProcA(hWnd, uMsg, wParam, lParam); 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: case WM_KEYDOWN:
// While this probably should be (HIWORD(lParam) & KF_REPEAT), this seems // While this probably should be (HIWORD(lParam) & KF_REPEAT), this seems
// to be what the assembly is actually doing // to be what the assembly is actually doing
if (lParam & (KF_REPEAT << 16)) { if (lParam & (KF_REPEAT << 16)) {
return DefWindowProcA(hWnd, uMsg, wParam, lParam); return DefWindowProcA(hWnd, uMsg, wParam, lParam);
} }
keyCode = wParam;
type = c_notificationKeyPress; type = c_notificationKeyPress;
keyCode = wParam;
break; break;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
g_mousemoved = 1; g_mousemoved = 1;
@ -457,6 +452,13 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return 0; return 0;
} }
break; 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: default:
return DefWindowProcA(hWnd, uMsg, wParam, lParam); return DefWindowProcA(hWnd, uMsg, wParam, lParam);
} }
@ -812,10 +814,8 @@ inline void IsleApp::Tick(BOOL sleepIfNotNextFrame)
} }
this->m_gameStarted = 1; this->m_gameStarted = 1;
} }
return;
} }
else if (sleepIfNotNextFrame != 0)
if (sleepIfNotNextFrame != 0)
Sleep(0); Sleep(0);
} }