From 61b364c3dfeb99579304d83273c06846ed2e75f8 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sat, 16 Sep 2006 00:41:11 +0000 Subject: Added a config header that controls inclusion of disassembly and memory model. --- gemma.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'gemma.c') diff --git a/gemma.c b/gemma.c index 1074860..c0fcf43 100644 --- a/gemma.c +++ b/gemma.c @@ -41,7 +41,7 @@ static const char id[]="$Id$"; /* ---------------------------------------- GLOBALS */ static Z80 *z80; -static Z80Byte mem[0x10000]; +Z80Byte Z80_MEMORY[0x10000]; static sig_atomic_t stop=FALSE; @@ -271,14 +271,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 */ { @@ -412,15 +412,17 @@ static void DisplayState(DString s, const char *label, /* ---------------------------------------- MEMORY */ +#ifndef ENABLE_ARRAY_MEMORY static Z80Byte Peek(Z80 *z80, Z80Word addr) { - return mem[addr]; + return Z80_MEMORY[addr]; } static void Poke(Z80 *z80, Z80Word addr, Z80Byte b) { - mem[addr]=b; + Z80_MEMORY[addr]=b; } +#endif static Z80Byte ReadPort(Z80 *z80, Z80Word addr) { @@ -435,12 +437,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; @@ -455,8 +457,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; @@ -493,11 +495,11 @@ 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])) + if (isspace(Z80_MEMORY[s.DE]) || isprint(Z80_MEMORY[s.DE])) { - DSAddChar(ds,mem[s.DE]); + DSAddChar(ds,Z80_MEMORY[s.DE]); } s.DE++; @@ -505,9 +507,9 @@ static void WritePort(Z80 *z80, Z80Word addr, Z80Byte val) break; case 0x83: - while(mem[s.DE]) + while(Z80_MEMORY[s.DE]) { - DSAddChar(ds,mem[s.DE]); + DSAddChar(ds,Z80_MEMORY[s.DE]); s.DE++; } break; @@ -719,7 +721,7 @@ void GEMMA_UpdateDisplay(GEMMA_View view) { gchar *p; p=g_markup_printf_escaped - ("%c",isprint(mem[addr+off]) ? mem[addr+off] : '.'); + ("%c",isprint(Z80_MEMORY[addr+off]) ? Z80_MEMORY[addr+off] : '.'); DSAdd(asc,p); g_free(p); } @@ -738,11 +740,11 @@ void GEMMA_UpdateDisplay(GEMMA_View view) if (as_words) { - sprintf(buff,"%4.4X ",MK(mem[a+1],mem[a])); + sprintf(buff,"%4.4X ",MK(Z80_MEMORY[a+1],Z80_MEMORY[a])); } else { - sprintf(buff,"%2.2X ",mem[a]); + sprintf(buff,"%2.2X ",Z80_MEMORY[a]); } DSAdd(ds,buff); @@ -821,7 +823,7 @@ void GEMMA_LoadHEX(const char *path) Z80Byte b; b=ToHex(buff[f*2+9])<<4|ToHex(buff[f*2+10]); - mem[addr++]=b; + Z80_MEMORY[addr++]=b; } } } @@ -979,7 +981,11 @@ void GEMMA_Stop(void) void GEMMA_Init(GtkWidget *top) { +#ifdef ENABLE_ARRAY_MEMORY + z80=Z80Init(ReadPort,WritePort); +#else z80=Z80Init(Peek,Poke,ReadPort,WritePort,Peek); +#endif Z80SetPC(z80,0x100); if (!z80) -- cgit v1.2.3