diff --git a/LEGO1/lego/legoomni/include/actions/regbook_actions.h b/LEGO1/lego/legoomni/include/actions/regbook_actions.h index 74182f46..42470c15 100644 --- a/LEGO1/lego/legoomni/include/actions/regbook_actions.h +++ b/LEGO1/lego/legoomni/include/actions/regbook_actions.h @@ -76,35 +76,35 @@ enum Script { c_Back_Down_Bitmap = 66, c_Info_Down_Bitmap = 67, c_Check0_Ctl = 68, - c_Check0_Bitmap = 69, - c_Check0_Bitmap = 70, + c_Check0_Bitmap_69 = 69, + c_Check0_Bitmap_70 = 70, c_Check1_Ctl = 71, - c_Check1_Bitmap = 72, - c_Check1_Bitmap = 73, + c_Check1_Bitmap_72 = 72, + c_Check1_Bitmap_73 = 73, c_Check2_Ctl = 74, - c_Check2_Bitmap = 75, - c_Check2_Bitmap = 76, + c_Check2_Bitmap_75 = 75, + c_Check2_Bitmap_76 = 76, c_Check3_Ctl = 77, - c_Check3_Bitmap = 78, - c_Check3_Bitmap = 79, + c_Check3_Bitmap_78 = 78, + c_Check3_Bitmap_79 = 79, c_Check4_Ctl = 80, - c_Check4_Bitmap = 81, - c_Check4_Bitmap = 82, + c_Check4_Bitmap_81 = 81, + c_Check4_Bitmap_82 = 82, c_Check5_Ctl = 83, - c_Check5_Bitmap = 84, - c_Check5_Bitmap = 85, + c_Check5_Bitmap_84 = 84, + c_Check5_Bitmap_85 = 85, c_Check6_Ctl = 86, - c_Check6_Bitmap = 87, - c_Check6_Bitmap = 88, + c_Check6_Bitmap_87 = 87, + c_Check6_Bitmap_88 = 88, c_Check7_Ctl = 89, - c_Check7_Bitmap = 90, - c_Check7_Bitmap = 91, + c_Check7_Bitmap_90 = 90, + c_Check7_Bitmap_91 = 91, c_Check8_Ctl = 92, - c_Check8_Bitmap = 93, - c_Check8_Bitmap = 94, + c_Check8_Bitmap_93 = 93, + c_Check8_Bitmap_94 = 94, c_Check9_Ctl = 95, - c_Check9_Bitmap = 96, - c_Check9_Bitmap = 97, + c_Check9_Bitmap_96 = 96, + c_Check9_Bitmap_97 = 97, c_ConfigAnimation = 98, c_Chptr_Model = 99, c_DuneBugy_Model = 100, diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h index 3252b2c9..84dba4f2 100644 --- a/LEGO1/lego/legoomni/include/legogamestate.h +++ b/LEGO1/lego/legoomni/include/legogamestate.h @@ -162,6 +162,8 @@ class LegoGameState { inline void SetActorId(MxU8 p_actorId) { m_actorId = p_actorId; } inline void SetUnknown0x41c(undefined4 p_unk0x41c) { m_unk0x41c = p_unk0x41c; } inline void SetUnknown0x42c(Area p_unk0x42c) { m_unk0x42c = p_unk0x42c; } + inline Username* GetPlayersIndex(MxS32 p_index) { return &m_players[p_index]; } + inline MxS16 GetPlayerCount() { return m_playerCount; } void SetCurrentAct(Act p_currentAct); void FindLoadedAct(); @@ -184,15 +186,21 @@ class LegoGameState { LegoBackgroundColor* m_tempBackgroundColor; // 0x1c LegoFullScreenMovie* m_fullScreenMovie; // 0x20 MxU16 m_unk0x24; // 0x24 - MxS16 m_playerCount; // 0x26 - Username m_players[9]; // 0x28 - History m_history; // 0xa6 - undefined2 m_unk0x41a; // 0x41a - undefined4 m_unk0x41c; // 0x41c - MxBool m_isDirty; // 0x420 - Area m_currentArea; // 0x424 - Area m_previousArea; // 0x428 - Area m_unk0x42c; // 0x42c + + // Member visibility needs to be refactored, since most members are accessed directly. + +public: + MxS16 m_playerCount; // 0x26 + Username m_players[9]; // 0x28 + +private: + History m_history; // 0xa6 + undefined2 m_unk0x41a; // 0x41a + undefined4 m_unk0x41c; // 0x41c + MxBool m_isDirty; // 0x420 + Area m_currentArea; // 0x424 + Area m_previousArea; // 0x428 + Area m_unk0x42c; // 0x42c }; MxBool ROIHandlerFunction(const char* p_input, char* p_output, MxU32 p_copyLen); diff --git a/LEGO1/lego/legoomni/include/legoworld.h b/LEGO1/lego/legoomni/include/legoworld.h index 526a28d3..c12e77ba 100644 --- a/LEGO1/lego/legoomni/include/legoworld.h +++ b/LEGO1/lego/legoomni/include/legoworld.h @@ -69,8 +69,6 @@ class LegoWorld : public LegoEntity { inline MxCoreSet& GetUnknown0xd0() { return m_set0xd0; } inline list& GetROIList() { return m_roiList; } - inline void SetScriptIndex(MxS32 p_scriptIndex) { m_scriptIndex = p_scriptIndex; } - MxBool PresentersPending(); void Remove(MxCore* p_object); void FUN_1001fc80(IslePathActor* p_actor); @@ -78,6 +76,8 @@ class LegoWorld : public LegoEntity { MxCore* Find(const char* p_class, const char* p_name); MxCore* Find(const MxAtomId& p_atom, MxS32 p_entityId); + inline void SetScriptIndex(MxS32 p_scriptIndex) { m_scriptIndex = p_scriptIndex; } + // SYNTHETIC: LEGO1 0x1001dee0 // LegoWorld::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/include/registrationbook.h b/LEGO1/lego/legoomni/include/registrationbook.h index c9628786..c941ce5c 100644 --- a/LEGO1/lego/legoomni/include/registrationbook.h +++ b/LEGO1/lego/legoomni/include/registrationbook.h @@ -1,7 +1,10 @@ #ifndef REGISTRATIONBOOK_H #define REGISTRATIONBOOK_H +#include "jukebox.h" #include "legoworld.h" +#include "mxcontrolpresenter.h" +#include "mxstillpresenter.h" class InfocenterState; class MxEndActionNotificationParam; @@ -35,29 +38,31 @@ class RegistrationBook : public LegoWorld { MxBool VTable0x64() override; // vtable+0x64 void Enable(MxBool p_enable) override; // vtable+0x68 + inline void PlayAction(MxU32 p_objectId); + // SYNTHETIC: LEGO1 0x10076f30 // RegistrationBook::`scalar deleting destructor' private: - undefined4 m_unk0xf8; // 0xf8 - undefined m_unk0xfc; // 0xfc - undefined m_unk0xfd[3]; // 0xfd - undefined m_unk0x100[0x68]; // 0x100 - undefined m_unk0x168[0x118]; // 0x168 + undefined4 m_unk0xf8; // 0xf8 + undefined m_unk0xfc; // 0xfc + undefined m_unk0xfd[3]; // 0xfd + MxStillPresenter* m_alphabet[26]; // 0x100 + MxStillPresenter* m_name[10][7]; // 0x168 struct { - undefined4 m_unk0x00[3]; // 0x00 - undefined2 m_unk0x0c; // 0x0c - undefined2 m_unk0x0e; // 0x0e - } m_unk0x280; // 0x280 - undefined m_unk0x290[0x28]; // 0x290 - undefined2 m_unk0x2b8; // 0x2b8 - InfocenterState* m_infocenterState; // 0x2bc - undefined m_unk0x2c0; // 0x2c0 - undefined m_unk0x2c1; // 0x2c1 - undefined m_unk0x2c2[0x02]; // 0x2c2 - undefined4 m_unk0x2c4; // 0x2c4 - undefined4 m_unk0x2c8; // 0x2c8 - undefined4 m_unk0x2cc; // 0x2cc + undefined4 m_unk0x00[3]; // 0x00 + undefined2 m_unk0x0c; // 0x0c + undefined2 m_unk0x0e; // 0x0e + } m_unk0x280; // 0x280 + MxControlPresenter* m_checkmark[10]; // 0x290 + undefined2 m_unk0x2b8; // 0x2b8 + InfocenterState* m_infocenterState; // 0x2bc + undefined m_unk0x2c0; // 0x2c0 + undefined m_unk0x2c1; // 0x2c1 + undefined m_unk0x2c2[0x02]; // 0x2c2 + undefined4 m_unk0x2c4; // 0x2c4 + undefined4 m_unk0x2c8; // 0x2c8 + undefined4 m_unk0x2cc; // 0x2cc MxLong HandleEndAction(MxEndActionNotificationParam& p_param); MxLong HandleKeyPress(MxS8 p_key); diff --git a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp index 35bfb3dc..6d168637 100644 --- a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp +++ b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp @@ -4,24 +4,30 @@ #include "legocontrolmanager.h" #include "legogamestate.h" #include "legoinputmanager.h" +#include "legoomni.h" #include "misc.h" #include "mxactionnotificationparam.h" +#include "mxbackgroundaudiomanager.h" #include "mxmisc.h" #include "mxnotificationmanager.h" #include "mxtimer.h" +#include "regbook_actions.h" DECOMP_SIZE_ASSERT(RegistrationBook, 0x2d0) +// GLOBAL: LEGO1 0x100d9924 +const char* g_infoman = "infoman"; + // FUNCTION: LEGO1 0x10076d20 RegistrationBook::RegistrationBook() : m_unk0xf8(0x80000000), m_unk0xfc(1) { - memset(m_unk0x100, 0, sizeof(m_unk0x100)); - memset(m_unk0x168, 0, sizeof(m_unk0x168)); + memset(m_alphabet, 0, sizeof(m_alphabet)); + memset(m_name, 0, sizeof(m_name)); - // Maybe not be part of the struct, but then it would need packing + // May not be part of the struct, but then it would need packing m_unk0x280.m_unk0x0e = 0; - memset(m_unk0x290, 0, sizeof(m_unk0x290)); + memset(m_checkmark, 0, sizeof(m_checkmark)); memset(&m_unk0x280, -1, sizeof(m_unk0x280) - 2); m_unk0x2b8 = 0; @@ -45,6 +51,7 @@ RegistrationBook::~RegistrationBook() MxResult RegistrationBook::Create(MxDSAction& p_dsAction) { MxResult result = LegoWorld::Create(p_dsAction); + if (result == SUCCESS) { InputManager()->SetWorld(this); ControlManager()->Register(this); @@ -56,6 +63,7 @@ MxResult RegistrationBook::Create(MxDSAction& p_dsAction) m_infocenterState = (InfocenterState*) GameState()->GetState("InfocenterState"); } + return result; } @@ -110,10 +118,77 @@ MxLong RegistrationBook::HandleClick(LegoControlManagerEvent& p_param) return 0; } -// STUB: LEGO1 0x10077cc0 +// FUNCTION: LEGO1 0x10077cc0 void RegistrationBook::ReadyWorld() { - // TODO + LegoGameState* gameState = GameState(); + gameState->GetHistory()->WriteScoreHistory(); + MxS16 i; + + PlayMusic(JukeboxScript::c_InformationCenter_Music); + + char letterBuffer[] = "A_Bitmap"; + for (i = 0; i < 26; i++) { + m_alphabet[i] = (MxStillPresenter*) Find("MxStillPresenter", letterBuffer); + + // We need to loop through the entire alphabet, + // so increment the first char of the bitmap name + letterBuffer[0]++; + } + + // Now we have to do the checkmarks + char checkmarkBuffer[] = "Check0_Ctl"; + for (i = 0; i < 10; i++) { + m_checkmark[i] = (MxControlPresenter*) Find("MxControlPresenter", checkmarkBuffer); + + // Just like in the prior letter loop, + // we need to increment the fifth char + // to get the next checkmark bitmap + checkmarkBuffer[5]++; + } + + LegoGameState::Username* players = GameState()->m_players; + + for (i = 1; i <= GameState()->m_playerCount; i++) { + for (MxS16 j = 0; j < 7; j++) { + if (players[i - 1].m_letters[j] != -1) { + if (j == 0) { + m_checkmark[i]->Enable(TRUE); + } + + // Start building the player names using a two-dimensional array + m_name[i][j] = m_alphabet[players[i - 1].m_letters[j]]->Clone(); + + // Enable the presenter to actually show the letter in the grid + m_name[i][j]->Enable(TRUE); + + m_name[i][j]->SetTickleState(MxPresenter::e_repeating); + m_name[i][j]->SetPosition(23 * j + 343, 27 * i + 121); + } + } + } + + if (m_infocenterState->HasRegistered()) { + PlayAction(RegbookScript::c_iic008in_PlayWav); + + LegoROI* infoman = FindROI(g_infoman); + if (infoman != NULL) { + infoman->SetUnknown0x0c(0); + } + } + else { + PlayAction(RegbookScript::c_iic006in_RunAnim); + } +} + +inline void RegistrationBook::PlayAction(MxU32 p_objectId) +{ + MxDSAction action; + action.SetAtomId(*g_regbookScript); + action.SetObjectId(p_objectId); + + BackgroundAudioManager()->LowerVolume(); + Start(&action); } // STUB: LEGO1 0x10077fd0 @@ -154,6 +229,6 @@ MxLong RegistrationBook::HandleNotification19(MxParam& p_param) // FUNCTION: LEGO1 0x100783e0 MxBool RegistrationBook::VTable0x64() { - DeleteObjects(&m_atom, 500, 506); + DeleteObjects(&m_atom, RegbookScript::c_iic006in_RunAnim, RegbookScript::c_iic008in_PlayWav); return TRUE; } diff --git a/LEGO1/omni/include/mxdisplaysurface.h b/LEGO1/omni/include/mxdisplaysurface.h index 4e107f60..61b35eec 100644 --- a/LEGO1/omni/include/mxdisplaysurface.h +++ b/LEGO1/omni/include/mxdisplaysurface.h @@ -92,7 +92,7 @@ class MxDisplaySurface : public MxCore { void ClearScreen(); static LPDIRECTDRAWSURFACE CreateCursorSurface(); - static LPDIRECTDRAWSURFACE FUN_100bbfb0(LPDIRECTDRAWSURFACE p_und); + static LPDIRECTDRAWSURFACE CopySurface(LPDIRECTDRAWSURFACE p_src); inline LPDIRECTDRAWSURFACE GetDirectDrawSurface1() { return this->m_ddSurface1; } inline LPDIRECTDRAWSURFACE GetDirectDrawSurface2() { return this->m_ddSurface2; } diff --git a/LEGO1/omni/src/video/mxdisplaysurface.cpp b/LEGO1/omni/src/video/mxdisplaysurface.cpp index c599b131..a4bd9947 100644 --- a/LEGO1/omni/src/video/mxdisplaysurface.cpp +++ b/LEGO1/omni/src/video/mxdisplaysurface.cpp @@ -701,11 +701,30 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44( return surface; } -// STUB: LEGO1 0x100bbfb0 -LPDIRECTDRAWSURFACE MxDisplaySurface::FUN_100bbfb0(LPDIRECTDRAWSURFACE p_und) +// FUNCTION: LEGO1 0x100bbfb0 +LPDIRECTDRAWSURFACE MxDisplaySurface::CopySurface(LPDIRECTDRAWSURFACE p_src) { - // TODO - return NULL; + LPDIRECTDRAWSURFACE newSurface = NULL; + IDirectDraw* draw = MVideoManager()->GetDirectDraw(); + + DDSURFACEDESC ddsd; + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + + p_src->GetSurfaceDesc(&ddsd); + + if (draw->CreateSurface(&ddsd, &newSurface, NULL) != DD_OK) { + return NULL; + } + + RECT rect = {0, 0, (LONG) ddsd.dwWidth, (LONG) ddsd.dwHeight}; + + if (newSurface->BltFast(0, 0, p_src, &rect, 16) != DD_OK) { + newSurface->Release(); + return NULL; + } + + return newSurface; } // FUNCTION: LEGO1 0x100bc070 diff --git a/LEGO1/omni/src/video/mxstillpresenter.cpp b/LEGO1/omni/src/video/mxstillpresenter.cpp index 4093dabe..3908aadb 100644 --- a/LEGO1/omni/src/video/mxstillpresenter.cpp +++ b/LEGO1/omni/src/video/mxstillpresenter.cpp @@ -231,7 +231,7 @@ MxStillPresenter* MxStillPresenter::Clone() if (presenter) { if (presenter->AddToManager() == SUCCESS) { - MxDSAction* action = presenter->GetAction()->Clone(); + MxDSAction* action = GetAction()->Clone(); if (action && presenter->StartAction(NULL, action) == SUCCESS) { presenter->SetBit0(GetBit0()); @@ -249,7 +249,7 @@ MxStillPresenter* MxStillPresenter::Clone() } if (m_unk0x58) { - presenter->m_unk0x58 = MxDisplaySurface::FUN_100bbfb0(m_unk0x58); + presenter->m_unk0x58 = MxDisplaySurface::CopySurface(m_unk0x58); } if (m_alpha) {