summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2021-08-20 21:32:55 +0000
committerIan C <ianc@noddybox.co.uk>2021-08-20 21:32:55 +0000
commit40121879f3dfaedce310fbc543589ff6aab3a398 (patch)
treeb35afaf9a528a58703e24f4085587357c623e7f6
parent66d4bb423e981aece8c5590eb2a5968a5d874c9f (diff)
Updated with latest Z80 core from 3dsspec
-rw-r--r--emma.c2
-rw-r--r--z80.c28
-rw-r--r--z80.h57
-rw-r--r--z80_config.h14
-rw-r--r--z80_decode.c544
-rw-r--r--z80_dis.c9
-rw-r--r--z80_private.h37
7 files changed, 362 insertions, 329 deletions
diff --git a/emma.c b/emma.c
index a719885..c36e71e 100644
--- a/emma.c
+++ b/emma.c
@@ -212,7 +212,7 @@ static void DisplayState(void)
pc=z80->PC;
Log("A=%2.2x F=%s ",
- z80->AF.b[Z80_HI_WORD],FlagString(z80->AF.b[Z80_LO_WORD]));
+ z80->AF.b.hi,FlagString(z80->AF.b.lo));
Log("BC=%4.4x DE=%4.4x HL=%4.4x ",z80->BC.w,z80->DE.w,z80->HL.w);
Log("IX=%4.4x IY=%4.4x SP=%4.4x\n",z80->IX.w,z80->IY.w,z80->SP);
Log("I=%2.2x IM=%2.2x R=%2.2x ",z80->I,z80->IM,z80->R);
diff --git a/z80.c b/z80.c
index 36c5793..dc4b9d1 100644
--- a/z80.c
+++ b/z80.c
@@ -2,11 +2,11 @@
z80 - Z80 Emulator
- Copyright (C) 2006 Ian Cowburn <ianc@noddybox.co.uk>
+ Copyright (C) 2021 Ian Cowburn <ianc@noddybox.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -15,8 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ along with this program; if not, see <http://www.gnu.org/licenses/>
-------------------------------------------------------------------------
@@ -31,10 +30,6 @@
#include "z80.h"
#include "z80_private.h"
-static const char ident[]="$Id$";
-static const char ident_z80_header[]=Z80_H;
-static const char ident_z80_private_header[]=Z80_PRIVATE_H;
-
Z80Label *z80_labels=NULL;
/* ---------------------------------------- PRIVATE FUNCTIONS
@@ -173,6 +168,10 @@ Z80 *Z80Init(Z80ReadMemory read_memory,
void Z80Reset(Z80 *cpu)
{
PRIV->cycle=0;
+ PRIV->timer[Z80_TIMER_1]=0;
+ PRIV->timer[Z80_TIMER_2]=0;
+ PRIV->timer[Z80_TIMER_3]=0;
+
cpu->PC=0;
cpu->AF.w=0xffff;
@@ -212,6 +211,18 @@ void Z80ResetCycles(Z80 *cpu, Z80Val cycles)
}
+Z80Val Z80GetTimer(Z80 *cpu, Z80Timer timer)
+{
+ return PRIV->timer[timer];
+}
+
+
+void Z80SetTimer(Z80 *cpu, Z80Timer timer, Z80Val cycles)
+{
+ PRIV->timer[timer] = cycles;
+}
+
+
int Z80LodgeCallback(Z80 *cpu, Z80CallbackReason reason, Z80Callback callback)
{
int f;
@@ -328,4 +339,5 @@ const char *Z80Disassemble(Z80 *cpu, Z80Word *pc)
#endif
}
+
/* END OF FILE */
diff --git a/z80.h b/z80.h
index 000b950..eb3ec71 100644
--- a/z80.h
+++ b/z80.h
@@ -2,11 +2,11 @@
z80 - Z80 emulation
- Copyright (C) 2006 Ian Cowburn <ianc@noddybox.co.uk>
+ Copyright (C) 2021 Ian Cowburn <ianc@noddybox.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -15,8 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ along with this program; if not, see <http://www.gnu.org/licenses/>
-------------------------------------------------------------------------
@@ -27,6 +26,8 @@
#ifndef Z80_H
#define Z80_H "$Id$"
+#include <stdio.h>
+
/* Configuration
*/
#include "z80_config.h"
@@ -55,20 +56,30 @@ typedef signed char Z80Relative;
typedef unsigned short Z80Word;
-/* A Z80 16-bit register. To access the HI/LO component use the indexes
- Z80_HI_WORD and Z80_LO_WORD which will be initialised once Z80Init has been
- called.
+/* A Z80 16-bit register made up of 2 8-bit registers.
*/
+#ifdef Z80_LITTLE_ENDIAN
+typedef struct
+{
+ Z80Byte lo;
+ Z80Byte hi;
+} Z80RegPair;
+#endif
+
+#ifdef Z80_BIG_ENDIAN
+typedef struct
+{
+ Z80Byte hi;
+ Z80Byte lo;
+} Z80RegPair;
+#endif
+
typedef union
{
Z80Word w;
- Z80Byte b[2];
+ Z80RegPair b;
} Z80Reg;
-extern int Z80_HI_WORD;
-extern int Z80_LO_WORD;
-
-
/* The processor
*/
struct Z80Private;
@@ -133,13 +144,23 @@ typedef int (*Z80Callback)(Z80 *cpu, Z80Val data);
*/
typedef enum
{
- eZ80_Instruction, /* data = no cycles since reset */
+ eZ80_Instruction, /* data = cycles as returned by Z80Cycles */
eZ80_EDHook, /* data = byte after ED opcode (only for NOP opcodes) */
eZ80_Halt, /* data = 1 halt raised, 0 halt cleared by int */
eZ80_RETI, /* data = ignored */
eZ80_NO_CALLBACK /* leave at end */
} Z80CallbackReason;
+/* Defines cycle timers
+*/
+typedef enum
+{
+ Z80_TIMER_1,
+ Z80_TIMER_2,
+ Z80_TIMER_3,
+ Z80_NO_TIMERS
+} Z80Timer;
+
/* Flags in the F register
*/
@@ -234,6 +255,11 @@ void Z80Exec(Z80 *cpu);
Z80Val Z80Cycles(Z80 *cpu);
void Z80ResetCycles(Z80 *cpu, Z80Val cycles);
+/* Timers that count in cycle counts
+*/
+Z80Val Z80GetTimer(Z80 *cpu, Z80Timer timer);
+void Z80SetTimer(Z80 *cpu, Z80Timer timer, Z80Val cycles);
+
/* Set address to label mappings for the disassembler
*/
@@ -245,6 +271,11 @@ void Z80SetLabels(Z80Label labels[]);
*/
const char *Z80Disassemble(Z80 *cpu, Z80Word *addr);
+/* Allows the CPU state to be saved/loaded from a stream
+*/
+void Z80SaveSnapshot(Z80 *cpu, FILE *fp);
+void Z80LoadSnapshot(Z80 *cpu, FILE *fp);
+
#endif
/* END OF FILE */
diff --git a/z80_config.h b/z80_config.h
index af36944..098ddf0 100644
--- a/z80_config.h
+++ b/z80_config.h
@@ -2,11 +2,11 @@
z80 - Z80 emulation
- Copyright (C) 2006 Ian Cowburn <ianc@noddybox.co.uk>
+ Copyright (C) 2021 Ian Cowburn <ianc@noddybox.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -15,8 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ along with this program; if not, see <http://www.gnu.org/licenses/>
-------------------------------------------------------------------------
@@ -37,6 +36,11 @@
*/
#define ENABLE_DISASSEM
+/* Pick one of these as appropriate for your real CPU
+#define Z80_BIG_ENDIAN
+*/
+#define Z80_LITTLE_ENDIAN
+
/* Define this to enable the array-based memory model. In this mode
an externally visible Z80Byte array called Z80_MEMORY must be
@@ -45,8 +49,8 @@
In this mode the signature of Z80Init changes so that the memory functions
are not passed. ALL processor instances share the same memory.
-#define ENABLE_ARRAY_MEMORY
*/
+#define ENABLE_ARRAY_MEMORY
#ifdef ENABLE_ARRAY_MEMORY
#define RAMBOT 0x0000
diff --git a/z80_decode.c b/z80_decode.c
index a8f66ca..c642783 100644
--- a/z80_decode.c
+++ b/z80_decode.c
@@ -2,11 +2,11 @@
z80 - Z80 Emulator
- Copyright (C) 2006 Ian Cowburn <ianc@noddybox.co.uk>
+ Copyright (C) 2021 Ian Cowburn <ianc@noddybox.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -15,8 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ along with this program; if not, see <http://www.gnu.org/licenses/>
-------------------------------------------------------------------------
@@ -29,8 +28,6 @@
#include "z80.h"
#include "z80_private.h"
-static const char ident[]="$Id$";
-
/* ---------------------------------------- TABLES AND INIT
*/
static Z80Byte PSZtable[512];
@@ -39,13 +36,6 @@ static Z80Byte Ptable[512];
static Z80Byte Stable[512];
static Z80Byte Ztable[512];
-
-int Z80_HI_WORD;
-int Z80_LO_WORD;
-
-#define HI Z80_HI_WORD
-#define LO Z80_LO_WORD
-
/* ---------------------------------------- MISC FUNCTIONS
*/
void Z80_InitialiseInternals(void)
@@ -57,17 +47,7 @@ void Z80_InitialiseInternals(void)
*/
r.w=0x1234;
- if (r.b[0] == 0x12)
- {
- HI=0;
- LO=1;
- }
- else if (r.b[1] == 0x12)
- {
- HI=1;
- LO=0;
- }
- else
+ if (r.b.hi != 0x12 || r.b.lo != 0x34)
{
exit(1);
}
@@ -153,12 +133,12 @@ do { \
do { \
Z80Byte VAL=ONCE; \
unsigned w; \
- w=cpu->AF.b[HI]+(unsigned)VAL; \
- cpu->AF.b[LO]=SZtable[w]; \
- if ((cpu->AF.b[HI]^w^VAL)&H_Z80) cpu->AF.b[LO]|=H_Z80; \
- if ((VAL^cpu->AF.b[HI]^0x80)&(VAL^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
+ w=cpu->AF.b.hi+(unsigned)VAL; \
+ cpu->AF.b.lo=SZtable[w]; \
+ if ((cpu->AF.b.hi^w^VAL)&H_Z80) cpu->AF.b.lo|=H_Z80; \
+ if ((VAL^cpu->AF.b.hi^0x80)&(VAL^w)&0x80) cpu->AF.b.lo|=P_Z80; \
SETHIDDEN(w); \
- cpu->AF.b[HI]=w; \
+ cpu->AF.b.hi=w; \
} while(0)
@@ -166,12 +146,12 @@ do { \
do { \
Z80Byte VAL=ONCE; \
unsigned w; \
- w=(cpu->AF.b[HI]+(unsigned)VAL+CARRY)&0x1ff; \
- cpu->AF.b[LO]=SZtable[w]; \
- if ((cpu->AF.b[HI]^w^VAL)&H_Z80) cpu->AF.b[LO]|=H_Z80; \
- if ((VAL^cpu->AF.b[HI]^0x80)&(VAL^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
+ w=(cpu->AF.b.hi+(unsigned)VAL+CARRY)&0x1ff; \
+ cpu->AF.b.lo=SZtable[w]; \
+ if ((cpu->AF.b.hi^w^VAL)&H_Z80) cpu->AF.b.lo|=H_Z80; \
+ if ((VAL^cpu->AF.b.hi^0x80)&(VAL^w)&0x80) cpu->AF.b.lo|=P_Z80; \
SETHIDDEN(w); \
- cpu->AF.b[HI]=w; \
+ cpu->AF.b.hi=w; \
} while(0)
@@ -179,12 +159,12 @@ do { \
do { \
Z80Byte VAL=ONCE; \
unsigned w; \
- w=(cpu->AF.b[HI]-(unsigned)VAL)&0x1ff; \
- cpu->AF.b[LO]=SZtable[w]|N_Z80; \
- if ((cpu->AF.b[HI]^w^VAL)&H_Z80) cpu->AF.b[LO]|=H_Z80; \
- if ((VAL^cpu->AF.b[HI])&(cpu->AF.b[HI]^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
+ w=(cpu->AF.b.hi-(unsigned)VAL)&0x1ff; \
+ cpu->AF.b.lo=SZtable[w]|N_Z80; \
+ if ((cpu->AF.b.hi^w^VAL)&H_Z80) cpu->AF.b.lo|=H_Z80; \
+ if ((VAL^cpu->AF.b.hi)&(cpu->AF.b.hi^w)&0x80) cpu->AF.b.lo|=P_Z80; \
SETHIDDEN(w); \
- cpu->AF.b[HI]=w; \
+ cpu->AF.b.hi=w; \
} while(0)
@@ -192,10 +172,10 @@ do { \
do { \
Z80Byte VAL=ONCE; \
unsigned w; \
- w=(cpu->AF.b[HI]-(unsigned)VAL)&0x1ff; \
- cpu->AF.b[LO]=SZtable[w]|N_Z80; \
- if ((cpu->AF.b[HI]^w^VAL)&H_Z80) cpu->AF.b[LO]|=H_Z80; \
- if ((VAL^cpu->AF.b[HI])&(cpu->AF.b[HI]^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
+ w=(cpu->AF.b.hi-(unsigned)VAL)&0x1ff; \
+ cpu->AF.b.lo=SZtable[w]|N_Z80; \
+ if ((cpu->AF.b.hi^w^VAL)&H_Z80) cpu->AF.b.lo|=H_Z80; \
+ if ((VAL^cpu->AF.b.hi)&(cpu->AF.b.hi^w)&0x80) cpu->AF.b.lo|=P_Z80; \
SETHIDDEN(VAL); \
} while(0)
@@ -204,12 +184,12 @@ do { \
do { \
Z80Byte VAL=ONCE; \
unsigned w; \
- w=(cpu->AF.b[HI]-(unsigned)VAL-CARRY)&0x1ff; \
- cpu->AF.b[LO]=SZtable[w]|N_Z80; \
- if ((cpu->AF.b[HI]^w^VAL)&H_Z80) cpu->AF.b[LO]|=H_Z80; \
- if ((VAL^cpu->AF.b[HI])&(cpu->AF.b[HI]^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
+ w=(cpu->AF.b.hi-(unsigned)VAL-CARRY)&0x1ff; \
+ cpu->AF.b.lo=SZtable[w]|N_Z80; \
+ if ((cpu->AF.b.hi^w^VAL)&H_Z80) cpu->AF.b.lo|=H_Z80; \
+ if ((VAL^cpu->AF.b.hi)&(cpu->AF.b.hi^w)&0x80) cpu->AF.b.lo|=P_Z80; \
SETHIDDEN(w); \
- cpu->AF.b[HI]=w; \
+ cpu->AF.b.hi=w; \
} while(0)
@@ -218,9 +198,9 @@ do { \
Z80Word VAL=ONCE; \
Z80Val w; \
w=(REG)+(Z80Val)VAL; \
- cpu->AF.b[LO]&=(S_Z80|Z_Z80|V_Z80); \
- if (w>0xffff) cpu->AF.b[LO]|=C_Z80; \
- if (((REG)^w^VAL)&0x1000) cpu->AF.b[LO]|=H_Z80; \
+ cpu->AF.b.lo&=(S_Z80|Z_Z80|V_Z80); \
+ if (w>0xffff) cpu->AF.b.lo|=C_Z80; \
+ if (((REG)^w^VAL)&0x1000) cpu->AF.b.lo|=H_Z80; \
SETHIDDEN(w>>8); \
(REG)=w; \
} while(0)
@@ -231,12 +211,12 @@ do { \
Z80Word VAL=ONCE; \
Z80Val w; \
w=(REG)+(Z80Val)VAL+CARRY; \
- cpu->AF.b[LO]=0; \
- if ((w&0xffff)==0) cpu->AF.b[LO]=Z_Z80; \
- if (w&0x8000) cpu->AF.b[LO]|=S_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; \
+ cpu->AF.b.lo=0; \
+ if ((w&0xffff)==0) cpu->AF.b.lo=Z_Z80; \
+ if (w&0x8000) cpu->AF.b.lo|=S_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); \
(REG)=w; \
} while(0)
@@ -247,12 +227,12 @@ do { \
Z80Word VAL=ONCE; \
Z80Val w; \
w=(REG)-(Z80Val)VAL-CARRY; \
- cpu->AF.b[LO]=N_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 ((VAL^(REG))&((REG)^w)&0x8000) cpu->AF.b[LO]|=P_Z80; \
- if (((REG)^w^VAL)&0x1000) cpu->AF.b[LO]|=H_Z80; \
+ cpu->AF.b.lo=N_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 ((VAL^(REG))&((REG)^w)&0x8000) cpu->AF.b.lo|=P_Z80; \
+ if (((REG)^w^VAL)&0x1000) cpu->AF.b.lo|=H_Z80; \
SETHIDDEN(w>>8); \
(REG)=w; \
} while(0)
@@ -261,19 +241,19 @@ do { \
#define INC8(REG) \
do { \
(REG)++; \
- cpu->AF.b[LO]=CARRY|SZtable[(REG)]; \
- if ((REG)==0x80) cpu->AF.b[LO]|=P_Z80; \
- if (((REG)&0x0f)==0) cpu->AF.b[LO]|=H_Z80; \
+ cpu->AF.b.lo=CARRY|SZtable[(REG)]; \
+ 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 { \
(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)]; \
+ 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)
@@ -315,9 +295,9 @@ do { \
*/
#define RRCA \
do { \
- 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]); \
+ 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)
@@ -325,9 +305,9 @@ do { \
do { \
Z80Byte c; \
c=CARRY; \
- 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]); \
+ 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)
@@ -336,7 +316,7 @@ do { \
Z80Byte c; \
c=(REG)&C_Z80; \
(REG)=((REG)>>1)|((REG)<<7); \
- cpu->AF.b[LO]=PSZtable[(REG)]|c; \
+ cpu->AF.b.lo=PSZtable[(REG)]|c; \
SETHIDDEN(REG); \
} while(0)
@@ -346,16 +326,16 @@ do { \
Z80Byte c; \
c=(REG)&C_Z80; \
(REG)=((REG)>>1)|(CARRY<<7); \
- cpu->AF.b[LO]=PSZtable[(REG)]|c; \
+ cpu->AF.b.lo=PSZtable[(REG)]|c; \
SETHIDDEN(REG); \
} while(0)
#define RLCA \
do { \
- 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]); \
+ 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)
@@ -363,9 +343,9 @@ do { \
do { \
Z80Byte c; \
c=CARRY; \
- 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]); \
+ 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)
@@ -374,7 +354,7 @@ do { \
Z80Byte c; \
c=(REG)>>7; \
(REG)=((REG)<<1)|c; \
- cpu->AF.b[LO]=PSZtable[(REG)]|c; \
+ cpu->AF.b.lo=PSZtable[(REG)]|c; \
SETHIDDEN(REG); \
} while(0)
@@ -384,7 +364,7 @@ do { \
Z80Byte c; \
c=(REG)>>7; \
(REG)=((REG)<<1)|CARRY; \
- cpu->AF.b[LO]=PSZtable[(REG)]|c; \
+ cpu->AF.b.lo=PSZtable[(REG)]|c; \
SETHIDDEN(REG); \
} while(0)
@@ -394,7 +374,7 @@ do { \
Z80Byte c; \
c=(REG)&C_Z80; \
(REG)>>=1; \
- cpu->AF.b[LO]=PSZtable[(REG)]|c; \
+ cpu->AF.b.lo=PSZtable[(REG)]|c; \
SETHIDDEN(REG); \
} while(0)
@@ -404,7 +384,7 @@ do { \
Z80Byte c; \
c=(REG)&C_Z80; \
(REG)=((REG)>>1)|((REG)&0x80); \
- cpu->AF.b[LO]=PSZtable[(REG)]|c; \
+ cpu->AF.b.lo=PSZtable[(REG)]|c; \
SETHIDDEN(REG); \
} while(0)
@@ -414,7 +394,7 @@ do { \
Z80Byte c; \
c=(REG)>>7; \
(REG)=((REG)<<1)|1; \
- cpu->AF.b[LO]=PSZtable[(REG)]|c; \
+ cpu->AF.b.lo=PSZtable[(REG)]|c; \
SETHIDDEN(REG); \
} while(0)
@@ -424,7 +404,7 @@ do { \
Z80Byte c; \
c=(REG)>>7; \
(REG)=(REG)<<1; \
- cpu->AF.b[LO]=PSZtable[(REG)]|c; \
+ cpu->AF.b.lo=PSZtable[(REG)]|c; \
SETHIDDEN(REG); \
} while(0)
@@ -433,41 +413,41 @@ do { \
*/
#define AND(VAL) \
do { \
- cpu->AF.b[HI]&=VAL; \
- cpu->AF.b[LO]=PSZtable[cpu->AF.b[HI]]|H_Z80; \
- SETHIDDEN(cpu->AF.b[HI]); \
+ cpu->AF.b.hi&=VAL; \
+ cpu->AF.b.lo=PSZtable[cpu->AF.b.hi]|H_Z80; \
+ SETHIDDEN(cpu->AF.b.hi); \
} while(0)
#define OR(VAL) \
do { \
- cpu->AF.b[HI]|=VAL; \
- cpu->AF.b[LO]=PSZtable[cpu->AF.b[HI]]; \
- SETHIDDEN(cpu->AF.b[HI]); \
+ cpu->AF.b.hi|=VAL; \
+ cpu->AF.b.lo=PSZtable[cpu->AF.b.hi]; \
+ SETHIDDEN(cpu->AF.b.hi); \
} while(0)
#define XOR(VAL) \
do { \
- cpu->AF.b[HI]^=VAL; \
- cpu->AF.b[LO]=PSZtable[cpu->AF.b[HI]]; \
- SETHIDDEN(cpu->AF.b[HI]); \
+ cpu->AF.b.hi^=VAL; \
+ cpu->AF.b.lo=PSZtable[cpu->AF.b.hi]; \
+ SETHIDDEN(cpu->AF.b.hi); \
} while(0)
#define BIT(REG,B) \
do { \
- cpu->AF.b[LO]=CARRY|H_Z80; \
+ cpu->AF.b.lo=CARRY|H_Z80; \
if ((REG)&(1<<B)) \
{ \
- if (B==7 && (REG&S_Z80)) cpu->AF.b[LO]|=S_Z80; \
- if (B==5 && (REG&B5_Z80)) cpu->AF.b[LO]|=B5_Z80; \
- if (B==3 && (REG&B3_Z80)) cpu->AF.b[LO]|=B3_Z80; \
+ if (B==7 && (REG&S_Z80)) cpu->AF.b.lo|=S_Z80; \
+ if (B==5 && (REG&B5_Z80)) cpu->AF.b.lo|=B5_Z80; \
+ if (B==3 && (REG&B3_Z80)) cpu->AF.b.lo|=B3_Z80; \
} \
else \
{ \
- cpu->AF.b[LO]|=Z_Z80; \
- cpu->AF.b[LO]|=P_Z80; \
+ cpu->AF.b.lo|=Z_Z80; \
+ cpu->AF.b.lo|=P_Z80; \
} \
} while(0)
@@ -560,7 +540,7 @@ do { \
else \
CLRFLAG(P_Z80); \
\
- SETHIDDEN(cpu->AF.b[HI]+b); \
+ SETHIDDEN(cpu->AF.b.hi+b); \
} while(0)
#define LDD \
@@ -581,7 +561,7 @@ do { \
else \
CLRFLAG(P_Z80); \
\
- SETHIDDEN(cpu->AF.b[HI]+b); \
+ SETHIDDEN(cpu->AF.b.hi+b); \
} while(0)
#define CPI \
@@ -638,13 +618,13 @@ do { \
b=IN(cpu->BC.w); \
POKE(cpu->HL.w,b); \
\
- cpu->BC.b[HI]--; \
+ cpu->BC.b.hi--; \
cpu->HL.w++; \
\
- cpu->AF.b[LO]=SZtable[cpu->BC.b[HI]]; \
- SETHIDDEN(cpu->BC.b[HI]); \
+ cpu->AF.b.lo=SZtable[cpu->BC.b.hi]; \
+ SETHIDDEN(cpu->BC.b.hi); \
\
- w=(((Z80Word)cpu->BC.b[LO])&0xff)+b; \
+ w=(((Z80Word)cpu->BC.b.lo)&0xff)+b; \
\
if (b&0x80) \
SETFLAG(N_Z80); \
@@ -669,13 +649,13 @@ do { \
b=IN(cpu->BC.w); \
POKE(cpu->HL.w,b); \
\
- cpu->BC.b[HI]--; \
+ cpu->BC.b.hi--; \
cpu->HL.w--; \
\
- cpu->AF.b[LO]=SZtable[cpu->BC.b[HI]]; \
- SETHIDDEN(cpu->BC.b[HI]); \
+ cpu->AF.b.lo=SZtable[cpu->BC.b.hi]; \
+ SETHIDDEN(cpu->BC.b.hi); \
\
- w=(((Z80Word)cpu->BC.b[LO])&0xff)+b; \
+ w=(((Z80Word)cpu->BC.b.lo)&0xff)+b; \
\
if (b&0x80) \
SETFLAG(N_Z80); \
@@ -697,10 +677,10 @@ do { \
OUT(cpu->BC.w,PEEK(cpu->HL.w)); \
\
cpu->HL.w++; \
- cpu->BC.b[HI]--; \
+ cpu->BC.b.hi--; \
\
- cpu->AF.b[LO]=SZtable[cpu->BC.b[HI]]; \
- SETHIDDEN(cpu->BC.b[HI]); \
+ cpu->AF.b.lo=SZtable[cpu->BC.b.hi]; \
+ SETHIDDEN(cpu->BC.b.hi); \
} while(0)
#define OUTD \
@@ -708,11 +688,11 @@ do { \
OUT(cpu->BC.w,PEEK(cpu->HL.w)); \
\
cpu->HL.w--; \
- cpu->BC.b[HI]--; \
+ cpu->BC.b.hi--; \
\
- cpu->AF.b[LO]=SZtable[cpu->BC.b[HI]]; \
+ cpu->AF.b.lo=SZtable[cpu->BC.b.hi]; \
SETFLAG(N_Z80); \
- SETHIDDEN(cpu->BC.b[HI]); \
+ SETHIDDEN(cpu->BC.b.hi); \
} while(0)
@@ -722,22 +702,22 @@ do { \
#define LD_BLOCK(BASE,DEST,DEST2) \
case BASE: /* LD DEST,B */ \
TSTATE(4); \
- DEST=cpu->BC.b[HI]; \
+ DEST=cpu->BC.b.hi; \
break; \
\
case BASE+1: /* LD DEST,C */ \
TSTATE(4); \
- DEST=cpu->BC.b[LO]; \
+ DEST=cpu->BC.b.lo; \
break; \
\
case BASE+2: /* LD DEST,D */ \
TSTATE(4); \
- DEST=cpu->DE.b[HI]; \
+ DEST=cpu->DE.b.hi; \
break; \
\
case BASE+3: /* LD DEST,E */ \
TSTATE(4); \
- DEST=cpu->DE.b[LO]; \
+ DEST=cpu->DE.b.lo; \
break; \
\
case BASE+4: /* LD DEST,H */ \
@@ -758,28 +738,28 @@ do { \
\
case BASE+7: /* LD DEST,A */ \
TSTATE(4); \
- DEST=cpu->AF.b[HI]; \
+ DEST=cpu->AF.b.hi; \
break;
#define ALU_BLOCK(BASE,OP) \
case BASE: /* OP A,B */ \
TSTATE(4); \
- OP(cpu->BC.b[HI]); \
+ OP(cpu->BC.b.hi); \
break; \
\
case BASE+1: /* OP A,C */ \
TSTATE(4); \
- OP(cpu->BC.b[LO]); \
+ OP(cpu->BC.b.lo); \
break; \
\
case BASE+2: /* OP A,D */ \
TSTATE(4); \
- OP(cpu->DE.b[HI]); \
+ OP(cpu->DE.b.hi); \
break; \
\
case BASE+3: /* OP A,E */ \
TSTATE(4); \
- OP(cpu->DE.b[LO]); \
+ OP(cpu->DE.b.lo); \
break; \
\
case BASE+4: /* OP A,H */ \
@@ -800,7 +780,7 @@ do { \
\
case BASE+7: /* OP A,A */ \
TSTATE(4); \
- OP(cpu->AF.b[HI]); \
+ OP(cpu->AF.b.hi); \
break;
@@ -810,32 +790,32 @@ do { \
#define CB_ALU_BLOCK(BASE,OP) \
case BASE: /* OP B */ \
TSTATE(8); \
- OP(cpu->BC.b[HI]); \
+ OP(cpu->BC.b.hi); \
break; \
\
case BASE+1: /* OP C */ \
TSTATE(8); \
- OP(cpu->BC.b[LO]); \
+ OP(cpu->BC.b.lo); \
break; \
\
case BASE+2: /* OP D */ \
TSTATE(8); \
- OP(cpu->DE.b[HI]); \
+ OP(cpu->DE.b.hi); \
break; \
\
case BASE+3: /* OP E */ \
TSTATE(8); \
- OP(cpu->DE.b[LO]); \
+ OP(cpu->DE.b.lo); \
break; \
\
case BASE+4: /* OP H */ \
TSTATE(8); \
- OP(cpu->HL.b[HI]); \
+ OP(cpu->HL.b.hi); \
break; \
\
case BASE+5: /* OP L */ \
TSTATE(8); \
- OP(cpu->HL.b[LO]); \
+ OP(cpu->HL.b.lo); \
break; \
\
case BASE+6: /* OP (HL) */ \
@@ -845,38 +825,38 @@ do { \
\
case BASE+7: /* OP A */ \
TSTATE(8); \
- OP(cpu->AF.b[HI]); \
+ OP(cpu->AF.b.hi); \
break;
#define CB_BITMANIP_BLOCK(BASE,OP,BIT_NO) \
case BASE: /* OP B */ \
TSTATE(8); \
- OP(cpu->BC.b[HI],BIT_NO); \
+ OP(cpu->BC.b.hi,BIT_NO); \
break; \
\
case BASE+1: /* OP C */ \
TSTATE(8); \
- OP(cpu->BC.b[LO],BIT_NO); \
+ OP(cpu->BC.b.lo,BIT_NO); \
break; \
\
case BASE+2: /* OP D */ \
TSTATE(8); \
- OP(cpu->DE.b[HI],BIT_NO); \
+ OP(cpu->DE.b.hi,BIT_NO); \
break; \
\
case BASE+3: /* OP E */ \
TSTATE(8); \
- OP(cpu->DE.b[LO],BIT_NO); \
+ OP(cpu->DE.b.lo,BIT_NO); \
break; \
\
case BASE+4: /* OP H */ \
TSTATE(8); \
- OP(cpu->HL.b[HI],BIT_NO); \
+ OP(cpu->HL.b.hi,BIT_NO); \
break; \
\
case BASE+5: /* OP L */ \
TSTATE(8); \
- OP(cpu->HL.b[LO],BIT_NO); \
+ OP(cpu->HL.b.lo,BIT_NO); \
break; \
\
case BASE+6: /* OP (HL) */ \
@@ -886,7 +866,7 @@ do { \
\
case BASE+7: /* OP A */ \
TSTATE(8); \
- OP(cpu->AF.b[HI],BIT_NO); \
+ OP(cpu->AF.b.hi,BIT_NO); \
break;
/* ---------------------------------------- SHIFTED CB OPCODE SHORT-HAND BLOCKS
@@ -895,32 +875,32 @@ do { \
#define SHIFTED_CB_ALU_BLOCK(BASE,OP) \
case BASE: /* OP B */ \
TSTATE(8); \
- OP_ON_MEM_WITH_COPY(OP,addr,cpu->BC.b[HI]); \
+ OP_ON_MEM_WITH_COPY(OP,addr,cpu->BC.b.hi); \
break; \
\
case BASE+1: /* OP C */ \
TSTATE(8); \
- OP_ON_MEM_WITH_COPY(OP,addr,cpu->BC.b[LO]); \
+ OP_ON_MEM_WITH_COPY(OP,addr,cpu->BC.b.lo); \
break; \
\
case BASE+2: /* OP D */ \
TSTATE(8); \
- OP_ON_MEM_WITH_COPY(OP,addr,cpu->DE.b[HI]); \
+ OP_ON_MEM_WITH_COPY(OP,addr,cpu->DE.b.hi); \
break; \
\
case BASE+3: /* OP E */ \
TSTATE(8); \
- OP_ON_MEM_WITH_COPY(OP,addr,cpu->DE.b[LO]); \
+ OP_ON_MEM_WITH_COPY(OP,addr,cpu->DE.b.lo); \
break; \
\
case BASE+4: /* OP H */ \
TSTATE(8); \
- OP_ON_MEM_WITH_COPY(OP,addr,cpu->HL.b[HI]); \
+ OP_ON_MEM_WITH_COPY(OP,addr,cpu->HL.b.hi); \
break; \
\
case BASE+5: /* OP L */ \
TSTATE(8); \
- OP_ON_MEM_WITH_COPY(OP,addr,cpu->HL.b[LO]); \
+ OP_ON_MEM_WITH_COPY(OP,addr,cpu->HL.b.lo); \
break; \
\
case BASE+6: /* OP (HL) */ \
@@ -930,38 +910,38 @@ do { \
\
case BASE+7: /* OP A */ \
TSTATE(8); \
- OP_ON_MEM_WITH_COPY(OP,addr,cpu->AF.b[HI]); \
+ OP_ON_MEM_WITH_COPY(OP,addr,cpu->AF.b.hi); \
break;
#define SHIFTED_CB_BITMANIP_BLOCK(BASE,OP,BIT_NO) \
case BASE: /* OP B */ \
TSTATE(8); \
- OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->BC.b[HI]); \
+ OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->BC.b.hi); \
break; \
\
case BASE+1: /* OP C */ \
TSTATE(8); \
- OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->BC.b[LO]); \
+ OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->BC.b.lo); \
break; \
\
case BASE+2: /* OP D */ \
TSTATE(8); \
- OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->DE.b[HI]); \
+ OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->DE.b.hi); \
break; \
\
case BASE+3: /* OP E */ \
TSTATE(8); \
- OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->DE.b[LO]); \
+ OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->DE.b.lo); \
break; \
\
case BASE+4: /* OP H */ \
TSTATE(8); \
- OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->HL.b[HI]); \
+ OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->HL.b.hi); \
break; \
\
case BASE+5: /* OP L */ \
TSTATE(8); \
- OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->HL.b[LO]); \
+ OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->HL.b.lo); \
break; \
\
case BASE+6: /* OP (HL) */ \
@@ -971,7 +951,7 @@ do { \
\
case BASE+7: /* OP A */ \
TSTATE(8); \
- OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->AF.b[HI]); \
+ OP_ON_MEM_WITH_ARG_AND_COPY(OP,addr,BIT_NO,cpu->AF.b.hi); \
break;
/* ---------------------------------------- DAA
@@ -984,8 +964,8 @@ static void DAA (Z80 *cpu)
{
Z80Byte add=0;
Z80Byte carry=0;
- Z80Byte nf=cpu->AF.b[LO]&N_Z80;
- Z80Byte acc=cpu->AF.b[HI];
+ Z80Byte nf=cpu->AF.b.lo&N_Z80;
+ Z80Byte acc=cpu->AF.b.hi;
if (acc>0x99 || IS_C)
{
@@ -1000,18 +980,18 @@ static void DAA (Z80 *cpu)
if (nf)
{
- cpu->AF.b[HI]-=add;
+ cpu->AF.b.hi-=add;
}
else
{
- cpu->AF.b[HI]+=add;
+ cpu->AF.b.hi+=add;
}
- cpu->AF.b[LO]=PSZtable[cpu->AF.b[HI]]
+ cpu->AF.b.lo=PSZtable[cpu->AF.b.hi]
| carry
| nf
- | ((acc^cpu->AF.b[HI])&H_Z80)
- | (cpu->AF.b[HI]&(B3_Z80|B5_Z80));
+ | ((acc^cpu->AF.b.hi)&H_Z80)
+ | (cpu->AF.b.hi&(B3_Z80|B5_Z80));
}
/* ---------------------------------------- HANDLERS FOR ED OPCODES
@@ -1025,20 +1005,20 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
if (PRIV->pread)
{
- cpu->BC.b[HI]=PRIV->pread(cpu,cpu->BC.w);
+ cpu->BC.b.hi=PRIV->pread(cpu,cpu->BC.w);
}
else
{
- cpu->BC.b[HI]=0;
+ cpu->BC.b.hi=0;
}
- cpu->AF.b[LO]=CARRY|PSZtable[cpu->BC.b[HI]];
- SETHIDDEN(cpu->BC.b[HI]);
+ cpu->AF.b.lo=CARRY|PSZtable[cpu->BC.b.hi];
+ SETHIDDEN(cpu->BC.b.hi);
break;
case 0x41: /* OUT (C),B */
TSTATE(12);
- if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->BC.b[HI]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->BC.b.hi);
break;
case 0x42: /* SBC HL,BC */
@@ -1057,8 +1037,8 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
TSTATE(8);
- b=cpu->AF.b[HI];
- cpu->AF.b[HI]=0;
+ b=cpu->AF.b.hi;
+ cpu->AF.b.hi=0;
SUB8(b);
break;
}
@@ -1076,7 +1056,7 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x47: /* LD I,A */
TSTATE(9);
- cpu->I=cpu->AF.b[HI];
+ cpu->I=cpu->AF.b.hi;
break;
case 0x48: /* IN C,(C) */
@@ -1084,20 +1064,20 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
if (PRIV->pread)
{
- cpu->BC.b[LO]=PRIV->pread(cpu,cpu->BC.w);
+ cpu->BC.b.lo=PRIV->pread(cpu,cpu->BC.w);
}
else
{
- cpu->BC.b[LO]=0;
+ cpu->BC.b.lo=0;
}
- cpu->AF.b[LO]=CARRY|PSZtable[cpu->BC.b[LO]];
- SETHIDDEN(cpu->BC.b[LO]);
+ cpu->AF.b.lo=CARRY|PSZtable[cpu->BC.b.lo];
+ SETHIDDEN(cpu->BC.b.lo);
break;
case 0x49: /* OUT (C),C */
TSTATE(12);
- if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->BC.b[LO]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->BC.b.lo);
break;
case 0x4a: /* ADC HL,BC */
@@ -1116,8 +1096,8 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
TSTATE(8);
- b=cpu->AF.b[HI];
- cpu->AF.b[HI]=0;
+ b=cpu->AF.b.hi;
+ cpu->AF.b.hi=0;
SUB8(b);
break;
}
@@ -1136,7 +1116,7 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x4f: /* LD R,A */
TSTATE(9);
- cpu->R=cpu->AF.b[HI];
+ cpu->R=cpu->AF.b.hi;
break;
case 0x50: /* IN D,(C) */
@@ -1144,20 +1124,20 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
if (PRIV->pread)
{
- cpu->DE.b[HI]=PRIV->pread(cpu,cpu->BC.w);
+ cpu->DE.b.hi=PRIV->pread(cpu,cpu->BC.w);
}
else
{
- cpu->DE.b[HI]=0;
+ cpu->DE.b.hi=0;
}
- cpu->AF.b[LO]=CARRY|PSZtable[cpu->DE.b[HI]];
- SETHIDDEN(cpu->BC.b[HI]);
+ cpu->AF.b.lo=CARRY|PSZtable[cpu->DE.b.hi];
+ SETHIDDEN(cpu->BC.b.hi);
break;
case 0x51: /* OUT (C),D */
TSTATE(12);
- if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->DE.b[HI]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->DE.b.hi);
break;
case 0x52: /* SBC HL,DE */
@@ -1176,8 +1156,8 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
TSTATE(8);
- b=cpu->AF.b[HI];
- cpu->AF.b[HI]=0;
+ b=cpu->AF.b.hi;
+ cpu->AF.b.hi=0;
SUB8(b);
break;
}
@@ -1195,7 +1175,7 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x57: /* LD A,I */
TSTATE(9);
- cpu->AF.b[HI]=cpu->I;
+ cpu->AF.b.hi=cpu->I;
break;
case 0x58: /* IN E,(C) */
@@ -1203,20 +1183,20 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
if (PRIV->pread)
{
- cpu->DE.b[LO]=PRIV->pread(cpu,cpu->BC.w);
+ cpu->DE.b.lo=PRIV->pread(cpu,cpu->BC.w);
}
else
{
- cpu->BC.b[LO]=0;
+ cpu->BC.b.lo=0;
}
- cpu->AF.b[LO]=CARRY|PSZtable[cpu->DE.b[LO]];
- SETHIDDEN(cpu->DE.b[LO]);
+ cpu->AF.b.lo=CARRY|PSZtable[cpu->DE.b.lo];
+ SETHIDDEN(cpu->DE.b.lo);
break;
case 0x59: /* OUT (C),E */
TSTATE(12);
- if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->DE.b[LO]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->DE.b.lo);
break;
case 0x5a: /* ADC HL,DE */
@@ -1235,8 +1215,8 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
TSTATE(8);
- b=cpu->AF.b[HI];
- cpu->AF.b[HI]=0;
+ b=cpu->AF.b.hi;
+ cpu->AF.b.hi=0;
SUB8(b);
break;
}
@@ -1254,7 +1234,7 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
case 0x5f: /* LD A,R */
TSTATE(9);
- cpu->AF.b[HI]=cpu->R;
+ cpu->AF.b.hi=cpu->R;
break;
case 0x60: /* IN H,(C) */
@@ -1262,20 +1242,20 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
if (PRIV->pread)
{
- cpu->HL.b[HI]=PRIV->pread(cpu,cpu->BC.w);
+ cpu->HL.b.hi=PRIV->pread(cpu,cpu->BC.w);
}
else
{
- cpu->HL.b[HI]=0;
+ cpu->HL.b.hi=0;
}
- cpu->AF.b[LO]=CARRY|PSZtable[cpu->HL.b[HI]];
- SETHIDDEN(cpu->HL.b[HI]);
+ cpu->AF.b.lo=CARRY|PSZtable[cpu->HL.b.hi];
+ SETHIDDEN(cpu->HL.b.hi);
break;
case 0x61: /* OUT (C),H */
TSTATE(12);
- if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->HL.b[HI]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->HL.b.hi);
break;
case 0x62: /* SBC HL,HL */
@@ -1294,8 +1274,8 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
TSTATE(8);
- b=cpu->AF.b[HI];
- cpu->AF.b[HI]=0;
+ b=cpu->AF.b.hi;
+ cpu->AF.b.hi=0;
SUB8(b);
break;
}
@@ -1319,11 +1299,11 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
b=PEEK(cpu->HL.w);
- POKE(cpu->HL.w,(b>>4)|(cpu->AF.b[HI]<<4));
- cpu->AF.b[HI]=(cpu->AF.b[HI]&0xf0)|(b&0x0f);
+ POKE(cpu->HL.w,(b>>4)|(cpu->AF.b.hi<<4));
+ cpu->AF.b.hi=(cpu->AF.b.hi&0xf0)|(b&0x0f);
- cpu->AF.b[LO]=CARRY|PSZtable[cpu->AF.b[HI]];
- SETHIDDEN(cpu->AF.b[HI]);
+ cpu->AF.b.lo=CARRY|PSZtable[cpu->AF.b.hi];
+ SETHIDDEN(cpu->AF.b.hi);
break;
}
@@ -1332,20 +1312,20 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
if (PRIV->pread)
{
- cpu->HL.b[LO]=PRIV->pread(cpu,cpu->BC.w);
+ cpu->HL.b.lo=PRIV->pread(cpu,cpu->BC.w);
}
else
{
- cpu->HL.b[LO]=0;
+ cpu->HL.b.lo=0;
}
- cpu->AF.b[LO]=CARRY|PSZtable[cpu->HL.b[LO]];
- SETHIDDEN(cpu->HL.b[LO]);
+ cpu->AF.b.lo=CARRY|PSZtable[cpu->HL.b.lo];
+ SETHIDDEN(cpu->HL.b.lo);
break;
case 0x69: /* OUT (C),L */
TSTATE(12);
- if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->HL.b[LO]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->HL.b.lo);
break;
case 0x6a: /* ADC HL,HL */
@@ -1364,8 +1344,8 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
TSTATE(8);
- b=cpu->AF.b[HI];
- cpu->AF.b[HI]=0;
+ b=cpu->AF.b.hi;
+ cpu->AF.b.hi=0;
SUB8(b);
break;
}
@@ -1389,11 +1369,11 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
b=PEEK(cpu->HL.w);
- POKE(cpu->HL.w,(b<<4)|(cpu->AF.b[HI]&0x0f));
- cpu->AF.b[HI]=(cpu->AF.b[HI]&0xf0)|(b>>4);
+ POKE(cpu->HL.w,(b<<4)|(cpu->AF.b.hi&0x0f));
+ cpu->AF.b.hi=(cpu->AF.b.hi&0xf0)|(b>>4);
- cpu->AF.b[LO]=CARRY|PSZtable[cpu->AF.b[HI]];
- SETHIDDEN(cpu->AF.b[HI]);
+ cpu->AF.b.lo=CARRY|PSZtable[cpu->AF.b.hi];
+ SETHIDDEN(cpu->AF.b.hi);
break;
}
@@ -1412,7 +1392,7 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
b=0;
}
- cpu->AF.b[LO]=CARRY|PSZtable[b];
+ cpu->AF.b.lo=CARRY|PSZtable[b];
SETHIDDEN(b);
break;
}
@@ -1438,8 +1418,8 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
TSTATE(8);
- b=cpu->AF.b[HI];
- cpu->AF.b[HI]=0;
+ b=cpu->AF.b.hi;
+ cpu->AF.b.hi=0;
SUB8(b);
break;
}
@@ -1465,20 +1445,20 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
if (PRIV->pread)
{
- cpu->AF.b[HI]=PRIV->pread(cpu,cpu->BC.w);
+ cpu->AF.b.hi=PRIV->pread(cpu,cpu->BC.w);
}
else
{
- cpu->AF.b[HI]=0;
+ cpu->AF.b.hi=0;
}
- cpu->AF.b[LO]=CARRY|PSZtable[cpu->AF.b[HI]];
- SETHIDDEN(cpu->AF.b[HI]);
+ cpu->AF.b.lo=CARRY|PSZtable[cpu->AF.b.hi];
+ SETHIDDEN(cpu->AF.b.hi);
break;
case 0x79: /* OUT (C),A */
TSTATE(12);
- if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->AF.b[HI]);
+ if (PRIV->pwrite) PRIV->pwrite(cpu,cpu->BC.w,cpu->AF.b.hi);
break;
case 0x7a: /* ADC HL,SP */
@@ -1497,8 +1477,8 @@ static void DecodeED(Z80 *cpu, Z80Byte opcode)
TSTATE(8);
- b=cpu->AF.b[HI];
- cpu->AF.b[HI]=0;
+ b=cpu->AF.b.hi;
+ cpu->AF.b.hi=0;
SUB8(b);
break;
}
@@ -1769,18 +1749,18 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
{
case 0xdd:
HL=&(cpu->IX.w);
- L=cpu->IX.b+LO;
- H=cpu->IX.b+HI;
+ L=&(cpu->IX.b.lo);
+ H=&(cpu->IX.b.hi);
break;
case 0xfd:
HL=&(cpu->IY.w);
- L=cpu->IY.b+LO;
- H=cpu->IY.b+HI;
+ L=&(cpu->IY.b.lo);
+ H=&(cpu->IY.b.hi);
break;
default:
HL=&(cpu->HL.w);
- L=cpu->HL.b+LO;
- H=cpu->HL.b+HI;
+ L=&(cpu->HL.b.lo);
+ H=&(cpu->HL.b.hi);
break;
}
@@ -1797,7 +1777,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x02: /* LD (BC),A */
TSTATE(7);
- POKE(cpu->BC.w,cpu->AF.b[HI]);
+ POKE(cpu->BC.w,cpu->AF.b.hi);
break;
case 0x03: /* INC BC */
@@ -1807,17 +1787,17 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x04: /* INC B */
TSTATE(4);
- INC8(cpu->BC.b[HI]);
+ INC8(cpu->BC.b.hi);
break;
case 0x05: /* DEC B */
TSTATE(4);
- DEC8(cpu->BC.b[HI]);
+ DEC8(cpu->BC.b.hi);
break;
case 0x06: /* LD B,n */
TSTATE(7);
- cpu->BC.b[HI]=FETCH_BYTE;
+ cpu->BC.b.hi=FETCH_BYTE;
break;
case 0x07: /* RLCA */
@@ -1837,7 +1817,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x0a: /* LD A,(BC) */
TSTATE(7);
- cpu->AF.b[HI]=PEEK(cpu->BC.w);
+ cpu->AF.b.hi=PEEK(cpu->BC.w);
break;
case 0x0b: /* DEC BC */
@@ -1847,17 +1827,17 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x0c: /* INC C */
TSTATE(4);
- INC8(cpu->BC.b[LO]);
+ INC8(cpu->BC.b.lo);
break;
case 0x0d: /* DEC C */
TSTATE(4);
- DEC8(cpu->BC.b[LO]);
+ DEC8(cpu->BC.b.lo);
break;
case 0x0e: /* LD C,n */
TSTATE(7);
- cpu->BC.b[LO]=FETCH_BYTE;
+ cpu->BC.b.lo=FETCH_BYTE;
break;
case 0x0f: /* RRCA */
@@ -1866,7 +1846,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
break;
case 0x10: /* DJNZ */
- if (--(cpu->BC.b[HI]))
+ if (--(cpu->BC.b.hi))
{
TSTATE(13);
JR;
@@ -1885,7 +1865,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x12: /* LD (DE),A */
TSTATE(7);
- POKE(cpu->DE.w,cpu->AF.b[HI]);
+ POKE(cpu->DE.w,cpu->AF.b.hi);
break;
case 0x13: /* INC DE */
@@ -1895,17 +1875,17 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x14: /* INC D */
TSTATE(4);
- INC8(cpu->DE.b[HI]);
+ INC8(cpu->DE.b.hi);
break;
case 0x15: /* DEC D */
TSTATE(4);
- DEC8(cpu->DE.b[HI]);
+ DEC8(cpu->DE.b.hi);
break;
case 0x16: /* LD D,n */
TSTATE(7);
- cpu->DE.b[HI]=FETCH_BYTE;
+ cpu->DE.b.hi=FETCH_BYTE;
break;
case 0x17: /* RLA */
@@ -1925,7 +1905,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x1a: /* LD A,(DE) */
TSTATE(7);
- cpu->AF.b[HI]=PEEK(cpu->DE.w);
+ cpu->AF.b.hi=PEEK(cpu->DE.w);
break;
case 0x1b: /* DEC DE */
@@ -1935,17 +1915,17 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x1c: /* INC E */
TSTATE(4);
- INC8(cpu->DE.b[LO]);
+ INC8(cpu->DE.b.lo);
break;
case 0x1d: /* DEC E */
TSTATE(4);
- DEC8(cpu->DE.b[LO]);
+ DEC8(cpu->DE.b.lo);
break;
case 0x1e: /* LD E,n */
TSTATE(7);
- cpu->DE.b[LO]=FETCH_BYTE;
+ cpu->DE.b.lo=FETCH_BYTE;
break;
case 0x1f: /* RRA */
@@ -2028,10 +2008,10 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x2f: /* CPL */
TSTATE(4);
- cpu->AF.b[HI]^=0xff;
+ cpu->AF.b.hi^=0xff;
SETFLAG(H_Z80);
SETFLAG(N_Z80);
- SETHIDDEN(cpu->AF.b[HI]);
+ SETHIDDEN(cpu->AF.b.hi);
break;
case 0x30: /* JR NC,d */
@@ -2045,7 +2025,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x32: /* LD (nnnn),A */
TSTATE(13);
- POKE(FETCH_WORD,cpu->AF.b[HI]);
+ POKE(FETCH_WORD,cpu->AF.b.hi);
break;
case 0x33: /* INC SP */
@@ -2073,9 +2053,9 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x37: /* SCF */
TSTATE(4);
- cpu->AF.b[LO]=(cpu->AF.b[LO]&(S_Z80|Z_Z80|P_Z80))
+ cpu->AF.b.lo=(cpu->AF.b.lo&(S_Z80|Z_Z80|P_Z80))
| C_Z80
- | (cpu->AF.b[HI]&(B3_Z80|B5_Z80));
+ | (cpu->AF.b.hi&(B3_Z80|B5_Z80));
break;
case 0x38: /* JR C,d */
@@ -2089,7 +2069,7 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x3a: /* LD A,(nnnn) */
TSTATE(13);
- cpu->AF.b[HI]=PEEK(FETCH_WORD);
+ cpu->AF.b.hi=PEEK(FETCH_WORD);
break;
case 0x3b: /* DEC SP */
@@ -2099,17 +2079,17 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x3c: /* INC A */
TSTATE(4);
- INC8(cpu->AF.b[HI]);
+ INC8(cpu->AF.b.hi);
break;
case 0x3d: /* DEC A */
TSTATE(4);
- DEC8(cpu->AF.b[HI]);
+ DEC8(cpu->AF.b.hi);
break;
case 0x3e: /* LD A,n */
TSTATE(7);
- cpu->AF.b[HI]=FETCH_BYTE;
+ cpu->AF.b.hi=FETCH_BYTE;
break;
case 0x3f: /* CCF */
@@ -2120,51 +2100,51 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
else
CLRFLAG(H_Z80);
- cpu->AF.b[LO]^=C_Z80;
- SETHIDDEN(cpu->AF.b[HI]);
+ cpu->AF.b.lo^=C_Z80;
+ SETHIDDEN(cpu->AF.b.hi);
break;
- 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])
+ 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);
OFFSET(off);
- POKE(*HL+off,cpu->BC.b[HI]);
+ POKE(*HL+off,cpu->BC.b.hi);
break;
case 0x71: /* LD (HL),C */
TSTATE(7);
OFFSET(off);
- POKE(*HL+off,cpu->BC.b[LO]);
+ POKE(*HL+off,cpu->BC.b.lo);
break;
case 0x72: /* LD (HL),D */
TSTATE(7);
OFFSET(off);
- POKE(*HL+off,cpu->DE.b[HI]);
+ POKE(*HL+off,cpu->DE.b.hi);
break;
case 0x73: /* LD (HL),E */
TSTATE(7);
OFFSET(off);
- POKE(*HL+off,cpu->DE.b[LO]);
+ POKE(*HL+off,cpu->DE.b.lo);
break;
case 0x74: /* LD (HL),H */
TSTATE(7);
OFFSET(off);
- POKE(*HL+off,cpu->HL.b[HI]);
+ POKE(*HL+off,cpu->HL.b.hi);
break;
case 0x75: /* LD (HL),L */
TSTATE(7);
OFFSET(off);
- POKE(*HL+off,cpu->HL.b[LO]);
+ POKE(*HL+off,cpu->HL.b.lo);
break;
case 0x76: /* HALT */
@@ -2180,10 +2160,10 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
case 0x77: /* LD (HL),A */
TSTATE(7);
OFFSET(off);
- POKE(*HL+off,cpu->AF.b[HI]);
+ POKE(*HL+off,cpu->AF.b.hi);
break;
- LD_BLOCK(0x78,cpu->AF.b[HI],cpu->AF.b[HI])
+ LD_BLOCK(0x78,cpu->AF.b.hi,cpu->AF.b.hi)
ALU_BLOCK(0x80,ADD8)
ALU_BLOCK(0x88,ADC8)
@@ -2297,8 +2277,8 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
Z80Word port;
port=FETCH_BYTE;
- port|=(Z80Word)cpu->AF.b[HI]<<8;
- PRIV->pwrite(cpu,port,cpu->AF.b[HI]);
+ port|=(Z80Word)cpu->AF.b.hi<<8;
+ PRIV->pwrite(cpu,port,cpu->AF.b.hi);
}
else
cpu->PC++;
@@ -2344,8 +2324,8 @@ void Z80_Decode(Z80 *cpu, Z80Byte opcode)
Z80Word port;
port=FETCH_BYTE;
- port|=(Z80Word)cpu->AF.b[HI]<<8;
- cpu->AF.b[HI]=PRIV->pread(cpu,port);
+ port|=(Z80Word)cpu->AF.b.hi<<8;
+ cpu->AF.b.hi=PRIV->pread(cpu,port);
}
else
cpu->PC++;
diff --git a/z80_dis.c b/z80_dis.c
index 8a8ade8..dc593cd 100644
--- a/z80_dis.c
+++ b/z80_dis.c
@@ -2,11 +2,11 @@
z80 - Z80 Emulator
- Copyright (C) 2006 Ian Cowburn <ianc@noddybox.co.uk>
+ Copyright (C) 2021 Ian Cowburn <ianc@noddybox.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -15,16 +15,13 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ along with this program; if not, see <http://www.gnu.org/licenses/>
-------------------------------------------------------------------------
$Id$
*/
-static const char ident[]="$Id$";
-
#include "z80_config.h"
#ifdef ENABLE_DISASSEM
diff --git a/z80_private.h b/z80_private.h
index be45e56..c03df07 100644
--- a/z80_private.h
+++ b/z80_private.h
@@ -2,11 +2,11 @@
z80 - Z80 emulation
- Copyright (C) 2006 Ian Cowburn (ianc@noddybox.demon.co.uk)
+ Copyright (C) 2021 Ian Cowburn (ianc@noddybox.co.uk)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -15,8 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ along with this program; if not, see <http://www.gnu.org/licenses/>
-------------------------------------------------------------------------
@@ -49,6 +48,8 @@ struct Z80Private
{
Z80Val cycle;
+ Z80Val timer[Z80_NO_TIMERS];
+
int halt;
Z80Byte shift;
@@ -120,13 +121,15 @@ extern Z80Byte Z80_MEMORY[];
#define SET(v,b) (v)|=b
#define CLR(v,b) (v)&=~(b)
-#define SETFLAG(f) SET(cpu->AF.b[LO],f)
-#define CLRFLAG(f) CLR(cpu->AF.b[LO],f)
+#define SETFLAG(f) SET(cpu->AF.b.lo,f)
+#define CLRFLAG(f) CLR(cpu->AF.b.lo,f)
#ifdef ENABLE_ARRAY_MEMORY
#define PEEK(addr) Z80_MEMORY[addr]
+/* This can't be a macro as the macro is used as PEEKW(FETCH_WORD)
+*/
static inline Z80Word PEEKW(Z80Word addr)
{
return (PEEK(addr) | (Z80Word)PEEK(addr+1)<<8);
@@ -167,19 +170,25 @@ static inline Z80Word PEEKW(Z80Word addr)
#endif
-#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 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
#define IS_IX_IY (PRIV->shift==0xdd || PRIV->shift==0xfd)
#define OFFSET(off) off=(IS_IX_IY ? (Z80Relative)FETCH_BYTE:0)
-#define TSTATE(n) PRIV->cycle+=n
+#define TSTATE(n) do \
+ { \
+ PRIV->cycle+=n; \
+ PRIV->timer[Z80_TIMER_1]+=n; \
+ PRIV->timer[Z80_TIMER_2]+=n; \
+ PRIV->timer[Z80_TIMER_3]+=n; \
+ } while(0)
#define ADD_R(v) cpu->R=((cpu->R&0x80)|((cpu->R+(v))&0x7f))
#define INC_R ADD_R(1)
@@ -212,7 +221,7 @@ static inline Z80Word PEEKW(Z80Word addr)
cpu->SP+=2; \
} while(0)
-#define SETHIDDEN(res) cpu->AF.b[LO]=(cpu->AF.b[LO]&~(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 \