cpu/cpu - Fix F register
This commit is contained in:
parent
899cebb698
commit
243553acba
2 changed files with 13 additions and 17 deletions
22
cpu/cpu.cpp
22
cpu/cpu.cpp
|
@ -8,27 +8,23 @@
|
||||||
void Cpu_state::setAF(u16 v)
|
void Cpu_state::setAF(u16 v)
|
||||||
{
|
{
|
||||||
A = (u8)(v >> 8);
|
A = (u8)(v >> 8);
|
||||||
zero = (v & 0x80 != 0);
|
zero = ((v & F_ZERO) != 0);
|
||||||
subtract = (v & 0x40 != 0);
|
subtract = ((v & F_SUB) != 0);
|
||||||
halfcarry = (v & 0x20 != 0);
|
halfcarry = ((v & F_HALF) != 0);
|
||||||
carry = (v & 0x10 != 0);
|
carry = ((v & F_CARRY) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 Cpu_state::getAF()
|
u16 Cpu_state::getAF()
|
||||||
{
|
{
|
||||||
return ((u16)A << 8) |
|
return ((u16)A << 8) | getF();
|
||||||
(zero ? 0x80 : 0) |
|
|
||||||
(subtract ? 0x40 : 0) |
|
|
||||||
(halfcarry ? 0x20 : 0) |
|
|
||||||
(carry ? 0x10 : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 Cpu_state::getF()
|
u8 Cpu_state::getF()
|
||||||
{
|
{
|
||||||
return (zero ? 0x80 : 0) |
|
return (zero ? F_ZERO : 0) |
|
||||||
(subtract ? 0x40 : 0) |
|
(subtract ? F_SUB : 0) |
|
||||||
(halfcarry ? 0x20 : 0) |
|
(halfcarry ? F_HALF : 0) |
|
||||||
(carry ? 0x10 : 0);
|
(carry ? F_CARRY : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
u8& Cpu_state::reg8(Cpu& cpu, u8 idx)
|
u8& Cpu_state::reg8(Cpu& cpu, u8 idx)
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
typedef u8 opcode_t;
|
typedef u8 opcode_t;
|
||||||
|
|
||||||
enum Flags {
|
enum Flags {
|
||||||
F_ZERO = 0x8,
|
F_ZERO = 0x80,
|
||||||
F_SUB = 0x4,
|
F_SUB = 0x40,
|
||||||
F_HALF = 0x2,
|
F_HALF = 0x20,
|
||||||
F_CARRY = 0x1,
|
F_CARRY = 0x10,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AluOp : int {
|
enum AluOp : int {
|
||||||
|
|
Loading…
Reference in a new issue