- [FIX] RLCA(), RLA(), RRCA() i RRA() calculaven mal el carry i m'estaven tornant loco

This commit is contained in:
2024-04-19 11:00:45 +02:00
parent 0b798189bc
commit 18869a09ee
3 changed files with 52 additions and 24 deletions

14
z80.cpp
View File

@@ -166,6 +166,8 @@ namespace z80
t+=3;
if (addr>=0x4000) memory[addr] = value;
if (z80debug::isbreak(addr, 4)) z80debug::stop();
//if (z80debug::debugging())
z80debug::setmemmodified(addr);
return value;
}
@@ -427,30 +429,38 @@ namespace z80
void RLCA()
{
const bool should_carry = rA & 0x80;
rA = (rA>>7) | (rA<<1);
KEEP_FLAGS(fS | fZ | fP);
SET_FLAGS(rA & (fX | fY | fC));
if (should_carry) SET_FLAGS(fC);
}
void RRCA()
{
const bool should_carry = rA & 0x01;
rA = (rA<<7) | (rA>>1);
KEEP_FLAGS(fS | fZ | fP);
SET_FLAGS(rA & (fX | fY | fC));
if (should_carry) SET_FLAGS(fC);
}
void RLA()
{
const bool should_carry = rA & 0x80;
rA = (rA<<1) | (rF&fC);
KEEP_FLAGS(fS | fZ | fP);
SET_FLAGS(rA & (fX | fY | fC));
SET_FLAGS(rA & (fX | fY));
if (should_carry) SET_FLAGS(fC);
}
void RRA()
{
const bool should_carry = rA & 0x01;
rA = ((rF&fC)<<7) | (rA>>1);
KEEP_FLAGS(fS | fZ | fP);
SET_FLAGS(rA & (fX | fY | fC));
SET_FLAGS(rA & (fX | fY));
if (should_carry) SET_FLAGS(fC);
}
void RRD()