X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fbsod.c;h=ce2e496916d38eae5328a860a4702f67cf7b8a60;hb=6f5482d73adb0165c0130bb47d852644ab0c4869;hp=e42d708202b8c09b75798058ecd691bc977ae7b4;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/hacks/bsod.c b/hacks/bsod.c index e42d7082..ce2e4969 100644 --- a/hacks/bsod.c +++ b/hacks/bsod.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1998-2006 Jamie Zawinski +/* xscreensaver, Copyright (c) 1998-2011 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 @@ -56,10 +56,13 @@ #ifdef DO_XPM # include "images/amiga.xpm" # include "images/hmac.xpm" +# include "images/osx_10_2.xpm" +# include "images/osx_10_3.xpm" #endif #include "images/atari.xbm" #include "images/mac.xbm" #include "images/macbomb.xbm" +#include "images/atm.xbm" #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) @@ -69,9 +72,9 @@ typedef enum { EOF=0, LEFT, CENTER, RIGHT, LEFT_FULL, CENTER_FULL, RIGHT_FULL, COLOR, INVERT, MOVETO, MARGINS, - CURSOR_BLOCK, CURSOR_LINE, RECT, COPY, IMG, + CURSOR_BLOCK, CURSOR_LINE, RECT, COPY, PIXMAP, IMG, PAUSE, CHAR_DELAY, LINE_DELAY, - LOOP + LOOP, RESET } bsod_event_type; struct bsod_event { @@ -91,6 +94,8 @@ struct bsod_state { Bool wrap_p; Bool scroll_p; + Pixmap pixmap; /* Source image used by BSOD_PIXMAP */ + int x, y; /* current text-drawing position */ int current_left; /* don't use this */ @@ -236,6 +241,13 @@ struct bsod_state { (bst)->pos++; \ } while (0) +/* Copy a rect from bst->pixmap to the window. + */ +#define BSOD_PIXMAP(bst,srcx,srcy,w,h,tox,toy) do { \ + BSOD_COPY(bst,srcx,srcy,w,h,tox,toy); \ + (bst)->queue[(bst)->pos-1].type = PIXMAP; \ + } while (0) + /* Load a random image (or the desktop) onto the window. */ #define BSOD_IMG(bst) do { \ @@ -254,6 +266,14 @@ struct bsod_state { (bst)->pos++; \ } while (0) +/* Restart the whole thing from the beginning. + */ +#define BSOD_RESET(bst) do { \ + ensure_queue (bst); \ + (bst)->queue[(bst)->pos].type = RESET; \ + (bst)->pos++; \ + } while (0) + static void ensure_queue (struct bsod_state *bst) @@ -430,6 +450,7 @@ bsod_pop (struct bsod_state *bst) if (! bst->queue[bst->pos].arg3) /* "done once" */ { position_for_text (bst, s); + bst->queue[bst->pos].arg4 = (void *) bst->queue[bst->pos].type; bst->queue[bst->pos].type = LEFT; if (type == CENTER_FULL || @@ -496,6 +517,7 @@ bsod_pop (struct bsod_state *bst) return 0; } case COPY: + case PIXMAP: { int srcx = (long) bst->queue[bst->pos].arg1; int srcy = (long) bst->queue[bst->pos].arg2; @@ -503,7 +525,9 @@ bsod_pop (struct bsod_state *bst) int h = (long) bst->queue[bst->pos].arg4; int tox = (long) bst->queue[bst->pos].arg5; int toy = (long) bst->queue[bst->pos].arg6; - XCopyArea (bst->dpy, bst->window, bst->window, bst->gc, + XCopyArea (bst->dpy, + (type == PIXMAP ? bst->pixmap : bst->window), + bst->window, bst->gc, srcx, srcy, w, h, tox, toy); bst->pos++; return 0; @@ -581,6 +605,23 @@ bsod_pop (struct bsod_state *bst) abort(); return 0; } + case RESET: + { + int i; + for (i = 0; i < bst->queue_size; i++) + switch (bst->queue[i].type) { + case LEFT: case LEFT_FULL: + case CENTER: case CENTER_FULL: + case RIGHT: case RIGHT_FULL: + bst->queue[i].arg2 = bst->queue[i].arg1; + bst->queue[i].arg3 = 0; + bst->queue[i].type = (bsod_event_type) bst->queue[i].arg4; + break; + default: break; + } + bst->pos = 0; + return 0; + } case EOF: { bst->pos = -1; @@ -617,7 +658,13 @@ make_bsod_state (Display *dpy, Window window, If the window is big: use ".bigFont" if it is loadable, else use ".bigFont2". */ - if (bst->xgwa.height < 640) + if ( +# ifdef USE_IPHONE + 1 +# else + bst->xgwa.height < 640 +# endif + ) { sprintf (buf1, "%.100s.font", name); sprintf (buf2, "%.100s.font", class); @@ -675,12 +722,14 @@ make_bsod_state (Display *dpy, Window window, static void -free_bsod_state ( struct bsod_state *bst) +free_bsod_state (struct bsod_state *bst) { int i; if (bst->free_cb) bst->free_cb (bst); + if (bst->pixmap) + XFreePixmap(bst->dpy, bst->pixmap); XFreeFont (bst->dpy, bst->font); XFreeGC (bst->dpy, bst->gc); @@ -903,7 +952,7 @@ windows_xp (Display *dpy, Window window) "Physical memory dump complete.\n" "Contact your system administrator or technical support group for " "further\n" - "assitance.\n"); + "assistance.\n"); XClearWindow (dpy, window); return bst; @@ -976,6 +1025,52 @@ windows_other (Display *dpy, Window window) } +/* As seen in Portal 2. By jwz. + */ +static struct bsod_state * +glados (Display *dpy, Window window) +{ + struct bsod_state *bst = make_bsod_state (dpy, window, "glaDOS", "GlaDOS"); + const char * panicstr[] = { + "\n", + "MOLTEN CORE WARNING\n", + "\n", + "An operator error exception has occurred at FISSREAC0020093:09\n", + "FISSREAC0020077:14 FISSREAC0020023:17 FISSREAC0020088:22\n", + "neutron multiplication rate at spikevalue 99999999\n", + "\n", + "* Press any key to vent radiological emissions into atmosphere.\n", + "* Consult reactor core manual for instructions on proper reactor core\n", + "maintenance and repair.\n", + "\n", + "Press any key to continue\n", + }; + + int i; + + bst->y = ((bst->xgwa.height - + ((bst->font->ascent + bst->font->descent) * countof(panicstr))) + / 2); + + BSOD_MOVETO (bst, 0, bst->y); + BSOD_INVERT (bst); + BSOD_TEXT (bst, CENTER, "OPERATOR ERROR\n"); + BSOD_INVERT (bst); + for (i = 0; i < countof(panicstr); i++) + BSOD_TEXT (bst, CENTER, panicstr[i]); + BSOD_PAUSE (bst, 1000000); + BSOD_INVERT (bst); + BSOD_RECT (bst, True, 0, 0, bst->xgwa.width, bst->xgwa.height); + BSOD_INVERT (bst); + BSOD_PAUSE (bst, 250000); + BSOD_RESET (bst); + + XClearWindow (dpy, window); + return bst; +} + + + /* SCO OpenServer 5 panic, by Tom Kelly */ static struct bsod_state * @@ -1487,7 +1582,7 @@ mac1 (Display *dpy, Window window) English, French, German, and Japanese overlayed transparently. */ static struct bsod_state * -macx (Display *dpy, Window window) +macx_10_0 (Display *dpy, Window window) { struct bsod_state *bst = make_bsod_state (dpy, window, "macx", "MacX"); @@ -1509,6 +1604,18 @@ macx (Display *dpy, Window window) pixmap = xpm_data_to_pixmap (dpy, window, (char **) happy_mac, &pix_w, &pix_h, &mask); +# ifdef USE_IPHONE + if (pixmap) + { + pixmap = double_pixmap (dpy, bst->gc, bst->xgwa.visual, + bst->xgwa.depth, pixmap, pix_w, pix_h); + mask = double_pixmap (dpy, bst->gc, bst->xgwa.visual, + 1, mask, pix_w, pix_h); + pix_w *= 2; + pix_h *= 2; + } +# endif + x = (bst->xgwa.width - pix_w) / 2; y = (bst->xgwa.height - pix_h) / 2; if (y < 0) y = 0; @@ -1558,6 +1665,62 @@ macx (Display *dpy, Window window) } +# ifdef DO_XPM +static struct bsod_state * +macx_10_2 (Display *dpy, Window window, Bool v10_3_p) +{ + struct bsod_state *bst = make_bsod_state (dpy, window, "macx", "MacX"); + + Pixmap pixmap = 0; + int pix_w = 0, pix_h = 0; + int x, y; + + pixmap = xpm_data_to_pixmap (dpy, window, + (char **) (v10_3_p ? osx_10_3 : osx_10_2), + &pix_w, &pix_h, 0); + if (! pixmap) abort(); + +#if 0 + if (bst->xgwa.height > 600) /* scale up the bitmap */ + { + pixmap = double_pixmap (dpy, bst->gc, bst->xgwa.visual, bst->xgwa.depth, + pixmap, pix_w, pix_h); + if (! pixmap) abort(); + pix_w *= 2; + pix_h *= 2; + } +#endif + + BSOD_IMG (bst); + BSOD_PAUSE (bst, 2000000); + + bst->pixmap = pixmap; + + x = (bst->xgwa.width - pix_w) / 2; + y = ((bst->xgwa.height - pix_h) / 2); + BSOD_PIXMAP (bst, 0, 0, pix_w, pix_h, x, y); + + return bst; +} +# endif /* DO_XPM */ + + +static struct bsod_state * +macx (Display *dpy, Window window) +{ +# ifdef DO_XPM + switch (random() % 3) { + case 0: return macx_10_0 (dpy, window); break; + case 1: return macx_10_2 (dpy, window, False); break; + case 2: return macx_10_2 (dpy, window, True); break; + default: abort(); + } +# else /* !DO_XPM */ + return macx_10_0 (dpy, window); +# endif /* !DO_XPM */ +} + + #ifndef HAVE_COCOA /* #### I have no idea how to implement this without real plane-masks. I don't think it would look right if done with alpha-transparency... */ @@ -2212,15 +2375,14 @@ hppa_linux (Display *dpy, Window window) make_bsod_state (dpy, window, "hppalinux", "HPPALinux"); int i = 0; - const char *sysname; + const char *release, *sysname, *gccversion, *version; long int linedelay = 0; __extension__ struct { long int delay; const char *string; } linux_panic[] = {{ 0, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" "\n\n\n\n\n\n\n\n\n\n\n\n\n" }, - { 0, "Linux version 2.6.0-test11-pa2 (root@%s) " - "(gcc version 3.3.2 (Debian)) #2 Mon Dec 8 06:09:27 GMT 2003\n" }, + { 0, "Linux version %s (root@%s) (gcc version %s) %s\n" }, { 4000, "FP[0] enabled: Rev 1 Model 16\n" }, { 10, "The 32-bit Kernel has started...\n" }, { -1, "Determining PDC firmware type: System Map.\n" }, @@ -2290,7 +2452,7 @@ hppa_linux (Display *dpy, Window window) { -1, "Soft power switch enabled, polling @ 0xf0400804.\n" }, { -1, "pty: 256 Unix98 ptys configured\n" }, { -1, "Generic RTC Driver v1.07\n" }, - { -1, "Serial: 8250/16550 driver $Revision: 1.85 $ 13 ports, " + { -1, "Serial: 8250/16550 driver $Revision: 1.97 $ 13 ports, " "IRQ sharing disabled\n" }, { -1, "ttyS0 at I/O 0x3f8 (irq = 0) is a 16550A\n" }, { -1, "ttyS1 at I/O 0x2f8 (irq = 0) is a 16550A\n" }, @@ -2350,22 +2512,38 @@ hppa_linux (Display *dpy, Window window) bst->left_margin = bst->right_margin = 10; bst->top_margin = bst->bottom_margin = 10; + release = "2.6.0-test11-pa2"; sysname = "hppa"; + version = "#2 Mon Dec 8 06:09:27 GMT 2003"; # ifdef HAVE_UNAME { struct utsname uts; char *s; if (uname (&uts) >= 0) - sysname = uts.nodename; + { + sysname = uts.nodename; + if (!strcmp (uts.sysname, "Linux")) + { + release = uts.release; + version = uts.version; + } + } s = strchr (sysname, '.'); if (s) *s = 0; } # endif /* !HAVE_UNAME */ +# if (defined (__GNUC__) && defined (__VERSION__)) + gccversion = __VERSION__; +# else /* !(defined (__GNUC__) && defined (__VERSION__)) */ + gccversion = "3.3.2 (Debian)"; +# endif /* !(defined (__GNUC__) && defined (__VERSION__)) */ + /* Insert current host name into banner on line 2 */ { char ss[1024]; - sprintf (ss, linux_panic[1].string, sysname); + snprintf (ss, 1024, linux_panic[1].string, + release, sysname, gccversion, version); linux_panic[1].string = ss; } @@ -3388,6 +3566,7 @@ static void a2controller_crash(apple2_sim_t *sim, int *stepno, case A2CONTROLLER_FREE: free(mine); + mine = 0; break; } } @@ -3430,6 +3609,61 @@ apple2crash (Display *dpy, Window window) } +/* A crash spotted on a cash machine circa 2006, by jwz. I didn't note + what model it was; probably a Tranax Mini-Bank 1000 or similar vintage. + */ +static struct bsod_state * +atm (Display *dpy, Window window) +{ + struct bsod_state *bst = make_bsod_state (dpy, window, "atm", "ATM"); + + Pixmap pixmap = 0; + int pix_w = atm_width; + int pix_h = atm_height; + int x, y, i = 0; + float scale = 0.48; + + XClearWindow (dpy, window); + + pixmap = XCreatePixmapFromBitmapData (dpy, window, (char *) atm_bits, + atm_width, atm_height, + bst->fg, bst->bg, bst->xgwa.depth); + + while (pix_w <= bst->xgwa.width * scale && + pix_h <= bst->xgwa.height * scale) + { + pixmap = double_pixmap (dpy, bst->gc, bst->xgwa.visual, bst->xgwa.depth, + pixmap, pix_w, pix_h); + pix_w *= 2; + pix_h *= 2; + i++; + } + + x = (bst->xgwa.width - pix_w) / 2; + y = (bst->xgwa.height - pix_h) / 2; + if (y < 0) y = 0; + + if (i > 0) + { + int j; + XSetForeground (dpy, bst->gc, + get_pixel_resource (dpy, bst->xgwa.colormap, + "atm.background", + "ATM.Background")); + for (j = -1; j < pix_w; j += i+1) + XDrawLine (bst->dpy, pixmap, bst->gc, j, 0, j, pix_h); + for (j = -1; j < pix_h; j += i+1) + XDrawLine (bst->dpy, pixmap, bst->gc, 0, j, pix_w, j); + } + + XCopyArea (dpy, pixmap, window, bst->gc, 0, 0, pix_w, pix_h, x, y); + + XFreePixmap (dpy, pixmap); + + return bst; +} + + /***************************************************************************** *****************************************************************************/ @@ -3465,6 +3699,8 @@ static const struct { { "MSDOS", msdos }, { "Nvidia", nvidia }, { "Apple2", apple2crash }, + { "ATM", atm }, + { "GLaDOS", glados }, }; @@ -3686,6 +3922,8 @@ bsod_event (Display *dpy, Window window, void *closure, XEvent *event) /* pick a new mode and restart when mouse clicked, or certain keys typed. */ if (event->type == ButtonPress) + return True; + else if (event->type == ButtonRelease) reset_p = True; else if (event->type == KeyPress) { @@ -3753,6 +3991,8 @@ static const char *bsod_defaults [] = { "*doMSDOS: True", "*doOS2: True", "*doNvidia: True", + "*doATM: True", + "*doGLaDOS: True", "*font: 9x15bold", "*font2: -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*", @@ -3769,6 +4009,9 @@ static const char *bsod_defaults [] = { ".windowslh.background: #AA0000", /* EGA color 0x04. */ ".windowslh.background2: #AAAAAA", /* EGA color 0x07. */ + ".glaDOS.foreground: White", + ".glaDOS.background: #0000AA", /* EGA color 0x01. */ + ".amiga.foreground: #FF0000", ".amiga.background: Black", ".amiga.background2: White", @@ -3845,19 +4088,27 @@ static const char *bsod_defaults [] = { ".os2.foreground: White", ".os2.background: Black", - "*dontClearRoot: True", + ".atm.foreground: Black", + ".atm.background: #FF6600", - "*apple2TVColor: 50", - "*apple2TVTint: 5", - "*apple2TVBrightness: 10", - "*apple2TVContrast: 90", - "*apple2SimulateUser: True", + "*dontClearRoot: True", ANALOGTV_DEFAULTS #ifdef HAVE_XSHM_EXTENSION "*useSHM: True", #endif + +# ifdef USE_IPHONE + "*font: Courier-Bold 9", + ".amiga.font: Courier-Bold 12", + ".macsbug.font: Courier-Bold 5", + ".sco.font: Courier-Bold 9", + ".hvx.font: Courier-Bold 9", + ".bsd.font: Courier-Bold 9", + ".solaris.font: Courier-Bold 6", +# endif + 0 }; @@ -3915,6 +4166,10 @@ static const XrmOptionDescRec bsod_options [] = { { "-no-msdos", ".doMSDOS", XrmoptionNoArg, "False" }, { "-os2", ".doOS2", XrmoptionNoArg, "True" }, { "-no-os2", ".doOS2", XrmoptionNoArg, "False" }, + { "-atm", ".doATM", XrmoptionNoArg, "True" }, + { "-no-atm", ".doATM", XrmoptionNoArg, "False" }, + { "-glados", ".doGLaDOS", XrmoptionNoArg, "True" }, + { "-no-glados", ".doGLaDOS", XrmoptionNoArg, "False" }, ANALOGTV_OPTIONS { 0, 0, 0, 0 } };