Merge branch 'c-warnings'

This commit is contained in:
Crayon2000 2024-02-11 14:12:17 -05:00
commit e5ae898ff1
18 changed files with 61 additions and 74 deletions

View file

@ -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;
@ -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);

View file

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

View file

@ -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);

View file

@ -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;
@ -48,7 +48,6 @@ bool GRRLIB_GeckoInit() {
* @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);

View file

@ -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
@ -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;
@ -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;

View file

@ -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;
}
@ -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;

View file

@ -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);

View file

@ -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__

View file

@ -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;

View file

@ -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).

View file

@ -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,11 +240,11 @@ 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;
u32 currentTime = ticks_to_millisecs(gettime());
const u32 currentTime = ticks_to_millisecs(gettime());
frameCount++;
if(currentTime - lastTime > 1000) {

View file

@ -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);

View file

@ -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]);

View file

@ -50,14 +50,13 @@
#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;
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)
@ -217,11 +216,11 @@ 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;
u32 currentTime = ticks_to_millisecs(gettime());
const u32 currentTime = ticks_to_millisecs(gettime());
frameCount++;
if(currentTime - lastTime > 1000) {

View file

@ -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);

View file

@ -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,11 +98,11 @@ 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;
u32 currentTime = ticks_to_millisecs(gettime());
const u32 currentTime = ticks_to_millisecs(gettime());
frameCount++;
if(currentTime - lastTime > 1000) {

View file

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

View file

@ -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,11 +104,11 @@ 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;
u32 currentTime = ticks_to_millisecs(gettime());
const u32 currentTime = ticks_to_millisecs(gettime());
frameCount++;
if(currentTime - lastTime > 1000) {
@ -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);