A carry occurs if the value of a bit carries over to the next bit to the left after an operation occurs. So say if it says to set Flag H if there is a carry from bit3, you check if bit4 (the next bit) is set after the operation. Simple as if(answer&0x10). A half carry is the same as a carry, except that it only occurs in the lower nibble of the byte.
Just so you know the H and N flags are BCD flags, and thus only used by the DAA function for scores and what not. So H/N flag errors for the most part won't cause a game to break. You should be more concerned about the Carry and Zero flags, which are used for jumps and things.
shizzie, wouldn't it be (answer&0x8) to check the fourth bit? and also, in a carry operation in binary arithmetic, if the fourth bit was already a 1, then a carry from the addition of the third bits would cause the fourth bit to be 0 and cause it to carry to the fifth bit, etc.
here is an example of this scenario:
in this case the fourth bit for each operand was already 0, so the carry to the fourth bit made the fourth bit 1 for a binary result of 1000 or 0x8.
here, the fourth bit is already set in one of the operands (in this case, the first), so a carry from the addition of the third bit causes another carry in the addition of the fourth over in to the fifth, resulting in the binary value 10000 or 0x10.
taking this into consideration, i think to figure out if a half carry occurs at the third bit during and INC r instruction, where the register is simply incremented by '1', i would simply do this:
//run this before the increment operation
// then the result is a carry
in other words if
reg.B = 0111
and 0111 + 0001 = 1000 then
we have a half-carry situation and need to set the appropriate flag.
perhaps i'm missing something?