summaryrefslogtreecommitdiff
path: root/emma.c
diff options
context:
space:
mode:
Diffstat (limited to 'emma.c')
-rw-r--r--emma.c139
1 files changed, 61 insertions, 78 deletions
diff --git a/emma.c b/emma.c
index 89a70de..a719885 100644
--- a/emma.c
+++ b/emma.c
@@ -207,17 +207,19 @@ static const char *FlagString(Z80Byte flag)
static void DisplayState(void)
{
- Z80State s;
-
- Z80GetState(z80,&s);
-
- Log("A=%2.2x F=%s ",s.AF>>8,FlagString(s.AF&0xff));
- Log("BC=%4.4x DE=%4.4x HL=%4.4x ",s.BC,s.DE,s.HL);
- Log("IX=%4.4x IY=%4.4x SP=%4.4x\n",s.IX,s.IY,s.SP);
- Log("I=%2.2x IM=%2.2x R=%2.2x ",s.I,s.IM,s.R);
- Log("IFF1=%2.2x IFF2=%2.2x CYCLES=%lu\n",s.IFF1,s.IFF2,s.cycle);
- Log("%4.4x: ",s.PC);
- Log("%s\n",Disassemble(&s.PC));
+ Z80Word pc;
+
+ pc=z80->PC;
+
+ Log("A=%2.2x F=%s ",
+ z80->AF.b[Z80_HI_WORD],FlagString(z80->AF.b[Z80_LO_WORD]));
+ 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);
+ Log("IFF1=%2.2x IFF2=%2.2x CYCLES=%lu\n",
+ z80->IFF1,z80->IFF2,Z80Cycles(z80));
+ Log("%4.4x: ",pc);
+ Log("%s\n",Disassemble(&pc));
}
@@ -238,75 +240,72 @@ static int StrEq(const char *a, const char *b)
static int Expand(void *client, const char *p, long *res)
{
- Z80State s;
int ok=TRUE;
- Z80GetState(z80,&s);
-
if (StrEq(p,"AF"))
- *res=s.AF;
+ *res=z80->AF.w;
else if (StrEq(p,"BC"))
- *res=s.BC;
+ *res=z80->BC.w;
else if (StrEq(p,"DE"))
- *res=s.DE;
+ *res=z80->DE.w;
else if (StrEq(p,"HL"))
- *res=s.HL;
+ *res=z80->HL.w;
else if (StrEq(p,"IX"))
- *res=s.IX;
+ *res=z80->IX.w;
else if (StrEq(p,"IY"))
- *res=s.IY;
+ *res=z80->IY.w;
else if (StrEq(p,"SP"))
- *res=s.SP;
+ *res=z80->SP;
else if (StrEq(p,"PC"))
- *res=s.PC;
+ *res=z80->PC;
else if (StrEq(p,"A"))
- *res=HI(s.AF);
+ *res=HI(z80->AF.w);
else if (StrEq(p,"F"))
- *res=LO(s.AF);
+ *res=LO(z80->AF.w);
else if (StrEq(p,"B"))
- *res=HI(s.BC);
+ *res=HI(z80->BC.w);
else if (StrEq(p,"C"))
- *res=LO(s.BC);
+ *res=LO(z80->BC.w);
else if (StrEq(p,"D"))
- *res=HI(s.DE);
+ *res=HI(z80->DE.w);
else if (StrEq(p,"E"))
- *res=LO(s.DE);
+ *res=LO(z80->DE.w);
else if (StrEq(p,"H"))
- *res=HI(s.HL);
+ *res=HI(z80->HL.w);
else if (StrEq(p,"L"))
- *res=LO(s.HL);
+ *res=LO(z80->HL.w);
else if (StrEq(p,"AF_"))
- *res=s.AF_;
+ *res=z80->AF_;
else if (StrEq(p,"BC_"))
- *res=s.BC_;
+ *res=z80->BC_;
else if (StrEq(p,"DE_"))
- *res=s.DE_;
+ *res=z80->DE_;
else if (StrEq(p,"HL_"))
- *res=s.HL_;
+ *res=z80->HL_;
else if (StrEq(p,"A_"))
- *res=HI(s.AF_);
+ *res=HI(z80->AF_);
else if (StrEq(p,"F_"))
- *res=LO(s.AF_);
+ *res=LO(z80->AF_);
else if (StrEq(p,"B_"))
- *res=HI(s.BC_);
+ *res=HI(z80->BC_);
else if (StrEq(p,"C_"))
- *res=LO(s.BC_);
+ *res=LO(z80->BC_);
else if (StrEq(p,"D_"))
- *res=HI(s.DE_);
+ *res=HI(z80->DE_);
else if (StrEq(p,"E_"))
- *res=LO(s.DE_);
+ *res=LO(z80->DE_);
else if (StrEq(p,"H_"))
- *res=HI(s.HL_);
+ *res=HI(z80->HL_);
else if (StrEq(p,"L_"))
- *res=LO(s.HL_);
+ *res=LO(z80->HL_);
else if (StrEq(p,"IM"))
- *res=s.IM;
+ *res=z80->IM;
else if (StrEq(p,"R"))
- *res=s.R;
+ *res=z80->R;
else if (StrEq(p,"IFF1"))
- *res=s.IFF1;
+ *res=z80->IFF1;
else if (StrEq(p,"IFF2"))
- *res=s.IFF2;
+ *res=z80->IFF2;
else if (p[0]=='@')
{
Z80Word n;
@@ -709,20 +708,14 @@ static void DoStep(int no, const char *arg[])
static void DoSetPC(int no, const char *arg[])
{
- Z80State s;
-
- Z80GetState(z80,&s);
-
if (no<2)
{
- s.PC=MK(Z80_MEMORY[s.SP+1],Z80_MEMORY[s.SP]);
- s.SP+=2;
+ z80->PC=MK(Z80_MEMORY[z80->SP+1],Z80_MEMORY[z80->SP]);
+ z80->SP+=2;
DisplayState();
}
else
- s.PC=Address(arg[1]);
-
- Z80SetState(z80,&s);
+ z80->PC=Address(arg[1]);
}
@@ -730,11 +723,7 @@ static void DoRun(int no, const char *arg[])
{
if (no>1)
{
- Z80State s;
-
- Z80GetState(z80,&s);
- s.PC=Address(arg[1]);
- Z80SetState(z80,&s);
+ z80->PC=Address(arg[1]);
}
while(!stop)
@@ -766,11 +755,7 @@ static void DoUntil(int no, const char *arg[])
if (no>2)
{
- Z80State s;
-
- Z80GetState(z80,&s);
- s.PC=Address(arg[2]);
- Z80SetState(z80,&s);
+ z80->PC=Address(arg[2]);
}
while(!stop)
@@ -976,12 +961,9 @@ static Z80Byte ReadPort(Z80 *z80, Z80Word addr)
{
Z80Byte b=0xff;
Z80Word ptr;
- Z80State s;
char expr[1024];
char *p;
- Z80GetState(z80,&s);
-
switch(addr&0xff)
{
case 0x80:
@@ -1001,7 +983,7 @@ static Z80Byte ReadPort(Z80 *z80, Z80Word addr)
break;
case 0x81:
- ptr=s.DE;
+ ptr=z80->DE.w;
p=expr;
@@ -1025,9 +1007,9 @@ static Z80Byte ReadPort(Z80 *z80, Z80Word addr)
static void WritePort(Z80 *z80, Z80Word addr, Z80Byte val)
{
- Z80State s;
+ Z80Word de;
- Z80GetState(z80,&s);
+ de=z80->DE.w;
switch(addr&0xff)
{
@@ -1042,21 +1024,22 @@ static void WritePort(Z80 *z80, Z80Word addr, Z80Byte val)
break;
case 0x82:
- while(Z80_MEMORY[s.DE]!='$')
+ while(Z80_MEMORY[de]!='$')
{
- if (isspace(Z80_MEMORY[s.DE]) || isprint(Z80_MEMORY[s.DE]))
- Log("%c",Z80_MEMORY[s.DE]);
+ if (isspace(Z80_MEMORY[de]) ||
+ isprint(Z80_MEMORY[de]))
+ Log("%c",Z80_MEMORY[de]);
- s.DE++;
+ de++;
}
fflush(stdout);
break;
case 0x83:
- while(Z80_MEMORY[s.DE])
+ while(Z80_MEMORY[de])
{
- Log("%c",Z80_MEMORY[s.DE]);
- s.DE++;
+ Log("%c",Z80_MEMORY[de]);
+ de++;
}
fflush(stdout);
break;