From 665e1cabd8acee86ea3865e0a38467dec52e6f66 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sat, 26 Aug 2006 00:50:13 +0000 Subject: Updates --- z80_decode.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'z80_decode.c') diff --git a/z80_decode.c b/z80_decode.c index 5b8207d..52a0423 100644 --- a/z80_decode.c +++ b/z80_decode.c @@ -262,17 +262,17 @@ do { \ do { \ REG++; \ cpu->AF.b[LO]=CARRY|SZtable[REG]; \ - if (REG&0x80) cpu->AF.b[LO]|=P_Z80; \ - if (REG&0x0f) cpu->AF.b[LO]|=H_Z80; \ + if (REG==0x80) cpu->AF.b[LO]|=P_Z80; \ + if ((REG&0x0f)==0) cpu->AF.b[LO]|=H_Z80; \ } while(0) #define DEC8(REG) \ do { \ - cpu->AF.b[LO]=N_Z80|CARRY; \ - if (REG&0x80) cpu->AF.b[LO]|=P_Z80; \ - if (REG&0x0f) cpu->AF.b[LO]|=H_Z80; \ REG--; \ + cpu->AF.b[LO]=N_Z80|CARRY; \ + if (REG==0x7f) cpu->AF.b[LO]|=P_Z80; \ + if ((REG&0x0f)==0x0f) cpu->AF.b[LO]|=H_Z80; \ cpu->AF.b[LO]|=SZtable[REG]; \ } while(0) @@ -281,7 +281,7 @@ do { \ */ #define RRCA \ do { \ - cpu->AF.b[LO]=(cpu->AF.b[LO]&0xec)|(cpu->AF.b[HI]&C_Z80); \ + cpu->AF.b[LO]=(cpu->AF.b[LO]&0xc8)|(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]&0xec)|(cpu->AF.b[HI]&C_Z80); \ + cpu->AF.b[LO]=(cpu->AF.b[LO]&0xc8)|(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]&0xec)|(cpu->AF.b[HI]>>7); \ + cpu->AF.b[LO]=(cpu->AF.b[LO]&0xc8)|(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]&0xec)|(cpu->AF.b[HI]>>7); \ + cpu->AF.b[LO]=(cpu->AF.b[LO]&0xc8)|(cpu->AF.b[HI]>>7); \ cpu->AF.b[HI]=(cpu->AF.b[HI]<<1)|c; \ SETHIDDEN(cpu->AF.b[HI]); \ } while(0) @@ -683,7 +683,7 @@ do { \ /* ---------------------------------------- BASE OPCODE SHORT-HAND BLOCKS */ -#define LD_BLOCK(BASE,DEST) \ +#define LD_BLOCK(BASE,DEST,DEST2) \ case BASE: /* LD DEST,B */ \ TSTATE(4); \ DEST=cpu->BC.b[HI]; \ @@ -717,7 +717,7 @@ do { \ case BASE+6: /* LD DEST,(HL) */ \ TSTATE(7); \ OFFSET(off); \ - DEST=cpu->memory[*HL+off]; \ + DEST2=cpu->memory[*HL+off]; \ break; \ \ case BASE+7: /* LD DEST,A */ \ @@ -1994,7 +1994,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode) case 0x29: /* ADD HL,HL */ TSTATE(11); - ADD16(*HL,cpu->HL.w); + ADD16(*HL,*HL); break; case 0x2a: /* LD HL,(nnnn) */ @@ -2066,6 +2066,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode) case 0x37: /* SCF */ TSTATE(4); + CLRFLAG(H_Z80); SETFLAG(C_Z80); break; @@ -2105,15 +2106,21 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode) case 0x3f: /* CCF */ TSTATE(4); + + if (CARRY) + SETFLAG(H_Z80); + else + CLRFLAG(H_Z80); + cpu->AF.b[LO]^=C_Z80; break; - LD_BLOCK(0x40,cpu->BC.b[HI]) - LD_BLOCK(0x48,cpu->BC.b[LO]) - LD_BLOCK(0x50,cpu->DE.b[HI]) - LD_BLOCK(0x58,cpu->DE.b[LO]) - LD_BLOCK(0x60,*H) - LD_BLOCK(0x68,*L) + LD_BLOCK(0x40,cpu->BC.b[HI],cpu->BC.b[HI]) + LD_BLOCK(0x48,cpu->BC.b[LO],cpu->BC.b[LO]) + LD_BLOCK(0x50,cpu->DE.b[HI],cpu->DE.b[HI]) + LD_BLOCK(0x58,cpu->DE.b[LO],cpu->DE.b[LO]) + LD_BLOCK(0x60,*H,cpu->HL.b[HI]) + LD_BLOCK(0x68,*L,cpu->HL.b[LO]) case 0x70: /* LD (HL),B */ TSTATE(7); @@ -2167,7 +2174,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode) cpu->memory[*HL+off]=cpu->AF.b[HI]; break; - LD_BLOCK(0x78,cpu->AF.b[HI]) + LD_BLOCK(0x78,cpu->AF.b[HI],cpu->AF.b[HI]) ALU_BLOCK(0x80,ADD8) ALU_BLOCK(0x88,ADC8) -- cgit v1.2.3