diff options
author | Ian C <ianc@noddybox.co.uk> | 2020-03-19 22:51:10 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2020-03-19 22:51:10 +0000 |
commit | 5106ea51907aa9f6a15070041fefd820671cc4ed (patch) | |
tree | dda3e6bc91586ff42cc92a5101efe8327ed1899a /src | |
parent | 4e244ffab7a7bb44e4b535b0a290c99ecce3a3c2 (diff) |
First attempt at display routine. Still keyboard handling to do.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 7 | ||||
-rw-r--r-- | src/czx81.c | 76 |
2 files changed, 81 insertions, 2 deletions
diff --git a/src/Makefile b/src/Makefile index 8deb3e5..9fc766e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -21,6 +21,9 @@ TARGET=czx81 # ncursesw CURSES=-lncurses +# For debug build +#CFLAGS+=-g + OBJS= czx81.o \ z80.o \ z80_decode.o \ @@ -29,12 +32,12 @@ OBJS= czx81.o \ zx81rom.o $(TARGET): $(OBJS) - $(CC) -o $(TARGET) $(OBJS) $(CURSES) + $(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(CURSES) clean: rm -f $(TARGET) $(OBJS) core -czx81.o: czx81.c wide_curses.h +czx81.o: czx81.c wide_curses.h z80.h z80_config.h zx81rom.h stream.o: stream.c stream.h z80.o: z80.c z80.h z80_config.h z80_private.h stream.h z80_decode.o: z80_decode.c z80.h z80_config.h z80_private.h diff --git a/src/czx81.c b/src/czx81.c index 6ba48a8..1e50c5c 100644 --- a/src/czx81.c +++ b/src/czx81.c @@ -83,6 +83,26 @@ static Z80 *z80; static Z80Byte matrix[8]; +static wchar_t scrcode[0x40] = +{ + L' ', L'\u2598', L'\u259d', L'\u2580', /* 00 - 03 */ + L'\u2596', L'\u258c', L'\u259e', L'\u259b', /* 04 - 07 */ + L'\u2592', L'\u2584', L'\u2580', L'"', /* 08 - 0b */ + L'\u00a3', L'$', L':', L'?', /* 0c - 0f */ + L'(', L')', L'>', L'<', /* 10 - 13 */ + L'=', L'+', L'-', L'*', /* 14 - 17 */ + L'/', L';', L',', L'.', /* 18 - 1b */ + L'0', L'1', L'2', L'3', /* 1c - 1f */ + L'4', L'5', L'6', L'7', /* 20 - 23 */ + L'8', L'9', L'A', L'B', /* 24 - 27 */ + L'C', L'D', L'E', L'F', /* 28 - 2b */ + L'G', L'H', L'I', L'J', /* 2c - 2f */ + L'K', L'L', L'M', L'N', /* 30 - 33 */ + L'O', L'P', L'Q', L'R', /* 34 - 37 */ + L'S', L'T', L'U', L'V', /* 38 - 3b */ + L'W', L'X', L'Y', L'Z', /* 3c - 3f */ +}; + /* -------------------------------------------------- ZX81 CODE */ @@ -420,6 +440,60 @@ static void ZX81Init(void) } +static void DrawScreen(void) +{ + int fast; + int x,y; + + fast = (FRAME_TSTATES == FAST_TSTATES); + + if (fast) + { + for(y = 0; y < TXT_H; y++) + { + for(x = 0; x < TXT_W; x++) + { + mvprintw(y, x, "%lc", L'\u2592'); + } + } + } + else + { + Z80Byte *scr; + + scr = mem + PEEKW(DFILE); + y = 0; + + while(y < TXT_H) + { + scr++; + x = 0; + + while(*scr != 118 && x < TXT_W) + { + Z80Byte ch = *scr++; + + if (ch & 0x80) + { + attron(A_REVERSE); + } + + mvprintw(y, x, "%lc", scrcode[ch & 0x3f]); + + if (ch & 0x80) + { + attroff(A_REVERSE); + } + + x++; + } + + y++; + } + } +} + + /* -------------------------------------------------- UTILS */ static long TimeDiff(const struct timespec *start, @@ -475,6 +549,8 @@ int main(void) clear(); + DrawScreen(); + ch = getch(); if (ch == 3) |