mirror of https://github.com/snes9xgit/snes9x.git
Use a lookup table. A little faster.
This commit is contained in:
parent
db8227fa42
commit
02aa2d0c6a
17
gfx.h
17
gfx.h
|
@ -125,6 +125,7 @@ struct SLineMatrixData
|
||||||
extern uint16 BlackColourMap[256];
|
extern uint16 BlackColourMap[256];
|
||||||
extern uint16 DirectColourMaps[8][256];
|
extern uint16 DirectColourMaps[8][256];
|
||||||
extern uint8 mul_brightness[16][32];
|
extern uint8 mul_brightness[16][32];
|
||||||
|
extern uint8 brightness_cap[64];
|
||||||
extern struct SBG BG;
|
extern struct SBG BG;
|
||||||
extern struct SGFX GFX;
|
extern struct SGFX GFX;
|
||||||
|
|
||||||
|
@ -132,8 +133,6 @@ extern struct SGFX GFX;
|
||||||
#define V_FLIP 0x8000
|
#define V_FLIP 0x8000
|
||||||
#define BLANK_TILE 2
|
#define BLANK_TILE 2
|
||||||
|
|
||||||
#include "ppu.h"
|
|
||||||
|
|
||||||
#define COLOR_ADD1_2(C1, C2) \
|
#define COLOR_ADD1_2(C1, C2) \
|
||||||
((((((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) + \
|
||||||
|
@ -148,19 +147,11 @@ extern struct SGFX GFX;
|
||||||
inline uint16 COLOR_ADD(uint16 C1, uint16 C2)
|
inline uint16 COLOR_ADD(uint16 C1, uint16 C2)
|
||||||
{
|
{
|
||||||
int r1, g1, b1, r2, g2, b2;
|
int r1, g1, b1, r2, g2, b2;
|
||||||
int cap = mul_brightness[PPU.Brightness][31];
|
|
||||||
DECOMPOSE_PIXEL(C1, r1, g1, b1);
|
DECOMPOSE_PIXEL(C1, r1, g1, b1);
|
||||||
DECOMPOSE_PIXEL(C2, r2, g2, b2);
|
DECOMPOSE_PIXEL(C2, r2, g2, b2);
|
||||||
r1 += r2;
|
return BUILD_PIXEL(brightness_cap[r1 + r2],
|
||||||
if (r1 > cap)
|
brightness_cap[g1 + g2],
|
||||||
r1 = cap;
|
brightness_cap[b1 + b2]);
|
||||||
g1 += g2;
|
|
||||||
if (g1 > cap)
|
|
||||||
g1 = cap;
|
|
||||||
b1 += b2;
|
|
||||||
if (b1 > cap)
|
|
||||||
b1 = cap;
|
|
||||||
return BUILD_PIXEL(r1, g1, b1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define COLOR_SUB1_2(C1, C2) \
|
#define COLOR_SUB1_2(C1, C2) \
|
||||||
|
|
|
@ -144,6 +144,8 @@ uint8 mul_brightness[16][32] =
|
||||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uint8 brightness_cap[64];
|
||||||
|
|
||||||
uint8 S9xOpLengthsM0X0[256] =
|
uint8 S9xOpLengthsM0X0[256] =
|
||||||
{
|
{
|
||||||
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||||
|
|
8
ppu.cpp
8
ppu.cpp
|
@ -189,6 +189,14 @@ void S9xFixColourBrightness (void)
|
||||||
{
|
{
|
||||||
IPPU.XB = mul_brightness[PPU.Brightness];
|
IPPU.XB = mul_brightness[PPU.Brightness];
|
||||||
|
|
||||||
|
for (int i = 0; i < 64; i++)
|
||||||
|
{
|
||||||
|
if (i > IPPU.XB[0x1f])
|
||||||
|
brightness_cap[i] = IPPU.XB[0x1f];
|
||||||
|
else
|
||||||
|
brightness_cap[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 256; i++)
|
for (int i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
IPPU.Red[i] = IPPU.XB[(PPU.CGDATA[i]) & 0x1f];
|
IPPU.Red[i] = IPPU.XB[(PPU.CGDATA[i]) & 0x1f];
|
||||||
|
|
Loading…
Reference in New Issue