[CHG] Pure cosmetic update - Made the code more readable and fixed some spelling errors.

This commit is contained in:
Xane 2009-03-07 22:21:43 +00:00
parent c2086fbf93
commit fc6019ae7b

View file

@ -27,7 +27,7 @@ static void RawTo4x4RGBA(const unsigned char *src, void *dst, const unsigned int
/** /**
* Clear screen with a specific color. * Clear screen with a specific color.
* @param color the color to use to fill the screen. * @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);
@ -35,9 +35,9 @@ inline void GRRLIB_FillScreen(u32 color) {
/** /**
* Draw a dot. * Draw a dot.
* @param x specifies the x-coordinate of the dot. * @param x Specifies the x-coordinate of the dot.
* @param y specifies the y-coordinate of the dot. * @param y Specifies the y-coordinate of the dot.
* @param color the color of the dot in RGBA format. * @param color The color of the dot in RGBA format.
*/ */
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}};
@ -47,9 +47,9 @@ inline void GRRLIB_Plot(f32 x, f32 y, u32 color) {
/** /**
* Draw an array of points. * Draw an array of points.
* @param v array containing the points. * @param v Array containing the points.
* @param color the color of the points in RGBA format. * @param color The color of the points in RGBA format.
* @param n number of points in the vector array. * @param n Number of points in the vector array.
*/ */
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);
@ -57,11 +57,11 @@ void GRRLIB_NPlot(Vector v[], u32 color, long n) {
/** /**
* Draw a line. * Draw a line.
* @param x1 start point for line for the x coordinate. * @param x1 Starting point for line for the x coordinate.
* @param y1 start point for line for the y coordinate. * @param y1 Starting point for line for the y coordinate.
* @param x2 end point for line for the x coordinate. * @param x2 Ending point for line for the x coordinate.
* @param y2 end point for line for the x coordinate. * @param y2 Ending point for line for the x coordinate.
* @param color line color in RGBA format. * @param color Line color in RGBA format.
*/ */
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}};
@ -71,12 +71,12 @@ inline void GRRLIB_Line(f32 x1, f32 y1, f32 x2, f32 y2, u32 color) {
/** /**
* Draw a rectangle. * Draw a rectangle.
* @param x specifies the x-coordinate of the upper-left corner of the rectangle. * @param x Specifies the x-coordinate of the upper-left corner of the rectangle.
* @param y specifies the y-coordinate of the upper-left corner of the rectangle. * @param y Specifies the y-coordinate of the upper-left corner of the rectangle.
* @param width the width of the rectangle. * @param width The width of the rectangle.
* @param height the height of the rectangle. * @param height The height of the rectangle.
* @param color the color of the rectangle in RGBA format. * @param color The color of the rectangle in RGBA format.
* @param filled true to fill the rectangle with a color. * @param filled Set to true to fill the 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) {
f32 x2 = x+width; f32 x2 = x+width;
@ -94,11 +94,11 @@ inline void GRRLIB_Rectangle(f32 x, f32 y, f32 width, f32 height, u32 color, u8
/** /**
* Draw a circle. * Draw a circle.
* @author Dark_Link * @author Dark_Link
* @param x * @param x Specifies the x-coordinate of the circle.
* @param y * @param y Specifies the y-coordinate of the circle.
* @param radius the radius of the circle. * @param radius The radius of the circle.
* @param color the color of the circle in RGBA format. * @param color The color of the circle in RGBA format.
* @param filled true to fill the circle with a color. * @param filled Set to true to fill the circle.
*/ */
inline void GRRLIB_Circle(f32 x, f32 y, f32 radius, u32 color, u8 filled) { inline void GRRLIB_Circle(f32 x, f32 y, f32 radius, u32 color, u8 filled) {
Vector v[36]; Vector v[36];
@ -124,9 +124,9 @@ inline void GRRLIB_Circle(f32 x, f32 y, f32 radius, u32 color, u8 filled) {
/** /**
* Draw a polygon. * Draw a polygon.
* @param v * @param v The vector containing the coordinates of the polygon.
* @param color the color of the polygon in RGBA format. * @param color The color of the filled polygon in RGBA format.
* @param n * @param n Number of points in the vector.
*/ */
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);
@ -134,9 +134,9 @@ void GRRLIB_NGone(Vector v[], u32 color, long n) {
/** /**
* Draw a filled polygon. * Draw a filled polygon.
* @param v * @param v The vector containing the coordinates of the polygon.
* @param color the color of the filled polygon in RGBA format. * @param color The color of the filled polygon in RGBA format.
* @param n * @param n Number of points in the vector.
*/ */
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);
@ -144,10 +144,10 @@ void GRRLIB_NGoneFilled(Vector v[], u32 color, long n) {
/** /**
* Initialize a tile set. * Initialize a tile set.
* @param tex texture to initialize. * @param tex The texture to initialize.
* @param tilew widht of the tile. * @param tilew Width of the tile.
* @param tileh height of the tile. * @param tileh Height of the tile.
* @param tilestart offset for starting position. * @param tilestart Offset for starting position. (Used in fonts)
*/ */
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;
@ -162,7 +162,7 @@ void GRRLIB_InitTileSet(struct GRRLIB_texImg *tex, unsigned int tilew, unsigned
/** /**
* Load a texture from a buffer. * Load a texture from a buffer.
* @param my_png the PNG buffer to load. * @param my_png the PNG buffer to load.
* @return A GRRLIB_texImg structure filled with PNG informations. * @return A GRRLIB_texImg structure filled with image informations.
*/ */
GRRLIB_texImg GRRLIB_LoadTexturePNG(const unsigned char my_png[]) { GRRLIB_texImg GRRLIB_LoadTexturePNG(const unsigned char my_png[]) {
PNGUPROP imgProp; PNGUPROP imgProp;
@ -182,7 +182,7 @@ 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 DragonMinded * @author DragonMinded
* @param src * @param src
* @param dst * @param dst
@ -224,10 +224,10 @@ static void RawTo4x4RGBA(const unsigned char *src, void *dst, const unsigned int
/** /**
* Load a texture from a buffer. * Load a texture from a buffer.
* Take Care to have a JPG finnishing by 0xFF 0xD9 !!!! * Take care to have the JPG finnish with 0xFF 0xD9!!
* @author DrTwox * @author DrTwox
* @param my_jpg the JPEG buffer to load. * @param my_jpg The JPEG buffer to load.
* @return A GRRLIB_texImg structure filled with PNG informations. * @return A GRRLIB_texImg structure filled with image informations.
*/ */
GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) { GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
struct jpeg_decompress_struct cinfo; struct jpeg_decompress_struct cinfo;
@ -237,7 +237,7 @@ GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
unsigned int i; unsigned int i;
if ((my_jpg[0]==0xff) && (my_jpg[1]==0xd8) && (my_jpg[2]==0xff)) { if ((my_jpg[0]==0xff) && (my_jpg[1]==0xd8) && (my_jpg[2]==0xff)) {
while(1) { while(true) {
if ((my_jpg[n]==0xff) && (my_jpg[n+1]==0xd9)) if ((my_jpg[n]==0xff) && (my_jpg[n+1]==0xd9))
break; break;
n++; n++;
@ -267,7 +267,7 @@ GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
my_texture.data = memalign(32, cinfo.output_width * cinfo.output_height * 4); my_texture.data = memalign(32, cinfo.output_width * cinfo.output_height * 4);
RawTo4x4RGBA(tempBuffer, my_texture.data, cinfo.output_width, cinfo.output_height); RawTo4x4RGBA(tempBuffer, my_texture.data, cinfo.output_width, cinfo.output_height);
/* Done - do cleanup and release memory */ /* Done - Do cleanup and release allocated memory */
jpeg_finish_decompress(&cinfo); jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo); jpeg_destroy_decompress(&cinfo);
free(row_pointer[0]); free(row_pointer[0]);
@ -283,11 +283,11 @@ GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
/** /**
* Print formatted output. * Print formatted output.
* @param xpos * @param xpos Specifies the x-coordinate of the upper-left corner of the text.
* @param ypos * @param ypos Specifies the y-coordinate of the upper-left corner of the text.
* @param bmf * @param bmf The ByteMap font to use.
* @param zoom * @param zoom This is a factor by which the text size will be increase or decrease.
* @param text text to draw. * @param text Text to draw.
* @param ... Optional arguments. * @param ... Optional arguments.
*/ */
void GRRLIB_PrintBMF(f32 xpos, f32 ypos, GRRLIB_bytemapFont bmf, f32 zoom, const char *text, ...) { void GRRLIB_PrintBMF(f32 xpos, f32 ypos, GRRLIB_bytemapFont bmf, f32 zoom, const char *text, ...) {
@ -321,16 +321,15 @@ void GRRLIB_PrintBMF(f32 xpos, f32 ypos, GRRLIB_bytemapFont bmf, f32 zoom, const
} }
} }
} }
GRRLIB_FlushTex(tex_BMfont); GRRLIB_FlushTex(tex_BMfont);
GRRLIB_DrawImg(0, 0, tex_BMfont, 0, 1, 1, 0xFFFFFFFF); GRRLIB_DrawImg(0, 0, tex_BMfont, 0, 1, 1, 0xFFFFFFFF);
free(tex_BMfont.data); free(tex_BMfont.data);
} }
/** /**
* Load a ByteMap font structure from a buffer. * Load a ByteMap font structure from a buffer.
* @param my_bmf the ByteMap font buffer to load. * @param my_bmf The ByteMap font buffer to load.
* @return A GRRLIB_bytemapFont structure filled with BMF informations. * @return A GRRLIB_bytemapFont structure filled with BMF informations.
*/ */
GRRLIB_bytemapFont GRRLIB_LoadBMF(const unsigned char my_bmf[]) { GRRLIB_bytemapFont GRRLIB_LoadBMF(const unsigned char my_bmf[]) {
@ -384,11 +383,10 @@ GRRLIB_bytemapFont GRRLIB_LoadBMF(const unsigned char my_bmf[]) {
} }
/** /**
* Free memory. * Free memory allocated by ByteMap fonts.
* @param bmf a GRRLIB_bytemapFont structure. * @param bmf a GRRLIB_bytemapFont structure.
*/ */
void GRRLIB_FreeBMF(GRRLIB_bytemapFont bmf) void GRRLIB_FreeBMF(GRRLIB_bytemapFont bmf) {
{
unsigned int i; unsigned int i;
for (i=0; i<bmf.nbChar; i++) { for (i=0; i<bmf.nbChar; i++) {
@ -401,8 +399,8 @@ void GRRLIB_FreeBMF(GRRLIB_bytemapFont bmf)
/** /**
* Load a texture from a buffer. * Load a texture from a buffer.
* @param my_img the JPEG or PNG buffer to load. * @param my_img The JPEG or PNG buffer to load.
* @return A GRRLIB_texImg structure filled with imgage informations. * @return A GRRLIB_texImg structure filled with image informations.
*/ */
GRRLIB_texImg GRRLIB_LoadTexture(const unsigned char my_img[]) { GRRLIB_texImg GRRLIB_LoadTexture(const unsigned char my_img[]) {
if (my_img[0]==0xFF && my_img[1]==0xD8 && my_img[2]==0xFF) { if (my_img[0]==0xFF && my_img[1]==0xD8 && my_img[2]==0xFF) {
@ -415,8 +413,8 @@ GRRLIB_texImg GRRLIB_LoadTexture(const unsigned char my_img[]) {
/** /**
* Create an empty texture. * Create an empty texture.
* @param w width of the new texture to create. * @param w Width of the new texture to create.
* @param h height of the new texture to create. * @param h Height of the new texture to create.
* @return A GRRLIB_texImg structure newly created. * @return A GRRLIB_texImg structure newly created.
*/ */
GRRLIB_texImg GRRLIB_CreateEmptyTexture(unsigned int w, unsigned int h) { GRRLIB_texImg GRRLIB_CreateEmptyTexture(unsigned int w, unsigned int h) {
@ -438,13 +436,13 @@ GRRLIB_texImg GRRLIB_CreateEmptyTexture(unsigned int w, unsigned int h) {
/** /**
* Draw a texture. * Draw a texture.
* @param xpos specifies the x-coordinate of the upper-left corner. * @param xpos Specifies the x-coordinate of the upper-left corner.
* @param ypos specifies the y-coordinate of the upper-left corner. * @param ypos Specifies the y-coordinate of the upper-left corner.
* @param tex texture to draw. * @param tex The texture to draw.
* @param degrees angle of rotation. * @param degrees Angle of rotation.
* @param scaleX specifies the x-coordinate scale. -1 could be used for flipping the texture horizontally. * @param scaleX Specifies the x-coordinate scale. -1 could be used for flipping the texture horizontally.
* @param scaleY specifies the y-coordinate scale. -1 could be used for flipping the texture vertically. * @param scaleY Specifies the y-coordinate scale. -1 could be used for flipping the texture vertically.
* @param color * @param color Color in RGBA format.
*/ */
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;
@ -495,14 +493,14 @@ inline void GRRLIB_DrawImg(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees,
/** /**
* Draw a tile. * Draw a tile.
* @param xpos specifies the x-coordinate of the upper-left corner. * @param xpos Specifies the x-coordinate of the upper-left corner.
* @param ypos specifies the y-coordinate of the upper-left corner. * @param ypos Specifies the y-coordinate of the upper-left corner.
* @param tex texture containing the tile to draw. * @param tex The texture containing the tile to draw.
* @param degrees angle of rotation. * @param degrees Angle of rotation.
* @param scaleX specifies the x-coordinate scale. -1 could be used for flipping the texture horizontally. * @param scaleX Specifies the x-coordinate scale. -1 could be used for flipping the texture horizontally.
* @param scaleY specifies the y-coordinate scale. -1 could be used for flipping the texture vertically. * @param scaleY Specifies the y-coordinate scale. -1 could be used for flipping the texture vertically.
* @param color * @param color Color in RGBA format.
* @param frame specifies the frame to draw. * @param frame Specifies the frame to draw.
*/ */
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;
@ -558,12 +556,12 @@ inline void GRRLIB_DrawTile(f32 xpos, f32 ypos, GRRLIB_texImg tex, float degrees
/** /**
* Print formatted output. * Print formatted output.
* @param xpos specifies the x-coordinate of the upper-left corner of the text. * @param xpos Specifies the x-coordinate of the upper-left corner of the text.
* @param ypos specifies the y-coordinate of the upper-left corner of the text. * @param ypos Specifies the y-coordinate of the upper-left corner of the text.
* @param tex texture containing the character set. * @param tex The texture containing the character set.
* @param color text color in RGBA format. The alpha channel is used to change the opacity of the text. * @param color Text color in RGBA format. The alpha channel is used to change the opacity of the text.
* @param zoom this is a factor by which the text size will be increase or decrease. * @param zoom This is a factor by which the text size will be increase or decrease.
* @param text text to draw. * @param text Text to draw.
* @param ... Optional arguments. * @param ... Optional arguments.
*/ */
void GRRLIB_Printf(f32 xpos, f32 ypos, GRRLIB_texImg tex, u32 color, f32 zoom, const char *text, ...) { void GRRLIB_Printf(f32 xpos, f32 ypos, GRRLIB_texImg tex, u32 color, f32 zoom, const char *text, ...) {
@ -582,13 +580,13 @@ void GRRLIB_Printf(f32 xpos, f32 ypos, GRRLIB_texImg tex, u32 color, f32 zoom, c
} }
/** /**
* Determines whether the specified point lies within the specified rectangle. * Determine whether the specified point lies within the specified rectangle.
* @param hotx specifies the x-coordinate of the upper-left corner of the rectangle. * @param hotx Specifies the x-coordinate of the upper-left corner of the rectangle.
* @param hoty specifies the y-coordinate of the upper-left corner of the rectangle. * @param hoty Specifies the y-coordinate of the upper-left corner of the rectangle.
* @param hotw the width of the rectangle. * @param hotw The width of the rectangle.
* @param hoth the height of the rectangle. * @param hoth The height of the rectangle.
* @param wpadx specifies the x-coordinate of the point. * @param wpadx Specifies the x-coordinate of the point.
* @param wpady specifies the y-coordinate of the point. * @param wpady Specifies the y-coordinate of the point.
* @return If the specified point lies within the rectangle, the return value is true otherwise it's false. * @return If the specified point lies within the rectangle, the return value is true otherwise it's false.
*/ */
bool GRRLIB_PtInRect(int hotx, int hoty, int hotw, int hoth, int wpadx, int wpady) { bool GRRLIB_PtInRect(int hotx, int hoty, int hotw, int hoth, int wpadx, int wpady) {
@ -596,15 +594,15 @@ bool GRRLIB_PtInRect(int hotx, int hoty, int hotw, int hoth, int wpadx, int wpad
} }
/** /**
* Determines whether a specified rectangle lies within another rectangle. * Determine whether a specified rectangle lies within another rectangle.
* @param rect1x specifies the x-coordinate of the upper-left corner of the rectangle. * @param rect1x Specifies the x-coordinate of the upper-left corner of the rectangle.
* @param rect1y specifies the y-coordinate of the upper-left corner of the rectangle. * @param rect1y Specifies the y-coordinate of the upper-left corner of the rectangle.
* @param rect1w specifies the width of the rectangle. * @param rect1w Specifies the width of the rectangle.
* @param rect1h specifies the height of the rectangle. * @param rect1h Specifies the height of the rectangle.
* @param rect2x specifies the x-coordinate of the upper-left corner of the rectangle. * @param rect2x Specifies the x-coordinate of the upper-left corner of the rectangle.
* @param rect2y specifies the y-coordinate of the upper-left corner of the rectangle. * @param rect2y Specifies the y-coordinate of the upper-left corner of the rectangle.
* @param rect2w specifies the width of the rectangle. * @param rect2w Specifies the width of the rectangle.
* @param rect2h specifies the height of the rectangle. * @param rect2h Specifies the height of the rectangle.
* @return If the specified rectangle lies within the other rectangle, the return value is true otherwise it's false. * @return If the specified rectangle lies within the other rectangle, the return value is true otherwise it's false.
*/ */
bool GRRLIB_RectInRect(int rect1x, int rect1y, int rect1w, int rect1h, int rect2x, int rect2y, int rect2w, int rect2h) { bool GRRLIB_RectInRect(int rect1x, int rect1y, int rect1w, int rect1h, int rect2x, int rect2y, int rect2w, int rect2h) {
@ -613,15 +611,15 @@ bool GRRLIB_RectInRect(int rect1x, int rect1y, int rect1w, int rect1h, int rect2
} }
/** /**
* Determines whether a part of a specified rectangle lies on another rectangle. * Determine whether a part of a specified rectangle lies on another rectangle.
* @param rect1x specifies the x-coordinate of the upper-left corner of the first rectangle. * @param rect1x Specifies the x-coordinate of the upper-left corner of the first rectangle.
* @param rect1y specifies the y-coordinate of the upper-left corner of the first rectangle. * @param rect1y Specifies the y-coordinate of the upper-left corner of the first rectangle.
* @param rect1w specifies the width of the first rectangle. * @param rect1w Specifies the width of the first rectangle.
* @param rect1h specifies the height of the first rectangle. * @param rect1h Specifies the height of the first rectangle.
* @param rect2x specifies the x-coordinate of the upper-left corner of the second rectangle. * @param rect2x Specifies the x-coordinate of the upper-left corner of the second rectangle.
* @param rect2y specifies the y-coordinate of the upper-left corner of the second rectangle. * @param rect2y Specifies the y-coordinate of the upper-left corner of the second rectangle.
* @param rect2w specifies the width of the second rectangle. * @param rect2w Specifies the width of the second rectangle.
* @param rect2h specifies the height of the second rectangle. * @param rect2h Specifies the height of the second rectangle.
* @return If the specified rectangle lies on the other rectangle, the return value is true otherwise it's false. * @return If the specified rectangle lies on the other rectangle, the return value is true otherwise it's false.
*/ */
bool GRRLIB_RectOnRect(int rect1x, int rect1y, int rect1w, int rect1h, int rect2x, int rect2y, int rect2w, int rect2h) { bool GRRLIB_RectOnRect(int rect1x, int rect1y, int rect1w, int rect1h, int rect2x, int rect2y, int rect2w, int rect2h) {
@ -633,7 +631,7 @@ bool GRRLIB_RectOnRect(int rect1x, int rect1y, int rect1w, int rect1h, int rect2
/** /**
* Clips the drawing area to an rectangle * Clip the drawing area to an rectangle
* @param x The x-coordinate of the rectangle. * @param x The x-coordinate of the rectangle.
* @param y The y-coordinate of the rectangle. * @param y The y-coordinate of the rectangle.
* @param width The width of the rectangle. * @param width The width of the rectangle.
@ -645,17 +643,16 @@ void GRRLIB_ClipDrawing( int x, int y, int width, int height ) {
} }
/** /**
* Resets the clipping to normal * Reset the clipping to normal
*/ */
void GRRLIB_ClipReset() { void GRRLIB_ClipReset() {
GX_SetClipMode( GX_CLIP_DISABLE ); GX_SetClipMode( GX_CLIP_DISABLE );
GX_SetScissor( 0, 0, rmode->fbWidth, rmode->efbHeight ); GX_SetScissor( 0, 0, rmode->fbWidth, rmode->efbHeight );
} }
/** /**
* Sets a texture's X and Y handles. (e.g. for rotation) * Set a texture's X and Y handles. (e.g. for rotation)
* @param tex GRRLIB Texture * @param tex The texture to set the handle on.
* @param x The handle's x-coordinate * @param x The handle's x-coordinate
* @param y The handle's y-coordinate * @param y The handle's y-coordinate
*/ */
@ -667,8 +664,8 @@ void GRRLIB_SetHandle( GRRLIB_texImg * tex, int x, int y ) {
} }
/** /**
* Centers a texture's handles. (e.g. for rotation) * Center a texture's handles. (e.g. for rotation)
* @param tex GRRLIB Texture * @param tex The texture to center.
*/ */
void GRRLIB_SetMidHandle( GRRLIB_texImg * tex ) { void GRRLIB_SetMidHandle( GRRLIB_texImg * tex ) {
tex->handlex = 0; tex->handlex = 0;
@ -680,9 +677,9 @@ void GRRLIB_SetMidHandle( GRRLIB_texImg * tex ) {
/** /**
* Return the color value of a pixel from a GRRLIB_texImg. * Return the color value of a pixel from a GRRLIB_texImg.
* @param x specifies the x-coordinate of the pixel in the texture. * @param x Specifies the x-coordinate of the pixel in the texture.
* @param y specifies the y-coordinate of the pixel in the texture. * @param y Specifies the y-coordinate of the pixel in the texture.
* @param tex texture to get the color from. * @param tex The texture to get the color from.
* @return The color of a pixel in RGBA format. * @return The color of a pixel in RGBA format.
*/ */
u32 GRRLIB_GetPixelFromtexImg(int x, int y, GRRLIB_texImg tex) { u32 GRRLIB_GetPixelFromtexImg(int x, int y, GRRLIB_texImg tex) {
@ -703,10 +700,10 @@ u32 GRRLIB_GetPixelFromtexImg(int x, int y, GRRLIB_texImg tex) {
/** /**
* Set the color value of a pixel to a GRRLIB_texImg. * Set the color value of a pixel to a GRRLIB_texImg.
* @see GRRLIB_FlushTex * @see GRRLIB_FlushTex
* @param x specifies the x-coordinate of the pixel in the texture. * @param x Specifies the x-coordinate of the pixel in the texture.
* @param y specifies the y-coordinate of the pixel in the texture. * @param y Specifies the y-coordinate of the pixel in the texture.
* @param tex texture to set the color to. * @param tex The texture to set the color to.
* @param color the color of the pixel in RGBA format. * @param color The color of the pixel in RGBA format.
*/ */
void GRRLIB_SetPixelTotexImg(int x, int y, GRRLIB_texImg tex, u32 color) { void GRRLIB_SetPixelTotexImg(int x, int y, GRRLIB_texImg tex, u32 color) {
u8 *truc = (u8*)tex.data; u8 *truc = (u8*)tex.data;
@ -721,20 +718,19 @@ void GRRLIB_SetPixelTotexImg(int x, int y, GRRLIB_texImg tex, u32 color) {
} }
/** /**
* Writes the contents of a texture in the data cache down to main memory. * Write the contents of a texture in the data cache down to main memory.
* For performance the CPU holds a data cache where modifications are stored before they get written down to mainmemory. * For performance the CPU holds a data cache where modifications are stored before they get written down to mainmemory.
* @param tex the texture to flush. * @param tex The texture to flush.
*/ */
void GRRLIB_FlushTex(GRRLIB_texImg tex) void GRRLIB_FlushTex(GRRLIB_texImg tex) {
{
DCFlushRange(tex.data, tex.w * tex.h * 4); DCFlushRange(tex.data, tex.w * tex.h * 4);
} }
/** /**
* Change a texture to gray scale. * Change a texture to gray scale.
* @see GRRLIB_FlushTex * @see GRRLIB_FlushTex
* @param texsrc the texture source. * @param texsrc The texture source.
* @param texdest the texture grayscaled destination. * @param texdest The texture grayscaled destination.
*/ */
void GRRLIB_BMFX_Grayscale(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) { void GRRLIB_BMFX_Grayscale(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
unsigned int x, y; unsigned int x, y;
@ -756,8 +752,8 @@ void GRRLIB_BMFX_Grayscale(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
/** /**
* Invert colors of the texture. * Invert colors of the texture.
* @see GRRLIB_FlushTex * @see GRRLIB_FlushTex
* @param texsrc the texture source. * @param texsrc The texture source.
* @param texdest the texture destination. * @param texdest The texture destination.
*/ */
void GRRLIB_BMFX_Invert(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) { void GRRLIB_BMFX_Invert(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
unsigned int x, y; unsigned int x, y;
@ -766,7 +762,6 @@ void GRRLIB_BMFX_Invert(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
for (y = 0; y < texsrc.h; y++) { for (y = 0; y < texsrc.h; y++) {
for (x = 0; x < texsrc.w; x++) { for (x = 0; x < texsrc.w; x++) {
color = GRRLIB_GetPixelFromtexImg(x, y, texsrc); color = GRRLIB_GetPixelFromtexImg(x, y, texsrc);
GRRLIB_SetPixelTotexImg(x, y, texdest, GRRLIB_SetPixelTotexImg(x, y, texdest,
((0xFFFFFF - (color >> 8 & 0xFFFFFF)) << 8) | (color & 0xFF)); ((0xFFFFFF - (color >> 8 & 0xFFFFFF)) << 8) | (color & 0xFF));
} }
@ -776,8 +771,8 @@ void GRRLIB_BMFX_Invert(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
/** /**
* Flip texture horizontal. * Flip texture horizontal.
* @see GRRLIB_FlushTex * @see GRRLIB_FlushTex
* @param texsrc the texture source. * @param texsrc The texture source.
* @param texdest the texture destination. * @param texdest The texture destination.
*/ */
void GRRLIB_BMFX_FlipH(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) { void GRRLIB_BMFX_FlipH(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
unsigned int x, y, txtWidth = texsrc.w - 1; unsigned int x, y, txtWidth = texsrc.w - 1;
@ -793,8 +788,8 @@ void GRRLIB_BMFX_FlipH(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
/** /**
* Flip texture vertical. * Flip texture vertical.
* @see GRRLIB_FlushTex * @see GRRLIB_FlushTex
* @param texsrc the texture source. * @param texsrc The texture source.
* @param texdest the texture destination. * @param texdest The texture destination.
*/ */
void GRRLIB_BMFX_FlipV(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) { void GRRLIB_BMFX_FlipV(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
unsigned int x, y, texHeight = texsrc.h - 1; unsigned int x, y, texHeight = texsrc.h - 1;
@ -808,11 +803,11 @@ void GRRLIB_BMFX_FlipV(GRRLIB_texImg texsrc, GRRLIB_texImg texdest) {
} }
/** /**
* Blur a texture. * A texture effect. (Blur)
* @see GRRLIB_FlushTex * @see GRRLIB_FlushTex
* @param texsrc the texture source. * @param texsrc The texture source.
* @param texdest the texture destination. * @param texdest The texture destination.
* @param factor the blur factor. * @param factor The blur factor.
*/ */
void GRRLIB_BMFX_Blur(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor) { void GRRLIB_BMFX_Blur(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor) {
int numba = (1+(factor<<1))*(1+(factor<<1)); int numba = (1+(factor<<1))*(1+(factor<<1));
@ -863,10 +858,10 @@ void GRRLIB_BMFX_Blur(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor) {
} }
/** /**
* A texture effect. * A texture effect. (Pixelate)
* @see GRRLIB_FlushTex * @see GRRLIB_FlushTex
* @param texsrc the texture source. * @param texsrc The texture source.
* @param texdest the texture destination. * @param texdest The texture destination.
* @param factor The factor level of the effect. * @param factor The factor level of the effect.
*/ */
void GRRLIB_BMFX_Pixelate(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor) { void GRRLIB_BMFX_Pixelate(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor) {
@ -887,10 +882,10 @@ void GRRLIB_BMFX_Pixelate(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int facto
} }
/** /**
* A texture effect. * A texture effect. (Scatter)
* @see GRRLIB_FlushTex * @see GRRLIB_FlushTex
* @param texsrc the texture source. * @param texsrc The texture source.
* @param texdest the texture destination. * @param texdest The texture destination.
* @param factor The factor level of the effect. * @param factor The factor level of the effect.
*/ */
void GRRLIB_BMFX_Scatter(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor) { void GRRLIB_BMFX_Scatter(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor) {
@ -917,11 +912,7 @@ void GRRLIB_BMFX_Scatter(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor
} }
/** /**
* * Draws a vector.
* @param v
* @param color
* @param n
* @param fmt
*/ */
void GRRLIB_GXEngine(Vector v[], u32 color, long n, u8 fmt) { void GRRLIB_GXEngine(Vector v[], u32 color, long n, u8 fmt) {
int i; int i;
@ -973,10 +964,10 @@ void GRRLIB_Init() {
memset(gp_fifo, 0, DEFAULT_FIFO_SIZE); memset(gp_fifo, 0, DEFAULT_FIFO_SIZE);
GX_Init(gp_fifo, DEFAULT_FIFO_SIZE); GX_Init(gp_fifo, DEFAULT_FIFO_SIZE);
// clears the bg to color and clears the z buffer // Clears the BG to color and clears the z-buffer
GX_SetCopyClear((GXColor){ 0, 0, 0, 0xff }, GX_MAX_Z24); GX_SetCopyClear((GXColor){ 0, 0, 0, 0xff }, GX_MAX_Z24);
// other gx setup // Other GX setup
yscale = GX_GetYScaleFactor(rmode->efbHeight, rmode->xfbHeight); yscale = GX_GetYScaleFactor(rmode->efbHeight, rmode->xfbHeight);
xfbHeight = GX_SetDispCopyYScale(yscale); xfbHeight = GX_SetDispCopyYScale(yscale);
GX_SetScissor(0, 0, rmode->fbWidth, rmode->efbHeight); GX_SetScissor(0, 0, rmode->fbWidth, rmode->efbHeight);
@ -993,8 +984,8 @@ void GRRLIB_Init() {
GX_SetDispCopyGamma(GX_GM_1_0); GX_SetDispCopyGamma(GX_GM_1_0);
// setup the vertex descriptor // Setup the vertex descriptor
// tells the flipper to expect direct data // Tells the flipper to expect direct data
GX_ClearVtxDesc(); GX_ClearVtxDesc();
GX_InvVtxCache(); GX_InvVtxCache();
GX_InvalidateTexAll(); GX_InvalidateTexAll();
@ -1035,7 +1026,7 @@ void GRRLIB_Init() {
void GRRLIB_Render() { void GRRLIB_Render() {
GX_DrawDone(); GX_DrawDone();
fb ^= 1; // flip framebuffer fb ^= 1; // Flip framebuffer
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetColorUpdate(GX_TRUE); GX_SetColorUpdate(GX_TRUE);
GX_CopyDisp(xfb[fb], GX_TRUE); GX_CopyDisp(xfb[fb], GX_TRUE);
@ -1049,7 +1040,7 @@ void GRRLIB_Render() {
*/ */
void GRRLIB_Exit() { void GRRLIB_Exit() {
GX_SetClipMode( GX_CLIP_DISABLE ); GX_SetClipMode( GX_CLIP_DISABLE );
GX_SetScissor( 0, 0, WinW, WinH ); GX_SetScissor( 0, 0, rmode->fbWidth, rmode->efbHeight );
GRRLIB_FillScreen( 0x000000FF ); GRRLIB_FillScreen( 0x000000FF );
GRRLIB_Render(); GRRLIB_Render();
GX_Flush(); GX_Flush();