From 559faffdb7949779cfd52d0114e19eb4c14cc47d Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 29 Dec 2024 18:06:59 +0100 Subject: [PATCH 1/7] Pass SDL_Keycode in LEGO1.dll --- LEGO1/lego/legoomni/include/gasstation.h | 4 +- LEGO1/lego/legoomni/include/hospital.h | 2 +- LEGO1/lego/legoomni/include/infocenter.h | 2 +- .../include/legoeventnotificationparam.h | 9 +- .../lego/legoomni/include/legoinputmanager.h | 3 +- .../lego/legoomni/include/registrationbook.h | 2 +- .../legoomni/src/entity/legonavcontroller.cpp | 96 +++++++++---------- .../legoomni/src/input/legoinputmanager.cpp | 10 +- LEGO1/lego/legoomni/src/worlds/gasstation.cpp | 4 +- LEGO1/lego/legoomni/src/worlds/hospital.cpp | 4 +- LEGO1/lego/legoomni/src/worlds/infocenter.cpp | 4 +- LEGO1/lego/legoomni/src/worlds/police.cpp | 2 +- .../legoomni/src/worlds/registrationbook.cpp | 23 ++--- LEGO1/lego/legoomni/src/worlds/score.cpp | 2 +- 14 files changed, 83 insertions(+), 84 deletions(-) diff --git a/LEGO1/lego/legoomni/include/gasstation.h b/LEGO1/lego/legoomni/include/gasstation.h index 76b2d17c..e89ac51c 100644 --- a/LEGO1/lego/legoomni/include/gasstation.h +++ b/LEGO1/lego/legoomni/include/gasstation.h @@ -7,6 +7,8 @@ #include "legoworld.h" #include "radio.h" +#include + class MxStillPresenter; // VTABLE: LEGO1 0x100d46e0 @@ -95,7 +97,7 @@ class GasStation : public LegoWorld { inline void StopAction(GarageScript::Script p_objectId); MxLong HandleEndAction(MxEndActionNotificationParam& p_param); - MxLong HandleKeyPress(MxS8 p_key); + MxLong HandleKeyPress(SDL_Keycode p_key); MxLong HandleButtonDown(LegoControlManagerNotificationParam& p_param); MxS16 m_currentActorId; // 0xf8 diff --git a/LEGO1/lego/legoomni/include/hospital.h b/LEGO1/lego/legoomni/include/hospital.h index 41465550..e42d1235 100644 --- a/LEGO1/lego/legoomni/include/hospital.h +++ b/LEGO1/lego/legoomni/include/hospital.h @@ -91,7 +91,7 @@ class Hospital : public LegoWorld { // Hospital::`scalar deleting destructor' private: - MxLong HandleKeyPress(MxS8 p_key); + MxLong HandleKeyPress(SDL_Keycode p_key); MxLong HandleEndAction(MxEndActionNotificationParam& p_param); MxLong HandleButtonDown(LegoControlManagerNotificationParam& p_param); MxBool HandleControl(LegoControlManagerNotificationParam& p_param); diff --git a/LEGO1/lego/legoomni/include/infocenter.h b/LEGO1/lego/legoomni/include/infocenter.h index b1a943cf..f35cc77a 100644 --- a/LEGO1/lego/legoomni/include/infocenter.h +++ b/LEGO1/lego/legoomni/include/infocenter.h @@ -130,7 +130,7 @@ class Infocenter : public LegoWorld { private: void InitializeBitmaps(); - MxLong HandleKeyPress(MxS8 p_key); + MxLong HandleKeyPress(SDL_Keycode p_key); MxU8 HandleMouseMove(MxS32 p_x, MxS32 p_y); MxU8 HandleButtonUp(MxS32 p_x, MxS32 p_y); MxU8 HandleControl(LegoControlManagerNotificationParam& p_param); diff --git a/LEGO1/lego/legoomni/include/legoeventnotificationparam.h b/LEGO1/lego/legoomni/include/legoeventnotificationparam.h index 7cfa28f9..4ee0bbae 100644 --- a/LEGO1/lego/legoomni/include/legoeventnotificationparam.h +++ b/LEGO1/lego/legoomni/include/legoeventnotificationparam.h @@ -4,6 +4,7 @@ #include "mxnotificationparam.h" #include "mxtypes.h" +#include #include class LegoROI; @@ -35,7 +36,7 @@ class LegoEventNotificationParam : public MxNotificationParam { MxU8 p_modifier, MxS32 p_x, MxS32 p_y, - MxU8 p_key + SDL_Keycode p_key ) : MxNotificationParam(p_type, p_sender), m_modifier(p_modifier), m_x(p_x), m_y(p_y), m_key(p_key), m_roi(NULL) { @@ -43,7 +44,7 @@ class LegoEventNotificationParam : public MxNotificationParam { LegoROI* GetROI() { return m_roi; } MxU8 GetModifier() { return m_modifier; } - MxU8 GetKey() const { return m_key; } + SDL_Keycode GetKey() const { return m_key; } // FUNCTION: LEGO1 0x10012190 // FUNCTION: BETA10 0x10024210 @@ -59,7 +60,7 @@ class LegoEventNotificationParam : public MxNotificationParam { void SetModifier(MxU8 p_modifier) { m_modifier = p_modifier; } // FUNCTION: BETA10 0x1007d6b0 - void SetKey(MxU8 p_key) { m_key = p_key; } + void SetKey(SDL_Keycode p_key) { m_key = p_key; } // FUNCTION: BETA10 0x1007d650 void SetX(MxS32 p_x) { m_x = p_x; } @@ -71,7 +72,7 @@ class LegoEventNotificationParam : public MxNotificationParam { MxU8 m_modifier; // 0x0c MxS32 m_x; // 0x10 MxS32 m_y; // 0x14 - MxU8 m_key; // 0x18 + SDL_Keycode m_key;// 0x18 LegoROI* m_roi; // 0x1c }; diff --git a/LEGO1/lego/legoomni/include/legoinputmanager.h b/LEGO1/lego/legoomni/include/legoinputmanager.h index f93e2be3..53a442e4 100644 --- a/LEGO1/lego/legoomni/include/legoinputmanager.h +++ b/LEGO1/lego/legoomni/include/legoinputmanager.h @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -87,7 +88,7 @@ class LegoInputManager : public MxPresenter { LegoInputManager(); ~LegoInputManager() override; - LEGO1_EXPORT void QueueEvent(NotificationId p_id, MxU8 p_modifier, MxLong p_x, MxLong p_y, MxU8 p_key); + LEGO1_EXPORT void QueueEvent(NotificationId p_id, MxU8 p_modifier, MxLong p_x, MxLong p_y, SDL_Keycode p_key); void Register(MxCore*); void UnRegister(MxCore*); diff --git a/LEGO1/lego/legoomni/include/registrationbook.h b/LEGO1/lego/legoomni/include/registrationbook.h index 3e2cf367..9ceef334 100644 --- a/LEGO1/lego/legoomni/include/registrationbook.h +++ b/LEGO1/lego/legoomni/include/registrationbook.h @@ -66,7 +66,7 @@ class RegistrationBook : public LegoWorld { LPDIRECTDRAWSURFACE m_checkboxNormal; // 0x2cc MxLong HandleEndAction(MxEndActionNotificationParam& p_param); - MxLong HandleKeyPress(MxU8 p_key); + MxLong HandleKeyPress(SDL_Keycode p_key); MxLong HandleControl(LegoControlManagerNotificationParam& p_param); MxLong HandlePathStruct(LegoPathStructNotificationParam& p_param); void FUN_100775c0(MxS16 p_playerIndex); diff --git a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp index 8856abb7..d33004a8 100644 --- a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp @@ -639,10 +639,10 @@ MxLong LegoNavController::Notify(MxParam& p_param) { if (((MxNotificationParam&) p_param).GetNotification() == c_notificationKeyPress) { m_unk0x5d = TRUE; - MxU8 key = ((LegoEventNotificationParam&) p_param).GetKey(); + SDL_Keycode key = ((LegoEventNotificationParam&) p_param).GetKey(); switch (key) { - case VK_PAUSE: // Pause game + case SDLK_PAUSE: // Pause game if (Lego()->IsPaused()) { Lego()->Resume(); } @@ -650,7 +650,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) Lego()->Pause(); } break; - case VK_ESCAPE: { // Return to infocenter + case SDLK_ESCAPE: { // Return to infocenter LegoWorld* currentWorld = CurrentWorld(); if (currentWorld != NULL) { InfocenterState* state = (InfocenterState*) GameState()->GetState("InfocenterState"); @@ -664,10 +664,10 @@ MxLong LegoNavController::Notify(MxParam& p_param) } break; } - case VK_SPACE: // Interrupt/end animations or free navigation + case SDLK_SPACE: // Interrupt/end animations or free navigation AnimationManager()->FUN_10061010(TRUE); break; - case 'Z': { // Make nearby plants "dance" + case SDLK_Z: { // Make nearby plants "dance" LegoOmni* omni = Lego(); if (omni->GetCurrentWorld() != NULL && omni->GetCurrentWorld()->GetWorldId() == LegoOmni::e_act1) { @@ -701,15 +701,15 @@ MxLong LegoNavController::Notify(MxParam& p_param) } break; } - case VK_ADD: - case VK_SUBTRACT: { // Cycles through characters and puts them in front of you + case SDLK_KP_PLUS: + case SDLK_KP_MINUS: { // Cycles through characters and puts them in front of you if (g_nextCharacter == -1) { g_nextCharacter = 0; } else { CharacterManager()->ReleaseActor(CharacterManager()->GetActorName(g_nextCharacter)); - if (key == VK_ADD) { + if (key == SDLK_KP_PLUS) { g_nextCharacter++; if (g_nextCharacter >= CharacterManager()->GetNumActors()) { g_nextCharacter = 0; @@ -736,7 +736,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) } break; } - case VK_F12: { // Saves the game + case SDLK_F12: { // Saves the game InfocenterState* state = (InfocenterState*) GameState()->GetState("InfocenterState"); if (state && state->HasRegistered()) { GameState()->Save(0); @@ -748,7 +748,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) if (!*g_currentInput) { // password "protected" debug shortcuts switch (((LegoEventNotificationParam&) p_param).GetKey()) { - case VK_TAB: + case SDLK_TAB: VideoManager()->ToggleFPS(g_fpsEnabled); if (g_fpsEnabled) { g_fpsEnabled = FALSE; @@ -759,16 +759,16 @@ MxLong LegoNavController::Notify(MxParam& p_param) default: m_unk0x5d = FALSE; break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': + case SDLK_0: + case SDLK_1: + case SDLK_2: + case SDLK_3: + case SDLK_4: + case SDLK_5: + case SDLK_6: + case SDLK_7: + case SDLK_8: + case SDLK_9: if (g_changeLight && key <= '1') { LegoROI* roi = VideoManager()->GetViewROI(); Tgl::FloatMatrix4 matrix; @@ -821,7 +821,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) } } - if (g_switchAct && key >= '1' && key <= '5') { + if (g_switchAct && key >= SDLK_1 && key <= SDLK_5) { switch (GameState()->GetCurrentAct()) { case LegoGameState::e_act1: GameState()->m_currentArea = LegoGameState::e_isle; @@ -835,17 +835,17 @@ MxLong LegoNavController::Notify(MxParam& p_param) } switch (key) { - case '1': + case SDLK_1: GameState()->SetCurrentAct(LegoGameState::e_act1); GameState()->SwitchArea(LegoGameState::e_isle); break; - case '2': + case SDLK_2: GameState()->SwitchArea(LegoGameState::e_act2main); break; - case '3': + case SDLK_3: GameState()->SwitchArea(LegoGameState::e_act3script); break; - case '4': { + case SDLK_4: { Act3State* act3State = (Act3State*) GameState()->GetState("Act3State"); if (act3State == NULL) { act3State = new Act3State(); @@ -859,7 +859,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) GameState()->SwitchArea(LegoGameState::e_infomain); break; } - case '5': { + case SDLK_5: { Act3State* act3State = (Act3State*) GameState()->GetState("Act3State"); if (act3State == NULL) { act3State = new Act3State(); @@ -884,7 +884,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) LegoOmni::GetInstance()->Start(&action); } break; - case 'A': + case SDLK_A: if (g_animationCalcStep == 1) { Lego()->m_unk0x13c = TRUE; AnimationManager()->FUN_10060570(TRUE); @@ -900,22 +900,22 @@ MxLong LegoNavController::Notify(MxParam& p_param) } } break; - case 'C': + case SDLK_C: g_locationCalcStep = 1; break; - case 'D': + case SDLK_D: m_unk0x60 = -1.0; break; - case 'F': + case SDLK_F: RealtimeView::SetUserMaxLOD(0.0); break; - case 'G': + case SDLK_G: g_switchAct = TRUE; break; - case 'H': + case SDLK_H: RealtimeView::SetUserMaxLOD(5.0); break; - case 'I': { + case SDLK_I: { LegoROI* roi = VideoManager()->GetViewROI(); MxMatrix mat; mat.SetIdentity(); @@ -923,7 +923,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) roi->WrappedVTable0x24(mat); break; } - case 'J': { + case SDLK_J: { LegoROI* roi = VideoManager()->GetViewROI(); MxMatrix mat; mat.SetIdentity(); @@ -931,7 +931,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) roi->WrappedVTable0x24(mat); break; } - case 'K': { + case SDLK_K: { MxMatrix mat; LegoROI* roi = LegoOmni::GetInstance()->GetVideoManager()->GetViewROI(); mat.SetIdentity(); @@ -939,10 +939,10 @@ MxLong LegoNavController::Notify(MxParam& p_param) roi->WrappedVTable0x24(mat); break; } - case 'L': + case SDLK_L: g_changeLight = TRUE; break; - case 'M': { + case SDLK_M: { LegoROI* roi = LegoOmni::GetInstance()->GetVideoManager()->GetViewROI(); MxMatrix mat; mat.SetIdentity(); @@ -950,12 +950,12 @@ MxLong LegoNavController::Notify(MxParam& p_param) roi->WrappedVTable0x24(mat); break; } - case 'N': + case SDLK_N: if (VideoManager()) { VideoManager()->SetRender3D(!VideoManager()->GetRender3D()); } break; - case 'P': + case SDLK_P: if (!g_resetPlants) { PlantManager()->LoadWorldInfo(LegoOmni::e_act1); g_resetPlants = TRUE; @@ -965,14 +965,14 @@ MxLong LegoNavController::Notify(MxParam& p_param) g_resetPlants = FALSE; } break; - case 'S': + case SDLK_S: g_enableMusic = g_enableMusic == FALSE; BackgroundAudioManager()->Enable(g_enableMusic); break; - case 'U': + case SDLK_U: m_unk0x60 = 1.0; break; - case 'V': + case SDLK_V: if (g_nextAnimation > 0 && g_animationCalcStep == 0) { AnimationManager()->FUN_10061010(FALSE); } @@ -984,7 +984,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) g_nextAnimation = 0; g_animationCalcStep = 1; break; - case 'W': { + case SDLK_W: { MxMatrix mat; LegoROI* roi = LegoOmni::GetInstance()->GetVideoManager()->GetViewROI(); const float* position = roi->GetWorldPosition(); @@ -999,10 +999,10 @@ MxLong LegoNavController::Notify(MxParam& p_param) ); break; } - case 'X': + case SDLK_X: RealtimeView::SetUserMaxLOD(3.6); break; - case VK_MULTIPLY: { + case SDLK_KP_MULTIPLY: { MxU8 newActor = GameState()->GetActorId() + 1; if (newActor > LegoActor::c_laura) { @@ -1012,10 +1012,10 @@ MxLong LegoNavController::Notify(MxParam& p_param) GameState()->SetActorId(newActor); break; } - case VK_DIVIDE: + case SDLK_KP_DIVIDE: GameState()->SetActorId(LegoActor::c_brickster); break; - case VK_F11: + case SDLK_F11: if (GameState()->m_isDirty) { GameState()->m_isDirty = FALSE; } @@ -1023,7 +1023,7 @@ MxLong LegoNavController::Notify(MxParam& p_param) GameState()->m_isDirty = TRUE; } break; - case VK_OEM_MINUS: + case SDLK_MINUS: g_unk0x100f66bc = LegoAnimationManager::e_unk1; break; } diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index 4351ecfb..cdbd8485 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -288,12 +288,12 @@ void LegoInputManager::ClearWorld() } // FUNCTION: LEGO1 0x1005c740 -void LegoInputManager::QueueEvent(NotificationId p_id, MxU8 p_modifier, MxLong p_x, MxLong p_y, MxU8 p_key) +void LegoInputManager::QueueEvent(NotificationId p_id, MxU8 p_modifier, MxLong p_x, MxLong p_y, SDL_Keycode p_key) { LegoEventNotificationParam param = LegoEventNotificationParam(p_id, NULL, p_modifier, p_x, p_y, p_key); if (((!m_unk0x88) || ((m_unk0x335 && (param.GetNotification() == c_notificationButtonDown)))) || - ((m_unk0x336 && (p_key == VK_SPACE)))) { + ((m_unk0x336 && (p_key == SDLK_SPACE)))) { ProcessOneEvent(param); } } @@ -317,8 +317,8 @@ MxBool LegoInputManager::ProcessOneEvent(LegoEventNotificationParam& p_param) MxBool processRoi; if (p_param.GetNotification() == c_notificationKeyPress) { - if (!Lego()->IsPaused() || p_param.GetKey() == VK_PAUSE) { - if (p_param.GetKey() == VK_SHIFT) { + if (!Lego()->IsPaused() || p_param.GetKey() == SDLK_PAUSE) { + if (p_param.GetKey() == SDLK_LSHIFT || p_param.GetKey() == SDLK_RSHIFT) { if (m_unk0x195) { m_unk0x80 = FALSE; p_param.SetNotification(c_notificationDragEnd); @@ -348,7 +348,7 @@ MxBool LegoInputManager::ProcessOneEvent(LegoEventNotificationParam& p_param) if (m_unk0x335 != 0) { if (p_param.GetNotification() == c_notificationButtonDown) { - LegoEventNotificationParam notification(c_notificationKeyPress, NULL, 0, 0, 0, VK_SPACE); + LegoEventNotificationParam notification(c_notificationKeyPress, NULL, 0, 0, 0, SDLK_SPACE); LegoNotifyListCursor cursor(m_keyboardNotifyList); MxCore* target; diff --git a/LEGO1/lego/legoomni/src/worlds/gasstation.cpp b/LEGO1/lego/legoomni/src/worlds/gasstation.cpp index b78ef473..9456f83d 100644 --- a/LEGO1/lego/legoomni/src/worlds/gasstation.cpp +++ b/LEGO1/lego/legoomni/src/worlds/gasstation.cpp @@ -358,9 +358,9 @@ MxLong GasStation::HandleEndAction(MxEndActionNotificationParam& p_param) } // FUNCTION: LEGO1 0x10005920 -MxLong GasStation::HandleKeyPress(MxS8 p_key) +MxLong GasStation::HandleKeyPress(SDL_Keycode p_key) { - if (p_key == VK_SPACE && g_unk0x100f0160 == 0 && m_unk0x106 != 0) { + if (p_key == SDLK_SPACE && g_unk0x100f0160 == 0 && m_unk0x106 != 0) { m_state->StopActions(); return 1; } diff --git a/LEGO1/lego/legoomni/src/worlds/hospital.cpp b/LEGO1/lego/legoomni/src/worlds/hospital.cpp index 0a9cec10..e34ab085 100644 --- a/LEGO1/lego/legoomni/src/worlds/hospital.cpp +++ b/LEGO1/lego/legoomni/src/worlds/hospital.cpp @@ -226,11 +226,11 @@ void Hospital::ReadyWorld() } // FUNCTION: LEGO1 0x10074dd0 -MxLong Hospital::HandleKeyPress(MxS8 p_key) +MxLong Hospital::HandleKeyPress(SDL_Keycode p_key) { MxLong result = 0; - if (p_key == VK_SPACE && g_unk0x100f7918 == 0) { + if (p_key == SDLK_SPACE && g_unk0x100f7918 == 0) { DeleteObjects(&m_atomId, HospitalScript::c_hho002cl_RunAnim, HospitalScript::c_hho006cl_RunAnim); result = 1; } diff --git a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp index d7fea12f..2c4a4dc5 100644 --- a/LEGO1/lego/legoomni/src/worlds/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/worlds/infocenter.cpp @@ -720,11 +720,11 @@ MxU8 Infocenter::HandleMouseMove(MxS32 p_x, MxS32 p_y) } // FUNCTION: LEGO1 0x1006fda0 -MxLong Infocenter::HandleKeyPress(MxS8 p_key) +MxLong Infocenter::HandleKeyPress(SDL_Keycode p_key) { MxLong result = 0; - if (p_key == VK_SPACE && m_worldStarted) { + if (p_key == SDLK_SPACE && m_worldStarted) { switch (m_infocenterState->GetUnknown0x74()) { case 0: StopCutscene(); diff --git a/LEGO1/lego/legoomni/src/worlds/police.cpp b/LEGO1/lego/legoomni/src/worlds/police.cpp index 7bf48e9b..9bd8b4c1 100644 --- a/LEGO1/lego/legoomni/src/worlds/police.cpp +++ b/LEGO1/lego/legoomni/src/worlds/police.cpp @@ -167,7 +167,7 @@ MxLong Police::HandleKeyPress(LegoEventNotificationParam& p_param) { MxLong result = 0; - if (p_param.GetKey() == VK_SPACE && m_policeState->GetUnknown0x0c() == 1) { + if (p_param.GetKey() == SDLK_SPACE && m_policeState->GetUnknown0x0c() == 1) { DeleteObjects(&m_atomId, PoliceScript::c_nps001ni_RunAnim, PoliceScript::c_nps002la_RunAnim); m_policeState->SetUnknown0x0c(0); return 1; diff --git a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp index 5ade0b3a..4c4da07f 100644 --- a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp +++ b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp @@ -169,27 +169,22 @@ MxLong RegistrationBook::HandleEndAction(MxEndActionNotificationParam& p_param) } // FUNCTION: LEGO1 0x100772d0 -MxLong RegistrationBook::HandleKeyPress(MxU8 p_key) +MxLong RegistrationBook::HandleKeyPress(SDL_Keycode p_key) { - MxS16 key; - if (p_key >= 'a' && p_key <= 'z') { - key = p_key - ' '; - } - else { - key = p_key; - } + // keycode is case-insensitive + SDL_Keycode key = p_key; - if ((key < 'A' || key > 'Z') && key != VK_BACK) { - if (key == VK_SPACE) { + if ((key < SDLK_A || key > SDLK_Z) && key != SDLK_BACKSPACE) { + if (key == SDLK_SPACE) { DeleteObjects(&m_atomId, RegbookScript::c_iic006in_RunAnim, RegbookScript::c_iic008in_PlayWav); BackgroundAudioManager()->RaiseVolume(); } } - else if (key != VK_BACK && m_unk0x280.m_cursorPos < 7) { + else if (key != SDLK_BACKSPACE && m_unk0x280.m_cursorPos < 7) { m_name[0][m_unk0x280.m_cursorPos] = m_alphabet[key - 'A']->Clone(); if (m_name[0][m_unk0x280.m_cursorPos] != NULL) { - m_alphabet[key - 'A']->GetAction()->SetUnknown24(m_alphabet[key - 'A']->GetAction()->GetUnknown24() + 1); + m_alphabet[key - SDLK_A]->GetAction()->SetUnknown24(m_alphabet[key - SDLK_A]->GetAction()->GetUnknown24() + 1); m_name[0][m_unk0x280.m_cursorPos]->Enable(TRUE); m_name[0][m_unk0x280.m_cursorPos]->SetTickleState(MxPresenter::e_repeating); m_name[0][m_unk0x280.m_cursorPos]->SetPosition(m_unk0x280.m_cursorPos * 23 + 343, 121); @@ -198,12 +193,12 @@ MxLong RegistrationBook::HandleKeyPress(MxU8 p_key) m_checkmark[0]->Enable(TRUE); } - m_unk0x280.m_letters[m_unk0x280.m_cursorPos] = key - 'A'; + m_unk0x280.m_letters[m_unk0x280.m_cursorPos] = key - SDLK_A; m_unk0x280.m_cursorPos++; } } else { - if (key == VK_BACK && m_unk0x280.m_cursorPos > 0) { + if (key == SDLK_BACKSPACE && m_unk0x280.m_cursorPos > 0) { m_unk0x280.m_cursorPos--; m_name[0][m_unk0x280.m_cursorPos]->Enable(FALSE); diff --git a/LEGO1/lego/legoomni/src/worlds/score.cpp b/LEGO1/lego/legoomni/src/worlds/score.cpp index d1547fb8..d2f171c3 100644 --- a/LEGO1/lego/legoomni/src/worlds/score.cpp +++ b/LEGO1/lego/legoomni/src/worlds/score.cpp @@ -96,7 +96,7 @@ MxLong Score::Notify(MxParam& p_param) ret = FUN_10001510((MxEndActionNotificationParam&) p_param); break; case c_notificationKeyPress: - if (((LegoEventNotificationParam&) p_param).GetKey() == VK_SPACE) { + if (((LegoEventNotificationParam&) p_param).GetKey() == SDLK_SPACE) { DeleteScript(); } ret = 1; From 19bf6166ee601568bd0679225203940428e3e505 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 29 Dec 2024 18:07:55 +0100 Subject: [PATCH 2/7] ISLE.EXE: use iniparser for getting isle.mediaPath --- ISLE/isleapp.cpp | 21 +++++++++++++++------ ISLE/isleapp.h | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 731aa6e1..8a6baa35 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -140,6 +140,10 @@ IsleApp::~IsleApp() if (m_savePath) { delete[] m_savePath; } + + if (m_mediaPath) { + delete[] m_mediaPath; + } } // FUNCTION: ISLE 0x401260 @@ -175,18 +179,16 @@ void IsleApp::Close() MxS32 IsleApp::SetupLegoOmni() { MxS32 result = FALSE; - char mediaPath[256]; - GetProfileStringA("LEGO Island", "MediaPath", "", mediaPath, sizeof(mediaPath)); #ifdef COMPAT_MODE MxS32 failure; { - MxOmniCreateParam param(mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags()); + MxOmniCreateParam param(m_mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags()); failure = Lego()->Create(param) == FAILURE; } #else MxS32 failure = - Lego()->Create(MxOmniCreateParam(mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags())) == FAILURE; + Lego()->Create(MxOmniCreateParam(m_mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags())) == FAILURE; #endif if (!failure) { @@ -525,11 +527,14 @@ void IsleApp::LoadConfig() iniConfig = new char[strlen(m_iniPath) + 1]; strcpy(iniConfig, m_iniPath); } - else { + else if (prefPath) { iniConfig = new char[strlen(prefPath) + strlen("isle.ini") + 1](); strcat(iniConfig, prefPath); strcat(iniConfig, "isle.ini"); - } + } else { + iniConfig = new char[strlen("isle.ini") + 1]; + strcpy(iniConfig, "isle.ini"); + } SDL_Log("Reading configuration from \"%s\"", iniConfig); dictionary* dict = iniparser_load(iniConfig); @@ -544,6 +549,10 @@ void IsleApp::LoadConfig() strcpy(m_cdPath, cdPath); MxOmni::SetCD(m_cdPath); + const char *mediaPath = iniparser_getstring(dict, "isle:mediapath", cdPath); + m_mediaPath = new char[strlen(mediaPath) + 1]; + strcpy(m_mediaPath, mediaPath); + m_flipSurfaces = iniparser_getboolean(dict, "isle:Flip Surfaces", m_flipSurfaces); m_fullScreen = iniparser_getboolean(dict, "isle:Full Screen", m_fullScreen); m_wideViewAngle = iniparser_getboolean(dict, "isle:Wide View Angle", m_wideViewAngle); diff --git a/ISLE/isleapp.h b/ISLE/isleapp.h index a45c9949..858a34a5 100644 --- a/ISLE/isleapp.h +++ b/ISLE/isleapp.h @@ -78,6 +78,7 @@ class IsleApp { SDL_Cursor* m_cursorBusy; // 0x80 SDL_Cursor* m_cursorNo; // 0x84 SDL_Cursor* m_cursorCurrent; // 0x88 + char* m_mediaPath; char* m_iniPath; }; From 7ee594b3bde9333674875489b9e6ef21c5b8a421 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 29 Dec 2024 18:08:15 +0100 Subject: [PATCH 3/7] Use SDL_isdigit instead of isdigit --- LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp index 42741147..8e328637 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -312,7 +312,7 @@ void LegoAnimPresenter::FUN_100695c0() LegoU32 len = strlen(actorName); strcpy(lodName, actorName); - for (LegoChar* i = &lodName[len - 1]; isdigit(*i) || *i == '_'; i--) { + for (LegoChar* i = &lodName[len - 1]; SDL_isdigit(*i) || *i == '_'; i--) { *i = '\0'; } From dfdc7801736af1ac690204849297876d08a40245 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 29 Dec 2024 18:10:03 +0100 Subject: [PATCH 4/7] clang-format --- ISLE/isleapp.cpp | 13 +++++++------ .../legoomni/include/legoeventnotificationparam.h | 10 +++++----- LEGO1/lego/legoomni/src/worlds/registrationbook.cpp | 4 +++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 8a6baa35..453ce64e 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -531,10 +531,11 @@ void IsleApp::LoadConfig() iniConfig = new char[strlen(prefPath) + strlen("isle.ini") + 1](); strcat(iniConfig, prefPath); strcat(iniConfig, "isle.ini"); - } else { - iniConfig = new char[strlen("isle.ini") + 1]; - strcpy(iniConfig, "isle.ini"); - } + } + else { + iniConfig = new char[strlen("isle.ini") + 1]; + strcpy(iniConfig, "isle.ini"); + } SDL_Log("Reading configuration from \"%s\"", iniConfig); dictionary* dict = iniparser_load(iniConfig); @@ -549,8 +550,8 @@ void IsleApp::LoadConfig() strcpy(m_cdPath, cdPath); MxOmni::SetCD(m_cdPath); - const char *mediaPath = iniparser_getstring(dict, "isle:mediapath", cdPath); - m_mediaPath = new char[strlen(mediaPath) + 1]; + const char* mediaPath = iniparser_getstring(dict, "isle:mediapath", cdPath); + m_mediaPath = new char[strlen(mediaPath) + 1]; strcpy(m_mediaPath, mediaPath); m_flipSurfaces = iniparser_getboolean(dict, "isle:Flip Surfaces", m_flipSurfaces); diff --git a/LEGO1/lego/legoomni/include/legoeventnotificationparam.h b/LEGO1/lego/legoomni/include/legoeventnotificationparam.h index 4ee0bbae..a88c62f0 100644 --- a/LEGO1/lego/legoomni/include/legoeventnotificationparam.h +++ b/LEGO1/lego/legoomni/include/legoeventnotificationparam.h @@ -69,11 +69,11 @@ class LegoEventNotificationParam : public MxNotificationParam { void SetY(MxS32 p_y) { m_y = p_y; } protected: - MxU8 m_modifier; // 0x0c - MxS32 m_x; // 0x10 - MxS32 m_y; // 0x14 - SDL_Keycode m_key;// 0x18 - LegoROI* m_roi; // 0x1c + MxU8 m_modifier; // 0x0c + MxS32 m_x; // 0x10 + MxS32 m_y; // 0x14 + SDL_Keycode m_key; // 0x18 + LegoROI* m_roi; // 0x1c }; // SYNTHETIC: LEGO1 0x10028770 diff --git a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp index 4c4da07f..4ccf3ea3 100644 --- a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp +++ b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp @@ -184,7 +184,9 @@ MxLong RegistrationBook::HandleKeyPress(SDL_Keycode p_key) m_name[0][m_unk0x280.m_cursorPos] = m_alphabet[key - 'A']->Clone(); if (m_name[0][m_unk0x280.m_cursorPos] != NULL) { - m_alphabet[key - SDLK_A]->GetAction()->SetUnknown24(m_alphabet[key - SDLK_A]->GetAction()->GetUnknown24() + 1); + m_alphabet[key - SDLK_A]->GetAction()->SetUnknown24( + m_alphabet[key - SDLK_A]->GetAction()->GetUnknown24() + 1 + ); m_name[0][m_unk0x280.m_cursorPos]->Enable(TRUE); m_name[0][m_unk0x280.m_cursorPos]->SetTickleState(MxPresenter::e_repeating); m_name[0][m_unk0x280.m_cursorPos]->SetPosition(m_unk0x280.m_cursorPos * 23 + 343, 121); From cbc7a932997fa82f6b740c6f813810f566c555b2 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 29 Dec 2024 18:18:14 +0100 Subject: [PATCH 5/7] hdPath is a better default for mediaPath --- ISLE/isleapp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 453ce64e..f96be68a 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -550,7 +550,7 @@ void IsleApp::LoadConfig() strcpy(m_cdPath, cdPath); MxOmni::SetCD(m_cdPath); - const char* mediaPath = iniparser_getstring(dict, "isle:mediapath", cdPath); + const char* mediaPath = iniparser_getstring(dict, "isle:mediapath", hdPath); m_mediaPath = new char[strlen(mediaPath) + 1]; strcpy(m_mediaPath, mediaPath); From 2138d408210c9417e24449b3c65c9ac45978646b Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 29 Dec 2024 18:26:37 +0100 Subject: [PATCH 6/7] Replaced a stray 'A' with SDLK_A --- LEGO1/lego/legoomni/src/worlds/registrationbook.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp index 4ccf3ea3..bf6e1310 100644 --- a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp +++ b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp @@ -181,7 +181,7 @@ MxLong RegistrationBook::HandleKeyPress(SDL_Keycode p_key) } } else if (key != SDLK_BACKSPACE && m_unk0x280.m_cursorPos < 7) { - m_name[0][m_unk0x280.m_cursorPos] = m_alphabet[key - 'A']->Clone(); + m_name[0][m_unk0x280.m_cursorPos] = m_alphabet[key - SDLK_A]->Clone(); if (m_name[0][m_unk0x280.m_cursorPos] != NULL) { m_alphabet[key - SDLK_A]->GetAction()->SetUnknown24( From 975e2ce54f2dc01b3e039cfac772fe1e0145cf4d Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 29 Dec 2024 18:48:08 +0100 Subject: [PATCH 7/7] Use SDL_Keycode to store the ogel cheat code --- LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp index d33004a8..d974c439 100644 --- a/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp +++ b/LEGO1/lego/legoomni/src/entity/legonavcontroller.cpp @@ -109,10 +109,17 @@ MxU32 g_switchAct = FALSE; LegoAnimationManager::PlayMode g_unk0x100f66bc = LegoAnimationManager::e_unk2; // GLOBAL: LEGO1 0x100f66c0 -char g_debugPassword[] = "OGEL"; +SDL_Keycode g_debugPassword[] = { + // "OGEL" + SDLK_O, + SDLK_G, + SDLK_E, + SDLK_L, + 0, +}; // GLOBAL: LEGO1 0x100f66c8 -char* g_currentInput = g_debugPassword; +SDL_Keycode* g_currentInput = g_debugPassword; // GLOBAL: LEGO1 0x100f66cc MxS32 g_nextCharacter = -1;