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,52 +390,46 @@ 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 targetWidth = LOWORD(lParam); int targetDepth = wParam;
int targetHeight = HIWORD(lParam); int targetWidth = LOWORD(lParam);
int targetDepth = wParam; int targetHeight = HIWORD(lParam);
if (g_waitingForTargetDepth) { if (g_waitingForTargetDepth) {
g_waitingForTargetDepth = 0; g_waitingForTargetDepth = 0;
g_targetDepth = targetDepth; g_targetDepth = targetDepth;
}
else {
BOOL valid = FALSE;
if (targetWidth == g_targetWidth && targetHeight == g_targetHeight && g_targetDepth == targetDepth) {
valid = TRUE;
} }
else {
BOOL valid = FALSE;
if (g_rmDisabled) { if (g_targetWidth == targetWidth && g_targetHeight == targetHeight &&
if (valid) { g_targetDepth == targetDepth) {
g_reqEnableRMDevice = 1; 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); 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);
} }