summaryrefslogtreecommitdiff
path: root/emma.c
diff options
context:
space:
mode:
Diffstat (limited to 'emma.c')
-rw-r--r--emma.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/emma.c b/emma.c
index b38a3ee..89a70de 100644
--- a/emma.c
+++ b/emma.c
@@ -49,7 +49,7 @@ static const char id[]="$Id$";
/* ---------------------------------------- GLOBALS
*/
static Z80 *z80;
-static Z80Byte mem[0x10000];
+Z80Byte Z80_MEMORY[0x10000];
static sig_atomic_t stop=FALSE;
static int quit=FALSE;
@@ -87,20 +87,21 @@ static void SigInt(int sig)
/* ---------------------------------------- MEMORY
*/
+#ifndef ENABLE_ARRAY_MEMORY
static Z80Byte Peek(Z80 *cpu, Z80Word addr)
{
if (mem_trace)
{
- Log("Read %2.2x from %4.4x\n",mem[addr],addr);
+ Log("Read %2.2x from %4.4x\n",Z80_MEMORY[addr],addr);
}
- return mem[addr];
+ return Z80_MEMORY[addr];
}
static Z80Byte DisPeek(Z80 *cpu, Z80Word addr)
{
- return mem[addr];
+ return Z80_MEMORY[addr];
}
@@ -113,9 +114,10 @@ static void Poke(Z80 *cpu, Z80Word addr, Z80Byte b)
Log("Wrote %2.2x to %4.4x\n",b,addr);
}
- mem[addr]=b;
+ Z80_MEMORY[addr]=b;
}
}
+#endif
/* ---------------------------------------- COMMANDS AND ASSOC UTILS
@@ -310,14 +312,14 @@ static int Expand(void *client, const char *p, long *res)
Z80Word n;
n=Address(p+1);
- *res=mem[n];
+ *res=Z80_MEMORY[n];
}
else if (p[0]=='#')
{
Z80Word n;
n=Address(p+1);
- *res=MK(mem[n+1],mem[n]);
+ *res=MK(Z80_MEMORY[n+1],Z80_MEMORY[n]);
}
else /* Check for labels */
{
@@ -470,7 +472,7 @@ static void DoLoad(int no, const char *arg[])
while((c=getc(fp))!=EOF)
{
- mem[addr++]=(Z80Byte)c;
+ Z80_MEMORY[addr++]=(Z80Byte)c;
total++;
}
@@ -536,7 +538,7 @@ static void DoIntel(int no, const char *arg[])
Z80Byte b;
b=ToHex(buff[f*2+9])<<4|ToHex(buff[f*2+10]);
- mem[addr++]=b;
+ Z80_MEMORY[addr++]=b;
}
}
}
@@ -604,10 +606,10 @@ static void DoDump(int no, const char *arg[])
if ((count%8)==0)
Log("0x%4.4x: ",addr);
- Log(" 0x%2.2x",mem[addr]);
+ Log(" 0x%2.2x",Z80_MEMORY[addr]);
- if (isprint(mem[addr]))
- asc[count%8]=mem[addr];
+ if (isprint(Z80_MEMORY[addr]))
+ asc[count%8]=Z80_MEMORY[addr];
else
asc[count%8]='.';
@@ -713,7 +715,7 @@ static void DoSetPC(int no, const char *arg[])
if (no<2)
{
- s.PC=MK(mem[s.SP+1],mem[s.SP]);
+ s.PC=MK(Z80_MEMORY[s.SP+1],Z80_MEMORY[s.SP]);
s.SP+=2;
DisplayState();
}
@@ -983,12 +985,12 @@ static Z80Byte ReadPort(Z80 *z80, Z80Word addr)
switch(addr&0xff)
{
case 0x80:
- ptr=MK(mem[1],mem[0]);
+ ptr=MK(Z80_MEMORY[1],Z80_MEMORY[0]);
p=expr;
- while(mem[ptr])
- *p++=mem[ptr++];
+ while(Z80_MEMORY[ptr])
+ *p++=Z80_MEMORY[ptr++];
*p=0;
@@ -1003,8 +1005,8 @@ static Z80Byte ReadPort(Z80 *z80, Z80Word addr)
p=expr;
- while(mem[ptr])
- *p++=mem[ptr++];
+ while(Z80_MEMORY[ptr])
+ *p++=Z80_MEMORY[ptr++];
*p=0;
@@ -1040,10 +1042,10 @@ static void WritePort(Z80 *z80, Z80Word addr, Z80Byte val)
break;
case 0x82:
- while(mem[s.DE]!='$')
+ while(Z80_MEMORY[s.DE]!='$')
{
- if (isspace(mem[s.DE]) || isprint(mem[s.DE]))
- Log("%c",mem[s.DE]);
+ if (isspace(Z80_MEMORY[s.DE]) || isprint(Z80_MEMORY[s.DE]))
+ Log("%c",Z80_MEMORY[s.DE]);
s.DE++;
}
@@ -1051,9 +1053,9 @@ static void WritePort(Z80 *z80, Z80Word addr, Z80Byte val)
break;
case 0x83:
- while(mem[s.DE])
+ while(Z80_MEMORY[s.DE])
{
- Log("%c",mem[s.DE]);
+ Log("%c",Z80_MEMORY[s.DE]);
s.DE++;
}
fflush(stdout);
@@ -1109,7 +1111,11 @@ int main(int argc, char *argv[])
{
const char *autoarg[2]={".","auto"};
+#ifndef ENABLE_ARRAY_MEMORY
z80=Z80Init(Peek,Poke,ReadPort,WritePort,DisPeek);
+#else
+ z80=Z80Init(ReadPort,WritePort);
+#endif
if (!z80)
{