mirror of
https://github.com/isledecomp/isle-portable.git
synced 2024-11-22 15:37:55 -05:00
isle: Improving WinMain and SetupWindow accuracy (#38)
* fix second Tick call, change loop * add missing parameter to SetupWindow * add missing include * reorganize CreateWindowEx * reorder cursor assignments * declare SetupWindow as inline * fix indent * WinMain 99% * minor improvement
This commit is contained in:
parent
7dbb06eef3
commit
579ee84049
4 changed files with 370 additions and 358 deletions
292
ISLE/isle.cpp
292
ISLE/isle.cpp
|
@ -1,15 +1,5 @@
|
|||
#include "isle.h"
|
||||
|
||||
#include "legoanimationmanager.h"
|
||||
#include "legobuildingmanager.h"
|
||||
#include "legomodelpresenter.h"
|
||||
#include "legopartpresenter.h"
|
||||
#include "legoworldpresenter.h"
|
||||
#include "mxdirectdraw.h"
|
||||
#include "mxdsaction.h"
|
||||
#include "mxomni.h"
|
||||
#include "res/resource.h"
|
||||
|
||||
// OFFSET: ISLE 0x401000
|
||||
Isle::Isle()
|
||||
{
|
||||
|
@ -291,284 +281,4 @@ void Isle::SetupCursor(WPARAM wParam)
|
|||
}
|
||||
|
||||
SetCursor(m_cursorCurrent);
|
||||
}
|
||||
|
||||
// OFFSET: ISLE 0x401d20
|
||||
LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (!g_isle) {
|
||||
return DefWindowProcA(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
switch (uMsg) {
|
||||
case WM_PAINT:
|
||||
return DefWindowProcA(hWnd, WM_PAINT, wParam, lParam);
|
||||
case WM_ACTIVATE:
|
||||
return DefWindowProcA(hWnd, WM_ACTIVATE, wParam, lParam);
|
||||
case WM_ACTIVATEAPP:
|
||||
if (g_isle) {
|
||||
if ((wParam != 0) && (g_isle->m_fullScreen)) {
|
||||
MoveWindow(hWnd, g_windowRect.left, g_windowRect.top,
|
||||
(g_windowRect.right - g_windowRect.left) + 1,
|
||||
(g_windowRect.bottom - g_windowRect.top) + 1, TRUE);
|
||||
}
|
||||
g_isle->m_windowActive = wParam;
|
||||
}
|
||||
return DefWindowProcA(hWnd,WM_ACTIVATEAPP,wParam,lParam);
|
||||
case WM_CLOSE:
|
||||
if (!g_closed && g_isle) {
|
||||
if (g_isle) {
|
||||
delete g_isle;
|
||||
}
|
||||
g_isle = NULL;
|
||||
g_closed = TRUE;
|
||||
return 0;
|
||||
}
|
||||
return DefWindowProcA(hWnd,WM_CLOSE,wParam,lParam);
|
||||
case WM_GETMINMAXINFO:
|
||||
{
|
||||
MINMAXINFO *mmi = (MINMAXINFO *) lParam;
|
||||
|
||||
mmi->ptMaxTrackSize.x = (g_windowRect.right - g_windowRect.left) + 1;
|
||||
mmi->ptMaxTrackSize.y = (g_windowRect.bottom - g_windowRect.top) + 1;
|
||||
mmi->ptMinTrackSize.x = (g_windowRect.right - g_windowRect.left) + 1;
|
||||
mmi->ptMinTrackSize.y = (g_windowRect.bottom - g_windowRect.top) + 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
case WM_ENTERMENULOOP:
|
||||
return DefWindowProcA(hWnd,WM_ENTERMENULOOP,wParam,lParam);
|
||||
case WM_SYSCOMMAND:
|
||||
if (wParam == SC_SCREENSAVE) {
|
||||
return 0;
|
||||
}
|
||||
if (wParam == SC_CLOSE && g_closed == 0) {
|
||||
if (g_isle) {
|
||||
if (g_rmDisabled) {
|
||||
ShowWindow(g_isle->m_windowHandle, SW_RESTORE);
|
||||
}
|
||||
PostMessageA(g_isle->m_windowHandle, WM_CLOSE, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
} else if (g_isle && g_isle->m_fullScreen && (wParam == SC_MOVE || wParam == SC_KEYMENU)) {
|
||||
return 0;
|
||||
}
|
||||
return DefWindowProcA(hWnd,WM_SYSCOMMAND,wParam,lParam);
|
||||
case WM_EXITMENULOOP:
|
||||
return DefWindowProcA(hWnd, WM_EXITMENULOOP, wParam, lParam);
|
||||
case WM_MOVING:
|
||||
if (g_isle && g_isle->m_fullScreen) {
|
||||
GetWindowRect(hWnd, (LPRECT) lParam);
|
||||
return 0;
|
||||
}
|
||||
return DefWindowProcA(hWnd, WM_MOVING, wParam, lParam);
|
||||
case WM_NCPAINT:
|
||||
if (g_isle && g_isle->m_fullScreen) {
|
||||
return 0;
|
||||
}
|
||||
return DefWindowProcA(hWnd, WM_NCPAINT, wParam, lParam);
|
||||
case WM_DISPLAYCHANGE:
|
||||
if (g_isle && VideoManager() && g_isle->m_fullScreen && VideoManager()->m_unk74 && VideoManager()->m_unk74[0x220]) {
|
||||
if (!g_waitingForTargetDepth) {
|
||||
unsigned char valid = FALSE;
|
||||
if (LOWORD(lParam) == g_targetWidth && HIWORD(lParam) == g_targetHeight && g_targetDepth == wParam) {
|
||||
valid = TRUE;
|
||||
}
|
||||
if (!g_rmDisabled) {
|
||||
if (!valid) {
|
||||
g_rmDisabled = 1;
|
||||
Lego()->vtable38();
|
||||
VideoManager()->DisableRMDevice();
|
||||
}
|
||||
} else if (valid) {
|
||||
g_reqEnableRMDevice = 1;
|
||||
}
|
||||
} else {
|
||||
g_waitingForTargetDepth = 0;
|
||||
g_targetDepth = wParam;
|
||||
}
|
||||
}
|
||||
return DefWindowProcA(hWnd, WM_DISPLAYCHANGE, wParam, lParam);
|
||||
case WM_SETCURSOR:
|
||||
case WM_KEYDOWN:
|
||||
case WM_MOUSEMOVE:
|
||||
case WM_TIMER:
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_LBUTTONUP:
|
||||
case 0x5400:
|
||||
{
|
||||
|
||||
NotificationId type = NONE;
|
||||
unsigned char keyCode = 0;
|
||||
|
||||
switch (uMsg) {
|
||||
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, WM_KEYDOWN, wParam, lParam);
|
||||
}
|
||||
keyCode = wParam;
|
||||
type = KEYDOWN;
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
g_mousemoved = 1;
|
||||
type = MOUSEMOVE;
|
||||
break;
|
||||
case WM_TIMER:
|
||||
type = TIMER;
|
||||
break;
|
||||
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_LBUTTONDOWN:
|
||||
g_mousedown = 1;
|
||||
type = MOUSEDOWN;
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
g_mousedown = 0;
|
||||
type = MOUSEUP;
|
||||
break;
|
||||
case 0x5400:
|
||||
if (g_isle) {
|
||||
g_isle->SetupCursor(wParam);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_isle) {
|
||||
if (InputManager()) {
|
||||
InputManager()->QueueEvent(type, wParam, LOWORD(lParam), HIWORD(lParam), keyCode);
|
||||
}
|
||||
if (g_isle && g_isle->m_drawCursor && type == MOUSEMOVE) {
|
||||
unsigned short x = LOWORD(lParam);
|
||||
unsigned short y = HIWORD(lParam);
|
||||
if (639 < x) {
|
||||
x = 639;
|
||||
}
|
||||
if (479 < y) {
|
||||
y = 479;
|
||||
}
|
||||
VideoManager()->MoveCursor(x,y);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return DefWindowProcA(hWnd,uMsg,wParam,lParam);
|
||||
}
|
||||
|
||||
// OFFSET: ISLE 0x4023e0
|
||||
MxResult Isle::SetupWindow(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASSA wndclass;
|
||||
ZeroMemory(&wndclass, sizeof(WNDCLASSA));
|
||||
|
||||
LoadConfig();
|
||||
|
||||
SetupVideoFlags(m_fullScreen, m_flipSurfaces, m_backBuffersInVram, m_using8bit,
|
||||
m_using16bit, m_unk24, FALSE, m_wideViewAngle, m_deviceId);
|
||||
|
||||
MxOmni::SetSound3D(m_use3dSound);
|
||||
|
||||
srand(timeGetTime() / 1000);
|
||||
SystemParametersInfoA(SPI_SETMOUSETRAILS, 0, NULL, 0);
|
||||
|
||||
ZeroMemory(&wndclass, sizeof(WNDCLASSA));
|
||||
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wndclass.lpfnWndProc = WndProc;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hIcon = LoadIconA(hInstance, MAKEINTRESOURCE(APP_ICON));
|
||||
wndclass.hCursor = LoadCursorA(hInstance, MAKEINTRESOURCE(ISLE_ARROW));
|
||||
m_cursorCurrent = wndclass.hCursor;
|
||||
m_cursorArrow = wndclass.hCursor;
|
||||
m_cursorBusy = LoadCursorA(hInstance, MAKEINTRESOURCE(ISLE_BUSY));
|
||||
m_cursorNo = LoadCursorA(hInstance, MAKEINTRESOURCE(ISLE_NO));
|
||||
wndclass.hInstance = hInstance;
|
||||
wndclass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
|
||||
wndclass.lpszClassName = WNDCLASS_NAME;
|
||||
|
||||
if (!RegisterClassA(&wndclass)) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
DWORD dwStyle;
|
||||
int x, y, width, height;
|
||||
|
||||
if (!m_fullScreen) {
|
||||
AdjustWindowRectEx(&g_windowRect, WS_CAPTION | WS_SYSMENU, 0, WS_EX_APPWINDOW);
|
||||
|
||||
height = g_windowRect.bottom - g_windowRect.top;
|
||||
width = g_windowRect.right - g_windowRect.left;
|
||||
|
||||
y = CW_USEDEFAULT;
|
||||
x = CW_USEDEFAULT;
|
||||
dwStyle = WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX;
|
||||
} else {
|
||||
AdjustWindowRectEx(&g_windowRect, WS_CAPTION | WS_SYSMENU, 0, WS_EX_APPWINDOW);
|
||||
height = g_windowRect.bottom - g_windowRect.top;
|
||||
width = g_windowRect.right - g_windowRect.left;
|
||||
dwStyle = WS_CAPTION | WS_SYSMENU;
|
||||
x = g_windowRect.left;
|
||||
y = g_windowRect.top;
|
||||
}
|
||||
|
||||
m_windowHandle = CreateWindowExA(WS_EX_APPWINDOW, WNDCLASS_NAME, WINDOW_TITLE, dwStyle,
|
||||
x, y, width + 1, height + 1, NULL, NULL, hInstance, NULL);
|
||||
if (!m_windowHandle) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if (m_fullScreen) {
|
||||
MoveWindow(m_windowHandle, g_windowRect.left, g_windowRect.top, (g_windowRect.right - g_windowRect.left) + 1, (g_windowRect.bottom - g_windowRect.top) + 1, TRUE);
|
||||
}
|
||||
|
||||
ShowWindow(m_windowHandle, SW_SHOWNORMAL);
|
||||
UpdateWindow(m_windowHandle);
|
||||
if (!SetupLegoOmni()) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
GameState()->SetSavePath(m_savePath);
|
||||
GameState()->SerializePlayersInfo(1);
|
||||
GameState()->SerializeScoreHistory(1);
|
||||
|
||||
int iVar10;
|
||||
if (m_islandQuality == 0) {
|
||||
iVar10 = 1;
|
||||
} else if (m_islandQuality == 1) {
|
||||
iVar10 = 2;
|
||||
} else {
|
||||
iVar10 = 100;
|
||||
}
|
||||
|
||||
int uVar1 = (m_islandTexture == 0);
|
||||
LegoModelPresenter::configureLegoModelPresenter(uVar1);
|
||||
LegoPartPresenter::configureLegoPartPresenter(uVar1,iVar10);
|
||||
LegoWorldPresenter::configureLegoWorldPresenter(m_islandQuality);
|
||||
LegoBuildingManager::configureLegoBuildingManager(m_islandQuality);
|
||||
LegoROI::configureLegoROI(iVar10);
|
||||
LegoAnimationManager::configureLegoAnimationManager(m_islandQuality);
|
||||
if (LegoOmni::GetInstance()) {
|
||||
if (LegoOmni::GetInstance()->GetInputManager()) {
|
||||
LegoOmni::GetInstance()->GetInputManager()->m_unk00[0xCD] = m_useJoystick;
|
||||
LegoOmni::GetInstance()->GetInputManager()->m_unk00[0x67] = m_joystickIndex;
|
||||
}
|
||||
}
|
||||
if (m_fullScreen) {
|
||||
MoveWindow(m_windowHandle, g_windowRect.left, g_windowRect.top, (g_windowRect.right - g_windowRect.left) + 1, (g_windowRect.bottom - g_windowRect.top) + 1, TRUE);
|
||||
}
|
||||
ShowWindow(m_windowHandle, SW_SHOWNORMAL);
|
||||
UpdateWindow(m_windowHandle);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
247
ISLE/isle.h
247
ISLE/isle.h
|
@ -5,8 +5,17 @@
|
|||
#include "define.h"
|
||||
|
||||
#include "legoomni.h"
|
||||
#include "legoanimationmanager.h"
|
||||
#include "legobuildingmanager.h"
|
||||
#include "legomodelpresenter.h"
|
||||
#include "legopartpresenter.h"
|
||||
#include "legoworldpresenter.h"
|
||||
#include "mxresult.h"
|
||||
#include "mxvideoparam.h"
|
||||
#include "mxdirectdraw.h"
|
||||
#include "mxdsaction.h"
|
||||
#include "mxomni.h"
|
||||
#include "res/resource.h"
|
||||
|
||||
class Isle
|
||||
{
|
||||
|
@ -20,7 +29,7 @@ class Isle
|
|||
int ReadRegBool(LPCSTR name, BOOL *out);
|
||||
int ReadRegInt(LPCSTR name, int *out);
|
||||
|
||||
MxResult SetupWindow(HINSTANCE hInstance);
|
||||
MxResult SetupWindow(HINSTANCE hInstance, LPSTR lpCmdLine);
|
||||
|
||||
void Tick(BOOL sleepIfNotNextFrame);
|
||||
|
||||
|
@ -79,68 +88,190 @@ class Isle
|
|||
|
||||
};
|
||||
|
||||
extern LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
// OFFSET: ISLE 0x4023e0
|
||||
inline MxResult Isle::SetupWindow(HINSTANCE hInstance, LPSTR lpCmdLine)
|
||||
{
|
||||
WNDCLASSA wndclass;
|
||||
ZeroMemory(&wndclass, sizeof(WNDCLASSA));
|
||||
|
||||
LoadConfig();
|
||||
|
||||
SetupVideoFlags(m_fullScreen, m_flipSurfaces, m_backBuffersInVram, m_using8bit,
|
||||
m_using16bit, m_unk24, FALSE, m_wideViewAngle, m_deviceId);
|
||||
|
||||
MxOmni::SetSound3D(m_use3dSound);
|
||||
|
||||
srand(timeGetTime() / 1000);
|
||||
SystemParametersInfoA(SPI_SETMOUSETRAILS, 0, NULL, 0);
|
||||
|
||||
ZeroMemory(&wndclass, sizeof(WNDCLASSA));
|
||||
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wndclass.lpfnWndProc = WndProc;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hIcon = LoadIconA(hInstance, MAKEINTRESOURCEA(APP_ICON));
|
||||
wndclass.hCursor = m_cursorArrow = m_cursorCurrent = LoadCursorA(hInstance, MAKEINTRESOURCEA(ISLE_ARROW));
|
||||
m_cursorBusy = LoadCursorA(hInstance, MAKEINTRESOURCEA(ISLE_BUSY));
|
||||
m_cursorNo = LoadCursorA(hInstance, MAKEINTRESOURCEA(ISLE_NO));
|
||||
wndclass.hInstance = hInstance;
|
||||
wndclass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
|
||||
wndclass.lpszClassName = WNDCLASS_NAME;
|
||||
|
||||
if (!RegisterClassA(&wndclass)) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if (m_fullScreen) {
|
||||
AdjustWindowRectEx(&g_windowRect, WS_CAPTION | WS_SYSMENU, 0, WS_EX_APPWINDOW);
|
||||
|
||||
m_windowHandle = CreateWindowExA(
|
||||
WS_EX_APPWINDOW,
|
||||
WNDCLASS_NAME,
|
||||
WINDOW_TITLE,
|
||||
WS_CAPTION | WS_SYSMENU,
|
||||
g_windowRect.left,
|
||||
g_windowRect.top,
|
||||
g_windowRect.right - g_windowRect.left + 1,
|
||||
g_windowRect.bottom - g_windowRect.top + 1,
|
||||
NULL, NULL, hInstance, NULL
|
||||
);
|
||||
} else {
|
||||
AdjustWindowRectEx(&g_windowRect, WS_CAPTION | WS_SYSMENU, 0, WS_EX_APPWINDOW);
|
||||
|
||||
m_windowHandle = CreateWindowExA(
|
||||
WS_EX_APPWINDOW,
|
||||
WNDCLASS_NAME,
|
||||
WINDOW_TITLE,
|
||||
WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
g_windowRect.right - g_windowRect.left + 1,
|
||||
g_windowRect.bottom - g_windowRect.top + 1,
|
||||
NULL, NULL, hInstance, NULL
|
||||
);
|
||||
}
|
||||
|
||||
if (!m_windowHandle) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if (m_fullScreen) {
|
||||
MoveWindow(m_windowHandle, g_windowRect.left, g_windowRect.top, (g_windowRect.right - g_windowRect.left) + 1, (g_windowRect.bottom - g_windowRect.top) + 1, TRUE);
|
||||
}
|
||||
|
||||
ShowWindow(m_windowHandle, SW_SHOWNORMAL);
|
||||
UpdateWindow(m_windowHandle);
|
||||
if (!SetupLegoOmni()) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
GameState()->SetSavePath(m_savePath);
|
||||
GameState()->SerializePlayersInfo(1);
|
||||
GameState()->SerializeScoreHistory(1);
|
||||
|
||||
int iVar10;
|
||||
switch (m_islandQuality) {
|
||||
case 0:
|
||||
iVar10 = 1;
|
||||
break;
|
||||
case 1:
|
||||
iVar10 = 2;
|
||||
break;
|
||||
default:
|
||||
iVar10 = 100;
|
||||
}
|
||||
|
||||
int uVar1 = (m_islandTexture == 0);
|
||||
LegoModelPresenter::configureLegoModelPresenter(uVar1);
|
||||
LegoPartPresenter::configureLegoPartPresenter(uVar1,iVar10);
|
||||
LegoWorldPresenter::configureLegoWorldPresenter(m_islandQuality);
|
||||
LegoBuildingManager::configureLegoBuildingManager(m_islandQuality);
|
||||
LegoROI::configureLegoROI(iVar10);
|
||||
LegoAnimationManager::configureLegoAnimationManager(m_islandQuality);
|
||||
if (LegoOmni::GetInstance()) {
|
||||
if (LegoOmni::GetInstance()->GetInputManager()) {
|
||||
LegoOmni::GetInstance()->GetInputManager()->m_useJoystick = m_useJoystick;
|
||||
LegoOmni::GetInstance()->GetInputManager()->m_joystickIndex = m_joystickIndex;
|
||||
}
|
||||
}
|
||||
if (m_fullScreen) {
|
||||
MoveWindow(m_windowHandle, g_windowRect.left, g_windowRect.top, (g_windowRect.right - g_windowRect.left) + 1, (g_windowRect.bottom - g_windowRect.top) + 1, TRUE);
|
||||
}
|
||||
ShowWindow(m_windowHandle, SW_SHOWNORMAL);
|
||||
UpdateWindow(m_windowHandle);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// OFFSET: ISLE 0x402c20
|
||||
inline void Isle::Tick(BOOL sleepIfNotNextFrame)
|
||||
{
|
||||
if (this->m_windowActive) {
|
||||
if (!Lego()) return;
|
||||
if (!TickleManager()) return;
|
||||
if (!Timer()) return;
|
||||
|
||||
long currentTime = Timer()->GetRealTime();
|
||||
if (currentTime < g_lastFrameTime) {
|
||||
g_lastFrameTime = -this->m_frameDelta;
|
||||
}
|
||||
if (this->m_frameDelta + g_lastFrameTime < currentTime) {
|
||||
if (!Lego()->vtable40()) {
|
||||
TickleManager()->Tickle();
|
||||
}
|
||||
g_lastFrameTime = currentTime;
|
||||
|
||||
if (g_startupDelay == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_startupDelay--;
|
||||
if (g_startupDelay != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
LegoOmni::GetInstance()->CreateBackgroundAudio();
|
||||
BackgroundAudioManager()->Enable(this->m_useMusic);
|
||||
|
||||
MxStreamController *stream = Streamer()->Open("\\lego\\scripts\\isle\\isle", 0);
|
||||
MxDSAction ds;
|
||||
|
||||
if (!stream) {
|
||||
stream = Streamer()->Open("\\lego\\scripts\\nocd", 0);
|
||||
if (!stream) {
|
||||
return;
|
||||
}
|
||||
|
||||
ds.SetAtomId(stream->atom);
|
||||
ds.SetUnknown24(-1);
|
||||
ds.SetUnknown1c(0);
|
||||
VideoManager()->EnableFullScreenMovie(TRUE, TRUE);
|
||||
|
||||
if (Start(&ds) != SUCCESS) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ds.SetAtomId(stream->atom);
|
||||
ds.SetUnknown24(-1);
|
||||
ds.SetUnknown1c(0);
|
||||
if (Start(&ds) != SUCCESS) {
|
||||
return;
|
||||
}
|
||||
this->m_gameStarted = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (sleepIfNotNextFrame == 0) return;
|
||||
if (!this->m_windowActive) {
|
||||
Sleep(0);
|
||||
return;
|
||||
}
|
||||
|
||||
Sleep(0);
|
||||
if (!Lego()) return;
|
||||
if (!TickleManager()) return;
|
||||
if (!Timer()) return;
|
||||
|
||||
long currentTime = Timer()->GetRealTime();
|
||||
if (currentTime < g_lastFrameTime) {
|
||||
g_lastFrameTime = -this->m_frameDelta;
|
||||
}
|
||||
|
||||
if (this->m_frameDelta + g_lastFrameTime < currentTime) {
|
||||
if (!Lego()->vtable40()) {
|
||||
TickleManager()->Tickle();
|
||||
}
|
||||
g_lastFrameTime = currentTime;
|
||||
|
||||
if (g_startupDelay == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_startupDelay--;
|
||||
if (g_startupDelay != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
LegoOmni::GetInstance()->CreateBackgroundAudio();
|
||||
BackgroundAudioManager()->Enable(this->m_useMusic);
|
||||
|
||||
MxStreamController *stream = Streamer()->Open("\\lego\\scripts\\isle\\isle", 0);
|
||||
MxDSAction ds;
|
||||
|
||||
if (!stream) {
|
||||
stream = Streamer()->Open("\\lego\\scripts\\nocd", 0);
|
||||
if (!stream) {
|
||||
return;
|
||||
}
|
||||
|
||||
ds.SetAtomId(stream->atom);
|
||||
ds.SetUnknown24(-1);
|
||||
ds.SetUnknown1c(0);
|
||||
VideoManager()->EnableFullScreenMovie(TRUE, TRUE);
|
||||
|
||||
if (Start(&ds) != SUCCESS) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ds.SetAtomId(stream->atom);
|
||||
ds.SetUnknown24(-1);
|
||||
ds.SetUnknown1c(0);
|
||||
if (Start(&ds) != SUCCESS) {
|
||||
return;
|
||||
}
|
||||
this->m_gameStarted = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (sleepIfNotNextFrame != 0)
|
||||
Sleep(0);
|
||||
}
|
||||
|
||||
#endif // ISLE_H
|
||||
|
|
184
ISLE/main.cpp
184
ISLE/main.cpp
|
@ -61,7 +61,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
g_isle = new Isle();
|
||||
|
||||
// Create window
|
||||
if (g_isle->SetupWindow(hInstance) != SUCCESS) {
|
||||
if (g_isle->SetupWindow(hInstance, lpCmdLine) != SUCCESS) {
|
||||
MessageBoxA(NULL, "\"LEGO\xAE Island\" failed to start. Please quit all other applications and try again.", "LEGO\xAE Island Error", MB_OK);
|
||||
return 0;
|
||||
}
|
||||
|
@ -90,14 +90,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
}
|
||||
|
||||
if (g_isle) {
|
||||
g_isle->Tick(1);
|
||||
g_isle->Tick(0);
|
||||
}
|
||||
|
||||
if (g_closed) {
|
||||
break;
|
||||
}
|
||||
|
||||
do {
|
||||
while (!g_closed) {
|
||||
if (!PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
break;
|
||||
}
|
||||
|
@ -134,10 +130,182 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
}
|
||||
goto LAB_00401bc7;
|
||||
}
|
||||
} while (!g_closed);
|
||||
}
|
||||
}
|
||||
|
||||
DestroyWindow(window);
|
||||
|
||||
return msg.wParam;
|
||||
}
|
||||
|
||||
// OFFSET: ISLE 0x401d20
|
||||
LRESULT WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (!g_isle) {
|
||||
return DefWindowProcA(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
switch (uMsg) {
|
||||
case WM_PAINT:
|
||||
return DefWindowProcA(hWnd, WM_PAINT, wParam, lParam);
|
||||
case WM_ACTIVATE:
|
||||
return DefWindowProcA(hWnd, WM_ACTIVATE, wParam, lParam);
|
||||
case WM_ACTIVATEAPP:
|
||||
if (g_isle) {
|
||||
if ((wParam != 0) && (g_isle->m_fullScreen)) {
|
||||
MoveWindow(hWnd, g_windowRect.left, g_windowRect.top,
|
||||
(g_windowRect.right - g_windowRect.left) + 1,
|
||||
(g_windowRect.bottom - g_windowRect.top) + 1, TRUE);
|
||||
}
|
||||
g_isle->m_windowActive = wParam;
|
||||
}
|
||||
return DefWindowProcA(hWnd,WM_ACTIVATEAPP,wParam,lParam);
|
||||
case WM_CLOSE:
|
||||
if (!g_closed && g_isle) {
|
||||
if (g_isle) {
|
||||
delete g_isle;
|
||||
}
|
||||
g_isle = NULL;
|
||||
g_closed = TRUE;
|
||||
return 0;
|
||||
}
|
||||
return DefWindowProcA(hWnd,WM_CLOSE,wParam,lParam);
|
||||
case WM_GETMINMAXINFO:
|
||||
{
|
||||
MINMAXINFO *mmi = (MINMAXINFO *) lParam;
|
||||
|
||||
mmi->ptMaxTrackSize.x = (g_windowRect.right - g_windowRect.left) + 1;
|
||||
mmi->ptMaxTrackSize.y = (g_windowRect.bottom - g_windowRect.top) + 1;
|
||||
mmi->ptMinTrackSize.x = (g_windowRect.right - g_windowRect.left) + 1;
|
||||
mmi->ptMinTrackSize.y = (g_windowRect.bottom - g_windowRect.top) + 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
case WM_ENTERMENULOOP:
|
||||
return DefWindowProcA(hWnd,WM_ENTERMENULOOP,wParam,lParam);
|
||||
case WM_SYSCOMMAND:
|
||||
if (wParam == SC_SCREENSAVE) {
|
||||
return 0;
|
||||
}
|
||||
if (wParam == SC_CLOSE && g_closed == 0) {
|
||||
if (g_isle) {
|
||||
if (g_rmDisabled) {
|
||||
ShowWindow(g_isle->m_windowHandle, SW_RESTORE);
|
||||
}
|
||||
PostMessageA(g_isle->m_windowHandle, WM_CLOSE, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
} else if (g_isle && g_isle->m_fullScreen && (wParam == SC_MOVE || wParam == SC_KEYMENU)) {
|
||||
return 0;
|
||||
}
|
||||
return DefWindowProcA(hWnd,WM_SYSCOMMAND,wParam,lParam);
|
||||
case WM_EXITMENULOOP:
|
||||
return DefWindowProcA(hWnd, WM_EXITMENULOOP, wParam, lParam);
|
||||
case WM_MOVING:
|
||||
if (g_isle && g_isle->m_fullScreen) {
|
||||
GetWindowRect(hWnd, (LPRECT) lParam);
|
||||
return 0;
|
||||
}
|
||||
return DefWindowProcA(hWnd, WM_MOVING, wParam, lParam);
|
||||
case WM_NCPAINT:
|
||||
if (g_isle && g_isle->m_fullScreen) {
|
||||
return 0;
|
||||
}
|
||||
return DefWindowProcA(hWnd, WM_NCPAINT, wParam, lParam);
|
||||
case WM_DISPLAYCHANGE:
|
||||
if (g_isle && VideoManager() && g_isle->m_fullScreen && VideoManager()->m_unk74 && VideoManager()->m_unk74[0x220]) {
|
||||
if (!g_waitingForTargetDepth) {
|
||||
unsigned char valid = FALSE;
|
||||
if (LOWORD(lParam) == g_targetWidth && HIWORD(lParam) == g_targetHeight && g_targetDepth == wParam) {
|
||||
valid = TRUE;
|
||||
}
|
||||
if (!g_rmDisabled) {
|
||||
if (!valid) {
|
||||
g_rmDisabled = 1;
|
||||
Lego()->vtable38();
|
||||
VideoManager()->DisableRMDevice();
|
||||
}
|
||||
} else if (valid) {
|
||||
g_reqEnableRMDevice = 1;
|
||||
}
|
||||
} else {
|
||||
g_waitingForTargetDepth = 0;
|
||||
g_targetDepth = wParam;
|
||||
}
|
||||
}
|
||||
return DefWindowProcA(hWnd, WM_DISPLAYCHANGE, wParam, lParam);
|
||||
case WM_SETCURSOR:
|
||||
case WM_KEYDOWN:
|
||||
case WM_MOUSEMOVE:
|
||||
case WM_TIMER:
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_LBUTTONUP:
|
||||
case 0x5400:
|
||||
{
|
||||
|
||||
NotificationId type = NONE;
|
||||
unsigned char keyCode = 0;
|
||||
|
||||
switch (uMsg) {
|
||||
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, WM_KEYDOWN, wParam, lParam);
|
||||
}
|
||||
keyCode = wParam;
|
||||
type = KEYDOWN;
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
g_mousemoved = 1;
|
||||
type = MOUSEMOVE;
|
||||
break;
|
||||
case WM_TIMER:
|
||||
type = TIMER;
|
||||
break;
|
||||
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_LBUTTONDOWN:
|
||||
g_mousedown = 1;
|
||||
type = MOUSEDOWN;
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
g_mousedown = 0;
|
||||
type = MOUSEUP;
|
||||
break;
|
||||
case 0x5400:
|
||||
if (g_isle) {
|
||||
g_isle->SetupCursor(wParam);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_isle) {
|
||||
if (InputManager()) {
|
||||
InputManager()->QueueEvent(type, wParam, LOWORD(lParam), HIWORD(lParam), keyCode);
|
||||
}
|
||||
if (g_isle && g_isle->m_drawCursor && type == MOUSEMOVE) {
|
||||
unsigned short x = LOWORD(lParam);
|
||||
unsigned short y = HIWORD(lParam);
|
||||
if (639 < x) {
|
||||
x = 639;
|
||||
}
|
||||
if (479 < y) {
|
||||
y = 479;
|
||||
}
|
||||
VideoManager()->MoveCursor(x,y);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return DefWindowProcA(hWnd,uMsg,wParam,lParam);
|
||||
}
|
|
@ -20,7 +20,10 @@ class LegoInputManager
|
|||
__declspec(dllexport) void Register(MxCore *);
|
||||
__declspec(dllexport) void UnRegister(MxCore *);
|
||||
|
||||
int m_unk00[0x400];
|
||||
char m_pad00[0x19C];
|
||||
int m_joystickIndex;
|
||||
char m_pad200[0x194];
|
||||
MxBool m_useJoystick;
|
||||
};
|
||||
|
||||
#endif // LEGOINPUTMANAGER_H
|
||||
|
|
Loading…
Reference in a new issue