summaryrefslogtreecommitdiff
path: root/z80_private.h
diff options
context:
space:
mode:
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 \
{ \