Refactor files based on beta debug build (#645)

* Rename LegoUnkSaveDataWriter -> LegoCharacterManager

* Refactor mxomni into mxomni/mxmisc

* Refactor legoomni into legoomni/misc

* Resolve deps

* Refactor atom

* Refactor mxutil

* Refactor mxio

* Rename/relocate files

* Fix format
This commit is contained in:
Christian Semmler
2024-03-09 15:07:52 -05:00
committed by GitHub
parent c62469fef4
commit 8069923651
150 changed files with 734 additions and 609 deletions

View File

@@ -1,137 +0,0 @@
#include "elevatorbottom.h"
#include "act1state.h"
#include "jukebox.h"
#include "legocontrolmanager.h"
#include "legogamestate.h"
#include "legoinputmanager.h"
#include "legoomni.h"
#include "legovariables.h"
#include "mxnotificationmanager.h"
#include "mxomni.h"
#include "mxtransitionmanager.h"
DECOMP_SIZE_ASSERT(ElevatorBottom, 0xfc)
// FUNCTION: LEGO1 0x10017e90
ElevatorBottom::ElevatorBottom()
{
NotificationManager()->Register(this);
this->m_unk0xf8 = LegoGameState::e_noArea;
}
// FUNCTION: LEGO1 0x10018060
ElevatorBottom::~ElevatorBottom()
{
if (InputManager()->GetWorld() == this) {
InputManager()->ClearWorld();
}
ControlManager()->Unregister(this);
NotificationManager()->Unregister(this);
}
// FUNCTION: LEGO1 0x100180f0
MxResult ElevatorBottom::Create(MxDSAction& p_dsAction)
{
MxResult result = LegoWorld::Create(p_dsAction);
if (result == SUCCESS) {
InputManager()->SetWorld(this);
ControlManager()->Register(this);
}
SetIsWorldActive(FALSE);
GameState()->SetCurrentArea(LegoGameState::e_elevbott);
GameState()->StopArea(LegoGameState::e_previousArea);
return result;
}
// FUNCTION: LEGO1 0x10018150
MxLong ElevatorBottom::Notify(MxParam& p_param)
{
MxLong ret = 0;
LegoWorld::Notify(p_param);
if (m_worldStarted) {
switch (((MxNotificationParam&) p_param).GetType()) {
case c_notificationClick:
ret = HandleClick((LegoControlManagerEvent&) p_param);
break;
case c_notificationTransitioned:
GameState()->SwitchArea(m_unk0xf8);
break;
}
}
return ret;
}
// FUNCTION: LEGO1 0x100181b0
void ElevatorBottom::ReadyWorld()
{
LegoWorld::ReadyWorld();
PlayMusic(JukeBox::e_informationCenter);
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
}
// FUNCTION: LEGO1 0x100181d0
MxLong ElevatorBottom::HandleClick(LegoControlManagerEvent& p_param)
{
MxLong result = 0;
if (p_param.GetUnknown0x28() == 1) {
switch (p_param.GetClickedObjectId()) {
case 1:
m_unk0xf8 = LegoGameState::e_infodoor;
TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE);
result = 1;
break;
case 2:
m_unk0xf8 = LegoGameState::e_infomain;
TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE);
result = 1;
break;
case 3:
LegoGameState* gs = GameState();
Act1State* state = (Act1State*) gs->GetState("Act1State");
if (state == NULL) {
state = (Act1State*) gs->CreateState("Act1State");
}
state->SetUnknown1c(1);
m_unk0xf8 = LegoGameState::e_elevride;
TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE);
VariableTable()->SetVariable(g_varCAMERALOCATION, "LCAMZI1,90");
result = 1;
break;
}
}
return result;
}
// FUNCTION: LEGO1 0x100182c0
void ElevatorBottom::Enable(MxBool p_enable)
{
LegoWorld::Enable(p_enable);
if (p_enable) {
InputManager()->SetWorld(this);
SetIsWorldActive(FALSE);
}
else {
if (InputManager()->GetWorld() == this) {
InputManager()->ClearWorld();
}
}
}
// FUNCTION: LEGO1 0x10018310
MxBool ElevatorBottom::VTable0x64()
{
DeleteObjects(&m_atom, 500, 999);
m_unk0xf8 = LegoGameState::e_infomain;
return TRUE;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,168 +0,0 @@
#include "infocenterdoor.h"
#include "infocenterstate.h"
#include "jukebox.h"
#include "legocontrolmanager.h"
#include "legogamestate.h"
#include "legoinputmanager.h"
#include "legoomni.h"
#include "mxactionnotificationparam.h"
#include "mxbackgroundaudiomanager.h"
#include "mxnotificationmanager.h"
#include "mxtransitionmanager.h"
DECOMP_SIZE_ASSERT(InfocenterDoor, 0xfc)
// FUNCTION: LEGO1 0x10037730
InfocenterDoor::InfocenterDoor()
{
m_unk0xf8 = LegoGameState::e_noArea;
NotificationManager()->Register(this);
}
// FUNCTION: LEGO1 0x100378f0
InfocenterDoor::~InfocenterDoor()
{
if (InputManager()->GetWorld() == this) {
InputManager()->ClearWorld();
}
ControlManager()->Unregister(this);
NotificationManager()->Unregister(this);
}
// FUNCTION: LEGO1 0x10037980
MxResult InfocenterDoor::Create(MxDSAction& p_dsAction)
{
MxResult result = LegoWorld::Create(p_dsAction);
if (result == SUCCESS) {
InputManager()->SetWorld(this);
ControlManager()->Register(this);
}
SetIsWorldActive(FALSE);
GameState()->SetCurrentArea(LegoGameState::e_infodoor);
GameState()->StopArea(LegoGameState::e_previousArea);
return result;
}
// FUNCTION: LEGO1 0x100379e0
MxLong InfocenterDoor::Notify(MxParam& p_param)
{
MxLong result = 0;
LegoWorld::Notify(p_param);
if (m_worldStarted) {
switch (((MxNotificationParam&) p_param).GetType()) {
case c_notificationEndAction:
if (((MxEndActionNotificationParam&) p_param).GetAction()->GetAtomId() == m_atom) {
BackgroundAudioManager()->RaiseVolume();
result = 1;
}
break;
case c_notificationClick:
result = HandleClick((LegoControlManagerEvent&) p_param);
break;
case c_notificationTransitioned:
GameState()->SwitchArea(m_unk0xf8);
result = 1;
break;
}
}
return result;
}
// FUNCTION: LEGO1 0x10037a70
void InfocenterDoor::ReadyWorld()
{
LegoWorld::ReadyWorld();
PlayMusic(JukeBox::e_informationCenter);
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
}
// FUNCTION: LEGO1 0x10037a90
MxLong InfocenterDoor::HandleClick(LegoControlManagerEvent& p_param)
{
MxLong result = 0;
if (p_param.GetUnknown0x28() == 1) {
DeleteObjects(&m_atom, 500, 510);
switch (p_param.GetClickedObjectId()) {
case 1:
m_unk0xf8 = LegoGameState::e_infoscor;
TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE);
result = 1;
break;
case 2:
m_unk0xf8 = LegoGameState::e_elevbott;
TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE);
result = 1;
break;
case 3:
m_unk0xf8 = LegoGameState::e_infomain;
TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE);
result = 1;
break;
case 4:
if (GameState()->GetActorId()) {
InfocenterState* state = (InfocenterState*) GameState()->GetState("InfocenterState");
if (state->HasRegistered()) {
m_unk0xf8 = LegoGameState::e_unk4;
}
else {
MxDSAction action;
action.SetObjectId(503);
action.SetAtomId(*g_infodoorScript);
BackgroundAudioManager()->LowerVolume();
Start(&action);
goto done;
}
}
else {
MxDSAction action;
action.SetObjectId(500);
action.SetAtomId(*g_infodoorScript);
BackgroundAudioManager()->LowerVolume();
Start(&action);
goto done;
}
TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE);
done:
result = 1;
break;
}
}
return result;
}
// FUNCTION: LEGO1 0x10037c80
void InfocenterDoor::Enable(MxBool p_enable)
{
LegoWorld::Enable(p_enable);
if (p_enable) {
InputManager()->SetWorld(this);
SetIsWorldActive(FALSE);
}
else {
if (InputManager()->GetWorld() == this) {
InputManager()->ClearWorld();
}
}
}
// FUNCTION: LEGO1 0x10037cd0
MxBool InfocenterDoor::VTable0x64()
{
DeleteObjects(&m_atom, 500, 510);
m_unk0xf8 = LegoGameState::e_infomain;
return TRUE;
}

