Fixed bug in ADD SP, inm which truncated the result to 8 bits :P
authorJorge Gorbe Moya <jgorbe@dsic.upv.es>
Fri, 12 Sep 2008 17:31:11 +0000 (19:31 +0200)
committerJorge Gorbe Moya <jgorbe@dsic.upv.es>
Fri, 12 Sep 2008 17:31:11 +0000 (19:31 +0200)
gbcore.cc

index 4187d93e60b930fbf92c27361648c61d62dd82ca..07467a1e9e68114984661dbb42268ec6472ea5f4 100644 (file)
--- a/gbcore.cc
+++ b/gbcore.cc
@@ -821,7 +821,7 @@ GameBoy::run_status GameBoy::run_cycle()
                                                // FIXME: No se que hacer con el half carry, en 4 o en 11?
                                                int n = static_cast<s8>(memory.read(regs.PC++));
                                                int res = regs.SP + n;
-                                               regs.SP = static_cast<u8>(res);
+                                               regs.SP = static_cast<u16>(res);
                                                reset_flag(ZERO_FLAG);
                                                reset_flag(ADD_SUB_FLAG);
                                                set_flag_if(res > 0xFFFF, CARRY_FLAG);