summaryrefslogtreecommitdiff
path: root/z80_private.h
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2006-08-20 22:31:42 +0000
committerIan C <ianc@noddybox.co.uk>2006-08-20 22:31:42 +0000
commitf295f65db435ab7cb384e44e1dd74dc6d7a34853 (patch)
tree7d9fe765fc9507e6ad800773c51bc5da5d0ae9df /z80_private.h
parent87ace20633ba711243e336630e2c9a8546516598 (diff)
Initial compilable version
Diffstat (limited to 'z80_private.h')
-rw-r--r--z80_private.h71
1 files changed, 47 insertions, 24 deletions
diff --git a/z80_private.h b/z80_private.h
index 08dc543..32ce91f 100644
--- a/z80_private.h
+++ b/z80_private.h
@@ -43,25 +43,30 @@
/* ---------------------------------------- TYPES
*/
+typedef union
+{
+ Z80Word w;
+ Z80Byte b[2];
+} Z80Reg;
+
struct Z80
{
Z80Val cycle;
Z80Word PC;
- Z80Byte A;
- Z80Byte F;
- Z80Word BC;
- Z80Word DE;
- Z80Word HL;
+ Z80Reg AF;
+ Z80Reg BC;
+ Z80Reg DE;
+ Z80Reg HL;
- Z80Word AF_;
- Z80Word BC_;
- Z80Word DE_;
- Z80Word HL_;
+ Z80Reg AF_;
+ Z80Reg BC_;
+ Z80Reg DE_;
+ Z80Reg HL_;
- Z80Word IX;
- Z80Word IY;
+ Z80Reg IX;
+ Z80Reg IY;
Z80Word SP;
@@ -136,8 +141,8 @@ struct Z80
#define SET(v,b) v|=b
#define CLR(v,b) v&=~(b)
-#define SETFLAG(f) SET(cpu->F,f)
-#define CLRFLAG(f) CLR(cpu->F,f)
+#define SETFLAG(f) SET(cpu->AF.b[LO],f)
+#define CLRFLAG(f) CLR(cpu->AF.b[LO],f)
#define PEEK(addr) (cpu->memory[addr])
#define PEEKW(addr) (PEEK(addr) | (Z80Word)PEEK(addr+1)<<8)
@@ -148,11 +153,12 @@ struct Z80
{ \
cpu->memory[addr]=val; \
} \
- while (0)(cpu->write(cpu,addr,val))
+ } while (0)
#define POKEW(addr,val) do \
{ \
- POKE(addr,val); \
- POKE(addr+1,val>>8); \
+ Z80Word once=val; \
+ POKE(addr,once); \
+ POKE(addr+1,once>>8); \
} while(0)
#define FETCH_BYTE (cpu->memory[cpu->PC++])
@@ -160,12 +166,12 @@ struct Z80
cpu->memory[cpu->PC-2]| \
((Z80Word)cpu->memory[cpu->PC-1]<<8))
-#define IS_C (cpu->F&C_Z80)
-#define IS_N (cpu->F&N_Z80)
-#define IS_P (cpu->F&P_Z80)
-#define IS_H (cpu->F&H_Z80)
-#define IS_Z (cpu->F&Z_Z80)
-#define IS_S (cpu->F&S_Z80)
+#define IS_C (cpu->AF.b[LO]&C_Z80)
+#define IS_N (cpu->AF.b[LO]&N_Z80)
+#define IS_P (cpu->AF.b[LO]&P_Z80)
+#define IS_H (cpu->AF.b[LO]&H_Z80)
+#define IS_Z (cpu->AF.b[LO]&Z_Z80)
+#define IS_S (cpu->AF.b[LO]&S_Z80)
#define CARRY IS_C
@@ -185,9 +191,25 @@ struct Z80
cpu->SP+=2; \
} while(0)
-#define SETHIDDEN(res) cpu->F=(cpu->F&~(B3_Z80|B5_Z80))|\
+#define SETHIDDEN(res) cpu->AF.b[LO]=(cpu->AF.b[LO]&~(B3_Z80|B5_Z80))|\
((res)&(B3_Z80|B5_Z80))
+#define CALL do \
+ { \
+ PUSH(cpu->PC+2); \
+ cpu->PC=PEEKW(cpu->PC); \
+ } while(0)
+#define NOCALL cpu->PC+=2
+#define JP cpu->PC=PEEKW(cpu->PC)
+#define NOJP cpu->PC+=2
+#define JR cpu->PC+=(Z80Relative)PEEK(cpu->PC)+1
+#define NOJR cpu->PC++
+
+#define IN(PORT) (cpu->pread ? cpu->pread(cpu,PORT) : 0)
+#define OUT(PORT,VAL) if (cpu->pwrite) \
+ { \
+ cpu->pwrite(cpu,PORT,VAL); \
+ }
/* ---------------------------------------- FLAG TABLES
@@ -201,7 +223,8 @@ extern Z80Byte Ztable[512];
/* ---------------------------------------- GLOBAL GENERAL OPCODES/ROUTINES
*/
-void Z80_Decode(Z80 *cpu);
+void Z80_Decode(Z80 *cpu, Z80Byte opcode);
+void Z80_InitialiseInternals(void);
#endif