Implement HistoryBook::ReadyWorld (#579)

* Implement HistoryBook::ReadyWorld

* Fix names and annotations

* WIP improvements

* Remove unnecessary padding/pack

* Remove packing

* Style

* Use countof

* Fix signed

* Fixes

* Remove duplicate annotation

* Rename

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Nathan M Gilbert
2024-02-19 09:24:30 -05:00
committed by GitHub
parent dbb2acf71c
commit cc1bc148d0
7 changed files with 136 additions and 29 deletions

View File

@@ -15,8 +15,9 @@
#include <stdio.h>
// Based on the highest dword offset (0x42c) referenced in the constructor.
// There may be other members that come after.
DECOMP_SIZE_ASSERT(LegoGameState::ScoreName, 0xe)
DECOMP_SIZE_ASSERT(LegoGameState::ScoreItem, 0x2c)
DECOMP_SIZE_ASSERT(LegoGameState::Scores, 0x372)
DECOMP_SIZE_ASSERT(LegoGameState, 0x430)
// GLOBAL: LEGO1 0x100f3e40
@@ -687,14 +688,21 @@ void LegoGameState::RegisterState(LegoState* p_state)
m_stateArray[targetIndex] = p_state;
}
// FUNCTION: LEGO1 0x1003c710
LegoGameState::ScoreName* LegoGameState::ScoreName::operator=(const ScoreName* p_other)
{
memcpy(m_letters, p_other->m_letters, sizeof(m_letters));
return this;
}
// STUB: LEGO1 0x1003c870
void LegoGameState::ScoreStruct::WriteScoreHistory()
void LegoGameState::Scores::WriteScoreHistory()
{
// TODO
}
// STUB: LEGO1 0x1003ccf0
void LegoGameState::ScoreStruct::FUN_1003ccf0(LegoFile&)
void LegoGameState::Scores::FUN_1003ccf0(LegoFile&)
{
// TODO
}

View File

@@ -111,7 +111,7 @@ MxResult Infocenter::Create(MxDSAction& p_dsAction)
if (m_infocenterState->GetNameLetter(i)) {
m_infocenterState->GetNameLetter(i)->Enable(TRUE);
m_infocenterState->GetNameLetter(i)->SetTickleState(MxPresenter::e_repeating);
m_infocenterState->GetNameLetter(i)->VTable0x88(((7 - count) / 2 + i) * 29 + 223, 45);
m_infocenterState->GetNameLetter(i)->SetPosition(((7 - count) / 2 + i) * 29 + 223, 45);
}
}
}
@@ -596,12 +596,12 @@ MxU8 Infocenter::HandleMouseMove(MxS32 p_x, MxS32 p_y)
m_unk0x11c->SetDisplayZ(1000);
VideoManager()->SortPresenterList();
m_unk0x11c->Enable(TRUE);
m_unk0x11c->VTable0x88(p_x, p_y);
m_unk0x11c->SetPosition(p_x, p_y);
m_unk0x11c->SetDisplayZ(oldDisplayZ);
}
else {
m_unk0x11c->VTable0x88(p_x, p_y);
m_unk0x11c->SetPosition(p_x, p_y);
}
FUN_10070d10(p_x, p_y);
@@ -1259,7 +1259,7 @@ void Infocenter::UpdateFrameHot(MxBool p_display)
VideoManager()->SortPresenterList();
m_frameHotBitmap->Enable(TRUE);
m_frameHotBitmap->VTable0x88(x, y);
m_frameHotBitmap->SetPosition(x, y);
m_frameHotBitmap->SetDisplayZ(originalDisplayZ);
}
else {

View File

@@ -1,5 +1,6 @@
#include "historybook.h"
#include "jukebox.h"
#include "legocontrolmanager.h"
#include "legoinputmanager.h"
#include "legoomni.h"
@@ -12,9 +13,9 @@ DECOMP_SIZE_ASSERT(HistoryBook, 0x3e4)
// FUNCTION: LEGO1 0x100822f0
HistoryBook::HistoryBook()
{
memset(m_unk0xfc, NULL, sizeof(m_unk0xfc));
memset(m_unk0x164, NULL, sizeof(m_unk0x164));
memset(m_unk0x394, NULL, sizeof(m_unk0x394));
memset(m_alphabet, NULL, sizeof(m_alphabet));
memset(m_names, NULL, sizeof(m_names));
memset(m_scores, NULL, sizeof(m_scores));
NotificationManager()->Register(this);
}
@@ -61,10 +62,88 @@ MxLong HistoryBook::Notify(MxParam& p_param)
return 0;
}
// STUB: LEGO1 0x100826f0
inline void SetColor(MxStillPresenter* p_presenter, MxU8 p_color, MxU8* p_colors, MxU32 p_x, MxU32 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
void HistoryBook::ReadyWorld()
{
// TODO
LegoWorld::ReadyWorld();
GameState()->GetScores()->WriteScoreHistory();
char bitmap[] = "A_Bitmap";
for (MxS16 i = 0; i < 26; i++) {
m_alphabet[i] = (MxStillPresenter*) Find("MxStillPresenter", bitmap);
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()->GetScores()->m_count; scoreIndex++) {
LegoGameState::ScoreItem* score = GameState()->GetScores()->GetScore(scoreIndex);
MxStillPresenter** scorebox = &m_scores[scoreIndex];
*scorebox = scoreboxMaster->Clone();
MxS32 scoreX = 0x90;
if (scoreIndex >= 10) {
if (scoreIndex == 10) {
scoreY = 0x79;
}
scoreX = 0x158;
}
MxS32 scoreboxX = 1;
MxS32 scoreboxRow = 5;
MxU8* scoreState = score->m_state;
for (; scoreboxRow > 0; scoreboxRow--) {
for (MxS32 scoreBoxColumn = 0, scoreboxY = 1; scoreBoxColumn < 5; scoreBoxColumn++, scoreboxY += 5) {
SetColor(*scorebox, scoreState[scoreBoxColumn], scoreColors, scoreboxX, scoreboxY);
}
scoreState += 5;
scoreboxX += 5;
}
(*scorebox)->Enable(TRUE);
(*scorebox)->SetTickleState(MxPresenter::e_repeating);
(*scorebox)->SetPosition(scoreX + 0xa1, scoreY);
for (MxS16 letterIndex = 0; letterIndex < (MxS16) _countof(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;
}
scoreY += 0x1b;
}
PlayMusic(JukeBox::e_informationCenter);
}
// FUNCTION: LEGO1 0x10082a10