mirror of
https://github.com/zeldaret/ss
synced 2026-07-09 22:21:32 -04:00
Some small classes
This commit is contained in:
+30
-10
@@ -1,26 +1,46 @@
|
||||
#ifndef EGG_FOG_H
|
||||
#define EGG_FOG_H
|
||||
|
||||
#include "common.h"
|
||||
#include "egg/prim/eggBinary.h"
|
||||
#include "nw4r/g3d/g3d_fog.h"
|
||||
#include "nw4r/types_nw4r.h"
|
||||
#include "rvl/GX/GXTypes.h"
|
||||
|
||||
namespace EGG {
|
||||
|
||||
// TODO: Add members
|
||||
class FogManager : IBinary<FogManager> {
|
||||
class Fog : public IBinary<Fog> {
|
||||
public:
|
||||
FogManager(u16);
|
||||
virtual ~FogManager();
|
||||
virtual void SetBinaryInner(Bin &) override;
|
||||
struct BinData {
|
||||
/* 0x10 */ f32 mStartZ;
|
||||
/* 0x14 */ f32 mEndZ;
|
||||
/* 0x18 */ f32 mNearZ;
|
||||
/* 0x1C */ f32 mFarZ;
|
||||
/* 0x20 */ GXColor mColor;
|
||||
/* 0x24 */ u8 field_0x24;
|
||||
/* 0x25 */ u8 mFlag2;
|
||||
/* 0x26 */ u16 field_0x26;
|
||||
/* 0x28 */ UNKWORD field_0x28;
|
||||
/* 0x2C */ UNKWORD field_0x2C;
|
||||
};
|
||||
Fog();
|
||||
virtual ~Fog();
|
||||
virtual void SetBinaryInner(const Bin &) override;
|
||||
virtual void GetBinaryInner(Bin *) const override;
|
||||
virtual size_t GetBinarySize() override;
|
||||
virtual void SetBinaryInner(const Bin &, const Bin &, f32) override;
|
||||
|
||||
void Calc();
|
||||
void CopyToG3D(nw4r::g3d::ScnRoot *) const;
|
||||
void CopyToG3D(nw4r::g3d::Fog fof) const;
|
||||
void Reset();
|
||||
|
||||
/* 0x04 */ u8 mFlag;
|
||||
/* 0x05 */ u8 TODO[0x10 - 0x05];
|
||||
private:
|
||||
|
||||
/* 0x04 */ GXColor mColor;
|
||||
/* 0x08 */ f32 mStartZ;
|
||||
/* 0x0C */ f32 mEndZ;
|
||||
/* 0x10 */ f32 mNearZ;
|
||||
/* 0x14 */ f32 mFarZ;
|
||||
/* 0x18 */ GXFogType mFogType;
|
||||
/* 0x1C */ u8 mFlags;
|
||||
};
|
||||
|
||||
} // namespace EGG
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef EGG_FOG_MANAGER_H
|
||||
#define EGG_FOG_MANAGER_H
|
||||
|
||||
#include "common.h"
|
||||
#include "egg/gfx/eggFog.h"
|
||||
#include "egg/prim/eggBinary.h"
|
||||
#include "nw4r/types_nw4r.h"
|
||||
|
||||
namespace EGG {
|
||||
|
||||
// TODO: Add members
|
||||
class FogManager : IBinary<FogManager> {
|
||||
public:
|
||||
struct BinData {
|
||||
/* 0x10 */ u16 mCount;
|
||||
/* 0x12 */ u8 _0x12[2];
|
||||
/* 0x14 */ IBinary<Fog>::Bin mFogData[1];
|
||||
};
|
||||
FogManager(u16);
|
||||
virtual ~FogManager();
|
||||
virtual void SetBinaryInner(const Bin &) override;
|
||||
virtual void GetBinaryInner(Bin *) const override;
|
||||
virtual size_t GetBinarySize() const override;
|
||||
virtual void SetBinaryInner(const Bin &, const Bin &, f32) override;
|
||||
|
||||
void ResetFog();
|
||||
void Calc();
|
||||
void CopyToG3D(nw4r::g3d::ScnRoot *) const;
|
||||
|
||||
void DoneDraw() {
|
||||
mFlag &= ~4;
|
||||
}
|
||||
|
||||
private:
|
||||
/* 0x04 */ u8 mFlag;
|
||||
/* 0x05 */ u8 TODO[0x08 - 0x05];
|
||||
/* 0x08 */ u16 mCount;
|
||||
/* 0x0A */ u16 mCount2;
|
||||
/* 0x0C */ Fog *mpFog;
|
||||
};
|
||||
|
||||
} // namespace EGG
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,20 @@
|
||||
#ifndef EGG_G3D_UTILITY_H
|
||||
#define EGG_G3D_UTILITY_H
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
#include "rvl/MEM/mem_allocator.h"
|
||||
|
||||
namespace EGG {
|
||||
|
||||
class G3DUtility {
|
||||
public:
|
||||
static MEMAllocator *getAllocator() {
|
||||
return sAllocator;
|
||||
}
|
||||
|
||||
private:
|
||||
static MEMAllocator *sAllocator;
|
||||
};
|
||||
|
||||
} // namespace EGG
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
#ifndef EGG_GLOBAL_DRAW_STATE_H
|
||||
#define EGG_GLOBAL_DRAW_STATE_H
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
#include "egg/gfx/eggScreen.h"
|
||||
#include "nw4r/math/math_types.h"
|
||||
|
||||
namespace EGG {
|
||||
|
||||
class GlobalDrawState {
|
||||
public:
|
||||
GlobalDrawState() {}
|
||||
static void setDrawSettingGX(bool, bool);
|
||||
static void beginDrawView(u16, nw4r::math::MTX34 const &, Screen const &);
|
||||
|
||||
private:
|
||||
static u16 sCameraId;
|
||||
static u32 sDrawFlag;
|
||||
static Screen const *spScreen;
|
||||
|
||||
// unknown
|
||||
static nw4r::math::MTX34 sMtx;
|
||||
};
|
||||
|
||||
} // namespace EGG
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,45 @@
|
||||
#ifndef EGG_ISCNPROC_H
|
||||
#define EGG_ISCNPROC_H
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
#include "common.h"
|
||||
#include "nw4r/g3d/g3d_scnproc.h"
|
||||
#include "rvl/MEM/mem_allocator.h"
|
||||
|
||||
namespace EGG {
|
||||
|
||||
class IScnProc {
|
||||
private:
|
||||
// Unofficial name
|
||||
struct ProcData {
|
||||
IScnProc *mpThis; // at 0x0
|
||||
nw4r::g3d::ScnProc *mpScnProc; // at 0x4
|
||||
u16 mIndex; // at 0x8
|
||||
u8 mFlags; // at 0xA
|
||||
};
|
||||
|
||||
ProcData *mpDataSet; // at 0x0
|
||||
u16 mNumScnProc; // at 0x4
|
||||
|
||||
public:
|
||||
IScnProc() : mpDataSet(nullptr), mNumScnProc(0) {}
|
||||
virtual void doDraw(u16) = 0; // at 0x8
|
||||
virtual ~IScnProc(); // at 0xC
|
||||
|
||||
void createScnProc(u16 procNum, MEMAllocator *allocator);
|
||||
void setPriorityScnProc(u16, u8, bool);
|
||||
void pushBackToScnGroup(nw4r::g3d::ScnGroup *);
|
||||
void removeFromScnGroup(nw4r::g3d::ScnGroup *);
|
||||
static void drawProcFunc(nw4r::g3d::ScnProc *, bool);
|
||||
static void drawProcFuncNoGlobalState(nw4r::g3d::ScnProc *, bool);
|
||||
|
||||
u16 getNumScnProc() {
|
||||
return mNumScnProc;
|
||||
}
|
||||
ProcData *getData(u16 procIndex) {
|
||||
return &mpDataSet[procIndex];
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace EGG
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,10 +16,11 @@ public:
|
||||
// TODO: Fill out more
|
||||
class LightTextureManager : public IBinary<LightTextureManager> {
|
||||
public:
|
||||
struct BinData {};
|
||||
virtual ~LightTextureManager();
|
||||
virtual void SetBinaryInner(Bin &) override;
|
||||
virtual void SetBinaryInner(const Bin &) override;
|
||||
virtual void GetBinaryInner(Bin *) const override;
|
||||
virtual size_t GetBinarySize() override;
|
||||
virtual size_t GetBinarySize() const override;
|
||||
virtual void SetBinaryInner(const Bin &, const Bin &, f32) override;
|
||||
void replaceModelTextures(nw4r::g3d::ResMdl) const;
|
||||
|
||||
@@ -29,12 +30,13 @@ public:
|
||||
// TODO: Fill out more
|
||||
class LightManager : public IBinary<LightManager> {
|
||||
public:
|
||||
struct BinData {};
|
||||
// vt at 0x00
|
||||
LightManager(u32, u32, u8);
|
||||
virtual ~LightManager();
|
||||
virtual void SetBinaryInner(Bin &) override;
|
||||
virtual void SetBinaryInner(const Bin &) override;
|
||||
virtual void GetBinaryInner(Bin *) const override;
|
||||
virtual size_t GetBinarySize() override;
|
||||
virtual size_t GetBinarySize() const override;
|
||||
virtual void SetBinaryInner(const Bin &, const Bin &, f32) override;
|
||||
virtual void Reset();
|
||||
virtual void Calc(nw4r::g3d::ScnRoot *);
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
#ifndef EGG_SCREEN_EFFECT_BASE_H
|
||||
#define EGG_SCREEN_EFFECT_BASE_H
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
#include "common.h"
|
||||
#include "egg/gfx/eggScreen.h"
|
||||
|
||||
namespace EGG {
|
||||
|
||||
class ScreenEffectBase {
|
||||
private:
|
||||
u8 mFlag;
|
||||
|
||||
public:
|
||||
ScreenEffectBase();
|
||||
virtual ~ScreenEffectBase() {} // at 0x8
|
||||
|
||||
protected:
|
||||
static Screen sScreen;
|
||||
};
|
||||
|
||||
} // namespace EGG
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
#ifndef EGG_STATE_EFB_H
|
||||
#define EGG_STATE_EFB_H
|
||||
|
||||
namespace EGG {} // namespace EGG
|
||||
namespace EGG {
|
||||
|
||||
class StateEfb {
|
||||
public:
|
||||
static void Clean();
|
||||
};
|
||||
|
||||
} // namespace EGG
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,6 +27,11 @@ public:
|
||||
|
||||
static void invalidateTexAllGX();
|
||||
|
||||
static bool GXSetColorUpdate_(bool);
|
||||
static bool GXSetAlphaUpdate_(bool);
|
||||
static bool GXSetDither_(bool);
|
||||
static bool GXSetDstAlpha_(bool, u8);
|
||||
|
||||
static bool GXSetColorUpdate(bool);
|
||||
static bool GXSetAlphaUpdate(bool);
|
||||
static bool GXSetDither();
|
||||
@@ -38,6 +43,9 @@ public:
|
||||
static void GXSetViewport(f32, f32, f32, f32, f32, f32);
|
||||
static void GZSetScissor(u32, u32, u32, u32);
|
||||
static void GZSetScissorBoxOffset(s32, s32);
|
||||
|
||||
|
||||
static u16 s_commandFlag;
|
||||
};
|
||||
|
||||
} // namespace EGG
|
||||
|
||||
@@ -3,23 +3,88 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
namespace EGG {
|
||||
|
||||
/**
|
||||
* @brief Common interface for objects that can be serialized to
|
||||
* and deserializized from binary.
|
||||
*
|
||||
* @tparam T The type of the Egg class. Must have a BinData type
|
||||
* that describes the binary type.
|
||||
*/
|
||||
template <class T>
|
||||
class IBinary {
|
||||
public:
|
||||
class Bin {};
|
||||
virtual void SetBinaryInner(Bin &) = 0;
|
||||
#pragma pack(push, 1)
|
||||
struct BinHeader {
|
||||
/* 0x00 */ char mType[4];
|
||||
/* 0x04 */ size_t mSize;
|
||||
/* 0x08 */ u8 mVersion;
|
||||
/* 0x09 */ u16 field_0x09;
|
||||
/* 0x0B */ u8 field_0x0B;
|
||||
/* 0x0C */ u32 field_0x0C;
|
||||
};
|
||||
struct Bin {
|
||||
BinHeader mHeader;
|
||||
typename T::BinData mData;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
protected:
|
||||
/** Load the object from binary */
|
||||
virtual void SetBinaryInner(const Bin &) = 0;
|
||||
/** Save the object to binary */
|
||||
virtual void GetBinaryInner(Bin *) const = 0;
|
||||
virtual size_t GetBinarySize() = 0;
|
||||
/** Get the size of the serialized data. Override if your binary has a dynamic size */
|
||||
virtual size_t GetBinarySize() const {
|
||||
return sizeof(Bin);
|
||||
}
|
||||
/** Load the object from binary, interpolating between values */
|
||||
virtual void SetBinaryInner(const Bin &, const Bin &, f32) = 0;
|
||||
|
||||
/** Get a 4-bytes long ID string corresponding to this type */
|
||||
static const char *GetBinaryType();
|
||||
int GetVersion();
|
||||
|
||||
void GetBinary(void *) const;
|
||||
/** Get the current version of this type */
|
||||
static int GetVersion();
|
||||
|
||||
public:
|
||||
// These functions below are automatically provided, you should not need to
|
||||
// touch them to implement de-/serialization for your type. They will parse
|
||||
// the binary header and then invoke the above virtual functions.
|
||||
void GetBinary(void *pData) const;
|
||||
void SetBinary(const void *);
|
||||
|
||||
void SetBinaryBlend(const void *, const void *, f32);
|
||||
void SetBinaryBlend(const void *a, const void *b, f32 blend);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void IBinary<T>::GetBinary(void *pData) const {
|
||||
Bin *pBin = reinterpret_cast<Bin *>(pData);
|
||||
BinHeader zeroedHeader = {0};
|
||||
pBin->mHeader = zeroedHeader;
|
||||
|
||||
pBin->mHeader.mVersion = GetVersion();
|
||||
pBin->mHeader.mSize = GetBinarySize();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
pBin->mHeader.mType[i] = GetBinaryType()[i];
|
||||
}
|
||||
typename T::BinData zeroedDatat = {0};
|
||||
pBin->mData = zeroedDatat;
|
||||
GetBinaryInner(pBin);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void IBinary<T>::SetBinary(const void *a) {
|
||||
const Bin *pBinA = reinterpret_cast<const Bin *>(a);
|
||||
SetBinaryInner(*pBinA);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void IBinary<T>::SetBinaryBlend(const void *a, const void *b, f32 blend) {
|
||||
const Bin *pBinA = reinterpret_cast<const Bin *>(a);
|
||||
const Bin *pBinB = reinterpret_cast<const Bin *>(b);
|
||||
SetBinaryInner(*pBinA, *pBinB, blend);
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#define M3D_H
|
||||
|
||||
#include "egg/core/eggHeap.h"
|
||||
#include "egg/gfx/eggFog.h"
|
||||
#include "egg/gfx/eggFogManager.h"
|
||||
#include "egg/gfx/eggLight.h"
|
||||
#include "m/m_allocator.h"
|
||||
#include "nw4r/g3d/g3d_scnroot.h"
|
||||
|
||||
@@ -76,6 +76,13 @@ public:
|
||||
bool IsFogRangeAdjEnable() const {
|
||||
return IsValid() && ref().adjEnable == TRUE;
|
||||
}
|
||||
|
||||
void SetFogRangeAdjEnable(bool enable) {
|
||||
if (!IsValid()) {
|
||||
return;
|
||||
}
|
||||
ref().adjEnable = enable;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace g3d
|
||||
|
||||
Reference in New Issue
Block a user