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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 170 additions and 63 deletions

View file

@ -76,35 +76,35 @@ enum Script {
c_Back_Down_Bitmap = 66, c_Back_Down_Bitmap = 66,
c_Info_Down_Bitmap = 67, c_Info_Down_Bitmap = 67,
c_Check0_Ctl = 68, c_Check0_Ctl = 68,
c_Check0_Bitmap = 69, c_Check0_Bitmap_69 = 69,
c_Check0_Bitmap = 70, c_Check0_Bitmap_70 = 70,
c_Check1_Ctl = 71, c_Check1_Ctl = 71,
c_Check1_Bitmap = 72, c_Check1_Bitmap_72 = 72,
c_Check1_Bitmap = 73, c_Check1_Bitmap_73 = 73,
c_Check2_Ctl = 74, c_Check2_Ctl = 74,
c_Check2_Bitmap = 75, c_Check2_Bitmap_75 = 75,
c_Check2_Bitmap = 76, c_Check2_Bitmap_76 = 76,
c_Check3_Ctl = 77, c_Check3_Ctl = 77,
c_Check3_Bitmap = 78, c_Check3_Bitmap_78 = 78,
c_Check3_Bitmap = 79, c_Check3_Bitmap_79 = 79,
c_Check4_Ctl = 80, c_Check4_Ctl = 80,
c_Check4_Bitmap = 81, c_Check4_Bitmap_81 = 81,
c_Check4_Bitmap = 82, c_Check4_Bitmap_82 = 82,
c_Check5_Ctl = 83, c_Check5_Ctl = 83,
c_Check5_Bitmap = 84, c_Check5_Bitmap_84 = 84,
c_Check5_Bitmap = 85, c_Check5_Bitmap_85 = 85,
c_Check6_Ctl = 86, c_Check6_Ctl = 86,
c_Check6_Bitmap = 87, c_Check6_Bitmap_87 = 87,
c_Check6_Bitmap = 88, c_Check6_Bitmap_88 = 88,
c_Check7_Ctl = 89, c_Check7_Ctl = 89,
c_Check7_Bitmap = 90, c_Check7_Bitmap_90 = 90,
c_Check7_Bitmap = 91, c_Check7_Bitmap_91 = 91,
c_Check8_Ctl = 92, c_Check8_Ctl = 92,
c_Check8_Bitmap = 93, c_Check8_Bitmap_93 = 93,
c_Check8_Bitmap = 94, c_Check8_Bitmap_94 = 94,
c_Check9_Ctl = 95, c_Check9_Ctl = 95,
c_Check9_Bitmap = 96, c_Check9_Bitmap_96 = 96,
c_Check9_Bitmap = 97, c_Check9_Bitmap_97 = 97,
c_ConfigAnimation = 98, c_ConfigAnimation = 98,
c_Chptr_Model = 99, c_Chptr_Model = 99,
c_DuneBugy_Model = 100, c_DuneBugy_Model = 100,

View file

@ -162,6 +162,8 @@ class LegoGameState {
inline void SetActorId(MxU8 p_actorId) { m_actorId = p_actorId; } inline void SetActorId(MxU8 p_actorId) { m_actorId = p_actorId; }
inline void SetUnknown0x41c(undefined4 p_unk0x41c) { m_unk0x41c = p_unk0x41c; } inline void SetUnknown0x41c(undefined4 p_unk0x41c) { m_unk0x41c = p_unk0x41c; }
inline void SetUnknown0x42c(Area p_unk0x42c) { m_unk0x42c = p_unk0x42c; } inline void SetUnknown0x42c(Area p_unk0x42c) { m_unk0x42c = p_unk0x42c; }
inline Username* GetPlayersIndex(MxS32 p_index) { return &m_players[p_index]; }
inline MxS16 GetPlayerCount() { return m_playerCount; }
void SetCurrentAct(Act p_currentAct); void SetCurrentAct(Act p_currentAct);
void FindLoadedAct(); void FindLoadedAct();
@ -184,8 +186,14 @@ class LegoGameState {
LegoBackgroundColor* m_tempBackgroundColor; // 0x1c LegoBackgroundColor* m_tempBackgroundColor; // 0x1c
LegoFullScreenMovie* m_fullScreenMovie; // 0x20 LegoFullScreenMovie* m_fullScreenMovie; // 0x20
MxU16 m_unk0x24; // 0x24 MxU16 m_unk0x24; // 0x24
// Member visibility needs to be refactored, since most members are accessed directly.
public:
MxS16 m_playerCount; // 0x26 MxS16 m_playerCount; // 0x26
Username m_players[9]; // 0x28 Username m_players[9]; // 0x28
private:
History m_history; // 0xa6 History m_history; // 0xa6
undefined2 m_unk0x41a; // 0x41a undefined2 m_unk0x41a; // 0x41a
undefined4 m_unk0x41c; // 0x41c undefined4 m_unk0x41c; // 0x41c

View file

@ -69,8 +69,6 @@ class LegoWorld : public LegoEntity {
inline MxCoreSet& GetUnknown0xd0() { return m_set0xd0; } inline MxCoreSet& GetUnknown0xd0() { return m_set0xd0; }
inline list<LegoROI*>& GetROIList() { return m_roiList; } inline list<LegoROI*>& GetROIList() { return m_roiList; }
inline void SetScriptIndex(MxS32 p_scriptIndex) { m_scriptIndex = p_scriptIndex; }
MxBool PresentersPending(); MxBool PresentersPending();
void Remove(MxCore* p_object); void Remove(MxCore* p_object);
void FUN_1001fc80(IslePathActor* p_actor); void FUN_1001fc80(IslePathActor* p_actor);
@ -78,6 +76,8 @@ class LegoWorld : public LegoEntity {
MxCore* Find(const char* p_class, const char* p_name); MxCore* Find(const char* p_class, const char* p_name);
MxCore* Find(const MxAtomId& p_atom, MxS32 p_entityId); MxCore* Find(const MxAtomId& p_atom, MxS32 p_entityId);
inline void SetScriptIndex(MxS32 p_scriptIndex) { m_scriptIndex = p_scriptIndex; }
// SYNTHETIC: LEGO1 0x1001dee0 // SYNTHETIC: LEGO1 0x1001dee0
// LegoWorld::`scalar deleting destructor' // LegoWorld::`scalar deleting destructor'

View file

@ -1,7 +1,10 @@
#ifndef REGISTRATIONBOOK_H #ifndef REGISTRATIONBOOK_H
#define REGISTRATIONBOOK_H #define REGISTRATIONBOOK_H
#include "jukebox.h"
#include "legoworld.h" #include "legoworld.h"
#include "mxcontrolpresenter.h"
#include "mxstillpresenter.h"
class InfocenterState; class InfocenterState;
class MxEndActionNotificationParam; class MxEndActionNotificationParam;
@ -35,6 +38,8 @@ class RegistrationBook : public LegoWorld {
MxBool VTable0x64() override; // vtable+0x64 MxBool VTable0x64() override; // vtable+0x64
void Enable(MxBool p_enable) override; // vtable+0x68 void Enable(MxBool p_enable) override; // vtable+0x68
inline void PlayAction(MxU32 p_objectId);
// SYNTHETIC: LEGO1 0x10076f30 // SYNTHETIC: LEGO1 0x10076f30
// RegistrationBook::`scalar deleting destructor' // RegistrationBook::`scalar deleting destructor'
@ -42,14 +47,14 @@ class RegistrationBook : public LegoWorld {
undefined4 m_unk0xf8; // 0xf8 undefined4 m_unk0xf8; // 0xf8
undefined m_unk0xfc; // 0xfc undefined m_unk0xfc; // 0xfc
undefined m_unk0xfd[3]; // 0xfd undefined m_unk0xfd[3]; // 0xfd
undefined m_unk0x100[0x68]; // 0x100 MxStillPresenter* m_alphabet[26]; // 0x100
undefined m_unk0x168[0x118]; // 0x168 MxStillPresenter* m_name[10][7]; // 0x168
struct { struct {
undefined4 m_unk0x00[3]; // 0x00 undefined4 m_unk0x00[3]; // 0x00
undefined2 m_unk0x0c; // 0x0c undefined2 m_unk0x0c; // 0x0c
undefined2 m_unk0x0e; // 0x0e undefined2 m_unk0x0e; // 0x0e
} m_unk0x280; // 0x280 } m_unk0x280; // 0x280
undefined m_unk0x290[0x28]; // 0x290 MxControlPresenter* m_checkmark[10]; // 0x290
undefined2 m_unk0x2b8; // 0x2b8 undefined2 m_unk0x2b8; // 0x2b8
InfocenterState* m_infocenterState; // 0x2bc InfocenterState* m_infocenterState; // 0x2bc
undefined m_unk0x2c0; // 0x2c0 undefined m_unk0x2c0; // 0x2c0

View file

@ -4,24 +4,30 @@
#include "legocontrolmanager.h" #include "legocontrolmanager.h"
#include "legogamestate.h" #include "legogamestate.h"
#include "legoinputmanager.h" #include "legoinputmanager.h"
#include "legoomni.h"
#include "misc.h" #include "misc.h"
#include "mxactionnotificationparam.h" #include "mxactionnotificationparam.h"
#include "mxbackgroundaudiomanager.h"
#include "mxmisc.h" #include "mxmisc.h"
#include "mxnotificationmanager.h" #include "mxnotificationmanager.h"
#include "mxtimer.h" #include "mxtimer.h"
#include "regbook_actions.h"
DECOMP_SIZE_ASSERT(RegistrationBook, 0x2d0) DECOMP_SIZE_ASSERT(RegistrationBook, 0x2d0)
// GLOBAL: LEGO1 0x100d9924
const char* g_infoman = "infoman";
// FUNCTION: LEGO1 0x10076d20 // FUNCTION: LEGO1 0x10076d20
RegistrationBook::RegistrationBook() : m_unk0xf8(0x80000000), m_unk0xfc(1) RegistrationBook::RegistrationBook() : m_unk0xf8(0x80000000), m_unk0xfc(1)
{ {
memset(m_unk0x100, 0, sizeof(m_unk0x100)); memset(m_alphabet, 0, sizeof(m_alphabet));
memset(m_unk0x168, 0, sizeof(m_unk0x168)); 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; 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); memset(&m_unk0x280, -1, sizeof(m_unk0x280) - 2);
m_unk0x2b8 = 0; m_unk0x2b8 = 0;
@ -45,6 +51,7 @@ RegistrationBook::~RegistrationBook()
MxResult RegistrationBook::Create(MxDSAction& p_dsAction) MxResult RegistrationBook::Create(MxDSAction& p_dsAction)
{ {
MxResult result = LegoWorld::Create(p_dsAction); MxResult result = LegoWorld::Create(p_dsAction);
if (result == SUCCESS) { if (result == SUCCESS) {
InputManager()->SetWorld(this); InputManager()->SetWorld(this);
ControlManager()->Register(this); ControlManager()->Register(this);
@ -56,6 +63,7 @@ MxResult RegistrationBook::Create(MxDSAction& p_dsAction)
m_infocenterState = (InfocenterState*) GameState()->GetState("InfocenterState"); m_infocenterState = (InfocenterState*) GameState()->GetState("InfocenterState");
} }
return result; return result;
} }
@ -110,10 +118,77 @@ MxLong RegistrationBook::HandleClick(LegoControlManagerEvent& p_param)
return 0; return 0;
} }
// STUB: LEGO1 0x10077cc0 // FUNCTION: LEGO1 0x10077cc0
void RegistrationBook::ReadyWorld() 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 // STUB: LEGO1 0x10077fd0
@ -154,6 +229,6 @@ MxLong RegistrationBook::HandleNotification19(MxParam& p_param)
// FUNCTION: LEGO1 0x100783e0 // FUNCTION: LEGO1 0x100783e0
MxBool RegistrationBook::VTable0x64() MxBool RegistrationBook::VTable0x64()
{ {
DeleteObjects(&m_atom, 500, 506); DeleteObjects(&m_atom, RegbookScript::c_iic006in_RunAnim, RegbookScript::c_iic008in_PlayWav);
return TRUE; return TRUE;
} }

View file

@ -92,7 +92,7 @@ class MxDisplaySurface : public MxCore {
void ClearScreen(); void ClearScreen();
static LPDIRECTDRAWSURFACE CreateCursorSurface(); static LPDIRECTDRAWSURFACE CreateCursorSurface();
static LPDIRECTDRAWSURFACE FUN_100bbfb0(LPDIRECTDRAWSURFACE p_und); static LPDIRECTDRAWSURFACE CopySurface(LPDIRECTDRAWSURFACE p_src);
inline LPDIRECTDRAWSURFACE GetDirectDrawSurface1() { return this->m_ddSurface1; } inline LPDIRECTDRAWSURFACE GetDirectDrawSurface1() { return this->m_ddSurface1; }
inline LPDIRECTDRAWSURFACE GetDirectDrawSurface2() { return this->m_ddSurface2; } inline LPDIRECTDRAWSURFACE GetDirectDrawSurface2() { return this->m_ddSurface2; }

View file

@ -701,11 +701,30 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44(
return surface; return surface;
} }
// STUB: LEGO1 0x100bbfb0 // FUNCTION: LEGO1 0x100bbfb0
LPDIRECTDRAWSURFACE MxDisplaySurface::FUN_100bbfb0(LPDIRECTDRAWSURFACE p_und) LPDIRECTDRAWSURFACE MxDisplaySurface::CopySurface(LPDIRECTDRAWSURFACE p_src)
{ {
// TODO LPDIRECTDRAWSURFACE newSurface = NULL;
IDirectDraw* draw = MVideoManager()->GetDirectDraw();
DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
p_src->GetSurfaceDesc(&ddsd);
if (draw->CreateSurface(&ddsd, &newSurface, NULL) != DD_OK) {
return NULL; return NULL;
}
RECT rect = {0, 0, (LONG) ddsd.dwWidth, (LONG) ddsd.dwHeight};
if (newSurface->BltFast(0, 0, p_src, &rect, 16) != DD_OK) {
newSurface->Release();
return NULL;
}
return newSurface;
} }
// FUNCTION: LEGO1 0x100bc070 // FUNCTION: LEGO1 0x100bc070

View file

@ -231,7 +231,7 @@ MxStillPresenter* MxStillPresenter::Clone()
if (presenter) { if (presenter) {
if (presenter->AddToManager() == SUCCESS) { if (presenter->AddToManager() == SUCCESS) {
MxDSAction* action = presenter->GetAction()->Clone(); MxDSAction* action = GetAction()->Clone();
if (action && presenter->StartAction(NULL, action) == SUCCESS) { if (action && presenter->StartAction(NULL, action) == SUCCESS) {
presenter->SetBit0(GetBit0()); presenter->SetBit0(GetBit0());
@ -249,7 +249,7 @@ MxStillPresenter* MxStillPresenter::Clone()
} }
if (m_unk0x58) { if (m_unk0x58) {
presenter->m_unk0x58 = MxDisplaySurface::FUN_100bbfb0(m_unk0x58); presenter->m_unk0x58 = MxDisplaySurface::CopySurface(m_unk0x58);
} }
if (m_alpha) { if (m_alpha) {