diff --git a/GRRLIB/GRRLIB/grrlib/GRRLIB__inline.h b/GRRLIB/GRRLIB/grrlib/GRRLIB__inline.h index b7101ea..36139f7 100644 --- a/GRRLIB/GRRLIB/grrlib/GRRLIB__inline.h +++ b/GRRLIB/GRRLIB/grrlib/GRRLIB__inline.h @@ -104,9 +104,8 @@ INLINE u32 GRRLIB_GetPixelFromtexImg (const int x, const int y, INLINE void GRRLIB_SetPixelTotexImg (const int x, const int y, GRRLIB_texImg *tex, const u32 color); -INLINE void GRRLIB_GetPixelFromFB (int x, int y, - u8 *R1, u8 *G1, u8 *B1, - u8 *R2, u8 *G2, u8 *B2); +INLINE u32 GRRLIB_GetPixelFromFB (int x, int y); +INLINE void GRRLIB_SetPixelToFB (int x, int y, u32 pokeColor); //------------------------------------------------------------------------------ // GRRLIB_settings.h - Rendering functions diff --git a/GRRLIB/GRRLIB/grrlib/GRRLIB_pixel.h b/GRRLIB/GRRLIB/grrlib/GRRLIB_pixel.h index 8cae7b7..3b2d9b4 100644 --- a/GRRLIB/GRRLIB/grrlib/GRRLIB_pixel.h +++ b/GRRLIB/GRRLIB/grrlib/GRRLIB_pixel.h @@ -67,44 +67,33 @@ void GRRLIB_SetPixelTotexImg (const int x, const int y, /** * Reads a pixel directly from the FrontBuffer. - * Since the FB is stored in YCbCr, * @param x The x-coordinate within the FB. * @param y The y-coordinate within the FB. - * @param R1 A pointer to a variable receiving the first Red value. - * @param G1 A pointer to a variable receiving the first Green value. - * @param B1 A pointer to a variable receiving the first Blue value. - * @param R2 A pointer to a variable receiving the second Red value. - * @param G2 A pointer to a variable receiving the second Green value. - * @param B2 A pointer to a variable receiving the second Blue value. */ INLINE -void GRRLIB_GetPixelFromFB (int x, int y, - u8 *R1, u8 *G1, u8 *B1, - u8 *R2, u8 *G2, u8 *B2) { - u32 Buffer; - u8 *Colors; +u32 GRRLIB_GetPixelFromFB (int x, int y) { + GXColor peekColor; + u32 MyColor; - // Position Correction - if (x > (rmode->fbWidth/2)) { x = (rmode->fbWidth/2); } - if (x < 0) { x = 0; } - if (y > rmode->efbHeight) { y = rmode->efbHeight; } - if (y < 0) { y = 0; } + GX_PeekARGB(x, y, &peekColor); + MyColor = RGBA(peekColor.r,peekColor.g,peekColor.b,peekColor.a); - // Preparing FB for reading - Buffer = ((u32 *)xfb[fb])[y*(rmode->fbWidth/2)+x]; - Colors = (u8 *) &Buffer; - - /** Color channel: - Colors[0] = Y1 - Colors[1] = Cb - Colors[2] = Y2 - Colors[3] = Cr */ - - *R1 = GRRLIB_ClampVar8( 1.164 * (Colors[0] - 16) + 1.596 * (Colors[3] - 128) ); - *G1 = GRRLIB_ClampVar8( 1.164 * (Colors[0] - 16) - 0.813 * (Colors[3] - 128) - 0.392 * (Colors[1] - 128) ); - *B1 = GRRLIB_ClampVar8( 1.164 * (Colors[0] - 16) + 2.017 * (Colors[1] - 128) ); - - *R2 = GRRLIB_ClampVar8( 1.164 * (Colors[2] - 16) + 1.596 * (Colors[3] - 128) ); - *G2 = GRRLIB_ClampVar8( 1.164 * (Colors[2] - 16) - 0.813 * (Colors[3] - 128) - 0.392 * (Colors[1] - 128) ); - *B2 = GRRLIB_ClampVar8( 1.164 * (Colors[2] - 16) + 2.017 * (Colors[1] - 128) ); + return (MyColor); +} + +/** + * Writes a pixel directly from the FrontBuffer. + * @param x The x-coordinate within the FB. + * @param y The y-coordinate within the FB. + */ +INLINE +void GRRLIB_SetPixelToFB (int x, int y, u32 pokeColor) { + GXColor MyColor; + + MyColor.r=R(pokeColor); + MyColor.g=G(pokeColor); + MyColor.b=B(pokeColor); + MyColor.a=A(pokeColor); + + GX_PokeARGB(x, y, MyColor); }