Skip to content

Commit 036041a

Browse files
authored
Implement FUN_00416db0 (isledecomp#65)
1 parent 8186a9b commit 036041a

5 files changed

Lines changed: 74 additions & 36 deletions

File tree

GolDP/include/goldrawstate.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ class GolDrawState {
6262

6363
LegoU32 GetFlags() const { return m_flags; }
6464

65+
LegoS32 m_width; // 0x04
66+
LegoS32 m_height; // 0x08
67+
6568
protected:
66-
undefined4 m_width; // 0x04
67-
undefined4 m_height; // 0x08
6869
undefined4 m_bpp; // 0x0c
6970
LegoU32 m_flags; // 0x10
7071
AzureRidge0x38* m_unk0x14; // 0x14

LEGORacers/include/crimsonforge0x800.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "golhashtable.h"
88
#include "types.h"
99

10+
class CactusInterface0x4;
11+
1012
// VTABLE: LEGORACERS 0x004af9a8
1113
// SIZE 0x800
1214
class CrimsonForge0x800 {
@@ -47,10 +49,10 @@ class CrimsonForge0x800 {
4749
LegoU32 p_flags,
4850
const LegoChar* p_driverName,
4951
const LegoChar* p_deviceName
50-
); // vtable+0x28
51-
virtual void VTable0x2c() = 0; // vtable+0x2c
52-
virtual void VTable0x30() = 0; // vtable+0x30
53-
virtual LegoS32 Tick(LegoS32 p_unk0x81c) = 0; // vtable+0x34
52+
); // vtable+0x28
53+
virtual void VTable0x2c() = 0; // vtable+0x2c
54+
virtual void VTable0x30() = 0; // vtable+0x30
55+
virtual LegoS32 Tick(CactusInterface0x4* p_unk0x81c) = 0; // vtable+0x34
5456

5557
// SYNTHETIC: LEGORACERS 0x004163b0
5658
// CrimsonForge0x800::`scalar deleting destructor'

LEGORacers/include/ironflame0x944.h

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include <windows.h>
1313

14+
class CactusInterface0x4;
15+
1416
// VTABLE: LEGORACERS 0x004af9f4
1517
// SIZE 0x944
1618
class IronFlame0x944 : public CrimsonForge0x800 {
@@ -33,10 +35,10 @@ class IronFlame0x944 : public CrimsonForge0x800 {
3335
LegoU32 p_flags,
3436
const LegoChar* p_driverName,
3537
const LegoChar* p_deviceName
36-
) override; // vtable+0x28
37-
void VTable0x2c() override; // vtable+0x2c
38-
void VTable0x30() override; // vtable+0x30
39-
LegoS32 Tick(LegoS32 p_unk0x81c) override; // vtable+0x34
38+
) override; // vtable+0x28
39+
void VTable0x2c() override; // vtable+0x2c
40+
void VTable0x30() override; // vtable+0x30
41+
LegoS32 Tick(CactusInterface0x4* p_unk0x81c) override; // vtable+0x34
4042

4143
enum {
4244
c_golBackendDP = 0x0,
@@ -61,28 +63,28 @@ class IronFlame0x944 : public CrimsonForge0x800 {
6163
void FUN_00416db0();
6264
void FUN_00417000(LegoU32 p_mode);
6365

64-
GolExport* m_golExport; // 0x800
65-
GolDrawState* m_golDrawState; // 0x804
66-
undefined4 m_unk0x808; // 0x808
67-
undefined4 m_unk0x80c; // 0x80c
68-
undefined4 m_unk0x810; // 0x810
69-
undefined4 m_unk0x814; // 0x814
70-
undefined4 m_unk0x818; // 0x818
71-
undefined4 m_unk0x81c; // 0x81c
72-
DWORD m_lastFrameTimeMs; // 0x820
73-
LegoU32 m_frameDeltaMs; // 0x824
74-
LegoU32 m_maxFrameDeltaMs; // 0x828
75-
undefined4 m_unk0x82c; // 0x82c
76-
HMODULE m_golLibrary; // 0x830
77-
OpalVault0xf0 m_unk0x834; // 0x834
78-
HWND m_hWnd; // 0x924
79-
LegoU32 m_golBackendType; // 0x928
80-
undefined4 m_unk0x92c; // 0x92c
81-
undefined4 m_unk0x930; // 0x930
82-
undefined4 m_unk0x934; // 0x934
83-
undefined4 m_unk0x938; // 0x938
84-
undefined4 m_unk0x93c; // 0x93c
85-
undefined4 m_unk0x940; // 0x940
66+
GolExport* m_golExport; // 0x800
67+
GolDrawState* m_golDrawState; // 0x804
68+
undefined4 m_unk0x808; // 0x808
69+
undefined4 m_unk0x80c; // 0x80c
70+
undefined4 m_unk0x810; // 0x810
71+
undefined4 m_unk0x814; // 0x814
72+
undefined4 m_unk0x818; // 0x818
73+
CactusInterface0x4* m_unk0x81c; // 0x81c
74+
DWORD m_lastFrameTimeMs; // 0x820
75+
LegoU32 m_frameDeltaMs; // 0x824
76+
LegoU32 m_maxFrameDeltaMs; // 0x828
77+
undefined4 m_unk0x82c; // 0x82c
78+
HMODULE m_golLibrary; // 0x830
79+
OpalVault0xf0 m_unk0x834; // 0x834
80+
HWND m_hWnd; // 0x924
81+
LegoU32 m_golBackendType; // 0x928
82+
undefined4 m_unk0x92c; // 0x92c
83+
undefined4 m_unk0x930; // 0x930
84+
undefined4 m_unk0x934; // 0x934
85+
undefined4 m_unk0x938; // 0x938
86+
undefined4 m_unk0x93c; // 0x93c
87+
undefined4 m_unk0x940; // 0x940
8688
};
8789

8890
LRESULT CALLBACK AppWndProc(HWND p_hWnd, UINT p_msg, WPARAM p_wParam, LPARAM p_lParam);

LEGORacers/library_msvc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// LIBRARY: LEGORACERS 0x004a84a4
88
// ??3@YAXPAX@Z
99

10+
// LIBRARY: LEGORACERS 0x004a84b0
11+
// __ftol
12+
1013
// LIBRARY: LEGORACERS 0x004a84bc
1114
// ??2@YAPAXI@Z
1215

LEGORacers/src/ironflame0x944.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "ironflame0x944.h"
22

33
#include "../../GolDP/include/gol.h"
4+
#include "cactusinterface0x4.h"
45
#include "gol.h"
56
#include "golerror.h"
67
#include "golfsutil.h"
@@ -291,15 +292,44 @@ void IronFlame0x944::VTable0x30()
291292
}
292293
}
293294

294-
// STUB: LEGORACERS 0x00416db0
295+
// FUNCTION: LEGORACERS 0x00416db0
295296
void IronFlame0x944::FUN_00416db0()
296297
{
297-
// TODO
298-
STUB(0x416db0);
298+
m_unk0x81c->VTable0x28();
299+
300+
if (m_unk0x92c == 2) {
301+
RECT rect;
302+
POINT topLeft;
303+
POINT bottomRight;
304+
POINT cursorPos;
305+
306+
GetClientRect(m_hWnd, &rect);
307+
topLeft.x = rect.left;
308+
topLeft.y = rect.top;
309+
bottomRight.x = rect.right;
310+
bottomRight.y = rect.bottom;
311+
ClientToScreen(m_hWnd, &topLeft);
312+
ClientToScreen(m_hWnd, &bottomRight);
313+
GetCursorPos(&cursorPos);
314+
315+
if (cursorPos.x < topLeft.x || cursorPos.x >= bottomRight.x || cursorPos.y < topLeft.y ||
316+
cursorPos.y >= bottomRight.y) {
317+
m_unk0x81c->VTable0x2c();
318+
}
319+
else {
320+
LegoFloat xScale = (LegoFloat) (bottomRight.x - topLeft.x) / m_golDrawState->m_width;
321+
LegoFloat yScale = (LegoFloat) (bottomRight.y - topLeft.y) / m_golDrawState->m_height;
322+
cursorPos.x -= topLeft.x;
323+
cursorPos.y -= topLeft.y;
324+
cursorPos.x /= xScale;
325+
cursorPos.y /= yScale;
326+
m_unk0x81c->VTable0x24(cursorPos.x, cursorPos.y);
327+
}
328+
}
299329
}
300330

301331
// FUNCTION: LEGORACERS 0x00416ef0
302-
LegoS32 IronFlame0x944::Tick(LegoS32 p_unk0x81c)
332+
LegoS32 IronFlame0x944::Tick(CactusInterface0x4* p_unk0x81c)
303333
{
304334
m_unk0x81c = p_unk0x81c;
305335
FUN_00416db0();

0 commit comments

Comments
 (0)