diff --git a/gfx.h b/gfx.h index db647a51..77eb344d 100644 --- a/gfx.h +++ b/gfx.h @@ -132,16 +132,36 @@ extern struct SGFX GFX; #define V_FLIP 0x8000 #define BLANK_TILE 2 +#include "ppu.h" + #define COLOR_ADD1_2(C1, C2) \ ((((((C1) & RGB_REMOVE_LOW_BITS_MASK) + \ ((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + \ ((C1) & (C2) & RGB_LOW_BITS_MASK)) | ALPHA_BITS_MASK) -#define COLOR_ADD(C1, C2) \ +/*#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)) + (((C1) ^ (C2)) & RGB_LOW_BITS_MASK)) */ + +inline uint16 COLOR_ADD(uint16 C1, uint16 C2) +{ + int r1, g1, b1, r2, g2, b2; + int cap = mul_brightness[PPU.Brightness][31]; + DECOMPOSE_PIXEL(C1, r1, g1, b1); + DECOMPOSE_PIXEL(C2, r2, g2, b2); + r1 += r2; + if (r1 > cap) + r1 = cap; + 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) \ GFX.ZERO[(((C1) | RGB_HI_BITS_MASKx2) - \ @@ -168,7 +188,6 @@ inline uint16 COLOR_SUB (uint16 C1, uint16 C2) void S9xStartScreenRefresh (void); void S9xEndScreenRefresh (void); -void S9xUpdateScreen (void); void S9xBuildDirectColourMaps (void); void RenderLine (uint8); void S9xComputeClipWindows (void); diff --git a/ppu.h b/ppu.h index a417e209..f5b0e0aa 100644 --- a/ppu.h +++ b/ppu.h @@ -228,6 +228,7 @@ extern SnesModel M2SNES; #define MAX_5C78_VERSION 0x03 #define MAX_5A22_VERSION 0x02 +void S9xUpdateScreen (void); static inline void FLUSH_REDRAW (void) { if (IPPU.PreviousLine != IPPU.CurrentLine)