Match HistoryBook::ReadyWorld() (#1373)

* Some progress on HistoryBook::ReadyWorld

* Refactor getter

* 48 %

* 49 %

* 53 %

* Improve BETA10 stack, LEGO1 now at 91

* variable number match on BETA10, 91 % on LEGO1

* Cleanup

* Match

---------

Co-authored-by: jonschz <jonschz@users.noreply.github.com>
Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
jonschz 2025-01-25 00:09:04 +01:00 committed by GitHub
parent 99befafff2
commit 82f2e2e755
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 81 additions and 62 deletions

View File

@ -41,8 +41,11 @@ public:
private: private:
LegoGameState::Area m_destLocation; // 0xf8 LegoGameState::Area m_destLocation; // 0xf8
MxStillPresenter* m_alphabet[26]; // 0xfc 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 #endif // HISTORYBOOK_H

View File

@ -163,7 +163,9 @@ public:
// FUNCTION: BETA10 0x1002c2b0 // FUNCTION: BETA10 0x1002c2b0
MxS16 GetCount() { return m_count; } 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 MxS16 m_count; // 0x00
ScoreItem m_scores[20]; // 0x02 ScoreItem m_scores[20]; // 0x02
@ -206,7 +208,6 @@ public:
Act GetLoadedAct() { return m_loadedAct; } Act GetLoadedAct() { return m_loadedAct; }
Area GetPreviousArea() { return m_previousArea; } Area GetPreviousArea() { return m_previousArea; }
Area GetUnknown0x42c() { return m_unk0x42c; } Area GetUnknown0x42c() { return m_unk0x42c; }
History* GetHistory() { return &m_history; }
void SetDirty(MxBool p_isDirty) { m_isDirty = p_isDirty; } void SetDirty(MxBool p_isDirty) { m_isDirty = p_isDirty; }
void SetPreviousArea(Area p_previousArea) { m_previousArea = p_previousArea; } void SetPreviousArea(Area p_previousArea) { m_previousArea = p_previousArea; }

View File

@ -16,7 +16,7 @@ DECOMP_SIZE_ASSERT(HistoryBook, 0x3e4)
HistoryBook::HistoryBook() HistoryBook::HistoryBook()
{ {
memset(m_alphabet, 0, sizeof(m_alphabet)); 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)); memset(m_scores, 0, sizeof(m_scores));
NotificationManager()->Register(this); NotificationManager()->Register(this);
} }
@ -32,11 +32,11 @@ HistoryBook::~HistoryBook()
m_scores[scoreIndex] = NULL; m_scores[scoreIndex] = NULL;
} }
for (MxS16 letterIndex = 0; letterIndex < (MxS16) sizeOfArray(m_names[0]); letterIndex++) { for (MxS16 letterIndex = 0; letterIndex < (MxS16) sizeOfArray(m_name[0]); letterIndex++) {
if (m_names[scoreIndex][letterIndex]) { if (m_name[scoreIndex][letterIndex]) {
delete m_names[scoreIndex][letterIndex]->GetAction(); delete m_name[scoreIndex][letterIndex]->GetAction();
delete m_names[scoreIndex][letterIndex]; delete m_name[scoreIndex][letterIndex];
m_names[scoreIndex][letterIndex] = NULL; m_name[scoreIndex][letterIndex] = NULL;
} }
} }
} }
@ -89,88 +89,94 @@ MxLong HistoryBook::Notify(MxParam& p_param)
return 0; 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: LEGO1 0x100826f0
// FUNCTION: BETA10 0x1002b9b9
void HistoryBook::ReadyWorld() void HistoryBook::ReadyWorld()
{ {
undefined2 dummy1 = 0x90, dummy2 = 0x79, dummy3 = 0xc8, dummy4 = 0x17, dummy5 = 0x1b;
#ifndef BETA10
LegoWorld::ReadyWorld(); LegoWorld::ReadyWorld();
GameState()->GetHistory()->WriteScoreHistory(); #endif
GameState()->m_history.WriteScoreHistory();
char bitmap[] = "A_Bitmap"; char bitmap[] = "A_Bitmap";
for (MxS16 i = 0; i < 26; i++) { MxS16 i;
m_alphabet[i] = (MxStillPresenter*) Find("MxStillPresenter", bitmap);
bitmap[0]++; 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"); MxStillPresenter* scoreboxMaster = (MxStillPresenter*) Find("MxStillPresenter", "ScoreBox");
MxU8 scoreColors[3] = MxU8 scoreColors[3] =
{0x76, 0x4c, 0x38}; // yellow - #FFB900, blue - #00548C, red - #CB1220, background - #CECECE, border - #74818B {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++) { MxS32 scoreY;
LegoGameState::ScoreItem* score = GameState()->GetHistory()->GetScore(scoreIndex);
MxStillPresenter** scorebox = &m_scores[scoreIndex]; for (i = 0, scoreY = 0x79; i < GameState()->m_history.GetCount(); i++, scoreY += 0x1b) {
*scorebox = scoreboxMaster->Clone(); LegoGameState::ScoreItem* score = GameState()->m_history.GetScore(i);
m_scores[i] = scoreboxMaster->Clone();
MxS32 scoreX = 0x90; MxS32 scoreX = 0x90;
if (scoreIndex >= 10) { if (i >= 10) {
if (scoreIndex == 10) { if (i == 10) {
scoreY = 0x79; scoreY = 0x79;
} }
scoreX = 0x158; scoreX = 0x158;
} }
MxS32 scoreboxX = 1; for (MxS32 scoreState = 0, scoreboxX = 1; scoreState < 5; scoreState++, scoreboxX += 5) {
MxS32 scoreboxRow = 5;
MxS32 scoreState = 0;
for (; scoreboxRow > 0; scoreboxRow--) {
for (MxS32 scoreBoxColumn = 0, scoreboxY = 1; scoreBoxColumn < 5; scoreBoxColumn++, scoreboxY += 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];
}
scoreState++; if (color > 0) {
scoreboxX += 5; 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
}
}
}
} }
(*scorebox)->Enable(TRUE); m_scores[i]->Enable(TRUE);
(*scorebox)->SetTickleState(MxPresenter::e_repeating); m_scores[i]->SetTickleState(MxPresenter::e_repeating);
(*scorebox)->SetPosition(scoreX + 0xa1, scoreY); m_scores[i]->SetPosition(scoreX + 0xa1, scoreY);
for (MxS16 letterIndex = 0; letterIndex < (MxS16) sizeOfArray(m_names[0]);) { #ifdef BETA10
MxS16 letter = score->m_name.m_letters[letterIndex]; 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();
if (letter == -1) { assert(m_name[i][j]);
break; m_name[i][j]->Enable(TRUE);
} m_name[i][j]->SetTickleState(MxPresenter::e_repeating);
m_name[i][j]->SetPosition(scoreX, scoreY);
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;
} }
#ifndef BETA10
PlayMusic(JukeboxScript::c_InformationCenter_Music); PlayMusic(JukeboxScript::c_InformationCenter_Music);
#endif
} }
// FUNCTION: LEGO1 0x10082a10 // FUNCTION: LEGO1 0x10082a10

