From 4ee18c0a3c0236c134886a64a66e05737f782658 Mon Sep 17 00:00:00 2001 From: damdoum Date: Fri, 16 Feb 2007 17:08:15 +0000 Subject: [PATCH] defines of 3D commands --- desmume/src/MMU.c | 62 ++++++++++++++++++++++------------------- desmume/src/gl_vertex.c | 33 ++++++++++++++-------- desmume/src/gl_vertex.h | 2 +- desmume/src/registers.h | 39 ++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 40 deletions(-) diff --git a/desmume/src/MMU.c b/desmume/src/MMU.c index e4d7c75ac..c4f390170 100644 --- a/desmume/src/MMU.c +++ b/desmume/src/MMU.c @@ -306,7 +306,7 @@ void MMU_clearMem() /* the VRAM blocks keep their content even when not blended in */ /* to ensure that we write the content back to the LCD ram */ /* FIXME: VRAM Bank E,F,G,H,I missing */ -void MMU_VRAMWriteBackToLCD(u8 block) +void MMU_VRAMWriteBackToLCD(u32 block) { u8 *destination; u8 *source; @@ -315,6 +315,7 @@ void MMU_VRAMWriteBackToLCD(u8 block) #if 1 return ; #endif + block = (u8)block; destination = 0 ; source = 0; VRAMBankCnt = MMU_read8(ARMCPU_ARM9,REG_VRAMCNTA+block) ; @@ -3626,103 +3627,108 @@ INLINE void MMU_write32_REG_3D(u32 adr, u32 val) { case 0x04000400 : OGLRender::glCallList(val); return; - case 0x04000440 : + case cmd_3D_MTX_MODE : OGLRender::glMatrixMode(val); return; - case 0x04000444 : + case cmd_3D_MTX_PUSH : OGLRender::glPushMatrix(); return; - case 0x04000448 : + case cmd_3D_MTX_POP : OGLRender::glPopMatrix(val); return; - case 0x0400044C : + case cmd_3D_MTX_STORE : OGLRender::glStoreMatrix(val); return; - case 0x04000450 : + case cmd_3D_MTX_RESTORE : OGLRender::glRestore(); return; - case 0x04000454 : + case cmd_3D_MTX_IDENTITY : OGLRender::glLoadIdentity(); return; - case 0x04000458 : + case cmd_3D_MTX_LOAD_4x4 : OGLRender::ML4x4ajouter(val); return; - case 0x0400045C : + case cmd_3D_MTX_LOAD_4x3 : OGLRender::ML4x3ajouter(val); return; - case 0x04000460 : + case cmd_3D_MTX_MULT_4x4 : OGLRender::glMultMatrix4x4(val); return; - case 0x04000464 : + case cmd_3D_MTX_MULT_4x3 : OGLRender::glMultMatrix4x3(val); return; - case 0x04000468 : + case cmd_3D_MTX_MULT_3x3 : OGLRender::glMultMatrix3x3(val); return; - case 0x0400046C : + case cmd_3D_MTX_SCALE : OGLRender::glScale(val); return; - case 0x04000470 : + case cmd_3D_MTX_TRANS : OGLRender::addTrans(val); return; - case 0x04000480 : + case cmd_3D_COLOR : OGLRender::glColor3b(val); return; - case 0x04000488 : + case cmd_3D_NORMA : OGLRender::glTexCoord(val); //execute = FALSE; return; #endif - case 0x0400048C : + case cmd_3D_VTX_16 : //OGLRender::glVertex3(val); + gl_VTX_16(val); return; - case 0x04000490 : + case cmd_3D_VTX_10 : //GPULOG("VERTEX 10 %d\r\n",val); gl_VTX_10(val); return; - case 0x04000494 : + case cmd_3D_VTX_XY : //GPULOG(printf(txt, "VERTEXY %d\r\n",val); gl_VTX_XY(val); return; - case 0x04000498 : + case cmd_3D_VTX_XZ : //GPULOG("VERTEXZ %d\r\n",val); gl_VTX_XZ(val); return; - case 0x0400049C : + case cmd_3D_VTX_YZ : //GPULOG("VERTEYZ %d\r\n",val); gl_VTX_YZ(val); return; - case 0x040004A0 : + case cmd_3D_VTX_DIFF : gl_VTX_DIFF(val); return; #ifdef RENDER3D - case 0x040004A8 : + case cmd_3D_TEXIMAGE_PARAM : OGLRender::glTexImage2D(val, FALSE); //execute = FALSE; testval = val; return; - case 0x040004AC : + case cmd_3D_PLTT_BASE : OGLRender::glTexImage2D(testval, TRUE); //execute = FALSE; return; #endif - case 0x04000500 : + case cmd_3D_BEGIN_VTXS : // OGLRender::glBegin(val); gl_VTX_begin(val); return; - case 0x04000504 : + case cmd_3D_END_VTXS : // OGLRender::glEnd(); gl_VTX_end(); return; #ifdef RENDER3D - case 0x04000540 : + case cmd_3D_SWAP_BUFFERS : OGLRender::glFlush(); return; - case 0x04000580 : + case cmd_3D_VIEWPORT : OGLRender::glViewPort(val); return; #endif } +/* + if (adr > 0x4000300 && adr < 0x4000700) + printf("command %08x\n", adr); +*/ } diff --git a/desmume/src/gl_vertex.c b/desmume/src/gl_vertex.c index 3d8f14bb4..6fc2e9bc4 100755 --- a/desmume/src/gl_vertex.c +++ b/desmume/src/gl_vertex.c @@ -25,8 +25,8 @@ static u16 vx=0,vy=0,vz=0; -//#define print(a) printf a -#define print(a) +#define print(a) printf a +//#define print(a) INLINE void gl_VTX_one() { float vfx,vfy,vfz; @@ -62,17 +62,28 @@ void gl_VTX_end() { print(("VTX_end.\n")); } - -void gl_VTX_16 (u32 xxyy, u32 zz__) { +void gl_VTX_16 (u32 val) { //see 400048Ch - Cmd 23h - VTX_16 - Set Vertex XYZ Coordinates (W) - _VTX_16 xy, z_; - xy.val = xxyy; - z_.val = zz__; - vx = xy.bits.low ; - vy = xy.bits.high; - vz = z_.bits.low ; - gl_VTX_one(); + _VTX_16 vval; + static int vtx_16_nbparams = 0; + + vval.val = val; + switch(vtx_16_nbparams) { + case 0: + vx = vval.bits.low ; + vy = vval.bits.high; + vtx_16_nbparams++; + break; + case 1: + vz = vval.bits.low ; + gl_VTX_one(); + vtx_16_nbparams=0; + break; + default: + break; + } } + void gl_VTX_10 (u32 xyz) { //see 4000490h - Cmd 24h - VTX_10 - Set Vertex XYZ Coordinates (W) _VTX_10 vt; diff --git a/desmume/src/gl_vertex.h b/desmume/src/gl_vertex.h index 437f7a66e..a55d24f90 100755 --- a/desmume/src/gl_vertex.h +++ b/desmume/src/gl_vertex.h @@ -53,7 +53,7 @@ void gl_VTX_begin(u32 val); void gl_VTX_end(); //see 4000504h - Cmd 41h - END_VTXS - End of Vertex List (W) -void gl_VTX_16 (u32 xxyy, u32 zz__); +void gl_VTX_16 (u32 val); //see 400048Ch - Cmd 23h - VTX_16 - Set Vertex XYZ Coordinates (W) void gl_VTX_10 (u32 xyz); //see 4000490h - Cmd 24h - VTX_10 - Set Vertex XYZ Coordinates (W) diff --git a/desmume/src/registers.h b/desmume/src/registers.h index 7ac365113..1dd7fa05c 100644 --- a/desmume/src/registers.h +++ b/desmume/src/registers.h @@ -249,5 +249,44 @@ #define REG_DISPA_DISPMMEMFIFO 0x04000068 +// 3d commands +#define cmd_3D_MTX_MODE 0x04000440 +#define cmd_3D_MTX_PUSH 0x04000444 +#define cmd_3D_MTX_POP 0x04000448 +#define cmd_3D_MTX_STORE 0x0400044C +#define cmd_3D_MTX_RESTORE 0x04000450 +#define cmd_3D_MTX_IDENTITY 0x04000454 +#define cmd_3D_MTX_LOAD_4x4 0x04000458 +#define cmd_3D_MTX_LOAD_4x3 0x0400045C +#define cmd_3D_MTX_MULT_4x4 0x04000460 +#define cmd_3D_MTX_MULT_4x3 0x04000464 +#define cmd_3D_MTX_MULT_3x3 0x04000468 +#define cmd_3D_MTX_SCALE 0x0400046C +#define cmd_3D_MTX_TRANS 0x04000470 +#define cmd_3D_COLOR 0x04000480 +#define cmd_3D_NORMA 0x04000484 +#define cmd_3D_TEXCOORD 0x04000488 +#define cmd_3D_VTX_16 0x0400048C +#define cmd_3D_VTX_10 0x04000490 +#define cmd_3D_VTX_XY 0x04000494 +#define cmd_3D_VTX_XZ 0x04000498 +#define cmd_3D_VTX_YZ 0x0400049C +#define cmd_3D_VTX_DIFF 0x040004A0 +#define cmd_3D_POLYGON_ATTR 0x040004A4 +#define cmd_3D_TEXIMAGE_PARAM 0x040004A8 +#define cmd_3D_PLTT_BASE 0x040004AC +#define cmd_3D_DIF_AMB 0x040004C0 +#define cmd_3D_SPE_EMI 0x040004C4 +#define cmd_3D_LIGHT_VECTOR 0x040004C8 +#define cmd_3D_LIGHT_COLOR 0x040004CC +#define cmd_3D_SHININESS 0x040004D0 +#define cmd_3D_BEGIN_VTXS 0x04000500 +#define cmd_3D_END_VTXS 0x04000504 +#define cmd_3D_SWAP_BUFFERS 0x04000540 +#define cmd_3D_VIEWPORT 0x04000580 +#define cmd_3D_BOX_TEST 0x040005C0 +#define cmd_3D_POS_TEST 0x040005C4 +#define cmd_3D_VEC_TEST 0x040005C8 + #endif