diff --git a/LEGO1/lego/legoomni/include/historybook.h b/LEGO1/lego/legoomni/include/historybook.h index 38f174a00a..76912d5dc3 100644 --- a/LEGO1/lego/legoomni/include/historybook.h +++ b/LEGO1/lego/legoomni/include/historybook.h @@ -41,8 +41,11 @@ class HistoryBook : public LegoWorld { private: LegoGameState::Area m_destLocation; // 0xf8 MxStillPresenter* m_alphabet[26]; // 0xfc - MxStillPresenter* m_names[20][7]; // 0x164 - MxStillPresenter* m_scores[20]; // 0x394 + + // variable name verified by BETA10 0x1002bd27 + MxStillPresenter* m_name[20][7]; // 0x164 + + MxStillPresenter* m_scores[20]; // 0x394 }; #endif // HISTORYBOOK_H diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h index dc1e6a97c3..291e58d045 100644 --- a/LEGO1/lego/legoomni/include/legogamestate.h +++ b/LEGO1/lego/legoomni/include/legogamestate.h @@ -163,7 +163,9 @@ class LegoGameState { // FUNCTION: BETA10 0x1002c2b0 MxS16 GetCount() { return m_count; } - ScoreItem* GetScore(MxS16 p_index) { return p_index >= m_count ? NULL : &m_scores[p_index]; } + // TODO: Not yet correct + // FUNCTION: BETA10 0x1002c540 + ScoreItem* GetScore(MxS32 p_index) { return p_index >= m_count ? NULL : &m_scores[p_index]; } MxS16 m_count; // 0x00 ScoreItem m_scores[20]; // 0x02 @@ -206,7 +208,6 @@ class LegoGameState { Act GetLoadedAct() { return m_loadedAct; } Area GetPreviousArea() { return m_previousArea; } Area GetUnknown0x42c() { return m_unk0x42c; } - History* GetHistory() { return &m_history; } void SetDirty(MxBool p_isDirty) { m_isDirty = p_isDirty; } void SetPreviousArea(Area p_previousArea) { m_previousArea = p_previousArea; } diff --git a/LEGO1/lego/legoomni/src/worlds/historybook.cpp b/LEGO1/lego/legoomni/src/worlds/historybook.cpp index cf32582580..b3df73d571 100644 --- a/LEGO1/lego/legoomni/src/worlds/historybook.cpp +++ b/LEGO1/lego/legoomni/src/worlds/historybook.cpp @@ -16,7 +16,7 @@ DECOMP_SIZE_ASSERT(HistoryBook, 0x3e4) HistoryBook::HistoryBook() { memset(m_alphabet, 0, sizeof(m_alphabet)); - memset(m_names, 0, sizeof(m_names)); + memset(m_name, 0, sizeof(m_name)); memset(m_scores, 0, sizeof(m_scores)); NotificationManager()->Register(this); } @@ -32,11 +32,11 @@ HistoryBook::~HistoryBook() m_scores[scoreIndex] = NULL; } - for (MxS16 letterIndex = 0; letterIndex < (MxS16) sizeOfArray(m_names[0]); letterIndex++) { - if (m_names[scoreIndex][letterIndex]) { - delete m_names[scoreIndex][letterIndex]->GetAction(); - delete m_names[scoreIndex][letterIndex]; - m_names[scoreIndex][letterIndex] = NULL; + for (MxS16 letterIndex = 0; letterIndex < (MxS16) sizeOfArray(m_name[0]); letterIndex++) { + if (m_name[scoreIndex][letterIndex]) { + delete m_name[scoreIndex][letterIndex]->GetAction(); + delete m_name[scoreIndex][letterIndex]; + m_name[scoreIndex][letterIndex] = NULL; } } } @@ -89,88 +89,94 @@ MxLong HistoryBook::Notify(MxParam& p_param) return 0; } -inline void SetColor(MxStillPresenter* p_presenter, MxU8 p_color, MxU8* p_colors, MxS32 p_x, MxS32 p_y) -{ - if (p_color) { - for (MxS32 lax = 0; lax < 4; lax++) { - if (p_presenter->GetAlphaMask() != NULL) { - memset(NULL, p_colors[p_color - 1], 4); - } - else { - memset(p_presenter->GetBitmap()->GetStart(p_x, p_y + lax), p_colors[p_color - 1], 4); - } - } - } -} - // FUNCTION: LEGO1 0x100826f0 +// FUNCTION: BETA10 0x1002b9b9 void HistoryBook::ReadyWorld() { + undefined2 dummy1 = 0x90, dummy2 = 0x79, dummy3 = 0xc8, dummy4 = 0x17, dummy5 = 0x1b; +#ifndef BETA10 LegoWorld::ReadyWorld(); - GameState()->GetHistory()->WriteScoreHistory(); +#endif + GameState()->m_history.WriteScoreHistory(); char bitmap[] = "A_Bitmap"; - for (MxS16 i = 0; i < 26; i++) { - m_alphabet[i] = (MxStillPresenter*) Find("MxStillPresenter", bitmap); - bitmap[0]++; + MxS16 i; + + for (i = 0; i < 26; i++) { + if (i < 26) { + m_alphabet[i] = (MxStillPresenter*) Find("MxStillPresenter", bitmap); + assert(m_alphabet[i]); + bitmap[0]++; + } } MxStillPresenter* scoreboxMaster = (MxStillPresenter*) Find("MxStillPresenter", "ScoreBox"); MxU8 scoreColors[3] = {0x76, 0x4c, 0x38}; // yellow - #FFB900, blue - #00548C, red - #CB1220, background - #CECECE, border - #74818B - MxS32 scoreY = 0x79; - for (MxS16 scoreIndex = 0; scoreIndex < GameState()->GetHistory()->m_count; scoreIndex++) { - LegoGameState::ScoreItem* score = GameState()->GetHistory()->GetScore(scoreIndex); + MxS32 scoreY; - MxStillPresenter** scorebox = &m_scores[scoreIndex]; - *scorebox = scoreboxMaster->Clone(); + for (i = 0, scoreY = 0x79; i < GameState()->m_history.GetCount(); i++, scoreY += 0x1b) { + LegoGameState::ScoreItem* score = GameState()->m_history.GetScore(i); + + m_scores[i] = scoreboxMaster->Clone(); MxS32 scoreX = 0x90; - if (scoreIndex >= 10) { - if (scoreIndex == 10) { + if (i >= 10) { + if (i == 10) { scoreY = 0x79; } scoreX = 0x158; } - MxS32 scoreboxX = 1; - MxS32 scoreboxRow = 5; - MxS32 scoreState = 0; - - for (; scoreboxRow > 0; scoreboxRow--) { + for (MxS32 scoreState = 0, scoreboxX = 1; scoreState < 5; scoreState++, scoreboxX += 5) { for (MxS32 scoreBoxColumn = 0, scoreboxY = 1; scoreBoxColumn < 5; scoreBoxColumn++, scoreboxY += 5) { - SetColor(*scorebox, score->m_scores[scoreState][scoreBoxColumn], scoreColors, scoreboxX, scoreboxY); + MxU8 color = score->m_scores[scoreState][scoreBoxColumn]; + + if (color > 0) { + for (MxS32 lax = 0; lax < 4; lax++) { +#ifdef BETA10 + memset(m_scores[i]->GetBitmapStart(scoreboxX, scoreboxY + lax), scoreColors[color - 1], 4); +#else + if (m_scores[i]->GetAlphaMask() != NULL) { + memset(NULL, scoreColors[color - 1], 4); + } + else { + memset( + m_scores[i]->GetBitmap()->GetStart(scoreboxX, lax + scoreboxY), + scoreColors[color - 1], + 4 + ); + } +#endif + } + } } - - scoreState++; - scoreboxX += 5; } - (*scorebox)->Enable(TRUE); - (*scorebox)->SetTickleState(MxPresenter::e_repeating); - (*scorebox)->SetPosition(scoreX + 0xa1, scoreY); - - for (MxS16 letterIndex = 0; letterIndex < (MxS16) sizeOfArray(m_names[0]);) { - MxS16 letter = score->m_name.m_letters[letterIndex]; - - if (letter == -1) { - break; - } - - MxS16 nameIndex = letterIndex++; - m_names[scoreIndex][nameIndex] = m_alphabet[letter]->Clone(); - m_names[scoreIndex][nameIndex]->Enable(TRUE); - m_names[scoreIndex][nameIndex]->SetTickleState(MxPresenter::e_repeating); - m_names[scoreIndex][nameIndex]->SetPosition(scoreX, scoreY); - scoreX += 0x17; + m_scores[i]->Enable(TRUE); + m_scores[i]->SetTickleState(MxPresenter::e_repeating); + m_scores[i]->SetPosition(scoreX + 0xa1, scoreY); + +#ifdef BETA10 + for (MxS16 j = 0; score->m_name.m_letters[j] != -1; j++, scoreX += 0x17) +#else + for (MxS16 j = 0; j < (MxS16) sizeOfArray(m_name[0]) && score->m_name.m_letters[j] != -1; j++, scoreX += 0x17) +#endif + { + m_name[i][j] = m_alphabet[score->m_name.m_letters[j]]->Clone(); + + assert(m_name[i][j]); + m_name[i][j]->Enable(TRUE); + m_name[i][j]->SetTickleState(MxPresenter::e_repeating); + m_name[i][j]->SetPosition(scoreX, scoreY); } - - scoreY += 0x1b; } +#ifndef BETA10 PlayMusic(JukeboxScript::c_InformationCenter_Music); +#endif } // FUNCTION: LEGO1 0x10082a10 diff --git a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp index 5ade0b3ae7..0e08113391 100644 --- a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp +++ b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp @@ -391,7 +391,7 @@ void RegistrationBook::FUN_100778c0() void RegistrationBook::ReadyWorld() { LegoGameState* gameState = GameState(); - gameState->GetHistory()->WriteScoreHistory(); + gameState->m_history.WriteScoreHistory(); MxS16 i; PlayMusic(JukeboxScript::c_InformationCenter_Music); diff --git a/LEGO1/library_msvc.h b/LEGO1/library_msvc.h index 82f3ae8780..2ae816e745 100644 --- a/LEGO1/library_msvc.h +++ b/LEGO1/library_msvc.h @@ -702,6 +702,9 @@ // LIBRARY: BETA10 0x100f9420 // memcpy +// LIBRARY: BETA10 0x100faa00 +// memcmp + // LIBRARY: BETA10 0x100fb080 // _stricmp diff --git a/LEGO1/omni/include/mxvideopresenter.h b/LEGO1/omni/include/mxvideopresenter.h index 907ddc0e54..a1794aec4a 100644 --- a/LEGO1/omni/include/mxvideopresenter.h +++ b/LEGO1/omni/include/mxvideopresenter.h @@ -104,6 +104,9 @@ class MxVideoPresenter : public MxMediaPresenter { MxBitmap* GetBitmap() { return m_frameBitmap; } AlphaMask* GetAlphaMask() { return m_alpha; } + // FUNCTION: BETA10 0x1002c2e0 + MxU8* GetBitmapStart(MxS32 p_left, MxS32 p_top) { return m_frameBitmap->GetStart(p_left, p_top); } + void SetBit0(BOOL p_e) { m_flags.m_bit0 = p_e; } void SetBit1(BOOL p_e) { m_flags.m_bit1 = p_e; } void SetBit2(BOOL p_e) { m_flags.m_bit2 = p_e; } diff --git a/reccmp-project.yml b/reccmp-project.yml index c614cdedce..009c737fdd 100644 --- a/reccmp-project.yml +++ b/reccmp-project.yml @@ -24,6 +24,7 @@ targets: # these classes have been changed by hand to account for changes between LEGO1 and BETA10 - Act2Actor - Act2Brick + - HistoryBook - LegoAct2 - LegoCarBuild - LegoCarBuildAnimPresenter @@ -34,3 +35,5 @@ targets: - 0x100f8ad0 - 0x100fa200 - 0x100f9780 + # memset etc. + - 0x100f9570