implement RegistrationBook::ReadyWorld(), impl/match MxDisplaySurface::CopySurface() (#678)

* implement RegistrationBook::ReadyWorld()

* don't fix the size of letterBuffer

* Fix crash in MxStillPresenter::Clone

* Implement MxDisplaySurface::CopySurface

100% match

* improve accuracy

* invert HasRegistered check

* fix legogamestate structure, documentation tweaks

* this might be cleaner actually

* Update mxdisplaysurface.cpp

* Update legogamestate.h

* don't hardcode action ids in VTable0x64

* Match ~98%

---------

Co-authored-by: Misha <106913236+MishaProductions@users.noreply.github.com>
Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Ramen2X
2024-03-15 21:32:06 -04:00
committed by GitHub
parent d07d7edc81
commit 6cd5ffcf1a
8 changed files with 170 additions and 63 deletions

View File

@@ -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;
}