fopEn_enemy / fix e_wb

This commit is contained in:
TakaRikka
2022-10-04 17:29:53 -07:00
parent 179d4e8df2
commit 31ef090a50
36 changed files with 1057 additions and 836 deletions
+27 -12
View File
@@ -11,22 +11,37 @@ class J3DDrawPacket;
class J3DMatPacket;
class J3DShapePacket;
typedef void (*J3DDrawBuffer_DrawFunc)(const J3DDrawBuffer* this_);
typedef int (J3DDrawBuffer::*sortFunc)(J3DMatPacket*);
typedef void (J3DDrawBuffer::*drawFunc)() const;
class J3DDrawBuffer {
public:
enum EDrawType {
DRAW_HEAD,
DRAW_TAIL,
};
enum ESortType {
SORT_MAT,
SORT_MAT_ANM,
SORT_Z,
SORT_MODEL,
SORT_INVALID,
SORT_NON,
};
J3DDrawBuffer() { initialize(); }
~J3DDrawBuffer();
void initialize();
J3DError allocBuffer(u32);
void frameInit();
void entryMatSort(J3DMatPacket*);
void entryMatAnmSort(J3DMatPacket*);
void entryZSort(J3DMatPacket*);
void entryModelSort(J3DMatPacket*);
void entryInvalidSort(J3DMatPacket*);
bool entryNonSort(J3DMatPacket*);
bool entryImm(J3DPacket* pPacket, u16 index);
int entryMatSort(J3DMatPacket*);
int entryMatAnmSort(J3DMatPacket*);
int entryZSort(J3DMatPacket*);
int entryModelSort(J3DMatPacket*);
int entryInvalidSort(J3DMatPacket*);
int entryNonSort(J3DMatPacket*);
int entryImm(J3DPacket* pPacket, u16 index);
void draw() const;
void drawHead() const;
void drawTail() const;
@@ -43,12 +58,12 @@ public:
/* 0x10 */ f32 mZNear;
/* 0x14 */ f32 mZFar;
/* 0x18 */ f32 mZRatio;
/* 0x1C */ Mtx* mpZMtx;
/* 0x1C */ MtxP mpZMtx;
/* 0x20 */ J3DPacket* mpCallBackPacket;
static u8 sortFuncTable[72];
static u8 drawFuncTable[24];
static u8 entryNum[4 + 4 /* padding */];
static sortFunc sortFuncTable[6];
static drawFunc drawFuncTable[2];
static int entryNum;
};
#endif /* J3DDRAWBUFFER_H */
+3 -1
View File
@@ -57,9 +57,11 @@ public:
}
void addChildPacket(J3DPacket*);
J3DPacket* getNextPacket() const { return mpNextSibling; }
void setNextPacket(J3DPacket* i_packet) { mpNextSibling = i_packet; }
inline void clear() {
void drawClear() {
mpNextSibling = NULL;
mpFirstChild = NULL;
}
+16
View File
@@ -27,6 +27,11 @@ static inline void J3DFifoWriteXFCmd(u16 cmd, u16 len) {
class J3DCurrentMtx : public J3DCurrentMtxInfo {
public:
J3DCurrentMtx() {
mMtxIdxRegA = 0x3cf3cf00;
mMtxIdxRegB = 0x00f3cf3c;
}
u32 getMtxIdxRegA() const { return mMtxIdxRegA; }
u32 getMtxIdxRegB() const { return mMtxIdxRegB; }
@@ -54,6 +59,14 @@ enum J3DShpFlag {
class J3DShape {
public:
J3DShape() {
initialize();
}
enum {
kVcdVatDLSize = 0xC0,
};
/* 80314B48 */ void initialize();
/* 80314BB8 */ void addTexMtxIndexInDL(_GXAttr, u32);
/* 80314CBC */ void addTexMtxIndexInVcd(_GXAttr);
@@ -93,11 +106,14 @@ public:
inline u32 getMtxGroupNum() const { return mMtxGroupNum; }
inline J3DShapeDraw* getShapeDraw(u32 idx) const { return mShapeDraw[idx]; }
inline J3DShapeMtx* getShapeMtx(u32 idx) const { return mShapeMtx[idx]; }
static void resetVcdVatCache() { sOldVcdVatCmd = NULL; }
static void* sOldVcdVatCmd;
private:
friend struct J3DShapeFactory;
/* 0x04 */ J3DMaterial* mMaterial;
/* 0x08 */ u16 mIndex;
/* 0x0A */ u16 mMtxGroupNum;
+32 -4
View File
@@ -24,6 +24,10 @@ extern u8 struct_804515B0[4];
class J3DShapeMtx {
public:
J3DShapeMtx(u16 useMtxIndex)
: mUseMtxIndex(useMtxIndex)
{}
/* 803130A8 */ void resetMtxLoadCache();
/* 803130E4 */ void loadMtxIndx_PNGP(int, u16) const;
/* 80313128 */ void loadMtxIndx_PCPU(int, u16) const;
@@ -54,6 +58,10 @@ private:
class J3DShapeMtxConcatView : public J3DShapeMtx {
public:
J3DShapeMtxConcatView(u16 useMtxIndex)
: J3DShapeMtx(useMtxIndex)
{}
/* 80314730 */ virtual ~J3DShapeMtxConcatView();
/* 803147E0 */ virtual u32 getType() const;
/* 80313C54 */ virtual void load() const;
@@ -73,6 +81,10 @@ public:
class J3DShapeMtxYBBoardConcatView : public J3DShapeMtxConcatView {
public:
J3DShapeMtxYBBoardConcatView(u16 useMtxIndex)
: J3DShapeMtxConcatView(useMtxIndex)
{}
/* 80314520 */ virtual ~J3DShapeMtxYBBoardConcatView();
/* 803147E0 */ virtual u32 getType() const;
/* 803143E4 */ virtual void load() const;
@@ -80,6 +92,10 @@ public:
class J3DShapeMtxBBoardConcatView : public J3DShapeMtxConcatView {
public:
J3DShapeMtxBBoardConcatView(u16 useMtxIndex)
: J3DShapeMtxConcatView(useMtxIndex)
{}
/* 803145A4 */ virtual ~J3DShapeMtxBBoardConcatView();
/* 803147E0 */ virtual u32 getType() const;
/* 803142D4 */ virtual void load() const;
@@ -87,6 +103,12 @@ public:
class J3DShapeMtxMulti : public J3DShapeMtx {
public:
J3DShapeMtxMulti(u16 useMtxIndex, u16 useMtxNum, u16* useMtxIndexTable)
: J3DShapeMtx(useMtxIndex)
, mUseMtxNum(useMtxNum)
, mUseMtxIndexTable(useMtxIndexTable)
{}
/* 803146B0 */ virtual ~J3DShapeMtxMulti();
/* 803147E0 */ virtual u32 getType() const;
/* 80273E08 */ virtual u32 getUseMtxNum() const;
@@ -96,11 +118,17 @@ public:
private:
/* 0x6 */ u16 mUseMtxNum;
/* 0x8 */ u16* mUseMtxIndex;
/* 0x8 */ u16* mUseMtxIndexTable;
};
class J3DShapeMtxMultiConcatView : public J3DShapeMtx {
class J3DShapeMtxMultiConcatView : public J3DShapeMtxConcatView {
public:
J3DShapeMtxMultiConcatView(u16 useMtxIndex, u16 useMtxNum, u16* useMtxIndexTable)
: J3DShapeMtxConcatView(useMtxIndex)
, mUseMtxNum(useMtxNum)
, mUseMtxIndexTable(useMtxIndexTable)
{}
/* 8031461C */ virtual ~J3DShapeMtxMultiConcatView();
/* 803147E0 */ virtual u32 getType() const;
/* 80273E08 */ virtual u32 getUseMtxNum() const;
@@ -111,7 +139,7 @@ public:
private:
/* 0x6 */ u16 mUseMtxNum;
/* 0x8 */ u16* mUseMtxIndex;
/* 0x8 */ u16* mUseMtxIndexTable;
};
#endif /* J3DSHAPEMTX_H */
#endif /* J3DSHAPEMTX_H */
@@ -1,6 +1,78 @@
#ifndef J3DSHAPEFACTORY_H
#define J3DSHAPEFACTORY_H
#include "dolphin/gx/GX.h"
#include "dolphin/types.h"
#endif /* J3DSHAPEFACTORY_H */
struct J3DShape;
struct J3DShapeMtx;
struct J3DShapeDraw;
struct ResNTAB;
struct J3DShapeInitData {
/* 0x00 */ u8 mShapeMtxType;
/* 0x02 */ u16 mMtxGroupNum;
/* 0x04 */ u16 mVtxDescListIndex;
/* 0x06 */ u16 mMtxInitDataIndex;
/* 0x08 */ u16 mDrawInitDataIndex;
/* 0x0C */ f32 mRadius;
/* 0x10 */ Vec mMin;
/* 0x1C */ Vec mMax;
};
struct J3DShapeMtxInitData {
/* 0x00 */ u16 mUseMtxIndex;
/* 0x02 */ u16 mUseMtxCount;
/* 0x04 */ u32 mFirstUseMtxIndex;
};
struct J3DShapeDrawInitData {
/* 0x00 */ u32 mDisplayListSize;
/* 0x04 */ u32 mDisplayListIndex;
};
struct J3DShapeBlock {
/* 0x00 */ u8 mMagic[4];
/* 0x04 */ u32 mSize;
/* 0x08 */ u16 mShapeNum;
/* 0x0A */ u16 _pad;
/* 0x0C */ J3DShapeInitData* mShapeInitData;
/* 0x10 */ u16* mIndexTable;
/* 0x14 */ ResNTAB* mNameTable;
/* 0x18 */ GXVtxDescList* mVtxDescList;
/* 0x1C */ u16* mMtxTable;
/* 0x20 */ u8* mDisplayListData;
/* 0x24 */ J3DShapeMtxInitData* mMtxInitData;
/* 0x28 */ J3DShapeDrawInitData* mDrawInitData;
};
struct J3DShapeFactory {
/* 80337350 */ J3DShapeFactory(J3DShapeBlock const&);
/* 80337400 */ J3DShape* create(int, u32, GXVtxDescList*);
/* 803375BC */ J3DShapeMtx* newShapeMtx(u32, int, int) const;
/* 8033784C */ J3DShapeDraw* newShapeDraw(int, int) const;
/* 803378D8 */ void allocVcdVatCmdBuffer(u32);
/* 80337944 */ s32 calcSize(int, u32);
/* 803379D8 */ s32 calcSizeVcdVatCmdBuffer(u32);
/* 803379E8 */ s32 calcSizeShapeMtx(u32, int, int) const;
/* 0x00 */ J3DShapeInitData* mShapeInitData;
/* 0x04 */ u16* mIndexTable;
/* 0x08 */ GXVtxDescList* mVtxDescList;
/* 0x0C */ u16* mMtxTable;
/* 0x10 */ u8* mDisplayListData;
/* 0x14 */ J3DShapeMtxInitData* mMtxInitData;
/* 0x18 */ J3DShapeDrawInitData* mDrawInitData;
/* 0x1C */ u8* mVcdVatCmdBuffer;
u32 getMtxGroupNum(int no) const { return mShapeInitData[mIndexTable[no]].mMtxGroupNum; }
GXVtxDescList* getVtxDescList(int no) const { return (GXVtxDescList*)((u8*)mVtxDescList + mShapeInitData[mIndexTable[no]].mVtxDescListIndex); }
f32 getRadius(int no) const { return mShapeInitData[mIndexTable[no]].mRadius; }
Vec& getMin(int no) const { return mShapeInitData[mIndexTable[no]].mMin; }
Vec& getMax(int no) const { return mShapeInitData[mIndexTable[no]].mMax; }
};
#endif /* J3DSHAPEFACTORY_H */
+1 -1
View File
@@ -3,7 +3,7 @@
template <typename T>
T* JSUConvertOffsetToPtr(const void* ptr, const void* offset) {
if (ptr == NULL) {
if (offset == NULL) {
return NULL;
} else {
return (T*)((s32)ptr + (s32)offset);