Some misc graphics stuff

This commit is contained in:
robojumper
2025-03-15 00:07:44 +01:00
parent 7400f6c66a
commit 3967ab8dc6
30 changed files with 991 additions and 156 deletions
+7
View File
@@ -14,6 +14,13 @@ struct cBgS_PolyInfo;
struct SoundSource {
virtual ~SoundSource() {}
// TODO
virtual bool shutdown(); // 0x48
virtual bool isReadyMaybe(); // 0x100
virtual bool load(void *data, const char *name); // 0x100
virtual void setFrame(f32 frame); // 0x108
virtual void setRate(f32 frame); // 0x10C
};
struct SoundInfo {
+24 -2
View File
@@ -2,6 +2,7 @@
#define D_A_OBJ_BASE_H
#include "c/c_math.h"
#include "common.h"
#include "d/a/d_a_base.h"
#include "d/col/c/c_cc_d.h"
#include "d/col/c/c_m3d_g_aab.h"
@@ -9,6 +10,7 @@
#include "m/m3d/m_shadow.h"
#include "m/m3d/m_smdl.h"
#include "m/m_angle.h"
#include "m/m_color.h"
#include "m/m_mtx.h"
#include "m/m_vec.h"
#include "m/types_m.h"
@@ -60,9 +62,29 @@ struct ActorCarryStruct {
// Ghidra has it as `unk_ActorObjectBase`
struct LightingInfo {
/* 0x00 */ u8 mField_0x00[0x60 - 0x00];
/* 0x00 */ u8 mField_0x00[0x40 - 0x00];
/* 0x40 */ mColor mTev0Color;
/* 0x44 */ mColor mTev1Color;
/* 0x48 */ mColor mTev2Color;
/* 0x4C */ mColor mTevPrevColor;
/* 0x50 */ mColor mTevK0Color;
/* 0x54 */ mColor mTevK1Color;
/* 0x58 */ mColor mTevK2Color;
/* 0x5C */ mColor mTevK3Color;
/* 0x60 */ u8 mLightingCode;
/* 0x61 */ u8 mField_0x61[0x70 - 0x61];
/* 0x61 */ u8 _0x61;
/* 0x62 */ u8 _0x62;
/* 0x63 */ u8 _0x63;
/* 0x64 */ u8 _0x64;
/* 0x65 */ bool mUseTev0;
/* 0x66 */ bool mUseTev1;
/* 0x67 */ bool mUseTev2;
/* 0x68 */ bool mUseTevPrev;
/* 0x69 */ bool mUseTevK0;
/* 0x6A */ bool mUseTevK1;
/* 0x6B */ bool mUseTevK2;
/* 0x6C */ bool mUseTevK3;
/* 0x6D */ u8 mField_0x69[0x70 - 0x6D];
};
// Ghidra: ActorObjectBase
+2 -2
View File
@@ -4,7 +4,7 @@
#include "d/a/obj/d_a_obj_base.h"
#include "d/col/bg/d_bg_w.h"
#include "m/m3d/m_anmtexsrt.h"
#include "toBeSorted/unk_with_water.h"
#include "toBeSorted/d_d3d.h"
class dAcOtreasureIsland_c : public dAcObjBase_c {
public:
@@ -20,7 +20,7 @@ private:
const static f32 unkFloat0;
const static f32 unkFloat1;
/* 0x330 */ UnkWithWater waterStuff;
/* 0x330 */ d3d::UnkWithWater waterStuff;
/* 0x348 */ m3d::smdl_c mModel;
/* 0x364 */ m3d::smdl_c mWater00;
/* 0x380 */ m3d::smdl_c mWater01;
+3 -3
View File
@@ -18,8 +18,8 @@
#include "nw4r/math/math_geometry.h"
#include "s/s_State.hpp"
#include "sized_string.h"
#include "toBeSorted/d_d3d.h"
#include "toBeSorted/raii_ptr.h"
#include "toBeSorted/unk_with_water.h"
struct DrawPriorityConfig {
u8 pDrawOpa1;
@@ -57,7 +57,7 @@ class dRoom_c : public dBase_c {
public:
model_c() {}
bool create(nw4r::g3d::ResFile resFile, mAllocator_c &alloc, s32 idx, UnkWithWater *waterThing);
bool create(nw4r::g3d::ResFile resFile, mAllocator_c &alloc, s32 idx, d3d::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);
@@ -197,7 +197,7 @@ private:
/* 0x068 */ mHeapAllocator_c mAllocator;
/* 0x084 */ nw4r::g3d::ResFile mRoomRes;
/* 0x088 */ UnkWithWater mWaterThing;
/* 0x088 */ d3d::UnkWithWater mWaterThing;
/* 0x0A0 */ model_c mModels[ROOM_NUM_MODELS];
/* 0x220 */ dBgWKCol mBg[ROOM_NUM_BG];
/* 0x4E0 */ STATE_MGR_DECLARE(dRoom_c);
+3 -3
View File
@@ -16,8 +16,8 @@
#include "toBeSorted/arc_managers/layout_arc_manager.h"
#include "toBeSorted/arc_managers/oarc_manager.h"
#include "toBeSorted/attention.h"
#include "toBeSorted/d_d3d.h"
#include "toBeSorted/time_area_mgr.h"
#include "toBeSorted/unk_with_water.h"
class RelObjCtrl {
public:
@@ -62,8 +62,8 @@ public:
return (field_0x88A0 & flag) != 0;
}
void initUnkWithWater(u32 val, UnkWithWater *waterThing);
void destroyUnkWithWater(u32 val, UnkWithWater *waterThing);
void initUnkWithWater(u32 val, d3d::UnkWithWater *waterThing);
void destroyUnkWithWater(u32 val, d3d::UnkWithWater *waterThing);
const RMPL *getRmpl() const {
return mpRmpl;
+25
View File
@@ -0,0 +1,25 @@
#ifndef D_T_SIREN_H
#define D_T_SIREN_H
#include "common.h"
#include "d/t/d_tg.h"
class dTgSiren_c : public dTg_c {
public:
dTgSiren_c() {}
virtual ~dTgSiren_c() {}
static bool isOutOfTime() {
if (sInstance == nullptr) {
return false;
}
return sInstance->outOfTime();
}
private:
bool outOfTime() const;
static dTgSiren_c *sInstance;
};
#endif
+6 -1
View File
@@ -1,9 +1,14 @@
#ifndef EGG_CPU_TEXTURE_H
#define EGG_CPU_TEXTURE_H
#include "rvl/GX/GXTexture.h"
namespace EGG {
class CpuTexture {};
class CpuTexture {
public:
void GetTexObj(GXTexObj *) const;
};
} // namespace EGG
+4 -4
View File
@@ -15,9 +15,9 @@ public:
virtual void play(); // 0x0C
virtual void setFrame(f32); // 0x10
virtual void setAnm(const char *name, playMode_e mode, f32); // 0x14
virtual void setAnm(const char *name, playMode_e mode); // 0x18
virtual void setRate(f32); // 0x20
virtual bool setAnm(const char *name, playMode_e mode, f32); // 0x14
virtual bool setAnm(const char *name, playMode_e mode); // 0x18
virtual void setRate(f32); // 0x1C
bool create(
void *mdlFile, void *anmFile, const char *mdlName, const char *anmName, mAllocator_c *alloc, u32 bufferOption,
@@ -57,7 +57,7 @@ public:
return mAnm;
}
private:
protected:
nw4r::g3d::ResFile mMdlFile;
nw4r::g3d::ResFile mAnmFile;
+1 -1
View File
@@ -15,7 +15,7 @@ public:
virtual int getType() const override;
virtual void remove() override;
virtual void setAnm(banm_c &anm);
virtual bool setAnm(banm_c &anm);
virtual void play();
int getMatID(const char *name) const;
+4 -4
View File
@@ -57,12 +57,12 @@ public:
bool create(nw4r::g3d::ResMdl, mAllocator_c *, u32, int, u32 *);
bool create(nw4r::g3d::ResMdl, mdlCallback_c *cb, mAllocator_c *, u32, int, u32 *);
virtual void remove();
virtual void remove() override;
void setCallback(callback_c *cb);
void play();
void setAnm(banm_c &);
void setAnm(banm_c &, f32);
virtual void play() override;
virtual bool setAnm(banm_c &) override;
bool setAnm(banm_c &, f32);
private:
/** If we allocated the callback ourselves, this is what we need to free */
+10
View File
@@ -494,6 +494,16 @@ public:
return ResName(NULL);
}
const char *GetTexName() const {
const ResTexPlttInfoData &r = ref();
if (r.nameTex != 0) {
return NW4R_G3D_OFS_TO_RESNAME(&r, r.nameTex).GetName();
}
return nullptr;
}
bool IsCIFmt() const {
return ref().namePltt != 0;
}
+1
View File
@@ -81,6 +81,7 @@ public:
void GXSetIndTexOrder(GXIndTexStageID stage, GXTexCoordID coord, GXTexMapID map);
void GXSetTevColorIn(GXTevStageID stage, GXTevColorArg a, GXTevColorArg b, GXTevColorArg c, GXTevColorArg d);
void GXSetTevAlphaIn(GXTevStageID stage, GXTevColorArg a, GXTevColorArg b, GXTevColorArg c, GXTevColorArg d);
void CallDisplayList(bool sync) const;
+11 -3
View File
@@ -37,12 +37,12 @@ struct UnalignedColor {
};
struct PaletteDefaultMCF {
/* 0x00 */ mColor MA00_kcolor3;
/* 0x00 */ mColor MA00_kColor3;
/* 0x04 */ mColor MA01_tevReg1;
/* 0x08 */ mColor MA01_kColor2;
/* 0x0C */ mColor MA02_tevReg1;
/* 0x10 */ mColor MA02_kcolor2;
/* 0x14 */ mColor MA03_kcolor3;
/* 0x10 */ mColor MA02_kColor2;
/* 0x14 */ mColor MA03_kColor3;
/* 0x18 */ mColor MA06_kColor3;
/* 0x1C */ mColor field_0x1C;
};
@@ -232,6 +232,14 @@ public:
void fn_800223A0(void *);
void fn_80022440(void *);
u8 get0x2DE8() const {
return field_0x2DE0[8];
}
const PaletteDefaultMCF &GetCurrentDefaultMcf() const {
return field_0x5CE4;
}
private:
mColor combineColors(const mColor &c1, const mColor &c2, f32 ratio);
+219
View File
@@ -0,0 +1,219 @@
#ifndef D_D3D_H
#define D_D3D_H
#include "common.h"
#include "d/a/d_a_base.h"
#include "egg/egg_types.h"
#include "m/m3d/m_anmmdl.h"
#include "m/m3d/m_fanm.h"
#include "m/m3d/m_mdl.h"
#include "m/m3d/m_proc.h"
#include "m/m_color.h"
#include "m/m_mtx.h"
#include "nw4r/g3d/res/g3d_resfile.h"
#include "toBeSorted/tlist.h"
#include <cstddef>
namespace d3d {
class AnmMdlWrapper : protected m3d::mdlAnmChr {
public:
AnmMdlWrapper();
virtual ~AnmMdlWrapper();
virtual void play() override;
virtual bool setAnm(const char *name, m3d::playMode_e mode, f32) override;
virtual bool setAnm(const char *name, m3d::playMode_e mode) override {
return setAnm(name, mode, 0.0f);
}
virtual void setFrame(f32 frame) override;
virtual void setRate(f32 rate) override;
// Base creation function, different names in different files
/* 0x20 */ virtual bool
create(dAcBase_c &ac, void *mdlFile, void *anmFile, const char *mdlName, const char *anmName, u32 bufferOption);
// Unknown overloads
/* 0x24 */ virtual bool
create2(dAcBase_c &ac, void *mdlFile, void *anmFile, const char *mdlName, const char *anmName, u32 bufferOption);
/* 0x28 */ virtual bool
create3(dAcBase_c &ac, void *mdlFile, void *anmFile, const char *mdlName, const char *anmName, u32 bufferOption) {
return create2(ac, mdlFile, anmFile, mdlName, anmName, bufferOption);
}
// Create with a callback
/* 0x2C */ virtual bool create(
dAcBase_c &ac, void *mdlFile, void *anmFile, const char *mdlName, const char *anmName,
m3d::mdl_c::mdlCallback_c *callback, u32 bufferOption
);
// Unknown overloads
/* 0x30 */ virtual bool create2(
dAcBase_c &ac, void *mdlFile, void *anmFile, const char *mdlName, const char *anmName,
m3d::mdl_c::mdlCallback_c *callback, u32 bufferOption
);
/* 0x34 */ virtual bool create3(
dAcBase_c &ac, void *mdlFile, void *anmFile, const char *mdlName, const char *anmName,
m3d::mdl_c::mdlCallback_c *callback, u32 bufferOption
);
// Create with same file name for both model and anim
/* 0x38 */ virtual bool
create(dAcBase_c &ac, void *resFile, const char *mdlName, const char *anmName, u32 bufferOption);
// Unknown overloads
/* 0x3C */ virtual bool
create2(dAcBase_c &ac, void *resFile, const char *mdlName, const char *anmName, u32 bufferOption);
/* 0x40 */ virtual bool
create3(dAcBase_c &ac, void *resFile, const char *mdlName, const char *anmName, u32 bufferOption) {
return create2(ac, resFile, mdlName, anmName, bufferOption);
}
// Create with a callback, same file name for both model and anim
/* 0x44 */ virtual bool create(
dAcBase_c &ac, void *mdlFile, const char *mdlName, const char *anmName, m3d::mdl_c::mdlCallback_c *callback,
u32 bufferOption
);
// Unknown overloads
/* 0x48 */ virtual bool create2(
dAcBase_c &ac, void *mdlFile, const char *mdlName, const char *anmName, m3d::mdl_c::mdlCallback_c *callback,
u32 bufferOption
);
/* 0x4C */ virtual bool create3(
dAcBase_c &ac, void *mdlFile, const char *mdlName, const char *anmName, m3d::mdl_c::mdlCallback_c *callback,
u32 bufferOption
) {
return create2(ac, mdlFile, mdlName, anmName, callback, bufferOption);
}
void setSoundSource(SoundSource *pSource);
protected:
bool loadSounds(const char *name);
void syncAnmFrame();
void setSoundRate(f32 rate);
/* 0x68 */ SoundSource *mpSoundSource;
/* 0x6C */ void *mpSoundData;
};
class AnmMdlWrapper2 : public AnmMdlWrapper {
public:
bool createExt(
dAcBase_c &ac, void *mdlFile, void *anmFile, void *ext1, void *ext2, const char *mdlName, const char *anmName,
m3d::mdl_c::mdlCallback_c *callback, u32 bufferOption
);
virtual bool setAnm(const char *name, m3d::playMode_e mode, f32) override;
private:
/* 0x70 */ nw4r::g3d::ResFile mExt1;
/* 0x74 */ nw4r::g3d::ResFile mExt2;
/* 0x78 */ bool mHasExt1;
/* 0x79 */ bool mHasExt2;
};
struct SomeListNode {
/* 0x00 */ u8 _0x00[4];
/* 0x04 */ u16 field_0x04;
/* 0x06 */ u16 field_0x06;
/* 0x08 */ u8 _0x08[4];
/* 0x0C */ TListNode<SomeListNode> mNode;
};
typedef TList<SomeListNode, offsetof(SomeListNode, mNode)> SomeList;
struct SomeListStruct {
SomeList list;
};
void setRoomTevColors(nw4r::g3d::ResMdl mdl, int b1, bool bUnk);
struct UnkWithWaterNode {
public:
UnkWithWaterNode(nw4r::g3d::ResTexObj &obj, GXTexMapID mapId) : mObj(obj), mMapId(mapId) {}
void apply(const GXTexObj *obj);
/* 0x00 */ TListNode<UnkWithWaterNode> mNode;
/* 0x08 */ nw4r::g3d::ResTexObj mObj;
/* 0x0C */ GXTexMapID mMapId;
};
class UnkWithWaterBase {
public:
UnkWithWaterBase() : field_0x04(0), field_0x08(0) {}
virtual void calc(EGG::CpuTexture *tex) = 0;
private:
/* 0x04 */ UNKWORD field_0x04;
/* 0x08 */ UNKWORD field_0x08;
};
class UnkWithWater : public UnkWithWaterBase {
public:
typedef TList<UnkWithWaterNode, offsetof(UnkWithWaterNode, mNode)> NodeList;
UnkWithWater() {}
virtual ~UnkWithWater() {
remove();
}
virtual void calc(EGG::CpuTexture *tex) override;
bool init(nw4r::g3d::ResTexObj &obj, GXTexMapID mapId);
static bool linkMdl(nw4r::g3d::ResMdl &mdl, UnkWithWater *thing);
bool hasLinks() const {
return mList.mCount != 0;
}
private:
void remove();
/* 0x0C */ NodeList mList;
};
class UnkProc : public m3d::proc_c {
public:
private:
};
class EggTextureProc : public UnkProc {
public:
EggTextureProc() : mpCpuTexture(nullptr) {}
virtual ~EggTextureProc() {
doRemove();
}
virtual int entry() override;
bool create(int prioOpa, int prioXlu, mAllocator_c *alloc);
bool createXlu(int prioXlu, mAllocator_c *alloc);
virtual void drawOpa() override {
doDraw();
}
virtual void drawXlu() override {
doDraw();
}
private:
void doRemove();
void doDraw();
/* 0x18 */ EGG::TextureBuffer *mpCpuTexture;
/* 0x1C */ mMtx_c mMtx;
/* 0x4C */ UNKWORD _0x4C;
/* 0x50 */ u8 field_0x50;
/* 0x51 */ u8 field_0x51;
/* 0x52 */ u8 field_0x52;
};
class XluProc : public UnkProc {
public:
virtual void drawXlu() override;
private:
/* 0x18 */ mColor mClr;
};
} // end namespace d3d
#endif
+1 -1
View File
@@ -13,7 +13,7 @@ public:
ExecCallback_CALC_MAT(nw4r::g3d::ScnObj::Timing, nw4r::g3d::ScnObj *, u32, void *) override;
/* 0x04 */ dAcObjBase_c *mpActor;
/* 0x08 */ UNKWORD field_0x08;
/* 0x08 */ bool field_0x08;
/* 8001a230 */ void attach(m3d::scnLeaf_c &);
};
+2 -2
View File
@@ -86,7 +86,7 @@ public:
* list of this type.
*/
Iterator GetPosition(T *pT) {
if (pT->mLink.mpNext == nullptr || pT->mLink.mpPrev == nullptr) {
if (GetNodeFromPtr(pT)->mpNext == nullptr || GetNodeFromPtr(pT)->mpPrev == nullptr) {
return GetEndIter();
} else {
return Iterator(pT);
@@ -139,7 +139,7 @@ public:
mCount--;
}
T* GetFirst() {
T *GetFirst() {
return GetPtrFromNode(&mStartEnd);
}
-45
View File
@@ -1,45 +0,0 @@
#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 UnkWithWaterBase {
public:
UnkWithWaterBase() : field_0x04(0), field_0x08(0) {}
virtual void calc() = 0;
private:
/* 0x04 */ UNKWORD field_0x04;
/* 0x08 */ UNKWORD field_0x08;
};
class UnkWithWater : public UnkWithWaterBase {
public:
typedef TList<UnkWithWaterNode, offsetof(UnkWithWaterNode, mNode)> NodeList;
UnkWithWater() {}
virtual ~UnkWithWater() {
remove();
}
virtual void calc() override;
static bool linkMdl(nw4r::g3d::ResMdl &mdl, UnkWithWater *thing);
bool hasLinks() const {
return mList.mCount != 0;
}
private:
void remove();
/* 0x0C */ NodeList mList;
};
#endif