From 89c74d0133edf23fe47b04f4756e143d72f59780 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Sat, 2 Nov 2024 00:13:40 -0400 Subject: [PATCH] GX work, GXData struct should be correct now --- include/dolphin/gx/GX.h | 5 +- include/dolphin/gx/GXEnum.h | 1 - include/dolphin/gx/GXInit.h | 68 +++++----- src/dolphin/gx/GXInit.c | 118 ++++------------- src/dolphin/gx/GXMisc.c | 27 +--- src/dolphin/gx/GXPerf.c | 240 +++++++++++++++-------------------- src/dolphin/gx/GXTev.c | 18 +-- src/dolphin/gx/GXTexture.c | 33 +---- src/dolphin/gx/GXTransform.c | 14 +- 9 files changed, 184 insertions(+), 340 deletions(-) diff --git a/include/dolphin/gx/GX.h b/include/dolphin/gx/GX.h index 3390d051..f263c563 100644 --- a/include/dolphin/gx/GX.h +++ b/include/dolphin/gx/GX.h @@ -23,7 +23,10 @@ extern "C" { #endif // Pack value into bitfield -#define GX_BITFIELD_SET(field, pos, size, value) (field) = __rlwimi((field), (value), 31 - (pos) - (size) + 1, (pos), (pos) + (size)-1) +#define GX_BITFIELD_SET(field, pos, size, value) \ + (field) = \ + (field & ~(((1 << (size)) - 1) << (31 - (pos) - (size) + 1))) | \ + ((int)(value) << (31 - (pos) - (size) + 1)) #define GX_BITFIELD_TRUNC(field, pos, size, value) (__rlwimi((field), (value), 0, (pos), (pos) + (size)-1)) #define GX_BITGET(field, pos, size) ((field) >> (31 - (pos) - (size) + 1) & ((1 << (size)) - 1)) diff --git a/include/dolphin/gx/GXEnum.h b/include/dolphin/gx/GXEnum.h index 1cb56b15..2ee0c019 100644 --- a/include/dolphin/gx/GXEnum.h +++ b/include/dolphin/gx/GXEnum.h @@ -1773,7 +1773,6 @@ typedef enum _GXMiscToken { GX_MT_NULL = 0, GX_MT_XF_FLUSH = 1, GX_MT_DL_SAVE_CONTEXT = 2, - GX_MT_ABORT_WAIT_COPYOUT = 3, } GXMiscToken; // Transform memory types. diff --git a/include/dolphin/gx/GXInit.h b/include/dolphin/gx/GXInit.h index 87e9a754..5acdfc83 100644 --- a/include/dolphin/gx/GXInit.h +++ b/include/dolphin/gx/GXInit.h @@ -80,52 +80,52 @@ typedef struct _GXData { // Texture regions /* 0x208 */ GXTexRegion TexRegions0[GX_MAX_TEXMAP]; - /* 0x288 */ GXTexRegion TexRegions1[GX_MAX_TEXMAP]; - /* 0x308 */ GXTexRegion TexRegions2[GX_MAX_TEXMAP]; + /* 0x288 */ GXTexRegion TexRegions1[4]; + /* 0x2C8 */ u32 m2C8; + /* 0x2C8 */ u32 m2CC; // Texture lookup table regions - /* 0x388 */ GXTlutRegion TlutRegions[GX_MAX_TLUT_ALL]; - /* 0x4C8 */ GXTexRegionCallback texRegionCallback; - /* 0x4CC */ GXTlutRegionCallback tlutRegionCallback; + /* 0x2D0 */ GXTlutRegion TlutRegions[GX_MAX_TLUT_ALL]; + /* 0x410 */ GXTexRegionCallback texRegionCallback; + /* 0x414 */ GXTlutRegionCallback tlutRegionCallback; // Command processor vars - /* 0x4D0 */ GXAttrType nrmType; - /* 0x4D4 */ GXBool hasNrms; - /* 0x4D5 */ GXBool hasBiNrms; - /* 0x4D8 */ u32 projType; - /* 0x4DC */ f32 projMtx[6]; + /* 0x418 */ GXAttrType nrmType; + /* 0x41C */ GXBool hasNrms; + /* 0x41D */ GXBool hasBiNrms; + /* 0x420 */ u32 projType; + /* 0x424 */ f32 projMtx[6]; // Viewport parms - /* 0x4F4 */ f32 vpLeft; - /* 0x4F8 */ f32 vpTop; - /* 0x4FC */ f32 vpWd; - /* 0x500 */ f32 vpHt; - /* 0x504 */ f32 vpNearz; - /* 0x508 */ f32 vpFarz; - /* 0x50C */ f32 zOffset; - /* 0x510 */ f32 zScale; + /* 0x43C */ f32 vpLeft; + /* 0x440 */ f32 vpTop; + /* 0x444 */ f32 vpWd; + /* 0x448 */ f32 vpHt; + /* 0x44C */ f32 vpNearz; + /* 0x450 */ f32 vpFarz; + /* 0x454 */ f32 zOffset; + /* 0x458 */ f32 zScale; // Texture regs - /* 0x514 */ u32 tImage0[8]; - /* 0x534 */ u32 tMode0[8]; - /* 0x554 */ u32 texmapId[16]; - /* 0x594 */ u32 tcsManEnab; - /* 0x598 */ u32 tevTcEnab; + /* 0x45C */ u32 tImage0[8]; + /* 0x47C */ u32 tMode0[8]; + /* 0x49C */ u32 texmapId[16]; + /* 0x4DC */ u32 tcsManEnab; + /* 0x4E0 */ u32 tevTcEnab; // Performance metrics - /* 0x59C */ GXPerf0 perf0; - /* 0x5A0 */ GXPerf1 perf1; - /* 0x5A4 */ u32 perfSel; + /* 0x4E4 */ GXPerf0 perf0; + /* 0x4E8 */ GXPerf1 perf1; + /* 0x4EC */ u32 perfSel; // Flags - /* 0x5A8 */ GXBool inDispList; - /* 0x5A9 */ GXBool dlSaveContext; - /* 0x5AA */ GXBool abtWaitPECopy; - /* 0x5AB */ u8 dirtyVAT; - /* 0x5AC */ u32 dirtyState; -} GXData; // Size: 0x5B0 - -STATIC_ASSERT(sizeof(GXData) == 0x5B0); + /* 0x4F0 */ GXBool inDispList; + /* 0x4F1 */ GXBool dlSaveContext; + /* 0x4F2 */ u8 dirtyVAT; + /* 0x4F4 */ u32 dirtyState; +} GXData; // Size: 0x4F8 + +STATIC_ASSERT(sizeof(GXData) == 0x4F8); extern GXData* const __GXData; diff --git a/src/dolphin/gx/GXInit.c b/src/dolphin/gx/GXInit.c index 1d17d4cc..d05c8ab4 100644 --- a/src/dolphin/gx/GXInit.c +++ b/src/dolphin/gx/GXInit.c @@ -20,9 +20,9 @@ GXTexRegion* __GXDefaultTexRegionCallback(const GXTexObj* obj, GXTexMapID id) { switch (format) { case GX_TF_RGBA8: - if (isMipMap) { - return &__GXData->TexRegions2[id]; - } + // if (isMipMap) { + // return &__GXData->TexRegions2[id]; + // } return &__GXData->TexRegions1[id]; case GX_TF_C4: @@ -63,68 +63,15 @@ u16* __cpReg; /* ############################################################################################## */ u32* __piReg; -BOOL __GXShutdown(BOOL final) { - u32 val; - u32 newPeCount; - OSTime newTime; - - if (!final) { - if (!calledOnce) { - peCount = GXReadMEMReg(0x28, 0x27); - time = OSGetTime(); - calledOnce = 1; - return FALSE; - } - - newTime = OSGetTime(); - newPeCount = GXReadMEMReg(0x28, 0x27); - - if (newTime - time < 10) { - return FALSE; - } - - if (newPeCount != peCount) { - peCount = newPeCount; - time = newTime; - return FALSE; - } - - } else { - GXSetBreakPtCallback(NULL); - GXSetDrawSyncCallback(NULL); - GXSetDrawDoneCallback(NULL); - - GX_WRITE_U32(0); - GX_WRITE_U32(0); - GX_WRITE_U32(0); - GX_WRITE_U32(0); - GX_WRITE_U32(0); - GX_WRITE_U32(0); - GX_WRITE_U32(0); - GX_WRITE_U32(0); - - PPCSync(); - - GX_SET_CP_REG(1, 0); - GX_SET_CP_REG(2, 3); - - __GXData->abtWaitPECopy = GX_TRUE; - - __GXAbort(); - } - - return TRUE; -} - -void __GXInitRevisionBits(void) { +inline void __GXInitRevisionBits(void) { u32 i; for (i = 0; i < 8; i++) { FAST_FLAG_SET(__GXData->vatA[i], 1, 30, 33); FAST_FLAG_SET(__GXData->vatB[i], 1, 31, 33); - GX_WRITE_U8(0x8); - GX_WRITE_U8(i | 0x80); - GX_WRITE_U32(__GXData->vatB[i]); + GXFIFO.u8 = 0x8; + GXFIFO.u8 = i | 0x80; + GXFIFO.u32 = __GXData->vatB[i]; } { @@ -137,14 +84,14 @@ void __GXInitRevisionBits(void) { FAST_FLAG_SET(reg1, 1, 3, 1); FAST_FLAG_SET(reg1, 1, 4, 1); FAST_FLAG_SET(reg1, 1, 5, 1); - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1000); - GX_WRITE_U32(reg1); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1000; + GXFIFO.u32 = reg1; FAST_FLAG_SET(reg2, 1, 0, 1); - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1012); - GX_WRITE_U32(reg2); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1012; + GXFIFO.u32 = reg2; } { @@ -154,8 +101,7 @@ void __GXInitRevisionBits(void) { FAST_FLAG_SET(reg, 1, 2, 1); FAST_FLAG_SET(reg, 1, 3, 1); FAST_FLAG_SET(reg, 0x58, 24, 8); - GX_WRITE_U8(0x61); - GX_WRITE_U32(reg); + GFWriteBPCmd(reg); } } @@ -190,8 +136,6 @@ static u32 GXTexRegionAddrTable[] = { 0x80000, 0x10000, 0xA0000, 0x30000, 0x80000, 0x50000, 0xA0000, 0x70000, }; -static OSResetFunctionInfo GXResetFuncInfo = {__GXShutdown, OS_RESET_PRIO_GX}; - static void EnableWriteGatherPipe() { u32 hid2; // r31 hid2 = PPCMfhid2(); @@ -207,7 +151,6 @@ GXFifoObj* GXInit(void* base, u32 size) { OSRegisterVersion(__GXVersion); __GXData->inDispList = GX_FALSE; __GXData->dlSaveContext = GX_TRUE; - __GXData->abtWaitPECopy = GX_TRUE; __GXData->tcsManEnab = 0; __GXData->tevTcEnab = 0; @@ -226,7 +169,7 @@ GXFifoObj* GXInit(void* base, u32 size) { GXSetGPFifo(&FifoObj); if (!resetFuncRegistered) { - OSRegisterResetFunction(&GXResetFuncInfo); + // OSRegisterResetFunction(&GXResetFuncInfo); resetFuncRegistered = 1; } @@ -292,14 +235,12 @@ GXFifoObj* GXInit(void* base, u32 size) { val1 = (val2 / 2048) | 0x69000400; - GX_WRITE_U8(0x61); - GX_WRITE_U32(val1); + GFWriteBPCmd(val1); __GXFlushTextureState(); val1 = (val2 / 4224) | 0x46000200; - GX_WRITE_U8(0x61); - GX_WRITE_U32(val1); + GFWriteBPCmd(val1); } __GXInitRevisionBits(); @@ -309,8 +250,8 @@ GXFifoObj* GXInit(void* base, u32 size) { GX_TEXCACHE_32K, GXTexRegionAddrTable[i + 8], GX_TEXCACHE_32K); GXInitTexCacheRegion(&__GXData->TexRegions1[i], GX_FALSE, GXTexRegionAddrTable[i + 16], GX_TEXCACHE_32K, GXTexRegionAddrTable[i + 24], GX_TEXCACHE_32K); - GXInitTexCacheRegion(&__GXData->TexRegions2[i], GX_TRUE, GXTexRegionAddrTable[i + 32], - GX_TEXCACHE_32K, GXTexRegionAddrTable[i + 40], GX_TEXCACHE_32K); + // GXInitTexCacheRegion(&__GXData->TexRegions2[i], GX_TRUE, GXTexRegionAddrTable[i + 32], + // GX_TEXCACHE_32K, GXTexRegionAddrTable[i + 40], GX_TEXCACHE_32K); } for (i = 0; i < GX_MAX_TLUT; i++) { @@ -325,22 +266,19 @@ GXFifoObj* GXInit(void* base, u32 size) { FAST_FLAG_SET(__GXData->perfSel, 0, 4, 4); - GX_WRITE_U8(0x8); - GX_WRITE_U8(0x20); - GX_WRITE_U32(__GXData->perfSel); + GXFIFO.u8 = 0x8; + GXFIFO.u8 = 0x20; + GXFIFO.u32 = __GXData->perfSel; - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0; - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x23000000); + GFWriteBPCmd(0x23000000); - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x24000000); + GFWriteBPCmd(0x24000000); - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x67000000); + GFWriteBPCmd(0x67000000); __GXSetIndirectMask(0); __GXSetTmemConfig(2); diff --git a/src/dolphin/gx/GXMisc.c b/src/dolphin/gx/GXMisc.c index 468192ea..b0a144e5 100644 --- a/src/dolphin/gx/GXMisc.c +++ b/src/dolphin/gx/GXMisc.c @@ -25,10 +25,6 @@ void GXSetMisc(GXMiscToken token, u32 val) { case GX_MT_DL_SAVE_CONTEXT: __GXData->dlSaveContext = (val != 0); break; - - case GX_MT_ABORT_WAIT_COPYOUT: - __GXData->abtWaitPECopy = (val != 0); - break; } } @@ -58,23 +54,7 @@ static void __GXAbortWait(u32 clocks) { } while (time1 - time0 <= clocks / 4); } -static void __GXAbortWaitPECopyDone(void) { - u32 peCnt0, peCnt1; - - peCnt0 = GXReadMEMReg(0x28, 0x27); - do { - peCnt1 = peCnt0; - __GXAbortWait(32); - - peCnt0 = GXReadMEMReg(0x28, 0x27); - } while (peCnt0 != peCnt1); -} - void __GXAbort(void) { - if (__GXData->abtWaitPECopy && GXGetGPFifo()) { - __GXAbortWaitPECopyDone(); - } - __PIRegs[0x18 / 4] = 1; __GXAbortWait(200); __PIRegs[0x18 / 4] = 0; @@ -83,12 +63,7 @@ void __GXAbort(void) { void GXAbortFrame(void) { __GXAbort(); - if (GXGetGPFifo()) { - __GXCleanGPFifo(); - __GXInitRevisionBits(); - __GXData->dirtyState = 0; - GXFlush(); - } + __GXCleanGPFifo(); } /* ############################################################################################## */ diff --git a/src/dolphin/gx/GXPerf.c b/src/dolphin/gx/GXPerf.c index 60591b0b..b8099a94 100644 --- a/src/dolphin/gx/GXPerf.c +++ b/src/dolphin/gx/GXPerf.c @@ -15,9 +15,9 @@ void GXSetGPMetric(GXPerf0 perf0, GXPerf1 perf1) { case GX_PERF0_XF_REGRD_CLKS: case GX_PERF0_CLIP_RATIO: case GX_PERF0_CLOCKS: - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0; break; case GX_PERF0_TRIANGLES: @@ -36,8 +36,7 @@ void GXSetGPMetric(GXPerf0 perf0, GXPerf1 perf1) { case GX_PERF0_TRIANGLES_0CLR: case GX_PERF0_TRIANGLES_1CLR: case GX_PERF0_TRIANGLES_2CLR: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x23000000); + GFWriteBPCmd(0x23000000); break; case GX_PERF0_QUAD_0CVG: @@ -47,8 +46,7 @@ void GXSetGPMetric(GXPerf0 perf0, GXPerf1 perf1) { case GX_PERF0_QUAD_3CVG: case GX_PERF0_QUAD_4CVG: case GX_PERF0_AVG_QUAD_CNT: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x24000000); + GFWriteBPCmd(0x24000000); break; case GX_PERF0_NONE: @@ -66,8 +64,7 @@ void GXSetGPMetric(GXPerf0 perf0, GXPerf1 perf1) { case GX_PERF1_TC_CHECK7_8: case GX_PERF1_TC_MISS: case GX_PERF1_CLOCKS: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x67000000); + GFWriteBPCmd(0x67000000); break; case GX_PERF1_VC_ELEMQ_FULL: @@ -79,9 +76,9 @@ void GXSetGPMetric(GXPerf0 perf0, GXPerf1 perf1) { case GX_PERF1_VC_ALL_STALLS: case GX_PERF1_VERTICES: FAST_FLAG_SET(__GXData->perfSel, 0, 4, 4); - GX_WRITE_U8(8); - GX_WRITE_U8(32); - GX_WRITE_U32(__GXData->perfSel); + GXFIFO.u8 = 8; + GXFIFO.u8 = 32; + GXFIFO.u32 = __GXData->perfSel; break; case GX_PERF1_FIFO_REQ: @@ -99,158 +96,135 @@ void GXSetGPMetric(GXPerf0 perf0, GXPerf1 perf1) { switch (__GXData->perf0) { case GX_PERF0_VERTICES: - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0x273); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0x273; break; case GX_PERF0_CLIP_VTX: - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0x14A); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0x14A; break; case GX_PERF0_CLIP_CLKS: - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0x16B); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0x16B; break; case GX_PERF0_XF_WAIT_IN: - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0x84); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0x84; break; case GX_PERF0_XF_WAIT_OUT: - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0xC6); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0xC6; break; case GX_PERF0_XF_XFRM_CLKS: - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0x210); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0x210; break; case GX_PERF0_XF_LIT_CLKS: - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0x252); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0x252; break; case GX_PERF0_XF_BOT_CLKS: - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0x231); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0x231; break; case GX_PERF0_XF_REGLD_CLKS: - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0x1AD); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0x1AD; break; case GX_PERF0_XF_REGRD_CLKS: - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0x1CE); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0x1CE; break; case GX_PERF0_CLOCKS: - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0x21); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0x21; break; case GX_PERF0_CLIP_RATIO: - GX_WRITE_U8(0x10); - GX_WRITE_U32(0x1006); - GX_WRITE_U32(0x153); + GXFIFO.u8 = 0x10; + GXFIFO.u32 = 0x1006; + GXFIFO.u32 = 0x153; break; case GX_PERF0_TRIANGLES: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2300AE7F); + GFWriteBPCmd(0x2300AE7F); break; case GX_PERF0_TRIANGLES_CULLED: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x23008E7F); + GFWriteBPCmd(0x23008E7F); break; case GX_PERF0_TRIANGLES_PASSED: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x23009E7F); + GFWriteBPCmd(0x23009E7F); break; case GX_PERF0_TRIANGLES_SCISSORED: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x23001E7F); + GFWriteBPCmd(0x23001E7F); break; case GX_PERF0_TRIANGLES_0TEX: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2300AC3F); + GFWriteBPCmd(0x2300AC3F); break; case GX_PERF0_TRIANGLES_1TEX: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2300AC7F); + GFWriteBPCmd(0x2300AC7F); break; case GX_PERF0_TRIANGLES_2TEX: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2300ACBF); + GFWriteBPCmd(0x2300ACBF); break; case GX_PERF0_TRIANGLES_3TEX: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2300ACFF); + GFWriteBPCmd(0x2300ACFF); break; case GX_PERF0_TRIANGLES_4TEX: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2300AD3F); + GFWriteBPCmd(0x2300AD3F); break; case GX_PERF0_TRIANGLES_5TEX: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2300AD7F); + GFWriteBPCmd(0x2300AD7F); break; case GX_PERF0_TRIANGLES_6TEX: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2300ADBF); + GFWriteBPCmd(0x2300ADBF); break; case GX_PERF0_TRIANGLES_7TEX: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2300ADFF); + GFWriteBPCmd(0x2300ADFF); break; case GX_PERF0_TRIANGLES_8TEX: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2300AE3F); + GFWriteBPCmd(0x2300AE3F); break; case GX_PERF0_TRIANGLES_0CLR: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2300A27F); + GFWriteBPCmd(0x2300A27F); break; case GX_PERF0_TRIANGLES_1CLR: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2300A67F); + GFWriteBPCmd(0x2300A67F); break; case GX_PERF0_TRIANGLES_2CLR: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2300AA7F); + GFWriteBPCmd(0x2300AA7F); break; case GX_PERF0_QUAD_0CVG: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2402C0C6); + GFWriteBPCmd(0x2402C0C6); break; case GX_PERF0_QUAD_NON0CVG: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2402C16B); + GFWriteBPCmd(0x2402C16B); break; case GX_PERF0_QUAD_1CVG: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2402C0E7); + GFWriteBPCmd(0x2402C0E7); break; case GX_PERF0_QUAD_2CVG: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2402C108); + GFWriteBPCmd(0x2402C108); break; case GX_PERF0_QUAD_3CVG: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2402C129); + GFWriteBPCmd(0x2402C129); break; case GX_PERF0_QUAD_4CVG: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2402C14A); + GFWriteBPCmd(0x2402C14A); break; case GX_PERF0_AVG_QUAD_CNT: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x2402C1AD); + GFWriteBPCmd(0x2402C1AD); break; case GX_PERF0_NONE: @@ -261,93 +235,83 @@ void GXSetGPMetric(GXPerf0 perf0, GXPerf1 perf1) { switch (__GXData->perf1) { case GX_PERF1_TEXELS: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x67000042); + GFWriteBPCmd(0x67000042); break; case GX_PERF1_TX_IDLE: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x67000084); + GFWriteBPCmd(0x67000084); break; case GX_PERF1_TX_REGS: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x67000063); + GFWriteBPCmd(0x67000063); break; case GX_PERF1_TX_MEMSTALL: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x67000129); + GFWriteBPCmd(0x67000129); break; case GX_PERF1_TC_MISS: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x67000252); + GFWriteBPCmd(0x67000252); break; case GX_PERF1_CLOCKS: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x67000021); + GFWriteBPCmd(0x67000021); break; case GX_PERF1_TC_CHECK1_2: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x6700014B); + GFWriteBPCmd(0x6700014B); break; case GX_PERF1_TC_CHECK3_4: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x6700018D); + GFWriteBPCmd(0x6700018D); break; case GX_PERF1_TC_CHECK5_6: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x670001CF); + GFWriteBPCmd(0x670001CF); break; case GX_PERF1_TC_CHECK7_8: - GX_WRITE_U8(0x61); - GX_WRITE_U32(0x67000211); + GFWriteBPCmd(0x67000211); break; case GX_PERF1_VC_ELEMQ_FULL: FAST_FLAG_SET(__GXData->perfSel, 2, 4, 4); - GX_WRITE_U8(8); - GX_WRITE_U8(32); - GX_WRITE_U32(__GXData->perfSel); + GXFIFO.u8 = 8; + GXFIFO.u8 = 32; + GXFIFO.u32 = __GXData->perfSel; break; case GX_PERF1_VC_MISSQ_FULL: FAST_FLAG_SET(__GXData->perfSel, 3, 4, 4); - GX_WRITE_U8(8); - GX_WRITE_U8(32); - GX_WRITE_U32(__GXData->perfSel); + GXFIFO.u8 = 8; + GXFIFO.u8 = 32; + GXFIFO.u32 = __GXData->perfSel; break; case GX_PERF1_VC_MEMREQ_FULL: FAST_FLAG_SET(__GXData->perfSel, 4, 4, 4); - GX_WRITE_U8(8); - GX_WRITE_U8(32); - GX_WRITE_U32(__GXData->perfSel); + GXFIFO.u8 = 8; + GXFIFO.u8 = 32; + GXFIFO.u32 = __GXData->perfSel; break; case GX_PERF1_VC_STATUS7: FAST_FLAG_SET(__GXData->perfSel, 5, 4, 4); - GX_WRITE_U8(8); - GX_WRITE_U8(32); - GX_WRITE_U32(__GXData->perfSel); + GXFIFO.u8 = 8; + GXFIFO.u8 = 32; + GXFIFO.u32 = __GXData->perfSel; break; case GX_PERF1_VC_MISSREP_FULL: FAST_FLAG_SET(__GXData->perfSel, 6, 4, 4); - GX_WRITE_U8(8); - GX_WRITE_U8(32); - GX_WRITE_U32(__GXData->perfSel); + GXFIFO.u8 = 8; + GXFIFO.u8 = 32; + GXFIFO.u32 = __GXData->perfSel; break; case GX_PERF1_VC_STREAMBUF_LOW: FAST_FLAG_SET(__GXData->perfSel, 7, 4, 4); - GX_WRITE_U8(8); - GX_WRITE_U8(32); - GX_WRITE_U32(__GXData->perfSel); + GXFIFO.u8 = 8; + GXFIFO.u8 = 32; + GXFIFO.u32 = __GXData->perfSel; break; case GX_PERF1_VC_ALL_STALLS: FAST_FLAG_SET(__GXData->perfSel, 9, 4, 4); - GX_WRITE_U8(8); - GX_WRITE_U8(32); - GX_WRITE_U32(__GXData->perfSel); + GXFIFO.u8 = 8; + GXFIFO.u8 = 32; + GXFIFO.u32 = __GXData->perfSel; break; case GX_PERF1_VERTICES: FAST_FLAG_SET(__GXData->perfSel, 8, 4, 4); - GX_WRITE_U8(8); - GX_WRITE_U8(32); - GX_WRITE_U32(__GXData->perfSel); + GXFIFO.u8 = 8; + GXFIFO.u8 = 32; + GXFIFO.u32 = __GXData->perfSel; break; case GX_PERF1_FIFO_REQ: diff --git a/src/dolphin/gx/GXTev.c b/src/dolphin/gx/GXTev.c index 21c8f51c..3cecde99 100644 --- a/src/dolphin/gx/GXTev.c +++ b/src/dolphin/gx/GXTev.c @@ -50,16 +50,14 @@ void GXSetTevOp(GXTevStageID stage, GXTevMode mode) { tevReg = __GXData->tevc[stage]; tevReg = (*color & ~0xFF000000) | (tevReg & 0xFF000000); - GX_WRITE_U8(0x61); - GX_WRITE_U32(tevReg); + GFWriteBPCmd(tevReg); __GXData->tevc[stage] = tevReg; tevReg = __GXData->teva[stage]; tevReg = (*alpha & ~0xFF00000F) | (tevReg & 0xFF00000F); - GX_WRITE_U8(0x61); - GX_WRITE_U32(tevReg); + GFWriteBPCmd(tevReg); __GXData->teva[stage] = tevReg; @@ -77,8 +75,7 @@ void GXSetTevColorIn(GXTevStageID stage, GXTevColorArg a, GXTevColorArg b, GXTev FAST_FLAG_SET(tevReg, c, 4, 4); FAST_FLAG_SET(tevReg, d, 0, 4); - GX_WRITE_U8(0x61); - GX_WRITE_U32(tevReg); + GFWriteBPCmd(tevReg); __GXData->tevc[stage] = tevReg; __GXData->bpSentNot = GX_FALSE; @@ -95,8 +92,7 @@ void GXSetTevAlphaIn(GXTevStageID stage, GXTevAlphaArg a, GXTevAlphaArg b, GXTev FAST_FLAG_SET(tevReg, c, 7, 3); FAST_FLAG_SET(tevReg, d, 4, 3); - GX_WRITE_U8(0x61); - GX_WRITE_U32(tevReg); + GFWriteBPCmd(tevReg); __GXData->teva[stage] = tevReg; __GXData->bpSentNot = GX_FALSE; @@ -120,8 +116,7 @@ void GXSetTevColorOp(GXTevStageID stage, GXTevOp op, GXTevBias bias, GXTevScale FAST_FLAG_SET(tevReg, doClamp, 19, 1); FAST_FLAG_SET(tevReg, outReg, 22, 2); - GX_WRITE_U8(0x61); - GX_WRITE_U32(tevReg); + GFWriteBPCmd(tevReg); __GXData->tevc[stage] = tevReg; __GXData->bpSentNot = GX_FALSE; } @@ -144,8 +139,7 @@ void GXSetTevAlphaOp(GXTevStageID stage, GXTevOp op, GXTevBias bias, GXTevScale FAST_FLAG_SET(tevReg, doClamp, 19, 1); FAST_FLAG_SET(tevReg, outReg, 22, 2); - GX_WRITE_U8(0x61); - GX_WRITE_U32(tevReg); + GFWriteBPCmd(tevReg); __GXData->teva[stage] = tevReg; __GXData->bpSentNot = GX_FALSE; } diff --git a/src/dolphin/gx/GXTexture.c b/src/dolphin/gx/GXTexture.c index e4b8485d..c1b11189 100644 --- a/src/dolphin/gx/GXTexture.c +++ b/src/dolphin/gx/GXTexture.c @@ -129,7 +129,7 @@ void GXInitTexObj(GXTexObj* obj, void* imagePtr, u16 width, u16 height, GXTexFmt maxDimSize = width > height ? 31 - __cntlzw(width) : 31 - __cntlzw(height); - GX_SET_REG(internal->texture_lod, (maxDimSize) * 16.f, 16, 23); + GX_SET_REG(internal->texture_lod, (u8)((maxDimSize) * 16.f), 16, 23); } else { GX_SET_REG(internal->texture_filter, 4, 24, 26); } @@ -223,7 +223,7 @@ void GXInitTexObjLOD(GXTexObj* obj, GXTexFilter minFilter, GXTexFilter maxFilter lodBias = 3.99f; } - GX_SET_REG(internal->texture_filter, lodBias * 32.0f, 15, 22); + GX_SET_REG(internal->texture_filter, (u8)(lodBias * 32.0f), 15, 22); GX_SET_REG(internal->texture_filter, maxFilter == 1 ? 1 : 0, 27, 27); GX_SET_REG(internal->texture_filter, GX2HWFiltConv[minFilter], 24, 26); GX_SET_REG(internal->texture_filter, doEdgeLOD ? 0 : 1, 23, 23); @@ -270,10 +270,6 @@ GXTexWrapMode GXGetTexObjWrapT(GXTexObj* obj) { return (obj->texture_filter & 0xc) >> 2; } -GXBool GXGetTexObjMipMap(const GXTexObj* obj) { - return (obj->texture_flags & 1) == 1; -} - u32 GXGetTexObjTlut(GXTexObj* obj) { return obj->tlut_name; } @@ -511,31 +507,6 @@ void __GXSetSUTexRegs(void) { void __GXSetTmemConfig(u32 config) { switch (config) { - case 2: - GX_BP_LOAD_REG(0x8c0d8000); - GX_BP_LOAD_REG(0x900dc000); - - GX_BP_LOAD_REG(0x8d0d8800); - GX_BP_LOAD_REG(0x910dc800); - - GX_BP_LOAD_REG(0x8e0d9000); - GX_BP_LOAD_REG(0x920dd000); - - GX_BP_LOAD_REG(0x8f0d9800); - GX_BP_LOAD_REG(0x930dd800); - - GX_BP_LOAD_REG(0xac0da000); - GX_BP_LOAD_REG(0xb00dc400); - - GX_BP_LOAD_REG(0xad0da800); - GX_BP_LOAD_REG(0xb10dcc00); - - GX_BP_LOAD_REG(0xae0db000); - GX_BP_LOAD_REG(0xb20dd400); - - GX_BP_LOAD_REG(0xaf0db800); - GX_BP_LOAD_REG(0xb30ddc00); - break; case 1: GX_BP_LOAD_REG(0x8c0d8000); GX_BP_LOAD_REG(0x900dc000); diff --git a/src/dolphin/gx/GXTransform.c b/src/dolphin/gx/GXTransform.c index 1bf66bbb..89037974 100644 --- a/src/dolphin/gx/GXTransform.c +++ b/src/dolphin/gx/GXTransform.c @@ -71,7 +71,7 @@ void GXProject(f32 model_x, f32 model_y, f32 model_z, Mtx model_mtx, f32* proj_m void __GXSetProjection(void) { GX_XF_LOAD_REGS(6, GX_XF_REG_PROJECTIONA); WriteProjPS(__GXData->projMtx, (volatile void*)GXFIFO_ADDR); - GX_WRITE_U32(__GXData->projType); + GXFIFO.u32 = __GXData->projType; } void GXSetProjection(const Mtx44 proj, GXProjectionType type) { @@ -225,12 +225,12 @@ void __GXSetViewport(void) { f = far + __GXData->zOffset; GX_XF_LOAD_REGS(5, GX_XF_REG_SCALEX); - GX_WRITE_F32(a); - GX_WRITE_F32(b); - GX_WRITE_F32(c); - GX_WRITE_F32(d); - GX_WRITE_F32(e); - GX_WRITE_F32(f); + GXFIFO.f32 = a; + GXFIFO.f32 = b; + GXFIFO.f32 = c; + GXFIFO.f32 = d; + GXFIFO.f32 = e; + GXFIFO.f32 = f; } void GXSetViewport(f32 left, f32 top, f32 width, f32 height, f32 nearZ, f32 farZ) {