From 736484548ea021452415a1711aab10e04b521451 Mon Sep 17 00:00:00 2001 From: Nebuleon Fumika Date: Thu, 10 Jan 2013 18:01:32 -0500 Subject: Attempt to optimise the ADD background drawing mode so it's playable on automatic frameskip in games like Super Metroid. It doesn't work well. See the video for this bug at . --- source/gfx.h | 66 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 30 deletions(-) (limited to 'source/gfx.h') diff --git a/source/gfx.h b/source/gfx.h index d6da783..88b2640 100644 --- a/source/gfx.h +++ b/source/gfx.h @@ -93,6 +93,31 @@ #include "port.h" #include "snes9x.h" +START_EXTERN_C +void S9xStartScreenRefresh (); +void S9xDrawScanLine (uint8 Line); +void S9xEndScreenRefresh (); +void S9xSetupOBJ (); +void S9xUpdateScreen (); +void RenderLine (uint8 line); +void S9xBuildDirectColourMaps (); + +// External port interface which must be implemented or initialised for each +// port. +extern struct SGFX GFX; + +bool8 S9xGraphicsInit (); +void S9xGraphicsDeinit(); +bool8 S9xInitUpdate (void); +bool8 S9xDeinitUpdate (int Width, int Height, bool8 sixteen_bit); +void S9xSyncSpeed (); + +#ifdef GFX_MULTI_FORMAT +bool8 S9xSetRenderPixelFormat (int format); +#endif + +END_EXTERN_C + struct SGFX{ // Initialize these variables uint8 *Screen; @@ -231,11 +256,17 @@ GFX.X2 [((((C1) & RGB_REMOVE_LOW_BITS_MASK) + \ ((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + \ ((C1) & (C2) & RGB_LOW_BITS_MASK)] #else -#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)) +inline uint16 COLOR_ADD (uint16, uint16); + +inline uint16 COLOR_ADD (uint16 C1, uint16 C2) +{ + if (C1 == 0) + return C2; + else if (C2 == 0) + return C1; + else + return 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); +} #endif #define COLOR_ADD1_2(C1, C2) \ @@ -288,30 +319,5 @@ typedef void (*LargePixelRenderer) (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount); -START_EXTERN_C -void S9xStartScreenRefresh (); -void S9xDrawScanLine (uint8 Line); -void S9xEndScreenRefresh (); -void S9xSetupOBJ (); -void S9xUpdateScreen (); -void RenderLine (uint8 line); -void S9xBuildDirectColourMaps (); - -// External port interface which must be implemented or initialised for each -// port. -extern struct SGFX GFX; - -bool8 S9xGraphicsInit (); -void S9xGraphicsDeinit(); -bool8 S9xInitUpdate (void); -bool8 S9xDeinitUpdate (int Width, int Height, bool8 sixteen_bit); -void S9xSyncSpeed (); - -#ifdef GFX_MULTI_FORMAT -bool8 S9xSetRenderPixelFormat (int format); -#endif - -END_EXTERN_C - #endif -- cgit v1.2.3