Remove most of GFX_MULTI_FORMAT.

This commit is contained in:
Brandon Wright 2019-03-07 17:14:51 -06:00
parent 58aa23ba6d
commit 76b6342ca1
17 changed files with 105 additions and 528 deletions

View File

@ -9,14 +9,10 @@
#define ALL_COLOR_MASK (FIRST_COLOR_MASK | SECOND_COLOR_MASK | THIRD_COLOR_MASK) #define ALL_COLOR_MASK (FIRST_COLOR_MASK | SECOND_COLOR_MASK | THIRD_COLOR_MASK)
#ifdef GFX_MULTI_FORMAT
static uint32 colorMask = 0, qcolorMask = 0, lowPixelMask = 0, qlowpixelMask = 0;
#else
#define colorMask (((~RGB_LOW_BITS_MASK & ALL_COLOR_MASK) << 16) | (~RGB_LOW_BITS_MASK & ALL_COLOR_MASK)) #define colorMask (((~RGB_LOW_BITS_MASK & ALL_COLOR_MASK) << 16) | (~RGB_LOW_BITS_MASK & ALL_COLOR_MASK))
#define qcolorMask (((~TWO_LOW_BITS_MASK & ALL_COLOR_MASK) << 16) | (~TWO_LOW_BITS_MASK & ALL_COLOR_MASK)) #define qcolorMask (((~TWO_LOW_BITS_MASK & ALL_COLOR_MASK) << 16) | (~TWO_LOW_BITS_MASK & ALL_COLOR_MASK))
#define lowPixelMask ((RGB_LOW_BITS_MASK << 16) | RGB_LOW_BITS_MASK) #define lowPixelMask ((RGB_LOW_BITS_MASK << 16) | RGB_LOW_BITS_MASK)
#define qlowpixelMask ((TWO_LOW_BITS_MASK << 16) | TWO_LOW_BITS_MASK) #define qlowpixelMask ((TWO_LOW_BITS_MASK << 16) | TWO_LOW_BITS_MASK)
#endif
static inline int GetResult (uint32, uint32, uint32, uint32); static inline int GetResult (uint32, uint32, uint32, uint32);
static inline int GetResult1 (uint32, uint32, uint32, uint32, uint32); static inline int GetResult1 (uint32, uint32, uint32, uint32, uint32);
@ -78,13 +74,6 @@ static inline uint32 Q_INTERPOLATE (uint32 A, uint32 B, uint32 C, uint32 D)
bool8 S9xBlit2xSaIFilterInit (void) bool8 S9xBlit2xSaIFilterInit (void)
{ {
#ifdef GFX_MULTI_FORMAT
colorMask = ((~RGB_LOW_BITS_MASK & ALL_COLOR_MASK) << 16) | (~RGB_LOW_BITS_MASK & ALL_COLOR_MASK);
qcolorMask = ((~TWO_LOW_BITS_MASK & ALL_COLOR_MASK) << 16) | (~TWO_LOW_BITS_MASK & ALL_COLOR_MASK);
lowPixelMask = (RGB_LOW_BITS_MASK << 16) | RGB_LOW_BITS_MASK;
qlowpixelMask = (TWO_LOW_BITS_MASK << 16) | TWO_LOW_BITS_MASK;
#endif
return (TRUE); return (TRUE);
} }

View File

@ -9,15 +9,10 @@
#define ALL_COLOR_MASK (FIRST_COLOR_MASK | SECOND_COLOR_MASK | THIRD_COLOR_MASK) #define ALL_COLOR_MASK (FIRST_COLOR_MASK | SECOND_COLOR_MASK | THIRD_COLOR_MASK)
#ifdef GFX_MULTI_FORMAT
static uint16 lowPixelMask = 0, qlowPixelMask = 0, highBitsMask = 0;
static uint32 colorMask = 0;
#else
#define lowPixelMask (RGB_LOW_BITS_MASK) #define lowPixelMask (RGB_LOW_BITS_MASK)
#define qlowPixelMask ((RGB_HI_BITS_MASK >> 3) | TWO_LOW_BITS_MASK) #define qlowPixelMask ((RGB_HI_BITS_MASK >> 3) | TWO_LOW_BITS_MASK)
#define highBitsMask (ALL_COLOR_MASK & RGB_REMOVE_LOW_BITS_MASK) #define highBitsMask (ALL_COLOR_MASK & RGB_REMOVE_LOW_BITS_MASK)
#define colorMask (((~RGB_HI_BITS_MASK & ALL_COLOR_MASK) << 16) | (~RGB_HI_BITS_MASK & ALL_COLOR_MASK)) #define colorMask (((~RGB_HI_BITS_MASK & ALL_COLOR_MASK) << 16) | (~RGB_HI_BITS_MASK & ALL_COLOR_MASK))
#endif
static snes_ntsc_t *ntsc = NULL; static snes_ntsc_t *ntsc = NULL;
static uint8 *XDelta = NULL; static uint8 *XDelta = NULL;
@ -31,13 +26,6 @@ bool8 S9xBlitFilterInit (void)
S9xBlitClearDelta(); S9xBlitClearDelta();
#ifdef GFX_MULTI_FORMAT
lowPixelMask = RGB_LOW_BITS_MASK;
qlowPixelMask = (RGB_HI_BITS_MASK >> 3) | TWO_LOW_BITS_MASK;
highBitsMask = ALL_COLOR_MASK & RGB_REMOVE_LOW_BITS_MASK;
colorMask = ((~RGB_HI_BITS_MASK & ALL_COLOR_MASK) << 16) | (~RGB_HI_BITS_MASK & ALL_COLOR_MASK);
#endif
return (TRUE); return (TRUE);
} }

View File

@ -15,12 +15,8 @@
#define trU 0x000700 #define trU 0x000700
#define trV 0x000006 #define trV 0x000006
#ifdef GFX_MULTI_FORMAT
static uint16 Mask_2 = 0, Mask13 = 0;
#else
#define Mask_2 SECOND_COLOR_MASK #define Mask_2 SECOND_COLOR_MASK
#define Mask13 FIRST_THIRD_COLOR_MASK #define Mask13 FIRST_THIRD_COLOR_MASK
#endif
#define Interp01(c1, c2) \ #define Interp01(c1, c2) \
(c1 == c2) ? c1 : \ (c1 == c2) ? c1 : \
@ -344,11 +340,6 @@ bool8 S9xBlitHQ2xFilterInit (void)
if (!RGBtoYUV) if (!RGBtoYUV)
return (FALSE); return (FALSE);
#ifdef GFX_MULTI_FORMAT
Mask_2 = SECOND_COLOR_MASK;
Mask13 = FIRST_THIRD_COLOR_MASK;
#endif
InitLUTs(); InitLUTs();
return (TRUE); return (TRUE);

154
gfx.cpp
View File

