aboutsummaryrefslogtreecommitdiff
path: root/source/gfx.h
diff options
context:
space:
mode:
authorNebuleon Fumika2013-01-10 18:01:32 -0500
committerNebuleon Fumika2013-01-10 18:01:32 -0500
commit736484548ea021452415a1711aab10e04b521451 (patch)
tree63cedb0dd10dbbf9c84a0ab19fbc7facbd978d37 /source/gfx.h
parente1ec72de1078f0e371e212852a9273746b1aa42e (diff)
downloadsnes9x2005-736484548ea021452415a1711aab10e04b521451.tar.gz
snes9x2005-736484548ea021452415a1711aab10e04b521451.tar.bz2
snes9x2005-736484548ea021452415a1711aab10e04b521451.zip
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 <http://www.youtube.com/watch?v=sUWjVxAD9Q8>.
Diffstat (limited to 'source/gfx.h')
-rw-r--r--source/gfx.h66
1 files changed, 36 insertions, 30 deletions
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