Some progress on HistoryBook::ReadyWorld

This commit is contained in:
jonschz 2025-01-24 10:50:19 +01:00
parent 99befafff2
commit cc6423603e
5 changed files with 51 additions and 22 deletions

View File

@ -41,8 +41,11 @@ class HistoryBook : public LegoWorld {
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 @@ class LegoGameState {
// 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 0x1002c54
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

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;
} }
} }
} }
@ -104,14 +104,19 @@ inline void SetColor(MxStillPresenter* p_presenter, MxU8 p_color, MxU8* p_colors
} }
// FUNCTION: LEGO1 0x100826f0 // FUNCTION: LEGO1 0x100826f0
// FUNCTION: BETA10 0x1002b9b9
void HistoryBook::ReadyWorld() void HistoryBook::ReadyWorld()
{ {
LegoWorld::ReadyWorld(); LegoWorld::ReadyWorld();
// TODO: No GetHistory() in between for BETA10 - check order / alignment for WriteScoreHistory
GameState()->GetHistory()->WriteScoreHistory(); GameState()->GetHistory()->WriteScoreHistory();
char bitmap[] = "A_Bitmap"; char bitmap[] = "A_Bitmap";
for (MxS16 i = 0; i < 26; i++) { MxS16 i = 0;
for (; i < 26; i++) {
m_alphabet[i] = (MxStillPresenter*) Find("MxStillPresenter", bitmap); m_alphabet[i] = (MxStillPresenter*) Find("MxStillPresenter", bitmap);
assert(m_alphabet[i]);
bitmap[0]++; bitmap[0]++;
} }
@ -120,15 +125,15 @@ void HistoryBook::ReadyWorld()
{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; MxS32 scoreY = 0x79;
for (MxS16 scoreIndex = 0; scoreIndex < GameState()->GetHistory()->m_count; scoreIndex++) { for (i = 0; i < GameState()->GetHistory()->GetCount(); i++) {
LegoGameState::ScoreItem* score = GameState()->GetHistory()->GetScore(scoreIndex); LegoGameState::ScoreItem* score = GameState()->GetHistory()->GetScore(i);
MxStillPresenter** scorebox = &m_scores[scoreIndex]; MxStillPresenter** scorebox = &m_scores[i];
*scorebox = scoreboxMaster->Clone(); *scorebox = scoreboxMaster->Clone();
MxS32 scoreX = 0x90; MxS32 scoreX = 0x90;
if (scoreIndex >= 10) { if (i >= 10) {
if (scoreIndex == 10) { if (i == 10) {
scoreY = 0x79; scoreY = 0x79;
} }
@ -141,7 +146,19 @@ void HistoryBook::ReadyWorld()
for (; scoreboxRow > 0; scoreboxRow--) { 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); // SetColor(*scorebox, score->m_scores[scoreState][scoreBoxColumn], scoreColors, scoreboxX, scoreboxY);
// inline void SetColor(MxStillPresenter* p_presenter, MxU8 p_color, MxU8* p_colors, MxS32 p_x, MxS32 p_y)
MxU8 color = score->m_scores[scoreState][scoreBoxColumn];
if (color) {
for (MxS32 lax = 0; lax < 4; lax++) {
if ((*scorebox)->GetAlphaMask() != NULL) {
memset(NULL, scoreColors[color - 1], 4);
}
else {
memset((*scorebox)->GetBitmap()->GetStart(scoreboxX, scoreboxY + lax), scoreColors[color - 1], 4);
}
}
}
} }
scoreState++; scoreState++;
@ -152,18 +169,20 @@ void HistoryBook::ReadyWorld()
(*scorebox)->SetTickleState(MxPresenter::e_repeating); (*scorebox)->SetTickleState(MxPresenter::e_repeating);
(*scorebox)->SetPosition(scoreX + 0xa1, scoreY); (*scorebox)->SetPosition(scoreX + 0xa1, scoreY);
for (MxS16 letterIndex = 0; letterIndex < (MxS16) sizeOfArray(m_names[0]);) { for (MxS16 letterIndex = 0; letterIndex < (MxS16) sizeOfArray(m_name[0]);) {
MxS16 letter = score->m_name.m_letters[letterIndex]; MxS16 letter = score->m_name.m_letters[letterIndex];
if (letter == -1) { if (letter == -1) {
break; break;
} }
MxS16 nameIndex = letterIndex++; MxS16 j = letterIndex++;
m_names[scoreIndex][nameIndex] = m_alphabet[letter]->Clone();
m_names[scoreIndex][nameIndex]->Enable(TRUE); assert(m_name[i][j]);
m_names[scoreIndex][nameIndex]->SetTickleState(MxPresenter::e_repeating); m_name[i][j] = m_alphabet[letter]->Clone();
m_names[scoreIndex][nameIndex]->SetPosition(scoreX, scoreY); m_name[i][j]->Enable(TRUE);
m_name[i][j]->SetTickleState(MxPresenter::e_repeating);
m_name[i][j]->SetPosition(scoreX, scoreY);
scoreX += 0x17; scoreX += 0x17;
} }

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

@ -34,3 +34,5 @@ targets:
- 0x100f8ad0 - 0x100f8ad0
- 0x100fa200 - 0x100fa200
- 0x100f9780 - 0x100f9780
# memset etc.
- 0x100f9570