mirror of https://github.com/snes9xgit/snes9x.git
Select brightness function in tile renderer.
This commit is contained in:
parent
2d97d2dd98
commit
9721f78df1
45
gfx.h
45
gfx.h
|
@ -131,8 +131,9 @@ extern struct SGFX GFX;
|
||||||
((((((C1) & RGB_REMOVE_LOW_BITS_MASK) + \
|
((((((C1) & RGB_REMOVE_LOW_BITS_MASK) + \
|
||||||
((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)
|
||||||
|
#define COLOR_ADD_BRIGHTNESS1_2 COLOR_ADD1_2
|
||||||
|
|
||||||
inline uint16 COLOR_ADD(uint16 C1, uint16 C2)
|
inline uint16 COLOR_ADD_BRIGHTNESS(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) |
|
||||||
(brightness_cap[((C1 >> GREEN_SHIFT_BITS) & 0x1f) + ((C2 >> GREEN_SHIFT_BITS) & 0x1f)] << GREEN_SHIFT_BITS) |
|
(brightness_cap[((C1 >> GREEN_SHIFT_BITS) & 0x1f) + ((C2 >> GREEN_SHIFT_BITS) & 0x1f)] << GREEN_SHIFT_BITS) |
|
||||||
|
@ -143,27 +144,39 @@ inline uint16 COLOR_ADD(uint16 C1, uint16 C2)
|
||||||
(brightness_cap[ (C1 & 0x1f) + (C2 & 0x1f)] ));
|
(brightness_cap[ (C1 & 0x1f) + (C2 & 0x1f)] ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline uint16 COLOR_ADD(uint16 C1, uint16 C2)
|
||||||
|
{
|
||||||
|
const int RED_MASK = 0x1F << RED_SHIFT_BITS;
|
||||||
|
const int GREEN_MASK = 0x1F << GREEN_SHIFT_BITS;
|
||||||
|
const int BLUE_MASK = 0x1F;
|
||||||
|
|
||||||
|
int rb = C1 & (RED_MASK | BLUE_MASK);
|
||||||
|
rb += C2 & (RED_MASK | BLUE_MASK);
|
||||||
|
int rbcarry = rb & ((0x20 << RED_SHIFT_BITS) | (0x20 << 0));
|
||||||
|
int g = (C1 & (GREEN_MASK)) + (C2 & (GREEN_MASK));
|
||||||
|
int rgbsaturate = (((g & (0x20 << GREEN_SHIFT_BITS)) | rbcarry) >> 5) * 0x1f;
|
||||||
|
return (uint16)((rb & (RED_MASK | BLUE_MASK)) | (g & GREEN_MASK) | rgbsaturate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#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]
|
||||||
|
|
||||||
inline uint16 COLOR_SUB (uint16 C1, uint16 C2)
|
inline uint16 COLOR_SUB (uint16 C1, uint16 C2)
|
||||||
{
|
{
|
||||||
uint16 mC1, mC2, v = ALPHA_BITS_MASK;
|
int a = (C1 & (THIRD_COLOR_MASK | FIRST_COLOR_MASK)) | ((0x20 << 0) | (0x20 << RED_SHIFT_BITS));
|
||||||
|
int b = C2 & (THIRD_COLOR_MASK | FIRST_COLOR_MASK);
|
||||||
mC1 = C1 & FIRST_COLOR_MASK;
|
int c = a - b;
|
||||||
mC2 = C2 & FIRST_COLOR_MASK;
|
int d = c & ((0x20 << RED_SHIFT_BITS) | (0x20 << 0));
|
||||||
if (mC1 > mC2) v += (mC1 - mC2);
|
int e = (C1 & (SECOND_COLOR_MASK)) | (0x20 << GREEN_SHIFT_BITS);
|
||||||
|
int f = C2 & (SECOND_COLOR_MASK);
|
||||||
mC1 = C1 & SECOND_COLOR_MASK;
|
int g = e - f;
|
||||||
mC2 = C2 & SECOND_COLOR_MASK;
|
int h = (g & (0x20 << GREEN_SHIFT_BITS)) | d;
|
||||||
if (mC1 > mC2) v += (mC1 - mC2);
|
int i = h >> 5;
|
||||||
|
int j = i * 0x1F;
|
||||||
mC1 = C1 & THIRD_COLOR_MASK;
|
int k = ((c & (THIRD_COLOR_MASK | FIRST_COLOR_MASK)) | (g & SECOND_COLOR_MASK)) & j;
|
||||||
mC2 = C2 & THIRD_COLOR_MASK;
|
return (uint16)k;
|
||||||
if (mC1 > mC2) v += (mC1 - mC2);
|
|
||||||
|
|
||||||
return (v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void S9xStartScreenRefresh (void);
|
void S9xStartScreenRefresh (void);
|
||||||
|
|
29
tile.cpp
29
tile.cpp
|
@ -21,7 +21,6 @@ static uint32 pixbit[8][16];
|
||||||
static uint8 hrbit_odd[256];
|
static uint8 hrbit_odd[256];
|
||||||
static uint8 hrbit_even[256];
|
static uint8 hrbit_even[256];
|
||||||
|
|
||||||
|
|
||||||
void S9xInitTileRenderer (void)
|
void S9xInitTileRenderer (void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -400,6 +399,14 @@ void S9xSelectTileRenderers (int BGMode, bool8 sub, bool8 obj)
|
||||||
if (Memory.FillRAM[0x2130] & 2)
|
if (Memory.FillRAM[0x2130] & 2)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (IPPU.MaxBrightness != 0xf)
|
||||||
|
{
|
||||||
|
if (i == 1)
|
||||||
|
i = 7;
|
||||||
|
else if (i == 3)
|
||||||
|
i = 8;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GFX.DrawTileMath = DT[i];
|
GFX.DrawTileMath = DT[i];
|
||||||
|
@ -1287,6 +1294,13 @@ static void MAKENAME(NAME1, Add_, NAME2) (ARGS)
|
||||||
#undef MATH
|
#undef MATH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void MAKENAME(NAME1, Add_Brightness_, NAME2) (ARGS)
|
||||||
|
{
|
||||||
|
#define MATH(A, B, C) REGMATH(ADD_BRIGHTNESS, A, B, C)
|
||||||
|
DRAW_TILE();
|
||||||
|
#undef MATH
|
||||||
|
}
|
||||||
|
|
||||||
static void MAKENAME(NAME1, AddF1_2_, NAME2) (ARGS)
|
static void MAKENAME(NAME1, AddF1_2_, NAME2) (ARGS)
|
||||||
{
|
{
|
||||||
#define MATH(A, B, C) MATHF1_2(ADD, A, B, C)
|
#define MATH(A, B, C) MATHF1_2(ADD, A, B, C)
|
||||||
|
@ -1301,6 +1315,13 @@ static void MAKENAME(NAME1, AddS1_2_, NAME2) (ARGS)
|
||||||
#undef MATH
|
#undef MATH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void MAKENAME(NAME1, AddS1_2_Brightness_, NAME2) (ARGS)
|
||||||
|
{
|
||||||
|
#define MATH(A, B, C) MATHS1_2(ADD_BRIGHTNESS, A, B, C)
|
||||||
|
DRAW_TILE();
|
||||||
|
#undef MATH
|
||||||
|
}
|
||||||
|
|
||||||
static void MAKENAME(NAME1, Sub_, NAME2) (ARGS)
|
static void MAKENAME(NAME1, Sub_, NAME2) (ARGS)
|
||||||
{
|
{
|
||||||
#define MATH(A, B, C) REGMATH(SUB, A, B, C)
|
#define MATH(A, B, C) REGMATH(SUB, A, B, C)
|
||||||
|
@ -1322,7 +1343,7 @@ static void MAKENAME(NAME1, SubS1_2_, NAME2) (ARGS)
|
||||||
#undef MATH
|
#undef MATH
|
||||||
}
|
}
|
||||||
|
|
||||||
static void (*MAKENAME(Renderers_, NAME1, NAME2)[7]) (ARGS) =
|
static void (*MAKENAME(Renderers_, NAME1, NAME2)[9]) (ARGS) =
|
||||||
{
|
{
|
||||||
MAKENAME(NAME1, _, NAME2),
|
MAKENAME(NAME1, _, NAME2),
|
||||||
MAKENAME(NAME1, Add_, NAME2),
|
MAKENAME(NAME1, Add_, NAME2),
|
||||||
|
@ -1330,7 +1351,9 @@ static void (*MAKENAME(Renderers_, NAME1, NAME2)[7]) (ARGS) =
|
||||||
MAKENAME(NAME1, AddS1_2_, NAME2),
|
MAKENAME(NAME1, AddS1_2_, NAME2),
|
||||||
MAKENAME(NAME1, Sub_, NAME2),
|
MAKENAME(NAME1, Sub_, NAME2),
|
||||||
MAKENAME(NAME1, SubF1_2_, NAME2),
|
MAKENAME(NAME1, SubF1_2_, NAME2),
|
||||||
MAKENAME(NAME1, SubS1_2_, NAME2)
|
MAKENAME(NAME1, SubS1_2_, NAME2),
|
||||||
|
MAKENAME(NAME1, Add_Brightness_, NAME2),
|
||||||
|
MAKENAME(NAME1, AddS1_2_Brightness_, NAME2)
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef MAKENAME
|
#undef MAKENAME
|
||||||
|
|
Loading…
Reference in New Issue