Skip to content

Commit d5ed947

Browse files
authored
Implement/match IronFlame0x944::VTable0x24 (isledecomp#66)
1 parent 036041a commit d5ed947

9 files changed

Lines changed: 164 additions & 35 deletions

File tree

GolDP/include/golcommondrawstate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class GolCommonDrawState : public GolDrawState {
4747
virtual undefined4 VTable0xb0(); // vtable+0xb0
4848
virtual undefined4 VTable0xb4(); // vtable+0xb4
4949

50-
private:
5150
undefined4 m_unk0x18; // 0x18
5251
undefined4 m_unk0x1c; // 0x1c
5352
};

GolDP/include/goldrawstate.h

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

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

65-
LegoS32 m_width; // 0x04
66-
LegoS32 m_height; // 0x08
67-
68-
protected:
65+
LegoS32 m_width; // 0x04
66+
LegoS32 m_height; // 0x08
6967
undefined4 m_bpp; // 0x0c
7068
LegoU32 m_flags; // 0x10
7169
AzureRidge0x38* m_unk0x14; // 0x14

LEGORacers/include/crimsonforge0x800.h

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

1010
class CactusInterface0x4;
11+
class OpalVault0xf0;
1112

1213
// VTABLE: LEGORACERS 0x004af9a8
1314
// SIZE 0x800
@@ -22,6 +23,7 @@ class CrimsonForge0x800 {
2223
c_flagBit5 = 1 << 5,
2324
c_flagBit6 = 1 << 6,
2425
c_flagBit7 = 1 << 7,
26+
c_flagBit8 = 1 << 8,
2527
c_flagBit9 = 1 << 9,
2628
c_flagBit10 = 1 << 10,
2729
c_flagBit12 = 1 << 12,
@@ -40,8 +42,8 @@ class CrimsonForge0x800 {
4042
virtual void UnloadGolLibrary() = 0; // vtable+0x18
4143
virtual void InitInput() = 0; // vtable+0x1c
4244
virtual void VTable0x20() = 0; // vtable+0x20
43-
virtual void VTable0x24(LegoU32 p_width, LegoU32 p_height, LegoU32 p_bpp,
44-
LegoU32 p_flags) = 0; // vtable+0x24
45+
virtual LegoS32 VTable0x24(LegoU32 p_width, LegoU32 p_height, LegoU32 p_bpp,
46+
LegoU32 p_flags) = 0; // vtable+0x24
4547
virtual void VTable0x28(
4648
LegoU32 p_width,
4749
LegoU32 p_height,
@@ -53,17 +55,18 @@ class CrimsonForge0x800 {
5355
virtual void VTable0x2c() = 0; // vtable+0x2c
5456
virtual void VTable0x30() = 0; // vtable+0x30
5557
virtual LegoS32 Tick(CactusInterface0x4* p_unk0x81c) = 0; // vtable+0x34
58+
virtual OpalVault0xf0* VTable0x38() = 0; // vtable+0x38
5659

5760
// SYNTHETIC: LEGORACERS 0x004163b0
5861
// CrimsonForge0x800::`scalar deleting destructor'
5962

60-
undefined4 GetUnk0x04() { return m_unk0x04; }
63+
LegoU32 GetFlags() { return m_flags; }
6164
GolHashTable& GetHashTable() { return m_hashTable; }
6265

6366
void Reset();
6467

6568
protected:
66-
undefined4 m_unk0x04; // 0x04
69+
LegoU32 m_flags; // 0x04
6770
GolFile m_files[20]; // 0x08
6871
GolFileSource m_fileSources[20]; // 0x3c8
6972
LegoU32 m_fileSourceCount; // 0x7d8

LEGORacers/include/ironflame0x944.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class IronFlame0x944 : public CrimsonForge0x800 {
2626
void UnloadGolLibrary() override; // vtable+0x18
2727
void InitInput() override; // vtable+0x1c
2828
void VTable0x20() override; // vtable+0x20
29-
void VTable0x24(LegoU32 p_width, LegoU32 p_height, LegoU32 p_bpp,
30-
LegoU32 p_flags) override; // vtable+0x24
29+
LegoS32 VTable0x24(LegoU32 p_width, LegoU32 p_height, LegoU32 p_bpp,
30+
LegoU32 p_flags) override; // vtable+0x24
3131
void VTable0x28(
3232
LegoU32 p_width,
3333
LegoU32 p_height,
@@ -39,6 +39,9 @@ class IronFlame0x944 : public CrimsonForge0x800 {
3939
void VTable0x2c() override; // vtable+0x2c
4040
void VTable0x30() override; // vtable+0x30
4141
LegoS32 Tick(CactusInterface0x4* p_unk0x81c) override; // vtable+0x34
42+
OpalVault0xf0* VTable0x38() override; // vtable+0x38
43+
virtual void VTable0x3c(); // vtable+0x3c
44+
virtual void VTable0x40(); // vtable+0x40
4245

4346
enum {
4447
c_golBackendDP = 0x0,
@@ -67,9 +70,9 @@ class IronFlame0x944 : public CrimsonForge0x800 {
6770
GolDrawState* m_golDrawState; // 0x804
6871
undefined4 m_unk0x808; // 0x808
6972
undefined4 m_unk0x80c; // 0x80c
70-
undefined4 m_unk0x810; // 0x810
71-
undefined4 m_unk0x814; // 0x814
72-
undefined4 m_unk0x818; // 0x818
73+
LegoU32 m_width; // 0x810
74+
LegoU32 m_height; // 0x814
75+
LegoU32 m_bpp; // 0x818
7376
CactusInterface0x4* m_unk0x81c; // 0x81c
7477
DWORD m_lastFrameTimeMs; // 0x820
7578
LegoU32 m_frameDeltaMs; // 0x824
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#ifndef JASPERAUXINTERFACE_H
2+
#define JASPERAUXINTERFACE_H
3+
4+
#include "decomp.h"
5+
6+
class JasperAuxInterface {
7+
public:
8+
virtual void VTable0x00() = 0; // vtable+0x00
9+
virtual void VTable0x04() = 0; // vtable+0x04
10+
virtual void VTable0x08() = 0; // vtable+0x08
11+
virtual void VTable0x0c() = 0; // vtable+0x0c
12+
virtual void VTable0x10() = 0; // vtable+0x10
13+
virtual void VTable0x14() = 0; // vtable+0x14
14+
virtual void VTable0x18() = 0; // vtable+0x18
15+
virtual void VTable0x1c() = 0; // vtable+0x1c
16+
virtual void VTable0x20() = 0; // vtable+0x20
17+
virtual void VTable0x24() = 0; // vtable+0x24
18+
virtual void VTable0x28() = 0; // vtable+0x28
19+
virtual void VTable0x2c() = 0; // vtable+0x2c
20+
virtual void VTable0x30() = 0; // vtable+0x30
21+
virtual void VTable0x34() = 0; // vtable+0x34
22+
virtual void VTable0x38() = 0; // vtable+0x38
23+
virtual void VTable0x3c() = 0; // vtable+0x3c
24+
virtual void VTable0x40() = 0; // vtable+0x40
25+
virtual void VTable0x44() = 0; // vtable+0x44
26+
};
27+
28+
#endif // JASPERAUXINTERFACE_H

LEGORacers/include/jaspercore0xf0.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define JASPERCORE0XF0_H
33

44
#include "decomp.h"
5+
#include "jasperauxinterface.h"
56
#include "types.h"
67

78
#include <dinput.h>
@@ -25,17 +26,21 @@ class JasperCore0xf0 {
2526
// SYNTHETIC: LEGORACERS 0x0044bf40
2627
// JasperCore0xf0::`scalar deleting destructor'
2728

29+
JasperAuxInterface* GetUnk0xa0() { return m_unk0xa0; }
30+
31+
protected:
32+
undefined m_unk0x04[0x40]; // 0x04
33+
undefined4 m_unk0x44; // 0x44
34+
undefined4 m_unk0x48; // 0x48
35+
undefined m_unk0x4c[0x40]; // 0x4c
36+
undefined4 m_unk0x8c; // 0x8c
37+
undefined4 m_unk0x90; // 0x90
38+
undefined4 m_unk0x94; // 0x94
39+
undefined4 m_unk0x98; // 0x98
40+
undefined4 m_unk0x9c; // 0x9c
41+
JasperAuxInterface* m_unk0xa0; // 0xa0
42+
2843
protected:
29-
undefined m_unk0x04[0x40]; // 0x04
30-
undefined4 m_unk0x44; // 0x44
31-
undefined4 m_unk0x48; // 0x48
32-
undefined m_unk0x4c[0x40]; // 0x4c
33-
undefined4 m_unk0x8c; // 0x8c
34-
undefined4 m_unk0x90; // 0x90
35-
undefined4 m_unk0x94; // 0x94
36-
undefined4 m_unk0x98; // 0x98
37-
undefined4 m_unk0x9c; // 0x9c
38-
undefined4 m_unk0xa0; // 0xa0
3944
undefined m_unk0xa4[0x40]; // 0xa4
4045
LPDIRECTINPUT m_directInput; // 0xe4
4146
undefined m_unk0xe8[0xec - 0xe8]; // 0xe8

LEGORacers/src/ironflame0x944.cpp

Lines changed: 102 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#include "ironflame0x944.h"
22

33
#include "../../GolDP/include/gol.h"
4+
#include "../../GolDP/include/golcommondrawstate.h"
45
#include "cactusinterface0x4.h"
56
#include "gol.h"
67
#include "golerror.h"
78
#include "golfsutil.h"
89
#include "golstream.h"
10+
#include "opalvault0xf0.h"
911

1012
#include <mmsystem.h>
1113
#include <stdio.h>
@@ -42,7 +44,7 @@ void IronFlame0x944::Init(const LegoChar* p_windowName, const LegoChar* p_fileNa
4244
{
4345
LegoChar buffer[64];
4446

45-
if (m_unk0x04 & c_flagInitialized) {
47+
if (m_flags & c_flagInitialized) {
4648
Destroy();
4749
}
4850

@@ -107,7 +109,7 @@ void IronFlame0x944::Init(const LegoChar* p_windowName, const LegoChar* p_fileNa
107109
ShowWindow(m_hWnd, SW_SHOW);
108110
m_lastFrameTimeMs = timeGetTime();
109111
m_unk0x92c = 0;
110-
m_unk0x04 |= c_flagInitialized;
112+
m_flags |= c_flagInitialized;
111113
}
112114

113115
// FUNCTION: LEGORACERS 0x004167b0
@@ -121,7 +123,7 @@ void IronFlame0x944::VTable0x2c()
121123
drawState->VTable0x48();
122124
}
123125

124-
m_unk0x04 &= ~c_flagDisplayActive;
126+
m_flags &= ~c_flagDisplayActive;
125127
}
126128

127129
// FUNCTION: LEGORACERS 0x004167e0
@@ -146,7 +148,7 @@ void IronFlame0x944::Destroy()
146148
UnloadGolLibrary();
147149

148150
m_unk0x92c = 0;
149-
m_unk0x04 = 0;
151+
m_flags = 0;
150152
}
151153

152154
// FUNCTION: LEGORACERS 0x00416860
@@ -268,11 +270,84 @@ void IronFlame0x944::VTable0x28(
268270
VTable0x24(p_width, p_height, p_bpp, p_flags | c_flagBit2);
269271
}
270272

271-
// STUB: LEGORACERS 0x00416b00
272-
void IronFlame0x944::VTable0x24(LegoU32, LegoU32, LegoU32, LegoU32)
273+
// FUNCTION: LEGORACERS 0x00416b00
274+
LegoS32 IronFlame0x944::VTable0x24(LegoU32 p_width, LegoU32 p_height, LegoU32 p_bpp, LegoU32 p_flags)
273275
{
274-
// TODO
275-
STUB(0x416b00);
276+
if (m_flags & c_flagDisplayActive) {
277+
VTable0x2c();
278+
}
279+
280+
m_width = p_width;
281+
m_height = p_height;
282+
m_bpp = p_bpp;
283+
m_flags = p_flags;
284+
m_unk0x930 = 1;
285+
286+
LegoU32 drawFlags = VTable0x00(p_flags);
287+
LegoS32 result = m_golDrawState->VTable0x44(p_width, p_height, p_bpp, drawFlags);
288+
if (result) {
289+
return result;
290+
}
291+
292+
GolCommonDrawState* commonState = static_cast<GolCommonDrawState*>(m_golDrawState);
293+
m_unk0x80c = commonState->m_unk0x1c;
294+
m_unk0x808 = (undefined4) m_golDrawState->m_unk0x14;
295+
296+
if (m_golDrawState->m_flags & GolDrawState::c_flagBit9) {
297+
m_flags |= c_flagBit3;
298+
}
299+
300+
if (!(m_flags & c_flagBit3)) {
301+
m_unk0x92c = 2;
302+
SetWindowLong(m_hWnd, GWL_STYLE, (LONG) m_unk0x940);
303+
304+
RECT rect;
305+
rect.left = 0;
306+
rect.right = p_width;
307+
rect.top = 0;
308+
rect.bottom = p_height;
309+
AdjustWindowRect(&rect, m_unk0x940, FALSE);
310+
311+
LegoS32 w = rect.right - rect.left;
312+
LegoS32 h = rect.bottom - rect.top;
313+
LegoS32 screenW = GetSystemMetrics(SM_CXSCREEN);
314+
LegoS32 screenH = GetSystemMetrics(SM_CYSCREEN);
315+
if (w > screenW) {
316+
w = screenW;
317+
}
318+
if (h > screenH) {
319+
h = screenH;
320+
}
321+
SetWindowPos(m_hWnd, NULL, 0, 0, w, h, SWP_SHOWWINDOW);
322+
}
323+
else {
324+
m_unk0x92c = 1;
325+
SetWindowLong(m_hWnd, GWL_STYLE, (LONG) m_unk0x93c);
326+
327+
if (m_flags & c_flagBit8) {
328+
SetWindowPos(m_hWnd, NULL, 0, 0, 0, 0, SWP_SHOWWINDOW);
329+
}
330+
else {
331+
VTable0x38()->GetUnk0xa0()->VTable0x44();
332+
SetWindowPos(
333+
m_hWnd,
334+
NULL,
335+
0,
336+
0,
337+
GetSystemMetrics(SM_CXSCREEN),
338+
GetSystemMetrics(SM_CYSCREEN),
339+
SWP_SHOWWINDOW
340+
);
341+
}
342+
}
343+
344+
SetWindowLong(m_hWnd, 0, (LONG) this);
345+
UpdateWindow(m_hWnd);
346+
SetFocus(m_hWnd);
347+
348+
m_unk0x930 = 0;
349+
m_flags |= c_flagDisplayActive;
350+
return 0;
276351
}
277352

278353
// FUNCTION: LEGORACERS 0x00416cd0
@@ -281,7 +356,7 @@ void IronFlame0x944::VTable0x30()
281356
if (m_golDrawState->GetFlags() & GolDrawState::c_flagBit0) {
282357
OutputDebugString("Toggling full-screen mode\n");
283358

284-
if (m_unk0x04 & c_flagBit3) {
359+
if (m_flags & c_flagBit3) {
285360
OutputDebugString("--to windowed\n");
286361
FUN_00417000(2);
287362
}
@@ -420,3 +495,21 @@ LegoU32 IronFlame0x944::VTable0x00(LegoU32 p_flags)
420495
}
421496
return result;
422497
}
498+
499+
// FUNCTION: LEGORACERS 0x00417980
500+
OpalVault0xf0* IronFlame0x944::VTable0x38()
501+
{
502+
return &m_unk0x834;
503+
}
504+
505+
// STUB: LEGORACERS 0x00417990 FOLDED
506+
void IronFlame0x944::VTable0x3c()
507+
{
508+
STUB(0x00417990);
509+
}
510+
511+
// STUB: LEGORACERS 0x00417990 FOLDED
512+
void IronFlame0x944::VTable0x40()
513+
{
514+
STUB(0x00417990);
515+
}

LEGORacers/src/jaspercore0xf0.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ LegoS32 JasperCore0xf0::Reset()
2323
m_unk0x98 = 0;
2424
m_unk0x94 = 0;
2525
m_unk0x90 = 0;
26-
m_unk0xa0 = 0;
26+
m_unk0xa0 = NULL;
2727
m_unk0x9c = 0;
2828
memset(m_unk0xa4, 0, sizeof(m_unk0xa4));
2929
memset(m_unk0x04, 0, sizeof(m_unk0x04));

LEGORacers/src/neoncactus0x1d6c.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ NeonCactus0x1d6c::~NeonCactus0x1d6c()
2727
// FUNCTION: LEGORACERS 0x0042bbb0
2828
LegoS32 NeonCactus0x1d6c::Init(LegoS32 p_argc, LegoChar** p_argv)
2929
{
30-
if (m_unk0x04.GetUnk0x04() & CrimsonForge0x800::c_flagInitialized) {
30+
if (m_unk0x04.GetFlags() & CrimsonForge0x800::c_flagInitialized) {
3131
Shutdown();
3232
}
3333

0 commit comments

Comments
 (0)