From 81295d66b59af1ca7cbd91f63c897d6f60b015b6 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 3 Sep 2006 01:15:46 +0000 Subject: Fixed bugs on BIT,RES and SET opcode macros. Fixed serious bug in POKE macro. Changes to GEMMA. --- z80_decode.c | 91 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 46 insertions(+), 45 deletions(-) (limited to 'z80_decode.c') diff --git a/z80_decode.c b/z80_decode.c index 1433b30..4b6929c 100644 --- a/z80_decode.c +++ b/z80_decode.c @@ -281,7 +281,7 @@ do { \ */ #define RRCA \ do { \ - cpu->AF.b[LO]=(cpu->AF.b[LO]&0xc8)|(cpu->AF.b[HI]&C_Z80); \ + cpu->AF.b[LO]=(cpu->AF.b[LO]&(S_Z80|Z_Z80|P_Z80))|(cpu->AF.b[HI]&C_Z80); \ cpu->AF.b[HI]=(cpu->AF.b[HI]>>1)|(cpu->AF.b[HI]<<7); \ SETHIDDEN(cpu->AF.b[HI]); \ } while(0) @@ -291,7 +291,7 @@ do { \ do { \ Z80Byte c; \ c=CARRY; \ - cpu->AF.b[LO]=(cpu->AF.b[LO]&0xc8)|(cpu->AF.b[HI]&C_Z80); \ + cpu->AF.b[LO]=(cpu->AF.b[LO]&(S_Z80|Z_Z80|P_Z80))|(cpu->AF.b[HI]&C_Z80); \ cpu->AF.b[HI]=(cpu->AF.b[HI]>>1)|(c<<7); \ SETHIDDEN(cpu->AF.b[HI]); \ } while(0) @@ -319,7 +319,7 @@ do { \ #define RLCA \ do { \ - cpu->AF.b[LO]=(cpu->AF.b[LO]&0xc8)|(cpu->AF.b[HI]>>7); \ + cpu->AF.b[LO]=(cpu->AF.b[LO]&(S_Z80|Z_Z80|P_Z80))|(cpu->AF.b[HI]>>7); \ cpu->AF.b[HI]=(cpu->AF.b[HI]<<1)|(cpu->AF.b[HI]>>7); \ SETHIDDEN(cpu->AF.b[HI]); \ } while(0) @@ -329,7 +329,7 @@ do { \ do { \ Z80Byte c; \ c=CARRY; \ - cpu->AF.b[LO]=(cpu->AF.b[LO]&0xc8)|(cpu->AF.b[HI]>>7); \ + cpu->AF.b[LO]=(cpu->AF.b[LO]&(S_Z80|Z_Z80|P_Z80))|(cpu->AF.b[HI]>>7); \ cpu->AF.b[HI]=(cpu->AF.b[HI]<<1)|c; \ SETHIDDEN(cpu->AF.b[HI]); \ } while(0) @@ -424,20 +424,21 @@ do { \ #define BIT(REG,B) \ do { \ cpu->AF.b[LO]=CARRY|H_Z80; \ - if ((REG)&&(1<AF.b[LO]|=S_Z80; \ - if (B==5) cpu->AF.b[LO]|=B5_Z80; \ - if (B==3) cpu->AF.b[LO]|=B3_Z80; \ + cpu->AF.b[LO]|=Z_Z80; \ + cpu->AF.b[LO]|=P_Z80; \ } \ else \ { \ - cpu->AF.b[LO]|=Z_Z80; \ - cpu->AF.b[LO]|=P_Z80; \ + if (B==7) cpu->AF.b[LO]|=S_Z80; \ + if (B==5) cpu->AF.b[LO]|=B5_Z80; \ + if (B==3) cpu->AF.b[LO]|=B3_Z80; \ } \ } while(0) -#define RES CLR +#define BIT_SET(REG,B) (REG)|=(1<