disabled printing as it useful only for developers

This commit is contained in:
damdoum 2007-02-27 17:53:03 +00:00
parent db7817d468
commit d9abbaa6a5
2 changed files with 126 additions and 118 deletions

View File

@ -24,6 +24,7 @@
#include "gl_vertex.h" #include "gl_vertex.h"
/* /*
credits goes to : credits goes to :
http://nocash.emubase.de/gbatek.htm#ds3dvideo http://nocash.emubase.de/gbatek.htm#ds3dvideo
@ -62,8 +63,8 @@ Table shows Port Address, Command ID, Number of Parameters, and Clock Cycles.
*/ */
#define print(a) printf a //#define print(a) printf a
//#define print(a) #define print(a)
BOOL attempted_3D_op=FALSE; BOOL attempted_3D_op=FALSE;
@ -71,93 +72,101 @@ int mtx_mode=0;
void gl_MTX_MODE (u32 val) { void gl_MTX_MODE (u32 val) {
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
mtx_mode = val; mtx_mode = val;
switch(val) { switch(val) {
case MTX_MODE_PROJECTION: case MTX_MODE_PROJECTION:
print(("MTX MODE PROJECTION\n")); print(("MTX MODE PROJECTION\n"));
break; break;
case MTX_MODE_POSITION: case MTX_MODE_POSITION:
print(("MTX MODE POSITION\n")); print(("MTX MODE POSITION\n"));
break; break;
case MTX_MODE_POS_VECTOR: case MTX_MODE_POS_VECTOR:
print(("MTX MODE POSITION & VECTOR\n")); print(("MTX MODE POSITION & VECTOR\n"));
break; break;
case MTX_MODE_TEXTURE: case MTX_MODE_TEXTURE:
print(("MTX MODE TEXTURE\n")); print(("MTX MODE TEXTURE\n"));
break; break;
} }
} }
/******************************************************************/ /******************************************************************/
// MTX_LOAD* - cmd 15h-1Ah // MTX_LOAD* - cmd 15h-1Ah
/******************************************************************/ /******************************************************************/
#define MMM 0.0 #define MMM 0
static float mCurrent[16]; #define M_0 0
static float mUnit[16]= #define M_1 (1<<12)
{1.0, 0.0, 0.0, 0.0, static u32 mCurrent[16]=
0.0, 1.0, 0.0, 0.0, {M_1, M_0, M_0, M_0,
0.0, 0.0, 1.0, 0.0, M_0, M_1, M_0, M_0,
0.0, 0.0, 0.0, 1.0}; M_0, M_0, M_1, M_0,
static float m4x4[16]= M_0, M_0, M_0, M_1};
static u32 mUnit[16]=
{M_1, M_0, M_0, M_0,
M_0, M_1, M_0, M_0,
M_0, M_0, M_1, M_0,
M_0, M_0, M_0, M_1};
static u32 m4x4[16]=
{MMM, MMM, MMM, MMM, {MMM, MMM, MMM, MMM,
MMM, MMM, MMM, MMM, MMM, MMM, MMM, MMM,
MMM, MMM, MMM, MMM, MMM, MMM, MMM, MMM,
MMM, MMM, MMM, MMM}; MMM, MMM, MMM, MMM};
static float m4x3[16]= static u32 m4x3[16]=
{MMM, MMM, MMM, 0.0, {MMM, MMM, MMM, M_0,
MMM, MMM, MMM, 0.0, MMM, MMM, MMM, M_0,
MMM, MMM, MMM, 0.0, MMM, MMM, MMM, M_0,
MMM, MMM, MMM, 1.0}; MMM, MMM, MMM, M_1};
static float m3x3[16]= static u32 m3x3[16]=
{MMM, MMM, MMM, 0.0, {MMM, MMM, MMM, M_0,
MMM, MMM, MMM, 0.0, MMM, MMM, MMM, M_0,
MMM, MMM, MMM, 0.0, MMM, MMM, MMM, M_0,
0.0, 0.0, 0.0, 1.0}; M_0, M_0, M_0, M_1};
void gl_MTX_show(float*m) { void gl_MTX_show(u32 * m32) {
float m[16];
int i;
for (i=0;i<16;i++)
m[i]=u32_to_float(m32[i]);
print(("\t[[%+.5f %+.5f %+.5f %+.5f]\n", m[0] ,m[1] ,m[2] ,m[3])); print(("\t[[%+.5f %+.5f %+.5f %+.5f]\n", m[0] ,m[1] ,m[2] ,m[3]));
print(("\t [%+.5f %+.5f %+.5f %+.5f]\n", m[4] ,m[5] ,m[6] ,m[7])); print(("\t [%+.5f %+.5f %+.5f %+.5f]\n", m[4] ,m[5] ,m[6] ,m[7]));
print(("\t [%+.5f %+.5f %+.5f %+.5f]\n", m[8] ,m[9] ,m[10],m[11])); print(("\t [%+.5f %+.5f %+.5f %+.5f]\n", m[8] ,m[9] ,m[10],m[11]));
print(("\t [%+.5f %+.5f %+.5f %+.5f]]\n",m[12],m[13],m[14],m[15])); print(("\t [%+.5f %+.5f %+.5f %+.5f]]\n",m[12],m[13],m[14],m[15]));
} }
void gl_MTX_load(float* m) { void gl_MTX_load(u32* m) {
int i; int i;
for (i=0;i<16;i++) for (i=0;i<16;i++)
mCurrent[i]=m[i]; mCurrent[i]=m[i];
gl_MTX_show(mCurrent); gl_MTX_show(mCurrent);
} }
void gl_MTX_mult(float* m) { void gl_MTX_mult(u32* m) {
int i; int i;
for (i=0;i<16;i++) for (i=0;i<16;i++)
mCurrent[i]*=m[i]; mCurrent[i] = (mCurrent[i]>>6)*(m[i]>>6);
gl_MTX_show(mCurrent); gl_MTX_show(mCurrent);
} }
void gl_MTX_IDENTITY () { void gl_MTX_IDENTITY () {
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
print(("MTX_IDENTITY\n")); print(("MTX_IDENTITY\n"));
gl_MTX_load(mUnit); gl_MTX_load(mUnit);
} }
void gl_MTX_LOAD_4x4 (u32 val) { void gl_MTX_LOAD_4x4 (u32 val) {
static int mtx_nbparams = 0; static int mtx_nbparams = 0;
_MTX_val mval;
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
mval.val = val;
switch(mtx_nbparams) { switch(mtx_nbparams) {
case 0: case 1: case 2: case 3: case 0: case 1: case 2: case 3:
case 4: case 5: case 6: case 7: case 4: case 5: case 6: case 7:
case 8: case 9: case 10: case 11: case 8: case 9: case 10: case 11:
case 12: case 13: case 14: case 12: case 13: case 14:
m4x4[mtx_nbparams]=mval.fval; m4x4[mtx_nbparams]=val;
mtx_nbparams++; mtx_nbparams++;
break; break;
case 15: case 15:
m4x4[mtx_nbparams]=mval.fval; m4x4[mtx_nbparams]=val;
mtx_nbparams=0; mtx_nbparams=0;
print(("MTX_LOAD_4x4\n")); print(("MTX_LOAD_4x4\n"));
gl_MTX_load(m4x4); gl_MTX_load(m4x4);
break; break;
default: default:
@ -166,21 +175,19 @@ CHECK_3D_ATTEMPT
} }
void gl_MTX_MULT_4x4 (u32 val) { void gl_MTX_MULT_4x4 (u32 val) {
static int mtx_nbparams = 0; static int mtx_nbparams = 0;
_MTX_val mval;
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
mval.val = val;
switch(mtx_nbparams) { switch(mtx_nbparams) {
case 0: case 1: case 2: case 3: case 0: case 1: case 2: case 3:
case 4: case 5: case 6: case 7: case 4: case 5: case 6: case 7:
case 8: case 9: case 10: case 11: case 8: case 9: case 10: case 11:
case 12: case 13: case 14: case 12: case 13: case 14:
m4x4[mtx_nbparams]=mval.fval; m4x4[mtx_nbparams]=val;
mtx_nbparams++; mtx_nbparams++;
break; break;
case 15: case 15:
m4x4[mtx_nbparams]=mval.fval; m4x4[mtx_nbparams]=val;
mtx_nbparams=0; mtx_nbparams=0;
print(("MTX_MULT_4x4\n")); print(("MTX_MULT_4x4\n"));
gl_MTX_mult(m4x4); gl_MTX_mult(m4x4);
break; break;
default: default:
@ -191,23 +198,21 @@ CHECK_3D_ATTEMPT
void gl_MTX_LOAD_4x3 (u32 val) { void gl_MTX_LOAD_4x3 (u32 val) {
static int mtx_nbparams = 0; static int mtx_nbparams = 0;
_MTX_val mval;
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
mval.val = val;
switch(mtx_nbparams) { switch(mtx_nbparams) {
case 3: case 7: case 11: case 3: case 7: case 11:
mtx_nbparams++; mtx_nbparams++;
case 0: case 1: case 2: case 0: case 1: case 2:
case 4: case 5: case 6: case 4: case 5: case 6:
case 8: case 9: case 10: case 8: case 9: case 10:
case 12: case 13: case 12: case 13:
m4x3[mtx_nbparams]=mval.fval; m4x3[mtx_nbparams]=val;
mtx_nbparams++; mtx_nbparams++;
break; break;
case 14: case 14:
m4x3[mtx_nbparams]=mval.fval; m4x3[mtx_nbparams]=val;
mtx_nbparams=0; mtx_nbparams=0;
print(("MTX_LOAD_4x3\n")); print(("MTX_LOAD_4x3\n"));
gl_MTX_load(m4x3); gl_MTX_load(m4x3);
break; break;
default: default:
@ -216,23 +221,21 @@ CHECK_3D_ATTEMPT
} }
void gl_MTX_MULT_4x3 (u32 val) { void gl_MTX_MULT_4x3 (u32 val) {
static int mtx_nbparams = 0; static int mtx_nbparams = 0;
_MTX_val mval;
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
mval.val = val;
switch(mtx_nbparams) { switch(mtx_nbparams) {
case 3: case 7: case 11: case 3: case 7: case 11:
mtx_nbparams++; mtx_nbparams++;
case 0: case 1: case 2: case 0: case 1: case 2:
case 4: case 5: case 6: case 4: case 5: case 6:
case 8: case 9: case 10: case 8: case 9: case 10:
case 12: case 13: case 12: case 13:
m4x3[mtx_nbparams]=mval.fval; m4x3[mtx_nbparams]=val;
mtx_nbparams++; mtx_nbparams++;
break; break;
case 14: case 14:
m4x3[mtx_nbparams]=mval.fval; m4x3[mtx_nbparams]=val;
mtx_nbparams=0; mtx_nbparams=0;
print(("MTX_MULT_4x3\n")); print(("MTX_MULT_4x3\n"));
gl_MTX_mult(m4x3); gl_MTX_mult(m4x3);
break; break;
default: default:
@ -242,22 +245,20 @@ CHECK_3D_ATTEMPT
void gl_MTX_LOAD_3x3 (u32 val) { void gl_MTX_LOAD_3x3 (u32 val) {
static int mtx_nbparams = 0; static int mtx_nbparams = 0;
_MTX_val mval;
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
mval.val = val;
switch(mtx_nbparams) { switch(mtx_nbparams) {
case 3: case 7: case 11: case 3: case 7: case 11:
mtx_nbparams++; mtx_nbparams++;
case 0: case 1: case 2: case 0: case 1: case 2:
case 4: case 5: case 6: case 4: case 5: case 6:
case 8: case 9: case 8: case 9:
m3x3[mtx_nbparams]=mval.fval; m3x3[mtx_nbparams]=val;
mtx_nbparams++; mtx_nbparams++;
break; break;
case 10: case 10:
m3x3[mtx_nbparams]=mval.fval; m3x3[mtx_nbparams]=val;
mtx_nbparams=0; mtx_nbparams=0;
print(("MTX_LOAD_3x3\n")); print(("MTX_LOAD_3x3\n"));
gl_MTX_load(m3x3); gl_MTX_load(m3x3);
break; break;
default: default:
@ -266,22 +267,20 @@ CHECK_3D_ATTEMPT
} }
void gl_MTX_MULT_3x3 (u32 val) { void gl_MTX_MULT_3x3 (u32 val) {
static int mtx_nbparams = 0; static int mtx_nbparams = 0;
_MTX_val mval;
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
mval.val = val;
switch(mtx_nbparams) { switch(mtx_nbparams) {
case 3: case 7: case 11: case 3: case 7: case 11:
mtx_nbparams++; mtx_nbparams++;
case 0: case 1: case 2: case 0: case 1: case 2:
case 4: case 5: case 6: case 4: case 5: case 6:
case 8: case 9: case 8: case 9:
m3x3[mtx_nbparams]=mval.fval; m3x3[mtx_nbparams]=val;
mtx_nbparams++; mtx_nbparams++;
break; break;
case 10: case 10:
m3x3[mtx_nbparams]=mval.fval; m3x3[mtx_nbparams]=val;
mtx_nbparams=0; mtx_nbparams=0;
print(("MTX_MULT_3x3\n")); print(("MTX_MULT_3x3\n"));
gl_MTX_mult(m3x3); gl_MTX_mult(m3x3);
break; break;
default: default:
@ -293,12 +292,12 @@ CHECK_3D_ATTEMPT
/******************************************************************/ /******************************************************************/
void gl_TEXCOORD(u32 val) { void gl_TEXCOORD(u32 val) {
_TEXCOORD tx; _TEXCOORD tx;
float s,t; float s,t;
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
tx.val = val; tx.val = val;
s = tx.bits.low / 2048.; s = TEXCOORD_to_float(tx.bits.low);
t = tx.bits.high / 2048.; t = TEXCOORD_to_float(tx.bits.high);
print(("\tTEX [%+.5f %+.5f]\n",s,t)); print(("\tTEX [%+.5f %+.5f]\n",s,t));
} }
@ -312,9 +311,9 @@ static s16 vx=0,vy=0,vz=0;
INLINE void gl_VTX_one() { INLINE void gl_VTX_one() {
float vfx,vfy,vfz; float vfx,vfy,vfz;
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
vfx = vx / 4096.; vfx = s16_to_float(vx);
vfy = vy / 4096.; vfy = s16_to_float(vy);
vfz = vz / 4096.; vfz = s16_to_float(vz);
print(("\tVTX [%+.5f %+.5f %+.5f]\n",vfx,vfy,vfz)); print(("\tVTX [%+.5f %+.5f %+.5f]\n",vfx,vfy,vfz));
} }
@ -339,7 +338,7 @@ CHECK_3D_ATTEMPT
print(("GL_QUAD_STRIP\n")); print(("GL_QUAD_STRIP\n"));
break; break;
default : default :
print(("unknown %d\n",val)); print(("unknown %d\n",val));
} }
} }
void gl_VTX_end() { void gl_VTX_end() {
@ -376,9 +375,9 @@ void gl_VTX_10 (u32 xyz) {
_VTX_10 vt; _VTX_10 vt;
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
vt.val = xyz; vt.val = xyz;
vx = vt.bits.low << 6; vx = VTX10_to_s16(vt.bits.low);
vy = vt.bits.mid << 6; vy = VTX10_to_s16(vt.bits.mid);
vz = vt.bits.high << 6; vz = VTX10_to_s16(vt.bits.high);
gl_VTX_one(); gl_VTX_one();
} }
@ -388,8 +387,8 @@ void gl_VTX_XY (u32 xy) {
_VTX_16 vt; _VTX_16 vt;
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
vt.val = xy; vt.val = xy;
vx = vt.bits.low ; vx = VTX16_to_s16(vt.bits.low);
vy = vt.bits.high; vy = VTX16_to_s16(vt.bits.high);
gl_VTX_one(); gl_VTX_one();
} }
void gl_VTX_XZ (u32 xz) { void gl_VTX_XZ (u32 xz) {
@ -397,8 +396,8 @@ void gl_VTX_XZ (u32 xz) {
_VTX_16 vt; _VTX_16 vt;
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
vt.val = xz; vt.val = xz;
vx = vt.bits.low ; vx = VTX16_to_s16(vt.bits.low);
vz = vt.bits.high; vz = VTX16_to_s16(vt.bits.high);
gl_VTX_one(); gl_VTX_one();
} }
void gl_VTX_YZ (u32 yz) { void gl_VTX_YZ (u32 yz) {
@ -406,8 +405,8 @@ void gl_VTX_YZ (u32 yz) {
_VTX_16 vt; _VTX_16 vt;
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
vt.val = yz; vt.val = yz;
vy = vt.bits.low ; vy = VTX16_to_s16(vt.bits.low);
vz = vt.bits.high; vz = VTX16_to_s16(vt.bits.high);
gl_VTX_one(); gl_VTX_one();
} }
@ -417,8 +416,8 @@ void gl_VTX_DIFF (u32 diff) {
_VTX_10 vt; _VTX_10 vt;
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
vt.val = diff; vt.val = diff;
vx += vt.bits.low << 3; vx += VTXDIFF_to_s16(vt.bits.low);
vy += vt.bits.mid << 3; vy += VTXDIFF_to_s16(vt.bits.mid);
vz += vt.bits.high << 3; vz += VTXDIFF_to_s16(vt.bits.high);
gl_VTX_one(); gl_VTX_one();
} }

View File

@ -36,7 +36,14 @@ BOOL attempted_3D_op;
#define BEGIN_GL_QUADS 1 #define BEGIN_GL_QUADS 1
#define BEGIN_GL_TRIANGLE_STRIP 2 #define BEGIN_GL_TRIANGLE_STRIP 2
#define BEGIN_GL_QUAD_STRIP 3 #define BEGIN_GL_QUAD_STRIP 3
#define TEXCOORD_to_float(t) (((float)(t)) / 2048.)
#define u32_to_float(t) (((float)(t)) / 4096.)
#define s16_to_float(t) (((float)(t)) / 4096.)
#define VTX16_to_s16(t) (t)
#define VTX10_to_s16(t) (t << 6)
#define VTXDIFF_to_s16(t) (t << 3)
typedef union { typedef union {
u32 val; u32 val;
float fval; float fval;
@ -97,6 +104,7 @@ void gl_VTX_DIFF (u32 diff);
INLINE static void gl_print_cmd(u32 adr) { INLINE static void gl_print_cmd(u32 adr) {
CHECK_3D_ATTEMPT CHECK_3D_ATTEMPT
#if 0
switch (adr) { switch (adr) {
GL_CMD_NAME(eng_3D_RDLINES_COUNT ) GL_CMD_NAME(eng_3D_RDLINES_COUNT )
GL_CMD_NAME(eng_3D_EDGE_COLOR ) GL_CMD_NAME(eng_3D_EDGE_COLOR )
@ -157,4 +165,5 @@ CHECK_3D_ATTEMPT
GL_CMD_NAME(eng_3D_VECMTX_RESULT ) GL_CMD_NAME(eng_3D_VECMTX_RESULT )
default: break; default: break;
} }
#endif
} }