diff options
author | Ian C <ianc@noddybox.co.uk> | 2006-09-06 23:35:58 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2006-09-06 23:35:58 +0000 |
commit | 3e2e62d3966f4620674e51a424c7c2e734e05235 (patch) | |
tree | d32da044922666a28cf5b587b1493324b7c14525 /emma.c | |
parent | 3261fd65167abc52aefa288ac71a1dc14b82ad16 (diff) |
Updated to use a function-based memory interface.
Diffstat (limited to 'emma.c')
-rw-r--r-- | emma.c | 46 |
1 files changed, 34 insertions, 12 deletions
@@ -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) { |