mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-12 03:01:17 +00:00
Merge branch 'master' into ClassLayout
# Conflicts: # LEGO1/legoinputmanager.h # LEGO1/mxvideomanager.cpp # LEGO1/mxvideomanager.h # isle.mak # isle.mdp
This commit is contained in:
commit
a19ab94388
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@ -60,6 +60,7 @@ jobs:
|
||||
C:\msys64\usr\bin\wget.exe https://legoisland.org/download/ISLE.EXE
|
||||
C:\msys64\usr\bin\wget.exe https://legoisland.org/download/LEGO1.DLL
|
||||
pip install capstone
|
||||
pip install colorama
|
||||
python3 tools/reccmp/reccmp.py -H ISLEPROGRESS.HTML ISLE.EXE Release/ISLE.EXE Release/ISLE.PDB .
|
||||
python3 tools/reccmp/reccmp.py -H LEGO1PROGRESS.HTML LEGO1.DLL Release/LEGO1.DLL Release/LEGO1.PDB .
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
@ -26,7 +26,10 @@ class LegoInputManager
|
||||
|
||||
virtual void VTable0x38(); // vtable0x38
|
||||
|
||||
int m_unk00[0x400];
|
||||
char m_pad00[0x19C];
|
||||
int m_joystickIndex;
|
||||
char m_pad200[0x194];
|
||||
MxBool m_useJoystick;
|
||||
};
|
||||
|
||||
#endif // LEGOINPUTMANAGER_H
|
||||
|
||||
@ -100,22 +100,18 @@ LegoNavController::LegoNavController()
|
||||
// inputManager->UnRegister(this);
|
||||
// }
|
||||
|
||||
// TODO: VideoManager()
|
||||
// OFFSET: LEGO1 0x10054ca0
|
||||
// void LegoNavController::SetControlMax(int p_hMax, int p_vMax)
|
||||
// {
|
||||
// LegoVideoManager* videoManager = VideoManager();
|
||||
void LegoNavController::SetControlMax(int p_hMax, int p_vMax)
|
||||
{
|
||||
this->m_hMax = p_hMax;
|
||||
this->m_vMax = p_vMax;
|
||||
|
||||
// this->m_hMax = p_hMax;
|
||||
// this->m_vMax = p_vMax;
|
||||
|
||||
// Probably checks for MxVideoParamFlags: FULL_SCREEN
|
||||
// if ((videoManager->m_unk44 & 0x01) != 0)
|
||||
// {
|
||||
// this->m_hMax = 640;
|
||||
// this->m_vMax = 480;
|
||||
// }
|
||||
// }
|
||||
if (VideoManager()->GetVideoParam().flags().GetFullScreen())
|
||||
{
|
||||
this->m_hMax = 640;
|
||||
this->m_vMax = 480;
|
||||
}
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x10054cd0
|
||||
void LegoNavController::ResetToDefault()
|
||||
|
||||
@ -20,7 +20,7 @@ class LegoNavController : public MxCore
|
||||
LegoNavController();
|
||||
// virtual ~LegoNavController(); // vtable+0x0
|
||||
|
||||
// void SetControlMax(int p_hMax, int p_vMax);
|
||||
void SetControlMax(int p_hMax, int p_vMax);
|
||||
void ResetToDefault();
|
||||
void SetTargets(int p_hPos, int p_vPos, MxBool p_accel);
|
||||
float CalculateNewTargetSpeed(int p_pos, int p_center, float p_maxSpeed);
|
||||
|
||||
@ -86,18 +86,6 @@ long LegoOmni::Notify(MxParam &p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x10058aa0
|
||||
const char *LegoOmni::GetClassName() const
|
||||
{
|
||||
return "LegoOmni";
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x10058ab0
|
||||
MxBool LegoOmni::IsClass(const char *name) const
|
||||
{
|
||||
return strcmp("LegoOmni", name) == 0;
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x10058bd0
|
||||
void LegoOmni::Init()
|
||||
{
|
||||
|
||||
@ -33,8 +33,15 @@ class LegoOmni : public MxOmni
|
||||
virtual ~LegoOmni(); // vtable+00
|
||||
|
||||
virtual long Notify(MxParam &p); // vtable+04
|
||||
virtual const char *GetClassName() const; // vtable+0c
|
||||
virtual MxBool IsClass(const char *name) const; // vtable+10;
|
||||
|
||||
// OFFSET: LEGO1 0x10058aa0
|
||||
inline virtual const char *GetClassName() const { return "LegoOmni"; }; // vtable+0c
|
||||
|
||||
// OFFSET: LEGO1 0x10058ab0
|
||||
inline virtual MxBool IsClass(const char *name) const {
|
||||
return !strcmp(name, LegoOmni::GetClassName()) || MxOmni::IsClass(name);
|
||||
}; // vtable+10;
|
||||
|
||||
virtual void Init(); // vtable+14
|
||||
virtual MxResult Create(MxOmniCreateParam &p); // vtable+18
|
||||
virtual void Destroy(); // vtable+1c
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
#ifndef LEGOVIDEOMANAGER_H
|
||||
#define LEGOVIDEOMANAGER_H
|
||||
|
||||
#include "mxvideomanager.h"
|
||||
#include "lego3dmanager.h"
|
||||
|
||||
// class LegoVideoManager : public MxVideoManager
|
||||
class LegoVideoManager
|
||||
class LegoVideoManager : public MxVideoManager
|
||||
{
|
||||
public:
|
||||
__declspec(dllexport) int EnableRMDevice();
|
||||
@ -14,31 +14,6 @@ class LegoVideoManager
|
||||
|
||||
inline Lego3DManager *Get3DManager() { return this->m_3dManager; }
|
||||
|
||||
int m_unk00;
|
||||
int m_unk04;
|
||||
int m_unk08;
|
||||
int m_unk0c;
|
||||
int m_unk10;
|
||||
int m_unk14;
|
||||
int m_unk18;
|
||||
int m_unk1c;
|
||||
int m_unk20;
|
||||
int m_unk24;
|
||||
int m_unk28;
|
||||
int m_unk2c;
|
||||
int m_unk30;
|
||||
int m_unk34;
|
||||
int m_unk38;
|
||||
int m_unk3c;
|
||||
int m_unk40;
|
||||
int m_unk44;
|
||||
int m_unk48;
|
||||
int m_unk4c;
|
||||
int m_unk50;
|
||||
int m_unk54;
|
||||
int m_unk58;
|
||||
int m_unk5c;
|
||||
int m_unk60;
|
||||
int m_unk64;
|
||||
Lego3DManager *m_3dManager;
|
||||
int m_unk6c;
|
||||
|
||||
@ -7,7 +7,7 @@ class MxAutoLocker
|
||||
{
|
||||
public:
|
||||
MxAutoLocker(MxCriticalSection* cs);
|
||||
virtual ~MxAutoLocker();
|
||||
~MxAutoLocker();
|
||||
private:
|
||||
MxCriticalSection* m_criticalSection;
|
||||
};
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
#include "mxcore.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// 0x1010141c
|
||||
unsigned int g_mxcoreCount = 0;
|
||||
|
||||
@ -27,16 +25,4 @@ long MxCore::Notify(MxParam &p)
|
||||
long MxCore::Tickle()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100144c0
|
||||
const char *MxCore::GetClassName() const
|
||||
{
|
||||
return "MxCore";
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100140d0
|
||||
MxBool MxCore::IsClass(const char *name) const
|
||||
{
|
||||
return strcmp(name, "MxCore") == 0;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
#ifndef MXCORE_H
|
||||
#define MXCORE_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "mxbool.h"
|
||||
|
||||
class MxParam;
|
||||
@ -12,8 +14,14 @@ class MxCore
|
||||
__declspec(dllexport) virtual ~MxCore(); // vtable+00
|
||||
__declspec(dllexport) virtual long Notify(MxParam &p); // vtable+04
|
||||
virtual long Tickle(); // vtable+08
|
||||
virtual const char *GetClassName() const; // vtable+0c
|
||||
virtual MxBool IsClass(const char *name) const; // vtable+10
|
||||
|
||||
// OFFSET: LEGO1 0x100144c0
|
||||
inline virtual const char *GetClassName() const { return "MxCore"; }; // vtable+0c
|
||||
|
||||
// OFFSET: LEGO1 0x100140d0
|
||||
inline virtual MxBool IsClass(const char *name) const {
|
||||
return !strcmp(name, MxCore::GetClassName());
|
||||
}; // vtable+10
|
||||
|
||||
private:
|
||||
unsigned int m_id;
|
||||
|
||||
8
LEGO1/mxpalette.cpp
Executable file
8
LEGO1/mxpalette.cpp
Executable file
@ -0,0 +1,8 @@
|
||||
#include "mxpalette.h"
|
||||
|
||||
// OFFSET: LEGO1 0x100bf150
|
||||
MxResult MxPalette::GetEntries(LPPALETTEENTRY p_entries)
|
||||
{
|
||||
memcpy(p_entries, this->m_entries, sizeof(this->m_entries));
|
||||
return SUCCESS;
|
||||
}
|
||||
@ -1,11 +1,23 @@
|
||||
#ifndef MXPALETTE_H
|
||||
#define MXPALETTE_H
|
||||
|
||||
class MxPalette
|
||||
#include <ddraw.h>
|
||||
|
||||
#include "mxcore.h"
|
||||
#include "mxresult.h"
|
||||
|
||||
class MxPalette : public MxCore
|
||||
{
|
||||
public:
|
||||
__declspec(dllexport) unsigned char operator==(MxPalette &);
|
||||
__declspec(dllexport) void Detach();
|
||||
|
||||
MxResult GetEntries(LPPALETTEENTRY p_entries);
|
||||
|
||||
private:
|
||||
LPDIRECTDRAWPALETTE m_pDirectDrawPalette;
|
||||
PALETTEENTRY m_entries[256];
|
||||
// there's a bit more here
|
||||
};
|
||||
|
||||
#endif // MXPALETTE_H
|
||||
|
||||
15
LEGO1/mxunknown100dc6b0.cpp
Executable file
15
LEGO1/mxunknown100dc6b0.cpp
Executable file
@ -0,0 +1,15 @@
|
||||
#include "mxunknown100dc6b0.h"
|
||||
|
||||
// OFFSET: LEGO1 0x100b84c0
|
||||
MxUnknown100dc6b0::MxUnknown100dc6b0()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100b85d0
|
||||
MxResult MxUnknown100dc6b0::Init()
|
||||
{
|
||||
this->m_unk08 = 0;
|
||||
this->m_unk0c = 0;
|
||||
return SUCCESS;
|
||||
}
|
||||
23
LEGO1/mxunknown100dc6b0.h
Executable file
23
LEGO1/mxunknown100dc6b0.h
Executable file
@ -0,0 +1,23 @@
|
||||
#ifndef MXUNKNOWN100DC6B0_H
|
||||
#define MXUNKNOWN100DC6B0_H
|
||||
|
||||
#include "mxcore.h"
|
||||
#include "mxresult.h"
|
||||
#include "mxcriticalsection.h"
|
||||
|
||||
class MxUnknown100dc6b0 : public MxCore
|
||||
{
|
||||
public:
|
||||
MxUnknown100dc6b0();
|
||||
|
||||
MxResult Init();
|
||||
|
||||
private:
|
||||
int m_unk08;
|
||||
int m_unk0c;
|
||||
|
||||
protected:
|
||||
MxCriticalSection m_criticalSection;
|
||||
};
|
||||
|
||||
#endif // MXUNKNOWN100DC6B0_H
|
||||
@ -10,6 +10,40 @@ MxVideoManager::~MxVideoManager()
|
||||
long MxVideoManager::Tickle()
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100be1f0
|
||||
MxVideoManager::MxVideoManager()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100be320
|
||||
int MxVideoManager::Init()
|
||||
{
|
||||
this->m_unk50 = 0;
|
||||
this->m_unk54 = NULL;
|
||||
this->m_unk58 = NULL;
|
||||
this->m_unk5c = 0;
|
||||
this->m_videoParam.SetPalette(NULL);
|
||||
this->m_unk60 = MX_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100bebe0
|
||||
long MxVideoManager::RealizePalette(MxPalette *p_palette)
|
||||
{
|
||||
PALETTEENTRY paletteEntries[256];
|
||||
|
||||
this->m_criticalSection.Enter();
|
||||
|
||||
if (p_palette && this->m_videoParam.GetPalette())
|
||||
{
|
||||
p_palette->GetEntries(paletteEntries);
|
||||
// TODO
|
||||
}
|
||||
|
||||
this->m_criticalSection.Leave();
|
||||
return 0;
|
||||
}
|
||||
@ -1,9 +1,10 @@
|
||||
#ifndef MXVIDEOMANAGER_H
|
||||
#define MXVIDEOMANAGER_H
|
||||
|
||||
#include "mxcore.h"
|
||||
#include "mxunknown100dc6b0.h"
|
||||
#include "mxvideoparam.h"
|
||||
|
||||
class MxVideoManager : public MxCore
|
||||
class MxVideoManager : public MxUnknown100dc6b0
|
||||
{
|
||||
public:
|
||||
virtual ~MxVideoManager();
|
||||
@ -12,6 +13,20 @@ class MxVideoManager : public MxCore
|
||||
|
||||
__declspec(dllexport) void InvalidateRect(MxRect32 &);
|
||||
__declspec(dllexport) virtual long RealizePalette(MxPalette *); // vtable+0x30
|
||||
|
||||
MxVideoManager();
|
||||
|
||||
int Init();
|
||||
|
||||
inline MxVideoParam& GetVideoParam() { return this->m_videoParam; }
|
||||
|
||||
private:
|
||||
MxVideoParam m_videoParam;
|
||||
int m_unk50;
|
||||
LPDIRECTDRAWSURFACE m_unk54;
|
||||
void* m_unk58;
|
||||
int m_unk5c;
|
||||
MxBool m_unk60;
|
||||
};
|
||||
|
||||
#endif // MXVIDEOMANAGER_H
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
#ifndef MXVIDEOPARAM_H
|
||||
#define MXVIDEOPARAM_H
|
||||
|
||||
#include <ddraw.h>
|
||||
|
||||
#include "mxpalette.h"
|
||||
#include "mxbool.h"
|
||||
#include "mxrect32.h"
|
||||
#include "mxvariabletable.h"
|
||||
#include "mxvideoparamflags.h"
|
||||
@ -19,6 +22,9 @@ class MxVideoParam
|
||||
|
||||
inline MxVideoParamFlags &flags() { return m_flags; }
|
||||
|
||||
inline void SetPalette(MxPalette *p_palette) { this->m_palette = p_palette; }
|
||||
inline MxPalette *GetPalette() { return this->m_palette; }
|
||||
|
||||
private:
|
||||
MxRect32 m_rect;
|
||||
MxPalette *m_palette;
|
||||
|
||||
@ -40,6 +40,23 @@ class MxVideoParamFlags
|
||||
inline void Set_f2bit6(BOOL e) { m_flags2.bit6 = e; }
|
||||
inline void Set_f2bit7(BOOL e) { m_flags2.bit7 = e; }
|
||||
|
||||
inline BYTE GetFullScreen() { return m_flags1.bit0; }
|
||||
inline BYTE GetFlipSurfaces() { return m_flags1.bit1; }
|
||||
inline BYTE GetBackBuffers() { return m_flags1.bit2; }
|
||||
inline BYTE Get_f1bit3() { return m_flags1.bit3; }
|
||||
inline BYTE Get_f1bit4() { return m_flags1.bit4; }
|
||||
inline BYTE Get16Bit() { return m_flags1.bit5; }
|
||||
inline BYTE GetWideViewAngle() { return m_flags1.bit6; }
|
||||
inline BYTE Get_f1bit7() { return m_flags1.bit7; }
|
||||
inline BYTE Get_f2bit0() { return m_flags2.bit0; }
|
||||
inline BYTE Get_f2bit1() { return m_flags2.bit1; }
|
||||
inline BYTE Get_f2bit2() { return m_flags2.bit2; }
|
||||
inline BYTE Get_f2bit3() { return m_flags2.bit3; }
|
||||
inline BYTE Get_f2bit4() { return m_flags2.bit4; }
|
||||
inline BYTE Get_f2bit5() { return m_flags2.bit5; }
|
||||
inline BYTE Get_f2bit6() { return m_flags2.bit6; }
|
||||
inline BYTE Get_f2bit7() { return m_flags2.bit7; }
|
||||
|
||||
private:
|
||||
flag_bitfield m_flags1;
|
||||
flag_bitfield m_flags2;
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
import colorama
|
||||
|
||||
parser = argparse.ArgumentParser(allow_abbrev=False,
|
||||
description='Recompilation Compare: compare an original EXE with a recompiled EXE + PDB.')
|
||||
@ -16,10 +17,14 @@
|
||||
parser.add_argument('decomp_dir', metavar='decomp-dir', help='The decompiled source tree')
|
||||
parser.add_argument('--verbose', '-v', metavar='offset', help='Print assembly diff for specific function (original file\'s offset)')
|
||||
parser.add_argument('--html', '-H', metavar='output-file', help='Generate searchable HTML summary of status and diffs')
|
||||
parser.add_argument('--no-color', '-n', action='store_true', help='Do not color the output')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
colorama.init()
|
||||
|
||||
verbose = None
|
||||
found_verbose_target = False
|
||||
if args.verbose:
|
||||
try:
|
||||
verbose = int(args.verbose, 16)
|
||||
@ -27,6 +32,8 @@
|
||||
parser.error('invalid verbose argument')
|
||||
html = args.html
|
||||
|
||||
plain = args.no_color
|
||||
|
||||
original = args.original
|
||||
if not os.path.isfile(original):
|
||||
parser.error('Original binary does not exist')
|
||||
@ -287,6 +294,13 @@ def parse_asm(file, addr, size):
|
||||
|
||||
addr = int(par[1], 16)
|
||||
|
||||
# Verbose flag handling
|
||||
if verbose:
|
||||
if addr == verbose:
|
||||
found_verbose_target = True
|
||||
else:
|
||||
continue
|
||||
|
||||
find_open_bracket = line
|
||||
while '{' not in find_open_bracket:
|
||||
find_open_bracket = srcfile.readline()
|
||||
@ -305,23 +319,53 @@ def parse_asm(file, addr, size):
|
||||
else:
|
||||
ratio = 0
|
||||
|
||||
print(' %s (%s / %s) is %.2f%% similar to the original' % (recinfo.name, hex(addr), hex(recinfo.addr), ratio * 100))
|
||||
percenttext = "%.2f%%" % (ratio * 100)
|
||||
if not plain:
|
||||
if ratio == 1.0:
|
||||
percenttext = colorama.Fore.GREEN + percenttext + colorama.Style.RESET_ALL
|
||||
elif ratio > 0.8:
|
||||
percenttext = colorama.Fore.YELLOW + percenttext + colorama.Style.RESET_ALL
|
||||
else:
|
||||
percenttext = colorama.Fore.RED + percenttext + colorama.Style.RESET_ALL
|
||||
|
||||
if not verbose:
|
||||
print(' %s (%s / %s) is %s similar to the original' % (recinfo.name, hex(addr), hex(recinfo.addr), percenttext))
|
||||
|
||||
function_count += 1
|
||||
total_accuracy += ratio
|
||||
|
||||
if recinfo.size:
|
||||
if verbose == addr or html:
|
||||
udiff = difflib.unified_diff(origasm, recompasm)
|
||||
udiff = difflib.unified_diff(origasm, recompasm, n=10)
|
||||
|
||||
if verbose == addr:
|
||||
# If verbose, print the diff for that funciton to the output
|
||||
if verbose:
|
||||
if ratio == 1.0:
|
||||
print("%s: %s 100%% match.\n\nOK!" % (hex(addr), recinfo.name))
|
||||
else:
|
||||
for line in udiff:
|
||||
print(line)
|
||||
print()
|
||||
print()
|
||||
if line.startswith("++") or line.startswith("@@") or line.startswith("--"):
|
||||
# Skip unneeded parts of the diff for the brief view
|
||||
pass
|
||||
elif line.startswith("+"):
|
||||
if plain:
|
||||
print(line)
|
||||
else:
|
||||
print(colorama.Fore.GREEN + line)
|
||||
elif line.startswith("-"):
|
||||
if plain:
|
||||
print(line)
|
||||
else:
|
||||
print(colorama.Fore.RED + line)
|
||||
else:
|
||||
print(line)
|
||||
if not plain:
|
||||
print(colorama.Style.RESET_ALL, end='')
|
||||
|
||||
if html:
|
||||
htmlinsert.append('{address: "%s", name: "%s", matching: %s, diff: "%s"}' % (hex(addr), recinfo.name, str(ratio), '\\n'.join(udiff).replace('"', '\\"').replace('\n', '\\n')))
|
||||
print("\n%s is only %s similar to the original, diff above" % (recinfo.name, percenttext))
|
||||
|
||||
# If html, record the diffs to an HTML file
|
||||
if html:
|
||||
htmlinsert.append('{address: "%s", name: "%s", matching: %s, diff: "%s"}' % (hex(addr), recinfo.name, str(ratio), '\\n'.join(udiff).replace('"', '\\"').replace('\n', '\\n')))
|
||||
|
||||
except UnicodeDecodeError:
|
||||
break
|
||||
@ -348,5 +392,9 @@ def gen_html(html, data):
|
||||
if html:
|
||||
gen_html(html, htmlinsert)
|
||||
|
||||
if function_count > 0:
|
||||
print('\nTotal accuracy %.2f%% across %i functions' % (total_accuracy / function_count * 100, function_count))
|
||||
if verbose:
|
||||
if not found_verbose_target:
|
||||
print('Failed to find the function with address %s' % hex(verbose))
|
||||
else:
|
||||
if function_count > 0:
|
||||
print('\nTotal accuracy %.2f%% across %i functions' % (total_accuracy / function_count * 100, function_count))
|
||||
|
||||
2
tools/reccmp/requirements.txt
Normal file
2
tools/reccmp/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
colorama
|
||||
capstone
|
||||
Loading…
Reference in New Issue
Block a user