mohanson / gameboy

Full featured Cross-platform GameBoy emulator by Rust. Forever boys!.
MIT License
1.36k stars 79 forks source link

Fix half carry flag logic in alu_add_hl #14

Closed nwtnni closed 5 years ago

nwtnni commented 5 years ago

Correct me if I'm wrong, but I think a mask of 0x0FFF is consistent with the 8-bit alu_add function:

self.reg.set_flag(C, u16::from(a) + u16::from(n) > 0xff);
self.reg.set_flag(H, (a & 0x0f) + (n & 0x0f) > 0x0f);

and other emulators I've checked with: SameBoy, binjgb, CoffeeGB

mohanson commented 5 years ago

Thanks! you are correct.