diff src/console/Gb_Cpu.cxx @ 341:986f098da058 trunk

[svn] - merge in blargg's changes
author nenolod
date Thu, 07 Dec 2006 15:20:41 -0800
parents fb513e10174e
children
line wrap: on
line diff
--- a/src/console/Gb_Cpu.cxx	Wed Dec 06 07:57:05 2006 -0800
+++ b/src/console/Gb_Cpu.cxx	Thu Dec 07 15:20:41 2006 -0800
@@ -1,4 +1,4 @@
-// Game_Music_Emu 0.5.1. http://www.slack.net/~ant/
+// Game_Music_Emu 0.5.2. http://www.slack.net/~ant/
 
 #include "Gb_Cpu.h"
 
@@ -96,6 +96,8 @@
 	this->state = &s;
 	memcpy( &s, &this->state_, sizeof s );
 	
+	typedef BOOST::uint16_t uint16_t;
+	
 #if BLARGG_BIG_ENDIAN
 	#define R8( n ) (r8_ [n]) 
 #elif BLARGG_LITTLE_ENDIAN
@@ -156,13 +158,14 @@
 	switch ( op )
 	{
 
-#define BRANCH( cond )          \
-{                               \
-	pc++;                       \
-	int offset = (BOOST::int8_t) data;  \
-	if ( !(cond) ) goto loop;   \
-	pc += offset;               \
-	goto loop;                  \
+// TODO: more efficient way to handle negative branch that wraps PC around
+#define BRANCH( cond )\
+{\
+	pc++;\
+	int offset = (BOOST::int8_t) data;\
+	if ( !(cond) ) goto loop;\
+	pc = uint16_t (pc + offset);\
+	goto loop;\
 }
 
 // Most Common