View File

@@ -1,158 +0,0 @@
#include "registrationbook.h"
#include "infocenterstate.h"
#include "legocontrolmanager.h"
#include "legogamestate.h"
#include "legoinputmanager.h"
#include "legoomni.h"
#include "mxactionnotificationparam.h"
#include "mxnotificationmanager.h"
#include "mxtimer.h"
DECOMP_SIZE_ASSERT(RegistrationBook, 0x2d0)
// 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));
// Maybe 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_unk0x280, -1, sizeof(m_unk0x280) - 2);
m_unk0x2b8 = 0;
m_infocenterState = NULL;
NotificationManager()->Register(this);
m_unk0x2c1 = 0;
m_unk0x2c4 = 0;
m_unk0x2c8 = 0;
m_unk0x2cc = 0;
}
// STUB: LEGO1 0x10076f50
RegistrationBook::~RegistrationBook()
{
// TODO
}
// FUNCTION: LEGO1 0x10077060
MxResult RegistrationBook::Create(MxDSAction& p_dsAction)
{
MxResult result = LegoWorld::Create(p_dsAction);
if (result == SUCCESS) {
InputManager()->SetWorld(this);
ControlManager()->Register(this);
SetIsWorldActive(FALSE);
InputManager()->Register(this);
GameState()->SetCurrentArea(LegoGameState::e_regbook);
GameState()->StopArea(LegoGameState::e_previousArea);
m_infocenterState = (InfocenterState*) GameState()->GetState("InfocenterState");
}
return result;
}
// FUNCTION: LEGO1 0x100770e0
MxLong RegistrationBook::Notify(MxParam& p_param)
{
MxLong result = 0;
LegoWorld::Notify(p_param);
if (m_worldStarted) {
switch (((MxNotificationParam&) p_param).GetType()) {
case c_notificationEndAction:
result = HandleEndAction((MxEndActionNotificationParam&) p_param);
break;
case c_notificationKeyPress:
m_unk0xf8 = Timer()->GetTime();
result = HandleKeyPress(((LegoEventNotificationParam&) p_param).GetKey());
break;
case c_notificationButtonDown:
m_unk0xf8 = Timer()->GetTime();
break;
case c_notificationClick:
result = HandleClick((LegoControlManagerEvent&) p_param);
break;
case c_notificationType19:
result = HandleNotification19(p_param);
break;
case c_notificationTransitioned:
GameState()->SwitchArea(LegoGameState::e_infomain);
break;
}
}
return result;
}
// STUB: LEGO1 0x10077210
MxLong RegistrationBook::HandleEndAction(MxEndActionNotificationParam& p_param)
{
return 0;
}
// STUB: LEGO1 0x100772d0
MxLong RegistrationBook::HandleKeyPress(MxS8 p_key)
{
return 0;
}
// STUB: LEGO1 0x100774a0
MxLong RegistrationBook::HandleClick(LegoControlManagerEvent& p_param)
{
return 0;
}
// STUB: LEGO1 0x10077cc0
void RegistrationBook::ReadyWorld()
{
// TODO
}
// STUB: LEGO1 0x10077fd0
MxResult RegistrationBook::Tickle()
{
if (!m_worldStarted) {
LegoWorld::Tickle();
}
else {
// TODO
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x10078180
void RegistrationBook::Enable(MxBool p_enable)
{
LegoWorld::Enable(p_enable);
if (p_enable) {
InputManager()->SetWorld(this);
SetIsWorldActive(FALSE);
}
else {
if (InputManager()->GetWorld() == this) {
InputManager()->ClearWorld();
}
}
}
// STUB: LEGO1 0x100781d0
MxLong RegistrationBook::HandleNotification19(MxParam& p_param)
{
return 0;
}
// FUNCTION: LEGO1 0x100783e0
MxBool RegistrationBook::VTable0x64()
{
DeleteObjects(&m_atom, 500, 506);
return TRUE;
}

View File

@@ -1,335 +0,0 @@
#include "score.h"
#include "ambulancemissionstate.h"
#include "jukebox.h"
#include "legocontrolmanager.h"
#include "legogamestate.h"
#include "legoinputmanager.h"
#include "legoomni.h"
#include "misc/legocontainer.h"
#include "mxnotificationmanager.h"
#include "mxnotificationparam.h"
#include "mxtransitionmanager.h"
#include "pizzamissionstate.h"
#include "racestate.h"
#include "towtrackmissionstate.h"
DECOMP_SIZE_ASSERT(Score, 0x104)
// FUNCTION: LEGO1 0x10001000
Score::Score()
{
m_unk0xf8 = LegoGameState::e_noArea;
NotificationManager()->Register(this);
}
// FUNCTION: LEGO1 0x100010b0
MxBool Score::VTable0x5c()
{
return TRUE;
}
// FUNCTION: LEGO1 0x10001200
Score::~Score()
{
if (InputManager()->GetWorld() == this) {
InputManager()->ClearWorld();
}
InputManager()->UnRegister(this);
ControlManager()->Unregister(this);
NotificationManager()->Unregister(this);
}
// FUNCTION: LEGO1 0x100012a0
MxResult Score::Create(MxDSAction& p_dsAction)
{
MxResult result = LegoWorld::Create(p_dsAction);
if (result == SUCCESS) {
InputManager()->SetWorld(this);
ControlManager()->Register(this);
InputManager()->Register(this);
SetIsWorldActive(FALSE);
LegoGameState* gs = GameState();
ScoreState* state = (ScoreState*) gs->GetState("ScoreState");
m_state = state ? state : (ScoreState*) gs->CreateState("ScoreState");
GameState()->SetCurrentArea(LegoGameState::e_infoscor);
GameState()->StopArea(LegoGameState::e_previousArea);
}
return result;
}
// FUNCTION: LEGO1 0x10001340
void Score::DeleteScript()
{
if (m_state->GetTutorialFlag()) {
MxDSAction action;
action.SetObjectId(0x1f5);
action.SetAtomId(*g_infoscorScript);
action.SetUnknown24(-2);
DeleteObject(action);
m_state->SetTutorialFlag(FALSE);
}
}
// FUNCTION: LEGO1 0x10001410
MxLong Score::Notify(MxParam& p_param)
{
MxLong ret = 0;
LegoWorld::Notify(p_param);
if (m_worldStarted) {
switch (((MxNotificationParam&) p_param).GetNotification()) {
case c_notificationStartAction:
ret = 1;
Paint();
break;
case c_notificationEndAction:
ret = FUN_10001510((MxEndActionNotificationParam&) p_param);
break;
case c_notificationKeyPress:
if (((LegoEventNotificationParam&) p_param).GetKey() == 0x20) {
DeleteScript(); // Shutting down
}
ret = 1;
break;
case c_notificationClick:
ret = FUN_100016d0((LegoControlManagerEvent&) p_param);
break;
case c_notificationTransitioned:
DeleteObjects(g_infoscorScript, 7, 9);
if (m_unk0xf8) {
GameState()->SwitchArea(m_unk0xf8);
}
ret = 1;
break;
default:
break;
}
}
return ret;
}
// FUNCTION: LEGO1 0x10001510
MxLong Score::FUN_10001510(MxEndActionNotificationParam& p_param)
{
MxDSAction* action = p_param.GetAction();
if (m_atom == action->GetAtomId()) {
MxU32 id = action->GetObjectId();
switch (action->GetObjectId()) {
case 10:
m_unk0xf8 = LegoGameState::e_histbook;
TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 0x32, 0, 0);
break;
case 0x1f5:
PlayMusic(JukeBox::e_informationCenter);
m_state->SetTutorialFlag(FALSE);
}
}
return 1;
}
// FUNCTION: LEGO1 0x10001580
void Score::ReadyWorld()
{
LegoWorld::ReadyWorld();
MxDSAction action;
action.SetObjectId(0x1f4);
action.SetAtomId(m_atom);
action.SetUnknown84(this);
Start(&action);
if (m_state->GetTutorialFlag()) {
MxDSAction action2;
action.SetObjectId(0x1f5);
action.SetAtomId(*g_infoscorScript);
Start(&action);
}
else {
PlayMusic(JukeBox::e_informationCenter);
}
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
}
// FUNCTION: LEGO1 0x100016d0
MxLong Score::FUN_100016d0(LegoControlManagerEvent& p_param)
{
MxS16 l = p_param.GetUnknown0x28();
if (l == 1 || p_param.GetClickedObjectId() == 4) {
switch (p_param.GetClickedObjectId()) {
case 1:
m_unk0xf8 = LegoGameState::e_infomain;
DeleteScript();
TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 0x32, 0, 0);
break;
case 2:
m_unk0xf8 = LegoGameState::e_infodoor;
DeleteScript();
TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 0x32, 0, 0);
break;
case 3: {
LegoInputManager* im = InputManager();
im->SetUnknown88(TRUE);
im->SetUnknown336(FALSE);
DeleteScript();
MxDSAction action;
action.SetObjectId(10);
action.SetAtomId(*g_infoscorScript);
Start(&action);
break;
}
case 4: {
switch (l) {
case 1: {
MxDSAction action;
action.SetObjectId(7);
action.SetAtomId(*g_infoscorScript);
Start(&action);
break;
}
case 2: {
MxDSAction action;
action.SetObjectId(8);
action.SetAtomId(*g_infoscorScript);
Start(&action);
break;
}
case 3: {
MxDSAction action;
action.SetObjectId(9);
action.SetAtomId(*g_infoscorScript);
Start(&action);
break;
}
}
break;
}
}
}
return 1;
}
// FUNCTION: LEGO1 0x10001980
void Score::Enable(MxBool p_enable)
{
LegoWorld::Enable(p_enable);
if (p_enable) {
InputManager()->SetWorld(this);
SetIsWorldActive(FALSE);
}
else if (InputManager()->GetWorld() == this) {
InputManager()->ClearWorld();
}
}
// FUNCTION: LEGO1 0x100019d0
void Score::Paint()
{
LegoTextureInfo* gd = TextureContainer()->Get("bigcube.gif");
if (gd) {
RaceState* l78 = (RaceState*) GameState()->GetState("JetskiRaceState");
RaceState* l70 = (RaceState*) GameState()->GetState("CarRaceState");
TowTrackMissionState* lesi = (TowTrackMissionState*) GameState()->GetState("TowTrackMissionState");
PizzaMissionState* l74 = (PizzaMissionState*) GameState()->GetState("PizzaMissionState");
AmbulanceMissionState* lebp = (AmbulanceMissionState*) GameState()->GetState("AmbulanceMissionState");
DDSURFACEDESC desc;
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
if (gd->m_surface->Lock(NULL, &desc, 0, NULL) == DD_OK) {
if (desc.lPitch != desc.dwWidth) {
gd->m_surface->Unlock(desc.lpSurface);
return;
}
for (MxU8 id = 1; id <= 5; id++) {
m_surface = (MxU8*) desc.lpSurface;
MxU16 color = 0;
if (l70) {
color = l70->GetColor(id);
}
MxU32 row = id - 1;
FillArea(0, row, color);
color = 0;
if (l78) {
color = l78->GetColor(id);
}
FillArea(1, row, color);
color = 0;
if (l74) {
color = l74->GetColor(id);
}
FillArea(2, row, color);
color = 0;
if (lesi) {
color = lesi->GetColor(id);
}
FillArea(3, row, color);
color = 0;
if (lebp) {
color = lebp->GetColor(id);
}
FillArea(4, row, color);
}
gd->m_surface->Unlock(desc.lpSurface);
gd->m_texture->Changed(TRUE, FALSE);
m_surface = NULL;
}
}
}
// FUNCTION: LEGO1 0x10001d20
void Score::FillArea(MxU32 p_x, MxU32 p_y, MxS16 p_color)
{
MxU32 data[24];
data[9] = 0x2b00;
data[10] = 0x5700;
data[11] = 0x8000;
data[19] = 0x2a;
data[12] = 0xab00;
data[13] = 0xd600;
data[20] = 0x27;
data[21] = 0x29;
data[22] = 0x29;
data[23] = 0x2a;
data[4] = 0x2f;
data[5] = 0x56;
data[6] = 0x81;
data[15] = 0x29;
data[16] = 0x27;
data[7] = 0xaa;
data[8] = 0xd4;
data[14] = 0x25;
data[0] = 0x11;
data[17] = 0x28;
data[18] = 0x28;
data[1] = 0x0f;
MxU32 size = data[p_x + 14];
MxU8* ptr = data[p_x + 4] + data[p_y + 9] + m_surface;
MxS32 count = data[p_y + 19];
data[2] = 0x08;
data[3] = 0x05;
MxU32 value = data[p_color];
for (; count > 0; count--) {
memset(ptr++, value, size);
ptr += 0x100;
}
}
// FUNCTION: LEGO1 0x10001e40
MxBool Score::VTable0x64()
{
DeleteScript();
m_unk0xf8 = LegoGameState::e_infomain;
return TRUE;
}