summaryrefslogtreecommitdiff
path: root/z80_private.h
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2022-12-24 21:26:38 +0000
committerIan C <ianc@noddybox.co.uk>2022-12-24 21:26:38 +0000
commit51f4e96faabb862c10924ea92e4137e8fcf57d37 (patch)
tree1636aaa697908c3d8b6c4fbf3123b1eb46847edb /z80_private.h
parent2be063571c837ed5dd11a3be1211cb8182d4312d (diff)
Added MEMPTR setting.
Diffstat (limited to 'z80_private.h')
-rw-r--r--z80_private.h49
1 files changed, 43 insertions, 6 deletions
diff --git a/z80_private.h b/z80_private.h
index c03df07..b052c04 100644
--- a/z80_private.h
+++ b/z80_private.h
@@ -71,6 +71,8 @@ struct Z80Private
Z80Callback callback[eZ80_NO_CALLBACK][MAX_PER_CALLBACK];
int last_cb;
+
+ Z80Reg memptr;
};
#define PRIV cpu->priv
@@ -180,7 +182,19 @@ static inline Z80Word PEEKW(Z80Word addr)
#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 OFFSET(base,off) do \
+ { \
+ if (IS_IX_IY) \
+ { \
+ off=(Z80Relative)FETCH_BYTE; \
+ PRIV->memptr.w=base+off; \
+ } \
+ else \
+ { \
+ off=0; \
+ } \
+ } while(0)
#define TSTATE(n) do \
{ \
@@ -228,13 +242,36 @@ static inline Z80Word PEEKW(Z80Word addr)
{ \
PUSH(cpu->PC+2); \
cpu->PC=PEEKW(cpu->PC); \
+ PRIV->memptr.w=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 NOCALL do \
+ { \
+ PRIV->memptr.w=PEEKW(cpu->PC); \
+ cpu->PC+=2; \
+ } while(0)
+
+#define JP do \
+ { \
+ cpu->PC=PEEKW(cpu->PC); \
+ PRIV->memptr.w=cpu->PC; \
+ } while(0)
+
+#define NOJP NOCALL
+
+#define JR do \
+ { \
+ cpu->PC+=(Z80Relative)PEEK(cpu->PC)+1; \
+ PRIV->memptr.w=cpu->PC; \
+ } while(0)
+
+#define NOJR do \
+ { \
+ Z80Word addr=cpu->PC+ \
+ (Z80Relative)PEEK(cpu->PC)+1; \
+ PRIV->memptr.w=addr; \
+ cpu->PC++; \
+ } while(0)
#define OUT(P,V) do \
{ \