X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fapple2-main.c;h=3beeeeea62142ea7b9db5f59b755e494540999d6;hb=0d6b320def9180cf907ceaed56b23a972a11b757;hp=f183409939578677a29cceb91dd38675b406036a;hpb=bc7b7a8eb122206d239ec0e693676bcce31be1aa;p=xscreensaver diff --git a/hacks/apple2-main.c b/hacks/apple2-main.c index f1834099..3beeeeea 100644 --- a/hacks/apple2-main.c +++ b/hacks/apple2-main.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1998-2004 Jamie Zawinski +/* xscreensaver, Copyright (c) 1998-2005 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 @@ -24,6 +24,7 @@ #include #ifdef HAVE_FORKPTY +# include # ifdef HAVE_PTY_H # include # endif @@ -539,7 +540,7 @@ 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); + 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; @@ -572,6 +573,7 @@ char *defaults [] = { ".foreground: white", "*mode: random", "*duration: 20", + "*program: xscreensaver-text --cols 40", "*metaSendsESC: True", "*swapBSDEL: True", "*fast: False", @@ -802,12 +804,7 @@ launch_text_generator (struct terminal_controller_data *mine) { char buf[255]; char *oprogram = get_string_resource ("program", "Program"); - char *program; - - if (!oprogram || !*oprogram) - oprogram = FORTUNE_PROGRAM; - - program = (char *) malloc (strlen (oprogram) + 10); + char *program = (char *) malloc (strlen (oprogram) + 10); strcpy (program, "( "); strcat (program, oprogram); @@ -836,9 +833,15 @@ launch_text_generator (struct terminal_controller_data *mine) else if(!mine->pid) { /* This is the child fork. */ + char *av[10]; + int i = 0; if (putenv("TERM=vt100")) abort(); - execl("/bin/sh", "/bin/sh", "-c", oprogram, NULL); + 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); @@ -1504,17 +1507,17 @@ struct basic_controller_data { */ static char *moire_program[]={ "10 HGR2\n", - "20 FOR Y = 0 TO 191 STEP 2\n", + "20 FOR Y = 0 TO 190 STEP 2\n", "30 HCOLOR=4 : REM BLACK\n", - "40 HLINE 0,191-Y TO 279,Y\n", + "40 HPLOT 0,191-Y TO 279,Y\n", "60 HCOLOR=7 : REM WHITE\n", - "80 HLINE 0,190-Y TO 279,Y+1\n", + "80 HPLOT 0,190-Y TO 279,Y+1\n", "90 NEXT Y\n", - "100 FOR X = 0 TO 279 STEP 3\n", + "100 FOR X = 0 TO 278 STEP 3\n", "110 HCOLOR=4\n", - "120 HLINE 279-X,0 TO X,192\n", + "120 HPLOT 279-X,0 TO X,191\n", "140 HCOLOR=7\n", - "150 HLINE 278-X,0 TO X+1,192\n", + "150 HPLOT 278-X,0 TO X+1,191\n", "160 NEXT X\n", NULL }; @@ -1524,9 +1527,9 @@ static char *sinewave_program[] = { "25 K=0\n", "30 FOR X = 0 TO 279\n", "32 HCOLOR= 0\n", - "35 HLINE X,0 TO X,159\n", + "35 HPLOT X,0 TO X,159\n", "38 HCOLOR= 3\n", - "40 Y = 80 + SIN(15*(X-K)/279)\n", + "40 Y = 80 + SIN(15*(X-K)/279) * 40\n", "50 HPLOT X,Y\n", "60 NEXT X\n", "70 K=K+4\n", @@ -1548,13 +1551,13 @@ static char *random_lores_program[]={ "100 COLOR= RND(1)*16\n", "110 X=RND(1)*40\n", - "120 Y1=RND(1)*48\n", - "130 Y2=RND(1)*48\n", + "120 Y1=RND(1)*40\n", + "130 Y2=RND(1)*40\n", "140 FOR Y = Y1 TO Y2\n", "150 PLOT X,Y\n", "160 NEXT Y\n", - "210 Y=RND(1)*48\n", + "210 Y=RND(1)*40\n", "220 X1=RND(1)*40\n", "230 X2=RND(1)*40\n", "240 FOR X = X1 TO X2\n", @@ -1863,12 +1866,23 @@ screenhack (Display *dpy, Window window) int duration = get_integer_resource ("duration", "Integer"); char *s; void (*controller)(apple2_sim_t *sim, int *stepno, double *next_actiontime); + Bool random_p = False; + controller = 0; if (duration < 1) duration = 1; + if (!get_boolean_resource ("root", "Boolean")) + { + XWindowAttributes xgwa; + XGetWindowAttributes (dpy, window, &xgwa); + XSelectInput (dpy, window, + xgwa.your_event_mask | + KeyPressMask | ButtonPressMask | ExposureMask); + } + s = get_string_resource ("mode", "Mode"); if (!s || !*s || !strcasecmp(s, "random")) - controller = controllers[random() % (countof(controllers))]; + random_p = True; else if (!strcasecmp(s, "text")) controller = terminal_controller; else if (!strcasecmp(s, "slideshow")) @@ -1881,16 +1895,17 @@ screenhack (Display *dpy, Window window) progname, s); exit (1); } + if (s) free (s); - if (!get_boolean_resource ("root", "Boolean")) + if (controller == terminal_controller) + duration = 999999; /* this one runs "forever" */ + + while (1) { - XWindowAttributes xgwa; - XGetWindowAttributes (dpy, window, &xgwa); - XSelectInput (dpy, window, - xgwa.your_event_mask | - KeyPressMask | ButtonPressMask | ExposureMask); - } + if (random_p) + controller = controllers[random() % (countof(controllers))]; - apple2 (dpy, window, duration, controller); - XSync (dpy, False); + apple2 (dpy, window, duration, controller); + XSync (dpy, False); + } }