mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 16:34:06 +00:00
Implement misc.lib (#483)
* Implement misc.lib * Lowercase files * Minor changes * Fix file cases * Fixes * Fix missing dtor * Add override * Match LegoImage::Read * Fix delete call --------- Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
@@ -55,7 +55,6 @@ add_library(lego1 SHARED
|
|||||||
LEGO1/lego/legoomni/src/common/legoobjectfactory.cpp
|
LEGO1/lego/legoomni/src/common/legoobjectfactory.cpp
|
||||||
LEGO1/lego/legoomni/src/common/legoplantmanager.cpp
|
LEGO1/lego/legoomni/src/common/legoplantmanager.cpp
|
||||||
LEGO1/lego/legoomni/src/common/legostate.cpp
|
LEGO1/lego/legoomni/src/common/legostate.cpp
|
||||||
LEGO1/lego/legoomni/src/common/legostream.cpp
|
|
||||||
LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp
|
LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp
|
||||||
LEGO1/lego/legoomni/src/common/legoutil.cpp
|
LEGO1/lego/legoomni/src/common/legoutil.cpp
|
||||||
LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp
|
LEGO1/lego/legoomni/src/common/mxcompositemediapresenter.cpp
|
||||||
@@ -148,6 +147,9 @@ add_library(lego1 SHARED
|
|||||||
LEGO1/lego/sources/3dmanager/lego3dview.cpp
|
LEGO1/lego/sources/3dmanager/lego3dview.cpp
|
||||||
LEGO1/lego/sources/3dmanager/legoview1.cpp
|
LEGO1/lego/sources/3dmanager/legoview1.cpp
|
||||||
LEGO1/lego/sources/3dmanager/tglsurface.cpp
|
LEGO1/lego/sources/3dmanager/tglsurface.cpp
|
||||||
|
LEGO1/lego/sources/misc/legoimage.cpp
|
||||||
|
LEGO1/lego/sources/misc/legostorage.cpp
|
||||||
|
LEGO1/lego/sources/misc/legotexture.cpp
|
||||||
LEGO1/lego/sources/roi/legoroi.cpp
|
LEGO1/lego/sources/roi/legoroi.cpp
|
||||||
LEGO1/main.cpp
|
LEGO1/main.cpp
|
||||||
LEGO1/mxdirectx/mxdirect3d.cpp
|
LEGO1/mxdirectx/mxdirect3d.cpp
|
||||||
|
@@ -23,7 +23,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
virtual MxBool SetFlag() override; // vtable+0x18
|
virtual MxBool SetFlag() override; // vtable+0x18
|
||||||
virtual MxResult VTable0x1c(LegoFileStream* p_legoFileStream) override; // vtable+0x1c
|
virtual MxResult VTable0x1c(LegoFile* p_legoFile) override; // vtable+0x1c
|
||||||
|
|
||||||
inline void SetUnknown18(MxU32 p_unk0x18) { m_unk0x18 = p_unk0x18; }
|
inline void SetUnknown18(MxU32 p_unk0x18) { m_unk0x18 = p_unk0x18; }
|
||||||
inline MxU32 GetUnknown18() { return m_unk0x18; }
|
inline MxU32 GetUnknown18() { return m_unk0x18; }
|
||||||
|
@@ -22,7 +22,7 @@ public:
|
|||||||
return !strcmp(p_name, AmbulanceMissionState::ClassName()) || LegoState::IsA(p_name);
|
return !strcmp(p_name, AmbulanceMissionState::ClassName()) || LegoState::IsA(p_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual MxResult VTable0x1c(LegoFileStream* p_legoFileStream) override; // vtable+0x1c
|
virtual MxResult VTable0x1c(LegoFile* p_legoFile) override; // vtable+0x1c
|
||||||
|
|
||||||
inline MxU16 GetColor(MxU8 p_id)
|
inline MxU16 GetColor(MxU8 p_id)
|
||||||
{
|
{
|
||||||
|
@@ -24,7 +24,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual MxBool SetFlag() override; // vtable+0x18
|
virtual MxBool SetFlag() override; // vtable+0x18
|
||||||
virtual MxResult VTable0x1c(LegoFileStream* p_legoFileStream) override; // vtable+0x1C
|
virtual MxResult VTable0x1c(LegoFile* p_legoFile) override; // vtable+0x1C
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x10065130
|
// SYNTHETIC: LEGO1 0x10065130
|
||||||
// AnimState::`scalar deleting destructor'
|
// AnimState::`scalar deleting destructor'
|
||||||
|
@@ -22,7 +22,7 @@ public:
|
|||||||
return !strcmp(p_name, GasStationState::ClassName()) || LegoState::IsA(p_name);
|
return !strcmp(p_name, GasStationState::ClassName()) || LegoState::IsA(p_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual MxResult VTable0x1c(LegoFileStream* p_legoFileStream) override; // vtable+0x1c
|
virtual MxResult VTable0x1c(LegoFile* p_legoFile) override; // vtable+0x1c
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x10006290
|
// SYNTHETIC: LEGO1 0x10006290
|
||||||
// GasStationState::`scalar deleting destructor'
|
// GasStationState::`scalar deleting destructor'
|
||||||
|
@@ -23,7 +23,7 @@ public:
|
|||||||
return !strcmp(p_name, HospitalState::ClassName()) || LegoState::IsA(p_name);
|
return !strcmp(p_name, HospitalState::ClassName()) || LegoState::IsA(p_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual MxResult VTable0x1c(LegoFileStream* p_legoFileStream) override; // vtable+0x1c
|
virtual MxResult VTable0x1c(LegoFile* p_legoFile) override; // vtable+0x1c
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x100764c0
|
// SYNTHETIC: LEGO1 0x100764c0
|
||||||
// HospitalState::`scalar deleting destructor'
|
// HospitalState::`scalar deleting destructor'
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
#ifndef LEGOANIMPRESENTER_H
|
#ifndef LEGOANIMPRESENTER_H
|
||||||
#define LEGOANIMPRESENTER_H
|
#define LEGOANIMPRESENTER_H
|
||||||
|
|
||||||
|
#include "lego/sources/misc/legostorage.h"
|
||||||
#include "mxgeometry/mxgeometry3d.h"
|
#include "mxgeometry/mxgeometry3d.h"
|
||||||
#include "mxvideopresenter.h"
|
#include "mxvideopresenter.h"
|
||||||
|
|
||||||
class LegoWorld;
|
class LegoWorld;
|
||||||
class LegoMemoryStream;
|
|
||||||
class LegoAnimClass;
|
class LegoAnimClass;
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100d90c8
|
// VTABLE: LEGO1 0x100d90c8
|
||||||
@@ -99,7 +99,7 @@ public:
|
|||||||
|
|
||||||
virtual void VTable0x8() override; // vtable+0x08
|
virtual void VTable0x8() override; // vtable+0x08
|
||||||
virtual void VTable0xc() override; // vtable+0x0c
|
virtual void VTable0xc() override; // vtable+0x0c
|
||||||
virtual MxResult VTable0x10(LegoMemoryStream* p_stream, MxS32); // vtable+0x10
|
virtual MxResult VTable0x10(LegoMemory* p_stream, MxS32); // vtable+0x10
|
||||||
|
|
||||||
MxLong m_unk0x8; // 0x08
|
MxLong m_unk0x8; // 0x08
|
||||||
undefined4 m_unk0xc; // 0x0c
|
undefined4 m_unk0xc; // 0x0c
|
||||||
|
@@ -2,10 +2,11 @@
|
|||||||
#define LEGOGAMESTATE_H
|
#define LEGOGAMESTATE_H
|
||||||
|
|
||||||
#include "decomp.h"
|
#include "decomp.h"
|
||||||
|
#include "lego/sources/misc/legostorage.h"
|
||||||
#include "legobackgroundcolor.h"
|
#include "legobackgroundcolor.h"
|
||||||
#include "legofullscreenmovie.h"
|
#include "legofullscreenmovie.h"
|
||||||
#include "legostream.h"
|
|
||||||
#include "mxtypes.h"
|
#include "mxtypes.h"
|
||||||
|
#include "mxvariabletable.h"
|
||||||
|
|
||||||
class LegoState;
|
class LegoState;
|
||||||
class MxVariable;
|
class MxVariable;
|
||||||
@@ -47,7 +48,7 @@ public:
|
|||||||
|
|
||||||
struct ScoreStruct {
|
struct ScoreStruct {
|
||||||
void WriteScoreHistory();
|
void WriteScoreHistory();
|
||||||
void FUN_1003ccf0(LegoFileStream&);
|
void FUN_1003ccf0(LegoFile&);
|
||||||
|
|
||||||
MxU16 m_unk0x00;
|
MxU16 m_unk0x00;
|
||||||
undefined m_unk0x02[0x2c][20];
|
undefined m_unk0x02[0x2c][20];
|
||||||
@@ -55,7 +56,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void RegisterState(LegoState* p_state);
|
void RegisterState(LegoState* p_state);
|
||||||
MxResult WriteEndOfVariables(LegoStream* p_stream);
|
MxResult WriteVariable(LegoStorage* p_stream, MxVariableTable* p_from, const char* p_variableName);
|
||||||
|
MxResult WriteEndOfVariables(LegoStorage* p_stream);
|
||||||
|
MxS32 ReadVariable(LegoStorage* p_stream, MxVariableTable* p_to);
|
||||||
void SetROIHandlerFunction();
|
void SetROIHandlerFunction();
|
||||||
|
|
||||||
char* m_savePath; // 0x0
|
char* m_savePath; // 0x0
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#define LEGOSTATE_H
|
#define LEGOSTATE_H
|
||||||
|
|
||||||
#include "decomp.h"
|
#include "decomp.h"
|
||||||
#include "legostream.h"
|
#include "lego/sources/misc/legostorage.h"
|
||||||
#include "mxcore.h"
|
#include "mxcore.h"
|
||||||
#include "mxstring.h"
|
#include "mxstring.h"
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ public:
|
|||||||
|
|
||||||
virtual MxBool VTable0x14(); // vtable+0x14
|
virtual MxBool VTable0x14(); // vtable+0x14
|
||||||
virtual MxBool SetFlag(); // vtable+0x18
|
virtual MxBool SetFlag(); // vtable+0x18
|
||||||
virtual MxResult VTable0x1c(LegoFileStream* p_legoFileStream); // vtable+0x1C
|
virtual MxResult VTable0x1c(LegoFile* p_legoFile); // vtable+0x1C
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x10006160
|
// SYNTHETIC: LEGO1 0x10006160
|
||||||
// LegoState::`scalar deleting destructor'
|
// LegoState::`scalar deleting destructor'
|
||||||
|
@@ -1,91 +0,0 @@
|
|||||||
#ifndef LEGOSTREAM_H
|
|
||||||
#define LEGOSTREAM_H
|
|
||||||
|
|
||||||
#include "compat.h"
|
|
||||||
#include "decomp.h"
|
|
||||||
#include "mxstring.h"
|
|
||||||
#include "mxtypes.h"
|
|
||||||
|
|
||||||
#pragma warning(disable : 4237)
|
|
||||||
#include <iosfwd>
|
|
||||||
|
|
||||||
#define LEGOSTREAM_MODE_READ 1
|
|
||||||
#define LEGOSTREAM_MODE_WRITE 2
|
|
||||||
|
|
||||||
class MxVariableTable;
|
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100d7d80
|
|
||||||
class LegoStream {
|
|
||||||
public:
|
|
||||||
LegoStream() : m_mode(0) {}
|
|
||||||
// FUNCTION: LEGO1 0x10045ad0
|
|
||||||
inline virtual ~LegoStream() {}
|
|
||||||
|
|
||||||
virtual MxResult Read(void* p_buffer, MxU32 p_size) = 0;
|
|
||||||
virtual MxResult Write(const void* p_buffer, MxU32 p_size) = 0;
|
|
||||||
virtual MxResult Tell(MxU32* p_offset) = 0;
|
|
||||||
virtual MxResult Seek(MxU32 p_offset) = 0;
|
|
||||||
|
|
||||||
virtual MxBool IsWriteMode();
|
|
||||||
virtual MxBool IsReadMode();
|
|
||||||
|
|
||||||
enum OpenFlags {
|
|
||||||
c_readBit = 1,
|
|
||||||
c_writeBit = 2,
|
|
||||||
c_binaryBit = 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
static MxResult __stdcall WriteVariable(LegoStream* p_stream, MxVariableTable* p_from, const char* p_variableName);
|
|
||||||
static MxS32 __stdcall ReadVariable(LegoStream* p_stream, MxVariableTable* p_to);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
MxU8 m_mode;
|
|
||||||
};
|
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x10045b00
|
|
||||||
// LegoStream::`scalar deleting destructor'
|
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100db730
|
|
||||||
class LegoFileStream : public LegoStream {
|
|
||||||
public:
|
|
||||||
LegoFileStream();
|
|
||||||
virtual ~LegoFileStream() override;
|
|
||||||
|
|
||||||
MxResult Read(void* p_buffer, MxU32 p_size) override;
|
|
||||||
MxResult Write(const void* p_buffer, MxU32 p_size) override;
|
|
||||||
MxResult Tell(MxU32* p_offset) override;
|
|
||||||
MxResult Seek(MxU32 p_offset) override;
|
|
||||||
|
|
||||||
MxResult Open(const char* p_filename, OpenFlags p_mode);
|
|
||||||
|
|
||||||
LegoFileStream* FUN_10006030(MxString p_str);
|
|
||||||
|
|
||||||
private:
|
|
||||||
FILE* m_hFile;
|
|
||||||
};
|
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x10099230
|
|
||||||
// LegoFileStream::`scalar deleting destructor'
|
|
||||||
|
|
||||||
// VTABLE: LEGO1 0x100db710
|
|
||||||
class LegoMemoryStream : public LegoStream {
|
|
||||||
public:
|
|
||||||
LegoMemoryStream(char* p_buffer);
|
|
||||||
|
|
||||||
MxResult Read(void* p_buffer, MxU32 p_size) override;
|
|
||||||
MxResult Write(const void* p_buffer, MxU32 p_size) override;
|
|
||||||
MxResult Tell(MxU32* p_offset) override;
|
|
||||||
MxResult Seek(MxU32 p_offset) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
char* m_buffer;
|
|
||||||
MxU32 m_offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x10045a80
|
|
||||||
// LegoMemoryStream::~LegoMemoryStream
|
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x100990f0
|
|
||||||
// LegoMemoryStream::`scalar deleting destructor'
|
|
||||||
|
|
||||||
#endif // LEGOSTREAM_H
|
|
@@ -2,11 +2,11 @@
|
|||||||
#define LEGOUNKSAVEDATAWRITER_H
|
#define LEGOUNKSAVEDATAWRITER_H
|
||||||
|
|
||||||
#include "decomp.h"
|
#include "decomp.h"
|
||||||
|
#include "lego/sources/misc/legostorage.h"
|
||||||
#include "mxtypes.h"
|
#include "mxtypes.h"
|
||||||
|
|
||||||
class AutoROI;
|
class AutoROI;
|
||||||
class LegoROI;
|
class LegoROI;
|
||||||
class LegoStream;
|
|
||||||
|
|
||||||
struct LegoSaveDataEntry3 {
|
struct LegoSaveDataEntry3 {
|
||||||
char* m_name;
|
char* m_name;
|
||||||
@@ -35,7 +35,7 @@ struct LegoSaveDataEntry3 {
|
|||||||
|
|
||||||
class LegoUnkSaveDataWriter {
|
class LegoUnkSaveDataWriter {
|
||||||
public:
|
public:
|
||||||
MxResult WriteSaveData3(LegoStream* p_stream);
|
MxResult WriteSaveData3(LegoStorage* p_stream);
|
||||||
AutoROI* FUN_10083500(undefined4, undefined4);
|
AutoROI* FUN_10083500(undefined4, undefined4);
|
||||||
void FUN_10083db0(LegoROI* p_roi);
|
void FUN_10083db0(LegoROI* p_roi);
|
||||||
};
|
};
|
||||||
|
@@ -23,7 +23,7 @@ public:
|
|||||||
return !strcmp(p_name, this->m_className.GetData()) || LegoState::IsA(p_name);
|
return !strcmp(p_name, this->m_className.GetData()) || LegoState::IsA(p_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual MxResult VTable0x1c(LegoFileStream* p_legoFileStream) override; // vtable+0x1c
|
virtual MxResult VTable0x1c(LegoFile* p_legoFile) override; // vtable+0x1c
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x100260a0
|
// SYNTHETIC: LEGO1 0x100260a0
|
||||||
// LegoVehicleBuildState::`scalar deleting destructor'
|
// LegoVehicleBuildState::`scalar deleting destructor'
|
||||||
|
@@ -13,7 +13,7 @@ class IslePathActor;
|
|||||||
class LegoPathBoundary;
|
class LegoPathBoundary;
|
||||||
|
|
||||||
struct PresenterSetCompare {
|
struct PresenterSetCompare {
|
||||||
int operator()(MxPresenter* const& p_a, MxPresenter* const& p_b) const { return p_a > p_b; }
|
MxS32 operator()(MxPresenter* const& p_a, MxPresenter* const& p_b) const { return p_a > p_b; }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef set<MxPresenter*, PresenterSetCompare> MxPresenterSet;
|
typedef set<MxPresenter*, PresenterSetCompare> MxPresenterSet;
|
||||||
@@ -23,7 +23,7 @@ typedef set<MxPresenter*, PresenterSetCompare> MxPresenterSet;
|
|||||||
class LegoWorld : public LegoEntity {
|
class LegoWorld : public LegoEntity {
|
||||||
public:
|
public:
|
||||||
__declspec(dllexport) LegoWorld();
|
__declspec(dllexport) LegoWorld();
|
||||||
__declspec(dllexport) virtual ~LegoWorld(); // vtable+0x0
|
__declspec(dllexport) virtual ~LegoWorld() override; // vtable+0x0
|
||||||
|
|
||||||
virtual MxLong Notify(MxParam& p_param) override; // vtable+0x4
|
virtual MxLong Notify(MxParam& p_param) override; // vtable+0x4
|
||||||
virtual MxResult Tickle() override; // vtable+0x8
|
virtual MxResult Tickle() override; // vtable+0x8
|
||||||
@@ -119,7 +119,6 @@ protected:
|
|||||||
|
|
||||||
// TEMPLATE: LEGO1 0x1001df00
|
// TEMPLATE: LEGO1 0x1001df00
|
||||||
// Set<MxPresenter *,PresenterSetCompare>::~Set<MxPresenter *,PresenterSetCompare>
|
// Set<MxPresenter *,PresenterSetCompare>::~Set<MxPresenter *,PresenterSetCompare>
|
||||||
// clang-format om
|
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x1001eed0
|
// SYNTHETIC: LEGO1 0x1001eed0
|
||||||
// MxPresenterListCursor::`scalar deleting destructor'
|
// MxPresenterListCursor::`scalar deleting destructor'
|
||||||
@@ -143,6 +142,7 @@ protected:
|
|||||||
// MxListCursor<MxPresenter *>::MxListCursor<MxPresenter *>
|
// MxListCursor<MxPresenter *>::MxListCursor<MxPresenter *>
|
||||||
|
|
||||||
// GLOBAL: LEGO1 0x100f11a0
|
// GLOBAL: LEGO1 0x100f11a0
|
||||||
// _Tree<MxPresenter *,MxPresenter *,set<MxPresenter *,PresenterSetCompare,allocator<MxPresenter *> >::_Kfn,PresenterSetCompare,allocator<MxPresenter *> >::_Nil
|
// _Tree<MxPresenter *,MxPresenter *,set<MxPresenter *,PresenterSetCompare,allocator<MxPresenter *>>::_Kfn,PresenterSetCompare,allocator<MxPresenter *> >::_Nil
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
#endif // LEGOWORLD_H
|
#endif // LEGOWORLD_H
|
||||||
|
@@ -28,7 +28,7 @@ public:
|
|||||||
return !strcmp(p_name, PizzaMissionState::ClassName()) || LegoState::IsA(p_name);
|
return !strcmp(p_name, PizzaMissionState::ClassName()) || LegoState::IsA(p_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual MxResult VTable0x1c(LegoFileStream* p_legoFileStream) override; // vtable+0x1c
|
virtual MxResult VTable0x1c(LegoFile* p_legoFile) override; // vtable+0x1c
|
||||||
|
|
||||||
inline MxU16 GetColor(MxU8 p_id) { return GetState(p_id)->m_color; }
|
inline MxU16 GetColor(MxU8 p_id) { return GetState(p_id)->m_color; }
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ public:
|
|||||||
return !strcmp(p_name, PizzeriaState::ClassName()) || LegoState::IsA(p_name);
|
return !strcmp(p_name, PizzeriaState::ClassName()) || LegoState::IsA(p_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual MxResult VTable0x1c(LegoFileStream* p_legoFileStream) override; // vtable+0x1c
|
virtual MxResult VTable0x1c(LegoFile* p_legoFile) override; // vtable+0x1c
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x10017ce0
|
// SYNTHETIC: LEGO1 0x10017ce0
|
||||||
// PizzeriaState::`scalar deleting destructor'
|
// PizzeriaState::`scalar deleting destructor'
|
||||||
|
@@ -23,7 +23,7 @@ public:
|
|||||||
return !strcmp(p_name, PoliceState::ClassName()) || LegoState::IsA(p_name);
|
return !strcmp(p_name, PoliceState::ClassName()) || LegoState::IsA(p_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual MxResult VTable0x1c(LegoFileStream* p_legoFileStream) override; // vtable+0x1c
|
virtual MxResult VTable0x1c(LegoFile* p_legoFile) override; // vtable+0x1c
|
||||||
|
|
||||||
// SYNTHETIC: LEGO1 0x1005e920
|
// SYNTHETIC: LEGO1 0x1005e920
|
||||||
// PoliceState::`scalar deleting destructor'
|
// PoliceState::`scalar deleting destructor'
|
||||||
|
@@ -30,7 +30,7 @@ public:
|
|||||||
return !strcmp(p_name, RaceState::ClassName()) || LegoState::IsA(p_name);
|
return !strcmp(p_name, RaceState::ClassName()) || LegoState::IsA(p_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual MxResult VTable0x1c(LegoFileStream* p_legoFileStream) override; // vtable+0x1c
|
virtual MxResult VTable0x1c(LegoFile* p_legoFile) override; // vtable+0x1c
|
||||||
|
|
||||||
inline MxU16 GetColor(MxU8 p_id) { return GetState(p_id)->m_color; }
|
inline MxU16 GetColor(MxU8 p_id) { return GetState(p_id)->m_color; }
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ public:
|
|||||||
{
|
{
|
||||||
return !strcmp(p_name, TowTrackMissionState::ClassName()) || LegoState::IsA(p_name);
|
return !strcmp(p_name, TowTrackMissionState::ClassName()) || LegoState::IsA(p_name);
|
||||||
}
|
}
|
||||||
virtual MxResult VTable0x1c(LegoFileStream* p_legoFileStream) override; // vtable+0x1C
|
virtual MxResult VTable0x1c(LegoFile* p_legoFile) override; // vtable+0x1C
|
||||||
|
|
||||||
inline MxU16 GetColor(MxU8 p_id)
|
inline MxU16 GetColor(MxU8 p_id)
|
||||||
{
|
{
|
||||||
|
@@ -14,7 +14,7 @@ Act1State::Act1State()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x10033ac0
|
// STUB: LEGO1 0x10033ac0
|
||||||
MxResult Act1State::VTable0x1c(LegoFileStream* p_legoFileStream)
|
MxResult Act1State::VTable0x1c(LegoFile* p_legoFile)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
@@ -25,7 +25,7 @@ LegoVehicleBuildState::LegoVehicleBuildState(char* p_classType)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x10026120
|
// STUB: LEGO1 0x10026120
|
||||||
MxResult LegoVehicleBuildState::VTable0x1c(LegoFileStream* p_legoFileStream)
|
MxResult LegoVehicleBuildState::VTable0x1c(LegoFile* p_legoFile)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
@@ -18,7 +18,7 @@ AnimState::~AnimState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x100652d0
|
// STUB: LEGO1 0x100652d0
|
||||||
MxResult AnimState::VTable0x1c(LegoFileStream* p_legoFileStream)
|
MxResult AnimState::VTable0x1c(LegoFile* p_legoFile)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
#include "legoanimationmanager.h"
|
#include "legoanimationmanager.h"
|
||||||
#include "legoomni.h"
|
#include "legoomni.h"
|
||||||
#include "legostate.h"
|
#include "legostate.h"
|
||||||
#include "legostream.h"
|
|
||||||
#include "legoutil.h"
|
#include "legoutil.h"
|
||||||
#include "legovideomanager.h"
|
#include "legovideomanager.h"
|
||||||
#include "mxbackgroundaudiomanager.h"
|
#include "mxbackgroundaudiomanager.h"
|
||||||
@@ -31,6 +30,13 @@ const char* g_playersGSI = "Players.gsi";
|
|||||||
// STRING: LEGO1 0x100f3e24
|
// STRING: LEGO1 0x100f3e24
|
||||||
const char* g_historyGSI = "History.gsi";
|
const char* g_historyGSI = "History.gsi";
|
||||||
|
|
||||||
|
// This is a pointer to the end of the global variable name table, which has
|
||||||
|
// the text "END_OF_VARIABLES" in it.
|
||||||
|
// TODO: make g_endOfVariables reference the actual end of the variable array.
|
||||||
|
// GLOBAL: LEGO1 0x100f3e50
|
||||||
|
// STRING: LEGO1 0x100f3e00
|
||||||
|
const char* g_endOfVariables = "END_OF_VARIABLES";
|
||||||
|
|
||||||
// GLOBAL: LEGO1 0x100f3e58
|
// GLOBAL: LEGO1 0x100f3e58
|
||||||
ColorStringStruct g_colorSaveData[43] = {
|
ColorStringStruct g_colorSaveData[43] = {
|
||||||
{"c_dbbkfny0", "lego red"}, {"c_dbbkxly0", "lego white"}, {"c_chbasey0", "lego black"},
|
{"c_dbbkfny0", "lego red"}, {"c_dbbkxly0", "lego white"}, {"c_chbasey0", "lego black"},
|
||||||
@@ -119,8 +125,8 @@ MxResult LegoGameState::Save(MxULong p_slot)
|
|||||||
MxVariableTable* variableTable = VariableTable();
|
MxVariableTable* variableTable = VariableTable();
|
||||||
MxString savePath;
|
MxString savePath;
|
||||||
GetFileSavePath(&savePath, p_slot);
|
GetFileSavePath(&savePath, p_slot);
|
||||||
LegoFileStream fileStream;
|
LegoFile fileStream;
|
||||||
if (fileStream.Open(savePath.GetData(), LegoStream::c_writeBit) != FAILURE) {
|
if (fileStream.Open(savePath.GetData(), LegoFile::c_write) != FAILURE) {
|
||||||
MxU32 maybeVersion = 0x1000C;
|
MxU32 maybeVersion = 0x1000C;
|
||||||
fileStream.Write(&maybeVersion, 4);
|
fileStream.Write(&maybeVersion, 4);
|
||||||
fileStream.Write(&m_unk0x24, 2);
|
fileStream.Write(&m_unk0x24, 2);
|
||||||
@@ -128,12 +134,12 @@ MxResult LegoGameState::Save(MxULong p_slot)
|
|||||||
fileStream.Write(&m_unk0xc, 1);
|
fileStream.Write(&m_unk0xc, 1);
|
||||||
|
|
||||||
for (MxS32 i = 0; i < sizeof(g_colorSaveData) / sizeof(g_colorSaveData[0]); ++i) {
|
for (MxS32 i = 0; i < sizeof(g_colorSaveData) / sizeof(g_colorSaveData[0]); ++i) {
|
||||||
if (LegoStream::WriteVariable(&fileStream, variableTable, g_colorSaveData[i].m_targetName) == FAILURE)
|
if (WriteVariable(&fileStream, variableTable, g_colorSaveData[i].m_targetName) == FAILURE)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LegoStream::WriteVariable(&fileStream, variableTable, "backgroundcolor") != FAILURE) {
|
if (WriteVariable(&fileStream, variableTable, "backgroundcolor") != FAILURE) {
|
||||||
if (LegoStream::WriteVariable(&fileStream, variableTable, "lightposition") != FAILURE) {
|
if (WriteVariable(&fileStream, variableTable, "lightposition") != FAILURE) {
|
||||||
WriteEndOfVariables(&fileStream);
|
WriteEndOfVariables(&fileStream);
|
||||||
|
|
||||||
// TODO: Calls down to more aggregate writing functions
|
// TODO: Calls down to more aggregate writing functions
|
||||||
@@ -166,8 +172,27 @@ void LegoGameState::SetSavePath(char* p_savePath)
|
|||||||
m_savePath = NULL;
|
m_savePath = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10039f70
|
||||||
|
MxResult LegoGameState::WriteVariable(LegoStorage* p_stream, MxVariableTable* p_from, const char* p_variableName)
|
||||||
|
{
|
||||||
|
MxResult result = FAILURE;
|
||||||
|
const char* variableValue = p_from->GetVariable(p_variableName);
|
||||||
|
|
||||||
|
if (variableValue) {
|
||||||
|
MxU8 length = strlen(p_variableName);
|
||||||
|
if (p_stream->Write((char*) &length, 1) == SUCCESS) {
|
||||||
|
if (p_stream->Write(p_variableName, length) == SUCCESS) {
|
||||||
|
length = strlen(variableValue);
|
||||||
|
if (p_stream->Write((char*) &length, 1) == SUCCESS)
|
||||||
|
result = p_stream->Write((char*) variableValue, length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1003a020
|
// FUNCTION: LEGO1 0x1003a020
|
||||||
MxResult LegoGameState::WriteEndOfVariables(LegoStream* p_stream)
|
MxResult LegoGameState::WriteEndOfVariables(LegoStorage* p_stream)
|
||||||
{
|
{
|
||||||
MxU8 len = strlen(g_endOfVariables);
|
MxU8 len = strlen(g_endOfVariables);
|
||||||
if (p_stream->Write(&len, 1) == SUCCESS)
|
if (p_stream->Write(&len, 1) == SUCCESS)
|
||||||
@@ -175,6 +200,36 @@ MxResult LegoGameState::WriteEndOfVariables(LegoStream* p_stream)
|
|||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 95% match, just some instruction ordering differences on the call to
|
||||||
|
// MxVariableTable::SetVariable at the end.
|
||||||
|
// FUNCTION: LEGO1 0x1003a080
|
||||||
|
MxS32 LegoGameState::ReadVariable(LegoStorage* p_stream, MxVariableTable* p_to)
|
||||||
|
{
|
||||||
|
MxS32 result = 1;
|
||||||
|
MxU8 length;
|
||||||
|
|
||||||
|
if (p_stream->Read((char*) &length, 1) == SUCCESS) {
|
||||||
|
char nameBuffer[256];
|
||||||
|
if (p_stream->Read(nameBuffer, length) == SUCCESS) {
|
||||||
|
nameBuffer[length] = '\0';
|
||||||
|
if (strcmp(nameBuffer, g_endOfVariables) == 0)
|
||||||
|
// 2 -> "This was the last entry, done reading."
|
||||||
|
result = 2;
|
||||||
|
else {
|
||||||
|
if (p_stream->Read((char*) &length, 1) == SUCCESS) {
|
||||||
|
char valueBuffer[256];
|
||||||
|
if (p_stream->Read(valueBuffer, length) == SUCCESS) {
|
||||||
|
result = 0;
|
||||||
|
valueBuffer[length] = '\0';
|
||||||
|
p_to->SetVariable(nameBuffer, valueBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1003a170
|
// FUNCTION: LEGO1 0x1003a170
|
||||||
void LegoGameState::GetFileSavePath(MxString* p_outPath, MxULong p_slotn)
|
void LegoGameState::GetFileSavePath(MxString* p_outPath, MxULong p_slotn)
|
||||||
{
|
{
|
||||||
@@ -312,7 +367,7 @@ void LegoGameState::ScoreStruct::WriteScoreHistory()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x1003ccf0
|
// STUB: LEGO1 0x1003ccf0
|
||||||
void LegoGameState::ScoreStruct::FUN_1003ccf0(LegoFileStream&)
|
void LegoGameState::ScoreStruct::FUN_1003ccf0(LegoFile&)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
@@ -320,16 +375,16 @@ void LegoGameState::ScoreStruct::FUN_1003ccf0(LegoFileStream&)
|
|||||||
// FUNCTION: LEGO1 0x1003cdd0
|
// FUNCTION: LEGO1 0x1003cdd0
|
||||||
void LegoGameState::SerializeScoreHistory(MxS16 p_flags)
|
void LegoGameState::SerializeScoreHistory(MxS16 p_flags)
|
||||||
{
|
{
|
||||||
LegoFileStream stream;
|
LegoFile stream;
|
||||||
MxString savePath(m_savePath);
|
MxString savePath(m_savePath);
|
||||||
savePath += "\\";
|
savePath += "\\";
|
||||||
savePath += g_historyGSI;
|
savePath += g_historyGSI;
|
||||||
|
|
||||||
if (p_flags == LegoStream::c_writeBit) {
|
if (p_flags == LegoFile::c_write) {
|
||||||
m_unk0xa6.WriteScoreHistory();
|
m_unk0xa6.WriteScoreHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream.Open(savePath.GetData(), (LegoStream::OpenFlags) p_flags) == SUCCESS) {
|
if (stream.Open(savePath.GetData(), p_flags) == SUCCESS) {
|
||||||
m_unk0xa6.FUN_1003ccf0(stream);
|
m_unk0xa6.FUN_1003ccf0(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,23 +20,10 @@ MxBool LegoState::SetFlag()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10005fb0
|
// FUNCTION: LEGO1 0x10005fb0
|
||||||
MxResult LegoState::VTable0x1c(LegoFileStream* p_legoFileStream)
|
MxResult LegoState::VTable0x1c(LegoFile* p_legoFile)
|
||||||
{
|
{
|
||||||
if (p_legoFileStream->IsWriteMode()) {
|
if (p_legoFile->IsWriteMode()) {
|
||||||
p_legoFileStream->FUN_10006030(this->ClassName());
|
p_legoFile->FUN_10006030(this->ClassName());
|
||||||
}
|
}
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10006030
|
|
||||||
LegoFileStream* LegoFileStream::FUN_10006030(MxString p_str)
|
|
||||||
{
|
|
||||||
const char* data = p_str.GetData();
|
|
||||||
MxU32 fullLength = strlen(data);
|
|
||||||
|
|
||||||
MxU16 limitedLength = fullLength;
|
|
||||||
Write(&limitedLength, sizeof(limitedLength));
|
|
||||||
Write(data, (MxS16) fullLength);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
@@ -1,201 +0,0 @@
|
|||||||
|
|
||||||
#include "legostream.h"
|
|
||||||
|
|
||||||
#include "mxvariabletable.h"
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
// This is a pointer to the end of the global variable name table, which has
|
|
||||||
// the text "END_OF_VARIABLES" in it.
|
|
||||||
// TODO: make g_endOfVariables reference the actual end of the variable array.
|
|
||||||
// GLOBAL: LEGO1 0x100f3e50
|
|
||||||
// STRING: LEGO1 0x100f3e00
|
|
||||||
const char* g_endOfVariables = "END_OF_VARIABLES";
|
|
||||||
|
|
||||||
// Very likely but not certain sizes.
|
|
||||||
// The classes are only used on the stack in functions we have not 100% matched
|
|
||||||
// yet, we can confirm the size once we have.
|
|
||||||
DECOMP_SIZE_ASSERT(LegoStream, 0x8);
|
|
||||||
DECOMP_SIZE_ASSERT(LegoFileStream, 0xC);
|
|
||||||
DECOMP_SIZE_ASSERT(LegoMemoryStream, 0x10);
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10039f70
|
|
||||||
MxResult LegoStream::WriteVariable(LegoStream* p_stream, MxVariableTable* p_from, const char* p_variableName)
|
|
||||||
{
|
|
||||||
MxResult result = FAILURE;
|
|
||||||
const char* variableValue = p_from->GetVariable(p_variableName);
|
|
||||||
|
|
||||||
if (variableValue) {
|
|
||||||
MxU8 length = strlen(p_variableName);
|
|
||||||
if (p_stream->Write((char*) &length, 1) == SUCCESS) {
|
|
||||||
if (p_stream->Write(p_variableName, length) == SUCCESS) {
|
|
||||||
length = strlen(variableValue);
|
|
||||||
if (p_stream->Write((char*) &length, 1) == SUCCESS)
|
|
||||||
result = p_stream->Write((char*) variableValue, length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 95% match, just some instruction ordering differences on the call to
|
|
||||||
// MxVariableTable::SetVariable at the end.
|
|
||||||
// FUNCTION: LEGO1 0x1003a080
|
|
||||||
MxS32 LegoStream::ReadVariable(LegoStream* p_stream, MxVariableTable* p_to)
|
|
||||||
{
|
|
||||||
MxS32 result = 1;
|
|
||||||
MxU8 length;
|
|
||||||
|
|
||||||
if (p_stream->Read((char*) &length, 1) == SUCCESS) {
|
|
||||||
char nameBuffer[256];
|
|
||||||
if (p_stream->Read(nameBuffer, length) == SUCCESS) {
|
|
||||||
nameBuffer[length] = '\0';
|
|
||||||
if (strcmp(nameBuffer, g_endOfVariables) == 0)
|
|
||||||
// 2 -> "This was the last entry, done reading."
|
|
||||||
result = 2;
|
|
||||||
else {
|
|
||||||
if (p_stream->Read((char*) &length, 1) == SUCCESS) {
|
|
||||||
char valueBuffer[256];
|
|
||||||
if (p_stream->Read(valueBuffer, length) == SUCCESS) {
|
|
||||||
result = 0;
|
|
||||||
valueBuffer[length] = '\0';
|
|
||||||
p_to->SetVariable(nameBuffer, valueBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10045ae0
|
|
||||||
MxBool LegoStream::IsWriteMode()
|
|
||||||
{
|
|
||||||
return m_mode == LEGOSTREAM_MODE_WRITE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10045af0
|
|
||||||
MxBool LegoStream::IsReadMode()
|
|
||||||
{
|
|
||||||
return m_mode == LEGOSTREAM_MODE_READ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10099080
|
|
||||||
LegoMemoryStream::LegoMemoryStream(char* p_buffer) : LegoStream()
|
|
||||||
{
|
|
||||||
m_buffer = p_buffer;
|
|
||||||
m_offset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10099160
|
|
||||||
MxResult LegoMemoryStream::Read(void* p_buffer, MxU32 p_size)
|
|
||||||
{
|
|
||||||
memcpy(p_buffer, m_buffer + m_offset, p_size);
|
|
||||||
m_offset += p_size;
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10099190
|
|
||||||
MxResult LegoMemoryStream::Write(const void* p_buffer, MxU32 p_size)
|
|
||||||
{
|
|
||||||
memcpy(m_buffer + m_offset, p_buffer, p_size);
|
|
||||||
m_offset += p_size;
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100991c0
|
|
||||||
LegoFileStream::LegoFileStream() : LegoStream()
|
|
||||||
{
|
|
||||||
m_hFile = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10099250
|
|
||||||
LegoFileStream::~LegoFileStream()
|
|
||||||
{
|
|
||||||
if (m_hFile != NULL)
|
|
||||||
fclose(m_hFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100992c0
|
|
||||||
MxResult LegoFileStream::Read(void* p_buffer, MxU32 p_size)
|
|
||||||
{
|
|
||||||
if (m_hFile == NULL)
|
|
||||||
return FAILURE;
|
|
||||||
|
|
||||||
return (fread(p_buffer, 1, p_size, m_hFile) == p_size) ? SUCCESS : FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10099300
|
|
||||||
MxResult LegoFileStream::Write(const void* p_buffer, MxU32 p_size)
|
|
||||||
{
|
|
||||||
if (m_hFile == NULL)
|
|
||||||
return FAILURE;
|
|
||||||
|
|
||||||
return (fwrite(p_buffer, 1, p_size, m_hFile) == p_size) ? SUCCESS : FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10099340
|
|
||||||
MxResult LegoFileStream::Tell(MxU32* p_offset)
|
|
||||||
{
|
|
||||||
if (m_hFile == NULL)
|
|
||||||
return FAILURE;
|
|
||||||
|
|
||||||
int got = ftell(m_hFile);
|
|
||||||
if (got == -1)
|
|
||||||
return FAILURE;
|
|
||||||
|
|
||||||
*p_offset = got;
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10099370
|
|
||||||
MxResult LegoFileStream::Seek(MxU32 p_offset)
|
|
||||||
{
|
|
||||||
if (m_hFile == NULL)
|
|
||||||
return FAILURE;
|
|
||||||
|
|
||||||
return (fseek(m_hFile, p_offset, 0) == 0) ? SUCCESS : FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100993a0
|
|
||||||
MxResult LegoFileStream::Open(const char* p_filename, OpenFlags p_mode)
|
|
||||||
{
|
|
||||||
char modeString[4];
|
|
||||||
|
|
||||||
if (m_hFile != NULL)
|
|
||||||
fclose(m_hFile);
|
|
||||||
|
|
||||||
modeString[0] = '\0';
|
|
||||||
if (p_mode & c_readBit) {
|
|
||||||
m_mode = LEGOSTREAM_MODE_READ;
|
|
||||||
strcat(modeString, "r");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_mode & c_writeBit) {
|
|
||||||
if (m_mode != LEGOSTREAM_MODE_READ)
|
|
||||||
m_mode = LEGOSTREAM_MODE_WRITE;
|
|
||||||
strcat(modeString, "w");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((p_mode & c_binaryBit) != 0)
|
|
||||||
strcat(modeString, "b");
|
|
||||||
else
|
|
||||||
strcat(modeString, "t");
|
|
||||||
|
|
||||||
return (m_hFile = fopen(p_filename, modeString)) ? SUCCESS : FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100994a0
|
|
||||||
MxResult LegoMemoryStream::Tell(MxU32* p_offset)
|
|
||||||
{
|
|
||||||
*p_offset = m_offset;
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100994b0
|
|
||||||
MxResult LegoMemoryStream::Seek(MxU32 p_offset)
|
|
||||||
{
|
|
||||||
m_offset = p_offset;
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
@@ -1,7 +1,6 @@
|
|||||||
#include "legounksavedatawriter.h"
|
#include "legounksavedatawriter.h"
|
||||||
|
|
||||||
#include "legogamestate.h"
|
#include "legogamestate.h"
|
||||||
#include "legostream.h"
|
|
||||||
#include "roi/legoroi.h"
|
#include "roi/legoroi.h"
|
||||||
|
|
||||||
DECOMP_SIZE_ASSERT(LegoSaveDataEntry3, 0x108);
|
DECOMP_SIZE_ASSERT(LegoSaveDataEntry3, 0x108);
|
||||||
@@ -10,7 +9,7 @@ DECOMP_SIZE_ASSERT(LegoSaveDataEntry3, 0x108);
|
|||||||
LegoSaveDataEntry3 g_saveData3[66];
|
LegoSaveDataEntry3 g_saveData3[66];
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10083310
|
// FUNCTION: LEGO1 0x10083310
|
||||||
MxResult LegoUnkSaveDataWriter::WriteSaveData3(LegoStream* p_stream)
|
MxResult LegoUnkSaveDataWriter::WriteSaveData3(LegoStorage* p_stream)
|
||||||
{
|
{
|
||||||
MxResult result = FAILURE;
|
MxResult result = FAILURE;
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ GasStationState::GasStationState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x10006300
|
// STUB: LEGO1 0x10006300
|
||||||
MxResult GasStationState::VTable0x1c(LegoFileStream* p_legoFileStream)
|
MxResult GasStationState::VTable0x1c(LegoFile* p_legoFile)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
@@ -20,7 +20,7 @@ AmbulanceMissionState::AmbulanceMissionState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x10037440
|
// STUB: LEGO1 0x10037440
|
||||||
MxResult AmbulanceMissionState::VTable0x1c(LegoFileStream* p_legoFileStream)
|
MxResult AmbulanceMissionState::VTable0x1c(LegoFile* p_legoFile)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -14,7 +14,7 @@ HospitalState::HospitalState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x10076530
|
// STUB: LEGO1 0x10076530
|
||||||
MxResult HospitalState::VTable0x1c(LegoFileStream* p_legoFileStream)
|
MxResult HospitalState::VTable0x1c(LegoFile* p_legoFile)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -4,7 +4,7 @@ DECOMP_SIZE_ASSERT(PizzaMissionStateEntry, 0x20)
|
|||||||
DECOMP_SIZE_ASSERT(PizzaMissionState, 0xb0)
|
DECOMP_SIZE_ASSERT(PizzaMissionState, 0xb0)
|
||||||
|
|
||||||
// STUB: LEGO1 0x100393c0
|
// STUB: LEGO1 0x100393c0
|
||||||
MxResult PizzaMissionState::VTable0x1c(LegoFileStream* p_legoFileStream)
|
MxResult PizzaMissionState::VTable0x1c(LegoFile* p_legoFile)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
@@ -7,7 +7,7 @@ PizzeriaState::PizzeriaState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x10017da0
|
// STUB: LEGO1 0x10017da0
|
||||||
MxResult PizzeriaState::VTable0x1c(LegoFileStream* p_legoFileStream)
|
MxResult PizzeriaState::VTable0x1c(LegoFile* p_legoFile)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
@@ -12,18 +12,18 @@ PoliceState::PoliceState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1005e990
|
// FUNCTION: LEGO1 0x1005e990
|
||||||
MxResult PoliceState::VTable0x1c(LegoFileStream* p_legoFileStream)
|
MxResult PoliceState::VTable0x1c(LegoFile* p_legoFile)
|
||||||
{
|
{
|
||||||
if (p_legoFileStream->IsWriteMode()) {
|
if (p_legoFile->IsWriteMode()) {
|
||||||
p_legoFileStream->FUN_10006030(ClassName());
|
p_legoFile->FUN_10006030(ClassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_legoFileStream->IsReadMode()) {
|
if (p_legoFile->IsReadMode()) {
|
||||||
p_legoFileStream->Read(&m_unk0x8, sizeof(m_unk0x8));
|
p_legoFile->Read(&m_unk0x8, sizeof(m_unk0x8));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
undefined4 unk0x8 = m_unk0x8;
|
undefined4 unk0x8 = m_unk0x8;
|
||||||
p_legoFileStream->Write(&unk0x8, sizeof(m_unk0x8));
|
p_legoFile->Write(&unk0x8, sizeof(m_unk0x8));
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
@@ -12,7 +12,7 @@ RaceState::RaceState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x10016140
|
// STUB: LEGO1 0x10016140
|
||||||
MxResult RaceState::VTable0x1c(LegoFileStream* p_legoFileStream)
|
MxResult RaceState::VTable0x1c(LegoFile* p_legoFile)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
@@ -21,54 +21,54 @@ TowTrackMissionState::TowTrackMissionState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x1004dde0
|
// FUNCTION: LEGO1 0x1004dde0
|
||||||
MxResult TowTrackMissionState::VTable0x1c(LegoFileStream* p_legoFileStream)
|
MxResult TowTrackMissionState::VTable0x1c(LegoFile* p_legoFile)
|
||||||
{
|
{
|
||||||
if (p_legoFileStream->IsWriteMode()) {
|
if (p_legoFile->IsWriteMode()) {
|
||||||
p_legoFileStream->FUN_10006030(this->ClassName());
|
p_legoFile->FUN_10006030(this->ClassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_legoFileStream->IsReadMode()) {
|
if (p_legoFile->IsReadMode()) {
|
||||||
p_legoFileStream->Read(&m_unk0x12, sizeof(MxU16));
|
p_legoFile->Read(&m_unk0x12, sizeof(MxU16));
|
||||||
p_legoFileStream->Read(&m_unk0x14, sizeof(MxU16));
|
p_legoFile->Read(&m_unk0x14, sizeof(MxU16));
|
||||||
p_legoFileStream->Read(&m_unk0x16, sizeof(MxU16));
|
p_legoFile->Read(&m_unk0x16, sizeof(MxU16));
|
||||||
p_legoFileStream->Read(&m_unk0x18, sizeof(MxU16));
|
p_legoFile->Read(&m_unk0x18, sizeof(MxU16));
|
||||||
p_legoFileStream->Read(&m_unk0x1a, sizeof(MxU16));
|
p_legoFile->Read(&m_unk0x1a, sizeof(MxU16));
|
||||||
p_legoFileStream->Read(&m_unk0x1c, sizeof(MxU16));
|
p_legoFile->Read(&m_unk0x1c, sizeof(MxU16));
|
||||||
p_legoFileStream->Read(&m_color1, sizeof(MxU16));
|
p_legoFile->Read(&m_color1, sizeof(MxU16));
|
||||||
p_legoFileStream->Read(&m_color2, sizeof(MxU16));
|
p_legoFile->Read(&m_color2, sizeof(MxU16));
|
||||||
p_legoFileStream->Read(&m_color3, sizeof(MxU16));
|
p_legoFile->Read(&m_color3, sizeof(MxU16));
|
||||||
p_legoFileStream->Read(&m_color4, sizeof(MxU16));
|
p_legoFile->Read(&m_color4, sizeof(MxU16));
|
||||||
}
|
}
|
||||||
else if (p_legoFileStream->IsWriteMode()) {
|
else if (p_legoFile->IsWriteMode()) {
|
||||||
MxU16 write = m_unk0x12;
|
MxU16 write = m_unk0x12;
|
||||||
p_legoFileStream->Write(&write, sizeof(MxU16));
|
p_legoFile->Write(&write, sizeof(MxU16));
|
||||||
|
|
||||||
write = m_unk0x14;
|
write = m_unk0x14;
|
||||||
p_legoFileStream->Write(&write, sizeof(MxU16));
|
p_legoFile->Write(&write, sizeof(MxU16));
|
||||||
|
|
||||||
write = m_unk0x16;
|
write = m_unk0x16;
|
||||||
p_legoFileStream->Write(&write, sizeof(MxU16));
|
p_legoFile->Write(&write, sizeof(MxU16));
|
||||||
|
|
||||||
write = m_unk0x18;
|
write = m_unk0x18;
|
||||||
p_legoFileStream->Write(&write, sizeof(MxU16));
|
p_legoFile->Write(&write, sizeof(MxU16));
|
||||||
|
|
||||||
write = m_unk0x1a;
|
write = m_unk0x1a;
|
||||||
p_legoFileStream->Write(&write, sizeof(MxU16));
|
p_legoFile->Write(&write, sizeof(MxU16));
|
||||||
|
|
||||||
write = m_unk0x1c;
|
write = m_unk0x1c;
|
||||||
p_legoFileStream->Write(&write, sizeof(MxU16));
|
p_legoFile->Write(&write, sizeof(MxU16));
|
||||||
|
|
||||||
write = m_color1;
|
write = m_color1;
|
||||||
p_legoFileStream->Write(&write, sizeof(MxU16));
|
p_legoFile->Write(&write, sizeof(MxU16));
|
||||||
|
|
||||||
write = m_color2;
|
write = m_color2;
|
||||||
p_legoFileStream->Write(&write, sizeof(MxU16));
|
p_legoFile->Write(&write, sizeof(MxU16));
|
||||||
|
|
||||||
write = m_color3;
|
write = m_color3;
|
||||||
p_legoFileStream->Write(&write, sizeof(MxU16));
|
p_legoFile->Write(&write, sizeof(MxU16));
|
||||||
|
|
||||||
write = m_color4;
|
write = m_color4;
|
||||||
p_legoFileStream->Write(&write, sizeof(MxU16));
|
p_legoFile->Write(&write, sizeof(MxU16));
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
#include "legoanimpresenter.h"
|
#include "legoanimpresenter.h"
|
||||||
|
|
||||||
#include "legoomni.h"
|
#include "legoomni.h"
|
||||||
#include "legostream.h"
|
|
||||||
#include "legoworld.h"
|
#include "legoworld.h"
|
||||||
#include "mxcompositepresenter.h"
|
#include "mxcompositepresenter.h"
|
||||||
#include "mxdsanim.h"
|
#include "mxdsanim.h"
|
||||||
@@ -60,7 +59,7 @@ void LegoAnimPresenter::Destroy(MxBool p_fromDestructor)
|
|||||||
MxResult LegoAnimPresenter::VTable0x88(MxStreamChunk* p_chunk)
|
MxResult LegoAnimPresenter::VTable0x88(MxStreamChunk* p_chunk)
|
||||||
{
|
{
|
||||||
MxResult result = FAILURE;
|
MxResult result = FAILURE;
|
||||||
LegoMemoryStream stream((char*) p_chunk->GetData());
|
LegoMemory stream((char*) p_chunk->GetData());
|
||||||
|
|
||||||
MxS32 magicSig;
|
MxS32 magicSig;
|
||||||
MxS32 val2 = 0;
|
MxS32 val2 = 0;
|
||||||
@@ -238,7 +237,7 @@ LegoAnimClass::~LegoAnimClass()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STUB: LEGO1 0x100a0c70
|
// STUB: LEGO1 0x100a0c70
|
||||||
MxResult LegoAnimClass::VTable0x10(LegoMemoryStream* p_stream, MxS32)
|
MxResult LegoAnimClass::VTable0x10(LegoMemory* p_stream, MxS32)
|
||||||
{
|
{
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#include "legopalettepresenter.h"
|
#include "legopalettepresenter.h"
|
||||||
|
|
||||||
|
#include "lego/sources/misc/legostorage.h"
|
||||||
#include "legoomni.h"
|
#include "legoomni.h"
|
||||||
#include "legostream.h"
|
|
||||||
#include "legovideomanager.h"
|
#include "legovideomanager.h"
|
||||||
#include "mxstreamchunk.h"
|
#include "mxstreamchunk.h"
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ MxResult LegoPalettePresenter::ParsePalette(MxStreamChunk* p_chunk)
|
|||||||
RGBQUAD palette[256];
|
RGBQUAD palette[256];
|
||||||
MxResult result = FAILURE;
|
MxResult result = FAILURE;
|
||||||
|
|
||||||
LegoMemoryStream stream((char*) p_chunk->GetData());
|
LegoMemory stream((char*) p_chunk->GetData());
|
||||||
if (stream.Read(buffer, sizeof(buffer)) == SUCCESS) {
|
if (stream.Read(buffer, sizeof(buffer)) == SUCCESS) {
|
||||||
if (stream.Read(palette, sizeof(palette)) == SUCCESS) {
|
if (stream.Read(palette, sizeof(palette)) == SUCCESS) {
|
||||||
m_palette = new MxPalette(palette);
|
m_palette = new MxPalette(palette);
|
||||||
|
176
LEGO1/lego/sources/misc/legoimage.cpp
Normal file
176
LEGO1/lego/sources/misc/legoimage.cpp
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
#include "legoimage.h"
|
||||||
|
|
||||||
|
#include "decomp.h"
|
||||||
|
#include "legostorage.h"
|
||||||
|
#include "memory.h"
|
||||||
|
|
||||||
|
DECOMP_SIZE_ASSERT(LegoPaletteEntry, 0x3);
|
||||||
|
DECOMP_SIZE_ASSERT(LegoImage, 0x310);
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100994c0
|
||||||
|
LegoPaletteEntry::LegoPaletteEntry()
|
||||||
|
{
|
||||||
|
m_red = 0;
|
||||||
|
m_green = 0;
|
||||||
|
m_blue = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100994d0
|
||||||
|
LegoResult LegoPaletteEntry::Read(LegoStorage* p_storage)
|
||||||
|
{
|
||||||
|
LegoResult result;
|
||||||
|
if ((result = p_storage->Read(&m_red, sizeof(m_red))) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if ((result = p_storage->Read(&m_green, sizeof(m_green))) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if ((result = p_storage->Read(&m_blue, sizeof(m_blue))) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10099520
|
||||||
|
LegoResult LegoPaletteEntry::Write(LegoStorage* p_storage)
|
||||||
|
{
|
||||||
|
LegoResult result;
|
||||||
|
if ((result = p_storage->Write(&m_red, sizeof(m_red))) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if ((result = p_storage->Write(&m_green, sizeof(m_green))) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if ((result = p_storage->Write(&m_blue, sizeof(m_blue))) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10099570
|
||||||
|
LegoImage::LegoImage()
|
||||||
|
{
|
||||||
|
m_width = 0;
|
||||||
|
m_height = 0;
|
||||||
|
m_count = 0;
|
||||||
|
m_bits = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100995a0
|
||||||
|
LegoImage::LegoImage(LegoU32 p_width, LegoU32 p_height)
|
||||||
|
{
|
||||||
|
m_width = p_width;
|
||||||
|
m_height = p_height;
|
||||||
|
m_count = 0;
|
||||||
|
m_bits = new LegoU8[m_width * m_height];
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100995f0
|
||||||
|
LegoImage::~LegoImage()
|
||||||
|
{
|
||||||
|
if (m_bits) {
|
||||||
|
delete[] m_bits;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10099610
|
||||||
|
LegoResult LegoImage::Read(LegoStorage* p_storage, LegoU32 p_square)
|
||||||
|
{
|
||||||
|
LegoResult result;
|
||||||
|
if ((result = p_storage->Read(&m_width, sizeof(m_width))) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if ((result = p_storage->Read(&m_height, sizeof(m_height))) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if ((result = p_storage->Read(&m_count, sizeof(m_height))) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
for (LegoU32 i = 0; i < m_count; i++) {
|
||||||
|
if ((result = m_palette[i].Read(p_storage)) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_bits) {
|
||||||
|
delete[] m_bits;
|
||||||
|
}
|
||||||
|
m_bits = new LegoU8[m_width * m_height];
|
||||||
|
if ((result = p_storage->Read(m_bits, m_width * m_height)) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p_square && m_width != m_height) {
|
||||||
|
LegoU8* newBits;
|
||||||
|
|
||||||
|
if (m_height < m_width) {
|
||||||
|
LegoU32 aspect = m_width / m_height;
|
||||||
|
newBits = new LegoU8[m_width * m_width];
|
||||||
|
LegoU8* src = m_bits;
|
||||||
|
LegoU8* dst = newBits;
|
||||||
|
|
||||||
|
for (LegoU32 row = 0; row < m_height; row++) {
|
||||||
|
if (aspect) {
|
||||||
|
for (LegoU32 dup = aspect; dup; dup--) {
|
||||||
|
memcpy(dst, src, m_width);
|
||||||
|
dst += m_width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
src += m_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_height = m_width;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LegoU32 aspect = m_height / m_width;
|
||||||
|
newBits = new LegoU8[m_height * m_height];
|
||||||
|
LegoU8* src = m_bits;
|
||||||
|
LegoU8* dst = newBits;
|
||||||
|
|
||||||
|
for (LegoU32 row = 0; row < m_height; row++) {
|
||||||
|
for (LegoU32 col = 0; col < m_width; col++) {
|
||||||
|
if (aspect) {
|
||||||
|
for (LegoU32 dup = aspect; dup; dup--) {
|
||||||
|
*dst = *src;
|
||||||
|
dst++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_width = m_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] m_bits;
|
||||||
|
m_bits = newBits;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100997e0
|
||||||
|
LegoResult LegoImage::Write(LegoStorage* p_storage)
|
||||||
|
{
|
||||||
|
LegoResult result;
|
||||||
|
if ((result = p_storage->Write(&m_width, sizeof(m_width))) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if ((result = p_storage->Write(&m_height, sizeof(m_height))) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if ((result = p_storage->Write(&m_count, sizeof(m_height))) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
for (LegoU32 i = 0; i < m_count; i++) {
|
||||||
|
if ((result = m_palette[i].Write(p_storage)) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_bits) {
|
||||||
|
if ((result = p_storage->Write(m_bits, m_width * m_height)) != SUCCESS) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
54
LEGO1/lego/sources/misc/legoimage.h
Normal file
54
LEGO1/lego/sources/misc/legoimage.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#ifndef __LEGOIMAGE_H
|
||||||
|
#define __LEGOIMAGE_H
|
||||||
|
|
||||||
|
#include "legotypes.h"
|
||||||
|
|
||||||
|
class LegoStorage;
|
||||||
|
|
||||||
|
// SIZE 0x3
|
||||||
|
class LegoPaletteEntry {
|
||||||
|
public:
|
||||||
|
LegoPaletteEntry();
|
||||||
|
// LegoPaletteEntry(LegoU8 p_red, LegoU8 p_green, LegoU8 p_blue);
|
||||||
|
LegoU8 GetRed() { return m_red; }
|
||||||
|
void SetRed(LegoU8 p_red) { m_red = p_red; }
|
||||||
|
LegoU8 GetGreen() { return m_green; }
|
||||||
|
void SetGreen(LegoU8 p_green) { m_green = p_green; }
|
||||||
|
LegoU8 GetBlue() { return m_blue; }
|
||||||
|
void SetBlue(LegoU8 p_blue) { m_blue = p_blue; }
|
||||||
|
LegoResult Read(LegoStorage* p_storage);
|
||||||
|
LegoResult Write(LegoStorage* p_storage);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LegoU8 m_red; // 0x00
|
||||||
|
LegoU8 m_green; // 0x01
|
||||||
|
LegoU8 m_blue; // 0x02
|
||||||
|
};
|
||||||
|
|
||||||
|
// 0x310
|
||||||
|
class LegoImage {
|
||||||
|
public:
|
||||||
|
LegoImage();
|
||||||
|
LegoImage(LegoU32 p_width, LegoU32 p_height);
|
||||||
|
~LegoImage();
|
||||||
|
LegoU32 GetWidth() { return m_width; }
|
||||||
|
void SetWidth(LegoU32 p_width) { m_width = p_width; }
|
||||||
|
LegoU32 GetHeight() { return m_height; }
|
||||||
|
void SetHeight(LegoU32 p_height) { m_height = p_height; }
|
||||||
|
LegoPaletteEntry* GetPalette() { return m_palette; }
|
||||||
|
LegoPaletteEntry& GetPaletteEntry(LegoU32 p_i) { return m_palette[p_i]; }
|
||||||
|
void SetPaletteEntry(LegoU32 p_i, LegoPaletteEntry& p_paletteEntry) { m_palette[p_i] = p_paletteEntry; }
|
||||||
|
LegoU8* GetBits() { return m_bits; }
|
||||||
|
void SetBits(LegoU8* p_bits) { m_bits = p_bits; }
|
||||||
|
LegoResult Read(LegoStorage* p_storage, LegoU32 p_square);
|
||||||
|
LegoResult Write(LegoStorage* p_storage);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LegoU32 m_width; // 0x00
|
||||||
|
LegoU32 m_height; // 0x04
|
||||||
|
LegoU32 m_count; // 0x08
|
||||||
|
LegoPaletteEntry m_palette[256]; // 0x0c
|
||||||
|
LegoU8* m_bits; // 0x30c
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __LEGOIMAGE_H
|
139
LEGO1/lego/sources/misc/legostorage.cpp
Normal file
139
LEGO1/lego/sources/misc/legostorage.cpp
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
#include "legostorage.h"
|
||||||
|
|
||||||
|
#include "decomp.h"
|
||||||
|
|
||||||
|
#include <memory.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
DECOMP_SIZE_ASSERT(LegoStorage, 0x8);
|
||||||
|
DECOMP_SIZE_ASSERT(LegoMemory, 0x10);
|
||||||
|
DECOMP_SIZE_ASSERT(LegoFile, 0xc);
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10099080
|
||||||
|
LegoMemory::LegoMemory(void* p_buffer) : LegoStorage()
|
||||||
|
{
|
||||||
|
m_buffer = (LegoU8*) p_buffer;
|
||||||
|
m_position = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10099160
|
||||||
|
LegoResult LegoMemory::Read(void* p_buffer, LegoU32 p_size)
|
||||||
|
{
|
||||||
|
memcpy(p_buffer, m_buffer + m_position, p_size);
|
||||||
|
m_position += p_size;
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10099190
|
||||||
|
LegoResult LegoMemory::Write(const void* p_buffer, LegoU32 p_size)
|
||||||
|
{
|
||||||
|
memcpy(m_buffer + m_position, p_buffer, p_size);
|
||||||
|
m_position += p_size;
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100991c0
|
||||||
|
LegoFile::LegoFile()
|
||||||
|
{
|
||||||
|
m_file = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10099250
|
||||||
|
LegoFile::~LegoFile()
|
||||||
|
{
|
||||||
|
if (m_file) {
|
||||||
|
fclose(m_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100992c0
|
||||||
|
LegoResult LegoFile::Read(void* p_buffer, LegoU32 p_size)
|
||||||
|
{
|
||||||
|
if (!m_file) {
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
if (fread(p_buffer, 1, p_size, m_file) != p_size) {
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10099300
|
||||||
|
LegoResult LegoFile::Write(const void* p_buffer, LegoU32 p_size)
|
||||||
|
{
|
||||||
|
if (!m_file) {
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
if (fwrite(p_buffer, 1, p_size, m_file) != p_size) {
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10099340
|
||||||
|
LegoResult LegoFile::GetPosition(LegoU32& p_position)
|
||||||
|
{
|
||||||
|
if (!m_file) {
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
LegoU32 position = ftell(m_file);
|
||||||
|
if (position == -1) {
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
p_position = position;
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10099370
|
||||||
|
LegoResult LegoFile::SetPosition(LegoU32 p_position)
|
||||||
|
{
|
||||||
|
if (!m_file) {
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
if (fseek(m_file, p_position, SEEK_SET) != 0) {
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100993a0
|
||||||
|
LegoResult LegoFile::Open(const char* p_name, LegoU32 p_mode)
|
||||||
|
{
|
||||||
|
if (m_file) {
|
||||||
|
fclose(m_file);
|
||||||
|
}
|
||||||
|
char mode[4];
|
||||||
|
mode[0] = '\0';
|
||||||
|
if (p_mode & c_read) {
|
||||||
|
m_mode = c_read;
|
||||||
|
strcat(mode, "r");
|
||||||
|
}
|
||||||
|
if (p_mode & c_write) {
|
||||||
|
if (m_mode != c_read)
|
||||||
|
m_mode = c_write;
|
||||||
|
strcat(mode, "w");
|
||||||
|
}
|
||||||
|
if ((p_mode & c_text) != 0)
|
||||||
|
strcat(mode, "t");
|
||||||
|
else
|
||||||
|
strcat(mode, "b");
|
||||||
|
|
||||||
|
if (!(m_file = fopen(p_name, mode))) {
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100994a0
|
||||||
|
LegoResult LegoMemory::GetPosition(LegoU32& p_position)
|
||||||
|
{
|
||||||
|
p_position = m_position;
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x100994b0
|
||||||
|
LegoResult LegoMemory::SetPosition(LegoU32 p_position)
|
||||||
|
{
|
||||||
|
m_position = p_position;
|
||||||
|
return SUCCESS;
|
||||||
|
}
|
95
LEGO1/lego/sources/misc/legostorage.h
Normal file
95
LEGO1/lego/sources/misc/legostorage.h
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
#ifndef __LEGOSTORAGE_H
|
||||||
|
#define __LEGOSTORAGE_H
|
||||||
|
|
||||||
|
#include "legotypes.h"
|
||||||
|
#include "mxstring.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// VTABLE: LEGO1 0x100d7d80
|
||||||
|
// SIZE 0x08
|
||||||
|
class LegoStorage {
|
||||||
|
public:
|
||||||
|
enum OpenFlags {
|
||||||
|
c_read = 1,
|
||||||
|
c_write = 2,
|
||||||
|
c_text = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
LegoStorage() : m_mode(0) {}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10045ad0
|
||||||
|
virtual ~LegoStorage(){};
|
||||||
|
|
||||||
|
virtual LegoResult Read(void* p_buffer, LegoU32 p_size) = 0;
|
||||||
|
virtual LegoResult Write(const void* p_buffer, LegoU32 p_size) = 0;
|
||||||
|
virtual LegoResult GetPosition(LegoU32& p_position) = 0;
|
||||||
|
virtual LegoResult SetPosition(LegoU32 p_position) = 0;
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10045ae0
|
||||||
|
virtual LegoBool IsWriteMode() { return m_mode == c_write; }
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10045af0
|
||||||
|
virtual LegoBool IsReadMode() { return m_mode == c_read; }
|
||||||
|
|
||||||
|
// SYNTHETIC: LEGO1 0x10045b00
|
||||||
|
// LegoStorage::`scalar deleting destructor'
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LegoU8 m_mode; // 0x04
|
||||||
|
};
|
||||||
|
|
||||||
|
// VTABLE: LEGO1 0x100db710
|
||||||
|
// SIZE 0x10
|
||||||
|
class LegoMemory : public LegoStorage {
|
||||||
|
public:
|
||||||
|
LegoMemory(void* p_buffer);
|
||||||
|
virtual LegoResult Read(void* p_buffer, LegoU32 p_size);
|
||||||
|
virtual LegoResult Write(const void* p_buffer, LegoU32 p_size);
|
||||||
|
virtual LegoResult GetPosition(LegoU32& p_position);
|
||||||
|
virtual LegoResult SetPosition(LegoU32 p_position);
|
||||||
|
|
||||||
|
// SYNTHETIC: LEGO1 0x10045a80
|
||||||
|
// LegoMemory::~LegoMemory
|
||||||
|
|
||||||
|
// SYNTHETIC: LEGO1 0x100990f0
|
||||||
|
// LegoMemory::`scalar deleting destructor'
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LegoU8* m_buffer; // 0x04
|
||||||
|
LegoU32 m_position; // 0x08
|
||||||
|
};
|
||||||
|
|
||||||
|
// VTABLE: LEGO1 0x100db730
|
||||||
|
// SIZE 0x0c
|
||||||
|
class LegoFile : public LegoStorage {
|
||||||
|
public:
|
||||||
|
LegoFile();
|
||||||
|
virtual ~LegoFile() override;
|
||||||
|
virtual LegoResult Read(void* p_buffer, LegoU32 p_size);
|
||||||
|
virtual LegoResult Write(const void* p_buffer, LegoU32 p_size);
|
||||||
|
virtual LegoResult GetPosition(LegoU32& p_position);
|
||||||
|
virtual LegoResult SetPosition(LegoU32 p_position);
|
||||||
|
LegoResult Open(const char* p_name, LegoU32 p_mode);
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10006030
|
||||||
|
LegoStorage* FUN_10006030(MxString p_str)
|
||||||
|
{
|
||||||
|
const char* data = p_str.GetData();
|
||||||
|
LegoU32 fullLength = strlen(data);
|
||||||
|
|
||||||
|
LegoU16 limitedLength = fullLength;
|
||||||
|
Write(&limitedLength, sizeof(limitedLength));
|
||||||
|
Write((char*) data, (LegoS16) fullLength);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SYNTHETIC: LEGO1 0x10099230
|
||||||
|
// LegoFile::`scalar deleting destructor'
|
||||||
|
|
||||||
|
protected:
|
||||||
|
FILE* m_file; // 0x08
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __LEGOSTORAGE_H
|
31
LEGO1/lego/sources/misc/legotexture.cpp
Normal file
31
LEGO1/lego/sources/misc/legotexture.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include "legotexture.h"
|
||||||
|
|
||||||
|
#include "decomp.h"
|
||||||
|
#include "legoimage.h"
|
||||||
|
#include "legostorage.h"
|
||||||
|
|
||||||
|
DECOMP_SIZE_ASSERT(LegoTexture, 0x4);
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10098fb0
|
||||||
|
LegoTexture::LegoTexture()
|
||||||
|
{
|
||||||
|
m_image = new LegoImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10099030
|
||||||
|
LegoTexture::~LegoTexture()
|
||||||
|
{
|
||||||
|
delete m_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10099050
|
||||||
|
LegoResult LegoTexture::Read(LegoStorage* p_storage, LegoU32 p_square)
|
||||||
|
{
|
||||||
|
return m_image->Read(p_storage, p_square);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FUNCTION: LEGO1 0x10099070
|
||||||
|
LegoResult LegoTexture::Write(LegoStorage* p_storage)
|
||||||
|
{
|
||||||
|
return m_image->Write(p_storage);
|
||||||
|
}
|
23
LEGO1/lego/sources/misc/legotexture.h
Normal file
23
LEGO1/lego/sources/misc/legotexture.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef __LEGOTEXTURE_H
|
||||||
|
#define __LEGOTEXTURE_H
|
||||||
|
|
||||||
|
#include "legotypes.h"
|
||||||
|
|
||||||
|
class LegoImage;
|
||||||
|
class LegoStorage;
|
||||||
|
|
||||||
|
// SIZE 0x04
|
||||||
|
class LegoTexture {
|
||||||
|
public:
|
||||||
|
LegoTexture();
|
||||||
|
~LegoTexture();
|
||||||
|
LegoImage* GetImage() { return m_image; }
|
||||||
|
void SetImage(LegoImage* p_image) { m_image = p_image; }
|
||||||
|
LegoResult Read(LegoStorage* p_storage, LegoU32 p_square);
|
||||||
|
LegoResult Write(LegoStorage* p_storage);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LegoImage* m_image; // 0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __LEGOTEXTURE_H
|
44
LEGO1/lego/sources/misc/legotypes.h
Normal file
44
LEGO1/lego/sources/misc/legotypes.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
This unpublished source code contains trade secrets and
|
||||||
|
copyrighted materials which are the property of Mindscape, Inc.
|
||||||
|
Unauthorized use, copying or distribution is a violation of U.S.
|
||||||
|
and international laws and is strictly prohibited.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LEGOTYPES_H
|
||||||
|
#define __LEGOTYPES_H
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FALSE
|
||||||
|
#define FALSE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#define NULL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SUCCESS
|
||||||
|
#define SUCCESS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FAILURE
|
||||||
|
#define FAILURE -1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef char LegoS8;
|
||||||
|
typedef unsigned char LegoU8;
|
||||||
|
typedef short LegoS16;
|
||||||
|
typedef unsigned short LegoU16;
|
||||||
|
typedef long LegoS32;
|
||||||
|
typedef unsigned long LegoU32;
|
||||||
|
typedef float LegoFloat;
|
||||||
|
typedef char LegoChar;
|
||||||
|
|
||||||
|
typedef LegoU8 LegoBool;
|
||||||
|
typedef LegoS32 LegoTime;
|
||||||
|
typedef LegoS32 LegoResult;
|
||||||
|
|
||||||
|
#endif // __LEGOTYPES_H
|
54
LEGO1/lego/sources/misc/legoutil.h
Normal file
54
LEGO1/lego/sources/misc/legoutil.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#ifndef __LEGOUTIL_H
|
||||||
|
#define __LEGOUTIL_H
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T Min(T p_t1, T p_t2)
|
||||||
|
{
|
||||||
|
return p_t1 < p_t2 ? p_t1 : p_t2;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T Min(T p_t1, T p_t2, T p_t3)
|
||||||
|
{
|
||||||
|
return Min(p_t1, Min(p_t2, p_t3));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T Max(T p_t1, T p_t2)
|
||||||
|
{
|
||||||
|
return p_t1 > p_t2 ? p_t1 : p_t2;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T Max(T p_t1, T p_t2, T p_t3)
|
||||||
|
{
|
||||||
|
return Max(p_t1, Max(p_t2, p_t3));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T Abs(T p_t)
|
||||||
|
{
|
||||||
|
return p_t < 0 ? -p_t : p_t;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline void Swap(T& p_t1, T& p_t2)
|
||||||
|
{
|
||||||
|
T t = p_t1;
|
||||||
|
p_t1 = p_t2;
|
||||||
|
p_t2 = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T DToR(T p_d)
|
||||||
|
{
|
||||||
|
return p_d * 3.1416F / 180.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline T RToD(T p_r)
|
||||||
|
{
|
||||||
|
return p_r * 180.0F / 3.1416F;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __LEGOUTIL_H
|
6
LEGO1/lego/sources/misc/version.h
Normal file
6
LEGO1/lego/sources/misc/version.h
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __VERSION_H
|
||||||
|
#define __VERSION_H
|
||||||
|
|
||||||
|
#define MODEL_VERSION 3
|
||||||
|
|
||||||
|
#endif // __VERSION_H
|
Reference in New Issue
Block a user