summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2007-02-16 18:06:39 +0000
committerIan C <ianc@noddybox.co.uk>2007-02-16 18:06:39 +0000
commit72bba5ee6e4742bf27cfc09c5c41ca9646b419d6 (patch)
tree1837498995180e09a3b12d6d74c9215961cd429f /source
parentb369f37c6244b5d56742b56f745219fb2544efe2 (diff)
Improved hi-res performance
Diffstat (limited to 'source')
-rw-r--r--source/zx81.c80
1 files changed, 76 insertions, 4 deletions
diff --git a/source/zx81.c b/source/zx81.c
index 7964ed1..81cfd55 100644
--- a/source/zx81.c
+++ b/source/zx81.c
@@ -19,7 +19,7 @@
-------------------------------------------------------------------------
- Provides the emulation for the zX81
+ Provides the emulation for the ZX81
*/
#include <stdlib.h>
@@ -82,6 +82,8 @@ static int last_I;
static Z80Byte mem[0x10000];
+static Z80Byte scr_mirror[7000];
+
static Z80Word RAMBOT=0;
static Z80Word RAMTOP=0;
static Z80Word RAMLEN=0;
@@ -366,14 +368,80 @@ static void ClearText(void)
}
-static void DrawScreen_HIRES(Z80 *z80)
+static void DrawScreen_HIRES_Dirty(Z80 *z80)
+{
+ uint16 *bmp;
+ Z80Byte *scr;
+ Z80Byte *mirror;
+ int x,y;
+ int table;
+ int c;
+ int v;
+ int b;
+
+ scr = mem + hires_dfile;
+ mirror = scr_mirror;
+ bmp = bmp_screen;
+ table = z80->I << 8;
+
+ /* scr is increment in both loops so that it can skip the end-of-line
+ character
+ */
+ for(y=0; y<192; y++)
+ {
+ for(x=0; x<32; x++)
+ {
+ c = *scr;
+
+ if (c != *mirror)
+ {
+ *mirror++ = c;
+
+ v = mem[table + (c&0x3f)*8];
+
+ if (c & 0x80)
+ {
+ v ^= 0xff;
+ }
+
+ for(b=0;b<8;b++)
+ {
+ if (v & 0x80)
+ {
+ *bmp++ = 0x8000;
+ }
+ else
+ {
+ *bmp++ = 0xffff;
+ }
+
+ v=v<<1;
+ }
+ }
+ else
+ {
+ mirror++;
+ bmp+=8;
+ }
+
+ scr++;
+ }
+
+ scr++;
+ }
+}
+
+
+static void DrawScreen_HIRES_Full(Z80 *z80)
{
uint16 *bmp;
Z80Byte *scr;
+ Z80Byte *mirror;
int x,y;
int table;
scr = mem + hires_dfile;
+ mirror = scr_mirror;
bmp = bmp_screen;
table = z80->I << 8;
@@ -388,7 +456,7 @@ static void DrawScreen_HIRES(Z80 *z80)
int v;
int b;
- c = *scr;
+ c = *mirror++ = *scr;
v = mem[table + (c&0x3f)*8];
@@ -416,8 +484,11 @@ static void DrawScreen_HIRES(Z80 *z80)
scr++;
}
+
+ DrawScreen = DrawScreen_HIRES_Dirty;
}
+
static void DrawScreen_TEXT(Z80 *z80)
{
Z80Byte *scr=mem+WORD(DFILE);
@@ -617,7 +688,8 @@ static int CheckTimers(Z80 *z80, Z80Val val)
else
{
hires = TRUE;
- DrawScreen = DrawScreen_HIRES;
+ DrawScreen = DrawScreen_HIRES_Full;
+ ClearBitmap();
ClearText();
FindHiresDFILE();
}