summaryrefslogtreecommitdiff
path: root/z80_private.h
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 /z80_private.h
parent66d4bb423e981aece8c5590eb2a5968a5d874c9f (diff)
Updated with latest Z80 core from 3dsspec
Diffstat (limited to 'z80_private.h')
-rw-r--r--z80_private.h37
1 files changed, 23 insertions, 14 deletions
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 \