@ -48,18 +48,12 @@ bool8 S9xGraphicsInit (void)
S9xInitTileRenderer(); S9xInitTileRenderer();
memset(BlackColourMap, 0, 256 * sizeof(uint16)); memset(BlackColourMap, 0, 256 * sizeof(uint16));
#ifdef GFX_MULTI_FORMAT
if (GFX.BuildPixel == NULL)
S9xSetRenderPixelFormat(RGB565);
#endif
GFX.RealPPL = GFX.Pitch >> 1; GFX.RealPPL = GFX.Pitch >> 1;
IPPU.OBJChanged = TRUE; IPPU.OBJChanged = TRUE;
Settings.BG_Forced = 0; Settings.BG_Forced = 0;
S9xFixColourBrightness(); S9xFixColourBrightness();
S9xBuildDirectColourMaps(); S9xBuildDirectColourMaps();
GFX.X2 = (uint16 *) malloc(sizeof(uint16) * 0x10000);
GFX.ZERO = (uint16 *) malloc(sizeof(uint16) * 0x10000); GFX.ZERO = (uint16 *) malloc(sizeof(uint16) * 0x10000);
GFX.ScreenSize = GFX.Pitch / 2 * SNES_HEIGHT_EXTENDED * (Settings.SupportHiRes ? 2 : 1); GFX.ScreenSize = GFX.Pitch / 2 * SNES_HEIGHT_EXTENDED * (Settings.SupportHiRes ? 2 : 1);
@ -67,38 +61,12 @@ bool8 S9xGraphicsInit (void)
GFX.ZBuffer = (uint8 *) malloc(GFX.ScreenSize); GFX.ZBuffer = (uint8 *) malloc(GFX.ScreenSize);
GFX.SubZBuffer = (uint8 *) malloc(GFX.ScreenSize); GFX.SubZBuffer = (uint8 *) malloc(GFX.ScreenSize);
if (!GFX.X2 || !GFX.ZERO || !GFX.SubScreen || !GFX.ZBuffer || !GFX.SubZBuffer) if (!GFX.ZERO || !GFX.SubScreen || !GFX.ZBuffer || !GFX.SubZBuffer)
{ {
S9xGraphicsDeinit(); S9xGraphicsDeinit();
return (FALSE); return (FALSE);
} }
// Lookup table for color addition
memset(GFX.X2, 0, 0x10000 * sizeof(uint16));
for (uint32 r = 0; r <= MAX_RED; r++)
{
uint32 r2 = r << 1;
if (r2 > MAX_RED)
r2 = MAX_RED;
for (uint32 g = 0; g <= MAX_GREEN; g++)
{
uint32 g2 = g << 1;
if (g2 > MAX_GREEN)
g2 = MAX_GREEN;
for (uint32 b = 0; b <= MAX_BLUE; b++)
{
uint32 b2 = b << 1;
if (b2 > MAX_BLUE)
b2 = MAX_BLUE;
GFX.X2[BUILD_PIXEL2(r, g, b)] = BUILD_PIXEL2(r2, g2, b2);
GFX.X2[BUILD_PIXEL2(r, g, b) & ~ALPHA_BITS_MASK] = BUILD_PIXEL2(r2, g2, b2);
}
}
}
// Lookup table for 1/2 color subtraction // Lookup table for 1/2 color subtraction
memset(GFX.ZERO, 0, 0x10000 * sizeof(uint16)); memset(GFX.ZERO, 0, 0x10000 * sizeof(uint16));
for (uint32 r = 0; r <= MAX_RED; r++) for (uint32 r = 0; r <= MAX_RED; r++)
@ -136,7 +104,6 @@ bool8 S9xGraphicsInit (void)
void S9xGraphicsDeinit (void) void S9xGraphicsDeinit (void)
{ {
if (GFX.X2) { free(GFX.X2); GFX.X2 = NULL; }
if (GFX.ZERO) { free(GFX.ZERO); GFX.ZERO = NULL; } if (GFX.ZERO) { free(GFX.ZERO); GFX.ZERO = NULL; }
if (GFX.SubScreen) { free(GFX.SubScreen); GFX.SubScreen = NULL; } if (GFX.SubScreen) { free(GFX.SubScreen); GFX.SubScreen = NULL; }
if (GFX.ZBuffer) { free(GFX.ZBuffer); GFX.ZBuffer = NULL; } if (GFX.ZBuffer) { free(GFX.ZBuffer); GFX.ZBuffer = NULL; }
@ -2157,122 +2124,3 @@ void S9xDrawCrosshair (const char *crosshair, uint8 fgcolor, uint8 bgcolor, int1
} }
} }
#ifdef GFX_MULTI_FORMAT
static uint32 BuildPixelRGB565 (uint32, uint32, uint32);
static uint32 BuildPixelRGB555 (uint32, uint32, uint32);
static uint32 BuildPixelBGR565 (uint32, uint32, uint32);
static uint32 BuildPixelBGR555 (uint32, uint32, uint32);
static uint32 BuildPixelGBR565 (uint32, uint32, uint32);
static uint32 BuildPixelGBR555 (uint32, uint32, uint32);
static uint32 BuildPixelRGB5551 (uint32, uint32, uint32);
static uint32 BuildPixel2RGB565 (uint32, uint32, uint32);
static uint32 BuildPixel2RGB555 (uint32, uint32, uint32);
static uint32 BuildPixel2BGR565 (uint32, uint32, uint32);
static uint32 BuildPixel2BGR555 (uint32, uint32, uint32);
static uint32 BuildPixel2GBR565 (uint32, uint32, uint32);
static uint32 BuildPixel2GBR555 (uint32, uint32, uint32);
static uint32 BuildPixel2RGB5551 (uint32, uint32, uint32);
static void DecomposePixelRGB565 (uint32, uint32 &, uint32 &, uint32 &);
static void DecomposePixelRGB555 (uint32, uint32 &, uint32 &, uint32 &);
static void DecomposePixelBGR565 (uint32, uint32 &, uint32 &, uint32 &);
static void DecomposePixelBGR555 (uint32, uint32 &, uint32 &, uint32 &);
static void DecomposePixelGBR565 (uint32, uint32 &, uint32 &, uint32 &);
static void DecomposePixelGBR555 (uint32, uint32 &, uint32 &, uint32 &);
static void DecomposePixelRGB5551 (uint32, uint32 &, uint32 &, uint32 &);
#define _BUILD_PIXEL(F) \
static uint32 BuildPixel##F (uint32 R, uint32 G, uint32 B) \
{ \
return (BUILD_PIXEL_##F(R, G, B)); \
} \
\
static uint32 BuildPixel2##F (uint32 R, uint32 G, uint32 B) \
{ \
return (BUILD_PIXEL2_##F(R, G, B)); \
} \
\
static void DecomposePixel##F (uint32 pixel, uint32 &R, uint32 &G, uint32 &B) \
{ \
DECOMPOSE_PIXEL_##F(pixel, R, G, B); \
}
_BUILD_PIXEL(RGB565)
_BUILD_PIXEL(RGB555)
_BUILD_PIXEL(BGR565)
_BUILD_PIXEL(BGR555)
_BUILD_PIXEL(GBR565)
_BUILD_PIXEL(GBR555)
_BUILD_PIXEL(RGB5551)
#define _BUILD_SETUP(F) \
GFX.BuildPixel = BuildPixel##F; \
GFX.BuildPixel2 = BuildPixel2##F; \
GFX.DecomposePixel = DecomposePixel##F; \
RED_LOW_BIT_MASK = RED_LOW_BIT_MASK_##F; \
GREEN_LOW_BIT_MASK = GREEN_LOW_BIT_MASK_##F; \
BLUE_LOW_BIT_MASK = BLUE_LOW_BIT_MASK_##F; \
RED_HI_BIT_MASK = RED_HI_BIT_MASK_##F; \
GREEN_HI_BIT_MASK = GREEN_HI_BIT_MASK_##F; \
BLUE_HI_BIT_MASK = BLUE_HI_BIT_MASK_##F; \
MAX_RED = MAX_RED_##F; \
MAX_GREEN = MAX_GREEN_##F; \
MAX_BLUE = MAX_BLUE_##F; \
SPARE_RGB_BIT_MASK = SPARE_RGB_BIT_MASK_##F; \
GREEN_HI_BIT = ((MAX_GREEN_##F + 1) >> 1); \
RGB_LOW_BITS_MASK = (RED_LOW_BIT_MASK_##F | GREEN_LOW_BIT_MASK_##F | BLUE_LOW_BIT_MASK_##F); \
RGB_HI_BITS_MASK = (RED_HI_BIT_MASK_##F | GREEN_HI_BIT_MASK_##F | BLUE_HI_BIT_MASK_##F); \
RGB_HI_BITS_MASKx2 = (RED_HI_BIT_MASK_##F | GREEN_HI_BIT_MASK_##F | BLUE_HI_BIT_MASK_##F) << 1; \
RGB_REMOVE_LOW_BITS_MASK = ~RGB_LOW_BITS_MASK; \
FIRST_COLOR_MASK = FIRST_COLOR_MASK_##F; \
SECOND_COLOR_MASK = SECOND_COLOR_MASK_##F; \
THIRD_COLOR_MASK = THIRD_COLOR_MASK_##F; \
ALPHA_BITS_MASK = ALPHA_BITS_MASK_##F; \
FIRST_THIRD_COLOR_MASK = FIRST_COLOR_MASK | THIRD_COLOR_MASK; \
TWO_LOW_BITS_MASK = RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 1); \
HIGH_BITS_SHIFTED_TWO_MASK = ((FIRST_COLOR_MASK | SECOND_COLOR_MASK | THIRD_COLOR_MASK) & ~TWO_LOW_BITS_MASK) >> 2;
bool8 S9xSetRenderPixelFormat (int format)
{
GFX.PixelFormat = format;
switch (format)
{
case RGB565:
_BUILD_SETUP(RGB565)
return (TRUE);
case RGB555:
_BUILD_SETUP(RGB555)
return (TRUE);
case BGR565:
_BUILD_SETUP(BGR565)
return (TRUE);
case BGR555:
_BUILD_SETUP(BGR555)
return (TRUE);
case GBR565:
_BUILD_SETUP(GBR565)
return (TRUE);
case GBR555:
_BUILD_SETUP(GBR555)
return (TRUE);
case RGB5551:
_BUILD_SETUP(RGB5551)
return (TRUE);
default:
break;
}
return (FALSE);
}
#endif

22
gfx.h
View File

@ -19,7 +19,6 @@ struct SGFX
uint32 ScreenSize; uint32 ScreenSize;
uint16 *S; uint16 *S;
uint8 *DB; uint8 *DB;
uint16 *X2;
uint16 *ZERO; uint16 *ZERO;
uint32 RealPPL; // true PPL of Screen buffer uint32 RealPPL; // true PPL of Screen buffer
uint32 PPL; // number of pixels on each of Screen buffer uint32 PPL; // number of pixels on each of Screen buffer
@ -51,13 +50,6 @@ struct SGFX
} OBJ[32]; } OBJ[32];
} OBJLines[SNES_HEIGHT_EXTENDED]; } OBJLines[SNES_HEIGHT_EXTENDED];
#ifdef GFX_MULTI_FORMAT
uint32 PixelFormat;
uint32 (*BuildPixel) (uint32, uint32, uint32);
uint32 (*BuildPixel2) (uint32, uint32, uint32);
void (*DecomposePixel) (uint32, uint32 &, uint32 &, uint32 &);
#endif
void (*DrawBackdropMath) (uint32, uint32, uint32); void (*DrawBackdropMath) (uint32, uint32, uint32);
void (*DrawBackdropNomath) (uint32, uint32, uint32); void (*DrawBackdropNomath) (uint32, uint32, uint32);
void (*DrawTileMath) (uint32, uint32, uint32, uint32); void (*DrawTileMath) (uint32, uint32, uint32, uint32);
@ -140,15 +132,6 @@ extern struct SGFX GFX;
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + \ ((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + \
((C1) & (C2) & RGB_LOW_BITS_MASK)) | ALPHA_BITS_MASK) ((C1) & (C2) & RGB_LOW_BITS_MASK)) | ALPHA_BITS_MASK)
#ifdef GFX_MULTI_FORMAT
#define COLOR_ADD(C1, C2) \
(GFX.X2[((((C1) & RGB_REMOVE_LOW_BITS_MASK) + \
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + \
((C1) & (C2) & RGB_LOW_BITS_MASK)] | \
(((C1) ^ (C2)) & RGB_LOW_BITS_MASK))
#else
inline uint16 COLOR_ADD(uint16 C1, uint16 C2) inline uint16 COLOR_ADD(uint16 C1, uint16 C2)
{ {
return ((brightness_cap[ (C1 >> RED_SHIFT_BITS) + (C2 >> RED_SHIFT_BITS) ] << RED_SHIFT_BITS) | return ((brightness_cap[ (C1 >> RED_SHIFT_BITS) + (C2 >> RED_SHIFT_BITS) ] << RED_SHIFT_BITS) |
@ -156,8 +139,6 @@ inline uint16 COLOR_ADD(uint16 C1, uint16 C2)
(brightness_cap[ (C1 & 0x1f) + (C2 & 0x1f)] )); (brightness_cap[ (C1 & 0x1f) + (C2 & 0x1f)] ));
} }
#endif // GFX_MULTI_FORMAT
#define COLOR_SUB1_2(C1, C2) \ #define COLOR_SUB1_2(C1, C2) \
GFX.ZERO[(((C1) | RGB_HI_BITS_MASKx2) - \ GFX.ZERO[(((C1) | RGB_HI_BITS_MASKx2) - \
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1] ((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1]
@ -190,9 +171,6 @@ void S9xDisplayChar (uint16 *, uint8);
void S9xGraphicsScreenResize (void); void S9xGraphicsScreenResize (void);
// called automatically unless Settings.AutoDisplayMessages is false // called automatically unless Settings.AutoDisplayMessages is false
void S9xDisplayMessages (uint16 *, int, int, int, int); void S9xDisplayMessages (uint16 *, int, int, int, int);
#ifdef GFX_MULTI_FORMAT
bool8 S9xSetRenderPixelFormat (int);
#endif
// external port interface which must be implemented or initialised for each port // external port interface which must be implemented or initialised for each port
bool8 S9xGraphicsInit (void); bool8 S9xGraphicsInit (void);

View File

@ -72,31 +72,6 @@ SnesModel M1SNES = { 1, 3, 2 };
SnesModel M2SNES = { 2, 4, 3 }; SnesModel M2SNES = { 2, 4, 3 };
SnesModel *Model = &M1SNES; SnesModel *Model = &M1SNES;
#ifdef GFX_MULTI_FORMAT
uint32 RED_LOW_BIT_MASK = RED_LOW_BIT_MASK_RGB565;
uint32 GREEN_LOW_BIT_MASK = GREEN_LOW_BIT_MASK_RGB565;
uint32 BLUE_LOW_BIT_MASK = BLUE_LOW_BIT_MASK_RGB565;
uint32 RED_HI_BIT_MASK = RED_HI_BIT_MASK_RGB565;
uint32 GREEN_HI_BIT_MASK = GREEN_HI_BIT_MASK_RGB565;
uint32 BLUE_HI_BIT_MASK = BLUE_HI_BIT_MASK_RGB565;
uint32 MAX_RED = MAX_RED_RGB565;
uint32 MAX_GREEN = MAX_GREEN_RGB565;
uint32 MAX_BLUE = MAX_BLUE_RGB565;
uint32 SPARE_RGB_BIT_MASK = SPARE_RGB_BIT_MASK_RGB565;
uint32 GREEN_HI_BIT = (MAX_GREEN_RGB565 + 1) >> 1;
uint32 RGB_LOW_BITS_MASK = (RED_LOW_BIT_MASK_RGB565 | GREEN_LOW_BIT_MASK_RGB565 | BLUE_LOW_BIT_MASK_RGB565);
uint32 RGB_HI_BITS_MASK = (RED_HI_BIT_MASK_RGB565 | GREEN_HI_BIT_MASK_RGB565 | BLUE_HI_BIT_MASK_RGB565);
uint32 RGB_HI_BITS_MASKx2 = (RED_HI_BIT_MASK_RGB565 | GREEN_HI_BIT_MASK_RGB565 | BLUE_HI_BIT_MASK_RGB565) << 1;
uint32 RGB_REMOVE_LOW_BITS_MASK = ~RGB_LOW_BITS_MASK;
uint32 FIRST_COLOR_MASK = FIRST_COLOR_MASK_RGB565;
uint32 SECOND_COLOR_MASK = SECOND_COLOR_MASK_RGB565;
uint32 THIRD_COLOR_MASK = THIRD_COLOR_MASK_RGB565;
uint32 ALPHA_BITS_MASK = ALPHA_BITS_MASK_RGB565;
uint32 FIRST_THIRD_COLOR_MASK = 0;
uint32 TWO_LOW_BITS_MASK = 0;
uint32 HIGH_BITS_SHIFTED_TWO_MASK = 0;
#endif
uint16 SignExtend[2] = uint16 SignExtend[2] =
{ {
0x0000, 0x0000,

View File

@ -990,18 +990,16 @@ bool retro_load_game(const struct retro_game_info *game)
if (rom_loaded) if (rom_loaded)
{ {
int pixel_format = RGB555; /* If we're in RGB565 format, switch frontend to that */
if (environ_cb) if (RED_SHIFT_BITS == 11)
{ {
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
if (environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) if (!environ_cb || !environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
pixel_format = RGB565; {
return false;
}
} }
S9xGraphicsDeinit();
S9xSetRenderPixelFormat(pixel_format);
S9xGraphicsInit();
g_geometry_update = true; g_geometry_update = true;
if (randomize_memory) if (randomize_memory)
@ -1137,17 +1135,12 @@ bool retro_load_game_special(unsigned game_type, const struct retro_game_info *i
if (rom_loaded) if (rom_loaded)
{ {
int pixel_format = RGB555; if(RED_SHIFT_BITS == 11)
if(environ_cb)
{ {
pixel_format = RGB565;
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) if (!environ_cb || !environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
pixel_format = RGB555; return false;
} }
S9xGraphicsDeinit();
S9xSetRenderPixelFormat(pixel_format);
S9xGraphicsInit();
g_geometry_update = true; g_geometry_update = true;
} }

View File

@ -199,11 +199,6 @@ void InitGraphics (void)
if (!snesScreenA || !snesScreenB || !blitGLBuffer) if (!snesScreenA || !snesScreenB || !blitGLBuffer)
QuitWithFatalError(0, "render 01"); QuitWithFatalError(0, "render 01");
#ifdef GFX_MULTI_FORMAT
S9xSetRenderPixelFormat(RGB555);
printf("GFX_MULTI_FORMAT is #defined.\n");
#endif
if (!S9xBlitFilterInit() | if (!S9xBlitFilterInit() |
!S9xBlit2xSaIFilterInit() | !S9xBlit2xSaIFilterInit() |
!S9xBlitHQ2xFilterInit() | !S9xBlitHQ2xFilterInit() |

315
pixform.h
View File

@ -7,238 +7,111 @@
#ifndef _PIXFORM_H_ #ifndef _PIXFORM_H_
#define _PIXFORM_H_ #define _PIXFORM_H_
#ifdef GFX_MULTI_FORMAT
enum { RGB565, RGB555, BGR565, BGR555, GBR565, GBR555, RGB5551 };
#define BUILD_PIXEL(R, G, B) ((*GFX.BuildPixel) (R, G, B))
#define BUILD_PIXEL2(R, G, B) ((*GFX.BuildPixel2) (R, G, B))
#define DECOMPOSE_PIXEL(PIX, R, G, B) ((*GFX.DecomposePixel) (PIX, R, G, B))
extern uint32 MAX_RED;
extern uint32 MAX_GREEN;
extern uint32 MAX_BLUE;
extern uint32 RED_LOW_BIT_MASK;
extern uint32 GREEN_LOW_BIT_MASK;
extern uint32 BLUE_LOW_BIT_MASK;
extern uint32 RED_HI_BIT_MASK;
extern uint32 GREEN_HI_BIT_MASK;
extern uint32 BLUE_HI_BIT_MASK;
extern uint32 FIRST_COLOR_MASK;
extern uint32 SECOND_COLOR_MASK;
extern uint32 THIRD_COLOR_MASK;
extern uint32 ALPHA_BITS_MASK;
extern uint32 GREEN_HI_BIT;
extern uint32 RGB_LOW_BITS_MASK;
extern uint32 RGB_HI_BITS_MASK;
extern uint32 RGB_HI_BITS_MASKx2;
extern uint32 RGB_REMOVE_LOW_BITS_MASK;
extern uint32 FIRST_THIRD_COLOR_MASK;
extern uint32 TWO_LOW_BITS_MASK;
extern uint32 HIGH_BITS_SHIFTED_TWO_MASK;
extern uint32 SPARE_RGB_BIT_MASK;
#endif
/* RGB565 format */ /* RGB565 format */
#define BUILD_PIXEL_RGB565(R, G, B) (((int) (R) << 11) | ((int) (G) << 6) | (int) (B)) #define BUILD_PIXEL_RGB565(R, G, B) (((int)(R) << 11) | ((int)(G) << 6) | (int)(B))
#define BUILD_PIXEL2_RGB565(R, G, B) (((int) (R) << 11) | ((int) (G) << 5) | (int) (B)) #define BUILD_PIXEL2_RGB565(R, G, B) (((int)(R) << 11) | ((int)(G) << 5) | (int)(B))
#define DECOMPOSE_PIXEL_RGB565(PIX, R, G, B) { (R) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (B) = (PIX) & 0x1f; } #define DECOMPOSE_PIXEL_RGB565(PIX, R, G, B) \
#define SPARE_RGB_BIT_MASK_RGB565 (1 << 5) { \
(R) = (PIX) >> 11; \
(G) = ((PIX) >> 6) & 0x1f; \
(B) = (PIX)&0x1f; \
}
#define SPARE_RGB_BIT_MASK_RGB565 (1 << 5)
#define MAX_RED_RGB565 31 #define MAX_RED_RGB565 31
#define MAX_GREEN_RGB565 63 #define MAX_GREEN_RGB565 63
#define MAX_BLUE_RGB565 31 #define MAX_BLUE_RGB565 31
#define RED_SHIFT_BITS_RGB565 11 #define RED_SHIFT_BITS_RGB565 11
#define GREEN_SHIFT_BITS_RGB565 6 #define GREEN_SHIFT_BITS_RGB565 6
#define RED_LOW_BIT_MASK_RGB565 0x0800 #define RED_LOW_BIT_MASK_RGB565 0x0800
#define GREEN_LOW_BIT_MASK_RGB565 0x0020 #define GREEN_LOW_BIT_MASK_RGB565 0x0020
#define BLUE_LOW_BIT_MASK_RGB565 0x0001 #define BLUE_LOW_BIT_MASK_RGB565 0x0001
#define RED_HI_BIT_MASK_RGB565 0x8000 #define RED_HI_BIT_MASK_RGB565 0x8000
#define GREEN_HI_BIT_MASK_RGB565 0x0400 #define GREEN_HI_BIT_MASK_RGB565 0x0400
#define BLUE_HI_BIT_MASK_RGB565 0x0010 #define BLUE_HI_BIT_MASK_RGB565 0x0010
#define FIRST_COLOR_MASK_RGB565 0xF800 #define FIRST_COLOR_MASK_RGB565 0xF800
#define SECOND_COLOR_MASK_RGB565 0x07E0 #define SECOND_COLOR_MASK_RGB565 0x07E0
#define THIRD_COLOR_MASK_RGB565 0x001F #define THIRD_COLOR_MASK_RGB565 0x001F
#define ALPHA_BITS_MASK_RGB565 0x0000 #define ALPHA_BITS_MASK_RGB565 0x0000
/* RGB555 format */ /* RGB555 format */
#define BUILD_PIXEL_RGB555(R, G, B) (((int) (R) << 10) | ((int) (G) << 5) | (int) (B)) #define BUILD_PIXEL_RGB555(R, G, B) (((int)(R) << 10) | ((int)(G) << 5) | (int)(B))
#define BUILD_PIXEL2_RGB555(R, G, B) (((int) (R) << 10) | ((int) (G) << 5) | (int) (B)) #define BUILD_PIXEL2_RGB555(R, G, B) (((int)(R) << 10) | ((int)(G) << 5) | (int)(B))
#define DECOMPOSE_PIXEL_RGB555(PIX, R, G, B) { (R) = (PIX) >> 10; (G) = ((PIX) >> 5) & 0x1f; (B) = (PIX) & 0x1f; } #define DECOMPOSE_PIXEL_RGB555(PIX, R, G, B) \
#define SPARE_RGB_BIT_MASK_RGB555 (1 << 15) { \
(R) = (PIX) >> 10; \
(G) = ((PIX) >> 5) & 0x1f; \
(B) = (PIX)&0x1f; \
}
#define SPARE_RGB_BIT_MASK_RGB555 (1 << 15)
#define MAX_RED_RGB555 31 #define MAX_RED_RGB555 31
#define MAX_GREEN_RGB555 31 #define MAX_GREEN_RGB555 31
#define MAX_BLUE_RGB555 31 #define MAX_BLUE_RGB555 31
#define RED_SHIFT_BITS_RGB555 10 #define RED_SHIFT_BITS_RGB555 10
#define GREEN_SHIFT_BITS_RGB555 5 #define GREEN_SHIFT_BITS_RGB555 5
#define RED_LOW_BIT_MASK_RGB555 0x0400 #define RED_LOW_BIT_MASK_RGB555 0x0400
#define GREEN_LOW_BIT_MASK_RGB555 0x0020 #define GREEN_LOW_BIT_MASK_RGB555 0x0020
#define BLUE_LOW_BIT_MASK_RGB555 0x0001 #define BLUE_LOW_BIT_MASK_RGB555 0x0001
#define RED_HI_BIT_MASK_RGB555 0x4000 #define RED_HI_BIT_MASK_RGB555 0x4000
#define GREEN_HI_BIT_MASK_RGB555 0x0200 #define GREEN_HI_BIT_MASK_RGB555 0x0200
#define BLUE_HI_BIT_MASK_RGB555 0x0010 #define BLUE_HI_BIT_MASK_RGB555 0x0010
#define FIRST_COLOR_MASK_RGB555 0x7C00 #define FIRST_COLOR_MASK_RGB555 0x7C00
#define SECOND_COLOR_MASK_RGB555 0x03E0 #define SECOND_COLOR_MASK_RGB555 0x03E0
#define THIRD_COLOR_MASK_RGB555 0x001F #define THIRD_COLOR_MASK_RGB555 0x001F
#define ALPHA_BITS_MASK_RGB555 0x0000 #define ALPHA_BITS_MASK_RGB555 0x0000
/* BGR565 format */ #define CONCAT(X, Y) X##Y
#define BUILD_PIXEL_BGR565(R, G, B) (((int) (B) << 11) | ((int) (G) << 6) | (int) (R))
#define BUILD_PIXEL2_BGR565(R, G, B) (((int) (B) << 11) | ((int) (G) << 5) | (int) (R))
#define DECOMPOSE_PIXEL_BGR565(PIX, R, G, B) { (B) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_BGR565 (1 << 5)
#define MAX_RED_BGR565 31
#define MAX_GREEN_BGR565 63
#define MAX_BLUE_BGR565 31
#define RED_LOW_BIT_MASK_BGR565 0x0001
#define GREEN_LOW_BIT_MASK_BGR565 0x0040
#define BLUE_LOW_BIT_MASK_BGR565 0x0800
#define RED_HI_BIT_MASK_BGR565 0x0010
#define GREEN_HI_BIT_MASK_BGR565 0x0400
#define BLUE_HI_BIT_MASK_BGR565 0x8000
#define FIRST_COLOR_MASK_BGR565 0xF800
#define SECOND_COLOR_MASK_BGR565 0x07E0
#define THIRD_COLOR_MASK_BGR565 0x001F
#define ALPHA_BITS_MASK_BGR565 0x0000
/* BGR555 format */
#define BUILD_PIXEL_BGR555(R, G, B) (((int) (B) << 10) | ((int) (G) << 5) | (int) (R))
#define BUILD_PIXEL2_BGR555(R, G, B) (((int) (B) << 10) | ((int) (G) << 5) | (int) (R))
#define DECOMPOSE_PIXEL_BGR555(PIX, R, G, B) { (B) = (PIX) >> 10; (G) = ((PIX) >> 5) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_BGR555 (1 << 15)
#define MAX_RED_BGR555 31
#define MAX_GREEN_BGR555 31
#define MAX_BLUE_BGR555 31
#define RED_LOW_BIT_MASK_BGR555 0x0001
#define GREEN_LOW_BIT_MASK_BGR555 0x0020
#define BLUE_LOW_BIT_MASK_BGR555 0x0400
#define RED_HI_BIT_MASK_BGR555 0x0010
#define GREEN_HI_BIT_MASK_BGR555 0x0200
#define BLUE_HI_BIT_MASK_BGR555 0x4000
#define FIRST_COLOR_MASK_BGR555 0x7C00
#define SECOND_COLOR_MASK_BGR555 0x03E0
#define THIRD_COLOR_MASK_BGR555 0x001F
#define ALPHA_BITS_MASK_BGR555 0x0000
/* GBR565 format */
#define BUILD_PIXEL_GBR565(R, G, B) (((int) (G) << 11) | ((int) (B) << 6) | (int) (R))
#define BUILD_PIXEL2_GBR565(R, G, B) (((int) (G) << 11) | ((int) (B) << 5) | (int) (R))
#define DECOMPOSE_PIXEL_GBR565(PIX, R, G, B) { (G) = (PIX) >> 11; (B) = ((PIX) >> 6) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_GBR565 (1 << 5)
#define MAX_RED_GBR565 31
#define MAX_GREEN_GBR565 31
#define MAX_BLUE_GBR565 63
#define RED_LOW_BIT_MASK_GBR565 0x0001
#define GREEN_LOW_BIT_MASK_GBR565 0x0800
#define BLUE_LOW_BIT_MASK_GBR565 0x0040
#define RED_HI_BIT_MASK_GBR565 0x0010
#define GREEN_HI_BIT_MASK_GBR565 0x8000
#define BLUE_HI_BIT_MASK_GBR565 0x0400
#define FIRST_COLOR_MASK_GBR565 0xF800
#define SECOND_COLOR_MASK_GBR565 0x07E0
#define THIRD_COLOR_MASK_GBR565 0x001F
#define ALPHA_BITS_MASK_GBR565 0x0000
/* GBR555 format */
#define BUILD_PIXEL_GBR555(R, G, B) (((int) (G) << 10) | ((int) (B) << 5) | (int) (R))
#define BUILD_PIXEL2_GBR555(R, G, B) (((int) (G) << 10) | ((int) (B) << 5) | (int) (R))
#define DECOMPOSE_PIXEL_GBR555(PIX, R, G, B) { (G) = (PIX) >> 10; (B) = ((PIX) >> 5) & 0x1f; (R) = (PIX) & 0x1f; }
#define SPARE_RGB_BIT_MASK_GBR555 (1 << 15)
#define MAX_RED_GBR555 31
#define MAX_GREEN_GBR555 31
#define MAX_BLUE_GBR555 31
#define RED_LOW_BIT_MASK_GBR555 0x0001
#define GREEN_LOW_BIT_MASK_GBR555 0x0400
#define BLUE_LOW_BIT_MASK_GBR555 0x0020
#define RED_HI_BIT_MASK_GBR555 0x0010
#define GREEN_HI_BIT_MASK_GBR555 0x4000
#define BLUE_HI_BIT_MASK_GBR555 0x0200
#define FIRST_COLOR_MASK_GBR555 0x7C00
#define SECOND_COLOR_MASK_GBR555 0x03E0
#define THIRD_COLOR_MASK_GBR555 0x001F
#define ALPHA_BITS_MASK_GBR555 0x0000
/* RGB5551 format */
#define BUILD_PIXEL_RGB5551(R, G, B) (((int) (R) << 11) | ((int) (G) << 6) | (int) ((B) << 1) | 1)
#define BUILD_PIXEL2_RGB5551(R, G, B) (((int) (R) << 11) | ((int) (G) << 6) | (int) ((B) << 1) | 1)
#define DECOMPOSE_PIXEL_RGB5551(PIX, R, G, B) { (R) = (PIX) >> 11; (G) = ((PIX) >> 6) & 0x1f; (B) = ((PIX) >> 1) & 0x1f; }
#define SPARE_RGB_BIT_MASK_RGB5551 (1)
#define MAX_RED_RGB5551 31
#define MAX_GREEN_RGB5551 31
#define MAX_BLUE_RGB5551 31
#define RED_LOW_BIT_MASK_RGB5551 0x0800
#define GREEN_LOW_BIT_MASK_RGB5551 0x0040
#define BLUE_LOW_BIT_MASK_RGB5551 0x0002
#define RED_HI_BIT_MASK_RGB5551 0x8000
#define GREEN_HI_BIT_MASK_RGB5551 0x0400
#define BLUE_HI_BIT_MASK_RGB5551 0x0020
#define FIRST_COLOR_MASK_RGB5551 0xf800
#define SECOND_COLOR_MASK_RGB5551 0x07c0
#define THIRD_COLOR_MASK_RGB5551 0x003e
#define ALPHA_BITS_MASK_RGB5551 0x0001
#ifndef GFX_MULTI_FORMAT
#define CONCAT(X, Y) X##Y
// C pre-processor needs a two stage macro define to enable it to concat // C pre-processor needs a two stage macro define to enable it to concat
// to macro names together to form the name of another macro. // to macro names together to form the name of another macro.
#define BUILD_PIXEL_D(F, R, G, B) CONCAT(BUILD_PIXEL_,F) (R, G, B) #define BUILD_PIXEL_D(F, R, G, B) CONCAT(BUILD_PIXEL_, F) (R, G, B)
#define BUILD_PIXEL2_D(F, R, G, B) CONCAT(BUILD_PIXEL2_,F) (R, G, B) #define BUILD_PIXEL2_D(F, R, G, B) CONCAT(BUILD_PIXEL2_, F) (R, G, B)
#define DECOMPOSE_PIXEL_D(F, PIX, R, G, B) CONCAT(DECOMPOSE_PIXEL_,F) (PIX, R, G, B) #define DECOMPOSE_PIXEL_D(F, PIX, R, G, B) CONCAT(DECOMPOSE_PIXEL_, F) (PIX, R, G, B)
#define BUILD_PIXEL(R, G, B) BUILD_PIXEL_D(PIXEL_FORMAT, R, G, B) #define BUILD_PIXEL(R, G, B) BUILD_PIXEL_D(PIXEL_FORMAT, R, G, B)
#define BUILD_PIXEL2(R, G, B) BUILD_PIXEL2_D(PIXEL_FORMAT, R, G, B) #define BUILD_PIXEL2(R, G, B) BUILD_PIXEL2_D(PIXEL_FORMAT, R, G, B)
#define DECOMPOSE_PIXEL(PIX, R, G, B) DECOMPOSE_PIXEL_D(PIXEL_FORMAT, PIX, R, G, B) #define DECOMPOSE_PIXEL(PIX, R, G, B) DECOMPOSE_PIXEL_D(PIXEL_FORMAT, PIX, R, G, B)
#define MAX_RED_D(F) CONCAT(MAX_RED_, F) #define MAX_RED_D(F) CONCAT(MAX_RED_, F)
#define MAX_GREEN_D(F) CONCAT(MAX_GREEN_, F) #define MAX_GREEN_D(F) CONCAT(MAX_GREEN_, F)
#define MAX_BLUE_D(F) CONCAT(MAX_BLUE_, F) #define MAX_BLUE_D(F) CONCAT(MAX_BLUE_, F)
#define RED_SHIFT_BITS_D(F) CONCAT(RED_SHIFT_BITS_, F) #define RED_SHIFT_BITS_D(F) CONCAT(RED_SHIFT_BITS_, F)
#define GREEN_SHIFT_BITS_D(F) CONCAT(GREEN_SHIFT_BITS_, F) #define GREEN_SHIFT_BITS_D(F) CONCAT(GREEN_SHIFT_BITS_, F)
#define RED_LOW_BIT_MASK_D(F) CONCAT(RED_LOW_BIT_MASK_, F) #define RED_LOW_BIT_MASK_D(F) CONCAT(RED_LOW_BIT_MASK_, F)
#define GREEN_LOW_BIT_MASK_D(F) CONCAT(GREEN_LOW_BIT_MASK_, F) #define GREEN_LOW_BIT_MASK_D(F) CONCAT(GREEN_LOW_BIT_MASK_, F)
#define BLUE_LOW_BIT_MASK_D(F) CONCAT(BLUE_LOW_BIT_MASK_, F) #define BLUE_LOW_BIT_MASK_D(F) CONCAT(BLUE_LOW_BIT_MASK_, F)
#define RED_HI_BIT_MASK_D(F) CONCAT(RED_HI_BIT_MASK_, F) #define RED_HI_BIT_MASK_D(F) CONCAT(RED_HI_BIT_MASK_, F)
#define GREEN_HI_BIT_MASK_D(F) CONCAT(GREEN_HI_BIT_MASK_, F) #define GREEN_HI_BIT_MASK_D(F) CONCAT(GREEN_HI_BIT_MASK_, F)
#define BLUE_HI_BIT_MASK_D(F) CONCAT(BLUE_HI_BIT_MASK_, F) #define BLUE_HI_BIT_MASK_D(F) CONCAT(BLUE_HI_BIT_MASK_, F)
#define FIRST_COLOR_MASK_D(F) CONCAT(FIRST_COLOR_MASK_, F) #define FIRST_COLOR_MASK_D(F) CONCAT(FIRST_COLOR_MASK_, F)
#define SECOND_COLOR_MASK_D(F) CONCAT(SECOND_COLOR_MASK_, F) #define SECOND_COLOR_MASK_D(F) CONCAT(SECOND_COLOR_MASK_, F)
#define THIRD_COLOR_MASK_D(F) CONCAT(THIRD_COLOR_MASK_, F) #define THIRD_COLOR_MASK_D(F) CONCAT(THIRD_COLOR_MASK_, F)
#define ALPHA_BITS_MASK_D(F) CONCAT(ALPHA_BITS_MASK_, F) #define ALPHA_BITS_MASK_D(F) CONCAT(ALPHA_BITS_MASK_, F)
#define MAX_RED MAX_RED_D(PIXEL_FORMAT) #define MAX_RED MAX_RED_D(PIXEL_FORMAT)
#define MAX_GREEN MAX_GREEN_D(PIXEL_FORMAT) #define MAX_GREEN MAX_GREEN_D(PIXEL_FORMAT)
#define MAX_BLUE MAX_BLUE_D(PIXEL_FORMAT) #define MAX_BLUE MAX_BLUE_D(PIXEL_FORMAT)
#define RED_SHIFT_BITS RED_SHIFT_BITS_D(PIXEL_FORMAT) #define RED_SHIFT_BITS RED_SHIFT_BITS_D(PIXEL_FORMAT)
#define GREEN_SHIFT_BITS GREEN_SHIFT_BITS_D(PIXEL_FORMAT) #define GREEN_SHIFT_BITS GREEN_SHIFT_BITS_D(PIXEL_FORMAT)
#define RED_LOW_BIT_MASK RED_LOW_BIT_MASK_D(PIXEL_FORMAT) #define RED_LOW_BIT_MASK RED_LOW_BIT_MASK_D(PIXEL_FORMAT)
#define GREEN_LOW_BIT_MASK GREEN_LOW_BIT_MASK_D(PIXEL_FORMAT) #define GREEN_LOW_BIT_MASK GREEN_LOW_BIT_MASK_D(PIXEL_FORMAT)
#define BLUE_LOW_BIT_MASK BLUE_LOW_BIT_MASK_D(PIXEL_FORMAT) #define BLUE_LOW_BIT_MASK BLUE_LOW_BIT_MASK_D(PIXEL_FORMAT)
#define RED_HI_BIT_MASK RED_HI_BIT_MASK_D(PIXEL_FORMAT) #define RED_HI_BIT_MASK RED_HI_BIT_MASK_D(PIXEL_FORMAT)
#define GREEN_HI_BIT_MASK GREEN_HI_BIT_MASK_D(PIXEL_FORMAT) #define GREEN_HI_BIT_MASK GREEN_HI_BIT_MASK_D(PIXEL_FORMAT)
#define BLUE_HI_BIT_MASK BLUE_HI_BIT_MASK_D(PIXEL_FORMAT) #define BLUE_HI_BIT_MASK BLUE_HI_BIT_MASK_D(PIXEL_FORMAT)
#define FIRST_COLOR_MASK FIRST_COLOR_MASK_D(PIXEL_FORMAT) #define FIRST_COLOR_MASK FIRST_COLOR_MASK_D(PIXEL_FORMAT)
#define SECOND_COLOR_MASK SECOND_COLOR_MASK_D(PIXEL_FORMAT) #define SECOND_COLOR_MASK SECOND_COLOR_MASK_D(PIXEL_FORMAT)
#define THIRD_COLOR_MASK THIRD_COLOR_MASK_D(PIXEL_FORMAT) #define THIRD_COLOR_MASK THIRD_COLOR_MASK_D(PIXEL_FORMAT)
#define ALPHA_BITS_MASK ALPHA_BITS_MASK_D(PIXEL_FORMAT) #define ALPHA_BITS_MASK ALPHA_BITS_MASK_D(PIXEL_FORMAT)
#define GREEN_HI_BIT ((MAX_GREEN + 1) >> 1) #define GREEN_HI_BIT ((MAX_GREEN + 1) >> 1)
#define RGB_LOW_BITS_MASK (RED_LOW_BIT_MASK | GREEN_LOW_BIT_MASK | BLUE_LOW_BIT_MASK) #define RGB_LOW_BITS_MASK (RED_LOW_BIT_MASK | GREEN_LOW_BIT_MASK | BLUE_LOW_BIT_MASK)
#define RGB_HI_BITS_MASK (RED_HI_BIT_MASK | GREEN_HI_BIT_MASK | BLUE_HI_BIT_MASK) #define RGB_HI_BITS_MASK (RED_HI_BIT_MASK | GREEN_HI_BIT_MASK | BLUE_HI_BIT_MASK)
#define RGB_HI_BITS_MASKx2 ((RED_HI_BIT_MASK | GREEN_HI_BIT_MASK | BLUE_HI_BIT_MASK) << 1) #define RGB_HI_BITS_MASKx2 ((RED_HI_BIT_MASK | GREEN_HI_BIT_MASK | BLUE_HI_BIT_MASK) << 1)
#define RGB_REMOVE_LOW_BITS_MASK (~RGB_LOW_BITS_MASK) #define RGB_REMOVE_LOW_BITS_MASK (~RGB_LOW_BITS_MASK)
#define FIRST_THIRD_COLOR_MASK (FIRST_COLOR_MASK | THIRD_COLOR_MASK) #define FIRST_THIRD_COLOR_MASK (FIRST_COLOR_MASK | THIRD_COLOR_MASK)
#define TWO_LOW_BITS_MASK (RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 1)) #define TWO_LOW_BITS_MASK (RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 1))
#define HIGH_BITS_SHIFTED_TWO_MASK (((FIRST_COLOR_MASK | SECOND_COLOR_MASK | THIRD_COLOR_MASK) & ~TWO_LOW_BITS_MASK ) >> 2) #define HIGH_BITS_SHIFTED_TWO_MASK (((FIRST_COLOR_MASK | SECOND_COLOR_MASK | THIRD_COLOR_MASK) & ~TWO_LOW_BITS_MASK) >> 2)
#endif #endif // _PIXFORM_H_
#endif

6
port.h
View File

@ -33,16 +33,10 @@
#define RIGHTSHIFT_int32_IS_SAR #define RIGHTSHIFT_int32_IS_SAR
#ifndef __LIBRETRO__ #ifndef __LIBRETRO__
#define SNES_JOY_READ_CALLBACKS #define SNES_JOY_READ_CALLBACKS
#define GFX_MULTI_FORMAT
#endif //__LIBRETRO__ #endif //__LIBRETRO__
#endif #endif
#ifdef __LIBRETRO__
#define GFX_MULTI_FORMAT
#endif
#ifdef __MACOSX__ #ifdef __MACOSX__
#undef GFX_MULTI_FORMAT
#define PIXEL_FORMAT RGB555 #define PIXEL_FORMAT RGB555
#endif #endif

2
unix/configure vendored
View File

@ -6319,8 +6319,6 @@ else
S9XDEFS="$S9XDEFS -DNOSOUND" S9XDEFS="$S9XDEFS -DNOSOUND"
fi fi
S9XDEFS="$S9XDEFS -DGFX_MULTI_FORMAT"
# Output. # Output.
S9XFLGS="$S9XFLGS $CXXFLAGS $CPPFLAGS $LDFLAGS" S9XFLGS="$S9XFLGS $CXXFLAGS $CPPFLAGS $LDFLAGS"

View File

@ -450,8 +450,6 @@ else
S9XDEFS="$S9XDEFS -DNOSOUND" S9XDEFS="$S9XDEFS -DNOSOUND"
fi fi
S9XDEFS="$S9XDEFS -DGFX_MULTI_FORMAT"
# Output. # Output.
S9XFLGS="$S9XFLGS $CXXFLAGS $CPPFLAGS $LDFLAGS" S9XFLGS="$S9XFLGS $CXXFLAGS $CPPFLAGS $LDFLAGS"

View File

@ -1542,10 +1542,6 @@ int main (int argc, char **argv)
S9xReportControllers(); S9xReportControllers();
#ifdef GFX_MULTI_FORMAT
S9xSetRenderPixelFormat(RGB565);
#endif
uint32 saved_flags = CPU.Flags; uint32 saved_flags = CPU.Flags;
bool8 loaded = FALSE; bool8 loaded = FALSE;

View File

@ -864,43 +864,7 @@ xinerama_end:
} }
#endif #endif
switch (GUI.depth) GUI.pixel_format = 565;
{
default:
case 32:
case 24:
S9xSetRenderPixelFormat(RGB555);
GUI.pixel_format = 555;
break;
case 16:
if (GUI.red_size != GUI.green_size || GUI.blue_size != GUI.green_size)
{
// 565 format
if (GUI.green_shift > GUI.blue_shift && GUI.green_shift > GUI.red_shift)
S9xSetRenderPixelFormat(GBR565);
else
if (GUI.red_shift > GUI.blue_shift)
S9xSetRenderPixelFormat(RGB565);
else
S9xSetRenderPixelFormat(BGR565);
GUI.pixel_format = 565;
break;
}
// FALL ...
case 15:
if (GUI.green_shift > GUI.blue_shift && GUI.green_shift > GUI.red_shift)
S9xSetRenderPixelFormat(GBR555);
else
if (GUI.red_shift > GUI.blue_shift)
S9xSetRenderPixelFormat(RGB555);
else
S9xSetRenderPixelFormat(BGR555);
GUI.pixel_format = 555;
break;
}
SetupImage(); SetupImage();

View File

@ -587,7 +587,6 @@ void CDirect3D::SetSnes9xColorFormat()
GUI.BlueShift = 0; GUI.BlueShift = 0;
GUI.GreenShift = 6; GUI.GreenShift = 6;
GUI.RedShift = 11; GUI.RedShift = 11;
S9xSetRenderPixelFormat (RGB565);
S9xBlit2xSaIFilterInit(); S9xBlit2xSaIFilterInit();
S9xBlitHQ2xFilterInit(); S9xBlitHQ2xFilterInit();
GUI.NeedDepthConvert = FALSE; GUI.NeedDepthConvert = FALSE;

View File

@ -442,7 +442,6 @@ void COpenGL::SetSnes9xColorFormat()
GUI.BlueShift = 0; GUI.BlueShift = 0;
GUI.GreenShift = 6; GUI.GreenShift = 6;
GUI.RedShift = 11; GUI.RedShift = 11;
S9xSetRenderPixelFormat (RGB565);
S9xBlit2xSaIFilterInit(); S9xBlit2xSaIFilterInit();
S9xBlitHQ2xFilterInit(); S9xBlitHQ2xFilterInit();
GUI.NeedDepthConvert = FALSE; GUI.NeedDepthConvert = FALSE;

View File

@ -315,7 +315,6 @@ sets default settings and calls the appropriate display object
*/ */
void S9xSetWinPixelFormat () void S9xSetWinPixelFormat ()
{ {
S9xSetRenderPixelFormat (RGB565);
GUI.NeedDepthConvert = FALSE; GUI.NeedDepthConvert = FALSE;
GUI.DepthConverted = !GUI.NeedDepthConvert; GUI.DepthConverted = !GUI.NeedDepthConvert;