]> git.sur5r.net Git - c128-kasse/blobdiff - src/print.c
kasse: allow starting up without a printer
[c128-kasse] / src / print.c
index 665f99feee090b7d19f34b0dca49eef3f084c92e..dee15994efe06e20309865f0154e96df3ddb49b2 100644 (file)
@@ -12,6 +12,7 @@
 #include "general.h"
 #define _IS_PRINT
 #include "print.h"
+#include "globals.h"
 
 /* NOTE: undocumented function which scratches files
    We need to use this function because linking unistd.h
@@ -36,19 +37,34 @@ void init_log(void) {
 }
 
 void print_the_buffer(void) {
-  BYTE c;
+  BYTE status;
+  char *c;
+
+  if (!printing)
+    return;
+
 RETRY:
-  c = cbm_open((BYTE)4, (BYTE)4, (BYTE)0, NULL);
-  if (c != 0) {
-    c128_perror(c, "cbm_open(printer)");
-    if (retry_or_quit() == 'q')
+  status = cbm_open((BYTE)4, (BYTE)4, (BYTE)0, NULL);
+  if (status != 0) {
+    c128_perror(status, "cbm_open(printer)");
+
+    do {
+      cprintf("\r\nr)etry, c)ontinue or q)uit?\r\n");
+      c = get_input();
+    } while ((*c != 'r') && (*c != 'c') && (*c != 'q'));
+
+    if (*c == 'q')
       exit(1);
+    else if (*c == 'c') {
+      printing = 0;
+      return;
+    }
 
     goto RETRY;
   }
-  c = cbm_write((BYTE)4, print_buffer, strlen(print_buffer));
-  if (c != strlen(print_buffer)) {
-    c128_perror(c, "write(printer)");
+  status = cbm_write((BYTE)4, print_buffer, strlen(print_buffer));
+  if (status != strlen(print_buffer)) {
+    c128_perror(status, "write(printer)");
     if (retry_or_quit() == 'q')
       exit(1);
     goto RETRY;