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;
Mtx m, m1, m2, mv;
guVector axis = (guVector){0, 0, 1};
if (tex == NULL || tex->data == NULL) return ;
GX_InitTexObj(&texObj, tex->data, tex->w, tex->h,
@ -54,16 +56,16 @@ void GRRLIB_DrawImg (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1);
GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
width = tex->w * 0.5;
height = tex->h * 0.5;
guMtxIdentity(m1);
guMtxIdentity (m1);
guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0);
guVector axis = (guVector) {0, 0, 1};
guMtxRotAxisDeg (m2, &axis, degrees);
guMtxConcat(m2, m1, m);
guMtxRotAxisDeg(m2, &axis, degrees);
guMtxConcat (m2, m1, m);
guMtxTransApply(m, m,
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_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position3f32(-width, -height, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(0, 0);
GX_Position3f32(width, -height, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(1, 0);
GX_Position3f32(width, height, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(1, 1);
GX_Position3f32(-width, height, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(0, 1);
GX_End();
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
}
/**
@ -107,13 +109,13 @@ void GRRLIB_DrawImg (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
*/
void GRRLIB_DrawImgQuad (const guVector pos[4], GRRLIB_texImg *tex,
const u32 color) {
if (tex == NULL || tex->data == NULL) {
return;
}
GXTexObj texObj;
Mtx m, m1, m2, mv;
guVector axis = (guVector){0, 0, 1};
if (tex == NULL || tex->data == NULL) return ;
GX_InitTexObj(&texObj, tex->data, tex->w, tex->h,
GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
@ -122,39 +124,38 @@ void GRRLIB_DrawImgQuad (const guVector pos[4], GRRLIB_texImg *tex,
0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1);
GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
guMtxIdentity(m1);
guMtxIdentity (m1);
guMtxScaleApply(m1, m1, 1, 1, 1.0);
guVector axis = (guVector) {0, 0, 1};
guMtxRotAxisDeg (m2, &axis, 0);
guMtxConcat(m2, m1, m);
guMtxRotAxisDeg(m2, &axis, 0);
guMtxConcat (m2, m1, m);
guMtxConcat(GXmodelView2D, m, mv);
GX_LoadPosMtxImm(mv, GX_PNMTX0);
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position3f32(pos[0].x, pos[0].y, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(0, 0);
GX_Position3f32(pos[1].x, pos[1].y, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(1, 0);
GX_Position3f32(pos[2].x, pos[2].y, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(1, 1);
GX_Position3f32(pos[3].x, pos[3].y, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(0, 1);
GX_End();
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
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,
const f32 degrees, const f32 scaleX, const f32 scaleY,
const u32 color, const int frame) {
if (tex == NULL || tex->data == NULL) {
return;
}
GXTexObj texObj;
f32 width, height;
Mtx m, m1, m2, mv;
guVector axis = (guVector){0, 0, 1};
if (tex == NULL || tex->data == NULL) return ;
// Frame Correction by spiffen
f32 FRAME_CORR = 0.001f;
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 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 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 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);
GX_InitTexObj(&texObj, tex->data,
tex->tilew * tex->nbtilew, tex->tileh * tex->nbtileh,
@ -195,18 +196,17 @@ void GRRLIB_DrawTile (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex,
0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1);
GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
width = tex->tilew * 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);
guMtxConcat(m2, m1, m);
guMtxConcat (m2, m1, m);
guMtxTransApply(m, m,
xpos +width +tex->handlex
-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_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position3f32(-width, -height, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(s1, t1);
GX_Position3f32(width, -height, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(s2, t1);
GX_Position3f32(width, height, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(s2, t2);
GX_Position3f32(-width, height, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(s1, t2);
GX_End();
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
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,
const u32 color, const int frame) {
if (tex == NULL || tex->data == NULL) {
return;
}
GXTexObj texObj;
Mtx m, m1, m2, mv;
guVector axis = (guVector){0, 0, 1};
if (tex == NULL || tex->data == NULL) return ;
// Frame Correction by spiffen
f32 FRAME_CORR = 0.001f;
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 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 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 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);
GX_InitTexObj(&texObj, tex->data,
tex->tilew * tex->nbtilew, tex->tileh * tex->nbtileh,
@ -273,14 +273,11 @@ void GRRLIB_DrawTileQuad (const guVector pos[4], GRRLIB_texImg *tex,
0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1);
GX_LoadTexObj(&texObj, GX_TEXMAP0);
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
guMtxIdentity(m1);
guMtxIdentity (m1);
guMtxScaleApply(m1, m1, 1, 1, 1.0f);
guVector axis = (guVector) {0, 0, 1};
guMtxRotAxisDeg(m2, &axis, 0);
guMtxConcat(m2, m1, m);
@ -289,42 +286,43 @@ void GRRLIB_DrawTileQuad (const guVector pos[4], GRRLIB_texImg *tex,
GX_LoadPosMtxImm(mv, GX_PNMTX0);
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position3f32(pos[0].x, pos[0].y, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(s1, t1);
GX_Position3f32(pos[1].x, pos[1].y, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(s2, t1);
GX_Position3f32(pos[2].x, pos[2].y, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(s2, t2);
GX_Position3f32(pos[3].x, pos[3].y, 0);
GX_Color1u32(color);
GX_Color1u32 (color);
GX_TexCoord2f32(s1, t2);
GX_End();
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);
GX_LoadPosMtxImm(GXmodelView2D, GX_PNMTX0);
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
}
/**
* Call this function after drawing.
*/
void GRRLIB_Render (void) {
GX_DrawDone();
GX_DrawDone(); // Tell the GX engine we are done drawing
GX_InvalidateTexAll();
fb ^= 1; // Flip framebuffer
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
fb ^= 1; // Toggle framebuffer index
GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetColorUpdate(GX_TRUE);
GX_CopyDisp(xfb[fb], GX_TRUE);
GX_CopyDisp (xfb[fb], GX_TRUE);
VIDEO_SetNextFramebuffer(xfb[fb]);
VIDEO_Flush();
VIDEO_WaitVSync();
VIDEO_SetNextFramebuffer(xfb[fb]); // Select eXternal Frame Buffer
VIDEO_Flush(); // Flush video buffer to screen
VIDEO_WaitVSync(); // Wait for screen to update
// Interlaced screens require two frames to update
if (rmode->viTVMode &VI_NON_INTERLACE) VIDEO_WaitVSync() ;
}