mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-25 16:22:20 +00:00
[CHG] Code formatting and some doxygen comments
This commit is contained in:
parent
89e3071ffc
commit
f5d25a55a5
3 changed files with 316 additions and 256 deletions
|
@ -12,26 +12,47 @@
|
||||||
GXRModeObj *rmode;
|
GXRModeObj *rmode;
|
||||||
void *gp_fifo = NULL;
|
void *gp_fifo = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear screen with a specific color.
|
||||||
|
* @param color the color to use to fill the screen.
|
||||||
|
*/
|
||||||
inline void GRRLIB_FillScreen(u32 color){
|
inline void GRRLIB_FillScreen(u32 color){
|
||||||
GRRLIB_Rectangle(-40, -40, 680,520, color, 1);
|
GRRLIB_Rectangle(-40, -40, 680,520, color, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
inline void GRRLIB_Plot(f32 x,f32 y, u32 color){
|
inline void GRRLIB_Plot(f32 x,f32 y, u32 color){
|
||||||
Vector v[]={{x,y,0.0f}};
|
Vector v[]={{x,y,0.0f}};
|
||||||
|
|
||||||
GRRLIB_NPlot(v,color,1);
|
GRRLIB_NPlot(v,color,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
void GRRLIB_NPlot(Vector v[],u32 color,long n){
|
void GRRLIB_NPlot(Vector v[],u32 color,long n){
|
||||||
GRRLIB_GXEngine(v,color,n,GX_POINTS);
|
GRRLIB_GXEngine(v,color,n,GX_POINTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a line.
|
||||||
|
* @param x1 start point for line for the x coordinate.
|
||||||
|
* @param y1 start point for line for the y coordinate.
|
||||||
|
* @param x2 end point for line for the x coordinate.
|
||||||
|
* @param y2 end point for line for the x coordinate.
|
||||||
|
* @param color line color.
|
||||||
|
*/
|
||||||
inline void GRRLIB_Line(f32 x1, f32 y1, f32 x2, f32 y2, u32 color){
|
inline void GRRLIB_Line(f32 x1, f32 y1, f32 x2, f32 y2, u32 color){
|
||||||
Vector v[]={{x1,y1,0.0f},{x2,y2,0.0f}};
|
Vector v[]={{x1,y1,0.0f},{x2,y2,0.0f}};
|
||||||
|
|
||||||
GRRLIB_NGone(v,color,2);
|
GRRLIB_NGone(v,color,2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw a rectangle.
|
||||||
|
*/
|
||||||
inline void GRRLIB_Rectangle(f32 x, f32 y, f32 width, f32 height, u32 color, u8 filled){
|
inline void GRRLIB_Rectangle(f32 x, f32 y, f32 width, f32 height, u32 color, u8 filled){
|
||||||
Vector v[] = {{x,y,0.0f},{x+width,y,0.0f},{x+width,y+height,0.0f},{x,y+height,0.0f},{x,y,0.0f}};
|
Vector v[] = {{x,y,0.0f},{x+width,y,0.0f},{x+width,y+height,0.0f},{x,y+height,0.0f},{x,y,0.0f}};
|
||||||
|
|
||||||
|
@ -42,13 +63,24 @@ inline void GRRLIB_Rectangle(f32 x, f32 y, f32 width, f32 height, u32 color, u8
|
||||||
GRRLIB_NGoneFilled(v,color,4);
|
GRRLIB_NGoneFilled(v,color,4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
void GRRLIB_NGone(Vector v[],u32 color,long n){
|
void GRRLIB_NGone(Vector v[],u32 color,long n){
|
||||||
GRRLIB_GXEngine(v,color,n,GX_LINESTRIP);
|
GRRLIB_GXEngine(v,color,n,GX_LINESTRIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
void GRRLIB_NGoneFilled(Vector v[],u32 color,long n){
|
void GRRLIB_NGoneFilled(Vector v[],u32 color,long n){
|
||||||
GRRLIB_GXEngine(v,color,n,GX_TRIANGLEFAN);
|
GRRLIB_GXEngine(v,color,n,GX_TRIANGLEFAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
void GRRLIB_InitTileSet(struct GRRLIB_texImg *tex, unsigned int tilew, unsigned int tileh, unsigned int tilestart){
|
void GRRLIB_InitTileSet(struct GRRLIB_texImg *tex, unsigned int tilew, unsigned int tileh, unsigned int tilestart){
|
||||||
tex->tilew = tilew;
|
tex->tilew = tilew;
|
||||||
tex->tileh = tileh;
|
tex->tileh = tileh;
|
||||||
|
@ -57,7 +89,11 @@ void GRRLIB_InitTileSet(struct GRRLIB_texImg *tex, unsigned int tilew, unsigned
|
||||||
tex->tilestart = tilestart;
|
tex->tilestart = tilestart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a texture from a buffer.
|
||||||
|
* @param my_png the PNG buffer to load.
|
||||||
|
* @return A GRRLIB_texImg structure filled with PNG informations.
|
||||||
|
*/
|
||||||
GRRLIB_texImg GRRLIB_LoadTexture(const unsigned char my_png[]) {
|
GRRLIB_texImg GRRLIB_LoadTexture(const unsigned char my_png[]) {
|
||||||
PNGUPROP imgProp;
|
PNGUPROP imgProp;
|
||||||
IMGCTX ctx;
|
IMGCTX ctx;
|
||||||
|
@ -74,10 +110,13 @@ GRRLIB_texImg GRRLIB_LoadTexture(const unsigned char my_png[]) {
|
||||||
return my_texture;
|
return my_texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GRRLIB_LoadTextureFromFile
|
/**
|
||||||
// Contribution by GRILLO
|
* Load a texture from a file.
|
||||||
|
* @author GRILLO
|
||||||
|
* @param filename the PNG file to load.
|
||||||
|
* @return A GRRLIB_texImg structure filled with PNG informations.
|
||||||
|
*/
|
||||||
GRRLIB_texImg GRRLIB_LoadTextureFromFile(const char *filename) {
|
GRRLIB_texImg GRRLIB_LoadTextureFromFile(const char *filename) {
|
||||||
|
|
||||||
PNGUPROP imgProp;
|
PNGUPROP imgProp;
|
||||||
IMGCTX ctx;
|
IMGCTX ctx;
|
||||||
GRRLIB_texImg my_texture;
|
GRRLIB_texImg my_texture;
|
||||||
|
@ -93,11 +132,13 @@ GRRLIB_texImg GRRLIB_LoadTextureFromFile(const char *filename) {
|
||||||
return my_texture;
|
return my_texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees, float scaleX, f32 scaleY, u32 color ){
|
inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees, float scaleX, f32 scaleY, u32 color ){
|
||||||
GXTexObj texObj;
|
GXTexObj texObj;
|
||||||
u16 width,height;
|
u16 width,height;
|
||||||
|
|
||||||
|
|
||||||
GX_InitTexObj(&texObj, tex.data, tex.w,tex.h, GX_TF_RGBA8,GX_CLAMP, GX_CLAMP,GX_FALSE);
|
GX_InitTexObj(&texObj, tex.data, tex.w,tex.h, GX_TF_RGBA8,GX_CLAMP, GX_CLAMP,GX_FALSE);
|
||||||
GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1);
|
GX_InitTexObjLOD(&texObj, GX_NEAR, GX_NEAR, 0.0f, 0.0f, 0.0f, 0, 0, GX_ANISO_1);
|
||||||
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
||||||
|
@ -139,9 +180,11 @@ inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees,
|
||||||
|
|
||||||
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
||||||
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
|
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees, float scaleX, f32 scaleY, u32 color, int frame){
|
inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees, float scaleX, f32 scaleY, u32 color, int frame){
|
||||||
GXTexObj texObj;
|
GXTexObj texObj;
|
||||||
// Frame Correction by spiffen
|
// Frame Correction by spiffen
|
||||||
|
@ -191,13 +234,15 @@ f32 width,height;
|
||||||
|
|
||||||
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
||||||
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
|
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
void GRRLIB_Printf(f32 xpos, f32 ypos, GRRLIB_texImg tex, u32 color, f32 zoom, char *text,...){
|
void GRRLIB_Printf(f32 xpos, f32 ypos, GRRLIB_texImg tex, u32 color, f32 zoom, char *text,...){
|
||||||
int i;
|
int i;
|
||||||
char tmp[1024];
|
char tmp[1024];
|
||||||
int size=0;
|
int size;
|
||||||
|
|
||||||
va_list argp;
|
va_list argp;
|
||||||
va_start(argp, text);
|
va_start(argp, text);
|
||||||
|
@ -211,6 +256,9 @@ void GRRLIB_Printf(f32 xpos, f32 ypos, GRRLIB_texImg tex, u32 color, f32 zoom, c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
void GRRLIB_GXEngine(Vector v[], u32 color, long n,u8 fmt){
|
void GRRLIB_GXEngine(Vector v[], u32 color, long n,u8 fmt){
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
|
@ -222,9 +270,9 @@ void GRRLIB_GXEngine(Vector v[], u32 color, long n,u8 fmt){
|
||||||
GX_End();
|
GX_End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
//********************************************************************************************
|
*/
|
||||||
void GRRLIB_InitVideo () {
|
void GRRLIB_InitVideo () {
|
||||||
VIDEO_Init();
|
VIDEO_Init();
|
||||||
rmode = VIDEO_GetPreferredMode(NULL);
|
rmode = VIDEO_GetPreferredMode(NULL);
|
||||||
|
@ -238,12 +286,13 @@ void GRRLIB_InitVideo () {
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
|
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
|
||||||
|
|
||||||
|
|
||||||
gp_fifo = (u8 *) memalign(32,DEFAULT_FIFO_SIZE);
|
gp_fifo = (u8 *) memalign(32,DEFAULT_FIFO_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
void GRRLIB_Start(){
|
void GRRLIB_Start(){
|
||||||
|
|
||||||
f32 yscale;
|
f32 yscale;
|
||||||
u32 xfbHeight;
|
u32 xfbHeight;
|
||||||
Mtx perspective;
|
Mtx perspective;
|
||||||
|
@ -307,6 +356,9 @@ void GRRLIB_Start(){
|
||||||
GX_SetCullMode(GX_CULL_NONE);
|
GX_SetCullMode(GX_CULL_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
void GRRLIB_Render () {
|
void GRRLIB_Render () {
|
||||||
GX_DrawDone ();
|
GX_DrawDone ();
|
||||||
|
|
||||||
|
@ -317,6 +369,4 @@ void GRRLIB_Render () {
|
||||||
VIDEO_SetNextFramebuffer(xfb[fb]);
|
VIDEO_SetNextFramebuffer(xfb[fb]);
|
||||||
VIDEO_Flush();
|
VIDEO_Flush();
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,18 @@
|
||||||
|
|
||||||
#include "../libpng/pngu/pngu.h"
|
#include "../libpng/pngu/pngu.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @struct GRRLIB_texImg
|
||||||
|
* @brief Structure to hold the texture informations.
|
||||||
|
* @param w width of the texture.
|
||||||
|
* @param h height of the texture.
|
||||||
|
* @param tilew widht of a tile.
|
||||||
|
* @param tileh height of a tile.
|
||||||
|
* @param nbtilew number of tiles for the x axis.
|
||||||
|
* @param nbtileh number of tiles for the y axis.
|
||||||
|
* @param tilestart
|
||||||
|
* @param data pointer to the texture data.
|
||||||
|
*/
|
||||||
typedef struct GRRLIB_texImg{
|
typedef struct GRRLIB_texImg{
|
||||||
unsigned int w;
|
unsigned int w;
|
||||||
unsigned int h;
|
unsigned int h;
|
||||||
|
@ -52,7 +64,6 @@ inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees
|
||||||
void GRRLIB_Printf(f32 xpos, f32 ypos, GRRLIB_texImg tex, u32 color, f32 zoom, char *text,...);
|
void GRRLIB_Printf(f32 xpos, f32 ypos, GRRLIB_texImg tex, u32 color, f32 zoom, char *text,...);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GRRLIB_GXEngine(Vector v[], u32 color, long count,u8 fmt);
|
void GRRLIB_GXEngine(Vector v[], u32 color, long count,u8 fmt);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,6 @@ int rot=0;
|
||||||
u32 wpaddown = WPAD_ButtonsDown(0);
|
u32 wpaddown = WPAD_ButtonsDown(0);
|
||||||
u32 wpadheld = WPAD_ButtonsHeld(0);
|
u32 wpadheld = WPAD_ButtonsHeld(0);
|
||||||
|
|
||||||
|
|
||||||
ir_t ir1;
|
ir_t ir1;
|
||||||
WPAD_IR(WPAD_CHAN_0, &ir1);
|
WPAD_IR(WPAD_CHAN_0, &ir1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue