mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-20 06:01:16 +00:00
More use of SDL (#47)
* Use SDL_GetPerformance(Counter|Frequency) in MxStopWatch * Fix flic.h for gcc Linux compiler * cmake: remove left-over message * Replace some more stricmp with SDL_strcasecmp * Pass SDL_Window* to LEGO1.DLL, and pass window events through SDL event handler * clang-format * Use SDL_Timer for unknown input dragging events * Fix naming --------- Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
parent
d3cdec8b5d
commit
65adfe7d64
@ -433,7 +433,6 @@ endif()
|
|||||||
set(lego1_objects)
|
set(lego1_objects)
|
||||||
set(lego1_link_libraries dxguid d3drm_guid)
|
set(lego1_link_libraries dxguid d3drm_guid)
|
||||||
foreach(lego1_library IN LISTS lego1_targets)
|
foreach(lego1_library IN LISTS lego1_targets)
|
||||||
message("lego1_library:${lego1_library}")
|
|
||||||
target_compile_definitions(${lego1_library}-objects PRIVATE LEGO1_DLL)
|
target_compile_definitions(${lego1_library}-objects PRIVATE LEGO1_DLL)
|
||||||
list(APPEND lego1_objects $<TARGET_OBJECTS:${lego1_library}-objects>)
|
list(APPEND lego1_objects $<TARGET_OBJECTS:${lego1_library}-objects>)
|
||||||
list(APPEND lego1_link_libraries ${lego1_library}-interface)
|
list(APPEND lego1_link_libraries ${lego1_library}-interface)
|
||||||
|
|||||||
@ -178,18 +178,15 @@ MxS32 IsleApp::SetupLegoOmni()
|
|||||||
char mediaPath[256];
|
char mediaPath[256];
|
||||||
GetProfileStringA("LEGO Island", "MediaPath", "", mediaPath, sizeof(mediaPath));
|
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
|
#ifdef COMPAT_MODE
|
||||||
MxS32 failure;
|
MxS32 failure;
|
||||||
{
|
{
|
||||||
MxOmniCreateParam param(mediaPath, hwnd, m_videoParam, MxOmniCreateFlags());
|
MxOmniCreateParam param(mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags());
|
||||||
failure = Lego()->Create(param) == FAILURE;
|
failure = Lego()->Create(param) == FAILURE;
|
||||||
}
|
}
|
||||||
#else
|
#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
|
#endif
|
||||||
|
|
||||||
if (!failure) {
|
if (!failure) {
|
||||||
@ -392,12 +389,22 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: use g_userEvent instead of SDL_EVENT_USER
|
if (event->user.type == g_legoSdlEvents.m_windowsMessage) {
|
||||||
if (event->type >= SDL_EVENT_USER && event->type <= SDL_EVENT_LAST - 1) {
|
|
||||||
switch (event->user.code) {
|
switch (event->user.code) {
|
||||||
case WM_ISLE_SETCURSOR:
|
case WM_ISLE_SETCURSOR:
|
||||||
g_isle->SetupCursor((Cursor) (uintptr_t) event->user.data1);
|
g_isle->SetupCursor((Cursor) (uintptr_t) event->user.data1);
|
||||||
break;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <SDL3/SDL_joystick.h>
|
#include <SDL3/SDL_joystick.h>
|
||||||
#include <SDL3/SDL_keyboard.h>
|
#include <SDL3/SDL_keyboard.h>
|
||||||
|
#include <SDL3/SDL_timer.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
class LegoCameraController;
|
class LegoCameraController;
|
||||||
@ -145,7 +146,7 @@ class LegoInputManager : public MxPresenter {
|
|||||||
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
|
SDL_TimerID 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
|
||||||
|
|||||||
@ -3,9 +3,12 @@
|
|||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "lego1_export.h"
|
#include "lego1_export.h"
|
||||||
|
#include "legoutils.h"
|
||||||
#include "mxdsaction.h"
|
#include "mxdsaction.h"
|
||||||
#include "mxomni.h"
|
#include "mxomni.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL_events.h>
|
||||||
|
|
||||||
class Isle;
|
class Isle;
|
||||||
class LegoAnimationManager;
|
class LegoAnimationManager;
|
||||||
class LegoBuildingManager;
|
class LegoBuildingManager;
|
||||||
@ -185,7 +188,15 @@ class LegoOmni : public MxOmni {
|
|||||||
MxResult StartActionIfUnknown0x13c(MxDSAction& p_dsAction) { return m_unk0x13c ? Start(&p_dsAction) : SUCCESS; }
|
MxResult StartActionIfUnknown0x13c(MxDSAction& p_dsAction) { return m_unk0x13c ? Start(&p_dsAction) : SUCCESS; }
|
||||||
void SetUnknown13c(MxBool p_unk0x13c) { m_unk0x13c = p_unk0x13c; }
|
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
|
// SYNTHETIC: LEGO1 0x10058b30
|
||||||
// LegoOmni::`scalar deleting destructor'
|
// LegoOmni::`scalar deleting destructor'
|
||||||
|
|||||||
@ -4,8 +4,10 @@
|
|||||||
#include "actionsfwd.h"
|
#include "actionsfwd.h"
|
||||||
#include "decomp.h"
|
#include "decomp.h"
|
||||||
#include "extra.h"
|
#include "extra.h"
|
||||||
|
#include "lego1_export.h"
|
||||||
#include "mxtypes.h"
|
#include "mxtypes.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL_stdinc.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#define WM_ISLE_SETCURSOR 0x5400
|
#define WM_ISLE_SETCURSOR 0x5400
|
||||||
@ -13,6 +15,12 @@
|
|||||||
// name verified by BETA10 0x100d4054
|
// name verified by BETA10 0x100d4054
|
||||||
#define DS_NOT_A_STREAM -1
|
#define DS_NOT_A_STREAM -1
|
||||||
|
|
||||||
|
struct LegoSdlEvents {
|
||||||
|
Uint32 m_windowsMessage;
|
||||||
|
};
|
||||||
|
|
||||||
|
LEGO1_EXPORT extern LegoSdlEvents g_legoSdlEvents;
|
||||||
|
|
||||||
enum Cursor {
|
enum Cursor {
|
||||||
e_cursorArrow = 0,
|
e_cursorArrow = 0,
|
||||||
e_cursorBusy,
|
e_cursorBusy,
|
||||||
@ -58,6 +66,7 @@ void PlayCamAnim(LegoPathActor* p_actor, MxBool p_unused, MxU32 p_location, MxBo
|
|||||||
void FUN_1003eda0();
|
void FUN_1003eda0();
|
||||||
MxBool RemoveFromCurrentWorld(const MxAtomId& p_atomId, MxS32 p_id);
|
MxBool RemoveFromCurrentWorld(const MxAtomId& p_atomId, MxS32 p_id);
|
||||||
void EnableAnimations(MxBool p_enable);
|
void EnableAnimations(MxBool p_enable);
|
||||||
|
void InitSdlEvents();
|
||||||
void SetAppCursor(Cursor p_cursor);
|
void SetAppCursor(Cursor p_cursor);
|
||||||
MxBool FUN_1003ef60();
|
MxBool FUN_1003ef60();
|
||||||
MxBool RemoveFromWorld(MxAtomId& p_entityAtom, MxS32 p_entityId, MxAtomId& p_worldAtom, MxS32 p_worldEntityId);
|
MxBool RemoveFromWorld(MxAtomId& p_entityAtom, MxS32 p_entityId, MxAtomId& p_worldAtom, MxS32 p_worldEntityId);
|
||||||
|
|||||||
@ -103,7 +103,7 @@ inline void LegoCarBuildAnimPresenter::Beta10Inline0x100733d0()
|
|||||||
if (roi) {
|
if (roi) {
|
||||||
const LegoChar* name = roi->GetName();
|
const LegoChar* name = roi->GetName();
|
||||||
|
|
||||||
if (name && stricmp(wiredName, name) == 0) {
|
if (name && SDL_strcasecmp(wiredName, name) == 0) {
|
||||||
if (bvar5) {
|
if (bvar5) {
|
||||||
roi->SetVisibility(TRUE);
|
roi->SetVisibility(TRUE);
|
||||||
}
|
}
|
||||||
@ -310,7 +310,7 @@ void LegoCarBuildAnimPresenter::SwapNodesByName(LegoChar* p_name1, LegoChar* p_n
|
|||||||
{
|
{
|
||||||
char buffer[40];
|
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* node1 = FindNodeDataByName(m_anim->GetRoot(), p_name1);
|
||||||
LegoAnimNodeData* node2 = FindNodeDataByName(m_anim->GetRoot(), p_name2);
|
LegoAnimNodeData* node2 = FindNodeDataByName(m_anim->GetRoot(), p_name2);
|
||||||
|
|
||||||
@ -468,7 +468,7 @@ LegoAnimNodeData* LegoCarBuildAnimPresenter::FindNodeDataByName(LegoTreeNode* p_
|
|||||||
if (p_treeNode) {
|
if (p_treeNode) {
|
||||||
data = (LegoAnimNodeData*) p_treeNode->GetData();
|
data = (LegoAnimNodeData*) p_treeNode->GetData();
|
||||||
|
|
||||||
if (stricmp(data->GetName(), p_name) == 0) {
|
if (SDL_strcasecmp(data->GetName(), p_name) == 0) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,7 +494,7 @@ LegoTreeNode* LegoCarBuildAnimPresenter::FindNodeByName(LegoTreeNode* p_treeNode
|
|||||||
if (p_treeNode) {
|
if (p_treeNode) {
|
||||||
data = (LegoAnimNodeData*) p_treeNode->GetData();
|
data = (LegoAnimNodeData*) p_treeNode->GetData();
|
||||||
|
|
||||||
if (stricmp(data->GetName(), p_name) == 0) {
|
if (SDL_strcasecmp(data->GetName(), p_name) == 0) {
|
||||||
return p_treeNode;
|
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) {
|
if (SDL_strcasecmp(m_parts[m_placedPartCount].m_name, p_name) != 0) {
|
||||||
for (i = m_placedPartCount + 1; i < m_numberOfParts; i++) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -595,7 +595,7 @@ void LegoCarBuildAnimPresenter::FUN_10079a90()
|
|||||||
// FUNCTION: BETA10 0x100724fa
|
// FUNCTION: BETA10 0x100724fa
|
||||||
MxBool LegoCarBuildAnimPresenter::StringEqualsPlatform(const LegoChar* p_string)
|
MxBool LegoCarBuildAnimPresenter::StringEqualsPlatform(const LegoChar* p_string)
|
||||||
{
|
{
|
||||||
return stricmp(p_string, "PLATFORM") == 0;
|
return SDL_strcasecmp(p_string, "PLATFORM") == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10079b40
|
// FUNCTION: LEGO1 0x10079b40
|
||||||
|
|||||||
@ -887,7 +887,7 @@ void LegoAnimationManager::FUN_10060480(const LegoChar* p_characterNames[], MxU3
|
|||||||
{
|
{
|
||||||
for (MxS32 i = 0; i < p_numCharacterNames; i++) {
|
for (MxS32 i = 0; i < p_numCharacterNames; i++) {
|
||||||
for (MxS32 j = 0; j < sizeOfArray(g_characters); j++) {
|
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;
|
g_characters[j].m_unk0x08 = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <vec.h>
|
#include <vec.h>
|
||||||
|
|
||||||
|
LegoSdlEvents g_legoSdlEvents;
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1003dd70
|
// FUNCTION: LEGO1 0x1003dd70
|
||||||
// FUNCTION: BETA10 0x100d3410
|
// FUNCTION: BETA10 0x100d3410
|
||||||
LegoROI* PickROI(MxLong p_x, MxLong p_y)
|
LegoROI* PickROI(MxLong p_x, MxLong p_y)
|
||||||
@ -565,13 +567,22 @@ void EnableAnimations(MxBool p_enable)
|
|||||||
AnimationManager()->FUN_100604d0(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
|
// FUNCTION: LEGO1 0x1003ef40
|
||||||
void SetAppCursor(Cursor p_cursor)
|
void SetAppCursor(Cursor p_cursor)
|
||||||
{
|
{
|
||||||
static Uint32 g_userEvent = SDL_RegisterEvents(1);
|
|
||||||
|
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.user.type = g_userEvent;
|
event.user.type = g_legoSdlEvents.m_windowsMessage;
|
||||||
event.user.code = WM_ISLE_SETCURSOR;
|
event.user.code = WM_ISLE_SETCURSOR;
|
||||||
event.user.data1 = (void*) p_cursor;
|
event.user.data1 = (void*) p_cursor;
|
||||||
SDL_PushEvent(&event);
|
SDL_PushEvent(&event);
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
#include "mxmisc.h"
|
#include "mxmisc.h"
|
||||||
#include "mxvariabletable.h"
|
#include "mxvariabletable.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL_stdinc.h>
|
||||||
#include <vec.h>
|
#include <vec.h>
|
||||||
|
|
||||||
DECOMP_SIZE_ASSERT(LegoJetskiRaceActor, 0x1a8)
|
DECOMP_SIZE_ASSERT(LegoJetskiRaceActor, 0x1a8)
|
||||||
@ -123,7 +124,7 @@ void LegoJetskiRaceActor::Animate(float p_time)
|
|||||||
{
|
{
|
||||||
if (m_unk0x0c == 0) {
|
if (m_unk0x0c == 0) {
|
||||||
const LegoChar* raceState = VariableTable()->GetVariable(g_raceState);
|
const LegoChar* raceState = VariableTable()->GetVariable(g_raceState);
|
||||||
if (!stricmp(raceState, g_racing)) {
|
if (!SDL_strcasecmp(raceState, g_racing)) {
|
||||||
m_unk0x0c = 1;
|
m_unk0x0c = 1;
|
||||||
m_lastTime = p_time - 1.0f;
|
m_lastTime = p_time - 1.0f;
|
||||||
m_unk0x1c = p_time;
|
m_unk0x1c = p_time;
|
||||||
|
|||||||
@ -514,11 +514,22 @@ MxBool LegoInputManager::FUN_1005cdf0(LegoEventNotificationParam& p_param)
|
|||||||
return result;
|
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: LEGO1 0x1005cfb0
|
||||||
// FUNCTION: BETA10 0x10089fc5
|
// FUNCTION: BETA10 0x10089fc5
|
||||||
void LegoInputManager::StartAutoDragTimer()
|
void LegoInputManager::StartAutoDragTimer()
|
||||||
{
|
{
|
||||||
m_autoDragTimerID = ::SetTimer(LegoOmni::GetInstance()->GetWindowHandle(), 1, m_autoDragTime, NULL);
|
m_autoDragTimerID = SDL_AddTimer(m_autoDragTime, LegoInputManagerTimerCallback, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1005cfd0
|
// FUNCTION: LEGO1 0x1005cfd0
|
||||||
@ -526,7 +537,8 @@ void LegoInputManager::StartAutoDragTimer()
|
|||||||
void LegoInputManager::StopAutoDragTimer()
|
void LegoInputManager::StopAutoDragTimer()
|
||||||
{
|
{
|
||||||
if (m_autoDragTimerID) {
|
if (m_autoDragTimerID) {
|
||||||
::KillTimer(LegoOmni::GetInstance()->GetWindowHandle(), m_autoDragTimerID);
|
SDL_RemoveTimer(m_autoDragTimerID);
|
||||||
|
m_autoDragTimerID = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -160,6 +160,7 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param)
|
|||||||
{
|
{
|
||||||
MxResult result = FAILURE;
|
MxResult result = FAILURE;
|
||||||
AUTOLOCK(m_criticalSection);
|
AUTOLOCK(m_criticalSection);
|
||||||
|
HWND hWnd = NULL;
|
||||||
|
|
||||||
p_param.CreateFlags().CreateObjectFactory(FALSE);
|
p_param.CreateFlags().CreateObjectFactory(FALSE);
|
||||||
p_param.CreateFlags().CreateVideoManager(FALSE);
|
p_param.CreateFlags().CreateVideoManager(FALSE);
|
||||||
@ -191,7 +192,13 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param)
|
|||||||
goto done;
|
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;
|
delete m_inputManager;
|
||||||
m_inputManager = NULL;
|
m_inputManager = NULL;
|
||||||
goto done;
|
goto done;
|
||||||
@ -260,6 +267,8 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param)
|
|||||||
SetAppCursor(e_cursorBusy);
|
SetAppCursor(e_cursorBusy);
|
||||||
m_gameState->SetCurrentAct(LegoGameState::e_act1);
|
m_gameState->SetCurrentAct(LegoGameState::e_act1);
|
||||||
|
|
||||||
|
InitSdlEvents();
|
||||||
|
|
||||||
result = SUCCESS;
|
result = SUCCESS;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|||||||
@ -85,7 +85,12 @@ MxResult LegoVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyM
|
|||||||
Mx3DPointFloat dirVec(0.0, 0.0, 1.0);
|
Mx3DPointFloat dirVec(0.0, 0.0, 1.0);
|
||||||
Mx3DPointFloat upVec(0.0, 1.0, 0.0);
|
Mx3DPointFloat upVec(0.0, 1.0, 0.0);
|
||||||
MxMatrix outMatrix;
|
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;
|
MxS32 bits = p_videoParam.Flags().Get16Bit() ? 16 : 8;
|
||||||
|
|
||||||
if (!p_videoParam.GetPalette()) {
|
if (!p_videoParam.GetPalette()) {
|
||||||
@ -176,7 +181,11 @@ MxResult LegoVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyM
|
|||||||
|
|
||||||
Lego3DManager::CreateStruct createStruct;
|
Lego3DManager::CreateStruct createStruct;
|
||||||
memset(&createStruct, 0, sizeof(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_pDirectDraw = m_pDirectDraw;
|
||||||
createStruct.m_pFrontBuffer = m_displaySurface->GetDirectDrawSurface1();
|
createStruct.m_pFrontBuffer = m_displaySurface->GetDirectDrawSurface1();
|
||||||
createStruct.m_pBackBuffer = m_displaySurface->GetDirectDrawSurface2();
|
createStruct.m_pBackBuffer = m_displaySurface->GetDirectDrawSurface2();
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL_stdinc.h>
|
||||||
|
#include <SDL3/SDL_timer.h>
|
||||||
#include <limits.h> // ULONG_MAX
|
#include <limits.h> // ULONG_MAX
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -29,73 +31,55 @@ class MxStopWatch {
|
|||||||
double ElapsedSeconds() const;
|
double ElapsedSeconds() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
unsigned long TicksPerSeconds() const;
|
Uint64 TicksPerSeconds() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LARGE_INTEGER m_startTick; // 0x00
|
Uint64 m_startTick; // 0x00
|
||||||
// ??? when we provide LARGE_INTEGER arithmetic, use a
|
// ??? when we provide LARGE_INTEGER arithmetic, use a
|
||||||
// LARGE_INTEGER m_elapsedTicks rather than m_elapsedSeconds
|
// LARGE_INTEGER m_elapsedTicks rather than m_elapsedSeconds
|
||||||
double m_elapsedSeconds; // 0x0c
|
double m_elapsedSeconds; // 0x0c
|
||||||
unsigned long m_ticksPerSeconds; // 0x14
|
Uint64 m_ticksPerSeconds; // 0x14
|
||||||
};
|
};
|
||||||
|
|
||||||
// FUNCTION: BETA10 0x100d8ba0
|
// FUNCTION: BETA10 0x100d8ba0
|
||||||
inline MxStopWatch::MxStopWatch()
|
inline MxStopWatch::MxStopWatch()
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
m_ticksPerSeconds = TicksPerSeconds();
|
m_ticksPerSeconds = SDL_GetPerformanceCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: BETA10 0x100d8be0
|
// FUNCTION: BETA10 0x100d8be0
|
||||||
inline void MxStopWatch::Start()
|
inline void MxStopWatch::Start()
|
||||||
{
|
{
|
||||||
QueryPerformanceCounter(&m_startTick);
|
m_startTick = SDL_GetPerformanceCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: BETA10 0x100d8f50
|
// FUNCTION: BETA10 0x100d8f50
|
||||||
inline void MxStopWatch::Stop()
|
inline void MxStopWatch::Stop()
|
||||||
{
|
{
|
||||||
LARGE_INTEGER endTick;
|
Uint64 endTick;
|
||||||
BOOL result;
|
|
||||||
|
|
||||||
result = QueryPerformanceCounter(&endTick);
|
endTick = SDL_GetPerformanceCounter();
|
||||||
assert(result);
|
|
||||||
|
|
||||||
if (endTick.HighPart != m_startTick.HighPart) {
|
m_elapsedSeconds = (double) (endTick - m_startTick) / (double) m_ticksPerSeconds;
|
||||||
// LARGE_INTEGER arithmetic not yet provided
|
|
||||||
m_elapsedSeconds = HUGE_VAL_IMMEDIATE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_elapsedSeconds += ((endTick.LowPart - m_startTick.LowPart) / (double) m_ticksPerSeconds);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: BETA10 0x100d8c10
|
// FUNCTION: BETA10 0x100d8c10
|
||||||
inline void MxStopWatch::Reset()
|
inline void MxStopWatch::Reset()
|
||||||
{
|
{
|
||||||
m_startTick.LowPart = 0;
|
m_startTick = 0;
|
||||||
m_startTick.HighPart = 0;
|
m_elapsedSeconds = 0.;
|
||||||
m_elapsedSeconds = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: BETA10 0x100d8c60
|
// FUNCTION: BETA10 0x100d8c60
|
||||||
inline unsigned long MxStopWatch::TicksPerSeconds() const
|
inline Uint64 MxStopWatch::TicksPerSeconds() const
|
||||||
{
|
{
|
||||||
LARGE_INTEGER ticksPerSeconds;
|
Uint64 ticksPerSeconds;
|
||||||
BOOL result;
|
|
||||||
|
|
||||||
result = QueryPerformanceFrequency(&ticksPerSeconds);
|
ticksPerSeconds = SDL_GetPerformanceFrequency();
|
||||||
assert(result);
|
assert(ticksPerSeconds);
|
||||||
|
|
||||||
if (ticksPerSeconds.HighPart) {
|
return ticksPerSeconds;
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: BETA10 0x100d9020
|
// FUNCTION: BETA10 0x100d9020
|
||||||
|
|||||||
@ -25,7 +25,7 @@ typedef struct {
|
|||||||
WORD type; // 0x04
|
WORD type; // 0x04
|
||||||
} FLIC_CHUNK;
|
} FLIC_CHUNK;
|
||||||
|
|
||||||
typedef struct : FLIC_CHUNK {
|
typedef struct FLIC_HEADER : FLIC_CHUNK {
|
||||||
WORD frames; /* Number of frames in first segment */ // 0x06
|
WORD frames; /* Number of frames in first segment */ // 0x06
|
||||||
WORD width; /* FLIC width in pixels */ // 0x08
|
WORD width; /* FLIC width in pixels */ // 0x08
|
||||||
WORD height; /* FLIC height in pixels */ // 0x0a
|
WORD height; /* FLIC height in pixels */ // 0x0a
|
||||||
@ -35,7 +35,7 @@ typedef struct : FLIC_CHUNK {
|
|||||||
} FLIC_HEADER;
|
} FLIC_HEADER;
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
typedef struct : FLIC_CHUNK {
|
typedef struct FLIC_FRAME : FLIC_CHUNK {
|
||||||
WORD chunks; /* Number of subchunks */ // 0x06
|
WORD chunks; /* Number of subchunks */ // 0x06
|
||||||
WORD delay; /* Delay in milliseconds */ // 0x08
|
WORD delay; /* Delay in milliseconds */ // 0x08
|
||||||
WORD reserved; /* Always zero */ // 0x0a
|
WORD reserved; /* Always zero */ // 0x0a
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
#include "mxcriticalsection.h"
|
#include "mxcriticalsection.h"
|
||||||
#include "mxstring.h"
|
#include "mxstring.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL_video.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
class MxAtomSet;
|
class MxAtomSet;
|
||||||
@ -61,7 +62,7 @@ class MxOmni : public MxCore {
|
|||||||
static void SetInstance(MxOmni* p_instance);
|
static void SetInstance(MxOmni* p_instance);
|
||||||
static MxBool ActionSourceEquals(MxDSAction* p_action, const char* p_name);
|
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
|
// FUNCTION: BETA10 0x10125100
|
||||||
MxObjectFactory* GetObjectFactory() const { return this->m_objectFactory; }
|
MxObjectFactory* GetObjectFactory() const { return this->m_objectFactory; }
|
||||||
@ -102,7 +103,7 @@ class MxOmni : public MxCore {
|
|||||||
static MxOmni* g_instance;
|
static MxOmni* g_instance;
|
||||||
|
|
||||||
MxString m_mediaPath; // 0x08
|
MxString m_mediaPath; // 0x08
|
||||||
HWND m_windowHandle; // 0x18
|
SDL_Window* m_windowHandle; // 0x18
|
||||||
MxObjectFactory* m_objectFactory; // 0x1c
|
MxObjectFactory* m_objectFactory; // 0x1c
|
||||||
MxVariableTable* m_variableTable; // 0x20
|
MxVariableTable* m_variableTable; // 0x20
|
||||||
MxTickleManager* m_tickleManager; // 0x24
|
MxTickleManager* m_tickleManager; // 0x24
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
#include "mxstring.h"
|
#include "mxstring.h"
|
||||||
#include "mxvideoparam.h"
|
#include "mxvideoparam.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <SDL3/SDL_video.h>
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100dc218
|
// VTABLE: LEGO1 0x100dc218
|
||||||
// VTABLE: BETA10 0x101c1ca8
|
// VTABLE: BETA10 0x101c1ca8
|
||||||
@ -15,7 +15,7 @@ class MxOmniCreateParam : public MxParam {
|
|||||||
public:
|
public:
|
||||||
LEGO1_EXPORT MxOmniCreateParam(
|
LEGO1_EXPORT MxOmniCreateParam(
|
||||||
const char* p_mediaPath,
|
const char* p_mediaPath,
|
||||||
HWND p_windowHandle,
|
SDL_Window* p_windowHandle,
|
||||||
MxVideoParam& p_vparam,
|
MxVideoParam& p_vparam,
|
||||||
MxOmniCreateFlags p_flags
|
MxOmniCreateFlags p_flags
|
||||||
);
|
);
|
||||||
@ -24,7 +24,7 @@ class MxOmniCreateParam : public MxParam {
|
|||||||
MxOmniCreateFlags& CreateFlags() { return this->m_createFlags; }
|
MxOmniCreateFlags& CreateFlags() { return this->m_createFlags; }
|
||||||
|
|
||||||
const MxString& GetMediaPath() const { return m_mediaPath; }
|
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; }
|
MxVideoParam& GetVideoParam() { return m_videoParam; }
|
||||||
const MxVideoParam& GetVideoParam() const { return m_videoParam; }
|
const MxVideoParam& GetVideoParam() const { return m_videoParam; }
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class MxOmniCreateParam : public MxParam {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MxString m_mediaPath; // 0x04
|
MxString m_mediaPath; // 0x04
|
||||||
HWND m_windowHandle; // 0x14
|
SDL_Window* m_windowHandle; // 0x14
|
||||||
MxVideoParam m_videoParam; // 0x18
|
MxVideoParam m_videoParam; // 0x18
|
||||||
MxOmniCreateFlags m_createFlags; // 0x3c
|
MxOmniCreateFlags m_createFlags; // 0x3c
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,7 +8,7 @@ DECOMP_SIZE_ASSERT(MxOmniCreateParam, 0x40)
|
|||||||
// FUNCTION: BETA10 0x10130b6b
|
// FUNCTION: BETA10 0x10130b6b
|
||||||
MxOmniCreateParam::MxOmniCreateParam(
|
MxOmniCreateParam::MxOmniCreateParam(
|
||||||
const char* p_mediaPath,
|
const char* p_mediaPath,
|
||||||
HWND p_windowHandle,
|
SDL_Window* p_windowHandle,
|
||||||
MxVideoParam& p_vparam,
|
MxVideoParam& p_vparam,
|
||||||
MxOmniCreateFlags p_flags
|
MxOmniCreateFlags p_flags
|
||||||
)
|
)
|
||||||
|
|||||||
@ -139,7 +139,14 @@ MxResult MxDisplaySurface::Create(MxVideoParam& p_videoParam)
|
|||||||
DDSURFACEDESC ddsd;
|
DDSURFACEDESC ddsd;
|
||||||
MxResult result = FAILURE;
|
MxResult result = FAILURE;
|
||||||
LPDIRECTDRAW lpDirectDraw = MVideoManager()->GetDirectDraw();
|
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_initialized = TRUE;
|
||||||
m_videoParam = p_videoParam;
|
m_videoParam = p_videoParam;
|
||||||
@ -842,7 +849,13 @@ void MxDisplaySurface::Display(MxS32 p_left, MxS32 p_top, MxS32 p_left2, MxS32 p
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MxPoint32 point(0, 0);
|
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_left2 += m_videoParam.GetRect().GetLeft() + point.GetX();
|
||||||
p_top2 += m_videoParam.GetRect().GetTop() + point.GetY();
|
p_top2 += m_videoParam.GetRect().GetTop() + point.GetY();
|
||||||
|
|||||||
@ -216,6 +216,7 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS,
|
|||||||
{
|
{
|
||||||
MxBool locked = FALSE;
|
MxBool locked = FALSE;
|
||||||
MxResult status = FAILURE;
|
MxResult status = FAILURE;
|
||||||
|
HWND hWnd = NULL;
|
||||||
|
|
||||||
m_unk0x60 = TRUE;
|
m_unk0x60 = TRUE;
|
||||||
|
|
||||||
@ -237,7 +238,13 @@ MxResult MxVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS,
|
|||||||
goto done;
|
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;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
// Various macros to enable compiling with other/newer compilers.
|
// 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
|
#define COMPAT_MODE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user