Format code

This commit is contained in:
Crayon2000 2020-01-13 14:41:26 -05:00
parent 0d76531301
commit 9bc3664484
8 changed files with 23 additions and 23 deletions

View file

@ -93,7 +93,7 @@ All notable changes to this project will be documented in this file.
## 4.0.0 - 2009-03-05 ## 4.0.0 - 2009-03-05
- Color format changed to RGBA for ALL GRRLib functions to fit to GX_Color format and use `GX_Color1u32` - Color format changed to RGBA for ALL GRRLib functions to fit to `GXColor` format and use `GX_Color1u32`
- `GRRLIB_LoadTexture()` now auto detect PNG or JPEG - `GRRLIB_LoadTexture()` now auto detect PNG or JPEG
- GRRLib introduce a new texture structure (easier to handle texture width, height, etc ...) - GRRLib introduce a new texture structure (easier to handle texture width, height, etc ...)
- Add `GRRLIB_InitTileSet()` to initialize a tile set - Add `GRRLIB_InitTileSet()` to initialize a tile set

View file

@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
Copyright (c) 2009-2019 The GRRLIB Team Copyright (c) 2009-2020 The GRRLIB Team
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -94,24 +94,24 @@ void GRRLIB_3dMode(f32 minDist, f32 maxDist, f32 fov, bool texturemode, bool nor
GX_ClearVtxDesc(); GX_ClearVtxDesc();
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
if(normalmode) { if(normalmode == true) {
GX_SetVtxDesc(GX_VA_NRM, GX_DIRECT); GX_SetVtxDesc(GX_VA_NRM, GX_DIRECT);
} }
GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT); GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
if(texturemode) { if(texturemode == true) {
GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);
} }
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
if(normalmode) { if(normalmode == true) {
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_F32, 0);
} }
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
if(texturemode) { if(texturemode == true) {
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
} }
if(texturemode) { if(texturemode == true) {
GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE); GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
} }
else { else {
@ -342,7 +342,7 @@ void GRRLIB_ObjectViewInv(f32 posx, f32 posy, f32 posz, f32 angx, f32 angy, f32
void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep) { void GRRLIB_SetTexture(GRRLIB_texImg *tex, bool rep) {
GXTexObj texObj; GXTexObj texObj;
if (rep) { if (rep == true) {
GX_InitTexObj(&texObj, tex->data, tex->w, tex->h, GX_TF_RGBA8, GX_REPEAT, GX_REPEAT, GX_FALSE); GX_InitTexObj(&texObj, tex->data, tex->w, tex->h, GX_TF_RGBA8, GX_REPEAT, GX_REPEAT, GX_FALSE);
} }
else { else {
@ -540,7 +540,7 @@ void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
else { else {
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (d+1)); GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (d+1));
} }
for(i = 0 ; i <= d ; i++) { for(i = 0; i <= d; i++) {
dx = cosf( M_PI * 2.0f * i / d ); dx = cosf( M_PI * 2.0f * i / d );
dy = sinf( M_PI * 2.0f * i / d ); dy = sinf( M_PI * 2.0f * i / d );
GX_Position3f32( r * dx, -0.5f * h, r * dy ); GX_Position3f32( r * dx, -0.5f * h, r * dy );
@ -561,7 +561,7 @@ void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
GX_Position3f32(0.0f, -0.5f * h, 0.0f); GX_Position3f32(0.0f, -0.5f * h, 0.0f);
GX_Normal3f32(0.0f, -1.0f, 0.0f); GX_Normal3f32(0.0f, -1.0f, 0.0f);
GX_Color1u32(col); GX_Color1u32(col);
for(i = 0 ; i <= d ; i++) { for(i = 0; i <= d; i++) {
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), -0.5f * h, r * sinf( M_PI * 2.0f * i / d ) ); GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), -0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
GX_Normal3f32(0.0f, -1.0f, 0.0f); GX_Normal3f32(0.0f, -1.0f, 0.0f);
GX_Color1u32(col); GX_Color1u32(col);
@ -577,7 +577,7 @@ void GRRLIB_DrawCylinder(f32 r, f32 h, int d, bool filled, u32 col) {
GX_Position3f32(0.0f, 0.5f * h, 0.0f); GX_Position3f32(0.0f, 0.5f * h, 0.0f);
GX_Normal3f32(0.0f, 1.0f, 0.0f); GX_Normal3f32(0.0f, 1.0f, 0.0f);
GX_Color1u32(col); GX_Color1u32(col);
for(i = 0 ; i <= d ; i++) { for(i = 0; i <= d; i++) {
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), 0.5f * h, r * sinf( M_PI * 2.0f * i / d ) ); GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), 0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
GX_Normal3f32(0.0f, 1.0f, 0.0f); GX_Normal3f32(0.0f, 1.0f, 0.0f);
GX_Color1u32(col); GX_Color1u32(col);
@ -603,7 +603,7 @@ void GRRLIB_DrawCone(f32 r, f32 h, int d, bool filled, u32 col) {
else { else {
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (d+1)); GX_Begin(GX_LINESTRIP, GX_VTXFMT0, 2 * (d+1));
} }
for(i = 0 ; i <= d ; i++) { for(i = 0; i <= d; i++) {
dx = cosf( M_PI * 2.0f * i / d ); dx = cosf( M_PI * 2.0f * i / d );
dy = sinf( M_PI * 2.0f * i / d ); dy = sinf( M_PI * 2.0f * i / d );
GX_Position3f32( 0, -0.5f * h,0); GX_Position3f32( 0, -0.5f * h,0);
@ -624,7 +624,7 @@ void GRRLIB_DrawCone(f32 r, f32 h, int d, bool filled, u32 col) {
GX_Position3f32(0.0f, 0.5f * h, 0.0f); GX_Position3f32(0.0f, 0.5f * h, 0.0f);
GX_Normal3f32(0.0f, 1.0f, 0.0f); GX_Normal3f32(0.0f, 1.0f, 0.0f);
GX_Color1u32(col); GX_Color1u32(col);
for(i = 0 ; i <= d ; i++) { for(i = 0; i <= d; i++) {
GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), 0.5f * h, r * sinf( M_PI * 2.0f * i / d ) ); GX_Position3f32( r * cosf( M_PI * 2.0f * i / d ), 0.5f * h, r * sinf( M_PI * 2.0f * i / d ) );
GX_Normal3f32(0.0f, 1.0f, 0.0f); GX_Normal3f32(0.0f, 1.0f, 0.0f);
GX_Color1u32(col); GX_Color1u32(col);
@ -648,7 +648,7 @@ void GRRLIB_DrawTessPanel(f32 w, f32 wstep, f32 h, f32 hstep, bool filled, u32 c
tmpy = h/2.0f; tmpy = h/2.0f;
tmpx = w/2.0f; tmpx = w/2.0f;
tmp = ((w/wstep)*2)+2; tmp = ((w/wstep)*2)+2;
for ( y = -tmpy ; y <= tmpy ; y+=hstep ) for ( y = -tmpy; y <= tmpy; y += hstep )
{ {
if(filled == true) { if(filled == true) {
GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, tmp); GX_Begin(GX_TRIANGLESTRIP, GX_VTXFMT0, tmp);
@ -656,7 +656,7 @@ void GRRLIB_DrawTessPanel(f32 w, f32 wstep, f32 h, f32 hstep, bool filled, u32 c
else { else {
GX_Begin(GX_LINESTRIP, GX_VTXFMT0, tmp); GX_Begin(GX_LINESTRIP, GX_VTXFMT0, tmp);
} }
for ( x = -tmpx ; x <= tmpx ; x+=wstep ) for ( x = -tmpx; x <= tmpx; x += wstep )
{ {
GX_Position3f32( x, y, 0.0f ); GX_Position3f32( x, y, 0.0f );
GX_Normal3f32( 0.0f, 0.0f, 1.0f); GX_Normal3f32( 0.0f, 0.0f, 1.0f);

View file

@ -1,5 +1,5 @@
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
Copyright (c) 2009-2019 The GRRLIB Team Copyright (c) 2009-2020 The GRRLIB Team
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -211,7 +211,7 @@ GRR_EXTERN u32 fb GRR_INIT(0);
* @section Links * @section Links
* Forum: http://grrlib.santo.fr/forum\n * Forum: http://grrlib.santo.fr/forum\n
* Code: https://github.com/GRRLIB/GRRLIB\n * Code: https://github.com/GRRLIB/GRRLIB\n
* IRC: <a href="irc://irc.efnet.net/grrlib">\#GRRLIB</a> on EFnet * Chat: <a href="irc://irc.efnet.net/grrlib">\#GRRLIB</a> on EFnet
* *
* @section Credits * @section Credits
* Project Leader : NoNameNo\n * Project Leader : NoNameNo\n

View file

@ -167,8 +167,8 @@ int main() {
if((dirx==0) && (diry==0)) { if((dirx==0) && (diry==0)) {
if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_LEFT) { diry=-4; idperso=15;} if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_LEFT) { diry=-4; idperso=15;}
else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_RIGHT) { diry=4; idperso=15;} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_RIGHT) { diry=4; idperso=15;}
else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_DOWN) { dirx=-4 ; idperso=1;} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_DOWN) { dirx=-4; idperso=1;}
else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_UP) { dirx=4 ; idperso=8;} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_UP) { dirx=4; idperso=8;}
} }
if((dirx==0) && (diry==0)) { if((dirx==0) && (diry==0)) {

View file

@ -18,7 +18,7 @@
int main() { int main() {
float a=0; float a=0;
int cubeZ=5; int cubeZ=5;
int i=0; int i;
float sinx=0; float sinx=0;
GRRLIB_Init(); GRRLIB_Init();

View file

@ -13,7 +13,7 @@
#include "gfx/logo.h" #include "gfx/logo.h"
int main() { int main() {
int i=0; int i;
float a=0; float a=0;
u32 col; u32 col;

View file

@ -156,8 +156,8 @@ int main() {
if((dirx==0) && (diry==0)) { if((dirx==0) && (diry==0)) {
if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_LEFT) { diry=-4; idperso=15;} if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_LEFT) { diry=-4; idperso=15;}
else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_RIGHT) { diry=4; idperso=15;} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_RIGHT) { diry=4; idperso=15;}
else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_DOWN) { dirx=-4 ; idperso=1;} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_DOWN) { dirx=-4; idperso=1;}
else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_UP) { dirx=4 ; idperso=8;} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_UP) { dirx=4; idperso=8;}
} }
if((dirx==0) && (diry==0)) { if((dirx==0) && (diry==0)) {