From 44616e89b414be2648dd9c358b7b1034f684cd5d Mon Sep 17 00:00:00 2001 From: Crayon2000 Date: Thu, 8 Feb 2024 01:41:17 -0500 Subject: [PATCH 1/3] Fix some C compiler warnings --- GRRLIB/GRRLIB/GRRLIB_3D.c | 16 ++++++++-------- GRRLIB/GRRLIB/GRRLIB_gecko.c | 6 +++--- GRRLIB/GRRLIB/GRRLIB_texEdit.c | 4 ++-- GRRLIB/GRRLIB/GRRLIB_ttf.c | 4 ++-- GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h | 6 +++--- GRRLIB/GRRLIB/grrlib/GRRLIB_private.h | 6 +++--- examples/basic_drawing/source/main.c | 9 ++++----- examples/bitmap_fx/source/main.c | 3 +-- examples/blending/source/main.c | 4 ++-- examples/gamecube/basic_drawing/source/main.c | 4 ++-- examples/gamecube/ttf/source/main.c | 4 ++-- examples/ttf/source/main.c | 8 ++++---- 12 files changed, 36 insertions(+), 38 deletions(-) diff --git a/GRRLIB/GRRLIB/GRRLIB_3D.c b/GRRLIB/GRRLIB/GRRLIB_3D.c index e7a8f5c..7109185 100644 --- a/GRRLIB/GRRLIB/GRRLIB_3D.c +++ b/GRRLIB/GRRLIB/GRRLIB_3D.c @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------------ -Copyright (c) 2009-2022 The GRRLIB Team +Copyright (c) 2009-2024 The GRRLIB Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -26,12 +26,12 @@ THE SOFTWARE. // User should not directly modify these Mtx _GRR_view; // Should be static as soon as all light functions needing this var will be in this file ;) -static guVector _GRR_cam = {0.0f, 0.0f, 0.0f}, - _GRR_up = {0.0f, 1.0f, 0.0f}, - _GRR_look = {0.0f, 0.0f, -100.0f}; -static guVector _GRRaxisx = (guVector){1, 0, 0}; // DO NOT MODIFY!!! -static guVector _GRRaxisy = (guVector){0, 1, 0}; // Even at runtime -static guVector _GRRaxisz = (guVector){0, 0, 1}; // NOT ever! +static guVector _GRR_cam = {0.0f, 0.0f, 0.0f}; +static guVector _GRR_up = {0.0f, 1.0f, 0.0f}; +static guVector _GRR_look = {0.0f, 0.0f, -100.0f}; +static guVector _GRRaxisx = (guVector){1.0f, 0.0f, 0.0f}; // DO NOT MODIFY!!! +static guVector _GRRaxisy = (guVector){0.0f, 1.0f, 0.0f}; // Even at runtime +static guVector _GRRaxisz = (guVector){0.0f, 0.0f, 1.0f}; // NOT ever! static Mtx _ObjTransformationMtx; /** @@ -122,7 +122,7 @@ void GRRLIB_3dMode(f32 minDist, f32 maxDist, f32 fov, bool texturemode, bool nor /** * Go back to 2D mode (contributed by chris_c aka DaShAmAn). */ -void GRRLIB_2dMode() { +void GRRLIB_2dMode(void) { Mtx view; Mtx44 m; diff --git a/GRRLIB/GRRLIB/GRRLIB_gecko.c b/GRRLIB/GRRLIB/GRRLIB_gecko.c index 8e004e4..3351379 100644 --- a/GRRLIB/GRRLIB/GRRLIB_gecko.c +++ b/GRRLIB/GRRLIB/GRRLIB_gecko.c @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------------ -Copyright (c) 2009-2019 The GRRLIB Team +Copyright (c) 2009-2024 The GRRLIB Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -30,8 +30,8 @@ static bool geckoinit = false; * Initialize USB Gecko. * @return Returns @c true if everything worked, @c false if problems occurred. */ -bool GRRLIB_GeckoInit() { - s32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1); +bool GRRLIB_GeckoInit(void) { + const s32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1); if (geckoattached) { usb_flush(EXI_CHANNEL_1); geckoinit = true; diff --git a/GRRLIB/GRRLIB/GRRLIB_texEdit.c b/GRRLIB/GRRLIB/GRRLIB_texEdit.c index c0a8472..7b7c607 100644 --- a/GRRLIB/GRRLIB/GRRLIB_texEdit.c +++ b/GRRLIB/GRRLIB/GRRLIB_texEdit.c @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------------ -Copyright (c) 2009-2022 The GRRLIB Team +Copyright (c) 2009-2024 The GRRLIB Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -377,7 +377,7 @@ GRRLIB_texImg* GRRLIB_LoadTextureJPGEx (const u8 *my_jpg, const u32 my_size) { jpeg_create_decompress(&cinfo); cinfo.err = jpeg_std_error(&jerr); cinfo.progress = NULL; - jpeg_mem_src(&cinfo, (unsigned char *)my_jpg, my_size); + jpeg_mem_src(&cinfo, (const unsigned char *)my_jpg, my_size); jpeg_read_header(&cinfo, TRUE); if (cinfo.jpeg_color_space == JCS_GRAYSCALE) { cinfo.out_color_space = JCS_RGB; diff --git a/GRRLIB/GRRLIB/GRRLIB_ttf.c b/GRRLIB/GRRLIB/GRRLIB_ttf.c index 5977383..df56d29 100644 --- a/GRRLIB/GRRLIB/GRRLIB_ttf.c +++ b/GRRLIB/GRRLIB/GRRLIB_ttf.c @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------------ -Copyright (c) 2009-2023 The GRRLIB Team +Copyright (c) 2009-2024 The GRRLIB Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -36,7 +36,7 @@ static void DrawBitmap(FT_Bitmap *bitmap, int offset, int top, const u8 cR, cons * Initialize FreeType library. * @return int 0=OK; -1=Failed */ -int GRRLIB_InitTTF () { +int GRRLIB_InitTTF (void) { if (FT_Init_FreeType(&ftLibrary) != 0) { return -1; } diff --git a/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h b/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h index f02a996..ad30218 100644 --- a/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h +++ b/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------------ -Copyright (c) 2009-2022 The GRRLIB Team +Copyright (c) 2009-2024 The GRRLIB Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -144,7 +144,7 @@ GRRLIB_texImg* GRRLIB_LoadTextureBMP (const u8 *my_bmp); //------------------------------------------------------------------------------ // GRRLIB_gecko.c - USB_Gecko output facilities -bool GRRLIB_GeckoInit(); +bool GRRLIB_GeckoInit(void); void GRRLIB_GeckoPrintf (const char *text, ...); //------------------------------------------------------------------------------ @@ -152,7 +152,7 @@ void GRRLIB_GeckoPrintf (const char *text, ...); void GRRLIB_SetBackgroundColour(u8 r, u8 g, u8 b, u8 a); void GRRLIB_Camera3dSettings(f32 posx, f32 posy, f32 posz, f32 upx, f32 upy, f32 upz, f32 lookx, f32 looky, f32 lookz); void GRRLIB_3dMode(f32 minDist, f32 maxDist, f32 fov, bool texturemode, bool normalmode); -void GRRLIB_2dMode(); +void GRRLIB_2dMode(void); void GRRLIB_ObjectViewBegin(void); void GRRLIB_ObjectViewScale(f32 scalx, f32 scaly, f32 scalz); void GRRLIB_ObjectViewRotate(f32 angx, f32 angy, f32 angz); diff --git a/GRRLIB/GRRLIB/grrlib/GRRLIB_private.h b/GRRLIB/GRRLIB/grrlib/GRRLIB_private.h index cfd4720..d2013e5 100644 --- a/GRRLIB/GRRLIB/grrlib/GRRLIB_private.h +++ b/GRRLIB/GRRLIB/grrlib/GRRLIB_private.h @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------------ -Copyright (c) 2009-2017 The GRRLIB Team +Copyright (c) 2009-2024 The GRRLIB Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -44,7 +44,7 @@ THE SOFTWARE. //------------------------------------------------------------------------------ // GRRLIB_ttf.c - FreeType function for GRRLIB -int GRRLIB_InitTTF(); -void GRRLIB_ExitTTF(); +int GRRLIB_InitTTF(void); +void GRRLIB_ExitTTF(void); #endif // __GRRLIB_PRIVATE_H__ diff --git a/examples/basic_drawing/source/main.c b/examples/basic_drawing/source/main.c index e5ed91a..e5dcbcf 100644 --- a/examples/basic_drawing/source/main.c +++ b/examples/basic_drawing/source/main.c @@ -51,7 +51,7 @@ #define GRRLIB_AQUA 0x00FFFFFF #define GRRLIB_WHITE 0xFFFFFFFF -static u8 CalculateFrameRate(); +static u8 CalculateFrameRate(void); int main() { s32 left = 0, top = 0, page = 0, frame = TILE_DOWN + 1; @@ -59,7 +59,6 @@ int main() { u8 FPS = 0; ir_t ir1; - u32 wpaddown, wpadheld; guVector triangle[] = {{400,200,0.0f}, {500,400,0.0f}, {300,400,0.0f}}; u32 trianglecolor[] = {GRRLIB_GREEN, GRRLIB_RED, GRRLIB_BLUE}; @@ -95,8 +94,8 @@ int main() { while(1) { WPAD_SetVRes(0, 640, 480); WPAD_ScanPads(); - wpaddown = WPAD_ButtonsDown(0); - wpadheld = WPAD_ButtonsHeld(0); + const u32 wpaddown = WPAD_ButtonsDown(0); + const u32 wpadheld = WPAD_ButtonsHeld(0); WPAD_IR(WPAD_CHAN_0, &ir1); @@ -241,7 +240,7 @@ int main() { * This function calculates the number of frames we render each second. * @return The number of frames per second. */ -static u8 CalculateFrameRate() { +static u8 CalculateFrameRate(void) { static u8 frameCount = 0; static u32 lastTime; static u8 FPS = 0; diff --git a/examples/bitmap_fx/source/main.c b/examples/bitmap_fx/source/main.c index 7bf57b6..6c12b9d 100644 --- a/examples/bitmap_fx/source/main.c +++ b/examples/bitmap_fx/source/main.c @@ -14,7 +14,6 @@ int main() { - u32 wpaddown; s8 page = 0; // Font texture @@ -115,7 +114,7 @@ int main() { while(1) { WPAD_ScanPads(); - wpaddown = WPAD_ButtonsDown(0); + const u32 wpaddown = WPAD_ButtonsDown(0); GRRLIB_FillScreen(0xFFFFFFFF); diff --git a/examples/blending/source/main.c b/examples/blending/source/main.c index f4d5a2f..84825cd 100644 --- a/examples/blending/source/main.c +++ b/examples/blending/source/main.c @@ -19,7 +19,7 @@ #include "RGFX_Font_png.h" // Declare Static Functions -static void ExitGame(); +static void ExitGame(void); // Prepare Graphics GRRLIB_texImg *GFX_Background; @@ -160,7 +160,7 @@ int main() { return 0; } -static void ExitGame() { +static void ExitGame(void) { // Free all memory used by textures. GRRLIB_FreeTexture(GFX_Background); GRRLIB_FreeTexture(GFX_Blob[0]); diff --git a/examples/gamecube/basic_drawing/source/main.c b/examples/gamecube/basic_drawing/source/main.c index be86c89..8fa7caf 100644 --- a/examples/gamecube/basic_drawing/source/main.c +++ b/examples/gamecube/basic_drawing/source/main.c @@ -50,7 +50,7 @@ #define GRRLIB_AQUA 0x00FFFFFF #define GRRLIB_WHITE 0xFFFFFFFF -static u8 CalculateFrameRate(); +static u8 CalculateFrameRate(void); int main() { s32 left = 0, top = 0, page = 0, frame = TILE_DOWN + 1; @@ -217,7 +217,7 @@ int main() { * This function calculates the number of frames we render each second. * @return The number of frames per second. */ -static u8 CalculateFrameRate() { +static u8 CalculateFrameRate(void) { static u8 frameCount = 0; static u32 lastTime; static u8 FPS = 0; diff --git a/examples/gamecube/ttf/source/main.c b/examples/gamecube/ttf/source/main.c index f838320..eda4c93 100644 --- a/examples/gamecube/ttf/source/main.c +++ b/examples/gamecube/ttf/source/main.c @@ -12,7 +12,7 @@ #include "FreeMonoBold_ttf.h" // Prototype -static u8 CalculateFrameRate(); +static u8 CalculateFrameRate(void); int main(int argc, char **argv) { bool ShowFPS = false; @@ -98,7 +98,7 @@ int main(int argc, char **argv) { * This function calculates the number of frames we render each second. * @return The number of frames per second. */ -static u8 CalculateFrameRate() { +static u8 CalculateFrameRate(void) { static u8 frameCount = 0; static u32 lastTime; static u8 FPS = 0; diff --git a/examples/ttf/source/main.c b/examples/ttf/source/main.c index 0a7f7d6..03fbf7b 100644 --- a/examples/ttf/source/main.c +++ b/examples/ttf/source/main.c @@ -12,8 +12,8 @@ #include "FreeMonoBold_ttf.h" // Prototype -static u8 CalculateFrameRate(); -static bool ScreenShot(); +static u8 CalculateFrameRate(void); +static bool ScreenShot(void); int main(int argc, char **argv) { bool ShowFPS = false; @@ -104,7 +104,7 @@ int main(int argc, char **argv) { * This function calculates the number of frames we render each second. * @return The number of frames per second. */ -static u8 CalculateFrameRate() { +static u8 CalculateFrameRate(void) { static u8 frameCount = 0; static u32 lastTime; static u8 FPS = 0; @@ -123,7 +123,7 @@ static u8 CalculateFrameRate() { * Create a PNG screenshot on the root of the SD card with a timestamp. * @return bool true=everything worked, false=problems occurred. */ -static bool ScreenShot() { +static bool ScreenShot(void) { char path[255]; time_t now = time(NULL); struct tm *ti = localtime(&now); From 83ed32fad9848e416429f571d6848588a652912e Mon Sep 17 00:00:00 2001 From: Crayon2000 Date: Sat, 10 Feb 2024 14:15:46 -0500 Subject: [PATCH 2/3] Refactoring --- GRRLIB/GRRLIB/GRRLIB_3D.c | 13 ++++++------- GRRLIB/GRRLIB/GRRLIB_bmf.c | 2 +- examples/basic_drawing/source/main.c | 2 +- examples/gamecube/basic_drawing/source/main.c | 7 +++---- examples/gamecube/bitmap_fx/source/main.c | 3 +-- examples/gamecube/ttf/source/main.c | 2 +- examples/particle/source/main.cpp | 2 +- examples/ttf/source/main.c | 2 +- 8 files changed, 15 insertions(+), 18 deletions(-) diff --git a/GRRLIB/GRRLIB/GRRLIB_3D.c b/GRRLIB/GRRLIB/GRRLIB_3D.c index 7109185..b2b14fd 100644 --- a/GRRLIB/GRRLIB/GRRLIB_3D.c +++ b/GRRLIB/GRRLIB/GRRLIB_3D.c @@ -421,6 +421,8 @@ void GRRLIB_DrawTorus(f32 r, f32 R, int nsides, int rings, bool filled, u32 col) * @param col Color of the sphere. */ void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) { + const f32 dtheta = 2 * M_PI / longs; + for(int i = 0; i <= lats; i++) { const f32 lat0 = M_PI * (-0.5f + (f32) (i - 1) / lats); const f32 z0 = sinf(lat0); @@ -430,14 +432,11 @@ void GRRLIB_DrawSphere(f32 r, int lats, int longs, bool filled, u32 col) { const f32 z1 = sinf(lat1); const f32 zr1 = cosf(lat1); - if(filled == true) { - GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, 2 * (longs + 1)); - } - else { - GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (longs + 1)); - } + GX_Begin((filled == true) ? GX_TRIANGLESTRIP : GX_LINESTRIP, + GX_VTXFMT0, 2 * (longs + 1)); + for(int j = 0; j <= longs; j++) { - const f32 lng = 2 * M_PI * (f32) (j - 1) / longs; + const f32 lng = dtheta * (f32) (j - 1); const f32 x = cosf(lng); const f32 y = sinf(lng); diff --git a/GRRLIB/GRRLIB/GRRLIB_bmf.c b/GRRLIB/GRRLIB/GRRLIB_bmf.c index 7a88718..8102792 100644 --- a/GRRLIB/GRRLIB/GRRLIB_bmf.c +++ b/GRRLIB/GRRLIB/GRRLIB_bmf.c @@ -45,7 +45,7 @@ GRRLIB_bytemapFont* GRRLIB_LoadBMF (const u8 my_bmf[] ) { //short int sizeinner = my_bmf[9]; //u8 usedcolors = my_bmf[10]; //u8 highestcolor = my_bmf[11]; - u8 nbPalette = my_bmf[16]; + const u8 nbPalette = my_bmf[16]; const short int numcolpal = 3 * nbPalette; fontArray->palette = (u32 *)calloc(nbPalette + 1, sizeof(u32)); for (u32 i=0; i < numcolpal; i+=3) { diff --git a/examples/basic_drawing/source/main.c b/examples/basic_drawing/source/main.c index e5dcbcf..ebece40 100644 --- a/examples/basic_drawing/source/main.c +++ b/examples/basic_drawing/source/main.c @@ -244,7 +244,7 @@ static u8 CalculateFrameRate(void) { static u8 frameCount = 0; static u32 lastTime; static u8 FPS = 0; - u32 currentTime = ticks_to_millisecs(gettime()); + const u32 currentTime = ticks_to_millisecs(gettime()); frameCount++; if(currentTime - lastTime > 1000) { diff --git a/examples/gamecube/basic_drawing/source/main.c b/examples/gamecube/basic_drawing/source/main.c index 8fa7caf..898c392 100644 --- a/examples/gamecube/basic_drawing/source/main.c +++ b/examples/gamecube/basic_drawing/source/main.c @@ -57,7 +57,6 @@ int main() { u32 wait = TILE_DELAY, direction = TILE_DOWN, direction_new = TILE_DOWN; u8 FPS = 0; - u32 paddown, padheld; guVector triangle[] = {{400,200,0.0f}, {500,400,0.0f}, {300,400,0.0f}}; u32 trianglecolor[] = {GRRLIB_GREEN, GRRLIB_RED, GRRLIB_BLUE}; @@ -91,8 +90,8 @@ int main() { while(1) { PAD_ScanPads(); - paddown = PAD_ButtonsDown(0); - padheld = PAD_ButtonsHeld(0); + const u32 paddown = PAD_ButtonsDown(0); + const u32 padheld = PAD_ButtonsHeld(0); GRRLIB_FillScreen(GRRLIB_BLACK); // Clear the screen switch(page) @@ -221,7 +220,7 @@ static u8 CalculateFrameRate(void) { static u8 frameCount = 0; static u32 lastTime; static u8 FPS = 0; - u32 currentTime = ticks_to_millisecs(gettime()); + const u32 currentTime = ticks_to_millisecs(gettime()); frameCount++; if(currentTime - lastTime > 1000) { diff --git a/examples/gamecube/bitmap_fx/source/main.c b/examples/gamecube/bitmap_fx/source/main.c index b0355d5..7e741b1 100644 --- a/examples/gamecube/bitmap_fx/source/main.c +++ b/examples/gamecube/bitmap_fx/source/main.c @@ -14,7 +14,6 @@ int main() { - u32 paddown; s8 page = 0; // Font texture @@ -115,7 +114,7 @@ int main() { while(1) { PAD_ScanPads(); - paddown = PAD_ButtonsDown(0); + const u32 paddown = PAD_ButtonsDown(0); GRRLIB_FillScreen(0xFFFFFFFF); diff --git a/examples/gamecube/ttf/source/main.c b/examples/gamecube/ttf/source/main.c index eda4c93..29777c4 100644 --- a/examples/gamecube/ttf/source/main.c +++ b/examples/gamecube/ttf/source/main.c @@ -102,7 +102,7 @@ static u8 CalculateFrameRate(void) { static u8 frameCount = 0; static u32 lastTime; static u8 FPS = 0; - u32 currentTime = ticks_to_millisecs(gettime()); + const u32 currentTime = ticks_to_millisecs(gettime()); frameCount++; if(currentTime - lastTime > 1000) { diff --git a/examples/particle/source/main.cpp b/examples/particle/source/main.cpp index 37318f0..c1ef9dc 100644 --- a/examples/particle/source/main.cpp +++ b/examples/particle/source/main.cpp @@ -262,7 +262,7 @@ static u8 CalculateFrameRate() { static u8 frameCount = 0; static u32 lastTime; static u8 FPS = 0; - u32 currentTime = ticks_to_millisecs(gettime()); + const u32 currentTime = ticks_to_millisecs(gettime()); frameCount++; if(currentTime - lastTime > 1000) { diff --git a/examples/ttf/source/main.c b/examples/ttf/source/main.c index 03fbf7b..671955b 100644 --- a/examples/ttf/source/main.c +++ b/examples/ttf/source/main.c @@ -108,7 +108,7 @@ static u8 CalculateFrameRate(void) { static u8 frameCount = 0; static u32 lastTime; static u8 FPS = 0; - u32 currentTime = ticks_to_millisecs(gettime()); + const u32 currentTime = ticks_to_millisecs(gettime()); frameCount++; if(currentTime - lastTime > 1000) { From 30b5aeb705371c8ca9b2b2b2219bde12ce3b519b Mon Sep 17 00:00:00 2001 From: Crayon2000 Date: Sun, 11 Feb 2024 14:01:37 -0500 Subject: [PATCH 3/3] Refactoring --- GRRLIB/GRRLIB/GRRLIB_fileIO.c | 10 ++++------ GRRLIB/GRRLIB/GRRLIB_gecko.c | 3 +-- GRRLIB/GRRLIB/GRRLIB_texEdit.c | 2 +- GRRLIB/GRRLIB/GRRLIB_ttf.c | 3 +-- GRRLIB/lib/pngu/pngu.c | 8 ++------ GRRLIB/lib/pngu/pngu.h | 2 +- 6 files changed, 10 insertions(+), 18 deletions(-) diff --git a/GRRLIB/GRRLIB/GRRLIB_fileIO.c b/GRRLIB/GRRLIB/GRRLIB_fileIO.c index 642fd32..1df4244 100644 --- a/GRRLIB/GRRLIB/GRRLIB_fileIO.c +++ b/GRRLIB/GRRLIB/GRRLIB_fileIO.c @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------------ -Copyright (c) 2009-2022 The GRRLIB Team +Copyright (c) 2009-2024 The GRRLIB Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -78,7 +78,6 @@ int GRRLIB_LoadFile(const char* filename, u8* *data) { * If an error occurs NULL will be returned. */ GRRLIB_texImg* GRRLIB_LoadTextureFromFile(const char *filename) { - GRRLIB_texImg *tex; u8 *data; // Return NULL if load fails @@ -87,7 +86,7 @@ GRRLIB_texImg* GRRLIB_LoadTextureFromFile(const char *filename) { } // Convert to texture - tex = GRRLIB_LoadTexture(data); + GRRLIB_texImg *tex = GRRLIB_LoadTexture(data); // Free up the buffer free(data); @@ -102,10 +101,9 @@ GRRLIB_texImg* GRRLIB_LoadTextureFromFile(const char *filename) { * If an error occurs NULL will be returned. */ GRRLIB_ttfFont* GRRLIB_LoadTTFFromFile(const char *filename) { - GRRLIB_ttfFont *ttf; u8 *data; - s32 size = GRRLIB_LoadFile(filename, &data); + const s32 size = GRRLIB_LoadFile(filename, &data); // Return NULL if load fails if (size <= 0) { @@ -113,7 +111,7 @@ GRRLIB_ttfFont* GRRLIB_LoadTTFFromFile(const char *filename) { } // Convert to TTF - ttf = GRRLIB_LoadTTF(data, size); + GRRLIB_ttfFont *ttf = GRRLIB_LoadTTF(data, size); // Free up the buffer free(data); diff --git a/GRRLIB/GRRLIB/GRRLIB_gecko.c b/GRRLIB/GRRLIB/GRRLIB_gecko.c index 3351379..5b5d4eb 100644 --- a/GRRLIB/GRRLIB/GRRLIB_gecko.c +++ b/GRRLIB/GRRLIB/GRRLIB_gecko.c @@ -48,7 +48,6 @@ bool GRRLIB_GeckoInit(void) { * @param ... Optional arguments. */ void GRRLIB_GeckoPrintf (const char *text, ...) { - int size; char tmp[1024]; if (geckoinit == false) { @@ -57,7 +56,7 @@ void GRRLIB_GeckoPrintf (const char *text, ...) { va_list argp; va_start(argp, text); - size = vsnprintf(tmp, sizeof(tmp), text, argp); + const int size = vsnprintf(tmp, sizeof(tmp), text, argp); va_end(argp); usb_sendbuffer_safe(1, tmp, size); diff --git a/GRRLIB/GRRLIB/GRRLIB_texEdit.c b/GRRLIB/GRRLIB/GRRLIB_texEdit.c index 7b7c607..1ad1fa1 100644 --- a/GRRLIB/GRRLIB/GRRLIB_texEdit.c +++ b/GRRLIB/GRRLIB/GRRLIB_texEdit.c @@ -160,7 +160,7 @@ GRRLIB_texImg* GRRLIB_LoadTexturePNG (const u8 *my_png) { PNGUPROP imgProp; IMGCTX ctx = PNGU_SelectImageFromBuffer(my_png); PNGU_GetImageProperties(ctx, &imgProp); - my_texture->data = PNGU_DecodeTo4x4RGBA8(ctx, imgProp.imgWidth, imgProp.imgHeight, &width, &height, NULL); + my_texture->data = PNGU_DecodeTo4x4RGBA8(ctx, imgProp.imgWidth, imgProp.imgHeight, &width, &height); if (my_texture->data != NULL) { my_texture->w = width; my_texture->h = height; diff --git a/GRRLIB/GRRLIB/GRRLIB_ttf.c b/GRRLIB/GRRLIB/GRRLIB_ttf.c index df56d29..82715c2 100644 --- a/GRRLIB/GRRLIB/GRRLIB_ttf.c +++ b/GRRLIB/GRRLIB/GRRLIB_ttf.c @@ -131,7 +131,6 @@ void GRRLIB_PrintfTTFW(int x, int y, GRRLIB_ttfFont *myFont, const wchar_t *utf3 int penX = 0; int penY = fontSize; FT_GlyphSlot slot = Face->glyph; - FT_UInt glyphIndex; FT_UInt previousGlyph = 0; const u8 cR = R(color); const u8 cG = G(color); @@ -145,7 +144,7 @@ void GRRLIB_PrintfTTFW(int x, int y, GRRLIB_ttfFont *myFont, const wchar_t *utf3 /* Loop over each character, until the * end of the string is reached, or until the pixel width is too wide */ while(*utf32) { - glyphIndex = FT_Get_Char_Index(myFont->face, *utf32++); + const FT_UInt glyphIndex = FT_Get_Char_Index(myFont->face, *utf32++); if (myFont->kerning && previousGlyph && glyphIndex) { FT_Vector delta; diff --git a/GRRLIB/lib/pngu/pngu.c b/GRRLIB/lib/pngu/pngu.c index 72d50f7..fe14ada 100644 --- a/GRRLIB/lib/pngu/pngu.c +++ b/GRRLIB/lib/pngu/pngu.c @@ -564,10 +564,9 @@ static inline PNGU_u32 coordsRGBA8(PNGU_u32 x, PNGU_u32 y, PNGU_u32 w) } // Coded by Tantric for WiiMC (http://www.wiimc.org) -PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, int * dstWidth, int * dstHeight, PNGU_u8 *dstPtr) +PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, int * dstWidth, int * dstHeight) { PNGU_u8 default_alpha = 255; // default alpha value, which is used if the source image doesn't have an alpha channel. - PNGU_u8 *dst; int x, y, x2=0, y2=0, offset; int xRatio = 0, yRatio = 0; png_byte *pixel; @@ -604,10 +603,7 @@ PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, in int len = (padWidth * padHeight) << 2; if(len%32) len += (32-len%32); - if(dstPtr) - dst = dstPtr; // use existing allocation - else - dst = memalign (32, len); + PNGU_u8 *dst = memalign (32, len); if(!dst) return NULL; diff --git a/GRRLIB/lib/pngu/pngu.h b/GRRLIB/lib/pngu/pngu.h index 7c0a733..3340f5f 100644 --- a/GRRLIB/lib/pngu/pngu.h +++ b/GRRLIB/lib/pngu/pngu.h @@ -151,7 +151,7 @@ int PNGU_DecodeTo4x4RGB5A3 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *b // Expands selected image into a 4x4 tiled RGBA8 buffer. You need to specify context, image dimensions, // destination address. -PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, int * dstWidth, int * dstHeight, PNGU_u8 *dstPtr); +PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, int * dstWidth, int * dstHeight); // Encodes an YCbYCr image in PNG format and stores it in the selected device or memory buffer. You need to // specify context, image dimensions, destination address and stride in pixels (stride = buffer width - image width).