ftp://ftp.krokus.ru/pub/OpenBSD/distfiles/xscreensaver-4.21.tar.gz
[xscreensaver] / hacks / apple2.c
index 184ff68fc184b4a4eb6e33ed5a6ea09d9f71f7a7..5bb586d2b61141b84ad5f682ddde344d2fa9f114 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1998-2003 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1998-2004 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -71,14 +71,16 @@ void
 a2_scroll(apple2_state_t *st)
 {
   int i;
+  st->textlines[st->cursy][st->cursx] |= 0xc0;     /* turn off cursor */
+
   for (i=0; i<23; i++) {
     memcpy(st->textlines[i],st->textlines[i+1],40);
   }
   memset(st->textlines[23],0xe0,40);
 }
 
-void
-a2_printc(apple2_state_t *st, char c)
+static void
+a2_printc_1(apple2_state_t *st, char c, int scroll_p)
 {
   st->textlines[st->cursy][st->cursx] |= 0xc0; /* turn off blink */
 
@@ -86,7 +88,8 @@ a2_printc(apple2_state_t *st, char c)
     {
       if (st->cursy==23)
         {
-          a2_scroll(st);
+          if (scroll_p)
+            a2_scroll(st);
         }
       else
         {
@@ -118,7 +121,8 @@ a2_printc(apple2_state_t *st, char c)
       st->cursx++;
       if (st->cursx==40) {
         if (st->cursy==23) {
-          a2_scroll(st);
+          if (scroll_p)
+            a2_scroll(st);
         } else {
           st->cursy++;
         }
@@ -129,6 +133,19 @@ a2_printc(apple2_state_t *st, char c)
   st->textlines[st->cursy][st->cursx] &= 0x7f; /* turn on blink */
 }
 
+void
+a2_printc(apple2_state_t *st, char c)
+{
+  a2_printc_1(st, c, 1);
+}
+
+void
+a2_printc_noscroll(apple2_state_t *st, char c)
+{
+  a2_printc_1(st, c, 0);
+}
+
+
 void
 a2_prints(apple2_state_t *st, char *s)
 {
@@ -138,6 +155,8 @@ a2_prints(apple2_state_t *st, char *s)
 void
 a2_goto(apple2_state_t *st, int r, int c)
 {
+  if (r > 23) r = 23;
+  if (c > 39) r = 39;
   st->textlines[st->cursy][st->cursx] |= 0xc0; /* turn off blink */
   st->cursy=r;
   st->cursx=c;
@@ -598,6 +617,9 @@ apple2(Display *dpy, Window window, int delay,
       }
     }
 
+    if (sim->curtime >= delay)
+      stepno = A2CONTROLLER_DONE;
+
     if (sim->printing) {
       int nlcnt=0;
       while (*sim->printing) {
@@ -665,7 +687,7 @@ apple2(Display *dpy, Window window, int delay,
            and even bytes have different color spaces. So, pattern[0..600]
            gets the dots for one scan line. */
 
-        char *pp=&sim->inp->signal[row+ANALOGTV_TOP+4][ANALOGTV_PIC_START+100];
+        signed char *pp=&sim->inp->signal[row+ANALOGTV_TOP+4][ANALOGTV_PIC_START+100];
 
         if ((sim->st->gr_mode&A2_GR_HIRES) &&
             (row<160 || (sim->st->gr_mode&A2_GR_FULL))) {