summaryrefslogtreecommitdiff
path: root/z80_decode.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2006-09-03 01:15:46 +0000
committerIan C <ianc@noddybox.co.uk>2006-09-03 01:15:46 +0000
commit81295d66b59af1ca7cbd91f63c897d6f60b015b6 (patch)
treecd74a6e04e86f21a4966d884a7cd0cb779189fad /z80_decode.c
parent37141ac197eaefeae9dada0bcc1c429ff584df44 (diff)
Fixed bugs on BIT,RES and SET opcode macros. Fixed serious bug in POKE
macro. Changes to GEMMA.
Diffstat (limited to 'z80_decode.c')
-rw-r--r--z80_decode.c91
1 files changed, 46 insertions, 45 deletions
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<<B)) \
+ if ((REG)&(1<<B)) \
{ \
- 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; \
+ 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<<B)
+#define BIT_RES(REG,B) (REG)&=~(1<<B)
/* ---------------------------------------- JUMP OPERATIONS
@@ -1670,23 +1671,23 @@ static void DecodeCB(Z80 *cpu, Z80Byte opcode)
CB_BITMANIP_BLOCK(0x70,BIT,6)
CB_BITMANIP_BLOCK(0x78,BIT,7)
- CB_BITMANIP_BLOCK(0x80,RES,0)
- CB_BITMANIP_BLOCK(0x88,RES,1)
- CB_BITMANIP_BLOCK(0x90,RES,2)
- CB_BITMANIP_BLOCK(0x98,RES,3)
- CB_BITMANIP_BLOCK(0xa0,RES,4)
- CB_BITMANIP_BLOCK(0xa8,RES,5)
- CB_BITMANIP_BLOCK(0xb0,RES,6)
- CB_BITMANIP_BLOCK(0xb8,RES,7)
-
- CB_BITMANIP_BLOCK(0xc0,SET,0)
- CB_BITMANIP_BLOCK(0xc8,SET,1)
- CB_BITMANIP_BLOCK(0xd0,SET,2)
- CB_BITMANIP_BLOCK(0xd8,SET,3)
- CB_BITMANIP_BLOCK(0xe0,SET,4)
- CB_BITMANIP_BLOCK(0xe8,SET,5)
- CB_BITMANIP_BLOCK(0xf0,SET,6)
- CB_BITMANIP_BLOCK(0xf8,SET,7)
+ CB_BITMANIP_BLOCK(0x80,BIT_RES,0)
+ CB_BITMANIP_BLOCK(0x88,BIT_RES,1)
+ CB_BITMANIP_BLOCK(0x90,BIT_RES,2)
+ CB_BITMANIP_BLOCK(0x98,BIT_RES,3)
+ CB_BITMANIP_BLOCK(0xa0,BIT_RES,4)
+ CB_BITMANIP_BLOCK(0xa8,BIT_RES,5)
+ CB_BITMANIP_BLOCK(0xb0,BIT_RES,6)
+ CB_BITMANIP_BLOCK(0xb8,BIT_RES,7)
+
+ CB_BITMANIP_BLOCK(0xc0,BIT_SET,0)
+ CB_BITMANIP_BLOCK(0xc8,BIT_SET,1)
+ CB_BITMANIP_BLOCK(0xd0,BIT_SET,2)
+ CB_BITMANIP_BLOCK(0xd8,BIT_SET,3)
+ CB_BITMANIP_BLOCK(0xe0,BIT_SET,4)
+ CB_BITMANIP_BLOCK(0xe8,BIT_SET,5)
+ CB_BITMANIP_BLOCK(0xf0,BIT_SET,6)
+ CB_BITMANIP_BLOCK(0xf8,BIT_SET,7)
}
}
@@ -1730,23 +1731,23 @@ static void ShiftedDecodeCB(Z80 *cpu, Z80Byte opcode, Z80Relative offset)
SHIFTED_CB_BITMANIP_BLOCK(0x70,BIT,6)
SHIFTED_CB_BITMANIP_BLOCK(0x78,BIT,7)
- SHIFTED_CB_BITMANIP_BLOCK(0x80,RES,0)
- SHIFTED_CB_BITMANIP_BLOCK(0x88,RES,1)
- SHIFTED_CB_BITMANIP_BLOCK(0x90,RES,2)
- SHIFTED_CB_BITMANIP_BLOCK(0x98,RES,3)
- SHIFTED_CB_BITMANIP_BLOCK(0xa0,RES,4)
- SHIFTED_CB_BITMANIP_BLOCK(0xa8,RES,5)
- SHIFTED_CB_BITMANIP_BLOCK(0xb0,RES,6)
- SHIFTED_CB_BITMANIP_BLOCK(0xb8,RES,7)
-
- SHIFTED_CB_BITMANIP_BLOCK(0xc0,SET,0)
- SHIFTED_CB_BITMANIP_BLOCK(0xc8,SET,1)
- SHIFTED_CB_BITMANIP_BLOCK(0xd0,SET,2)
- SHIFTED_CB_BITMANIP_BLOCK(0xd8,SET,3)
- SHIFTED_CB_BITMANIP_BLOCK(0xe0,SET,4)
- SHIFTED_CB_BITMANIP_BLOCK(0xe8,SET,5)
- SHIFTED_CB_BITMANIP_BLOCK(0xf0,SET,6)
- SHIFTED_CB_BITMANIP_BLOCK(0xf8,SET,7)
+ SHIFTED_CB_BITMANIP_BLOCK(0x80,BIT_RES,0)
+ SHIFTED_CB_BITMANIP_BLOCK(0x88,BIT_RES,1)
+ SHIFTED_CB_BITMANIP_BLOCK(0x90,BIT_RES,2)
+ SHIFTED_CB_BITMANIP_BLOCK(0x98,BIT_RES,3)
+ SHIFTED_CB_BITMANIP_BLOCK(0xa0,BIT_RES,4)
+ SHIFTED_CB_BITMANIP_BLOCK(0xa8,BIT_RES,5)
+ SHIFTED_CB_BITMANIP_BLOCK(0xb0,BIT_RES,6)
+ SHIFTED_CB_BITMANIP_BLOCK(0xb8,BIT_RES,7)
+
+ SHIFTED_CB_BITMANIP_BLOCK(0xc0,BIT_SET,0)
+ SHIFTED_CB_BITMANIP_BLOCK(0xc8,BIT_SET,1)
+ SHIFTED_CB_BITMANIP_BLOCK(0xd0,BIT_SET,2)
+ SHIFTED_CB_BITMANIP_BLOCK(0xd8,BIT_SET,3)
+ SHIFTED_CB_BITMANIP_BLOCK(0xe0,BIT_SET,4)
+ SHIFTED_CB_BITMANIP_BLOCK(0xe8,BIT_SET,5)
+ SHIFTED_CB_BITMANIP_BLOCK(0xf0,BIT_SET,6)
+ SHIFTED_CB_BITMANIP_BLOCK(0xf8,BIT_SET,7)
}
}