Implement some Act1State functions

This commit is contained in:
Anonymous Maarten 2024-02-02 23:54:25 +01:00
parent 6653533b1f
commit 78d0491bed
5 changed files with 374 additions and 29 deletions

View File

@ -151,7 +151,7 @@ add_library(misc STATIC
)
register_lego1_target(misc)
set_property(TARGET misc PROPERTY ARCHIVE_OUTPUT_NAME "misc$<$<CONFIG:Debug>:d>")
target_include_directories(misc PRIVATE "${CMAKE_SOURCE_DIR}/LEGO1/omni/include" "${CMAKE_SOURCE_DIR}/util")
target_include_directories(misc PRIVATE "${CMAKE_SOURCE_DIR}/LEGO1/omni/include" "${CMAKE_SOURCE_DIR}/LEGO1/realtime" "${CMAKE_SOURCE_DIR}/util")
target_link_libraries(misc PRIVATE)
add_library(3dmanager STATIC
@ -393,6 +393,7 @@ target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/LEGO1")
target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/LEGO1/omni/include")
target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/LEGO1/lego/sources")
target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/LEGO1/lego/legoomni/include")
target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/LEGO1/realtime")
# Link libraries
target_link_libraries(lego1 PRIVATE tglrl viewmanager realtime mxdirectx roi FLIC::FLIC Vec::Vec dinput dxguid misc 3dmanager omni)

View File

@ -3,6 +3,11 @@
#include "legostate.h"
#include "misc/legotexture.h"
#include "roi/legoroi.h"
class LegoTexture;
// VTABLE: LEGO1 0x100d7028
// SIZE 0x26c
class Act1State : public LegoState {
@ -25,29 +30,87 @@ class Act1State : public LegoState {
MxBool SetFlag() override; // vtable+0x18
MxResult VTable0x1c(LegoFile* p_legoFile) override; // vtable+0x1c
inline void SetUnknown18(MxU32 p_unk0x18) { m_unk0x18 = p_unk0x18; }
inline MxU32 GetUnknown18() { return m_unk0x18; }
inline MxU32 GetUnknown1c() { return m_unk0x1c; }
inline MxS16 GetUnknown21() { return m_unk0x21; }
inline void SetUnknown18(MxU32 p_unk0x18) { m_unk0x018 = p_unk0x18; }
inline MxU32 GetUnknown18() { return m_unk0x018; }
inline MxU32 GetUnknown1c() { return m_unk0x01c; }
inline MxS16 GetUnknown21() { return m_unk0x021; }
inline void SetUnknown1c(MxU32 p_unk0x1c) { m_unk0x1c = p_unk0x1c; }
inline void SetUnknown21(MxS16 p_unk0x21) { m_unk0x21 = p_unk0x21; }
inline void SetUnknown1c(MxU32 p_unk0x1c) { m_unk0x01c = p_unk0x1c; }
inline void SetUnknown21(MxS16 p_unk0x21) { m_unk0x021 = p_unk0x21; }
void FUN_10034d00();
// SYNTHETIC: LEGO1 0x10033960
// Act1State::`scalar deleting destructor'
// SIZE 0x4c
class NamedPlane {
public:
// FUNCTION: LEGO1 0x10033800
NamedPlane() { }
inline void SetName(const char *name) { m_name = name; }
inline const MxString *GetName() const { return &m_name; }
int Serialize(LegoFile *p_file);
private:
MxString m_name; // 0x00
Mx3DPointFloat m_point1; // 0x10
Mx3DPointFloat m_point2; // 0x24
Mx3DPointFloat m_point3; // 0x38
};
// SIZE 0x14
class NamedTexture {
public:
~NamedTexture() {
delete m_texture;
}
// FUNCTION: LEGO1 0x1003f920
const MxString *GetName() const {
return &m_name;
}
LegoTexture *GetTexture() { return m_texture; }
private:
MxString m_name; // 0x00
LegoTexture *m_texture; // 0x4
};
protected:
undefined m_unk0x08[0x10]; // 0x08
MxU32 m_unk0x18; // 0x18
undefined2 m_unk0x1c; // 0x1c
undefined m_unk0x1e; // 0x1e
undefined m_unk0x1f; // 0x1f
undefined m_unk0x20; // 0x20
MxBool m_unk0x21; // 0x21
undefined m_unk0x22; // 0x22
// TODO
int *m_unk0x008; // 0x008
// FIXME: count for m_unk0x008
MxS16 m_unk0x00c; // 0x00c
undefined2 m_unk0x00e; // 0x00e
undefined2 m_unk0x010; // 0x010
undefined m_unk0x012; // 0x012
MxS32 m_unk0x014; // 0x014
MxU32 m_unk0x018; // 0x018
MxU16 m_unk0x01c; // 0x01c
undefined m_unk0x01e; // 0x01e
undefined m_unk0x01f; // 0x01f
undefined m_unk0x020; // 0x020
undefined m_unk0x021; // 0x021
undefined m_unk0x022; // 0x022
undefined m_unk0x023; // 0x023
NamedPlane m_unk0x024; // 0x024
NamedPlane m_unk0x070; // 0x070
NamedPlane m_unk0x0bc; // 0x0bc
NamedPlane m_unk0x108; // 0x108
NamedTexture *m_unk0x154; // 0x154
NamedTexture *m_unk0x158; // 0x158
NamedTexture *m_unk0x15c; // 0x15c
MxCore *m_unk0x160; // 0x160
NamedPlane m_unk0x164; // 0x164
NamedTexture *m_unk0x1b0; // 0x1b0
NamedTexture *m_unk0x1b4; // 0x1b4
MxCore *m_unk0x1b8; // 0x1b8
NamedPlane m_unk0x1bc; // 0x1bc
NamedTexture *m_unk0x208; // 0x208
MxCore *m_unk0x20c; // 0x20c
NamedPlane m_unk0x210; // 0x210
NamedTexture *m_unk0x25c; // 0x25c
NamedTexture *m_unk0x260; // 0x260
NamedTexture *m_unk0x264; // 0x264
MxCore *m_unk0x268; // 0x268
};
#endif // ACT1STATE_H

View File

@ -1,30 +1,249 @@
#include "act1state.h"
DECOMP_SIZE_ASSERT(Act1State, 0x26c)
DECOMP_SIZE_ASSERT(Act1State::NamedPlane, 0x4c)
DECOMP_SIZE_ASSERT(Act1State::NamedTexture, 0x14)
#define isle_asize(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
// Forward declarations
Act1State::NamedTexture *ReadNamedTexture(LegoFile *p_file);
void WriteNamedTexture(LegoFile *p_file, Act1State::NamedTexture *p_texture);
void FUN_1003f540(LegoFile *p_file, const char *p_filename);
enum {
eUnk_953 = 953,
eUnk_954 = 954,
eUnk_955 = 955,
};
// GLOBAL: ISLE 0x100f37f0
int g_act1_ints[] = {
eUnk_953,
eUnk_954,
eUnk_955,
};
// STUB: LEGO1 0x100334b0
Act1State::Act1State()
: m_unk0x00c(0)
, m_unk0x00e(0)
, m_unk0x008(NULL)
, m_unk0x010(0)
{
// TODO
m_unk0x1e = 0;
m_unk0x18 = 1;
m_unk0x20 = 0;
m_unk0x1f = 0;
m_unk0x21 = TRUE;
m_unk0x22 = 0;
m_unk0x1c = 1;
m_unk0x01e = 0;
m_unk0x018 = 1;
m_unk0x010 = 0;
m_unk0x020 = 0;
m_unk0x00e = 0;
m_unk0x01f = 0;
m_unk0x008 = g_act1_ints;
m_unk0x014 = -1;
m_unk0x022 = 0;
m_unk0x154 = NULL;
m_unk0x158 = NULL;
m_unk0x15c = NULL;
m_unk0x160 = NULL;
m_unk0x1b0 = NULL;
m_unk0x021 = 1;
m_unk0x01c = 1;
m_unk0x00c = isle_asize(g_act1_ints);
m_unk0x1b4 = NULL;
m_unk0x1b8 = NULL;
m_unk0x208 = NULL;
m_unk0x20c = NULL;
m_unk0x25c = NULL;
m_unk0x260 = NULL;
m_unk0x264 = NULL;
m_unk0x268 = NULL;
SetFlag();
}
// STUB: LEGO1 0x10033ac0
// FUNCTION: LEGO1 0x10033ac0
MxResult Act1State::VTable0x1c(LegoFile* p_legoFile)
{
if (p_legoFile->IsWriteMode()) {
p_legoFile->FUN_10006030(ClassName());
}
m_unk0x024.Serialize(p_legoFile);
m_unk0x070.Serialize(p_legoFile);
m_unk0x0bc.Serialize(p_legoFile);
m_unk0x108.Serialize(p_legoFile);
m_unk0x164.Serialize(p_legoFile);
m_unk0x1bc.Serialize(p_legoFile);
m_unk0x210.Serialize(p_legoFile);
if (p_legoFile->IsWriteMode()) {
if (m_unk0x108.GetName()->Compare("") != 0) {
if (m_unk0x154) {
WriteNamedTexture(p_legoFile, m_unk0x154);
} else {
FUN_1003f540(p_legoFile, "chwind.gif");
}
if (m_unk0x158) {
WriteNamedTexture(p_legoFile, m_unk0x158);
} else {
FUN_1003f540(p_legoFile, "chjetl.gif");
}
if (m_unk0x15c) {
WriteNamedTexture(p_legoFile, m_unk0x15c);
} else {
FUN_1003f540(p_legoFile, "chjetr.gif");
}
}
if (m_unk0x164.GetName()->Compare("") != 0) {
if (m_unk0x1b0) {
WriteNamedTexture(p_legoFile, m_unk0x1b0);
} else {
FUN_1003f540(p_legoFile, "jsfrnt.gif");
}
if (m_unk0x1b4) {
WriteNamedTexture(p_legoFile, m_unk0x1b4);
} else {
FUN_1003f540(p_legoFile, "jswnsh.gif");
}
}
if (m_unk0x1bc.GetName()->Compare("") != 0) {
if (m_unk0x208) {
WriteNamedTexture(p_legoFile, m_unk0x208);
} else {
FUN_1003f540(p_legoFile, "dbfrfn.gif");
}
}
if (m_unk0x210.GetName()->Compare("") != 0) {
if (m_unk0x25c) {
WriteNamedTexture(p_legoFile, m_unk0x25c);
} else {
FUN_1003f540(p_legoFile, "rcfrnt.gif");
}
if (m_unk0x260) {
WriteNamedTexture(p_legoFile, m_unk0x260);
} else {
FUN_1003f540(p_legoFile, "rcback.gif");
}
if (m_unk0x264) {
WriteNamedTexture(p_legoFile, m_unk0x264);
} else {
FUN_1003f540(p_legoFile, "rctail.gif");
}
}
p_legoFile->Write(&m_unk0x010, sizeof(undefined2));
p_legoFile->Write(&m_unk0x022, sizeof(undefined));
} else if (p_legoFile->IsReadMode()) {
if (m_unk0x108.GetName()->Compare("") != 0) {
m_unk0x154 = ReadNamedTexture(p_legoFile);
if (m_unk0x154 == NULL) {
return FAILURE;
}
m_unk0x158 = ReadNamedTexture(p_legoFile);
if (m_unk0x158 == NULL) {
return FAILURE;
}
m_unk0x15c = ReadNamedTexture(p_legoFile);
if (m_unk0x15c == NULL) {
return FAILURE;
}
}
if (m_unk0x164.GetName()->Compare("") != 0) {
m_unk0x1b0 = ReadNamedTexture(p_legoFile);
if (m_unk0x1b0 == NULL) {
return FAILURE;
}
m_unk0x1b4 = ReadNamedTexture(p_legoFile);
if (m_unk0x1b4 == NULL) {
return FAILURE;
}
}
if (m_unk0x1bc.GetName()->Compare("") != 0) {
m_unk0x208 = ReadNamedTexture(p_legoFile);
if (m_unk0x208 == NULL) {
return FAILURE;
}
}
if (m_unk0x210.GetName()->Compare("") != 0) {
m_unk0x25c = ReadNamedTexture(p_legoFile);
if (m_unk0x25c == NULL) {
return FAILURE;
}
m_unk0x260 = ReadNamedTexture(p_legoFile);
if (m_unk0x260 == NULL) {
return FAILURE;
}
m_unk0x264 = ReadNamedTexture(p_legoFile);
if (m_unk0x264 == NULL) {
return FAILURE;
}
}
p_legoFile->Read(&m_unk0x010, sizeof(undefined2));
p_legoFile->Read(&m_unk0x022, sizeof(undefined));
}
// TODO
return SUCCESS;
}
// STUB: LEGO1 0x100346d0
// FUNCTION: LEGO1 0x100346d0
MxBool Act1State::SetFlag()
{
// TODO
return FALSE;
m_unk0x024.SetName("");
m_unk0x070.SetName("");
m_unk0x0bc.SetName("");
m_unk0x022 = 0;
m_unk0x108.SetName("");
if (m_unk0x154) {
delete m_unk0x154;
m_unk0x154 = NULL;
}
if (m_unk0x158) {
delete m_unk0x158;
m_unk0x158 = NULL;
}
if (m_unk0x15c) {
delete m_unk0x15c;
m_unk0x15c = NULL;
}
if (m_unk0x160) {
delete m_unk0x160;
m_unk0x160 = NULL;
}
m_unk0x164.SetName("");
if (m_unk0x1b0) {
delete m_unk0x1b0;
m_unk0x1b0 = NULL;
}
if (m_unk0x1b4) {
delete m_unk0x1b4;
m_unk0x1b4 = NULL;
}
if (m_unk0x1b8) {
delete m_unk0x1b8;
m_unk0x1b8 = NULL;
}
m_unk0x1bc.SetName("");
if (m_unk0x208) {
delete m_unk0x208;
m_unk0x208 = NULL;
}
if (m_unk0x20c) {
delete m_unk0x20c;
m_unk0x20c = NULL;
}
m_unk0x210.SetName("");
if (m_unk0x25c) {
delete m_unk0x25c;
m_unk0x25c = NULL;
}
if (m_unk0x260) {
delete m_unk0x260;
m_unk0x260 = NULL;
}
if (m_unk0x264) {
delete m_unk0x264;
m_unk0x264 = NULL;
}
if (m_unk0x268) {
delete m_unk0x268;
m_unk0x268 = NULL;
}
return TRUE;
}
// STUB: LEGO1 0x10034d00
@ -32,3 +251,35 @@ void Act1State::FUN_10034d00()
{
// TODO
}
// FUNCTION: LEGO1 0x1003f8a0
void WriteNamedTexture(LegoFile *p_file, Act1State::NamedTexture *p_texture) {
p_file->FUN_10006030(*p_texture->GetName());
p_texture->GetTexture()->Write(p_file);
}
// STUB: LEGO1 0x1003f3b0
Act1State::NamedTexture *ReadNamedTexture(LegoFile *p_file) {
return NULL;
}
// FUNCTION: LEGO1 0x100344d0
int Act1State::NamedPlane::Serialize(LegoFile *p_file) {
if (p_file->IsWriteMode()) {
p_file->FUN_10006030(m_name);
p_file->WriteVector3(m_point1);
p_file->WriteVector3(m_point2);
p_file->WriteVector3(m_point3);
} else if (p_file->IsReadMode()) {
p_file->ReadString(&m_name);
p_file->ReadVector3(&m_point1);
p_file->ReadVector3(&m_point2);
p_file->ReadVector3(&m_point3);
}
return 0;
}
// STUB: LEGO1 0x1003f540
void FUN_1003f540(LegoFile *p_file, const char *p_filename) {
}

View File

@ -14,7 +14,7 @@ DECOMP_SIZE_ASSERT(ElevatorBottom, 0xfc)
// STRING: LEGO1 0x100f0d34
// GLOBAL: LEGO1 0x100f3a44
char* g_cameraLoc = "CAMERA_LOCATION";
const char* g_cameraLoc = "CAMERA_LOCATION";
// FUNCTION: LEGO1 0x10017e90
ElevatorBottom::ElevatorBottom()

View File

@ -4,6 +4,8 @@
#include "legotypes.h"
#include "mxstring.h"
#include "vector.h"
#include <stdio.h>
// VTABLE: LEGO1 0x100d7d80
@ -72,6 +74,34 @@ class LegoFile : public LegoStorage {
LegoResult SetPosition(LegoU32 p_position) override;
LegoResult Open(const char* p_name, LegoU32 p_mode);
// FUNCTION: LEGO1 0x10034430
LegoStorage *ReadVector3(Vector3 *p_vec3) {
Read(&(*p_vec3)[0], sizeof(float));
Read(&(*p_vec3)[1], sizeof(float));
Read(&(*p_vec3)[2], sizeof(float));
return this;
}
// FUNCTION: LEGO1 0x100343d0
LegoStorage *WriteVector3(Vector3 p_vec3) {
Write(&p_vec3[0], sizeof(float));
Write(&p_vec3[1], sizeof(float));
Write(&p_vec3[2], sizeof(float));
return this;
}
// FUNCTION: LEGO1 0x10034470
LegoStorage *ReadString(MxString *p_str) {
MxU16 len;
Read(&len, sizeof(MxU16));
char *text = new char[len + 1];
Read(text, len);
text[len] = '\0';
*p_str = text;
delete[] text;
return this;
}
// FUNCTION: LEGO1 0x10006030
LegoStorage* FUN_10006030(MxString p_str)
{