More whitespace changes & comments

This commit is contained in:
csBlueChip 2009-09-03 02:58:58 +00:00
parent 9bd2aebaec
commit 1951835c9d

View file

@ -44,6 +44,8 @@ void GRRLIB_DrawImg (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
u16 width, height; u16 width, height;
Mtx m, m1, m2, mv; Mtx m, m1, m2, mv;
guVector axis = (guVector){0, 0, 1};
if (tex == NULL || tex->data == NULL) return ; if (tex == NULL || tex->data == NULL) return ;
GX_InitTexObj(&texObj, tex->data, tex->w, tex->h, GX_InitTexObj(&texObj, tex->data, tex->w, tex->h,
@ -53,17 +55,17 @@ void GRRLIB_DrawImg (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR,
0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1);
GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
width = tex->w * 0.5; width = tex->w * 0.5;
height = tex->h * 0.5; height = tex->h * 0.5;
guMtxIdentity(m1);
guMtxIdentity (m1);
guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0); guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0);
guVector axis = (guVector) {0, 0, 1}; guMtxRotAxisDeg(m2, &axis, degrees);
guMtxRotAxisDeg (m2, &axis, degrees); guMtxConcat (m2, m1, m);
guMtxConcat(m2, m1, m);
guMtxTransApply(m, m, guMtxTransApply(m, m,
xpos +width +tex->handlex xpos +width +tex->handlex
@ -78,25 +80,25 @@ void GRRLIB_DrawImg (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
GX_LoadPosMtxImm(mv, GX_PNMTX0); GX_LoadPosMtxImm(mv, GX_PNMTX0);
GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position3f32(-width, -height, 0); GX_Position3f32(-width, -height, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(0, 0); GX_TexCoord2f32(0, 0);
GX_Position3f32(width, -height, 0); GX_Position3f32(width, -height, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(1, 0); GX_TexCoord2f32(1, 0);
GX_Position3f32(width, height, 0); GX_Position3f32(width, height, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(1, 1); GX_TexCoord2f32(1, 1);
GX_Position3f32(-width, height, 0); GX_Position3f32(-width, height, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(0, 1); GX_TexCoord2f32(0, 1);
GX_End(); GX_End();
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetVtxDesc(GX_VA_TEX0, GX_NONE); GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
} }
/** /**
@ -107,12 +109,12 @@ void GRRLIB_DrawImg (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
*/ */
void GRRLIB_DrawImgQuad (const guVector pos[4], GRRLIB_texImg *tex, void GRRLIB_DrawImgQuad (const guVector pos[4], GRRLIB_texImg *tex,
const u32 color) { const u32 color) {
if (tex == NULL || tex->data == NULL) { GXTexObj texObj;
return; Mtx m, m1, m2, mv;
}
GXTexObj texObj; guVector axis = (guVector){0, 0, 1};
Mtx m, m1, m2, mv;
if (tex == NULL || tex->data == NULL) return ;
GX_InitTexObj(&texObj, tex->data, tex->w, tex->h, GX_InitTexObj(&texObj, tex->data, tex->w, tex->h,
GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
@ -121,40 +123,39 @@ void GRRLIB_DrawImgQuad (const guVector pos[4], GRRLIB_texImg *tex,
GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR,
0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1);
GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
guMtxIdentity(m1); guMtxIdentity (m1);
guMtxScaleApply(m1, m1, 1, 1, 1.0); guMtxScaleApply(m1, m1, 1, 1, 1.0);
guVector axis = (guVector) {0, 0, 1}; guMtxRotAxisDeg(m2, &axis, 0);
guMtxRotAxisDeg (m2, &axis, 0); guMtxConcat (m2, m1, m);
guMtxConcat(m2, m1, m);
guMtxConcat(GXmodelView2D, m, mv); guMtxConcat(GXmodelView2D, m, mv);
GX_LoadPosMtxImm(mv, GX_PNMTX0); GX_LoadPosMtxImm(mv, GX_PNMTX0);
GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position3f32(pos[0].x, pos[0].y, 0); GX_Position3f32(pos[0].x, pos[0].y, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(0, 0); GX_TexCoord2f32(0, 0);
GX_Position3f32(pos[1].x, pos[1].y, 0); GX_Position3f32(pos[1].x, pos[1].y, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(1, 0); GX_TexCoord2f32(1, 0);
GX_Position3f32(pos[2].x, pos[2].y, 0); GX_Position3f32(pos[2].x, pos[2].y, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(1, 1); GX_TexCoord2f32(1, 1);
GX_Position3f32(pos[3].x, pos[3].y, 0); GX_Position3f32(pos[3].x, pos[3].y, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(0, 1); GX_TexCoord2f32(0, 1);
GX_End(); GX_End();
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetVtxDesc(GX_VA_TEX0, GX_NONE); GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
} }
/** /**
@ -171,20 +172,20 @@ void GRRLIB_DrawImgQuad (const guVector pos[4], GRRLIB_texImg *tex,
void GRRLIB_DrawTile (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex, void GRRLIB_DrawTile (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
const f32 degrees, const f32 scaleX, const f32 scaleY, const f32 degrees, const f32 scaleX, const f32 scaleY,
const u32 color, const int frame) { const u32 color, const int frame) {
if (tex == NULL || tex->data == NULL) { GXTexObj texObj;
return; f32 width, height;
} Mtx m, m1, m2, mv;
GXTexObj texObj; guVector axis = (guVector){0, 0, 1};
f32 width, height;
Mtx m, m1, m2, mv; if (tex == NULL || tex->data == NULL) return ;
// Frame Correction by spiffen // Frame Correction by spiffen
f32 FRAME_CORR = 0.001f; f32 FRAME_CORR = 0.001f;
f32 s1 = (((frame%tex->nbtilew))/(f32)tex->nbtilew)+(FRAME_CORR/tex->w); f32 s1 = (( (frame%tex->nbtilew) ) /(f32)tex->nbtilew) +(FRAME_CORR/tex->w);
f32 s2 = (((frame%tex->nbtilew)+1)/(f32)tex->nbtilew)-(FRAME_CORR/tex->w); f32 s2 = (( (frame%tex->nbtilew)+1) /(f32)tex->nbtilew) -(FRAME_CORR/tex->w);
f32 t1 = (((int)(frame/tex->nbtilew))/(f32)tex->nbtileh)+(FRAME_CORR/tex->h); f32 t1 = (((int)(frame/tex->nbtilew) ) /(f32)tex->nbtileh) +(FRAME_CORR/tex->h);
f32 t2 = (((int)(frame/tex->nbtilew)+1)/(f32)tex->nbtileh)-(FRAME_CORR/tex->h); f32 t2 = (((int)(frame/tex->nbtilew)+1) /(f32)tex->nbtileh) -(FRAME_CORR/tex->h);
GX_InitTexObj(&texObj, tex->data, GX_InitTexObj(&texObj, tex->data,
tex->tilew * tex->nbtilew, tex->tileh * tex->nbtileh, tex->tilew * tex->nbtilew, tex->tileh * tex->nbtileh,
@ -194,19 +195,18 @@ void GRRLIB_DrawTile (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR,
0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1);
GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); width = tex->tilew * 0.5f;
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
width = tex->tilew * 0.5f;
height = tex->tileh * 0.5f; height = tex->tileh * 0.5f;
guMtxIdentity(m1);
guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0f);
guVector axis = (guVector) {0, 0, 1}; guMtxIdentity (m1);
guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0f);
guMtxRotAxisDeg(m2, &axis, degrees); guMtxRotAxisDeg(m2, &axis, degrees);
guMtxConcat(m2, m1, m); guMtxConcat (m2, m1, m);
guMtxTransApply(m, m, guMtxTransApply(m, m,
xpos +width +tex->handlex xpos +width +tex->handlex
-tex->offsetx +( scaleX *(-tex->handley *sin(-DegToRad(degrees)) -tex->offsetx +( scaleX *(-tex->handley *sin(-DegToRad(degrees))
@ -220,25 +220,25 @@ void GRRLIB_DrawTile (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
GX_LoadPosMtxImm(mv, GX_PNMTX0); GX_LoadPosMtxImm(mv, GX_PNMTX0);
GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position3f32(-width, -height, 0); GX_Position3f32(-width, -height, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(s1, t1); GX_TexCoord2f32(s1, t1);
GX_Position3f32(width, -height, 0); GX_Position3f32(width, -height, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(s2, t1); GX_TexCoord2f32(s2, t1);
GX_Position3f32(width, height, 0); GX_Position3f32(width, height, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(s2, t2); GX_TexCoord2f32(s2, t2);
GX_Position3f32(-width, height, 0); GX_Position3f32(-width, height, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(s1, t2); GX_TexCoord2f32(s1, t2);
GX_End(); GX_End();
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetVtxDesc(GX_VA_TEX0, GX_NONE); GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
} }
/** /**
@ -250,19 +250,19 @@ void GRRLIB_DrawTile (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
*/ */
void GRRLIB_DrawTileQuad (const guVector pos[4], GRRLIB_texImg *tex, void GRRLIB_DrawTileQuad (const guVector pos[4], GRRLIB_texImg *tex,
const u32 color, const int frame) { const u32 color, const int frame) {
if (tex == NULL || tex->data == NULL) { GXTexObj texObj;
return; Mtx m, m1, m2, mv;
}
GXTexObj texObj; guVector axis = (guVector){0, 0, 1};
Mtx m, m1, m2, mv;
if (tex == NULL || tex->data == NULL) return ;
// Frame Correction by spiffen // Frame Correction by spiffen
f32 FRAME_CORR = 0.001f; f32 FRAME_CORR = 0.001f;
f32 s1 = (((frame%tex->nbtilew))/(f32)tex->nbtilew)+(FRAME_CORR/tex->w); f32 s1 = (( (frame%tex->nbtilew) ) /(f32)tex->nbtilew) +(FRAME_CORR/tex->w);
f32 s2 = (((frame%tex->nbtilew)+1)/(f32)tex->nbtilew)-(FRAME_CORR/tex->w); f32 s2 = (( (frame%tex->nbtilew)+1) /(f32)tex->nbtilew) -(FRAME_CORR/tex->w);
f32 t1 = (((int)(frame/tex->nbtilew))/(f32)tex->nbtileh)+(FRAME_CORR/tex->h); f32 t1 = (((int)(frame/tex->nbtilew) ) /(f32)tex->nbtileh) +(FRAME_CORR/tex->h);
f32 t2 = (((int)(frame/tex->nbtilew)+1)/(f32)tex->nbtileh)-(FRAME_CORR/tex->h); f32 t2 = (((int)(frame/tex->nbtilew)+1) /(f32)tex->nbtileh) -(FRAME_CORR/tex->h);
GX_InitTexObj(&texObj, tex->data, GX_InitTexObj(&texObj, tex->data,
tex->tilew * tex->nbtilew, tex->tileh * tex->nbtileh, tex->tilew * tex->nbtilew, tex->tileh * tex->nbtileh,
@ -272,15 +272,12 @@ void GRRLIB_DrawTileQuad (const guVector pos[4], GRRLIB_texImg *tex,
GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR,
0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1);
GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); guMtxIdentity (m1);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
guMtxIdentity(m1);
guMtxScaleApply(m1, m1, 1, 1, 1.0f); guMtxScaleApply(m1, m1, 1, 1, 1.0f);
guVector axis = (guVector) {0, 0, 1};
guMtxRotAxisDeg(m2, &axis, 0); guMtxRotAxisDeg(m2, &axis, 0);
guMtxConcat(m2, m1, m); guMtxConcat(m2, m1, m);
@ -289,42 +286,43 @@ void GRRLIB_DrawTileQuad (const guVector pos[4], GRRLIB_texImg *tex,
GX_LoadPosMtxImm(mv, GX_PNMTX0); GX_LoadPosMtxImm(mv, GX_PNMTX0);
GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position3f32(pos[0].x, pos[0].y, 0); GX_Position3f32(pos[0].x, pos[0].y, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(s1, t1); GX_TexCoord2f32(s1, t1);
GX_Position3f32(pos[1].x, pos[1].y, 0); GX_Position3f32(pos[1].x, pos[1].y, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(s2, t1); GX_TexCoord2f32(s2, t1);
GX_Position3f32(pos[2].x, pos[2].y, 0); GX_Position3f32(pos[2].x, pos[2].y, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(s2, t2); GX_TexCoord2f32(s2, t2);
GX_Position3f32(pos[3].x, pos[3].y, 0); GX_Position3f32(pos[3].x, pos[3].y, 0);
GX_Color1u32(color); GX_Color1u32 (color);
GX_TexCoord2f32(s1, t2); GX_TexCoord2f32(s1, t2);
GX_End(); GX_End();
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR); GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetVtxDesc(GX_VA_TEX0, GX_NONE); GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
} }
/** /**
* Call this function after drawing. * Call this function after drawing.
*/ */
void GRRLIB_Render (void) { void GRRLIB_Render (void) {
GX_DrawDone(); GX_DrawDone(); // Tell the GX engine we are done drawing
GX_InvalidateTexAll(); GX_InvalidateTexAll();
fb ^= 1; // Flip framebuffer fb ^= 1; // Toggle framebuffer index
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetColorUpdate(GX_TRUE); GX_SetColorUpdate(GX_TRUE);
GX_CopyDisp(xfb[fb], GX_TRUE); GX_CopyDisp (xfb[fb], GX_TRUE);
VIDEO_SetNextFramebuffer(xfb[fb]); VIDEO_SetNextFramebuffer(xfb[fb]); // Select eXternal Frame Buffer
VIDEO_Flush(); VIDEO_Flush(); // Flush video buffer to screen
VIDEO_WaitVSync(); // Wait for screen to update
VIDEO_WaitVSync(); // Interlaced screens require two frames to update
if (rmode->viTVMode &VI_NON_INTERLACE) VIDEO_WaitVSync() ; if (rmode->viTVMode &VI_NON_INTERLACE) VIDEO_WaitVSync() ;
} }