diff --git a/CMakeLists.txt b/CMakeLists.txt index e681cdf7..5768ccb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -433,7 +433,6 @@ endif() set(lego1_objects) set(lego1_link_libraries dxguid d3drm_guid) foreach(lego1_library IN LISTS lego1_targets) - message("lego1_library:${lego1_library}") target_compile_definitions(${lego1_library}-objects PRIVATE LEGO1_DLL) list(APPEND lego1_objects $) list(APPEND lego1_link_libraries ${lego1_library}-interface) diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 10a06a6a..66f13462 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -178,18 +178,15 @@ MxS32 IsleApp::SetupLegoOmni() char mediaPath[256]; GetProfileStringA("LEGO Island", "MediaPath", "", mediaPath, sizeof(mediaPath)); - // [library:window] For now, get the underlying Windows HWND to pass into Omni - HWND hwnd = (HWND - ) SDL_GetPointerProperty(SDL_GetWindowProperties(m_windowHandle), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); - #ifdef COMPAT_MODE MxS32 failure; { - MxOmniCreateParam param(mediaPath, hwnd, m_videoParam, MxOmniCreateFlags()); + MxOmniCreateParam param(mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags()); failure = Lego()->Create(param) == FAILURE; } #else - MxS32 failure = Lego()->Create(MxOmniCreateParam(mediaPath, hwnd, m_videoParam, MxOmniCreateFlags())) == FAILURE; + MxS32 failure = + Lego()->Create(MxOmniCreateParam(mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags())) == FAILURE; #endif if (!failure) { @@ -392,12 +389,22 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) break; } - // FIXME: use g_userEvent instead of SDL_EVENT_USER - if (event->type >= SDL_EVENT_USER && event->type <= SDL_EVENT_LAST - 1) { + if (event->user.type == g_legoSdlEvents.m_windowsMessage) { switch (event->user.code) { case WM_ISLE_SETCURSOR: g_isle->SetupCursor((Cursor) (uintptr_t) event->user.data1); break; + case WM_QUIT: + return SDL_APP_SUCCESS; + break; + case WM_TIMER: + if (InputManager()) { + InputManager()->QueueEvent(c_notificationTimer, (MxU8) (uintptr_t) event->user.data1, 0, 0, 0); + } + break; + default: + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unknown SDL Windows message: 0x%" SDL_PRIx32, event->user.code); + break; } } diff --git a/LEGO1/lego/legoomni/include/legoinputmanager.h b/LEGO1/lego/legoomni/include/legoinputmanager.h index f0d1d473..f93e2be3 100644 --- a/LEGO1/lego/legoomni/include/legoinputmanager.h +++ b/LEGO1/lego/legoomni/include/legoinputmanager.h @@ -10,6 +10,7 @@ #include #include +#include #include class LegoCameraController; @@ -145,7 +146,7 @@ private: MxS32 m_x; // 0x6c MxS32 m_y; // 0x70 MxS32 m_unk0x74; // 0x74 - UINT m_autoDragTimerID; // 0x78 + SDL_TimerID m_autoDragTimerID; // 0x78 UINT m_autoDragTime; // 0x7c MxBool m_unk0x80; // 0x80 MxBool m_unk0x81; // 0x81 diff --git a/LEGO1/lego/legoomni/include/legomain.h b/LEGO1/lego/legoomni/include/legomain.h index c7126f85..6cec064a 100644 --- a/LEGO1/lego/legoomni/include/legomain.h +++ b/LEGO1/lego/legoomni/include/legomain.h @@ -3,9 +3,12 @@ #include "compat.h" #include "lego1_export.h" +#include "legoutils.h" #include "mxdsaction.h" #include "mxomni.h" +#include + class Isle; class LegoAnimationManager; class LegoBuildingManager; @@ -185,7 +188,15 @@ public: MxResult StartActionIfUnknown0x13c(MxDSAction& p_dsAction) { return m_unk0x13c ? Start(&p_dsAction) : SUCCESS; } void SetUnknown13c(MxBool p_unk0x13c) { m_unk0x13c = p_unk0x13c; } - void CloseMainWindow() { PostMessageA(m_windowHandle, WM_CLOSE, 0, 0); } + void CloseMainWindow() + { + SDL_Event event; + event.user.type = g_legoSdlEvents.m_windowsMessage; + event.user.code = WM_CLOSE; + event.user.data1 = NULL; + event.user.data2 = NULL; + SDL_PushEvent(&event); + } // SYNTHETIC: LEGO1 0x10058b30 // LegoOmni::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/include/legoutils.h b/LEGO1/lego/legoomni/include/legoutils.h index ef816382..9d95f919 100644 --- a/LEGO1/lego/legoomni/include/legoutils.h +++ b/LEGO1/lego/legoomni/include/legoutils.h @@ -4,8 +4,10 @@ #include "actionsfwd.h" #include "decomp.h" #include "extra.h" +#include "lego1_export.h" #include "mxtypes.h" +#include #include #define WM_ISLE_SETCURSOR 0x5400 @@ -13,6 +15,12 @@ // name verified by BETA10 0x100d4054 #define DS_NOT_A_STREAM -1 +struct LegoSdlEvents { + Uint32 m_windowsMessage; +}; + +LEGO1_EXPORT extern LegoSdlEvents g_legoSdlEvents; + enum Cursor { e_cursorArrow = 0, e_cursorBusy, @@ -58,6 +66,7 @@ void PlayCamAnim(LegoPathActor* p_actor, MxBool p_unused, MxU32 p_location, MxBo void FUN_1003eda0(); MxBool RemoveFromCurrentWorld(const MxAtomId& p_atomId, MxS32 p_id); void EnableAnimations(MxBool p_enable); +void InitSdlEvents(); void SetAppCursor(Cursor p_cursor); MxBool FUN_1003ef60(); MxBool RemoveFromWorld(MxAtomId& p_entityAtom, MxS32 p_entityId, MxAtomId& p_worldAtom, MxS32 p_worldEntityId); diff --git a/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp b/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp index 138507ae..602eb746 100644 --- a/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp +++ b/LEGO1/lego/legoomni/src/build/legocarbuildpresenter.cpp @@ -103,7 +103,7 @@ inline void LegoCarBuildAnimPresenter::Beta10Inline0x100733d0() if (roi) { const LegoChar* name = roi->GetName(); - if (name && stricmp(wiredName, name) == 0) { + if (name && SDL_strcasecmp(wiredName, name) == 0) { if (bvar5) { roi->SetVisibility(TRUE); } @@ -310,7 +310,7 @@ void LegoCarBuildAnimPresenter::SwapNodesByName(LegoChar* p_name1, LegoChar* p_n { char buffer[40]; - if (stricmp(p_name1, p_name2) != 0) { + if (SDL_strcasecmp(p_name1, p_name2) != 0) { LegoAnimNodeData* node1 = FindNodeDataByName(m_anim->GetRoot(), p_name1); LegoAnimNodeData* node2 = FindNodeDataByName(m_anim->GetRoot(), p_name2); @@ -468,7 +468,7 @@ LegoAnimNodeData* LegoCarBuildAnimPresenter::FindNodeDataByName(LegoTreeNode* p_ if (p_treeNode) { data = (LegoAnimNodeData*) p_treeNode->GetData(); - if (stricmp(data->GetName(), p_name) == 0) { + if (SDL_strcasecmp(data->GetName(), p_name) == 0) { return data; } @@ -494,7 +494,7 @@ LegoTreeNode* LegoCarBuildAnimPresenter::FindNodeByName(LegoTreeNode* p_treeNode if (p_treeNode) { data = (LegoAnimNodeData*) p_treeNode->GetData(); - if (stricmp(data->GetName(), p_name) == 0) { + if (SDL_strcasecmp(data->GetName(), p_name) == 0) { return p_treeNode; } @@ -519,7 +519,7 @@ void LegoCarBuildAnimPresenter::FUN_10079790(const LegoChar* p_name) if (SDL_strcasecmp(m_parts[m_placedPartCount].m_name, p_name) != 0) { for (i = m_placedPartCount + 1; i < m_numberOfParts; i++) { - if (stricmp(m_parts[i].m_name, p_name) == 0) { + if (SDL_strcasecmp(m_parts[i].m_name, p_name) == 0) { break; } } @@ -595,7 +595,7 @@ void LegoCarBuildAnimPresenter::FUN_10079a90() // FUNCTION: BETA10 0x100724fa MxBool LegoCarBuildAnimPresenter::StringEqualsPlatform(const LegoChar* p_string) { - return stricmp(p_string, "PLATFORM") == 0; + return SDL_strcasecmp(p_string, "PLATFORM") == 0; } // FUNCTION: LEGO1 0x10079b40 diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 1829c8cc..2379b2d1 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -887,7 +887,7 @@ void LegoAnimationManager::FUN_10060480(const LegoChar* p_characterNames[], MxU3 { for (MxS32 i = 0; i < p_numCharacterNames; i++) { for (MxS32 j = 0; j < sizeOfArray(g_characters); j++) { - if (!stricmp(g_characters[j].m_name, p_characterNames[i])) { + if (!SDL_strcasecmp(g_characters[j].m_name, p_characterNames[i])) { g_characters[j].m_unk0x08 = TRUE; } } diff --git a/LEGO1/lego/legoomni/src/common/legoutils.cpp b/LEGO1/lego/legoomni/src/common/legoutils.cpp index 8230f4e2..b8f76c6f 100644 --- a/LEGO1/lego/legoomni/src/common/legoutils.cpp +++ b/LEGO1/lego/legoomni/src/common/legoutils.cpp @@ -37,6 +37,8 @@ #include #include +LegoSdlEvents g_legoSdlEvents; + // FUNCTION: LEGO1 0x1003dd70 // FUNCTION: BETA10 0x100d3410 LegoROI* PickROI(MxLong p_x, MxLong p_y) @@ -565,13 +567,22 @@ void EnableAnimations(MxBool p_enable) AnimationManager()->FUN_100604d0(p_enable); } +void InitSdlEvents() +{ + static bool g_initialized = false; + + if (!g_initialized) { + g_initialized = true; + Uint32 event = SDL_RegisterEvents(1); + g_legoSdlEvents.m_windowsMessage = event + 0; + } +} + // FUNCTION: LEGO1 0x1003ef40 void SetAppCursor(Cursor p_cursor) { - static Uint32 g_userEvent = SDL_RegisterEvents(1); - SDL_Event event; - event.user.type = g_userEvent; + event.user.type = g_legoSdlEvents.m_windowsMessage; event.user.code = WM_ISLE_SETCURSOR; event.user.data1 = (void*) p_cursor; SDL_PushEvent(&event); diff --git a/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp b/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp index af3dd04c..52e58567 100644 --- a/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp +++ b/LEGO1/lego/legoomni/src/entity/legojetskiraceactor.cpp @@ -6,6 +6,7 @@ #include "mxmisc.h" #include "mxvariabletable.h" +#include #include DECOMP_SIZE_ASSERT(LegoJetskiRaceActor, 0x1a8) @@ -123,7 +124,7 @@ void LegoJetskiRaceActor::Animate(float p_time) { if (m_unk0x0c == 0) { const LegoChar* raceState = VariableTable()->GetVariable(g_raceState); - if (!stricmp(raceState, g_racing)) { + if (!SDL_strcasecmp(raceState, g_racing)) { m_unk0x0c = 1; m_lastTime = p_time - 1.0f; m_unk0x1c = p_time; diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index c18367f5..b855e116 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -514,11 +514,22 @@ MxBool LegoInputManager::FUN_1005cdf0(LegoEventNotificationParam& p_param) return result; } +static Uint32 SDLCALL LegoInputManagerTimerCallback(void* userdata, SDL_TimerID timerID, Uint32 interval) +{ + LegoInputManager* inputManager = (LegoInputManager*) userdata; + SDL_Event event; + event.type = g_legoSdlEvents.m_windowsMessage; + event.user.code = WM_TIMER; + event.user.data1 = (void*) (uintptr_t) timerID; + event.user.data2 = NULL; + return interval; +} + // FUNCTION: LEGO1 0x1005cfb0 // FUNCTION: BETA10 0x10089fc5 void LegoInputManager::StartAutoDragTimer() { - m_autoDragTimerID = ::SetTimer(LegoOmni::GetInstance()->GetWindowHandle(), 1, m_autoDragTime, NULL); + m_autoDragTimerID = SDL_AddTimer(m_autoDragTime, LegoInputManagerTimerCallback, this); } // FUNCTION: LEGO1 0x1005cfd0 @@ -526,7 +537,8 @@ void LegoInputManager::StartAutoDragTimer() void LegoInputManager::StopAutoDragTimer() { if (m_autoDragTimerID) { - ::KillTimer(LegoOmni::GetInstance()->GetWindowHandle(), m_autoDragTimerID); + SDL_RemoveTimer(m_autoDragTimerID); + m_autoDragTimerID = 0; } } diff --git a/LEGO1/lego/legoomni/src/main/legomain.cpp b/LEGO1/lego/legoomni/src/main/legomain.cpp index fe7fc015..f5d725be 100644 --- a/LEGO1/lego/legoomni/src/main/legomain.cpp +++ b/LEGO1/lego/legoomni/src/main/legomain.cpp @@ -160,6 +160,7 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param) { MxResult result = FAILURE; AUTOLOCK(m_criticalSection); + HWND hWnd = NULL; p_param.CreateFlags().CreateObjectFactory(FALSE); p_param.CreateFlags().CreateVideoManager(FALSE); @@ -191,7 +192,13 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param) goto done; } - if (!(m_inputManager = new LegoInputManager()) || m_inputManager->Create(p_param.GetWindowHandle()) != SUCCESS) { + // [library:dinput] + hWnd = (HWND) SDL_GetPointerProperty( + SDL_GetWindowProperties(MxOmni::GetInstance()->GetWindowHandle()), + SDL_PROP_WINDOW_WIN32_HWND_POINTER, + NULL + ); + if (!(m_inputManager = new LegoInputManager()) || m_inputManager->Create(hWnd) != SUCCESS) { delete m_inputManager; m_inputManager = NULL; goto done; @@ -260,6 +267,8 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param) SetAppCursor(e_cursorBusy); m_gameState->SetCurrentAct(LegoGameState::e_act1); + InitSdlEvents(); + result = SUCCESS; done: diff --git a/LEGO1/lego/legoomni/src/video/legovideomanager.cpp b/LEGO1/lego/legoomni/src/video/legovideomanager.cpp index fb7bd950..0b5a9e4f 100644 --- a/LEGO1/lego/legoomni/src/video/legovideomanager.cpp +++ b/LEGO1/lego/legoomni/src/video/legovideomanager.cpp @@ -85,7 +85,12 @@ MxResult LegoVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyM Mx3DPointFloat dirVec(0.0, 0.0, 1.0); Mx3DPointFloat upVec(0.0, 1.0, 0.0); MxMatrix outMatrix; - HWND hwnd = MxOmni::GetInstance()->GetWindowHandle(); + // [library:ddraw] [library:d3d] + HWND hwnd = (HWND) SDL_GetPointerProperty( + SDL_GetWindowProperties(MxOmni::GetInstance()->GetWindowHandle()), + SDL_PROP_WINDOW_WIN32_HWND_POINTER, + NULL + ); MxS32 bits = p_videoParam.Flags().Get16Bit() ? 16 : 8; if (!p_videoParam.GetPalette()) { @@ -176,7 +181,11 @@ MxResult LegoVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyM Lego3DManager::CreateStruct createStruct; memset(&createStruct, 0, sizeof(createStruct)); - createStruct.m_hWnd = LegoOmni::GetInstance()->GetWindowHandle(); + createStruct.m_hWnd = (HWND) SDL_GetPointerProperty( + SDL_GetWindowProperties(MxOmni::GetInstance()->GetWindowHandle()), + SDL_PROP_WINDOW_WIN32_HWND_POINTER, + NULL + ); createStruct.m_pDirectDraw = m_pDirectDraw; createStruct.m_pFrontBuffer = m_displaySurface->GetDirectDrawSurface1(); createStruct.m_pBackBuffer = m_displaySurface->GetDirectDrawSurface2(); diff --git a/LEGO1/mxdirectx/mxstopwatch.h b/LEGO1/mxdirectx/mxstopwatch.h index fcd761a6..2cddb341 100644 --- a/LEGO1/mxdirectx/mxstopwatch.h +++ b/LEGO1/mxdirectx/mxstopwatch.h @@ -3,6 +3,8 @@ #include "assert.h" +#include +#include #include // ULONG_MAX #include #include @@ -29,73 +31,55 @@ public: double ElapsedSeconds() const; protected: - unsigned long TicksPerSeconds() const; + Uint64 TicksPerSeconds() const; private: - LARGE_INTEGER m_startTick; // 0x00 + Uint64 m_startTick; // 0x00 // ??? when we provide LARGE_INTEGER arithmetic, use a // LARGE_INTEGER m_elapsedTicks rather than m_elapsedSeconds - double m_elapsedSeconds; // 0x0c - unsigned long m_ticksPerSeconds; // 0x14 + double m_elapsedSeconds; // 0x0c + Uint64 m_ticksPerSeconds; // 0x14 }; // FUNCTION: BETA10 0x100d8ba0 inline MxStopWatch::MxStopWatch() { Reset(); - m_ticksPerSeconds = TicksPerSeconds(); + m_ticksPerSeconds = SDL_GetPerformanceCounter(); } // FUNCTION: BETA10 0x100d8be0 inline void MxStopWatch::Start() { - QueryPerformanceCounter(&m_startTick); + m_startTick = SDL_GetPerformanceCounter(); } // FUNCTION: BETA10 0x100d8f50 inline void MxStopWatch::Stop() { - LARGE_INTEGER endTick; - BOOL result; + Uint64 endTick; - result = QueryPerformanceCounter(&endTick); - assert(result); + endTick = SDL_GetPerformanceCounter(); - if (endTick.HighPart != m_startTick.HighPart) { - // LARGE_INTEGER arithmetic not yet provided - m_elapsedSeconds = HUGE_VAL_IMMEDIATE; - } - else { - m_elapsedSeconds += ((endTick.LowPart - m_startTick.LowPart) / (double) m_ticksPerSeconds); - } + m_elapsedSeconds = (double) (endTick - m_startTick) / (double) m_ticksPerSeconds; } // FUNCTION: BETA10 0x100d8c10 inline void MxStopWatch::Reset() { - m_startTick.LowPart = 0; - m_startTick.HighPart = 0; - m_elapsedSeconds = 0; + m_startTick = 0; + m_elapsedSeconds = 0.; } // FUNCTION: BETA10 0x100d8c60 -inline unsigned long MxStopWatch::TicksPerSeconds() const +inline Uint64 MxStopWatch::TicksPerSeconds() const { - LARGE_INTEGER ticksPerSeconds; - BOOL result; + Uint64 ticksPerSeconds; - result = QueryPerformanceFrequency(&ticksPerSeconds); - assert(result); + ticksPerSeconds = SDL_GetPerformanceFrequency(); + assert(ticksPerSeconds); - if (ticksPerSeconds.HighPart) { - // LARGE_INTEGER arithmetic not yet provided - - // timer is too fast (faster than 32bits/s, i.e. faster than 4GHz) - return ULONG_MAX; - } - else { - return ticksPerSeconds.LowPart; - } + return ticksPerSeconds; } // FUNCTION: BETA10 0x100d9020 diff --git a/LEGO1/omni/include/flic.h b/LEGO1/omni/include/flic.h index 21d114df..1ed06087 100644 --- a/LEGO1/omni/include/flic.h +++ b/LEGO1/omni/include/flic.h @@ -25,7 +25,7 @@ typedef struct { WORD type; // 0x04 } FLIC_CHUNK; -typedef struct : FLIC_CHUNK { +typedef struct FLIC_HEADER : FLIC_CHUNK { WORD frames; /* Number of frames in first segment */ // 0x06 WORD width; /* FLIC width in pixels */ // 0x08 WORD height; /* FLIC height in pixels */ // 0x0a @@ -35,7 +35,7 @@ typedef struct : FLIC_CHUNK { } FLIC_HEADER; #pragma pack(pop) -typedef struct : FLIC_CHUNK { +typedef struct FLIC_FRAME : FLIC_CHUNK { WORD chunks; /* Number of subchunks */ // 0x06 WORD delay; /* Delay in milliseconds */ // 0x08 WORD reserved; /* Always zero */ // 0x0a diff --git a/LEGO1/omni/include/mxomni.h b/LEGO1/omni/include/mxomni.h index 55fb4e21..c80ad35b 100644 --- a/LEGO1/omni/include/mxomni.h +++ b/LEGO1/omni/include/mxomni.h @@ -6,6 +6,7 @@ #include "mxcriticalsection.h" #include "mxstring.h" +#include #include class MxAtomSet; @@ -61,7 +62,7 @@ public: static void SetInstance(MxOmni* p_instance); static MxBool ActionSourceEquals(MxDSAction* p_action, const char* p_name); - HWND GetWindowHandle() const { return this->m_windowHandle; } + SDL_Window* GetWindowHandle() const { return m_windowHandle; } // FUNCTION: BETA10 0x10125100 MxObjectFactory* GetObjectFactory() const { return this->m_objectFactory; } @@ -102,7 +103,7 @@ protected: static MxOmni* g_instance; MxString m_mediaPath; // 0x08 - HWND m_windowHandle; // 0x18 + SDL_Window* m_windowHandle; // 0x18 MxObjectFactory* m_objectFactory; // 0x1c MxVariableTable* m_variableTable; // 0x20 MxTickleManager* m_tickleManager; // 0x24 diff --git a/LEGO1/omni/include/mxomnicreateparam.h b/LEGO1/omni/include/mxomnicreateparam.h index 65a19fd6..7e83e419 100644 --- a/LEGO1/omni/include/mxomnicreateparam.h +++ b/LEGO1/omni/include/mxomnicreateparam.h @@ -7,7 +7,7 @@ #include "mxstring.h" #include "mxvideoparam.h" -#include +#include // VTABLE: LEGO1 0x100dc218 // VTABLE: BETA10 0x101c1ca8 @@ -15,7 +15,7 @@ class MxOmniCreateParam : public MxParam { public: LEGO1_EXPORT MxOmniCreateParam( const char* p_mediaPath, - HWND p_windowHandle, + SDL_Window* p_windowHandle, MxVideoParam& p_vparam, MxOmniCreateFlags p_flags ); @@ -24,7 +24,7 @@ public: MxOmniCreateFlags& CreateFlags() { return this->m_createFlags; } const MxString& GetMediaPath() const { return m_mediaPath; } - const HWND GetWindowHandle() const { return m_windowHandle; } + SDL_Window* GetWindowHandle() const { return m_windowHandle; } MxVideoParam& GetVideoParam() { return m_videoParam; } const MxVideoParam& GetVideoParam() const { return m_videoParam; } @@ -34,7 +34,7 @@ public: private: MxString m_mediaPath; // 0x04 - HWND m_windowHandle; // 0x14 + SDL_Window* m_windowHandle; // 0x14 MxVideoParam m_videoParam; // 0x18 MxOmniCreateFlags m_createFlags; // 0x3c }; diff --git a/LEGO1/omni/src/main/mxomnicreateparam.cpp b/LEGO1/omni/src/main/mxomnicreateparam.cpp index 88235330..37133217 100644 --- a/LEGO1/omni/src/main/mxomnicreateparam.cpp +++ b/LEGO1/omni/src/main/mxomnicreateparam.cpp @@ -8,7 +8,7 @@ DECOMP_SIZE_ASSERT(MxOmniCreateParam, 0x40) // FUNCTION: BETA10 0x10130b6b MxOmniCreateParam::MxOmniCreateParam( const char* p_mediaPath, - HWND p_windowHandle, + SDL_Window* p_windowHandle, MxVideoParam& p_vparam, MxOmniCreateFlags p_flags ) diff --git a/LEGO1/omni/src/video/mxdisplaysurface.cpp b/LEGO1/omni/src/video/mxdisplaysurface.cpp index 6a2baddf..2bdfbe2d 100644 --- a/LEGO1/omni/src/video/mxdisplaysurface.cpp +++ b/LEGO1/omni/src/video/mxdisplaysurface.cpp @@ -139,7 +139,14 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam) DDSURFACEDESC ddsd; MxResult result = FAILURE; LPDIRECTDRAW lpDirectDraw = MVideoManager()->GetDirectDraw(); - HWND hWnd = MxOmni::GetInstance()->GetWindowHandle(); + SDL_Window* window = MxOmni::GetInstance()->GetWindowHandle(); + // [library:ddraw] + HWND hWnd = + (HWND) SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); + + if (!hWnd) { + goto done; + } m_initialized = TRUE; m_videoParam = p_videoParam; @@ -842,7 +849,13 @@ void MxDisplaySurface::Display(MxS32 p_left, MxS32 p_top, MxS32 p_left2, MxS32 p } else { MxPoint32 point(0, 0); - ClientToScreen(MxOmni::GetInstance()->GetWindowHandle(), (LPPOINT) &point); + // [library:ddraw] + HWND hWnd = (HWND) SDL_GetPointerProperty( + SDL_GetWindowProperties(MxOmni::GetInstance()->GetWindowHandle()), + SDL_PROP_WINDOW_WIN32_HWND_POINTER, + NULL + ); + ClientToScreen(hWnd, (LPPOINT) &point); p_left2 += m_videoParam.GetRect().GetLeft() + point.GetX(); p_top2 += m_videoParam.GetRect().GetTop() + point.GetY(); diff --git a/LEGO1/omni/src/video/mxvideomanager.cpp b/LEGO1/omni/src/video/mxvideomanager.cpp index 9c99f944..e6eab0e6 100644 --- a/LEGO1/omni/src/video/mxvideomanager.cpp +++ b/LEGO1/omni/src/video/mxvideomanager.cpp @@ -216,6 +216,7 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS, { MxBool locked = FALSE; MxResult status = FAILURE; + HWND hWnd = NULL; m_unk0x60 = TRUE; @@ -237,7 +238,13 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS, goto done; } - if (m_pDirectDraw->SetCooperativeLevel(MxOmni::GetInstance()->GetWindowHandle(), DDSCL_NORMAL) != DD_OK) { + // [library:ddraw] + hWnd = (HWND) SDL_GetPointerProperty( + SDL_GetWindowProperties(MxOmni::GetInstance()->GetWindowHandle()), + SDL_PROP_WINDOW_WIN32_HWND_POINTER, + NULL + ); + if (m_pDirectDraw->SetCooperativeLevel(hWnd, DDSCL_NORMAL) != DD_OK) { goto done; } diff --git a/util/compat.h b/util/compat.h index ea2a6507..db768dda 100644 --- a/util/compat.h +++ b/util/compat.h @@ -3,7 +3,7 @@ // Various macros to enable compiling with other/newer compilers. -#if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1100) +#if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER >= 1100) || !defined(_WIN32) #define COMPAT_MODE #endif