summaryrefslogtreecommitdiff
path: root/source/z80.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2023-04-23 08:24:31 +0800
committerIan C <ianc@noddybox.co.uk>2023-04-23 08:24:31 +0800
commit1d1e0acb5b4494f7c1b041e24e5de4f0614a150b (patch)
treef43094ced9e4b3dae4e9912eef606a9c567c635e /source/z80.c
parentef18a653053c30237a9aff27eea91d38bd308987 (diff)
Updated Z80 emulation
Diffstat (limited to 'source/z80.c')
-rw-r--r--source/z80.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/source/z80.c b/source/z80.c
index e5f6c92..d18640a 100644
--- a/source/z80.c
+++ b/source/z80.c
@@ -50,6 +50,8 @@ static void InitTables()
static void Z80_CheckInterrupt(Z80 *cpu)
{
+ Z80Word vector;
+
/* Check interrupts
*/
if (PRIV->raise)
@@ -68,6 +70,7 @@ static void Z80_CheckInterrupt(Z80 *cpu)
PRIV->nmi=FALSE;
PUSH(cpu->PC);
cpu->PC=0x66;
+ PRIV->memptr.w=cpu->PC;
}
else if (cpu->IFF1)
{
@@ -95,11 +98,14 @@ static void Z80_CheckInterrupt(Z80 *cpu)
case 1:
PUSH(cpu->PC);
cpu->PC=0x38;
+ PRIV->memptr.w=cpu->PC;
break;
case 2:
PUSH(cpu->PC);
- cpu->PC=(Z80Word)cpu->I*256+PRIV->devbyte;
+ vector=(Z80Word)cpu->I*256+PRIV->devbyte;
+ cpu->PC=PEEKW(vector);
+ PRIV->memptr.w=cpu->PC;
break;
}
}
@@ -170,6 +176,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;
@@ -194,6 +204,8 @@ void Z80Reset(Z80 *cpu)
PRIV->raise=FALSE;
PRIV->nmi=FALSE;
+
+ PRIV->memptr.w = 0x0000;
}
@@ -209,6 +221,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;