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+ }
0 commit comments