summaryrefslogtreecommitdiff
path: root/z80_decode.c
diff options
context:
space:
mode:
Diffstat (limited to 'z80_decode.c')
-rw-r--r--z80_decode.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/z80_decode.c b/z80_decode.c
index 6bb34f5..c5688c8 100644
--- a/z80_decode.c
+++ b/z80_decode.c
@@ -210,8 +210,10 @@ static Z80Word ADC16(Z80 *cpu, Z80Word REG, Z80Word VAL)
{
Z80Val w;
w=REG+(Z80Val)VAL+CARRY;
- cpu->AF.b[LO]&=(S_Z80|Z_Z80|V_Z80);
+ cpu->AF.b[LO]=0;
+ if ((w&0xffff)==0) cpu->AF.b[LO]=Z_Z80;
if (w>0xffff) cpu->AF.b[LO]|=C_Z80;
+ if ((VAL^REG^0x8000)&(REG^w)&0x8000) cpu->AF.b[LO]|=P_Z80;
if ((REG^w^VAL)&0x1000) cpu->AF.b[LO]|=H_Z80;
SETHIDDEN(w>>8);
return w;
@@ -223,11 +225,12 @@ static Z80Word SBC16(Z80 *cpu, Z80Word REG, Z80Word VAL)
Z80Val w;
w=REG-(Z80Val)VAL-CARRY;
cpu->AF.b[LO]=N_Z80;
+ if ((w&0xffff)==0) cpu->AF.b[LO]=Z_Z80;
if (w&0x8000) cpu->AF.b[LO]|=S_Z80;
if ((w&0xffff)==0) cpu->AF.b[LO]|=Z_Z80;
if (w>0xffff) cpu->AF.b[LO]|=C_Z80;
- if ((REG^w^VAL)&0x1000) cpu->AF.b[LO]|=H_Z80;
if ((VAL^REG)&(VAL^w)&0x8000) cpu->AF.b[LO]|=P_Z80;
+ if ((REG^w^VAL)&0x1000) cpu->AF.b[LO]|=H_Z80;
SETHIDDEN(w>>8);
return w;
}