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) {