From 0d08766ccc80cacfe0690cb8a1ea8f13038e404b Mon Sep 17 00:00:00 2001 From: Ian C Date: Tue, 3 Aug 2021 21:43:06 +0000 Subject: Sped up Z80 emulation --- source/spec.c | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) (limited to 'source/spec.c') diff --git a/source/spec.c b/source/spec.c index ef132d4..1a5eba2 100644 --- a/source/spec.c +++ b/source/spec.c @@ -78,9 +78,9 @@ #define OFF_X ((GFX_W-SCR_W)/2) #define OFF_Y ((GFX_H-SCR_H)/2) -#define ATTR_AT(x,y) mem[ATTR+(x)+((y)/8)*32] +#define ATTR_AT(x,y) Z80_MEMORY[ATTR+(x)+((y)/8)*32] -Z80Byte mem[0x10000]; +Z80Byte Z80_MEMORY[0x10000]; static int border; static int scanline; @@ -189,12 +189,12 @@ static void RomPatch(void) for(f=0;save[f]!=0xff;f++) { - mem[ROM_SAVE+f]=save[f]; + Z80_MEMORY[ROM_SAVE+f]=save[f]; } for(f=0;load[f]!=0xff;f++) { - mem[ROM_LOAD+f]=load[f]; + Z80_MEMORY[ROM_LOAD+f]=load[f]; } } @@ -337,21 +337,21 @@ static int EDCallback(Z80 *z80, Z80Val data) switch((Z80Byte)data) { case ED_SAVE: - z80->AF.b[Z80_LO_WORD] &= ~eZ80_Carry; + z80->AF.b.lo &= ~eZ80_Carry; break; case ED_LOAD: - if (TAPLoad(z80->AF.b[Z80_HI_WORD], + if (TAPLoad(z80->AF.b.hi, &z80->IX.w, &z80->DE.w, SPECWriteMemSNAP)) { - z80->AF.b[Z80_LO_WORD] |= eZ80_Carry; + z80->AF.b.lo |= eZ80_Carry; z80->BC.w=0xb001; } else { - z80->AF.b[Z80_LO_WORD] &= ~eZ80_Carry; + z80->AF.b.lo &= ~eZ80_Carry; z80->BC.w = 0xff01; } break; @@ -379,7 +379,7 @@ void SPECInit(Z80 *z80) /* Load the ROM */ - memcpy(mem,spec48_bin,ROMLEN); + memcpy(Z80_MEMORY,spec48_bin,ROMLEN); /* Patch the ROM */ @@ -429,26 +429,11 @@ void SPECHandleKey(SoftKey key, int is_pressed) } -Z80Byte SPECReadMem(Z80 *z80, Z80Word addr) -{ - return mem[addr]; -} - - -void SPECWriteMem(Z80 *z80, Z80Word addr, Z80Byte val) -{ - if (addr>=ROMLEN) - { - mem[addr]=val; - } -} - - void SPECWriteMemSNAP(Z80Word addr, Z80Byte val) { if (addr>=ROMLEN) { - mem[addr]=val; + Z80_MEMORY[addr]=val; } } @@ -538,7 +523,7 @@ void SPECReset(Z80 *z80) r=0; for(f=0;f