]> git.sur5r.net Git - c128-kasse/commitdiff
speed up interrupt handler by directly writing to VDC RAM
authorMaik Fischer <maikf@qu.cx>
Thu, 2 Nov 2017 18:15:34 +0000 (19:15 +0100)
committerMaik Fischer <maikf@qu.cx>
Sun, 23 Sep 2018 11:42:44 +0000 (13:42 +0200)
Makefile
include/globals.h
src/c128time.c
src/globals.c
src/kasse.c

index 5cc40866fbb82ccaec4d118d6960237eb1fd15b8..90b2af8fa7d5a08eb40b85018e1603934ed07750 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -35,7 +35,7 @@ include/charset_umlauts.h: assets/umlauts.pbm
 kasse: build/config.o build/kasse.o build/general.o build/credit_manager.o build/c128time.o build/print.o build/vdc_patch_charset.o build/vdc_util.o build/globals.o build/bcd2dec.o
        ${LD} -Ln $@.lbl -t c128 $^ -o $@
 
-itemz: build/config.o build/itemz.o build/general.o build/credit_manager.o build/c128time.o build/print.o build/globals.o
+itemz: build/config.o build/itemz.o build/general.o build/credit_manager.o build/c128time.o build/print.o build/globals.o build/bcd2dec.o build/vdc_util.o
        ${LD} -Ln $@.lbl -t c128 $^ -o $@
 
 cat: build/general.o build/cat.o build/config.o build/print.o build/globals.o
index c92bda1e4a2ff86c0480c4ffccfdd8066c7d369a..ec8385421c5e36bb623c80c70de492cadb6aeec1 100644 (file)
@@ -11,8 +11,6 @@
 #define GLOBAL extern
 #endif
 
-void init_globals(void);
-
 GLOBAL uint8_t printing;
 GLOBAL enum kasse_menu kasse_menu;
 GLOBAL struct daytime_t daytime;
index f631e841d134942ac74f30a1bd2268b6e6801d80..9d05903fecd31269a3615bd1ed8c00cca7c2ddec 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * RGB2R-C128-Kassenprogramm
- * © 2007-2009 phil_fry, sECuRE, sur5r
+ * © 2007-2017 phil_fry, sECuRE, sur5r, mxf
  * See LICENSE for license information
  *
  */
@@ -15,6 +15,7 @@
 #include "bcd2dec.h"
 #include "general.h"
 #include "globals.h"
+#include "vdc_util.h"
 
 /* This file uses the CIA TOD (Complex Interface Adapter, Time of Day)
  * for timekeeping, see https://www.c64-wiki.com/wiki/CIA and its Links section
 /* the Time of Day PM bit is set for hours >= 12 */
 #define TOD_PM 0x80
 
+/* VDC charmap starts at 0x0000; 80 chars per line.
+ * We want to draw at 72 chars on the 1st line.
+ */
+#define CLOCK_ADDR 72
+
+/* arbitrarly chosen stack size, should be large enough */
 #define DAYTIME_IRQ_STACK_SIZE 32
 uint8_t daytime_irq_stack[DAYTIME_IRQ_STACK_SIZE];
 
 void update_time(void) {
-  volatile static uint8_t bcd_hour, hour, min, sec, tenth;
+  uint8_t bcd_hour, hour, min, sec, dummy;
 
   /* Read the hour register first to stop the clock from updating the external
    * registers from the internal (still ticking!) CIA registers. */
@@ -49,7 +56,7 @@ void update_time(void) {
   min = bcd2dec(CIA1.tod_min);
 
   /* MUST read tod_10 to enable the clock latch again */
-  tenth = CIA1.tod_10;
+  dummy = CIA1.tod_10;
 
   /* it's a new day when hour wraps */
   if (daytime.hour > hour) {
@@ -104,16 +111,12 @@ void set_time(uint8_t day, uint8_t hour, uint8_t min, uint8_t sec) {
 }
 
 uint8_t _daytime_irq(void) {
-  static char *t;
-  static uint8_t x, y;
+  char *t;
   /* We are called 60 times a second. We only want to draw a clock
    * when we are a) on the mainscreen and b) the seconds changed */
   if (kasse_menu == MENU_MAIN && CIA1.tod_sec != daytime.sec) {
     t = get_time();
-    x = wherex();
-    y = wherey();
-    cputsxy(70, 3, t);
-    gotoxy(x, y);
+    vdc_write_mem(CLOCK_ADDR, t, 8);
   }
   /* always call additional handlers */
   return (IRQ_NOT_HANDLED);
index 014b556dfec7061b6d3fa4e4f0c9c41f2abf8f39..0443cbb93e43961a5520fb3905e05de4c848d4bf 100644 (file)
@@ -1,10 +1,2 @@
 #define IS_GLOBALS_C
 #include "globals.h"
-
-void init_globals(void) {
-  printing = 1;
-  /* initialize daytime global, start the CIA TOD */
-  set_time(0, 0, 0, 0);
-  kasse_menu = MENU_UNDEFINED;
-  return;
-}
index d2e5560adca6272faaa4241c6eadb857fc7dfe55..54521e68d905c266a6a0a039ec69f62959c676c3 100644 (file)
@@ -48,9 +48,10 @@ static void print_screen(void) {
     profit[0] = '\0';
   }
   textcolor(TC_CYAN);
-  cprintf("C128-Kassenprogramm (phil_fry, sECuRE, sur5r, mxf) " GV "\r\n");
+  /* fill whole line with cyan, so color bits are set up for the clock */
+  cprintf("%-80s", "C128-Kasse (phil_fry, sECuRE, sur5r, mxf) " GV);
   textcolor(TC_LIGHT_GRAY);
-  cprintf("\r\n\r\n"
+  cprintf("\r\n\r\n\r\n"
           "Ertrag: %s (%ld Artikel); Drucken: %s\r\n",
           profit, items_sold, (printing == 1 ? "ein" : "aus"));
   textcolor(TC_LIGHT_GRAY);
@@ -272,7 +273,8 @@ void set_time_interactive(void) {
   uint8_t day, tp1, tp2, tp3;
   char *time_input, *time;
   cprintf("Gib den aktuellen Tag des Events und Uhrzeit ein\r\n"
-          "(Format DHHMMSS):\r\n");
+          "Format DHHMMSS, 0-indexiert, z.B. 0174259 für \"erster Tag um "
+          "17:42:59\":\r\n");
   time_input = get_input();
   part[0] = time_input[0];
   day = atoi(part);
@@ -295,7 +297,10 @@ int main(void) {
   char *c;
   char *time;
 
-  init_globals();
+  printing = 1;
+  /* initialize daytime global, start the CIA TOD */
+  set_time(0, 0, 0, 0);
+  kasse_menu = MENU_UNDEFINED;
 
   videomode(VIDEOMODE_80x25);