From fc3c97d90d88deb9c0556afbc2921d9e4050f3c7 Mon Sep 17 00:00:00 2001 From: Crayon2000 Date: Wed, 25 Nov 2009 05:14:28 +0000 Subject: [PATCH] [CHG] Replaced tabs with spaces [CHG] Adapted lesson1 --- GRRLIB/GRRLIB/GRRLIB_render.c | 38 ++++++++-------- GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h | 2 +- GRRLIB/GRRLIB/grrlib/GRRLIB_fbSimple.h | 14 +++--- GRRLIB/GRRLIB/grrlib/GRRLIB_settings.h | 8 ++-- examples/lesson1/source/main.c | 61 ++++++++++++++++---------- 5 files changed, 70 insertions(+), 53 deletions(-) diff --git a/GRRLIB/GRRLIB/GRRLIB_render.c b/GRRLIB/GRRLIB/GRRLIB_render.c index 5d08cdc..f82236e 100644 --- a/GRRLIB/GRRLIB/GRRLIB_render.c +++ b/GRRLIB/GRRLIB/GRRLIB_render.c @@ -53,11 +53,11 @@ void GRRLIB_DrawImg (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex) GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); - // Get current drawing settings. - u32 color = GRRLIB_Settings.colorRGBA; - f32 degrees = GRRLIB_Settings.rotation; - f32 scaleX = GRRLIB_Settings.scaleX; - f32 scaleY = GRRLIB_Settings.scaleY; + // Get current drawing settings. + u32 color = GRRLIB_Settings.colorRGBA; + f32 degrees = GRRLIB_Settings.rotation; + f32 scaleX = GRRLIB_Settings.scaleX; + f32 scaleY = GRRLIB_Settings.scaleY; guMtxIdentity (m1); guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0); @@ -123,8 +123,8 @@ void GRRLIB_DrawImgQuad (const guVector pos[4], GRRLIB_texImg *tex) { GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); - // Get current drawing settings. - u32 color = GRRLIB_Settings.colorRGBA; + // Get current drawing settings. + u32 color = GRRLIB_Settings.colorRGBA; guMtxIdentity (m1); guMtxScaleApply(m1, m1, 1, 1, 1.0); @@ -192,11 +192,11 @@ void GRRLIB_DrawTile (const f32 xpos, const f32 ypos, const GRRLIB_texImg *tex, width = tex->tilew * 0.5f; height = tex->tileh * 0.5f; - // Get current drawing settings. - u32 color = GRRLIB_Settings.colorRGBA; - f32 degrees = GRRLIB_Settings.rotation; - f32 scaleX = GRRLIB_Settings.scaleX; - f32 scaleY = GRRLIB_Settings.scaleY; + // Get current drawing settings. + u32 color = GRRLIB_Settings.colorRGBA; + f32 degrees = GRRLIB_Settings.rotation; + f32 scaleX = GRRLIB_Settings.scaleX; + f32 scaleY = GRRLIB_Settings.scaleY; guMtxIdentity (m1); guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0f); @@ -271,11 +271,11 @@ void GRRLIB_DrawPart (const f32 xpos, const f32 ypos, const f32 partx, const f3 GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1); - // Get current drawing settings. - u32 color = GRRLIB_Settings.colorRGBA; - f32 degrees = GRRLIB_Settings.rotation; - f32 scaleX = GRRLIB_Settings.scaleX; - f32 scaleY = GRRLIB_Settings.scaleY; + // Get current drawing settings. + u32 color = GRRLIB_Settings.colorRGBA; + f32 degrees = GRRLIB_Settings.rotation; + f32 scaleX = GRRLIB_Settings.scaleX; + f32 scaleY = GRRLIB_Settings.scaleY; GX_LoadTexObj(&texObj, GX_TEXMAP0); GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); @@ -355,8 +355,8 @@ void GRRLIB_DrawTileQuad (const guVector pos[4], GRRLIB_texImg *tex, const int GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); - // Get current drawing settings. - u32 color = GRRLIB_Settings.colorRGBA; + // Get current drawing settings. + u32 color = GRRLIB_Settings.colorRGBA; guMtxIdentity (m1); guMtxScaleApply(m1, m1, 1, 1, 1.0f); diff --git a/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h b/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h index b0d4e6e..d682d80 100644 --- a/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h +++ b/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h @@ -91,7 +91,7 @@ bool GRRLIB_ScrShot (const char* filename) ; //------------------------------------------------------------------------------ //! GRRLIB_print.c - Will someome please tell me what these are :) void GRRLIB_Printf (const f32 xpos, const f32 ypos, - const GRRLIB_texImg *tex, + const GRRLIB_texImg *tex, const char *text, ...) ; void GRRLIB_PrintBMF (const f32 xpos, const f32 ypos, diff --git a/GRRLIB/GRRLIB/grrlib/GRRLIB_fbSimple.h b/GRRLIB/GRRLIB/grrlib/GRRLIB_fbSimple.h index c1e475b..cdbcef6 100644 --- a/GRRLIB/GRRLIB/grrlib/GRRLIB_fbSimple.h +++ b/GRRLIB/GRRLIB/grrlib/GRRLIB_fbSimple.h @@ -34,8 +34,8 @@ extern GRRLIB_drawSettings GRRLIB_Settings; */ INLINE void GRRLIB_FillScreen (const u32 color) { - u32 tmpColor = GRRLIB_Settings.colorRGBA; - GRRLIB_SetColorRGBA(color); + u32 tmpColor = GRRLIB_Settings.colorRGBA; + GRRLIB_SetColorRGBA(color); GRRLIB_Rectangle(-40, -40, rmode->fbWidth +80, rmode->xfbHeight +80, 1); GRRLIB_SetColorRGBA(tmpColor); } @@ -85,12 +85,12 @@ INLINE void GRRLIB_Rectangle (const f32 x, const f32 y, const f32 width, const f32 height, const u8 filled) { - + // Get current drawing settings. - u32 color = GRRLIB_Settings.colorRGBA; - f32 scaleX = GRRLIB_Settings.scaleX; - f32 scaleY = GRRLIB_Settings.scaleY; - + u32 color = GRRLIB_Settings.colorRGBA; + f32 scaleX = GRRLIB_Settings.scaleX; + f32 scaleY = GRRLIB_Settings.scaleY; + f32 x2 = x + width * scaleX; f32 y2 = y + height * scaleY; diff --git a/GRRLIB/GRRLIB/grrlib/GRRLIB_settings.h b/GRRLIB/GRRLIB/grrlib/GRRLIB_settings.h index abac7b8..5b169df 100644 --- a/GRRLIB/GRRLIB/grrlib/GRRLIB_settings.h +++ b/GRRLIB/GRRLIB/grrlib/GRRLIB_settings.h @@ -102,10 +102,10 @@ void GRRLIB_SetColor (const u8 r, const u8 g, const u8 b) { */ INLINE void GRRLIB_SetColorRGBA (const u32 color) { - GRRLIB_Settings.colorR = R(color); - GRRLIB_Settings.colorG = G(color); - GRRLIB_Settings.colorB = B(color); - GRRLIB_Settings.colorA = A(color); + GRRLIB_Settings.colorR = R(color); + GRRLIB_Settings.colorG = G(color); + GRRLIB_Settings.colorB = B(color); + GRRLIB_Settings.colorA = A(color); GRRLIB_Settings.colorRGBA = color; } diff --git a/examples/lesson1/source/main.c b/examples/lesson1/source/main.c index 2e1bab8..b973a35 100644 --- a/examples/lesson1/source/main.c +++ b/examples/lesson1/source/main.c @@ -106,14 +106,17 @@ int main() { switch(page) { case 1: // Draw images - GRRLIB_Printf(5, 25, tex_BMfont2, GRRLIB_WHITE, 1, "IMAGES DEMO"); + GRRLIB_ResetSettings(); + GRRLIB_Printf(5, 25, tex_BMfont2, "IMAGES DEMO"); - GRRLIB_DrawImg(10, 50, tex_test_jpg, 0, 1, 1, GRRLIB_WHITE); // Draw a jpeg - GRRLIB_DrawImg(350, 50, tex_test_bmp, 0, 4, 4, GRRLIB_WHITE); // Draw a bitmap + GRRLIB_DrawImg(10, 50, tex_test_jpg); // Draw a jpeg + GRRLIB_SetScale(4, 4); + GRRLIB_DrawImg(350, 50, tex_test_bmp); // Draw a bitmap // Draw a sprite - GRRLIB_DrawTile(600, 400, tex_sprite_png, 0, 2, 2, GRRLIB_WHITE, 12*4); // Rupee - GRRLIB_DrawTile(320+left, 240+top, tex_sprite_png, 0, 2, 2, GRRLIB_WHITE, frame); + GRRLIB_SetScale(2, 2); + GRRLIB_DrawTile(600, 400, tex_sprite_png, 12*4); // Rupee + GRRLIB_DrawTile(320+left, 240+top, tex_sprite_png, frame); if(GRRLIB_RectOnRect(320+left, 240+top, 48, 64, 618, 434, 12, 30)) { WPAD_Rumble(WPAD_CHAN_0, 1); @@ -140,33 +143,47 @@ int main() { } break; case 2: // Draw shapes - GRRLIB_Printf(5, 25, tex_BMfont2, GRRLIB_WHITE, 1, "SHAPES DEMO"); + GRRLIB_ResetSettings(); + GRRLIB_Printf(5, 25, tex_BMfont2, "SHAPES DEMO"); - GRRLIB_Rectangle(100, 100, 200, 100, GRRLIB_RED, 1); - GRRLIB_Line(100, 100, 350, 200, GRRLIB_SILVER); + GRRLIB_SetColorRGBA(GRRLIB_RED); + GRRLIB_Rectangle(100, 100, 200, 100, 1); + GRRLIB_SetColorRGBA(GRRLIB_SILVER); + GRRLIB_Line(100, 100, 350, 200); GRRLIB_NGoneFilled(triangle, trianglecolor, 3); - GRRLIB_Rectangle(left + 150, top + 150, 200, 200, 0x0000FFC8, 1); // Blue with alpha + GRRLIB_SetColorRGBA(0x0000FFC8); // Blue with alpha + GRRLIB_Rectangle(left + 150, top + 150, 200, 200, 1); + GRRLIB_SetColorRGBA(GRRLIB_OLIVE); GRRLIB_Circle(left + 300, top + 300, 50, GRRLIB_OLIVE, 1); // Draw a yellow four pixel dot where the wiimote is pointing - GRRLIB_Plot(ir1.sx, ir1.sy, GRRLIB_YELLOW); - GRRLIB_Plot(ir1.sx + 1, ir1.sy, GRRLIB_YELLOW); - GRRLIB_Plot(ir1.sx, ir1.sy + 1, GRRLIB_YELLOW); - GRRLIB_Plot(ir1.sx + 1, ir1.sy + 1, GRRLIB_YELLOW); + GRRLIB_SetColorRGBA(GRRLIB_YELLOW); + GRRLIB_Plot(ir1.sx, ir1.sy); + GRRLIB_Plot(ir1.sx + 1, ir1.sy); + GRRLIB_Plot(ir1.sx, ir1.sy + 1); + GRRLIB_Plot(ir1.sx + 1, ir1.sy + 1); break; default: // Print some text - GRRLIB_Printf(5, 25, tex_BMfont2, GRRLIB_WHITE, 1, "TEXT DEMO"); + GRRLIB_ResetSettings(); + GRRLIB_Printf(5, 25, tex_BMfont2, "TEXT DEMO"); - GRRLIB_Printf(5, 100, tex_BMfont4, GRRLIB_WHITE, 1, "TO QUIT PRESS THE HOME BUTTON."); - GRRLIB_Printf(5, 140, tex_BMfont4, GRRLIB_YELLOW, 1, "USE + OR - TO MOVE ACROSS PAGES."); - GRRLIB_Printf(5, 180, tex_BMfont4, GRRLIB_GREEN, 1, "USE THE D-PAD TO MOVE STUFF."); - GRRLIB_Printf(left, top+250, tex_BMfont1, GRRLIB_WHITE, 1, "IR X VALUE: %d", (int)ir1.x); - GRRLIB_Printf(left, top+300, tex_BMfont3, GRRLIB_WHITE, 1, "IR Y VALUE: %d", (int)ir1.y); - GRRLIB_Printf(left, top+350, tex_BMfont3, 0XFFFFFF50, 1, "TEXT WITH ALPHA"); - GRRLIB_Printf(left, top+400, tex_BMfont5, GRRLIB_LIME, 1, "This font has the 128 ASCII characters"); + GRRLIB_Printf(5, 100, tex_BMfont4, "TO QUIT PRESS THE HOME BUTTON."); + GRRLIB_SetColorRGBA(GRRLIB_YELLOW); + GRRLIB_Printf(5, 140, tex_BMfont4, "USE + OR - TO MOVE ACROSS PAGES."); + GRRLIB_SetColorRGBA(GRRLIB_GREEN); + GRRLIB_Printf(5, 180, tex_BMfont4, "USE THE D-PAD TO MOVE STUFF."); + GRRLIB_SetColorRGBA(GRRLIB_WHITE); + GRRLIB_Printf(left, top+250, tex_BMfont1, "IR X VALUE: %d", (int)ir1.x); + GRRLIB_Printf(left, top+300, tex_BMfont3, "IR Y VALUE: %d", (int)ir1.y); + GRRLIB_SetColorRGBA(0XFFFFFF50); + GRRLIB_Printf(left, top+350, tex_BMfont3, "TEXT WITH ALPHA"); + GRRLIB_SetColorRGBA(GRRLIB_LIME); + GRRLIB_Printf(left, top+400, tex_BMfont5, "This font has the 128 ASCII characters"); + GRRLIB_SetColorRGBA(GRRLIB_WHITE); GRRLIB_PrintBMF(left, top+420, bmf_Font2, 1, "%s", bmf_Font2->name); } - GRRLIB_Printf(500, 27, tex_BMfont5, GRRLIB_WHITE, 1, "Current FPS: %d", FPS); + GRRLIB_ResetSettings(); + GRRLIB_Printf(500, 27, tex_BMfont5, "Current FPS: %d", FPS); GRRLIB_Render(); FPS = CalculateFrameRate();