From b28946431766602e42cce84bb8fcf5b0dbbc6553 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 8 Sep 2018 00:43:53 +0100 Subject: [PATCH] plato: more fixes and split the 'tgi' code into it's own file. In theory it's just a case of writing a tgi lib (probably best in asm) for the various formats we need to deal with. --- Applications/plato/Makefile.6502 | 6 +-- Applications/plato/Makefile.68000 | 6 +-- Applications/plato/Makefile.6809 | 6 +-- Applications/plato/Makefile.z80 | 2 +- Applications/plato/plato.c | 4 +- Applications/plato/screen_base.c | 69 +---------------------------- Applications/plato/tgi.h | 12 ++++++ Applications/plato/tgi_ascii.c | 72 +++++++++++++++++++++++++++++++ 8 files changed, 98 insertions(+), 79 deletions(-) create mode 100644 Applications/plato/tgi.h create mode 100644 Applications/plato/tgi_ascii.c diff --git a/Applications/plato/Makefile.6502 b/Applications/plato/Makefile.6502 index cf15c99d..f13b2e67 100644 --- a/Applications/plato/Makefile.6502 +++ b/Applications/plato/Makefile.6502 @@ -10,10 +10,10 @@ CRT0NS = ../../Library/libs/crt0nostdio_6502.o .SUFFIXES: .c .o SRCS = io_base.c keyboard_base.c plato.c protocol.c screen_base.c terminal.c \ - touch_base.c + touch_base.c tgi_ascii.c -FSRCS = font.c io.c keyboard.c scale.c screen.c splash.c \ - terminal_char_load.c touch.c +FSRCS = fuzix/font.c fuzix/io.c fuzix/keyboard.c fuzix/scale.c fuzix/screen.c \ + fuzix/splash.c fuzix/terminal_char_load.c fuzix/touch.c INC = io.h keyboard.h plato_key.h protocol.h screen.h terminal.h touch.h diff --git a/Applications/plato/Makefile.68000 b/Applications/plato/Makefile.68000 index 6e34e76a..b70af166 100644 --- a/Applications/plato/Makefile.68000 +++ b/Applications/plato/Makefile.68000 @@ -15,10 +15,10 @@ ELF2FUZIX = elf2flt .SUFFIXES: .c .o SRCS = io_base.c keyboard_base.c plato.c protocol.c screen_base.c terminal.c \ - touch_base.c + touch_base.c tgi_ascii.c -FSRCS = font.c io.c keyboard.c scale.c screen.c splash.c \ - terminal_char_load.c touch.c +FSRCS = fuzix/font.c fuzix/io.c fuzix/keyboard.c fuzix/scale.c fuzix/screen.c \ + fuzix/splash.c fuzix/terminal_char_load.c fuzix/touch.c INC = io.h keyboard.h plato_key.h protocol.h screen.h terminal.h touch.h diff --git a/Applications/plato/Makefile.6809 b/Applications/plato/Makefile.6809 index 28e54123..c22c7bac 100644 --- a/Applications/plato/Makefile.6809 +++ b/Applications/plato/Makefile.6809 @@ -15,10 +15,10 @@ ASM_OPT = -o .SUFFIXES: .c .o SRCS = io_base.c keyboard_base.c plato.c protocol.c screen_base.c terminal.c \ - touch_base.c + touch_base.c tgi_ascii.c -FSRCS = font.c io.c keyboard.c scale.c screen.c splash.c \ - terminal_char_load.c touch.c +FSRCS = fuzix/font.c fuzix/io.c fuzix/keyboard.c fuzix/scale.c fuzix/screen.c \ + fuzix/splash.c fuzix/terminal_char_load.c fuzix/touch.c INC = io.h keyboard.h plato_key.h protocol.h screen.h terminal.h touch.h diff --git a/Applications/plato/Makefile.z80 b/Applications/plato/Makefile.z80 index dd2d980a..9488441b 100644 --- a/Applications/plato/Makefile.z80 +++ b/Applications/plato/Makefile.z80 @@ -4,7 +4,7 @@ CC = fcc -m$(USERCPU) $(Z80_PLATFORM) COPT = $(FUZIX_CCOPTS) SRCS = io_base.c keyboard_base.c plato.c protocol.c screen_base.c terminal.c \ - touch_base.c + touch_base.c tgi_ascii.c FSRCS = fuzix/font.c fuzix/io.c fuzix/keyboard.c fuzix/scale.c fuzix/screen.c \ fuzix/splash.c fuzix/terminal_char_load.c fuzix/touch.c diff --git a/Applications/plato/plato.c b/Applications/plato/plato.c index 83f90d22..4b396a2d 100644 --- a/Applications/plato/plato.c +++ b/Applications/plato/plato.c @@ -18,6 +18,8 @@ uint8_t already_started=false; extern padByte splash[]; extern short splash_size; +extern int io_eof; + /** * greeting(void) - Show terminal greeting */ @@ -39,7 +41,7 @@ void main(void) already_started=true; // And do the terminal - for (;;) + while (!io_eof) { io_main(); keyboard_main(); diff --git a/Applications/plato/screen_base.c b/Applications/plato/screen_base.c index 3fb6f8d6..eb05867b 100644 --- a/Applications/plato/screen_base.c +++ b/Applications/plato/screen_base.c @@ -11,6 +11,7 @@ #include #include #include +#include "tgi.h" #include "screen.h" #include "protocol.h" #include "io.h" @@ -31,74 +32,6 @@ extern uint16_t fontptr[]; extern uint8_t FONT_SIZE_X; extern uint8_t FONT_SIZE_Y; -/* - * Silly functions to get us going - */ - -static uint8_t pen; - -static void tgi_init(void) -{ -} - -static void tgi_done(void) -{ -} - -static void tgi_setpalette(const unsigned char *palette) -{ -} - -static void tgi_clear(void) -{ -// printf("[CLR]"); - printf("\033[0;0H\033[J"); - fflush(stdout); -} - -static void tgi_setcolor(unsigned char c) -{ - pen = c; -} - -static void tgi_setpixel(int x, int y) -{ - printf("\033[%d;%dH%c", y, x, " #"[pen]); -// printf("[%d,%d->%d]", x, y, pen); -} - -static void tgi_bar(int x1, int y1, int x2, int y2) -{ - int x,y; - for (y = y1; y < y2; y++) { - printf("\033[%d;%dH", y, x1); - if (pen) - for(x = x1; x < x2; x++) - putchar('#'); - else - for(x = x1; x < x2; x++) - putchar(' '); - } -// printf("[R %d,%d,%d,%d->%d]", x1, y1, x2,y2, pen); -} - -static void tgi_line(int x1, int y1, int x2, int y2) -{ - int dx = abs(x2-x1), sx = x1= dy) { err += dy; x1 += sx; } /* e_xy+e_x > 0 */ - if (e2 <= dx) { err += dx; y1 += sy; } /* e_xy+e_y < 0 */ - } - -// printf("[L %d,%d,%d,%d->%d]", x1, y1, x2,y2, pen); -} - /** * screen_init() - Set up the screen */ diff --git a/Applications/plato/tgi.h b/Applications/plato/tgi.h new file mode 100644 index 00000000..e4561a2e --- /dev/null +++ b/Applications/plato/tgi.h @@ -0,0 +1,12 @@ +/* + * A small subset of the CC65 tgi API + */ + +extern void tgi_init(void); +extern void tgi_done(void); +extern void tgi_setpalette(const unsigned char *palette); +extern void tgi_clear(void); +extern void tgi_setcolor(unsigned char c); +extern void tgi_setpixel(int x, int y); +extern void tgi_bar(int x1, int y1, int x2, int y2); +extern void tgi_line(int x1, int y1, int x2, int y2); diff --git a/Applications/plato/tgi_ascii.c b/Applications/plato/tgi_ascii.c new file mode 100644 index 00000000..3c233388 --- /dev/null +++ b/Applications/plato/tgi_ascii.c @@ -0,0 +1,72 @@ +#include +#include +#include +#include "tgi.h" + +/* + * Silly functions to get us going + */ + +static uint8_t pen; + +void tgi_init(void) +{ +} + +void tgi_done(void) +{ +} + +void tgi_setpalette(const unsigned char *palette) +{ +} + +void tgi_clear(void) +{ +// printf("[CLR]"); + printf("\033[0;0H\033[J"); + fflush(stdout); +} + +void tgi_setcolor(unsigned char c) +{ + pen = c; +} + +void tgi_setpixel(int x, int y) +{ + printf("\033[%d;%dH%c", y, x, " #"[pen]); +// printf("[%d,%d->%d]", x, y, pen); +} + +void tgi_bar(int x1, int y1, int x2, int y2) +{ + int x,y; + for (y = y1; y < y2; y++) { + printf("\033[%d;%dH", y, x1); + if (pen) + for(x = x1; x < x2; x++) + putchar('#'); + else + for(x = x1; x < x2; x++) + putchar(' '); + } +// printf("[R %d,%d,%d,%d->%d]", x1, y1, x2,y2, pen); +} + +void tgi_line(int x1, int y1, int x2, int y2) +{ + int dx = abs(x2-x1), sx = x1= dy) { err += dy; x1 += sx; } /* e_xy+e_x > 0 */ + if (e2 <= dx) { err += dx; y1 += sy; } /* e_xy+e_y < 0 */ + } + +// printf("[L %d,%d,%d,%d->%d]", x1, y1, x2,y2, pen); +} -- 2.34.1