cpu/cpu - Fix F register

This commit is contained in:
madmaurice 2023-09-01 23:43:24 +02:00
parent 899cebb698
commit 243553acba
2 changed files with 13 additions and 17 deletions

View file

@ -8,27 +8,23 @@
void Cpu_state::setAF(u16 v)
{
A = (u8)(v >> 8);
zero = (v & 0x80 != 0);
subtract = (v & 0x40 != 0);
halfcarry = (v & 0x20 != 0);
carry = (v & 0x10 != 0);
zero = ((v & F_ZERO) != 0);
subtract = ((v & F_SUB) != 0);
halfcarry = ((v & F_HALF) != 0);
carry = ((v & F_CARRY) != 0);
}
u16 Cpu_state::getAF()
{
return ((u16)A << 8) |
(zero ? 0x80 : 0) |
(subtract ? 0x40 : 0) |
(halfcarry ? 0x20 : 0) |
(carry ? 0x10 : 0);
return ((u16)A << 8) | getF();
}
u8 Cpu_state::getF()
{
return (zero ? 0x80 : 0) |
(subtract ? 0x40 : 0) |
(halfcarry ? 0x20 : 0) |
(carry ? 0x10 : 0);
return (zero ? F_ZERO : 0) |
(subtract ? F_SUB : 0) |
(halfcarry ? F_HALF : 0) |
(carry ? F_CARRY : 0);
}
u8& Cpu_state::reg8(Cpu& cpu, u8 idx)

View file

@ -8,10 +8,10 @@
typedef u8 opcode_t;
enum Flags {
F_ZERO = 0x8,
F_SUB = 0x4,
F_HALF = 0x2,
F_CARRY = 0x1,
F_ZERO = 0x80,
F_SUB = 0x40,
F_HALF = 0x20,
F_CARRY = 0x10,
};
enum AluOp : int {