X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fapple2-main.c;h=ef21995b2ce9cf85db2ab808f8a0aa9fff79cddf;hb=4ade52359b6eba3621566dac79793a33aa4c915f;hp=3beeeeea62142ea7b9db5f59b755e494540999d6;hpb=0d6b320def9180cf907ceaed56b23a972a11b757;p=xscreensaver diff --git a/hacks/apple2-main.c b/hacks/apple2-main.c index 3beeeeea..ef21995b 100644 --- a/hacks/apple2-main.c +++ b/hacks/apple2-main.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1998-2005 Jamie Zawinski +/* xscreensaver, Copyright (c) 1998-2013 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -13,25 +13,20 @@ * Pty and vt100 emulation by Fredrik Tolf */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif /* HAVE_CONFIG_H */ + #include #include -#include "screenhack.h" -#include "apple2.h" -#include -#include -#define XK_MISCELLANY -#include +#ifdef HAVE_UNISTD_H +# include +#endif -#ifdef HAVE_FORKPTY -# include -# ifdef HAVE_PTY_H -# include -# endif -# ifdef HAVE_UTIL_H -# include -# endif -#endif /* HAVE_FORKPTY */ +#include "screenhack.h" +#include "apple2.h" +#include "textclient.h" #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) @@ -41,10 +36,6 @@ #define DEBUG -extern XtAppContext app; - -Time subproc_relaunch_delay = 3000; - /* Given a bitmask, returns the position and width of the field. */ @@ -221,8 +212,8 @@ pick_a2_subimage (Display *dpy, Window window, XImage *in, dw = (in->width - fromw) / 2; /* near the center! */ dh = (in->height - fromh) / 2; - fromx = (random() % dw) + (dw/2); - fromy = (random() % dh) + (dh/2); + fromx = (dw <= 0 ? 0 : (random() % dw) + (dw/2)); + fromy = (dh <= 0 ? 0 : (random() % dh) + (dh/2)); } scale_image (dpy, window, in, @@ -269,7 +260,6 @@ a2_dither (unsigned int *in, unsigned char *out, int w, int h) long *temp_err; int fs_scale = 1024; int brightness = 75; - int fs_direction; #if 0 { @@ -310,7 +300,6 @@ a2_dither (unsigned int *in, unsigned char *out, int w, int h) this_berr[x] = random() % (fs_scale * 2) - fs_scale; /* (random errors in [-1 .. 1]) */ } - fs_direction = 1; for (y = 0; y < h; y++) for (x = 0; x < w; x++) @@ -519,13 +508,24 @@ a2_dither (unsigned int *in, unsigned char *out, int w, int h) #endif } +typedef struct slideshow_data_s { + int slideno; + int render_img_lineno; + unsigned char *render_img; + char *img_filename; + Bool image_loading_p; +} slideshow_data; + -static unsigned char * -load_image (Display *dpy, Window window, char **image_filename_r) +static void +image_loaded_cb (Screen *screen, Window window, Drawable p, + const char *name, XRectangle *geometry, + void *closure) { + Display *dpy = DisplayOfScreen (screen); + apple2_sim_t *sim = (apple2_sim_t *) closure; + slideshow_data *mine = (slideshow_data *) sim->controller_data; XWindowAttributes xgwa; - Pixmap p; - int w = 280; int h = 192; XImage *image; @@ -539,40 +539,37 @@ load_image (Display *dpy, Window window, char **image_filename_r) } XGetWindowAttributes (dpy, window, &xgwa); - p = XCreatePixmap (dpy, window, xgwa.width, xgwa.height, xgwa.depth); - load_random_image (xgwa.screen, window, p, image_filename_r, NULL); + image = XGetImage (dpy, p, 0, 0, xgwa.width, xgwa.height, ~0, ZPixmap); XFreePixmap (dpy, p); p = 0; - /* Make sure the window's background is not set to None, and get the - grabbed bits (if any) off it as soon as possible. */ - XSetWindowBackground (dpy, window, - get_pixel_resource ("background", "Background", - dpy, xgwa.colormap)); - XClearWindow (dpy, window); - /* Scale the XImage down to Apple][ size, and convert it to a 32bpp image (regardless of whether it started as TrueColor/PseudoColor.) */ pick_a2_subimage (dpy, window, image, buf32, w, h); + free(image->data); + image->data = 0; + XDestroyImage(image); /* Then dither the 32bpp image to a 6-color Apple][ colormap. */ a2_dither (buf32, buf8, w, h); free (buf32); - return buf8; + + mine->image_loading_p = False; + mine->img_filename = (name ? strdup (name) : 0); + mine->render_img = buf8; } -char *progclass = "Apple2"; -char *defaults [] = { +static const char *apple2_defaults [] = { ".background: black", ".foreground: white", "*mode: random", - "*duration: 20", + "*duration: 60", "*program: xscreensaver-text --cols 40", "*metaSendsESC: True", "*swapBSDEL: True", @@ -587,7 +584,8 @@ char *defaults [] = { 0 }; -XrmOptionDescRec options [] = { +static XrmOptionDescRec apple2_options [] = { + { "-mode", ".mode", XrmoptionSepArg, 0 }, { "-slideshow", ".mode", XrmoptionNoArg, "slideshow" }, { "-basic", ".mode", XrmoptionNoArg, "basic" }, { "-text", ".mode", XrmoptionNoArg, "text" }, @@ -609,21 +607,16 @@ XrmOptionDescRec options [] = { to avoid the pause while it loads. */ -void slideshow_controller(apple2_sim_t *sim, int *stepno, - double *next_actiontime) +static void slideshow_controller(apple2_sim_t *sim, int *stepno, + double *next_actiontime) { apple2_state_t *st=sim->st; int i; - struct mydata { - int slideno; - int render_img_lineno; - u_char *render_img; - char *img_filename; - } *mine; + slideshow_data *mine; if (!sim->controller_data) - sim->controller_data = calloc(sizeof(struct mydata),1); - mine=(struct mydata *) sim->controller_data; + sim->controller_data = calloc (1, sizeof(*mine)); + mine = (slideshow_data *) sim->controller_data; switch(*stepno) { @@ -639,17 +632,35 @@ void slideshow_controller(apple2_sim_t *sim, int *stepno, a2_goto(st,23,0); a2_printc(st,']'); - *next_actiontime += 4.0; *stepno=10; + break; case 10: - mine->render_img = load_image (sim->dpy, sim->window, &mine->img_filename); - if (st->gr_mode) { - *stepno=30; - } else { - *stepno=20; + { + XWindowAttributes xgwa; + Pixmap p; + XGetWindowAttributes (sim->dpy, sim->window, &xgwa); + p = XCreatePixmap (sim->dpy, sim->window, xgwa.width, xgwa.height, + xgwa.depth); + mine->image_loading_p = True; + load_image_async (xgwa.screen, sim->window, p, image_loaded_cb, sim); + + /* pause with a blank screen for a bit, while the image loads in the + background. */ + *next_actiontime += 2.0; + *stepno=11; + } + break; + + case 11: + if (! mine->image_loading_p) { /* image is finally loaded */ + if (st->gr_mode) { + *stepno=30; + } else { + *stepno=20; + } + *next_actiontime += 3.0; } - *next_actiontime += 3.0; break; case 20: @@ -676,7 +687,7 @@ void slideshow_controller(apple2_sim_t *sim, int *stepno, basename = slash+1; } { - char *dot=strchr(basename,'.'); + char *dot=strrchr(basename,'.'); if (dot) *dot=0; } if (strlen(basename)>20) basename[20]=0; @@ -726,7 +737,9 @@ void slideshow_controller(apple2_sim_t *sim, int *stepno, case 50: st->gr_mode |= A2_GR_FULL; *stepno=60; - *next_actiontime += sim->delay; + /* Note that sim->delay is sometimes "infinite" in this controller. + These images are kinda dull anyway, so don't leave it on too long. */ + *next_actiontime += 2; break; case 60: @@ -753,6 +766,7 @@ void slideshow_controller(apple2_sim_t *sim, int *stepno, free(mine->render_img); free(mine->img_filename); free(mine); + mine = 0; return; } @@ -761,16 +775,11 @@ void slideshow_controller(apple2_sim_t *sim, int *stepno, #define NPAR 16 struct terminal_controller_data { - FILE *pipe; - int pipe_id; - pid_t pid; - int input_available_p; - XtIntervalId timeout_id; + Display *dpy; char curword[256]; unsigned char lastc; - int fake_nl; double last_emit_time; - XComposeStatus compose; + text_data *tc; int escstate; int csiparam[NPAR]; @@ -785,202 +794,42 @@ struct terminal_controller_data { } bf; int w; } termattrib; - Bool meta_sends_esc_p; - Bool swap_bs_del_p; Bool fast_p; }; -static void -subproc_cb (XtPointer closure, int *source, XtInputId *id) -{ - struct terminal_controller_data *mine = - (struct terminal_controller_data *) closure; - mine->input_available_p = True; -} - -static void -launch_text_generator (struct terminal_controller_data *mine) -{ - char buf[255]; - char *oprogram = get_string_resource ("program", "Program"); - char *program = (char *) malloc (strlen (oprogram) + 10); - - strcpy (program, "( "); - strcat (program, oprogram); - strcat (program, " ) 2>&1"); - if (mine->pipe) abort(); +/* The structure of closure linkage throughout this code is so amazingly + baroque that I can't get to the 'struct state' from where I need it. */ +static const char *global_program; +static Bool global_fast_p; -# ifdef HAVE_FORKPTY - if (get_boolean_resource ("usePty", "Boolean")) - { - int fd; - struct winsize ws; - - ws.ws_col = SCREEN_COLS; - ws.ws_row = SCREEN_ROWS; - ws.ws_xpixel = ws.ws_col * 6; - ws.ws_ypixel = ws.ws_row * 8; - - mine->pipe = NULL; - if((mine->pid = forkpty(&fd, NULL, NULL, &ws)) < 0) - { - /* Unable to fork */ - sprintf (buf, "%.100s: forkpty", progname); - perror(buf); - } - else if(!mine->pid) - { - /* This is the child fork. */ - char *av[10]; - int i = 0; - if (putenv("TERM=vt100")) - abort(); - av[i++] = "/bin/sh"; - av[i++] = "-c"; - av[i++] = oprogram; - av[i] = 0; - execvp (av[0], av); - sprintf (buf, "%.100s: %.100s", progname, oprogram); - perror(buf); - exit(1); - } - else - { - /* This is the parent fork. */ - mine->pipe = fdopen(fd, "r+"); - mine->pipe_id = - XtAppAddInput (app, fileno (mine->pipe), - (XtPointer) (XtInputReadMask | XtInputExceptMask), - subproc_cb, (XtPointer) mine); - } - } - else -# endif /* HAVE_FORKPTY */ - - if ((mine->pipe = popen (program, "r"))) - { - if (mine->pipe_id) abort(); - mine->pipe_id = - XtAppAddInput (app, fileno (mine->pipe), - (XtPointer) (XtInputReadMask | XtInputExceptMask), - subproc_cb, (XtPointer) mine); - } - else - { - sprintf (buf, "%.100s: %.100s", progname, program); - perror(buf); - } -} - -static void -relaunch_generator_timer (XtPointer closure, XtIntervalId *id) -{ - struct terminal_controller_data *mine = - (struct terminal_controller_data *) closure; - mine->timeout_id=0; - launch_text_generator (mine); -} static void terminal_closegen(struct terminal_controller_data *mine) { - if (mine->pipe_id) { - XtRemoveInput (mine->pipe_id); - mine->pipe_id = 0; - } - if (mine->pipe) { - pclose (mine->pipe); - mine->pipe = 0; - } - if (mine->timeout_id) { - XtRemoveTimeOut(mine->timeout_id); - mine->timeout_id=0; + if (mine->tc) { + textclient_close (mine->tc); + mine->tc = 0; } } static int terminal_read(struct terminal_controller_data *mine, unsigned char *buf, int n) { - int rc; - if (mine->fake_nl) { - buf[0]='\n'; - mine->fake_nl=0; - return 1; - } - - if (!mine->input_available_p) return 0; - - rc=read (fileno (mine->pipe), (void *) buf, n); - if (rc>0) mine->lastc=buf[rc-1]; - - if (rc<=0) - { - terminal_closegen(mine); - - if (mine->lastc != '\n') { /* add a newline at eof if there wasn't one */ - mine->fake_nl=1; - } - - /* Set up a timer to re-launch the subproc in a bit. */ - mine->timeout_id = - XtAppAddTimeOut(app, subproc_relaunch_delay, - relaunch_generator_timer, - (XtPointer) mine); - } - - mine->input_available_p = False; - - return rc; -} - - -/* The interpretation of the ModN modifiers is dependent on what keys - are bound to them: Mod1 does not necessarily mean "meta". It only - means "meta" if Meta_L or Meta_R are bound to it. If Meta_L is on - Mod5, then Mod5 is the one that means Meta. Oh, and Meta and Alt - aren't necessarily the same thing. Icepicks in my forehead! - */ -static unsigned int -do_icccm_meta_key_stupidity (Display *dpy) -{ - unsigned int modbits = 0; - int i, j, k; - XModifierKeymap *modmap = XGetModifierMapping (dpy); - for (i = 3; i < 8; i++) - for (j = 0; j < modmap->max_keypermod; j++) - { - int code = modmap->modifiermap[i * modmap->max_keypermod + j]; - KeySym *syms; - int nsyms = 0; - if (code == 0) continue; - syms = XGetKeyboardMapping (dpy, code, 1, &nsyms); - for (k = 0; k < nsyms; k++) - if (syms[k] == XK_Meta_L || syms[k] == XK_Meta_R || - syms[k] == XK_Alt_L || syms[k] == XK_Alt_R) - modbits |= (1 << i); - XFree (syms); - } - XFreeModifiermap (modmap); - return modbits; -} - -/* Returns a mask of the bit or bits of a KeyPress event that mean "meta". - */ -static unsigned int -meta_modifier (Display *dpy) -{ - static Bool done_once = False; - static unsigned int mask = 0; - if (!done_once) - { - /* Really, we are supposed to recompute this if a KeymapNotify - event comes in, but fuck it. */ - done_once = True; - mask = do_icccm_meta_key_stupidity (dpy); + if (!mine || !mine->tc) { + return 0; + } else { + int i, count = 0; + for (i = 0; i < n; i++) { + int c = textclient_getc (mine->tc); + if (c <= 0) break; + buf[i] = c; + mine->lastc = c; + count++; } - return mask; + return count; + } } @@ -989,30 +838,9 @@ terminal_keypress_handler (Display *dpy, XEvent *event, void *data) { struct terminal_controller_data *mine = (struct terminal_controller_data *) data; - KeySym keysym; - unsigned char c = 0; - XLookupString (&event->xkey, (char *) &c, 1, &keysym, &mine->compose); - if (c == 0 || !mine->pipe) - return 0; - - if (!mine->swap_bs_del_p) ; - else if (c == 127) c = 8; - else if (c == 8) c = 127; - - /* If meta was held down, send ESC, or turn on the high bit. */ - if (event->xkey.state & meta_modifier (dpy)) - { - if (mine->meta_sends_esc_p) - fputc ('\033', mine->pipe); - else - c |= 0x80; - } - - fputc (c, mine->pipe); - fflush (mine->pipe); - - event->xany.type = 0; /* do not process this event further */ - + mine->dpy = dpy; + if (event->xany.type == KeyPress && mine->tc) + return textclient_putc (mine->tc, &event->xkey); return 0; } @@ -1087,6 +915,9 @@ a2_vt100_printc (apple2_sim_t *sim, struct terminal_controller_data *state, } break; case 10: /* LF */ +# ifndef HAVE_FORKPTY + state->cursor_x = 0; /* No ptys on iPhone; assume CRLF. */ +# endif case 11: /* VT */ case 12: /* FF */ if (state->cursor_y < rows - 1) @@ -1416,7 +1247,7 @@ a2_vt100_printc (apple2_sim_t *sim, struct terminal_controller_data *state, GNU/Linux dammit) occupies an entire screen on the Apple ][. */ -void +static void terminal_controller(apple2_sim_t *sim, int *stepno, double *next_actiontime) { apple2_state_t *st=sim->st; @@ -1427,13 +1258,9 @@ terminal_controller(apple2_sim_t *sim, int *stepno, double *next_actiontime) if (!sim->controller_data) sim->controller_data=calloc(sizeof(struct terminal_controller_data),1); mine=(struct terminal_controller_data *) sim->controller_data; + mine->dpy = sim->dpy; - mine->meta_sends_esc_p = get_boolean_resource ("metaSendsESC", "Boolean"); - mine->swap_bs_del_p = get_boolean_resource ("swapBSDEL", "Boolean"); - mine->fast_p = get_boolean_resource ("fast", "Boolean"); - - sim->dec->key_handler = terminal_keypress_handler; - sim->dec->key_data = mine; + mine->fast_p = global_fast_p; switch(*stepno) { @@ -1447,8 +1274,12 @@ terminal_controller(apple2_sim_t *sim, int *stepno, double *next_actiontime) a2_goto(st,2,0); mine->cursor_y = 2; - if (! mine->pipe) - launch_text_generator(mine); + if (! mine->tc) { + mine->tc = textclient_open (mine->dpy); + textclient_reshape (mine->tc, + SCREEN_COLS, SCREEN_ROWS, + SCREEN_COLS, SCREEN_ROWS); + } if (! mine->fast_p) *next_actiontime += 4.0; @@ -1475,7 +1306,7 @@ terminal_controller(apple2_sim_t *sim, int *stepno, double *next_actiontime) for (i=0; ipid) + if (mine->tc) a2_vt100_printc (sim, mine, c); else a2_ascii_printc (st, c, False, False, False, True); @@ -1486,6 +1317,7 @@ terminal_controller(apple2_sim_t *sim, int *stepno, double *next_actiontime) case A2CONTROLLER_FREE: terminal_closegen(mine); free(mine); + mine = 0; return; } } @@ -1493,7 +1325,7 @@ terminal_controller(apple2_sim_t *sim, int *stepno, double *next_actiontime) struct basic_controller_data { int prog_line; int x,y,k; - char **progtext; + const char * const * progtext; int progstep; char *rep_str; int rep_pos; @@ -1505,7 +1337,7 @@ struct basic_controller_data { Adding more programs is easy. Just add a listing here and to all_programs, then add the state machine to actually execute it to basic_controller. */ -static char *moire_program[]={ +static const char * const moire_program[]={ "10 HGR2\n", "20 FOR Y = 0 TO 190 STEP 2\n", "30 HCOLOR=4 : REM BLACK\n", @@ -1522,7 +1354,7 @@ static char *moire_program[]={ NULL }; -static char *sinewave_program[] = { +static const char * const sinewave_program[] = { "10 HGR\n", "25 K=0\n", "30 FOR X = 0 TO 279\n", @@ -1538,14 +1370,14 @@ static char *sinewave_program[] = { }; #if 0 -static char *dumb_program[]={ +static const char * const dumb_program[]={ "10 PRINT \"APPLE ][ ROOLZ! TRS-80 DROOLZ!\"\n", "20 GOTO 10\n", NULL }; #endif -static char *random_lores_program[]={ +static const char * const random_lores_program[]={ "1 REM APPLE ][ SCREEN SAVER\n", "10 GR\n", "100 COLOR= RND(1)*16\n", @@ -1570,7 +1402,7 @@ static char *random_lores_program[]={ static char typo_map[256]; -int make_typo(char *out_buf, char *orig, char *err_buf) +static int make_typo(char *out_buf, const char *orig, char *err_buf) { int i,j; int errc; @@ -1650,7 +1482,7 @@ int make_typo(char *out_buf, char *orig, char *err_buf) break; } - if (random()%10==0 && strlen(p)>=4 && (errc=typo_map[(int)(u_char)p[0]])) { + if (random()%10==0 && strlen(p)>=4 && (errc=typo_map[(int)(unsigned char)p[0]])) { int remain=strlen(p); int past=random()%(remain-2)+1; memmove(p+past+past, p, remain+1); @@ -1664,8 +1496,8 @@ int make_typo(char *out_buf, char *orig, char *err_buf) return success; } -struct { - char **progtext; +static const struct { + const char * const * progtext; int progstep; } all_programs[]={ {moire_program, 100}, @@ -1674,7 +1506,7 @@ struct { {random_lores_program, 500}, }; -void +static void basic_controller(apple2_sim_t *sim, int *stepno, double *next_actiontime) { apple2_state_t *st=sim->st; @@ -1848,47 +1680,47 @@ basic_controller(apple2_sim_t *sim, int *stepno, double *next_actiontime) case A2CONTROLLER_FREE: free(mine); + mine = 0; break; } } -void (*controllers[])(apple2_sim_t *sim, int *stepno, - double *next_actiontime) = { +static void (* const controllers[]) (apple2_sim_t *sim, int *stepno, + double *next_actiontime) = { slideshow_controller, terminal_controller, basic_controller }; -void -screenhack (Display *dpy, Window window) +struct state { + int duration; + Bool random_p; + apple2_sim_t *sim; + void (*controller) (apple2_sim_t *sim, int *stepno, double *next_actiontime); +}; + + +static void * +apple2_init (Display *dpy, Window window) { - int duration = get_integer_resource ("duration", "Integer"); + struct state *st = (struct state *) calloc (1, sizeof(*st)); char *s; - void (*controller)(apple2_sim_t *sim, int *stepno, double *next_actiontime); - Bool random_p = False; - controller = 0; - if (duration < 1) duration = 1; + st->duration = get_integer_resource (dpy, "duration", "Integer"); - if (!get_boolean_resource ("root", "Boolean")) - { - XWindowAttributes xgwa; - XGetWindowAttributes (dpy, window, &xgwa); - XSelectInput (dpy, window, - xgwa.your_event_mask | - KeyPressMask | ButtonPressMask | ExposureMask); - } + st->controller = 0; + if (st->duration < 1) st->duration = 1; - s = get_string_resource ("mode", "Mode"); + s = get_string_resource (dpy, "mode", "Mode"); if (!s || !*s || !strcasecmp(s, "random")) - random_p = True; + st->random_p = True; else if (!strcasecmp(s, "text")) - controller = terminal_controller; + st->controller = terminal_controller; else if (!strcasecmp(s, "slideshow")) - controller = slideshow_controller; + st->controller = slideshow_controller; else if (!strcasecmp(s, "basic")) - controller = basic_controller; + st->controller = basic_controller; else { fprintf (stderr, "%s: mode must be text, slideshow, or random; not %s\n", @@ -1897,15 +1729,85 @@ screenhack (Display *dpy, Window window) } if (s) free (s); - if (controller == terminal_controller) - duration = 999999; /* this one runs "forever" */ + global_program = get_string_resource (dpy, "program", "Program"); + global_fast_p = get_boolean_resource (dpy, "fast", "Boolean"); - while (1) - { - if (random_p) - controller = controllers[random() % (countof(controllers))]; - apple2 (dpy, window, duration, controller); - XSync (dpy, False); - } + /* Kludge for MacOS standalone mode: see OSX/SaverRunner.m. */ + { + const char *s = getenv ("XSCREENSAVER_STANDALONE"); + if (s && *s && strcmp(s, "0")) + { + st->controller = terminal_controller; + st->random_p = False; + global_program = getenv ("SHELL"); + global_fast_p = True; + } + } + + + if (! st->random_p) { + if (st->controller == terminal_controller || + st->controller == slideshow_controller) + st->duration = 999999; /* these run "forever" */ + } + + return st; +} + +static unsigned long +apple2_draw (Display *dpy, Window window, void *closure) +{ + struct state *st = (struct state *) closure; + + if (! st->sim) { + if (st->random_p) + st->controller = controllers[random() % (countof(controllers))]; + st->sim = apple2_start (dpy, window, st->duration, st->controller); + } + + if (! apple2_one_frame (st->sim)) { + st->sim = 0; + } + + return 10000; +} + +static void +apple2_reshape (Display *dpy, Window window, void *closure, + unsigned int w, unsigned int h) +{ + struct state *st = (struct state *) closure; + if (st->sim) + analogtv_reconfigure (st->sim->dec); +} + +static Bool +apple2_event (Display *dpy, Window window, void *closure, XEvent *event) +{ + struct state *st = (struct state *) closure; + + if (st->sim && + st->controller == terminal_controller && + event->xany.type == KeyPress) { + terminal_keypress_handler (dpy, event, st->sim->controller_data); + return True; + } + + return False; +} + +static void +apple2_free (Display *dpy, Window window, void *closure) +{ + struct state *st = (struct state *) closure; + if (st->sim) { + st->sim->stepno = A2CONTROLLER_DONE; + if (apple2_one_frame (st->sim)) + abort(); /* should have freed! */ + } + free (st); } + + +XSCREENSAVER_MODULE ("Apple2", apple2)