From e6cb6f55cbb0130bfac86dd168f963b06d76b773 Mon Sep 17 00:00:00 2001 From: neobrain Date: Sun, 12 May 2013 15:31:02 +0200 Subject: [PATCH] More manual register poking. No idea if it still works. --- source/main.cpp | 49 +++++++++++++++++++++------ source/mygx.h | 90 ------------------------------------------------- 2 files changed, 38 insertions(+), 101 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 7b28aa0..3e43941 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -210,19 +210,41 @@ int main() } // Simple testing code - MY_SetViewport(0,0,rmode->fbWidth,rmode->efbHeight,0,1); + // GX_SetViewport + wgPipe->U8 = 0x10; + wgPipe->U32 = (u32)((5<<16)|0x101a); + wgPipe->F32 = rmode->fbWidth * 0.5; + wgPipe->F32 = (-rmode->efbHeight) * 0.5; + wgPipe->F32 = 1*16777215.0; + wgPipe->F32 = rmode->fbWidth * 0.5 + 342.0; + wgPipe->F32 = rmode->efbHeight * 0.5 + 342.0; + wgPipe->F32 = 1*16777215.0; - wgPipe->U8 = 0x48; // InvVtxCache + // InvVtxCache + wgPipe->U8 = 0x48; guMtxIdentity(model); guMtxTransApply(model, model, -1.5f,0.0f,-6.0f); guMtxConcat(view,model,modelview); - MY_LoadPosMtxImm(modelview, GX_PNMTX0); + wgPipe->U8 = 0x10; + wgPipe->U32 = (u32)((11<<16)|(_SHIFTL(GX_PNMTX0,2,8))); + for (unsigned int i = 0;i < 12; ++i) + { + wgPipe->F32 = ((f32*)modelview)[i]; + } // Setup vtx desc - MY_LOAD_CP_REG(0x50, (_SHIFTL(GX_DIRECT,9,2))); - MY_LOAD_CP_REG(0x60, 0); - MY_LOAD_XF_REG(0x1008, 0); + wgPipe->U8 = 0x08; + wgPipe->U8 = 0x50; + wgPipe->U32 = _SHIFTL(GX_DIRECT,9,2); + + wgPipe->U8 = 0x08; + wgPipe->U8 = 0x60; + wgPipe->U32 = 0; + + wgPipe->U8 = 0x10; + wgPipe->U32 = 0x1008; + wgPipe->U32 = 0; // Draw a triangle wgPipe->U8 = GX_TRIANGLES|(GX_VTXFMT0&7); @@ -233,15 +255,20 @@ int main() guMtxTransApply(model, model, 3.0f,0.0f,0.0f); guMtxConcat(view,model,modelview); - MY_LoadPosMtxImm(modelview, GX_PNMTX0); + wgPipe->U8 = 0x10; + wgPipe->U32 = (u32)((11<<16)|(_SHIFTL(GX_PNMTX0,2,8))); + for (unsigned int i = 0;i < 12; ++i) + { + wgPipe->F32 = ((f32*)modelview)[i]; + } // Draw a quad wgPipe->U8 = GX_QUADS|(GX_VTXFMT0&7); wgPipe->U16 = 4; - GX_Position3f32(-1.0f, 1.0f, 0.0f); // Top left - GX_Position3f32( 1.0f, 1.0f, 0.0f); // Top right - GX_Position3f32( 1.0f,-1.0f, 0.0f); // Bottom right - GX_Position3f32(-1.0f,-1.0f, 0.0f); // Bottom left + wgPipe->F32 = -1.0f; wgPipe->F32 = 1.0f; wgPipe->F32 = 0.0f; // Top left + wgPipe->F32 = 1.0f; wgPipe->F32 = 1.0f; wgPipe->F32 = 0.0f; // Top right + wgPipe->F32 = 1.0f; wgPipe->F32 = -1.0f; wgPipe->F32 = 0.0f; // Bottom right + wgPipe->F32 = -1.0f; wgPipe->F32 = -1.0f; wgPipe->F32 = 0.0f; // Bottom left // finish frame... GX_DrawDone(); diff --git a/source/mygx.h b/source/mygx.h index 85a300e..03cb8f5 100644 --- a/source/mygx.h +++ b/source/mygx.h @@ -1,93 +1,3 @@ #define _SHIFTL(v, s, w) \ ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s))) -#define MY_LOAD_CP_REG(x, y) \ - do { \ - wgPipe->U8 = 0x08; \ - wgPipe->U8 = (u8)(x); \ - wgPipe->U32 = (u32)(y); \ - } while(0) - -#define MY_LOAD_XF_REG(x, y) \ - do { \ - wgPipe->U8 = 0x10; \ - wgPipe->U32 = (u32)((x)&0xffff); \ - wgPipe->U32 = (u32)(y); \ - } while(0) - -#define MY_LOAD_XF_REGS(x, n) \ - do { \ - wgPipe->U8 = 0x10; \ - wgPipe->U32 = (u32)(((((n)&0xffff)-1)<<16)|((x)&0xffff)); \ - } while(0) - -static inline void MyWriteMtxPS4x2(register Mtx mt,register void *wgpipe) -{ - register f32 tmp0,tmp1,tmp2,tmp3; - __asm__ __volatile__ - ("psq_l %0,0(%4),0,0\n\ - psq_l %1,8(%4),0,0\n\ - psq_l %2,16(%4),0,0\n\ - psq_l %3,24(%4),0,0\n\ - psq_st %0,0(%5),0,0\n\ - psq_st %1,0(%5),0,0\n\ - psq_st %2,0(%5),0,0\n\ - psq_st %3,0(%5),0,0" - : "=&f"(tmp0),"=&f"(tmp1),"=&f"(tmp2),"=&f"(tmp3) - : "b"(mt), "b"(wgpipe) - : "memory" - ); -} - -static inline void MyWriteMtxPS4x3(register Mtx mt,register void *wgpipe) -{ - register f32 tmp0,tmp1,tmp2,tmp3,tmp4,tmp5; - __asm__ __volatile__ ( - "psq_l %0,0(%6),0,0\n\ - psq_l %1,8(%6),0,0\n\ - psq_l %2,16(%6),0,0\n\ - psq_l %3,24(%6),0,0\n\ - psq_l %4,32(%6),0,0\n\ - psq_l %5,40(%6),0,0\n\ - psq_st %0,0(%7),0,0\n\ - psq_st %1,0(%7),0,0\n\ - psq_st %2,0(%7),0,0\n\ - psq_st %3,0(%7),0,0\n\ - psq_st %4,0(%7),0,0\n\ - psq_st %5,0(%7),0,0" - : "=&f"(tmp0),"=&f"(tmp1),"=&f"(tmp2),"=&f"(tmp3),"=&f"(tmp4),"=&f"(tmp5) - : "b"(mt), "b"(wgpipe) - : "memory" - ); -} - -void MY_LoadPosMtxImm(Mtx mt,u32 pnidx) -{ - MY_LOAD_XF_REGS((0x0000|(_SHIFTL(pnidx,2,8))),12); - MyWriteMtxPS4x3(mt,(void*)wgPipe); -} - -void MY_SetViewport(f32 xOrig,f32 yOrig,f32 wd,f32 ht,f32 nearZ,f32 farZ) -{ - f32 x0,y0,x1,y1,n,f,z; - static f32 Xfactor = 0.5; - static f32 Yfactor = 342.0; - static f32 Zfactor = 16777215.0; - - x0 = wd*Xfactor; - y0 = (-ht)*Xfactor; - x1 = (xOrig+(wd*Xfactor))+Yfactor; - y1 = (yOrig+(ht*Xfactor))+Yfactor; - n = Zfactor*nearZ; - f = Zfactor*farZ; - z = f-n; - - MY_LOAD_XF_REGS(0x101a,6); - wgPipe->F32 = x0; - wgPipe->F32 = y0; - wgPipe->F32 = z; - wgPipe->F32 = x1; - wgPipe->F32 = y1; - wgPipe->F32 = f; -} -