plato: more fixes and split the 'tgi' code into it's own file.
authorAlan Cox <alan@linux.intel.com>
Fri, 7 Sep 2018 23:43:53 +0000 (00:43 +0100)
committerAlan Cox <alan@linux.intel.com>
Fri, 7 Sep 2018 23:43:53 +0000 (00:43 +0100)
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
Applications/plato/Makefile.68000
Applications/plato/Makefile.6809
Applications/plato/Makefile.z80
Applications/plato/plato.c
Applications/plato/screen_base.c
Applications/plato/tgi.h [new file with mode: 0644]
Applications/plato/tgi_ascii.c [new file with mode: 0644]

index cf15c99..f13b2e6 100644 (file)
@@ -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
 
index 6e34e76..b70af16 100644 (file)
@@ -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
 
index 28e5412..c22c7ba 100644 (file)
@@ -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
 
index dd2d980..9488441 100644 (file)
@@ -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
index 83f90d2..4b396a2 100644 (file)
@@ -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();
index 3fb6f8d..eb05867 100644 (file)
@@ -11,6 +11,7 @@
 #include <string.h>
 #include <stdbool.h>
 #include <stdlib.h>
+#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<x2 ? 1 : -1;
-   int dy = -abs(y2-y1), sy = y1<y2 ? 1 : -1; 
-   int err = dx+dy, e2; /* error value e_xy */
-   for(;;){  /* loop */
-      tgi_setpixel(x1,y1);
-      if (x1==x2 && y1==y2) break;
-      e2 = 2*err;
-      if (e2 >= 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 (file)
index 0000000..e4561a2
--- /dev/null
@@ -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 (file)
index 0000000..3c23338
--- /dev/null
@@ -0,0 +1,72 @@
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#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<x2 ? 1 : -1;
+   int dy = -abs(y2-y1), sy = y1<y2 ? 1 : -1; 
+   int err = dx+dy, e2; /* error value e_xy */
+   for(;;){  /* loop */
+      tgi_setpixel(x1,y1);
+      if (x1==x2 && y1==y2) break;
+      e2 = 2*err;
+      if (e2 >= 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);
+}