[CHG] Code formatting

This commit is contained in:
Crayon2000 2009-01-19 00:48:28 +00:00
parent 9a450b7a78
commit 7643508990
3 changed files with 123 additions and 74 deletions

View file

@ -30,6 +30,9 @@ inline void GRRLIB_FillScreen(u32 color){
/**
*
* @param x
* @param y
* @param color
*/
inline void GRRLIB_Plot(f32 x, f32 y, u32 color){
Vector v[]={{x,y,0.0f}};
@ -39,6 +42,9 @@ inline void GRRLIB_Plot(f32 x,f32 y, u32 color){
/**
*
* @param v
* @param color
* @param n
*/
void GRRLIB_NPlot(Vector v[], u32 color, long n){
GRRLIB_GXEngine(v, color, n, GX_POINTS);
@ -60,6 +66,12 @@ inline void GRRLIB_Line(f32 x1, f32 y1, f32 x2, f32 y2, u32 color){
/**
* Draw a rectangle.
* @param x
* @param y
* @param width
* @param height
* @param color
* @param 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}};
@ -74,6 +86,9 @@ inline void GRRLIB_Rectangle(f32 x, f32 y, f32 width, f32 height, u32 color, u8
/**
*
* @param v
* @param color
* @param n
*/
void GRRLIB_NGone(Vector v[], u32 color, long n){
GRRLIB_GXEngine(v, color, n, GX_LINESTRIP);
@ -81,6 +96,9 @@ void GRRLIB_NGone(Vector v[],u32 color,long n){
/**
*
* @param v
* @param color
* @param n
*/
void GRRLIB_NGoneFilled(Vector v[], u32 color, long n){
GRRLIB_GXEngine(v, color, n, GX_TRIANGLEFAN);
@ -88,6 +106,10 @@ void GRRLIB_NGoneFilled(Vector v[],u32 color,long n){
/**
*
* @param tex
* @param tilew
* @param tileh
* @param tilestart
*/
void GRRLIB_InitTileSet(struct GRRLIB_texImg *tex, unsigned int tilew, unsigned int tileh, unsigned int tilestart){
tex->tilew = tilew;
@ -119,8 +141,12 @@ GRRLIB_texImg GRRLIB_LoadTexturePNG(const unsigned char my_png[]) {
}
/**
* Convert a raw bmp (RGB, no alpha) to 4x4RGBA
* Convert a raw bmp (RGB, no alpha) to 4x4RGBA.
* @author DrTwox
* @param src
* @param dst
* @param width
* @param height
*/
static void RawTo4x4RGBA(const unsigned char *src, void *dst, const unsigned int width, const unsigned int height) {
unsigned int block = 0;
@ -159,7 +185,7 @@ static void RawTo4x4RGBA(const unsigned char *src, void *dst, const unsigned int
* Load a texture from a buffer.
* Take Care to have a JPG Finnishing by 0xFF 0xD9 !!!!
* @author DrTwox
* @param my_jpg the JPG buffer to load.
* @param my_jpg the JPEG buffer to load.
* @return A GRRLIB_texImg structure filled with PNG informations.
*/
GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
@ -167,6 +193,7 @@ GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
struct jpeg_error_mgr jerr;
GRRLIB_texImg my_texture;
int n = 0;
unsigned int i;
if((my_jpg[0]==0xff) && (my_jpg[1]==0xd8) && (my_jpg[2]==0xff)){
while(1){
@ -201,7 +228,6 @@ GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
/* Decompress the JPEG into tempBuffer, one row at a time */
JSAMPROW row_pointer[1];
row_pointer[0] = (unsigned char*) malloc(cinfo.output_width * cinfo.num_components);
unsigned int i = 0;
size_t location = 0;
while (cinfo.output_scanline < cinfo.output_height) {
jpeg_read_scanlines(&cinfo, row_pointer, 1);
@ -230,10 +256,18 @@ GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
/**
*
* @param xpos
* @param ypos
* @param tex
* @param degrees
* @param scaleX
* @param scaleY
* @param color
*/
inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees, float scaleX, f32 scaleY, u32 color ){
GXTexObj texObj;
u16 width, height;
Mtx m, m1, m2, mv;
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);
@ -242,9 +276,8 @@ inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees,
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT);
Mtx m,m1,m2, mv;
width=tex.w * .5;
height=tex.h * .5;
width = tex.w * 0.5;
height = tex.h * 0.5;
guMtxIdentity (m1);
guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0);
Vector axis =(Vector) {0 , 0, 1 };
@ -280,16 +313,26 @@ inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees,
/**
*
* @param xpos
* @param ypos
* @param tex
* @param degrees
* @param scaleX
* @param scaleY
* @param color
* @param frame
*/
inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees, float scaleX, f32 scaleY, u32 color, int frame){
GXTexObj texObj;
f32 width, height;
Mtx m, m1, m2, mv;
// Frame Correction by spiffen
f32 FRAME_CORR = 0.001f;
f32 s1 = (((frame%tex.nbtilew))/(f32)tex.nbtilew)+(FRAME_CORR/tex.w);
f32 s2 = (((frame%tex.nbtilew)+1)/(f32)tex.nbtilew)-(FRAME_CORR/tex.w);
f32 t1 = (((int)(frame/tex.nbtilew))/(f32)tex.nbtileh)+(FRAME_CORR/tex.h);
f32 t2 = (((int)(frame/tex.nbtilew)+1)/(f32)tex.nbtileh)-(FRAME_CORR/tex.h);
f32 width,height;
GX_InitTexObj(&texObj, tex.data, tex.tilew*tex.nbtilew,tex.tileh*tex.nbtileh, 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);
@ -298,7 +341,6 @@ inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT);
Mtx m,m1,m2, mv;
width = tex.tilew * 0.5f;
height = tex.tileh * 0.5f;
guMtxIdentity (m1);
@ -334,19 +376,23 @@ inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees
/**
*
* @param xpos
* @param ypos
* @param tex
* @param color
* @param zoom
* @param ... Optional arguments.
*/
void GRRLIB_Printf(f32 xpos, f32 ypos, GRRLIB_texImg tex, u32 color, f32 zoom, char *text, ...){
int i;
int i, size;
char tmp[1024];
int size;
va_list argp;
va_start(argp, text);
vsprintf(tmp, text, argp);
size = vsprintf(tmp, text, argp);
va_end(argp);
size = strlen(tmp);
for(i=0; i<strlen(tmp); i++){
for(i=0; i<size; i++){
u8 c = tmp[i]-tex.tilestart;
GRRLIB_DrawTile(xpos+i*tex.tilew*zoom, ypos, tex, 0, zoom, zoom, color, c);
}
@ -354,9 +400,12 @@ void GRRLIB_Printf(f32 xpos, f32 ypos, GRRLIB_texImg tex, u32 color, f32 zoom, c
/**
*
* @param v
* @param color
* @param fmt
*/
void GRRLIB_GXEngine(Vector v[], u32 color, long n, u8 fmt){
int i=0;
int i;
GX_Begin(fmt, GX_VTXFMT0,n);
for(i=0; i<n; i++){