d_room mostly matching

This commit is contained in:
robojumper
2025-03-07 23:18:17 +01:00
parent c6b8a2dbaf
commit 641f3d7b30
27 changed files with 1144 additions and 193 deletions
+8
View File
@@ -173,6 +173,14 @@ public:
return actor_properties & property;
}
void callunkVirtFunc_0x60() {
unkVirtFunc_0x60();
}
void callrestorePosRotFromCopy() {
restorePosRotFromCopy();
}
public:
// funcs found in TU
/* 8002c650 */ static void setTempCreateParams(
+2 -2
View File
@@ -228,10 +228,10 @@ public:
void SetupMapGX(mMtx_c *);
void SetupMapMaterial(int matIdx, bool, s32 roomId);
UNKTYPE *GetMapAccessor();
void DrawMap(u8 roomId, mMtx_c *, bool bColor, int);
void DrawMap(int roomId, mMtx_c *, bool bColor, int);
void SetupScrollGX();
void SetupScrollMaterial(int matIdx, s32, bool);
void DrawMapScroll(u8 roomId, mMtx_c *, bool bColor, int);
void DrawMapScroll(int roomId, mMtx_c *, bool bColor, int);
void DrawSkyKeepMap(mMtx_c *, int);
bool ConfigureMapTexture(EGG::Heap *);
+3
View File
@@ -176,6 +176,9 @@ public:
void SetPriority(PRIORITY priority) {
mPriority = priority;
}
void SetUnkBase() {
mField_0x18.field_0x00 = 1;
}
void OnStickWall() {
field_0x24 |= 1;
}
+220
View File
@@ -0,0 +1,220 @@
#ifndef D_ROOM_H
#define D_ROOM_H
#include "common.h"
#include "d/a/d_a_base.h"
#include "d/col/bg/d_bg_w_kcol.h"
#include "d/d_base.h"
#include "m/m3d/m_anmmatclr.h"
#include "m/m3d/m_anmtexpat.h"
#include "m/m3d/m_anmtexsrt.h"
#include "m/m3d/m_anmvis.h"
#include "m/m3d/m_smdl.h"
#include "m/m_allocator.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
#include "nw4r/g3d/res/g3d_resnode.h"
#include "nw4r/math/math_geometry.h"
#include "s/s_State.hpp"
#include "sized_string.h"
#include "toBeSorted/unk_with_water.h"
struct DrawPriorityConfig {
u8 pDrawOpa1;
u8 pDrawXlu;
u8 pDrawOpa2;
};
// This could be std::unique_ptr, but we don't have it yet
template <typename T>
class RaiiPtr {
public:
T *mPtr;
RaiiPtr() : mPtr(nullptr) {}
~RaiiPtr() {
if (mPtr != nullptr) {
delete mPtr;
mPtr = nullptr;
}
}
void operator=(T *ptr) {
mPtr = ptr;
}
operator bool() const {
return mPtr != nullptr;
}
const T *operator->() const {
return mPtr;
}
T *operator->() {
return mPtr;
}
const T &operator*() const {
return *this->operator->();
}
T &operator*() {
return *this->operator->();
}
};
class dRoom_c : public dBase_c {
class mdl_c : public m3d::smdl_c {
public:
mdl_c() : mpAabb(nullptr) {}
virtual ~mdl_c() {
remove();
}
virtual void remove() override;
bool hasModel() const {
return getG3dObject() != nullptr;
}
bool create(nw4r::g3d::ResMdl resMdl, mAllocator_c &alloc);
void configureSomething();
void somethingVisibility(u32 id, bool visible);
private:
void doSomethingWithVis(bool arg);
nw4r::math::AABB *mpAabb;
};
class model_c {
friend class dRoom_c;
public:
model_c() {}
bool create(nw4r::g3d::ResFile resFile, mAllocator_c &alloc, s32 idx, UnkWithWater *waterThing);
bool getBounds(mVec3_c *min, mVec3_c *max) const;
nw4r::g3d::ResNode getResNode(const char *nodeName);
void updateObjNode(const char *node, bool visible);
void destroy();
void execute(s32 idx, bool roomfield_0x573, f32 pastState);
void draw(int roomid);
f32 getFrame() const;
void configureSomething(int roomid, mdl_c *mdl);
const DrawPriorityConfig *getDrawPriority(s32 idx);
private:
mdl_c mMdl;
RaiiPtr<m3d::anmMatClr_c> mpAnmClr;
RaiiPtr<m3d::anmTexPat_c> mpAnmPat;
RaiiPtr<m3d::anmTexSrt_c> mpAnmSrt;
RaiiPtr<m3d::anmVis_c> mpAnmVis;
};
public:
dRoom_c()
: mStateMgr(*this, sStateID::null),
field_0x15C(nullptr),
SCEN(nullptr),
PLY(nullptr),
CAM(nullptr),
EVNT(nullptr),
PATH(nullptr),
PNT(nullptr),
BPNT(nullptr),
AREA(nullptr),
unkCount(0),
scenCount(0),
plyCount(0),
camCount(0),
evntCount(0),
pathCount(0),
pntCount(0),
bpntCount(0),
areaCount(0),
mFlags(0) {}
virtual ~dRoom_c() {}
virtual int create() override;
virtual int doDelete() override;
virtual int execute() override;
virtual int draw() override;
STATE_FUNC_DECLARE(dRoom_c, Active);
STATE_FUNC_DECLARE(dRoom_c, NonActive);
bool checkFlag(u32 flag) {
return mFlags & flag;
}
void drawOnMapIfVisible(mMtx_c *mtx, int param);
void getBounds(mVec3_c *min, mVec3_c *max) const;
void someLastBossThing(bool arg);
f32 getFrame() const;
typedef void (*foreachObjCallback)(dAcBase_c *obj);
s32 foreachObject(foreachObjCallback cb);
private:
bool setupBg();
void executeBg();
void releaseBg();
static void formatObj(int obj, SizedString<8> &str);
void updateObjNodeInEachRoom(int obj, bool visible);
void destroyModels();
void activateUpdates();
void deactivateUpdates();
/* 0x068 */ mHeapAllocator_c mAllocator;
/* 0x084 */ nw4r::g3d::ResFile mRoomRes;
/* 0x088 */ UnkWithWater mWaterThing;
/* 0x0A0 */ model_c mModels[8];
/* 0x220 */ dBgWKCol mBg[2];
/* 0x4E0 */ STATE_MGR_DECLARE(dRoom_c);
/* 0x51C */ void *field_0x15C;
/* 0x520 */ void *SCEN;
/* 0x524 */ void *PLY;
/* 0x528 */ void *CAM;
/* 0x52C */ void *EVNT;
/* 0x530 */ void *PATH;
/* 0x534 */ void *PNT;
/* 0x538 */ void *BPNT;
/* 0x53C */ void *SPTH;
/* 0x540 */ void *field_0x540;
/* 0x544 */ void *field_0x544;
/* 0x548 */ void *AREA;
/* 0x54C */ u16 unkCount;
/* 0x54E */ u16 scenCount;
/* 0x550 */ u16 plyCount;
/* 0x552 */ u16 camCount;
/* 0x554 */ u16 evntCount;
/* 0x556 */ u16 pathCount;
/* 0x558 */ u16 pntCount;
/* 0x55A */ u16 bpntCount;
/* 0x55C */ u16 spthCount;
/* 0x55E */ u16 unk2Count;
/* 0x560 */ u16 unk3Count;
/* 0x562 */ u16 areaCount;
// peak vtable placement
class UnkRoomClass {
public:
virtual ~UnkRoomClass() {}
};
/* 0x564 */ UnkRoomClass mUnk;
/* 0x568 */ u8 mFlags;
void *BZS;
/* 0x570 */ s8 roomid;
/* 0x571 */ bool field_0x571;
/* 0x572 */ bool field_0x572;
/* 0x573 */ bool field_0x573;
/* 0x574 */ bool mHasAnmTexPat;
/* 0x575 */ bool mDidAlreadyInit;
/* 0x576 */ bool field_0x576;
};
#endif
+2 -1
View File
@@ -57,7 +57,7 @@ struct SpawnInfo {
/* 0x00 */ SizedString<32> stageName;
/* 0x20 */ u16 transitionFadeFrames;
/* 0x22 */ s8 room;
/* 0x22 */ u8 room;
/* 0x23 */ u8 layer;
/* 0x24 */ s8 entrance;
/* 0x25 */ u8 night;
@@ -136,6 +136,7 @@ public:
STATE_VIRTUAL_FUNC_DECLARE(dScGame_c, Action);
static bool isCurrentStage(const char *stageName);
static bool isStageSkyloftLayer20();
static SpawnInfo currentSpawnInfo;
static SpawnInfo nextSpawnInfo;
+21
View File
@@ -0,0 +1,21 @@
#ifndef D_T_MASS_OBJ_H
#define D_T_MASS_OBJ_H
#include "d/t/d_tg.h"
class dTgMassObj_c : public dTg_c {
public:
dTgMassObj_c() {}
virtual ~dTgMassObj_c() {}
static dTgMassObj_c *GetInstance() {
return sInstance;
}
void unloadRoom(u16 roomid);
private:
static dTgMassObj_c *sInstance;
};
#endif
+1 -1
View File
@@ -37,7 +37,7 @@ public:
void setCullModeAll(GXCullMode cullMode, bool bMarkDirty);
void setMatVisible(u32 matId, bool bVisble);
int setMatTexture(char *name, GXTexObj *texObj, bool copy, void *unk, int, int);
bool getBounds(mVec3_c *min, mVec3_c *max);
bool getBounds(mVec3_c *min, mVec3_c *max) const;
private:
banm_c *mpCurrentAnm;
+4
View File
@@ -53,6 +53,10 @@ public:
return mpScnLeaf;
}
inline const nw4r::g3d::ScnLeaf *getG3dObject() const {
return mpScnLeaf;
}
protected:
/* 0x14 */ nw4r::g3d::ScnLeaf *mpScnLeaf;
};
+4
View File
@@ -148,6 +148,10 @@ public:
return GetRevision() == REVISION;
}
const char *GetName() const {
return ofs_to_ptr<const char>(ref().name);
}
const u8 *GetResByteCode(const char *pName) const;
ResNode GetResNode(const char *pName) const;
+12 -2
View File
@@ -67,8 +67,8 @@ struct ResNodeData : ResNodeDataTypedef {
math::_VEC3 scale; // at 0x20
math::_VEC3 rot; // at 0x2C
math::_VEC3 translate; // at 0x38
math::VEC3 volume_min; // at 0x44
math::VEC3 volume_max; // at 0x50
math::_VEC3 volume_min; // at 0x44
math::_VEC3 volume_max; // at 0x50
s32 toParentNode; // at 0x5C
s32 toChildNode; // at 0x60
s32 toNextSibling; // at 0x64
@@ -143,6 +143,16 @@ public:
return ref().translate;
}
// not in the dwarf
const math::VEC3 &GetBoundsMin() const {
return *(const math::VEC3*)&ref().volume_min;
}
// not in the dwarf
const math::VEC3 &GetBoundsMax() const {
return *(const math::VEC3*)&ref().volume_max;
}
ResNode GetParentNode() {
return ofs_to_obj<ResNode>(ref().toParentNode);
}
+1
View File
@@ -35,6 +35,7 @@ struct PLANE {
struct AABB {
AABB() {}
AABB(const VEC3 &min, const VEC3 &max) : min(min), max(max) {}
void Set(const VEC3 *points, unsigned int num);
void Set(const AABB *box, const MTX34 *mtx);
@@ -30,7 +30,7 @@ public:
const char *getCurrentStageDirectory();
const char *getRoomArcDirectory(int room) const;
static EGG::ExpHeap *getHeap();
EGG::ExpHeap *getHeap(s32 roomid);
private:
SizedString<32> mStageName;
+9 -62
View File
@@ -3,73 +3,17 @@
#include "common.h"
#include "d/d_base.h"
#include "d/d_room.h"
#include "m/m_allocator.h"
#include "m/types_m.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
#define MAX_ROOM_NUMBER 64
class dRoomModel {
char mainModel[28]; // Actually smdl_c
nw4r::math::AABB *roomBounds;
m3d::anmMatClr_c *anmMatClr;
m3d::anmTexPat_c *anmTexPat;
m3d::anmTexSrt_c *anmTexSrt;
m3d::anmVis_c *anmVis;
};
class dRoomCollision {
char todo[352];
};
class dRoom : public dBase_c {
public:
mAllocator_c allocator;
nw4r::g3d::ResFile *roomRes;
char unkWithWater[24];
dRoomModel roomModels[8];
dRoomCollision roomCollisions[2];
char stateMgr[60];
char _0[4];
void *SCEN;
void *PLY;
void *CAM;
void *EVNT;
void *PATH;
void *PNT;
void *BPNT;
void *SPTH;
void *_1;
void *_2;
void *AREA;
char _3[4];
short plyCount;
short camCount;
short evntCount;
short pathCount;
short pntCount;
short bpntCount;
short spthCount;
short _4;
short _5;
short areaCount;
char _6[4];
u8 flags;
void *BZS;
s8 roomid;
char _7[3];
bool hasAnmTexPat;
bool didAlreadyInit;
bool checkFlag(u32 flag) {
return flags & flag;
}
};
class dRoomTable {
/* 801b4670 */ dRoomTable(dRoomTable *roomTable);
virtual ~dRoomTable();
dRoom *rooms[MAX_ROOM_NUMBER - 1];
dRoom_c *rooms[MAX_ROOM_NUMBER - 1];
};
class MapRelated {
@@ -99,16 +43,19 @@ public:
/* 80575760 */ static RoomManager *m_Instance;
public:
/* 801b3970 */ dRoom *GetRoomByIndex(int roomid);
/* 801b42b0 */ static dRoom *getRoom(int roomid);
/* 801b3970 */ dRoom_c *GetRoomByIndex(int roomid);
/* 801b42b0 */ static dRoom_c *getRoom(int roomid);
/* 801b42d0 */ static void bindStageResToFile(nw4r::g3d::ResFile *);
/* 801b4320 */ static void bindSkyCmnToResFile(nw4r::g3d::ResFile *);
/* 801b4380 */ static bool getMA0AnmTexSrt(nw4r::g3d::ResAnmTexSrt *, char *);
/* 801b4420 */ static bool getMA0IndirectSrt(nw4r::g3d::ResAnmTexSrt *, char *);
/* 801b4420 */ static bool getMA0IndirectSrt(nw4r::g3d::ResAnmTexSrt *, const nw4r::g3d::ResMdl &mdl);
/* 801b44c0 */ static void changeLoadedEntities(RoomManager *mgr, u32 index_shift, bool set);
/* 801b4510 */ static u32 checkRoomFlag(RoomManager *mgr, u32 flag);
/* 801b4550 */ static bool checkEnemyDefeatFlag(RoomManager *mgr, u32 flag);
/* 801b45c0 */ static bool fn_801B45C0(RoomManager *mgr /* plus others */);
/* 801b6c60 */ bool hasVisitedRoomId(s32 roomid) const;
void setRoom(int roomid, dRoom_c *room);
};
#endif
+15
View File
@@ -2,19 +2,34 @@
#define STAGE_MANAGER_H
#include "d/d_base.h"
#include "toBeSorted/unk_with_water.h"
class dStageMgr_c : dBase_c {
public:
bool isAreaTypeDungeon() const;
bool isAreaTypeSky() const;
bool isAreaTypeDungeonOrBoss() const;
bool isAreaTypeOverworldOrSkyloft() const;
s32 getSTIFunk1() const;
s32 getAreaType() const;
static dStageMgr_c *GetInstance() {
return sInstance;
}
bool checkFlag0x88A0(u32 flag) const {
return (field_0x88A0 & flag) != 0;
}
void initUnkWithWater(u32 val, UnkWithWater *waterThing);
void destroyUnkWithWater(u32 val, UnkWithWater *waterThing);
private:
static dStageMgr_c *sInstance;
/* 0x0068 */ u8 _0x0068[0x88A0 - 0x0068];
/* 0x88A0 */ u32 field_0x88A0;
};
#endif
+16 -1
View File
@@ -61,6 +61,18 @@ public:
static dTimeAreaMgr_c *sInstance;
bool isInLanayruMiningFacility() const {
return mIsInLanayruMiningFacility;
}
bool isField0x78() const {
return field_0x78;
}
void setField0x7A(bool val) {
field_0x7A = val;
}
private:
/* 0x04 */ u8 field_0x04[0x0C - 0x04];
/* 0x0C */ mHeapAllocator_c mAllocator;
@@ -68,7 +80,10 @@ private:
/* 0x40 */ dTimeAreaMgrProcB_c mProcB;
/* 0x5C */ u8 field_0x5C[0x64 - 0x5C];
/* 0x64 */ s32 field_0x64;
/* 0x68 */ u8 field_0x68[0x7B - 0x68];
/* 0x68 */ u8 field_0x68[0x78 - 0x68];
/* 0x78 */ bool field_0x78;
/* 0x79 */ u8 field_0x79[0x7A - 0x79];
/* 0x7A */ bool field_0x7A;
/* 0x7B */ bool mIsInLanayruMiningFacility;
};
+37
View File
@@ -0,0 +1,37 @@
#ifndef UNK_WITH_WATER_H
#define UNK_WITH_WATER_H
#include "common.h"
#include "nw4r/g3d/res/g3d_resmdl.h"
#include "toBeSorted/tlist.h"
struct UnkWithWaterNode {
public:
/* 0x00 */ TListNode<UnkWithWaterNode> mNode;
/* 0x08 */ UNKWORD field_0x08;
/* 0x0C */ UNKWORD field_0x0C;
};
class UnkWithWater {
public:
typedef TList<UnkWithWaterNode, offsetof(UnkWithWaterNode, mNode)> NodeList;
UnkWithWater() : field_0x04(0), field_0x08(0) {}
virtual ~UnkWithWater() {
remove();
}
static bool linkMdl(nw4r::g3d::ResMdl &mdl, UnkWithWater *thing);
bool hasLinks() const {
return mList.mCount != 0;
}
private:
void remove();
/* 0x04 */ UNKWORD field_0x04;
/* 0x08 */ UNKWORD field_0x08;
/* 0x0C */ NodeList mList;
};
#endif