From http://www.jwz.org/xscreensaver/xscreensaver-5.27.tar.gz
[xscreensaver] / hacks / apple2.c
index da5a6b899320f5e2038e835d14050d8deadcb10b..17b6788c6d2d04b95192ae6e3b79c83d7df843a5 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1998-2006 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1998-2010 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
@@ -151,7 +151,7 @@ void
 a2_goto(apple2_state_t *st, int r, int c)
 {
   if (r > 23) r = 23;
-  if (c > 39) r = 39;
+  if (c > 39) c = 39;
   st->textlines[st->cursy][st->cursx] |= 0xc0; /* turn off blink */
   st->cursy=r;
   st->cursx=c;
@@ -671,11 +671,12 @@ apple2_one_frame (apple2_sim_t *sim)
         int c;
         /* If we're in the midst of typing a string, emit a character with
            random timing. */
-        c =*sim->typing++;
+        c =*sim->typing;
         if (c==0) {
           sim->typing=NULL;
         }
         else {
+          sim->typing++;
           a2_printc(sim->st, c);
           if (c=='\r' || c=='\n') {
             sim->next_actiontime = sim->curtime;
@@ -699,10 +700,24 @@ apple2_one_frame (apple2_sim_t *sim)
         DONE:
           sim->stepno=A2CONTROLLER_FREE;
           sim->controller (sim, &sim->stepno, &sim->next_actiontime);
+          /* if stepno is changed, return 1 */
+          if (sim->stepno != A2CONTROLLER_FREE)
+            return 1;
 
           XClearWindow(sim->dpy, sim->window);
 
-          /* #### free sim? */
+          /* free sim */
+          /* This is from a2_make_font */
+          free(sim->text_im->data);
+          sim->text_im->data = 0;
+          XDestroyImage(sim->text_im);
+
+          /* And free else */
+          analogtv_release(sim->dec);
+          free(sim->st);
+          free(sim->inp);
+          free(sim);
+
           return 0;
         }
 
@@ -792,10 +807,11 @@ apple2_one_frame (apple2_sim_t *sim)
         }
       }
     }
-    analogtv_init_signal(sim->dec, 0.02);
     analogtv_reception_update(&sim->reception);
-    analogtv_add_signal(sim->dec, &sim->reception);
-    analogtv_draw(sim->dec);
+    {
+      const analogtv_reception *rec = &sim->reception;
+      analogtv_draw(sim->dec, 0.02, &rec, 1);
+    }
  
     return 1;
 }