Various changes to IsleApp (#531)

* ISLE experiment

* Annotations

* Remove define.cpp

* Remove header

* Fix types

* Leave as MxLong for now
This commit is contained in:
Christian Semmler 2024-02-05 09:01:48 -05:00 committed by GitHub
parent 264b9e815b
commit a2c1bd66b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 124 additions and 147 deletions

View file

@ -415,7 +415,6 @@ set_property(TARGET lego1 PROPERTY SUFFIX ".DLL")
if (ISLE_BUILD_APP) if (ISLE_BUILD_APP)
add_executable(isle WIN32 add_executable(isle WIN32
ISLE/res/isle.rc ISLE/res/isle.rc
ISLE/define.cpp
ISLE/isleapp.cpp ISLE/isleapp.cpp
) )

View file

@ -1,34 +0,0 @@
#include "define.h"
// GLOBAL: ISLE 0x410030
IsleApp* g_isle = 0;
// GLOBAL: ISLE 0x410034
unsigned char g_mousedown = 0;
// GLOBAL: ISLE 0x410038
unsigned char g_mousemoved = 0;
// GLOBAL: ISLE 0x41003c
int g_closed = 0;
// GLOBAL: ISLE 0x410040
RECT g_windowRect = {0, 0, 640, 480};
// GLOBAL: ISLE 0x410050
int g_rmDisabled = 0;
// GLOBAL: ISLE 0x410054
int g_waitingForTargetDepth = 1;
// GLOBAL: ISLE 0x410058
int g_targetWidth = 640;
// GLOBAL: ISLE 0x41005c
int g_targetHeight = 480;
// GLOBAL: ISLE 0x410060
int g_targetDepth = 16;
// GLOBAL: ISLE 0x410064
int g_reqEnableRMDevice = 0;

View file

@ -1,25 +0,0 @@
#ifndef DEFINE_H
#define DEFINE_H
#include <mxtypes.h>
#include <windows.h>
class IsleApp;
extern IsleApp* g_isle;
extern int g_closed;
// STRING: ISLE 0x4101c4
#define WNDCLASS_NAME "Lego Island MainNoM App"
// STRING: ISLE 0x4101dc
#define WINDOW_TITLE "LEGO\xAE"
extern unsigned char g_mousedown;
extern unsigned char g_mousemoved;
extern RECT g_windowRect;
extern int g_rmDisabled;
extern int g_waitingForTargetDepth;
extern int g_targetWidth;
extern int g_targetHeight;
extern int g_targetDepth;
extern int g_reqEnableRMDevice;
#endif // DEFINE_H

View file

@ -1,6 +1,6 @@
#include "isleapp.h" #include "isleapp.h"
#include "define.h" #include "decomp.h"
#include "legoanimationmanager.h" #include "legoanimationmanager.h"
#include "legobuildingmanager.h" #include "legobuildingmanager.h"
#include "legogamestate.h" #include "legogamestate.h"
@ -23,9 +23,50 @@
#include <dsound.h> #include <dsound.h>
DECOMP_SIZE_ASSERT(IsleApp, 0x8c)
// GLOBAL: ISLE 0x410030
IsleApp* g_isle = NULL;
// GLOBAL: ISLE 0x410034
unsigned char g_mousedown = 0;
// GLOBAL: ISLE 0x410038
unsigned char g_mousemoved = 0;
// GLOBAL: ISLE 0x41003c
BOOL g_closed = FALSE;
// GLOBAL: ISLE 0x410040
RECT g_windowRect = {0, 0, 640, 480};
// GLOBAL: ISLE 0x410050
BOOL g_rmDisabled = FALSE;
// GLOBAL: ISLE 0x410054
BOOL g_waitingForTargetDepth = TRUE;
// GLOBAL: ISLE 0x410058
int g_targetWidth = 640;
// GLOBAL: ISLE 0x41005c
int g_targetHeight = 480;
// GLOBAL: ISLE 0x410060
int g_targetDepth = 16;
// GLOBAL: ISLE 0x410064
BOOL g_reqEnableRMDevice = FALSE;
// STRING: ISLE 0x4101c4
#define WNDCLASS_NAME "Lego Island MainNoM App"
// STRING: ISLE 0x4101dc
#define WINDOW_TITLE "LEGO\xAE"
// Might be static functions of IsleApp // Might be static functions of IsleApp
BOOL FindExistingInstance(void); BOOL FindExistingInstance();
BOOL StartDirectSound(void); BOOL StartDirectSound();
// FUNCTION: ISLE 0x401000 // FUNCTION: ISLE 0x401000
IsleApp::IsleApp() IsleApp::IsleApp()
@ -34,23 +75,23 @@ IsleApp::IsleApp()
m_cdPath = NULL; m_cdPath = NULL;
m_deviceId = NULL; m_deviceId = NULL;
m_savePath = NULL; m_savePath = NULL;
m_fullScreen = 1; m_fullScreen = TRUE;
m_flipSurfaces = 0; m_flipSurfaces = FALSE;
m_backBuffersInVram = 1; m_backBuffersInVram = TRUE;
m_using8bit = 0; m_using8bit = FALSE;
m_using16bit = 1; m_using16bit = TRUE;
m_unk0x24 = 0; m_unk0x24 = 0;
m_drawCursor = 0; m_drawCursor = FALSE;
m_use3dSound = 1; m_use3dSound = TRUE;
m_useMusic = 1; m_useMusic = TRUE;
m_useJoystick = 0; m_useJoystick = FALSE;
m_joystickIndex = 0; m_joystickIndex = 0;
m_wideViewAngle = 1; m_wideViewAngle = TRUE;
m_islandQuality = 1; m_islandQuality = 1;
m_islandTexture = 1; m_islandTexture = 1;
m_gameStarted = 0; m_gameStarted = FALSE;
m_frameDelta = 10; m_frameDelta = 10;
m_windowActive = 1; m_windowActive = TRUE;
#ifdef COMPAT_MODE #ifdef COMPAT_MODE
{ {
@ -235,8 +276,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// Get reference to window // Get reference to window
HWND window; HWND window;
if (g_isle->m_windowHandle) { if (g_isle->GetWindowHandle()) {
window = g_isle->m_windowHandle; window = g_isle->GetWindowHandle();
} }
// Load accelerators (this call actually achieves nothing - there is no "AppAccel" resource in the original - but // Load accelerators (this call actually achieves nothing - there is no "AppAccel" resource in the original - but
@ -266,16 +307,16 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
} }
MSG nextMsg; MSG nextMsg;
if (!g_isle || !g_isle->m_windowHandle || msg.message != WM_MOUSEMOVE || if (!g_isle || !g_isle->GetWindowHandle() || msg.message != WM_MOUSEMOVE ||
!PeekMessageA(&nextMsg, NULL, 0, 0, PM_NOREMOVE) || nextMsg.message != WM_MOUSEMOVE) { !PeekMessageA(&nextMsg, NULL, 0, 0, PM_NOREMOVE) || nextMsg.message != WM_MOUSEMOVE) {
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessageA(&msg); DispatchMessageA(&msg);
} }
if (g_reqEnableRMDevice) { if (g_reqEnableRMDevice) {
g_reqEnableRMDevice = 0; g_reqEnableRMDevice = FALSE;
VideoManager()->EnableRMDevice(); VideoManager()->EnableRMDevice();
g_rmDisabled = 0; g_rmDisabled = FALSE;
Lego()->StopTimer(); Lego()->StopTimer();
} }
@ -299,7 +340,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
} }
// FUNCTION: ISLE 0x401ca0 // FUNCTION: ISLE 0x401ca0
BOOL FindExistingInstance(void) BOOL FindExistingInstance()
{ {
HWND hWnd = FindWindowA(WNDCLASS_NAME, WINDOW_TITLE); HWND hWnd = FindWindowA(WNDCLASS_NAME, WINDOW_TITLE);
if (hWnd) { if (hWnd) {
@ -312,7 +353,7 @@ BOOL FindExistingInstance(void)
} }
// FUNCTION: ISLE 0x401ce0 // FUNCTION: ISLE 0x401ce0
BOOL StartDirectSound(void) BOOL StartDirectSound()
{ {
LPDIRECTSOUND lpDS = NULL; LPDIRECTSOUND lpDS = NULL;
HRESULT ret = DirectSoundCreate(NULL, &lpDS, NULL); HRESULT ret = DirectSoundCreate(NULL, &lpDS, NULL);
@ -341,7 +382,7 @@ 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_ACTIVATEAPP: case WM_ACTIVATEAPP:
if (g_isle) { if (g_isle) {
if ((wParam != 0) && (g_isle->m_fullScreen)) { if ((wParam != 0) && (g_isle->GetFullScreen())) {
MoveWindow( MoveWindow(
hWnd, hWnd,
g_windowRect.left, g_windowRect.left,
@ -351,7 +392,7 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
TRUE TRUE
); );
} }
g_isle->m_windowActive = wParam; g_isle->SetWindowActive(wParam);
} }
return DefWindowProcA(hWnd, uMsg, wParam, lParam); return DefWindowProcA(hWnd, uMsg, wParam, lParam);
case WM_CLOSE: case WM_CLOSE:
@ -376,41 +417,41 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (wParam == SC_SCREENSAVE) { if (wParam == SC_SCREENSAVE) {
return 0; return 0;
} }
if (wParam == SC_CLOSE && g_closed == 0) { if (wParam == SC_CLOSE && g_closed == FALSE) {
if (g_isle) { if (g_isle) {
if (g_rmDisabled) { if (g_rmDisabled) {
ShowWindow(g_isle->m_windowHandle, SW_RESTORE); ShowWindow(g_isle->GetWindowHandle(), SW_RESTORE);
} }
PostMessageA(g_isle->m_windowHandle, WM_CLOSE, 0, 0); PostMessageA(g_isle->GetWindowHandle(), WM_CLOSE, 0, 0);
return 0; return 0;
} }
} }
else if (g_isle && g_isle->m_fullScreen && (wParam == SC_MOVE || wParam == SC_KEYMENU)) { else if (g_isle && g_isle->GetFullScreen() && (wParam == SC_MOVE || wParam == SC_KEYMENU)) {
return 0; return 0;
} }
return DefWindowProcA(hWnd, uMsg, wParam, lParam); return DefWindowProcA(hWnd, uMsg, wParam, lParam);
case WM_EXITMENULOOP: case WM_EXITMENULOOP:
return DefWindowProcA(hWnd, uMsg, wParam, lParam); return DefWindowProcA(hWnd, uMsg, wParam, lParam);
case WM_MOVING: case WM_MOVING:
if (g_isle && g_isle->m_fullScreen) { if (g_isle && g_isle->GetFullScreen()) {
GetWindowRect(hWnd, (LPRECT) lParam); GetWindowRect(hWnd, (LPRECT) lParam);
return 0; return 0;
} }
return DefWindowProcA(hWnd, uMsg, wParam, lParam); return DefWindowProcA(hWnd, uMsg, wParam, lParam);
case WM_NCPAINT: case WM_NCPAINT:
if (g_isle && g_isle->m_fullScreen) { if (g_isle && g_isle->GetFullScreen()) {
return 0; return 0;
} }
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->GetFullScreen() && VideoManager()->GetDirect3D()) {
if (VideoManager()->GetDirect3D()->GetAssignedDevice()) { if (VideoManager()->GetDirect3D()->GetAssignedDevice()) {
int targetDepth = wParam; int targetDepth = wParam;
int targetWidth = LOWORD(lParam); int targetWidth = LOWORD(lParam);
int targetHeight = HIWORD(lParam); int targetHeight = HIWORD(lParam);
if (g_waitingForTargetDepth) { if (g_waitingForTargetDepth) {
g_waitingForTargetDepth = 0; g_waitingForTargetDepth = FALSE;
g_targetDepth = targetDepth; g_targetDepth = targetDepth;
} }
else { else {
@ -423,11 +464,11 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (g_rmDisabled) { if (g_rmDisabled) {
if (valid) { if (valid) {
g_reqEnableRMDevice = 1; g_reqEnableRMDevice = TRUE;
} }
} }
else if (!valid) { else if (!valid) {
g_rmDisabled = 1; g_rmDisabled = TRUE;
Lego()->StartTimer(); Lego()->StartTimer();
VideoManager()->DisableRMDevice(); VideoManager()->DisableRMDevice();
} }
@ -466,9 +507,9 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
break; break;
case WM_SETCURSOR: case WM_SETCURSOR:
if (g_isle && (g_isle->m_cursorCurrent == g_isle->m_cursorBusy || if (g_isle && (g_isle->GetCursorCurrent() == g_isle->GetCursorBusy() ||
g_isle->m_cursorCurrent == g_isle->m_cursorNo || !g_isle->m_cursorCurrent)) { g_isle->GetCursorCurrent() == g_isle->GetCursorNo() || !g_isle->GetCursorCurrent())) {
SetCursor(g_isle->m_cursorCurrent); SetCursor(g_isle->GetCursorCurrent());
return 0; return 0;
} }
break; break;
@ -480,7 +521,7 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (InputManager()) { if (InputManager()) {
InputManager()->QueueEvent(type, wParam, LOWORD(lParam), HIWORD(lParam), keyCode); InputManager()->QueueEvent(type, wParam, LOWORD(lParam), HIWORD(lParam), keyCode);
} }
if (g_isle && g_isle->m_drawCursor && type == c_notificationMouseMove) { if (g_isle && g_isle->GetDrawCursor() && type == c_notificationMouseMove) {
int x = LOWORD(lParam); int x = LOWORD(lParam);
int y = HIWORD(lParam); int y = HIWORD(lParam);
if (x >= 640) { if (x >= 640) {
@ -662,7 +703,7 @@ BOOL IsleApp::ReadReg(LPCSTR name, LPSTR outValue, DWORD outSize)
} }
// FUNCTION: ISLE 0x4027b0 // FUNCTION: ISLE 0x4027b0
int IsleApp::ReadRegBool(LPCSTR name, BOOL* out) BOOL IsleApp::ReadRegBool(LPCSTR name, BOOL* out)
{ {
char buffer[256]; char buffer[256];
@ -684,7 +725,7 @@ int IsleApp::ReadRegBool(LPCSTR name, BOOL* out)
} }
// FUNCTION: ISLE 0x402880 // FUNCTION: ISLE 0x402880
int IsleApp::ReadRegInt(LPCSTR name, int* out) BOOL IsleApp::ReadRegInt(LPCSTR name, int* out)
{ {
char buffer[256]; char buffer[256];
@ -771,7 +812,7 @@ inline void IsleApp::Tick(BOOL sleepIfNotNextFrame)
// GLOBAL: ISLE 0x4101bc // GLOBAL: ISLE 0x4101bc
static int g_startupDelay = 200; static int g_startupDelay = 200;
if (!this->m_windowActive) { if (!m_windowActive) {
Sleep(0); Sleep(0);
return; return;
} }
@ -788,10 +829,10 @@ inline void IsleApp::Tick(BOOL sleepIfNotNextFrame)
MxLong currentTime = Timer()->GetRealTime(); MxLong currentTime = Timer()->GetRealTime();
if (currentTime < g_lastFrameTime) { if (currentTime < g_lastFrameTime) {
g_lastFrameTime = -this->m_frameDelta; g_lastFrameTime = -m_frameDelta;
} }
if (this->m_frameDelta + g_lastFrameTime < currentTime) { if (m_frameDelta + g_lastFrameTime < currentTime) {
if (!Lego()->IsTimerRunning()) { if (!Lego()->IsTimerRunning()) {
TickleManager()->Tickle(); TickleManager()->Tickle();
} }
@ -834,7 +875,7 @@ inline void IsleApp::Tick(BOOL sleepIfNotNextFrame)
if (Start(&ds) != SUCCESS) { if (Start(&ds) != SUCCESS) {
return; return;
} }
this->m_gameStarted = 1; m_gameStarted = TRUE;
} }
} }
else if (sleepIfNotNextFrame != 0) { else if (sleepIfNotNextFrame != 0) {

View file

@ -6,6 +6,7 @@
#include <windows.h> #include <windows.h>
// SIZE 0x8c
class IsleApp { class IsleApp {
public: public:
IsleApp(); IsleApp();
@ -28,56 +29,51 @@ class IsleApp {
MxResult SetupWindow(HINSTANCE hInstance, LPSTR lpCmdLine); MxResult SetupWindow(HINSTANCE hInstance, LPSTR lpCmdLine);
BOOL ReadReg(LPCSTR name, LPSTR outValue, DWORD outSize); BOOL ReadReg(LPCSTR name, LPSTR outValue, DWORD outSize);
int ReadRegBool(LPCSTR name, BOOL* out); BOOL ReadRegBool(LPCSTR name, BOOL* out);
int ReadRegInt(LPCSTR name, int* out); BOOL ReadRegInt(LPCSTR name, int* out);
void LoadConfig(); void LoadConfig();
void Tick(BOOL sleepIfNotNextFrame); void Tick(BOOL sleepIfNotNextFrame);
void SetupCursor(WPARAM wParam); void SetupCursor(WPARAM wParam);
// private: inline HWND GetWindowHandle() { return m_windowHandle; }
// 0 inline MxLong GetFrameDelta() { return m_frameDelta; }
LPSTR m_hdPath; inline BOOL GetFullScreen() { return m_fullScreen; }
LPSTR m_cdPath; inline HCURSOR GetCursorCurrent() { return m_cursorCurrent; }
LPSTR m_deviceId; inline HCURSOR GetCursorBusy() { return m_cursorBusy; }
LPSTR m_savePath; inline HCURSOR GetCursorNo() { return m_cursorNo; }
inline BOOL GetDrawCursor() { return m_drawCursor; }
// 10 inline void SetWindowActive(BOOL p_windowActive) { m_windowActive = p_windowActive; }
BOOL m_fullScreen;
BOOL m_flipSurfaces;
BOOL m_backBuffersInVram;
BOOL m_using8bit;
// 20 private:
BOOL m_using16bit; LPSTR m_hdPath; // 0x00
int m_unk0x24; LPSTR m_cdPath; // 0x04
BOOL m_use3dSound; LPSTR m_deviceId; // 0x08
BOOL m_useMusic; LPSTR m_savePath; // 0x0c
BOOL m_fullScreen; // 0x10
// 30 BOOL m_flipSurfaces; // 0x14
BOOL m_useJoystick; BOOL m_backBuffersInVram; // 0x18
int m_joystickIndex; BOOL m_using8bit; // 0x1c
BOOL m_wideViewAngle; BOOL m_using16bit; // 0x20
int m_islandQuality; int m_unk0x24; // 0x24
BOOL m_use3dSound; // 0x28
// 40 BOOL m_useMusic; // 0x2c
int m_islandTexture; BOOL m_useJoystick; // 0x30
int m_gameStarted; int m_joystickIndex; // 0x34
MxLong m_frameDelta; BOOL m_wideViewAngle; // 0x38
int m_islandQuality; // 0x3c
// 4c int m_islandTexture; // 0x40
MxVideoParam m_videoParam; BOOL m_gameStarted; // 0x44
MxLong m_frameDelta; // 0x48
// 70 MxVideoParam m_videoParam; // 0x4c
BOOL m_windowActive; BOOL m_windowActive; // 0x70
HWND m_windowHandle; HWND m_windowHandle; // 0x74
BOOL m_drawCursor; BOOL m_drawCursor; // 0x78
HCURSOR m_cursorArrow; HCURSOR m_cursorArrow; // 0x7c
HCURSOR m_cursorBusy; // 0x80
// 80 HCURSOR m_cursorNo; // 0x84
HCURSOR m_cursorBusy; HCURSOR m_cursorCurrent; // 0x88
HCURSOR m_cursorNo;
HCURSOR m_cursorCurrent;
}; };
#endif // ISLEAPP_H #endif // ISLEAPP_H