From f9b0accd147219c005a7f894bc3df4d168a44728 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 24 Feb 2013 03:49:06 +0100 Subject: [PATCH] Make macros out of MAKECOLOR - and use them --- mednafen/psx/gpu.cpp | 38 ++++++-------------------------------- mednafen/video/surface.h | 23 +++++++---------------- 2 files changed, 13 insertions(+), 48 deletions(-) diff --git a/mednafen/psx/gpu.cpp b/mednafen/psx/gpu.cpp index ed1abaa0..654388b7 100644 --- a/mednafen/psx/gpu.cpp +++ b/mednafen/psx/gpu.cpp @@ -1081,13 +1081,6 @@ INLINE void PS_GPU::ReorderRGB_Var(uint32 out_Rshift, uint32 out_Gshift, uint32 } - -template -void PS_GPU::ReorderRGB(bool bpp24, const uint16 *src, uint32 *dest, const int32 dx_start, const int32 dx_end, int32 fb_x) -{ - ReorderRGB_Var(out_Rshift, out_Gshift, out_Bshift, bpp24, src, dest, dx_start, dx_end, fb_x); -} - pscpu_timestamp_t PS_GPU::Update(const pscpu_timestamp_t sys_timestamp) { static const uint32 DotClockRatios[5] = { 10, 8, 5, 4, 7 }; @@ -1222,8 +1215,6 @@ pscpu_timestamp_t PS_GPU::Update(const pscpu_timestamp_t sys_timestamp) { if((bool)(DisplayMode & 0x08) != HardwarePALType) { - const uint32 black = surface->MakeColor(0, 0, 0); - DisplayRect->x = 0; DisplayRect->y = 0; DisplayRect->w = 384; @@ -1237,9 +1228,7 @@ pscpu_timestamp_t PS_GPU::Update(const pscpu_timestamp_t sys_timestamp) LineWidths[y].w = 384; for(int32 x = 0; x < 384; x++) - { - dest[x] = black; - } + dest[x] = 0; } char buffer[256]; @@ -1247,13 +1236,11 @@ pscpu_timestamp_t PS_GPU::Update(const pscpu_timestamp_t sys_timestamp) #ifndef __LIBRETRO__ trio_snprintf(buffer, sizeof(buffer), _("VIDEO STANDARD MISMATCH")); DrawTextTrans(surface->pixels + ((DisplayRect->h / 2) - (13 / 2)) * surface->pitch32, surface->pitch32 << 2, DisplayRect->w, (UTF8*)buffer, - surface->MakeColor(0x00, 0xFF, 0x00), true, MDFN_FONT_6x13_12x13); + MAKECOLOR(0x00, 0xFF, 0x00), true, MDFN_FONT_6x13_12x13); #endif } else { - const uint32 black = surface->MakeColor(0, 0, 0); - espec->InterlaceOn = (bool)(DisplayMode & 0x20); espec->InterlaceField = field; @@ -1268,7 +1255,7 @@ pscpu_timestamp_t PS_GPU::Update(const pscpu_timestamp_t sys_timestamp) for(int i = 0; i < (DisplayRect->y + DisplayRect->h); i++) { surface->pixels[i * surface->pitch32 + 0] = - surface->pixels[i * surface->pitch32 + 1] = black; + surface->pixels[i * surface->pitch32 + 1] = 0; LineWidths[i].x = 0; LineWidths[i].w = 2; } @@ -1365,25 +1352,12 @@ pscpu_timestamp_t PS_GPU::Update(const pscpu_timestamp_t sys_timestamp) { const uint16 *src = GPURAM[DisplayFB_CurLineYReadout]; - const uint32 black = surface->MakeColor(0, 0, 0); for(int32 x = 0; x < dx_start; x++) - dest[x] = black; + dest[x] = 0; //printf("%d %d %d - %d %d\n", scanline, dx_start, dx_end, HorizStart, HorizEnd); - if(surface->format.Rshift == 0 && surface->format.Gshift == 8 && surface->format.Bshift == 16) - ReorderRGB<0, 8, 16>(DisplayMode & 0x10, src, dest, dx_start, dx_end, fb_x); - else if(surface->format.Rshift == 8 && surface->format.Gshift == 16 && surface->format.Bshift == 24) - ReorderRGB<8, 16, 24>(DisplayMode & 0x10, src, dest, dx_start, dx_end, fb_x); - else if(surface->format.Rshift == 16 && surface->format.Gshift == 8 && surface->format.Bshift == 0) - ReorderRGB<16, 8, 0>(DisplayMode & 0x10, src, dest, dx_start, dx_end, fb_x); - else if(surface->format.Rshift == 24 && surface->format.Gshift == 16 && surface->format.Bshift == 8) - ReorderRGB<24, 16, 8>(DisplayMode & 0x10, src, dest, dx_start, dx_end, fb_x); - else - ReorderRGB_Var(surface->format.Rshift, surface->format.Gshift, surface->format.Bshift, DisplayMode & 0x10, src, dest, dx_start, dx_end, fb_x); - - for(uint32 x = dx_end; x < dmw; x++) - dest[x] = black; + ReorderRGB_Var(surface->format.Rshift, surface->format.Gshift, surface->format.Bshift, DisplayMode & 0x10, src, dest, dx_start, dx_end, fb_x); } //if(scanline == 64) @@ -1453,7 +1427,7 @@ void PS_GPU::StartFrame(EmulateSpecStruct *espec_arg) r = ((rc >> 0) & 0x1F) << 3; g = ((rc >> 5) & 0x1F) << 3; b = ((rc >> 10) & 0x1F) << 3; - OutputLUT[rc] = espec->surface->format.MakeColor(r, g, b, 0); + OutputLUT[rc] = MAKECOLOR(r, g, b, 0); } } } diff --git a/mednafen/video/surface.h b/mednafen/video/surface.h index 1f252b0a..587df2b7 100644 --- a/mednafen/video/surface.h +++ b/mednafen/video/surface.h @@ -6,6 +6,7 @@ #define GREEN_SHIFT 8 #define BLUE_SHIFT 0 #define ALPHA_SHIFT 24 +#define MAKECOLOR(r, g, b, a) ((r << RED_SHIFT) | (g << GREEN_SHIFT) | (b << BLUE_SHIFT) | (a << ALPHA_SHIFT)) #elif defined(WANT_16BPP) && defined(FRONTEND_SUPPORTS_RGB565) /* 16bit color - RGB565 */ #define RED_MASK 0xf800 @@ -17,6 +18,7 @@ #define RED_SHIFT 11 #define GREEN_SHIFT 5 #define BLUE_SHIFT 0 +#define MAKECOLOR(r, g, b, a) (((r >> RED_EXPAND) << RED_SHIFT) | ((g >> GREEN_EXPAND) << GREEN_SHIFT) | ((b >> BLUE_EXPAND) << BLUE_SHIFT)) #elif defined(WANT_16BPP) && !defined(FRONTEND_SUPPORTS_RGB565) /* 16bit color - RGB555 */ #define RED_MASK 0x7c00 @@ -28,6 +30,7 @@ #define RED_SHIFT 10 #define GREEN_SHIFT 5 #define BLUE_SHIFT 0 +#define MAKECOLOR(r, g, b, a) (((r >> RED_EXPAND) << RED_SHIFT) | ((g >> GREEN_EXPAND) << GREEN_SHIFT) | ((b >> BLUE_EXPAND) << BLUE_SHIFT)) #endif typedef struct @@ -74,17 +77,10 @@ class MDFN_PixelFormat uint8 Ashift; // [...] alpha component. // Creates a color value for the surface corresponding to the 8-bit R/G/B/A color passed. -#if defined(WANT_32BPP) INLINE uint32 MakeColor(uint8 r, uint8 g, uint8 b, uint8 a = 0) const { - return((r << RED_SHIFT) | (g << GREEN_SHIFT) | (b << BLUE_SHIFT) | (a << ALPHA_SHIFT)); + return MAKECOLOR(r, g, b, a); } -#elif defined(WANT_16BPP) - INLINE uint32 MakeColor(uint8 r, uint8 g, uint8 b, uint8 a = 0) const - { - return (((r >> RED_EXPAND) << RED_SHIFT) | ((g >> GREEN_EXPAND) << GREEN_SHIFT) | ((b >> BLUE_EXPAND) << BLUE_SHIFT)); - } -#endif // Gets the R/G/B/A values for the passed 32-bit surface pixel value #if defined(WANT_32BPP) @@ -134,13 +130,13 @@ class MDFN_Surface //typedef struct void SetFormat(const MDFN_PixelFormat &new_format, bool convert); -#if defined(WANT_32BPP) - // Creates a 32-bit value for the surface corresponding to the R/G/B/A color passed. + // Creates a value for the surface corresponding to the R/G/B/A color passed. INLINE uint32 MakeColor(uint8 r, uint8 g, uint8 b, uint8 a = 0) const { - return((r << RED_SHIFT) | (g << GREEN_SHIFT) | (b << BLUE_SHIFT) | (a << ALPHA_SHIFT)); + return MAKECOLOR(r, g, b, a); } +#if defined(WANT_32BPP) // Gets the R/G/B/A values for the passed 32-bit surface pixel value INLINE void DecodeColor(uint32 value, int &r, int &g, int &b, int &a) const { @@ -157,11 +153,6 @@ class MDFN_Surface //typedef struct b = (value >> BLUE_SHIFT) & 0xFF; } #elif defined(WANT_16BPP) - // Creates a 32-bit value for the surface corresponding to the R/G/B/A color passed. - INLINE uint32 MakeColor(uint8 r, uint8 g, uint8 b, uint8 a = 0) const - { - return (((r >> RED_EXPAND) << RED_SHIFT) | ((g >> GREEN_EXPAND) << GREEN_SHIFT) | ((b >> BLUE_EXPAND) << BLUE_SHIFT)); - } // Gets the R/G/B/A values for the passed 32-bit surface pixel value INLINE void DecodeColor(uint32 value, int &r, int &g, int &b, int &a) const