diff options
Diffstat (limited to 'source/zx81.c')
-rw-r--r-- | source/zx81.c | 161 |
1 files changed, 158 insertions, 3 deletions
diff --git a/source/zx81.c b/source/zx81.c index b2d85b1..1335d0b 100644 --- a/source/zx81.c +++ b/source/zx81.c @@ -29,6 +29,7 @@ #include "zx81.h" #include "gui.h" +#include "framebuffer.h" #include "stream.h" @@ -655,10 +656,164 @@ void ZX81Init(Z80 *z80) } -void ZX81RenderDisplay(Framebuffer *fb) +void ZX81RenderDisplay(Framebuffer *fb, Z80 *z80) { - FB_Clear(fb, COL_BLACK); - FB_Centre(fb, "TODO", 10, COL_WHITE, COL_TRANSPARENT); + u16 black; + u16 white; + + black = FB_GetColour(COL_BLACK); + white = FB_GetColour(COL_WHITE); + + if (fast_mode) + { + u16 x; + u16 y; + + for(x = 0; x < fb->width; x++) + { + for(y = 0; y < fb->height; y++) + { + FB_ADDR(fb, x, y) = ((x+y) % 2) ? black : white; + } + } + } + else if (hires) + { + int x; + int y; + Z80Byte *dfile; + + FB_Clear(fb, COL_WHITE); + + dfile = mem + WORD(DFILE); + + dfile++; + + for(y = 0; y < SCR_H; y++) + { + for(x = 0; x < TXT_W; x++) + { + int ch = *dfile++; + int px; + uint pen; + uint paper; + int data; + + if (ch == 118) + { + break; + } + + if (ch & 0x80) + { + pen = white; + paper = black; + ch -= 0x80; + } + else + { + pen = black; + paper = white; + } + + data = mem[z80->I * 256 + ch * 8]; + + for(px = 0; px < 8; px++) + { + if (data & 0x80) + { + FB_ADDR(fb, + x * 8 + px + 72, + fb->height - 24 - y) = pen; + } + else + { + FB_ADDR(fb, + x * 8 + px + 72, + fb->height - 24 - y) = paper; + } + + data = data<<1; + } + } + + if (*dfile == 118) + { + dfile++; + } + } + } + else + { + int x; + int y; + Z80Byte *dfile; + + FB_Clear(fb, COL_WHITE); + + dfile = mem + WORD(DFILE); + + dfile++; + + for(y = 0; y < TXT_H; y++) + { + for(x = 0; x < TXT_W; x++) + { + int ch = *dfile++; + int px; + int py; + uint pen; + uint paper; + + if (ch == 118) + { + break; + } + + if (ch & 0x80) + { + pen = white; + paper = black; + ch -= 0x80; + } + else + { + pen = black; + paper = white; + } + + for(py = 0; py < 8; py++) + { + int data; + + data = mem[z80->I * 256 + ch * 8 + py]; + + for(px = 0; px < 8; px++) + { + if (data & 0x80) + { + FB_ADDR(fb, + x * 8 + px + 72, + fb->height - 24 - y * 8 - py) = pen; + } + else + { + FB_ADDR(fb, + x * 8 + px + 72, + fb->height - 24 - y * 8 - py) = paper; + } + + data = data<<1; + } + } + } + + if (*dfile == 118) + { + dfile++; + } + } + } } |