From 3557796008941acab4f047f6818ff2b98951faf9 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sat, 13 Dec 2008 00:06:35 +0000 Subject: Rather than checking every memory access to return RET for ULA reads, preload the memory array. --- source/zx81.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/source/zx81.c b/source/zx81.c index b8143cd..fb6f801 100644 --- a/source/zx81.c +++ b/source/zx81.c @@ -887,11 +887,27 @@ void ZX81Init(uint16 *text_vram, uint16* bitmap_vram, Z80 *z80) RAMBOT=0x4000; RAMTOP=RAMBOT+0x4000; - for(f=RAMBOT;f<=RAMTOP;f++) - mem[f]=0; + for(f = RAMBOT; f <= RAMTOP; f++) + { + mem[f] = 0; + } + + for(f = 0; f < 8; f++) + { + matrix[f] = 0x1f; + } + + /* Fill the upper 32K with RET opcodes -- hopefully by simply returning + RET for ULA reads we save a lot of ROM patching shenanigans. + + Note that this check used to be in ZX81ReadMem, but obviously this + should cut down on a *lot* of pointless expression evaluation! + */ + for(f = 0x8000; f <= RAMTOP; f++) + { + mem[f] = 0xc9; + } - for(f=0;f<8;f++) - matrix[f]=0x1f; } @@ -917,17 +933,7 @@ void ZX81HandleKey(SoftKey key, int is_pressed) Z80Byte ZX81ReadMem(Z80 *z80, Z80Word addr) { - /* Hopefully by simply returning RET for ULA reads we save a lot of - ROM patching shenanigans. - */ - if (addr>0x7fff) - { - return 0xc9; - } - else - { - return mem[addr]; - } + return mem[addr]; } -- cgit v1.2.3