View File

@ -391,7 +391,7 @@ void RegistrationBook::FUN_100778c0()
void RegistrationBook::ReadyWorld() void RegistrationBook::ReadyWorld()
{ {
LegoGameState* gameState = GameState(); LegoGameState* gameState = GameState();
gameState->GetHistory()->WriteScoreHistory(); gameState->m_history.WriteScoreHistory();
MxS16 i; MxS16 i;
PlayMusic(JukeboxScript::c_InformationCenter_Music); PlayMusic(JukeboxScript::c_InformationCenter_Music);

View File

@ -702,6 +702,9 @@
// LIBRARY: BETA10 0x100f9420 // LIBRARY: BETA10 0x100f9420
// memcpy // memcpy
// LIBRARY: BETA10 0x100faa00
// memcmp
// LIBRARY: BETA10 0x100fb080 // LIBRARY: BETA10 0x100fb080
// _stricmp // _stricmp

View File

@ -104,6 +104,9 @@ public:
MxBitmap* GetBitmap() { return m_frameBitmap; } MxBitmap* GetBitmap() { return m_frameBitmap; }
AlphaMask* GetAlphaMask() { return m_alpha; } 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 SetBit0(BOOL p_e) { m_flags.m_bit0 = p_e; }
void SetBit1(BOOL p_e) { m_flags.m_bit1 = p_e; } void SetBit1(BOOL p_e) { m_flags.m_bit1 = p_e; }
void SetBit2(BOOL p_e) { m_flags.m_bit2 = p_e; } void SetBit2(BOOL p_e) { m_flags.m_bit2 = p_e; }

View File

@ -24,6 +24,7 @@ targets:
# these classes have been changed by hand to account for changes between LEGO1 and BETA10 # these classes have been changed by hand to account for changes between LEGO1 and BETA10
- Act2Actor - Act2Actor
- Act2Brick - Act2Brick
- HistoryBook
- LegoAct2 - LegoAct2
- LegoCarBuild - LegoCarBuild
- LegoCarBuildAnimPresenter - LegoCarBuildAnimPresenter
@ -34,3 +35,5 @@ targets:
- 0x100f8ad0 - 0x100f8ad0
- 0x100fa200 - 0x100fa200
- 0x100f9780 - 0x100f9780
# memset etc.
- 0x100f9570