mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-05-09 12:40:41 -04:00
Remove dependency on dinput, use SDL keyboard state for navigation (#14)
* WIP * Use SDL kb state for navigational keys * Remove linking against dinput
This commit is contained in:
parent
636996caf6
commit
880ae98f0b
8 changed files with 143 additions and 229 deletions
|
@ -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")
|
target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/LEGO1/lego/legoomni/include/actions")
|
||||||
|
|
||||||
# Link libraries
|
# 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)
|
foreach(tgt IN LISTS lego1_targets)
|
||||||
target_link_libraries(${tgt} PRIVATE $<$<BOOL:${ISLE_USE_DX5}>:DirectX5::DirectX5> SDL3::SDL3)
|
target_link_libraries(${tgt} PRIVATE $<$<BOOL:${ISLE_USE_DX5}>:DirectX5::DirectX5> SDL3::SDL3)
|
||||||
|
|
157
ISLE/isleapp.cpp
157
ISLE/isleapp.cpp
|
@ -33,7 +33,7 @@
|
||||||
#include <SDL3/SDL_init.h>
|
#include <SDL3/SDL_init.h>
|
||||||
#include <SDL3/SDL_main.h>
|
#include <SDL3/SDL_main.h>
|
||||||
#include <SDL3/SDL_messagebox.h>
|
#include <SDL3/SDL_messagebox.h>
|
||||||
#include <dsound.h>
|
#include <SDL3/SDL_timer.h>
|
||||||
#include <iniparser.h>
|
#include <iniparser.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
@ -43,34 +43,31 @@ DECOMP_SIZE_ASSERT(IsleApp, 0x8c)
|
||||||
IsleApp* g_isle = NULL;
|
IsleApp* g_isle = NULL;
|
||||||
|
|
||||||
// GLOBAL: ISLE 0x410034
|
// GLOBAL: ISLE 0x410034
|
||||||
unsigned char g_mousedown = FALSE;
|
MxU8 g_mousedown = FALSE;
|
||||||
|
|
||||||
// GLOBAL: ISLE 0x410038
|
// GLOBAL: ISLE 0x410038
|
||||||
unsigned char g_mousemoved = FALSE;
|
MxU8 g_mousemoved = FALSE;
|
||||||
|
|
||||||
// GLOBAL: ISLE 0x41003c
|
// GLOBAL: ISLE 0x41003c
|
||||||
BOOL g_closed = FALSE;
|
MxS32 g_closed = FALSE;
|
||||||
|
|
||||||
// GLOBAL: ISLE 0x410040
|
|
||||||
RECT g_windowRect = {0, 0, 640, 480};
|
|
||||||
|
|
||||||
// GLOBAL: ISLE 0x410050
|
// GLOBAL: ISLE 0x410050
|
||||||
BOOL g_rmDisabled = FALSE;
|
MxS32 g_rmDisabled = FALSE;
|
||||||
|
|
||||||
// GLOBAL: ISLE 0x410054
|
// GLOBAL: ISLE 0x410054
|
||||||
BOOL g_waitingForTargetDepth = TRUE;
|
MxS32 g_waitingForTargetDepth = TRUE;
|
||||||
|
|
||||||
// GLOBAL: ISLE 0x410058
|
// GLOBAL: ISLE 0x410058
|
||||||
int g_targetWidth = 640;
|
MxS32 g_targetWidth = 640;
|
||||||
|
|
||||||
// GLOBAL: ISLE 0x41005c
|
// GLOBAL: ISLE 0x41005c
|
||||||
int g_targetHeight = 480;
|
MxS32 g_targetHeight = 480;
|
||||||
|
|
||||||
// GLOBAL: ISLE 0x410060
|
// GLOBAL: ISLE 0x410060
|
||||||
int g_targetDepth = 16;
|
MxS32 g_targetDepth = 16;
|
||||||
|
|
||||||
// GLOBAL: ISLE 0x410064
|
// GLOBAL: ISLE 0x410064
|
||||||
BOOL g_reqEnableRMDevice = FALSE;
|
MxS32 g_reqEnableRMDevice = FALSE;
|
||||||
|
|
||||||
// STRING: ISLE 0x4101dc
|
// STRING: ISLE 0x4101dc
|
||||||
#define WINDOW_TITLE "LEGO®"
|
#define WINDOW_TITLE "LEGO®"
|
||||||
|
@ -154,7 +151,7 @@ void IsleApp::Close()
|
||||||
if (Lego()) {
|
if (Lego()) {
|
||||||
GameState()->Save(0);
|
GameState()->Save(0);
|
||||||
if (InputManager()) {
|
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);
|
VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->RemoveAll(NULL);
|
||||||
|
@ -181,9 +178,9 @@ void IsleApp::Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: ISLE 0x4013b0
|
// FUNCTION: ISLE 0x4013b0
|
||||||
BOOL IsleApp::SetupLegoOmni()
|
MxS32 IsleApp::SetupLegoOmni()
|
||||||
{
|
{
|
||||||
BOOL result = FALSE;
|
MxS32 result = FALSE;
|
||||||
char mediaPath[256];
|
char mediaPath[256];
|
||||||
GetProfileStringA("LEGO Island", "MediaPath", "", mediaPath, sizeof(mediaPath));
|
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);
|
(HWND) SDL_GetProperty(SDL_GetWindowProperties(m_windowHandle), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||||
|
|
||||||
#ifdef COMPAT_MODE
|
#ifdef COMPAT_MODE
|
||||||
BOOL failure;
|
MxS32 failure;
|
||||||
{
|
{
|
||||||
MxOmniCreateParam param(mediaPath, (struct HWND__*) hwnd, m_videoParam, MxOmniCreateFlags());
|
MxOmniCreateParam param(mediaPath, (struct HWND__*) hwnd, m_videoParam, MxOmniCreateFlags());
|
||||||
failure = Lego()->Create(param) == FAILURE;
|
failure = Lego()->Create(param) == FAILURE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
BOOL failure = Lego()->Create(MxOmniCreateParam(mediaPath, (struct HWND__*) hwnd, m_videoParam, MxOmniCreateFlags())
|
MxS32 failure =
|
||||||
) == FAILURE;
|
Lego()->Create(MxOmniCreateParam(mediaPath, (struct HWND__*) hwnd, m_videoParam, MxOmniCreateFlags())) ==
|
||||||
|
FAILURE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!failure) {
|
if (!failure) {
|
||||||
|
@ -213,14 +211,14 @@ BOOL IsleApp::SetupLegoOmni()
|
||||||
|
|
||||||
// FUNCTION: ISLE 0x401560
|
// FUNCTION: ISLE 0x401560
|
||||||
void IsleApp::SetupVideoFlags(
|
void IsleApp::SetupVideoFlags(
|
||||||
BOOL fullScreen,
|
MxS32 fullScreen,
|
||||||
BOOL flipSurfaces,
|
MxS32 flipSurfaces,
|
||||||
BOOL backBuffers,
|
MxS32 backBuffers,
|
||||||
BOOL using8bit,
|
MxS32 using8bit,
|
||||||
BOOL using16bit,
|
MxS32 using16bit,
|
||||||
BOOL param_6,
|
MxS32 param_6,
|
||||||
BOOL param_7,
|
MxS32 param_7,
|
||||||
BOOL wideViewAngle,
|
MxS32 wideViewAngle,
|
||||||
char* deviceId
|
char* deviceId
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -284,7 +282,7 @@ int SDL_AppIterate(void* appstate)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_isle->Tick(0);
|
g_isle->Tick();
|
||||||
|
|
||||||
if (!g_closed) {
|
if (!g_closed) {
|
||||||
if (g_reqEnableRMDevice) {
|
if (g_reqEnableRMDevice) {
|
||||||
|
@ -299,7 +297,7 @@ int SDL_AppIterate(void* appstate)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_mousedown && g_mousemoved && g_isle) {
|
if (g_mousedown && g_mousemoved && g_isle) {
|
||||||
g_isle->Tick(0);
|
g_isle->Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_mousemoved) {
|
if (g_mousemoved) {
|
||||||
|
@ -316,7 +314,8 @@ int SDL_AppEvent(void* appstate, const SDL_Event* event)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [library:window] Remaining functionality to be implemented:
|
// [library:window]
|
||||||
|
// Remaining functionality to be implemented:
|
||||||
// Full screen - crashes when minimizing/maximizing
|
// Full screen - crashes when minimizing/maximizing
|
||||||
// WM_TIMER - use SDL_Timer functionality instead
|
// WM_TIMER - use SDL_Timer functionality instead
|
||||||
// WM_SETCURSOR - update cursor
|
// WM_SETCURSOR - update cursor
|
||||||
|
@ -361,7 +360,7 @@ int SDL_AppEvent(void* appstate, const SDL_Event* event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_isle->GetDrawCursor()) {
|
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;
|
break;
|
||||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||||
|
@ -442,10 +441,10 @@ MxResult IsleApp::SetupWindow()
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
if (m_fullScreen) {
|
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 {
|
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) {
|
if (!m_windowHandle) {
|
||||||
|
@ -460,7 +459,7 @@ MxResult IsleApp::SetupWindow()
|
||||||
GameState()->SerializePlayersInfo(1);
|
GameState()->SerializePlayersInfo(1);
|
||||||
GameState()->SerializeScoreHistory(1);
|
GameState()->SerializeScoreHistory(1);
|
||||||
|
|
||||||
int iVar10;
|
MxS32 iVar10;
|
||||||
switch (m_islandQuality) {
|
switch (m_islandQuality) {
|
||||||
case 0:
|
case 0:
|
||||||
iVar10 = 1;
|
iVar10 = 1;
|
||||||
|
@ -472,7 +471,7 @@ MxResult IsleApp::SetupWindow()
|
||||||
iVar10 = 100;
|
iVar10 = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
int uVar1 = (m_islandTexture == 0);
|
MxS32 uVar1 = (m_islandTexture == 0);
|
||||||
LegoModelPresenter::configureLegoModelPresenter(uVar1);
|
LegoModelPresenter::configureLegoModelPresenter(uVar1);
|
||||||
LegoPartPresenter::configureLegoPartPresenter(uVar1, iVar10);
|
LegoPartPresenter::configureLegoPartPresenter(uVar1, iVar10);
|
||||||
LegoWorldPresenter::configureLegoWorldPresenter(m_islandQuality);
|
LegoWorldPresenter::configureLegoWorldPresenter(m_islandQuality);
|
||||||
|
@ -518,12 +517,12 @@ void IsleApp::LoadConfig()
|
||||||
m_joystickIndex = iniparser_getint(dict, "isle:JoystickIndex", m_joystickIndex);
|
m_joystickIndex = iniparser_getint(dict, "isle:JoystickIndex", m_joystickIndex);
|
||||||
m_drawCursor = iniparser_getboolean(dict, "isle:Draw Cursor", m_drawCursor);
|
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) {
|
if (backBuffersInVRAM != -1) {
|
||||||
m_backBuffersInVram = !backBuffersInVRAM;
|
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 != -1) {
|
||||||
if (bitDepth == 8) {
|
if (bitDepth == 8) {
|
||||||
m_using8bit = TRUE;
|
m_using8bit = TRUE;
|
||||||
|
@ -556,16 +555,16 @@ void IsleApp::LoadConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: ISLE 0x402c20
|
// FUNCTION: ISLE 0x402c20
|
||||||
inline void IsleApp::Tick(BOOL sleepIfNotNextFrame)
|
inline void IsleApp::Tick()
|
||||||
{
|
{
|
||||||
// GLOBAL: ISLE 0x4101c0
|
// GLOBAL: ISLE 0x4101c0
|
||||||
static MxLong g_lastFrameTime = 0;
|
static MxLong g_lastFrameTime = 0;
|
||||||
|
|
||||||
// GLOBAL: ISLE 0x4101bc
|
// GLOBAL: ISLE 0x4101bc
|
||||||
static int g_startupDelay = 200;
|
static MxS32 g_startupDelay = 200;
|
||||||
|
|
||||||
if (!m_windowActive) {
|
if (!m_windowActive) {
|
||||||
Sleep(0);
|
SDL_Delay(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,54 +583,54 @@ inline void IsleApp::Tick(BOOL sleepIfNotNextFrame)
|
||||||
g_lastFrameTime = -m_frameDelta;
|
g_lastFrameTime = -m_frameDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_frameDelta + g_lastFrameTime < currentTime) {
|
if (m_frameDelta + g_lastFrameTime >= currentTime) {
|
||||||
if (!Lego()->IsTimerRunning()) {
|
SDL_Delay(1);
|
||||||
TickleManager()->Tickle();
|
return;
|
||||||
}
|
}
|
||||||
g_lastFrameTime = currentTime;
|
|
||||||
|
|
||||||
if (g_startupDelay == 0) {
|
if (!Lego()->IsTimerRunning()) {
|
||||||
return;
|
TickleManager()->Tickle();
|
||||||
}
|
}
|
||||||
|
g_lastFrameTime = currentTime;
|
||||||
|
|
||||||
g_startupDelay--;
|
if (g_startupDelay == 0) {
|
||||||
if (g_startupDelay != 0) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
LegoOmni::GetInstance()->CreateBackgroundAudio();
|
g_startupDelay--;
|
||||||
BackgroundAudioManager()->Enable(this->m_useMusic);
|
if (g_startupDelay != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
MxStreamController* stream = Streamer()->Open("\\lego\\scripts\\isle\\isle", MxStreamer::e_diskStream);
|
LegoOmni::GetInstance()->CreateBackgroundAudio();
|
||||||
MxDSAction ds;
|
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) {
|
if (!stream) {
|
||||||
stream = Streamer()->Open("\\lego\\scripts\\nocd", MxStreamer::e_diskStream);
|
return;
|
||||||
if (!stream) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ds.SetAtomId(stream->GetAtom());
|
|
||||||
ds.SetUnknown24(-1);
|
|
||||||
ds.SetObjectId(0);
|
|
||||||
VideoManager()->EnableFullScreenMovie(TRUE, TRUE);
|
|
||||||
|
|
||||||
if (Start(&ds) != SUCCESS) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
ds.SetAtomId(stream->GetAtom());
|
ds.SetAtomId(stream->GetAtom());
|
||||||
ds.SetUnknown24(-1);
|
ds.SetUnknown24(-1);
|
||||||
ds.SetObjectId(0);
|
ds.SetObjectId(0);
|
||||||
if (Start(&ds) != SUCCESS) {
|
VideoManager()->EnableFullScreenMovie(TRUE, TRUE);
|
||||||
return;
|
|
||||||
}
|
if (Start(&ds) != SUCCESS) {
|
||||||
m_gameStarted = TRUE;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (sleepIfNotNextFrame != 0) {
|
else {
|
||||||
Sleep(0);
|
ds.SetAtomId(stream->GetAtom());
|
||||||
|
ds.SetUnknown24(-1);
|
||||||
|
ds.SetObjectId(0);
|
||||||
|
if (Start(&ds) != SUCCESS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_gameStarted = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,60 +16,60 @@ public:
|
||||||
|
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
BOOL SetupLegoOmni();
|
MxS32 SetupLegoOmni();
|
||||||
void SetupVideoFlags(
|
void SetupVideoFlags(
|
||||||
BOOL fullScreen,
|
MxS32 fullScreen,
|
||||||
BOOL flipSurfaces,
|
MxS32 flipSurfaces,
|
||||||
BOOL backBuffers,
|
MxS32 backBuffers,
|
||||||
BOOL using8bit,
|
MxS32 using8bit,
|
||||||
BOOL using16bit,
|
MxS32 using16bit,
|
||||||
BOOL param_6,
|
MxS32 param_6,
|
||||||
BOOL param_7,
|
MxS32 param_7,
|
||||||
BOOL wideViewAngle,
|
MxS32 wideViewAngle,
|
||||||
char* deviceId
|
char* deviceId
|
||||||
);
|
);
|
||||||
MxResult SetupWindow();
|
MxResult SetupWindow();
|
||||||
|
|
||||||
void LoadConfig();
|
void LoadConfig();
|
||||||
void Tick(BOOL sleepIfNotNextFrame);
|
void Tick();
|
||||||
void SetupCursor(WPARAM wParam);
|
void SetupCursor(WPARAM wParam);
|
||||||
|
|
||||||
static MxU8 MapMouseButtonFlagsToModifier(SDL_MouseButtonFlags p_flags);
|
static MxU8 MapMouseButtonFlagsToModifier(SDL_MouseButtonFlags p_flags);
|
||||||
|
|
||||||
inline SDL_Window* GetWindowHandle() { return m_windowHandle; }
|
inline SDL_Window* GetWindowHandle() { return m_windowHandle; }
|
||||||
inline MxLong GetFrameDelta() { return m_frameDelta; }
|
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 GetCursorCurrent() { return m_cursorCurrent; }
|
||||||
inline HCURSOR GetCursorBusy() { return m_cursorBusy; }
|
inline HCURSOR GetCursorBusy() { return m_cursorBusy; }
|
||||||
inline HCURSOR GetCursorNo() { return m_cursorNo; }
|
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:
|
private:
|
||||||
char* m_hdPath; // 0x00
|
char* m_hdPath; // 0x00
|
||||||
char* m_cdPath; // 0x04
|
char* m_cdPath; // 0x04
|
||||||
char* m_deviceId; // 0x08
|
char* m_deviceId; // 0x08
|
||||||
char* m_savePath; // 0x0c
|
char* m_savePath; // 0x0c
|
||||||
BOOL m_fullScreen; // 0x10
|
MxS32 m_fullScreen; // 0x10
|
||||||
BOOL m_flipSurfaces; // 0x14
|
MxS32 m_flipSurfaces; // 0x14
|
||||||
BOOL m_backBuffersInVram; // 0x18
|
MxS32 m_backBuffersInVram; // 0x18
|
||||||
BOOL m_using8bit; // 0x1c
|
MxS32 m_using8bit; // 0x1c
|
||||||
BOOL m_using16bit; // 0x20
|
MxS32 m_using16bit; // 0x20
|
||||||
int m_unk0x24; // 0x24
|
MxS32 m_unk0x24; // 0x24
|
||||||
BOOL m_use3dSound; // 0x28
|
MxS32 m_use3dSound; // 0x28
|
||||||
BOOL m_useMusic; // 0x2c
|
MxS32 m_useMusic; // 0x2c
|
||||||
BOOL m_useJoystick; // 0x30
|
MxS32 m_useJoystick; // 0x30
|
||||||
int m_joystickIndex; // 0x34
|
MxS32 m_joystickIndex; // 0x34
|
||||||
BOOL m_wideViewAngle; // 0x38
|
MxS32 m_wideViewAngle; // 0x38
|
||||||
int m_islandQuality; // 0x3c
|
MxS32 m_islandQuality; // 0x3c
|
||||||
int m_islandTexture; // 0x40
|
MxS32 m_islandTexture; // 0x40
|
||||||
BOOL m_gameStarted; // 0x44
|
MxS32 m_gameStarted; // 0x44
|
||||||
MxLong m_frameDelta; // 0x48
|
MxLong m_frameDelta; // 0x48
|
||||||
MxVideoParam m_videoParam; // 0x4c
|
MxVideoParam m_videoParam; // 0x4c
|
||||||
BOOL m_windowActive; // 0x70
|
MxS32 m_windowActive; // 0x70
|
||||||
SDL_Window* m_windowHandle; // 0x74
|
SDL_Window* m_windowHandle; // 0x74
|
||||||
BOOL m_drawCursor; // 0x78
|
MxS32 m_drawCursor; // 0x78
|
||||||
HCURSOR m_cursorArrow; // 0x7c
|
HCURSOR m_cursorArrow; // 0x7c
|
||||||
HCURSOR m_cursorBusy; // 0x80
|
HCURSOR m_cursorBusy; // 0x80
|
||||||
HCURSOR m_cursorNo; // 0x84
|
HCURSOR m_cursorNo; // 0x84
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "mxpresenter.h"
|
#include "mxpresenter.h"
|
||||||
#include "mxqueue.h"
|
#include "mxqueue.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL_keyboard.h>
|
||||||
#include <dinput.h>
|
#include <dinput.h>
|
||||||
|
|
||||||
class LegoCameraController;
|
class LegoCameraController;
|
||||||
|
@ -94,8 +95,6 @@ public:
|
||||||
|
|
||||||
MxResult Create(HWND p_hwnd);
|
MxResult Create(HWND p_hwnd);
|
||||||
void Destroy() override;
|
void Destroy() override;
|
||||||
void CreateAndAcquireKeyboard(HWND p_hwnd);
|
|
||||||
void ReleaseDX();
|
|
||||||
MxResult GetJoystickId();
|
MxResult GetJoystickId();
|
||||||
MxResult GetJoystickState(MxU32* p_joystickX, MxU32* p_joystickY, DWORD* p_buttonsState, MxU32* p_povPosition);
|
MxResult GetJoystickState(MxU32* p_joystickX, MxU32* p_joystickY, DWORD* p_buttonsState, MxU32* p_povPosition);
|
||||||
void StartAutoDragTimer();
|
void StartAutoDragTimer();
|
||||||
|
@ -132,31 +131,28 @@ public:
|
||||||
// LegoInputManager::`scalar deleting destructor'
|
// LegoInputManager::`scalar deleting destructor'
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MxCriticalSection m_criticalSection; // 0x58
|
MxCriticalSection m_criticalSection; // 0x58
|
||||||
LegoNotifyList* m_keyboardNotifyList; // 0x5c
|
LegoNotifyList* m_keyboardNotifyList; // 0x5c
|
||||||
LegoCameraController* m_camera; // 0x60
|
LegoCameraController* m_camera; // 0x60
|
||||||
LegoWorld* m_world; // 0x64
|
LegoWorld* m_world; // 0x64
|
||||||
LegoEventQueue* m_eventQueue; // 0x68
|
LegoEventQueue* m_eventQueue; // 0x68
|
||||||
MxS32 m_x; // 0x6c
|
MxS32 m_x; // 0x6c
|
||||||
MxS32 m_y; // 0x70
|
MxS32 m_y; // 0x70
|
||||||
MxS32 m_unk0x74; // 0x74
|
MxS32 m_unk0x74; // 0x74
|
||||||
UINT m_autoDragTimerID; // 0x78
|
UINT m_autoDragTimerID; // 0x78
|
||||||
UINT m_autoDragTime; // 0x7c
|
UINT m_autoDragTime; // 0x7c
|
||||||
MxBool m_unk0x80; // 0x80
|
MxBool m_unk0x80; // 0x80
|
||||||
MxBool m_unk0x81; // 0x81
|
MxBool m_unk0x81; // 0x81
|
||||||
LegoControlManager* m_controlManager; // 0x84
|
LegoControlManager* m_controlManager; // 0x84
|
||||||
MxBool m_unk0x88; // 0x88
|
MxBool m_unk0x88; // 0x88
|
||||||
IDirectInput* m_directInput; // 0x8c
|
const Uint8* m_keyboardState;
|
||||||
IDirectInputDevice* m_directInputDevice; // 0x90
|
MxBool m_unk0x195; // 0x195
|
||||||
MxBool m_kbStateSuccess; // 0x94
|
MxS32 m_joyid; // 0x198
|
||||||
MxU8 m_keyboardState[256]; // 0x95
|
MxS32 m_joystickIndex; // 0x19c
|
||||||
MxBool m_unk0x195; // 0x195
|
JOYCAPS m_joyCaps; // 0x200
|
||||||
MxS32 m_joyid; // 0x198
|
MxBool m_useJoystick; // 0x334
|
||||||
MxS32 m_joystickIndex; // 0x19c
|
MxBool m_unk0x335; // 0x335
|
||||||
JOYCAPS m_joyCaps; // 0x200
|
MxBool m_unk0x336; // 0x336
|
||||||
MxBool m_useJoystick; // 0x334
|
|
||||||
MxBool m_unk0x335; // 0x335
|
|
||||||
MxBool m_unk0x336; // 0x336
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// TEMPLATE: LEGO1 0x10028850
|
// TEMPLATE: LEGO1 0x10028850
|
||||||
|
|
|
@ -38,9 +38,6 @@ LegoInputManager::LegoInputManager()
|
||||||
m_controlManager = NULL;
|
m_controlManager = NULL;
|
||||||
m_unk0x81 = FALSE;
|
m_unk0x81 = FALSE;
|
||||||
m_unk0x88 = FALSE;
|
m_unk0x88 = FALSE;
|
||||||
m_directInput = NULL;
|
|
||||||
m_directInputDevice = NULL;
|
|
||||||
m_kbStateSuccess = FALSE;
|
|
||||||
m_unk0x195 = 0;
|
m_unk0x195 = 0;
|
||||||
m_joyid = -1;
|
m_joyid = -1;
|
||||||
m_joystickIndex = -1;
|
m_joystickIndex = -1;
|
||||||
|
@ -79,10 +76,9 @@ MxResult LegoInputManager::Create(HWND p_hwnd)
|
||||||
m_eventQueue = new LegoEventQueue;
|
m_eventQueue = new LegoEventQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateAndAcquireKeyboard(p_hwnd);
|
|
||||||
GetJoystickId();
|
GetJoystickId();
|
||||||
|
|
||||||
if (!m_keyboardNotifyList || !m_eventQueue || !m_directInputDevice) {
|
if (!m_keyboardNotifyList || !m_eventQueue) {
|
||||||
Destroy();
|
Destroy();
|
||||||
result = FAILURE;
|
result = FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -93,8 +89,6 @@ MxResult LegoInputManager::Create(HWND p_hwnd)
|
||||||
// FUNCTION: LEGO1 0x1005bfe0
|
// FUNCTION: LEGO1 0x1005bfe0
|
||||||
void LegoInputManager::Destroy()
|
void LegoInputManager::Destroy()
|
||||||
{
|
{
|
||||||
ReleaseDX();
|
|
||||||
|
|
||||||
if (m_keyboardNotifyList) {
|
if (m_keyboardNotifyList) {
|
||||||
delete 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
|
// FUNCTION: LEGO1 0x1005c0f0
|
||||||
void LegoInputManager::GetKeyboardState()
|
void LegoInputManager::GetKeyboardState()
|
||||||
{
|
{
|
||||||
m_kbStateSuccess = FALSE;
|
m_keyboardState = SDL_GetKeyboardState(NULL);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1005c160
|
// FUNCTION: LEGO1 0x1005c160
|
||||||
|
@ -166,39 +115,29 @@ MxResult LegoInputManager::GetNavigationKeyStates(MxU32& p_keyFlags)
|
||||||
{
|
{
|
||||||
GetKeyboardState();
|
GetKeyboardState();
|
||||||
|
|
||||||
if (!m_kbStateSuccess) {
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_unk0x100f67b8) {
|
if (g_unk0x100f67b8) {
|
||||||
if (m_keyboardState[DIK_LEFT] & 0x80 && GetAsyncKeyState(VK_LEFT) == 0) {
|
// [library:input] Figure out if we still need the logic that was here.
|
||||||
m_keyboardState[DIK_LEFT] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_keyboardState[DIK_RIGHT] & 0x80 && GetAsyncKeyState(VK_RIGHT) == 0) {
|
|
||||||
m_keyboardState[DIK_RIGHT] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MxU32 keyFlags = 0;
|
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;
|
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;
|
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;
|
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;
|
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;
|
keyFlags |= c_bit5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ private:
|
||||||
static unsigned ThreadProc(void* p_thread);
|
static unsigned ThreadProc(void* p_thread);
|
||||||
|
|
||||||
SDL_Thread* m_thread;
|
SDL_Thread* m_thread;
|
||||||
MxBool m_running;
|
MxBool m_running; // 0x0c
|
||||||
MxSemaphore m_semaphore;
|
MxSemaphore m_semaphore; // 0x10
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MxCore* m_target; // 0x18
|
MxCore* m_target; // 0x18
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#include "mxcriticalsection.h"
|
#include "mxcriticalsection.h"
|
||||||
|
|
||||||
#include "decomp.h"
|
#include "decomp.h"
|
||||||
#include "platform.h"
|
#include "mxtypes.h"
|
||||||
|
|
||||||
DECOMP_SIZE_ASSERT(MxCriticalSection, 0x1c)
|
DECOMP_SIZE_ASSERT(MxCriticalSection, 0x1c)
|
||||||
|
|
||||||
// GLOBAL: LEGO1 0x10101e78
|
// GLOBAL: LEGO1 0x10101e78
|
||||||
BOOL g_useMutex = FALSE;
|
MxS32 g_useMutex = FALSE;
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100b6d20
|
// FUNCTION: LEGO1 0x100b6d20
|
||||||
MxCriticalSection::MxCriticalSection()
|
MxCriticalSection::MxCriticalSection()
|
||||||
|
|
|
@ -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
|
|
Loading…
Add table
Add a link
Reference in a new issue