Hi,
I am working on a GB emulator, but I am getting stuck trying to understand the half carry flag.
In the CPU manual here: http://marc.rawer.de/Gameboy/Docs/GBCPUman.pdf for the DEC instruction on page 89 it says that:
I understand this to mean that the half carry flag is set whenever (register & 0xF) > 0.
This makes sense to me since for example:
(4 - 1) = 0b0100 + 0b1111 = 0b(1)0011 -> (Half carry = 1)
(0 - 1) = 0b0000 + 0b1111 = 0b(0)1111 -> (Half carry = 0)
But, every other emulator I look at says the opposite, that in the first example the half carry flag is not set, and in the second example it is.
Where am I going wrong here? I don't see how it can be the other way around. If anyone can provide an explanation or example I would really appreciate it.
Thanks!
I am working on a GB emulator, but I am getting stuck trying to understand the half carry flag.
In the CPU manual here: http://marc.rawer.de/Gameboy/Docs/GBCPUman.pdf for the DEC instruction on page 89 it says that:
Quote:
H - Set if no borrow from bit 4.
I understand this to mean that the half carry flag is set whenever (register & 0xF) > 0.
This makes sense to me since for example:
(4 - 1) = 0b0100 + 0b1111 = 0b(1)0011 -> (Half carry = 1)
(0 - 1) = 0b0000 + 0b1111 = 0b(0)1111 -> (Half carry = 0)
But, every other emulator I look at says the opposite, that in the first example the half carry flag is not set, and in the second example it is.
Where am I going wrong here? I don't see how it can be the other way around. If anyone can provide an explanation or example I would really appreciate it.
Thanks!