From 880ae98f0b8544853483adef7fa9760e7a3087fb Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 31 May 2024 23:13:27 -0400 Subject: [PATCH] Remove dependency on dinput, use SDL keyboard state for navigation (#14) * WIP * Use SDL kb state for navigational keys * Remove linking against dinput --- CMakeLists.txt | 2 +- ISLE/isleapp.cpp | 157 +++++++++--------- ISLE/isleapp.h | 58 +++---- .../lego/legoomni/include/legoinputmanager.h | 50 +++--- .../legoomni/src/input/legoinputmanager.cpp | 77 +-------- LEGO1/omni/include/mxthread.h | 4 +- LEGO1/omni/src/system/mxcriticalsection.cpp | 4 +- util/platform.h | 20 --- 8 files changed, 143 insertions(+), 229 deletions(-) delete mode 100644 util/platform.h diff --git a/CMakeLists.txt b/CMakeLists.txt index fc495a52..cd295e2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -474,7 +474,7 @@ target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/LEGO1/lego/legoomni target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/LEGO1/lego/legoomni/include/actions") # Link libraries -target_link_libraries(lego1 PRIVATE tglrl viewmanager realtime mxdirectx roi geom anim Vec::Vec dinput dxguid misc 3dmanager omni) +target_link_libraries(lego1 PRIVATE tglrl viewmanager realtime mxdirectx roi geom anim Vec::Vec dxguid misc 3dmanager omni) foreach(tgt IN LISTS lego1_targets) target_link_libraries(${tgt} PRIVATE $<$:DirectX5::DirectX5> SDL3::SDL3) diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 86ce3837..fd5bc838 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -43,34 +43,31 @@ DECOMP_SIZE_ASSERT(IsleApp, 0x8c) IsleApp* g_isle = NULL; // GLOBAL: ISLE 0x410034 -unsigned char g_mousedown = FALSE; +MxU8 g_mousedown = FALSE; // GLOBAL: ISLE 0x410038 -unsigned char g_mousemoved = FALSE; +MxU8 g_mousemoved = FALSE; // GLOBAL: ISLE 0x41003c -BOOL g_closed = FALSE; - -// GLOBAL: ISLE 0x410040 -RECT g_windowRect = {0, 0, 640, 480}; +MxS32 g_closed = FALSE; // GLOBAL: ISLE 0x410050 -BOOL g_rmDisabled = FALSE; +MxS32 g_rmDisabled = FALSE; // GLOBAL: ISLE 0x410054 -BOOL g_waitingForTargetDepth = TRUE; +MxS32 g_waitingForTargetDepth = TRUE; // GLOBAL: ISLE 0x410058 -int g_targetWidth = 640; +MxS32 g_targetWidth = 640; // GLOBAL: ISLE 0x41005c -int g_targetHeight = 480; +MxS32 g_targetHeight = 480; // GLOBAL: ISLE 0x410060 -int g_targetDepth = 16; +MxS32 g_targetDepth = 16; // GLOBAL: ISLE 0x410064 -BOOL g_reqEnableRMDevice = FALSE; +MxS32 g_reqEnableRMDevice = FALSE; // STRING: ISLE 0x4101dc #define WINDOW_TITLE "LEGO®" @@ -154,7 +151,7 @@ void IsleApp::Close() if (Lego()) { GameState()->Save(0); if (InputManager()) { - InputManager()->QueueEvent(c_notificationKeyPress, 0, 0, 0, VK_SPACE); + InputManager()->QueueEvent(c_notificationKeyPress, 0, 0, 0, SDLK_SPACE); } VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->RemoveAll(NULL); @@ -181,9 +178,9 @@ void IsleApp::Close() } // FUNCTION: ISLE 0x4013b0 -BOOL IsleApp::SetupLegoOmni() +MxS32 IsleApp::SetupLegoOmni() { - BOOL result = FALSE; + MxS32 result = FALSE; char mediaPath[256]; GetProfileStringA("LEGO Island", "MediaPath", "", mediaPath, sizeof(mediaPath)); @@ -192,14 +189,15 @@ BOOL IsleApp::SetupLegoOmni() (HWND) SDL_GetProperty(SDL_GetWindowProperties(m_windowHandle), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); #ifdef COMPAT_MODE - BOOL failure; + MxS32 failure; { MxOmniCreateParam param(mediaPath, (struct HWND__*) hwnd, m_videoParam, MxOmniCreateFlags()); failure = Lego()->Create(param) == FAILURE; } #else - BOOL failure = Lego()->Create(MxOmniCreateParam(mediaPath, (struct HWND__*) hwnd, m_videoParam, MxOmniCreateFlags()) - ) == FAILURE; + MxS32 failure = + Lego()->Create(MxOmniCreateParam(mediaPath, (struct HWND__*) hwnd, m_videoParam, MxOmniCreateFlags())) == + FAILURE; #endif if (!failure) { @@ -213,14 +211,14 @@ BOOL IsleApp::SetupLegoOmni() // FUNCTION: ISLE 0x401560 void IsleApp::SetupVideoFlags( - BOOL fullScreen, - BOOL flipSurfaces, - BOOL backBuffers, - BOOL using8bit, - BOOL using16bit, - BOOL param_6, - BOOL param_7, - BOOL wideViewAngle, + MxS32 fullScreen, + MxS32 flipSurfaces, + MxS32 backBuffers, + MxS32 using8bit, + MxS32 using16bit, + MxS32 param_6, + MxS32 param_7, + MxS32 wideViewAngle, char* deviceId ) { @@ -284,7 +282,7 @@ int SDL_AppIterate(void* appstate) return 1; } - g_isle->Tick(0); + g_isle->Tick(); if (!g_closed) { if (g_reqEnableRMDevice) { @@ -299,7 +297,7 @@ int SDL_AppIterate(void* appstate) } if (g_mousedown && g_mousemoved && g_isle) { - g_isle->Tick(0); + g_isle->Tick(); } if (g_mousemoved) { @@ -316,7 +314,8 @@ int SDL_AppEvent(void* appstate, const SDL_Event* event) return 0; } - // [library:window] Remaining functionality to be implemented: + // [library:window] + // Remaining functionality to be implemented: // Full screen - crashes when minimizing/maximizing // WM_TIMER - use SDL_Timer functionality instead // WM_SETCURSOR - update cursor @@ -361,7 +360,7 @@ int SDL_AppEvent(void* appstate, const SDL_Event* event) } if (g_isle->GetDrawCursor()) { - VideoManager()->MoveCursor(Min((int) event->motion.x, 639), Min((int) event->motion.y, 479)); + VideoManager()->MoveCursor(Min((MxS32) event->motion.x, 639), Min((MxS32) event->motion.y, 479)); } break; case SDL_EVENT_MOUSE_BUTTON_DOWN: @@ -442,10 +441,10 @@ MxResult IsleApp::SetupWindow() srand(time(NULL)); if (m_fullScreen) { - m_windowHandle = SDL_CreateWindow(WINDOW_TITLE, g_windowRect.right, g_windowRect.bottom, SDL_WINDOW_FULLSCREEN); + m_windowHandle = SDL_CreateWindow(WINDOW_TITLE, g_targetWidth, g_targetHeight, SDL_WINDOW_FULLSCREEN); } else { - m_windowHandle = SDL_CreateWindow(WINDOW_TITLE, g_windowRect.right, g_windowRect.bottom, 0); + m_windowHandle = SDL_CreateWindow(WINDOW_TITLE, g_targetWidth, g_targetHeight, 0); } if (!m_windowHandle) { @@ -460,7 +459,7 @@ MxResult IsleApp::SetupWindow() GameState()->SerializePlayersInfo(1); GameState()->SerializeScoreHistory(1); - int iVar10; + MxS32 iVar10; switch (m_islandQuality) { case 0: iVar10 = 1; @@ -472,7 +471,7 @@ MxResult IsleApp::SetupWindow() iVar10 = 100; } - int uVar1 = (m_islandTexture == 0); + MxS32 uVar1 = (m_islandTexture == 0); LegoModelPresenter::configureLegoModelPresenter(uVar1); LegoPartPresenter::configureLegoPartPresenter(uVar1, iVar10); LegoWorldPresenter::configureLegoWorldPresenter(m_islandQuality); @@ -518,12 +517,12 @@ void IsleApp::LoadConfig() m_joystickIndex = iniparser_getint(dict, "isle:JoystickIndex", m_joystickIndex); m_drawCursor = iniparser_getboolean(dict, "isle:Draw Cursor", m_drawCursor); - int backBuffersInVRAM = iniparser_getboolean(dict, "isle:Back Buffers in Video RAM", -1); + MxS32 backBuffersInVRAM = iniparser_getboolean(dict, "isle:Back Buffers in Video RAM", -1); if (backBuffersInVRAM != -1) { m_backBuffersInVram = !backBuffersInVRAM; } - int bitDepth = iniparser_getint(dict, "isle:Display Bit Depth", -1); + MxS32 bitDepth = iniparser_getint(dict, "isle:Display Bit Depth", -1); if (bitDepth != -1) { if (bitDepth == 8) { m_using8bit = TRUE; @@ -556,16 +555,16 @@ void IsleApp::LoadConfig() } // FUNCTION: ISLE 0x402c20 -inline void IsleApp::Tick(BOOL sleepIfNotNextFrame) +inline void IsleApp::Tick() { // GLOBAL: ISLE 0x4101c0 static MxLong g_lastFrameTime = 0; // GLOBAL: ISLE 0x4101bc - static int g_startupDelay = 200; + static MxS32 g_startupDelay = 200; if (!m_windowActive) { - Sleep(0); + SDL_Delay(1); return; } @@ -584,54 +583,54 @@ inline void IsleApp::Tick(BOOL sleepIfNotNextFrame) g_lastFrameTime = -m_frameDelta; } - if (m_frameDelta + g_lastFrameTime < currentTime) { - if (!Lego()->IsTimerRunning()) { - TickleManager()->Tickle(); - } - g_lastFrameTime = currentTime; + if (m_frameDelta + g_lastFrameTime >= currentTime) { + SDL_Delay(1); + return; + } - if (g_startupDelay == 0) { - return; - } + if (!Lego()->IsTimerRunning()) { + TickleManager()->Tickle(); + } + g_lastFrameTime = currentTime; - g_startupDelay--; - if (g_startupDelay != 0) { - return; - } + if (g_startupDelay == 0) { + return; + } - LegoOmni::GetInstance()->CreateBackgroundAudio(); - BackgroundAudioManager()->Enable(this->m_useMusic); + g_startupDelay--; + if (g_startupDelay != 0) { + return; + } - MxStreamController* stream = Streamer()->Open("\\lego\\scripts\\isle\\isle", MxStreamer::e_diskStream); - MxDSAction ds; + LegoOmni::GetInstance()->CreateBackgroundAudio(); + BackgroundAudioManager()->Enable(m_useMusic); + MxStreamController* stream = Streamer()->Open("\\lego\\scripts\\isle\\isle", MxStreamer::e_diskStream); + MxDSAction ds; + + if (!stream) { + stream = Streamer()->Open("\\lego\\scripts\\nocd", MxStreamer::e_diskStream); if (!stream) { - stream = Streamer()->Open("\\lego\\scripts\\nocd", MxStreamer::e_diskStream); - if (!stream) { - return; - } - - ds.SetAtomId(stream->GetAtom()); - ds.SetUnknown24(-1); - ds.SetObjectId(0); - VideoManager()->EnableFullScreenMovie(TRUE, TRUE); - - if (Start(&ds) != SUCCESS) { - return; - } + return; } - else { - ds.SetAtomId(stream->GetAtom()); - ds.SetUnknown24(-1); - ds.SetObjectId(0); - if (Start(&ds) != SUCCESS) { - return; - } - m_gameStarted = TRUE; + + ds.SetAtomId(stream->GetAtom()); + ds.SetUnknown24(-1); + ds.SetObjectId(0); + VideoManager()->EnableFullScreenMovie(TRUE, TRUE); + + if (Start(&ds) != SUCCESS) { + return; } } - else if (sleepIfNotNextFrame != 0) { - Sleep(0); + else { + ds.SetAtomId(stream->GetAtom()); + ds.SetUnknown24(-1); + ds.SetObjectId(0); + if (Start(&ds) != SUCCESS) { + return; + } + m_gameStarted = TRUE; } } diff --git a/ISLE/isleapp.h b/ISLE/isleapp.h index 99579a68..c6f84d1b 100644 --- a/ISLE/isleapp.h +++ b/ISLE/isleapp.h @@ -16,60 +16,60 @@ class IsleApp { void Close(); - BOOL SetupLegoOmni(); + MxS32 SetupLegoOmni(); void SetupVideoFlags( - BOOL fullScreen, - BOOL flipSurfaces, - BOOL backBuffers, - BOOL using8bit, - BOOL using16bit, - BOOL param_6, - BOOL param_7, - BOOL wideViewAngle, + MxS32 fullScreen, + MxS32 flipSurfaces, + MxS32 backBuffers, + MxS32 using8bit, + MxS32 using16bit, + MxS32 param_6, + MxS32 param_7, + MxS32 wideViewAngle, char* deviceId ); MxResult SetupWindow(); void LoadConfig(); - void Tick(BOOL sleepIfNotNextFrame); + void Tick(); void SetupCursor(WPARAM wParam); static MxU8 MapMouseButtonFlagsToModifier(SDL_MouseButtonFlags p_flags); inline SDL_Window* GetWindowHandle() { return m_windowHandle; } inline MxLong GetFrameDelta() { return m_frameDelta; } - inline BOOL GetFullScreen() { return m_fullScreen; } + inline MxS32 GetFullScreen() { return m_fullScreen; } inline HCURSOR GetCursorCurrent() { return m_cursorCurrent; } inline HCURSOR GetCursorBusy() { return m_cursorBusy; } inline HCURSOR GetCursorNo() { return m_cursorNo; } - inline BOOL GetDrawCursor() { return m_drawCursor; } + inline MxS32 GetDrawCursor() { return m_drawCursor; } - inline void SetWindowActive(BOOL p_windowActive) { m_windowActive = p_windowActive; } + inline void SetWindowActive(MxS32 p_windowActive) { m_windowActive = p_windowActive; } private: char* m_hdPath; // 0x00 char* m_cdPath; // 0x04 char* m_deviceId; // 0x08 char* m_savePath; // 0x0c - BOOL m_fullScreen; // 0x10 - BOOL m_flipSurfaces; // 0x14 - BOOL m_backBuffersInVram; // 0x18 - BOOL m_using8bit; // 0x1c - BOOL m_using16bit; // 0x20 - int m_unk0x24; // 0x24 - BOOL m_use3dSound; // 0x28 - BOOL m_useMusic; // 0x2c - BOOL m_useJoystick; // 0x30 - int m_joystickIndex; // 0x34 - BOOL m_wideViewAngle; // 0x38 - int m_islandQuality; // 0x3c - int m_islandTexture; // 0x40 - BOOL m_gameStarted; // 0x44 + MxS32 m_fullScreen; // 0x10 + MxS32 m_flipSurfaces; // 0x14 + MxS32 m_backBuffersInVram; // 0x18 + MxS32 m_using8bit; // 0x1c + MxS32 m_using16bit; // 0x20 + MxS32 m_unk0x24; // 0x24 + MxS32 m_use3dSound; // 0x28 + MxS32 m_useMusic; // 0x2c + MxS32 m_useJoystick; // 0x30 + MxS32 m_joystickIndex; // 0x34 + MxS32 m_wideViewAngle; // 0x38 + MxS32 m_islandQuality; // 0x3c + MxS32 m_islandTexture; // 0x40 + MxS32 m_gameStarted; // 0x44 MxLong m_frameDelta; // 0x48 MxVideoParam m_videoParam; // 0x4c - BOOL m_windowActive; // 0x70 + MxS32 m_windowActive; // 0x70 SDL_Window* m_windowHandle; // 0x74 - BOOL m_drawCursor; // 0x78 + MxS32 m_drawCursor; // 0x78 HCURSOR m_cursorArrow; // 0x7c HCURSOR m_cursorBusy; // 0x80 HCURSOR m_cursorNo; // 0x84 diff --git a/LEGO1/lego/legoomni/include/legoinputmanager.h b/LEGO1/lego/legoomni/include/legoinputmanager.h index c4a0dc1a..45dd6306 100644 --- a/LEGO1/lego/legoomni/include/legoinputmanager.h +++ b/LEGO1/lego/legoomni/include/legoinputmanager.h @@ -7,6 +7,7 @@ #include "mxpresenter.h" #include "mxqueue.h" +#include #include class LegoCameraController; @@ -94,8 +95,6 @@ class LegoInputManager : public MxPresenter { MxResult Create(HWND p_hwnd); void Destroy() override; - void CreateAndAcquireKeyboard(HWND p_hwnd); - void ReleaseDX(); MxResult GetJoystickId(); MxResult GetJoystickState(MxU32* p_joystickX, MxU32* p_joystickY, DWORD* p_buttonsState, MxU32* p_povPosition); void StartAutoDragTimer(); @@ -132,31 +131,28 @@ class LegoInputManager : public MxPresenter { // LegoInputManager::`scalar deleting destructor' private: - MxCriticalSection m_criticalSection; // 0x58 - LegoNotifyList* m_keyboardNotifyList; // 0x5c - LegoCameraController* m_camera; // 0x60 - LegoWorld* m_world; // 0x64 - LegoEventQueue* m_eventQueue; // 0x68 - MxS32 m_x; // 0x6c - MxS32 m_y; // 0x70 - MxS32 m_unk0x74; // 0x74 - UINT m_autoDragTimerID; // 0x78 - UINT m_autoDragTime; // 0x7c - MxBool m_unk0x80; // 0x80 - MxBool m_unk0x81; // 0x81 - LegoControlManager* m_controlManager; // 0x84 - MxBool m_unk0x88; // 0x88 - IDirectInput* m_directInput; // 0x8c - IDirectInputDevice* m_directInputDevice; // 0x90 - MxBool m_kbStateSuccess; // 0x94 - MxU8 m_keyboardState[256]; // 0x95 - MxBool m_unk0x195; // 0x195 - MxS32 m_joyid; // 0x198 - MxS32 m_joystickIndex; // 0x19c - JOYCAPS m_joyCaps; // 0x200 - MxBool m_useJoystick; // 0x334 - MxBool m_unk0x335; // 0x335 - MxBool m_unk0x336; // 0x336 + MxCriticalSection m_criticalSection; // 0x58 + LegoNotifyList* m_keyboardNotifyList; // 0x5c + LegoCameraController* m_camera; // 0x60 + LegoWorld* m_world; // 0x64 + LegoEventQueue* m_eventQueue; // 0x68 + MxS32 m_x; // 0x6c + MxS32 m_y; // 0x70 + MxS32 m_unk0x74; // 0x74 + UINT m_autoDragTimerID; // 0x78 + UINT m_autoDragTime; // 0x7c + MxBool m_unk0x80; // 0x80 + MxBool m_unk0x81; // 0x81 + LegoControlManager* m_controlManager; // 0x84 + MxBool m_unk0x88; // 0x88 + const Uint8* m_keyboardState; + MxBool m_unk0x195; // 0x195 + MxS32 m_joyid; // 0x198 + MxS32 m_joystickIndex; // 0x19c + JOYCAPS m_joyCaps; // 0x200 + MxBool m_useJoystick; // 0x334 + MxBool m_unk0x335; // 0x335 + MxBool m_unk0x336; // 0x336 }; // TEMPLATE: LEGO1 0x10028850 diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index de3ae8b2..c5526864 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -38,9 +38,6 @@ LegoInputManager::LegoInputManager() m_controlManager = NULL; m_unk0x81 = FALSE; m_unk0x88 = FALSE; - m_directInput = NULL; - m_directInputDevice = NULL; - m_kbStateSuccess = FALSE; m_unk0x195 = 0; m_joyid = -1; m_joystickIndex = -1; @@ -79,10 +76,9 @@ MxResult LegoInputManager::Create(HWND p_hwnd) m_eventQueue = new LegoEventQueue; } - CreateAndAcquireKeyboard(p_hwnd); GetJoystickId(); - if (!m_keyboardNotifyList || !m_eventQueue || !m_directInputDevice) { + if (!m_keyboardNotifyList || !m_eventQueue) { Destroy(); result = FAILURE; } @@ -93,8 +89,6 @@ MxResult LegoInputManager::Create(HWND p_hwnd) // FUNCTION: LEGO1 0x1005bfe0 void LegoInputManager::Destroy() { - ReleaseDX(); - if (m_keyboardNotifyList) { delete m_keyboardNotifyList; } @@ -110,55 +104,10 @@ void LegoInputManager::Destroy() } } -// FUNCTION: LEGO1 0x1005c030 -void LegoInputManager::CreateAndAcquireKeyboard(HWND p_hwnd) -{ - HINSTANCE hinstance = (HINSTANCE) GetWindowLong(p_hwnd, GWL_HINSTANCE); - HRESULT hresult = DirectInputCreate(hinstance, 0x500, &m_directInput, NULL); // 0x500 for DX5 - - if (hresult == DI_OK) { - HRESULT createdeviceresult = m_directInput->CreateDevice(GUID_SysKeyboard, &m_directInputDevice, NULL); - if (createdeviceresult == DI_OK) { - m_directInputDevice->SetCooperativeLevel(p_hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND); - m_directInputDevice->SetDataFormat(&c_dfDIKeyboard); - m_directInputDevice->Acquire(); - } - } -} - -// FUNCTION: LEGO1 0x1005c0a0 -void LegoInputManager::ReleaseDX() -{ - if (m_directInputDevice != NULL) { - m_directInputDevice->Unacquire(); - m_directInputDevice->Release(); - m_directInputDevice = NULL; - } - - if (m_directInput != NULL) { - m_directInput->Release(); - m_directInput = NULL; - } -} - // FUNCTION: LEGO1 0x1005c0f0 void LegoInputManager::GetKeyboardState() { - m_kbStateSuccess = FALSE; - - if (m_directInputDevice) { - HRESULT hr = m_directInputDevice->GetDeviceState(sizeOfArray(m_keyboardState), &m_keyboardState); - - if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) { - if (m_directInputDevice->Acquire() == S_OK) { - hr = m_directInputDevice->GetDeviceState(sizeOfArray(m_keyboardState), &m_keyboardState); - } - } - - if (hr == S_OK) { - m_kbStateSuccess = TRUE; - } - } + m_keyboardState = SDL_GetKeyboardState(NULL); } // FUNCTION: LEGO1 0x1005c160 @@ -166,39 +115,29 @@ MxResult LegoInputManager::GetNavigationKeyStates(MxU32& p_keyFlags) { GetKeyboardState(); - if (!m_kbStateSuccess) { - return FAILURE; - } - if (g_unk0x100f67b8) { - if (m_keyboardState[DIK_LEFT] & 0x80 && GetAsyncKeyState(VK_LEFT) == 0) { - m_keyboardState[DIK_LEFT] = 0; - } - - if (m_keyboardState[DIK_RIGHT] & 0x80 && GetAsyncKeyState(VK_RIGHT) == 0) { - m_keyboardState[DIK_RIGHT] = 0; - } + // [library:input] Figure out if we still need the logic that was here. } MxU32 keyFlags = 0; - if ((m_keyboardState[DIK_NUMPAD8] | m_keyboardState[DIK_UP]) & 0x80) { + if (m_keyboardState[SDL_SCANCODE_KP_8] || m_keyboardState[SDL_SCANCODE_UP]) { keyFlags |= c_up; } - if ((m_keyboardState[DIK_NUMPAD2] | m_keyboardState[DIK_DOWN]) & 0x80) { + if ((m_keyboardState[SDL_SCANCODE_KP_2] || m_keyboardState[SDL_SCANCODE_DOWN])) { keyFlags |= c_down; } - if ((m_keyboardState[DIK_NUMPAD4] | m_keyboardState[DIK_LEFT]) & 0x80) { + if ((m_keyboardState[SDL_SCANCODE_KP_4] || m_keyboardState[SDL_SCANCODE_LEFT])) { keyFlags |= c_left; } - if ((m_keyboardState[DIK_NUMPAD6] | m_keyboardState[DIK_RIGHT]) & 0x80) { + if ((m_keyboardState[SDL_SCANCODE_KP_6] || m_keyboardState[SDL_SCANCODE_RIGHT])) { keyFlags |= c_right; } - if ((m_keyboardState[DIK_LCONTROL] | m_keyboardState[DIK_RCONTROL]) & 0x80) { + if (m_keyboardState[SDL_SCANCODE_LCTRL] || m_keyboardState[SDL_SCANCODE_RCTRL]) { keyFlags |= c_bit5; } diff --git a/LEGO1/omni/include/mxthread.h b/LEGO1/omni/include/mxthread.h index 64d47884..551f900e 100644 --- a/LEGO1/omni/include/mxthread.h +++ b/LEGO1/omni/include/mxthread.h @@ -36,8 +36,8 @@ class MxThread { static unsigned ThreadProc(void* p_thread); SDL_Thread* m_thread; - MxBool m_running; - MxSemaphore m_semaphore; + MxBool m_running; // 0x0c + MxSemaphore m_semaphore; // 0x10 protected: MxCore* m_target; // 0x18 diff --git a/LEGO1/omni/src/system/mxcriticalsection.cpp b/LEGO1/omni/src/system/mxcriticalsection.cpp index e78bcfcd..1e468fe7 100644 --- a/LEGO1/omni/src/system/mxcriticalsection.cpp +++ b/LEGO1/omni/src/system/mxcriticalsection.cpp @@ -1,12 +1,12 @@ #include "mxcriticalsection.h" #include "decomp.h" -#include "platform.h" +#include "mxtypes.h" DECOMP_SIZE_ASSERT(MxCriticalSection, 0x1c) // GLOBAL: LEGO1 0x10101e78 -BOOL g_useMutex = FALSE; +MxS32 g_useMutex = FALSE; // FUNCTION: LEGO1 0x100b6d20 MxCriticalSection::MxCriticalSection() diff --git a/util/platform.h b/util/platform.h deleted file mode 100644 index 8ea91871..00000000 --- a/util/platform.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef TYPES_H -#define TYPES_H - -// Defining substitutions for definitions usually found in Windows headers - -#define BOOL int32_t - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#endif // TYPES_H