summaryrefslogtreecommitdiff
path: root/emma.c
diff options
context:
space:
mode:
Diffstat (limited to 'emma.c')
-rw-r--r--emma.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/emma.c b/emma.c
index 8737d87..b38a3ee 100644
--- a/emma.c
+++ b/emma.c
@@ -50,7 +50,6 @@ static const char id[]="$Id$";
*/
static Z80 *z80;
static Z80Byte mem[0x10000];
-static int memctl[256];
static sig_atomic_t stop=FALSE;
static int quit=FALSE;
@@ -86,6 +85,39 @@ static void SigInt(int sig)
}
+/* ---------------------------------------- MEMORY
+*/
+static Z80Byte Peek(Z80 *cpu, Z80Word addr)
+{
+ if (mem_trace)
+ {
+ Log("Read %2.2x from %4.4x\n",mem[addr],addr);
+ }
+
+ return mem[addr];
+}
+
+
+static Z80Byte DisPeek(Z80 *cpu, Z80Word addr)
+{
+ return mem[addr];
+}
+
+
+static void Poke(Z80 *cpu, Z80Word addr, Z80Byte b)
+{
+ if (addr>=bottom && addr<=top)
+ {
+ if (mem_trace)
+ {
+ Log("Wrote %2.2x to %4.4x\n",b,addr);
+ }
+
+ mem[addr]=b;
+ }
+}
+
+
/* ---------------------------------------- COMMANDS AND ASSOC UTILS
*/
static void Log(const char *format, ...)
@@ -783,8 +815,6 @@ static void DoSilent(int no, const char *arg[])
static void DoRange(int no, const char *arg[])
{
- int f;
-
if (no<3)
{
Log("Missing arguments\n");
@@ -794,11 +824,6 @@ static void DoRange(int no, const char *arg[])
bottom=(Address(arg[1]))/256;
top=Address(arg[2])/256;
- for(f=0;f<256;f++)
- {
- memctl[f]=(f>=bottom && f<=top);
- }
-
Log("Writable memory between 0x%4.4x and 0x%4.4x\n",bottom*256,top*256);
}
@@ -1083,11 +1108,8 @@ static int IntCheck(Z80 *z80, Z80Val v)
int main(int argc, char *argv[])
{
const char *autoarg[2]={".","auto"};
- int f;
-
- for(f=0;f<256;f++) memctl[f]=1;
- z80=Z80Init(mem,memctl,WritePort,ReadPort);
+ z80=Z80Init(Peek,Poke,ReadPort,WritePort,DisPeek);
if (!z80)
{