Skip to content

Commit

Permalink
Rename s2dex structs
Browse files Browse the repository at this point in the history
  • Loading branch information
cadmic committed Oct 2, 2024
1 parent 1653ef7 commit 85f7aee
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 43 deletions.
60 changes: 26 additions & 34 deletions include/emulator/rsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ typedef struct Rsp {
/* 0x39C8 */ int* dctBuf;
} Rsp; // size = 0x39CC

// uObjBg_t
typedef struct __anon_0x5ED4F {
typedef struct uObjBg_t {
/* 0x00 */ u16 imageX;
/* 0x02 */ u16 imageW;
/* 0x04 */ s16 frameX;
Expand All @@ -290,10 +289,9 @@ typedef struct __anon_0x5ED4F {
/* 0x22 */ u16 tmemLoadTH;
/* 0x24 */ u16 tmemSizeW;
/* 0x26 */ u16 tmemSize;
} __anon_0x5ED4F; // size = 0x28
} uObjBg_t; // size = 0x28

// uObjScaleBg_t
typedef struct __anon_0x5F05A {
typedef struct uObjScaleBg_t {
/* 0x00 */ u16 imageX;
/* 0x02 */ u16 imageW;
/* 0x04 */ s16 frameX;
Expand All @@ -312,17 +310,15 @@ typedef struct __anon_0x5F05A {
/* 0x1E */ u16 scaleH;
/* 0x20 */ s32 imageYorig;
/* 0x24 */ u8 padding[4];
} __anon_0x5F05A; // size = 0x28
} uObjScaleBg_t; // size = 0x28

// uObjBg
typedef union __anon_0x5F2FB {
__anon_0x5ED4F b;
__anon_0x5F05A s;
typedef union uObjBg {
uObjBg_t b;
uObjScaleBg_t s;
s64 force_structure_alignment;
} __anon_0x5F2FB;
} uObjBg;

// uObjSprite_t
typedef struct __anon_0x5F429 {
typedef struct uObjSprite_t {
/* 0x00 */ s16 objX;
/* 0x02 */ u16 scaleW;
/* 0x04 */ u16 imageW;
Expand All @@ -337,16 +333,14 @@ typedef struct __anon_0x5F429 {
/* 0x15 */ u8 imageSiz;
/* 0x16 */ u8 imagePal;
/* 0x17 */ u8 imageFlags;
} __anon_0x5F429; // size = 0x18
} uObjSprite_t; // size = 0x18

// uObjSprite
typedef union __anon_0x5F63B {
__anon_0x5F429 s;
typedef union uObjSprite {
uObjSprite_t s;
s64 force_structure_alignment;
} __anon_0x5F63B;
} uObjSprite;

// uObjTxtrBlock_t
typedef struct __anon_0x5F8B9 {
typedef struct uObjTxtrBlock_t {
/* 0x00 */ u32 type;
/* 0x04 */ u32 image;
/* 0x08 */ u16 tmem;
Expand All @@ -355,10 +349,9 @@ typedef struct __anon_0x5F8B9 {
/* 0x0E */ u16 sid;
/* 0x10 */ u32 flag;
/* 0x14 */ u32 mask;
} __anon_0x5F8B9; // size = 0x18
} uObjTxtrBlock_t; // size = 0x18

// uObjTxtrTile_t
typedef struct __anon_0x5F9D9 {
typedef struct uObjTxtrTile_t {
/* 0x00 */ u32 type;
/* 0x04 */ u32 image;
/* 0x08 */ u16 tmem;
Expand All @@ -367,10 +360,10 @@ typedef struct __anon_0x5F9D9 {
/* 0x0E */ u16 sid;
/* 0x10 */ u32 flag;
/* 0x14 */ u32 mask;
} __anon_0x5F9D9; // size = 0x18
} uObjTxtrTile_t; // size = 0x18

// uObjTxtrTLUT_t
typedef struct __anon_0x5FAFC {
typedef struct uObjTxtrTLUT_t {
/* 0x00 */ u32 type;
/* 0x04 */ u32 image;
/* 0x08 */ u16 phead;
Expand All @@ -379,19 +372,18 @@ typedef struct __anon_0x5FAFC {
/* 0x0E */ u16 sid;
/* 0x10 */ u32 flag;
/* 0x14 */ u32 mask;
} __anon_0x5FAFC; // size = 0x18
} uObjTxtrTLUT_t; // size = 0x18

// uObjTxtr
typedef union __anon_0x5FC1B {
__anon_0x5F8B9 block;
__anon_0x5F9D9 tile;
__anon_0x5FAFC tlut;
typedef union uObjTxtr {
uObjTxtrBlock_t block;
uObjTxtrTile_t tile;
uObjTxtrTLUT_t tlut;
s64 force_structure_alignment;
} __anon_0x5FC1B;
} uObjTxtr;

bool rspFillObjBg(Rsp* pRSP, s32 nAddress, __anon_0x5F2FB* pBg);
bool rspFillObjBg(Rsp* pRSP, s32 nAddress, uObjBg* pBg);
bool rspSetImage(struct Frame* pFrame, Rsp* pRSP, s32 nFormat, s32 nWidth, s32 nSize, s32 nImage);
bool rspFillObjBgScale(Rsp* pRSP, s32 nAddress, __anon_0x5F2FB* pBg);
bool rspFillObjBgScale(Rsp* pRSP, s32 nAddress, uObjBg* pBg);
bool rspPut32(Rsp* pRSP, u32 nAddress, s32* pData);
bool rspGet32(Rsp* pRSP, u32 nAddress, s32* pData);
bool rspInvalidateCache(Rsp* pRSP, s32 nOffset0, s32 nOffset1);
Expand Down
2 changes: 1 addition & 1 deletion src/emulator/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -3247,7 +3247,7 @@ bool frameHackCIMG_Zelda2_Shrink(Rdp* pRDP, Frame* pFrame, u64** ppnGBI) {
u32 nCommandHi;
Rsp* pRSP;
s32 done;
union __anon_0x5F2FB bg;
uObjBg bg;

pnGBI = *ppnGBI;
for (count = 0; count < ARRAY_COUNT(GBIcode); count++) {
Expand Down
16 changes: 8 additions & 8 deletions src/emulator/rsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4756,7 +4756,7 @@ static bool Matrix4by4Identity(Mtx44Ptr matrix4b4) {
}
#endif

static bool rspFillObjSprite(Rsp* pRSP, s32 nAddress, __anon_0x5F63B* pSprite) {
static bool rspFillObjSprite(Rsp* pRSP, s32 nAddress, uObjSprite* pSprite) {
u16* pnData16;
u8* pnData8;
u8* pObjSprite;
Expand Down Expand Up @@ -4786,7 +4786,7 @@ static bool rspFillObjSprite(Rsp* pRSP, s32 nAddress, __anon_0x5F63B* pSprite) {
return true;
}

bool rspFillObjBgScale(Rsp* pRSP, s32 nAddress, __anon_0x5F2FB* pBg) {
bool rspFillObjBgScale(Rsp* pRSP, s32 nAddress, uObjBg* pBg) {
u8* pnData8;
u8* pObjBg;
u16* pnData16;
Expand Down Expand Up @@ -4821,7 +4821,7 @@ bool rspFillObjBgScale(Rsp* pRSP, s32 nAddress, __anon_0x5F2FB* pBg) {
return true;
}

bool rspFillObjBg(Rsp* pRSP, s32 nAddress, __anon_0x5F2FB* pBg) {
bool rspFillObjBg(Rsp* pRSP, s32 nAddress, uObjBg* pBg) {
u8* pnData8;
u8* pObjBg;
u16* pnData16;
Expand Down Expand Up @@ -5064,7 +5064,7 @@ static inline bool guS2DEmuSetScissor(u32 ulx, u32 uly, u32 lrx, u32 lry, u8 fla
#else
// Similar to
// https://github.com/decompals/ultralib/blob/1616482098e51d2e1906e198bf1bde14e8fc5e90/src/gu/us2dex_emu.c#L177
static bool guS2DEmuBgRect1Cyc(Rsp* pRSP, Frame* pFrame, __anon_0x5F2FB* pBG) {
static bool guS2DEmuBgRect1Cyc(Rsp* pRSP, Frame* pFrame, uObjBg* pBG) {
s32 pad;

s16 frameX0, frameX1, framePtrY0, frameRemain;
Expand Down Expand Up @@ -5353,7 +5353,7 @@ static bool guS2DEmuBgRect1Cyc(Rsp* pRSP, Frame* pFrame, __anon_0x5F2FB* pBG) {
}
#endif

bool rspFillObjTxtr(Rsp* pRSP, s32 nAddress, __anon_0x5FC1B* pTxtr, u32* pLoadType) {
bool rspFillObjTxtr(Rsp* pRSP, s32 nAddress, uObjTxtr* pTxtr, u32* pLoadType) {
u32* pnData32;
u16* pnData16;
u8* pTxtrBlock;
Expand Down Expand Up @@ -5419,7 +5419,7 @@ static bool rspObjRectangle(Rsp* pRSP, Frame* pFrame, s32 nAddress) {
u16 nSizLineBytes;
f32 fDeltaS;
f32 fDeltaT;
__anon_0x5F63B objSprite;
uObjSprite objSprite;
Tile* pTile;
Rectangle primitive;
s32 nClampSetting;
Expand Down Expand Up @@ -5528,8 +5528,8 @@ static bool rspObjRectangle(Rsp* pRSP, Frame* pFrame, s32 nAddress) {
#pragma GLOBAL_ASM("asm/non_matchings/rsp/rspObjRectangleR.s")

bool rspBgRectCopy(Rsp* pRSP, Frame* pFrame, s32 nAddress) {
union __anon_0x5F2FB bg;
union __anon_0x5F2FB bgScale;
uObjBg bg;
uObjBg bgScale;
u32 nOldMode1;
u32 nOldMode2;

Expand Down

0 comments on commit 85f7aee

Please sign in to comment.