From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / bsod.c
1 /* xscreensaver, Copyright (c) 1998-2016 Jamie Zawinski <jwz@jwz.org>
2  *
3  * Permission to use, copy, modify, distribute, and sell this software and its
4  * documentation for any purpose is hereby granted without fee, provided that
5  * the above copyright notice appear in all copies and that both that
6  * copyright notice and this permission notice appear in supporting
7  * documentation.  No representations are made about the suitability of this
8  * software for any purpose.  It is provided "as is" without express or 
9  * implied warranty.
10  *
11  * Blue Screen of Death: the finest in personal computer emulation.
12  * Concept cribbed from Stephen Martin <smartin@mks.com>;
13  * this version written by jwz, 4-Jun-98.
14  * Mostly rewritten by jwz, 20-Feb-2006.
15  */
16
17
18 /* To add a new mode:
19
20     - Define a function `new_os(dpy,win)' that returns a `bsod_state' struct.
21     - Draw on the window to set up its frame-zero state.  This must be fast:
22       no sleeping or long loops!
23     - Populate the bsod_state structure with additional actions to take by
24       using the various BSOD_ macros.  Note that you can control the delays
25       when printing text on a per-character or per-line basis.
26     - Insert your function in the `all_modes' table.
27     - Add a `doXXX' entry to `bsod_defaults'.
28     - Add fonts or colors to `bsod_defaults' if necessary.
29
30    Look at windows_31() for a simple example.
31
32    Look at linux_fsck() for a more complicated example with random behavior.
33
34    Or, you can bypass all that: look at nvidia() for a really hairy example.
35  */
36
37
38 #include "screenhack.h"
39 #include "xpm-pixmap.h"
40 #include "apple2.h"
41
42 #include <ctype.h>
43 #include <time.h>
44
45 #ifdef HAVE_XSHM_EXTENSION
46 #include "xshm.h"
47 #endif
48
49 #ifdef HAVE_UNAME
50 # include <sys/utsname.h>
51 #endif /* HAVE_UNAME */
52
53 #if defined(HAVE_GDK_PIXBUF) || defined(HAVE_XPM) || defined(HAVE_JWXYZ)
54 # define DO_XPM
55 #endif
56
57 #ifdef DO_XPM
58 # include "images/amiga.xpm"
59 # include "images/hmac.xpm"
60 # include "images/osx_10_2.xpm"
61 # include "images/osx_10_3.xpm"
62 # include "images/android.xpm"
63 #endif
64 #include "images/atari.xbm"
65 #include "images/mac.xbm"
66 #include "images/macbomb.xbm"
67 #include "images/atm.xbm"
68
69 #undef countof
70 #define countof(x) (sizeof((x))/sizeof((*x)))
71
72 # undef MIN
73 # undef MAX
74 # define MIN(A,B) ((A)<(B)?(A):(B))
75 # define MAX(A,B) ((A)>(B)?(A):(B))
76
77 #undef EOF
78 typedef enum { EOF=0, 
79                LEFT, CENTER, RIGHT, 
80                LEFT_FULL, CENTER_FULL, RIGHT_FULL, 
81                COLOR, INVERT, MOVETO, MARGINS,
82                CURSOR_BLOCK, CURSOR_LINE, RECT, COPY, PIXMAP, IMG, FONT,
83                PAUSE, CHAR_DELAY, LINE_DELAY,
84                LOOP, RESET
85 } bsod_event_type;
86
87 struct bsod_event {
88   bsod_event_type type;
89   void *arg1, *arg2, *arg3, *arg4, *arg5, *arg6;
90 };
91
92 struct bsod_state {
93   Display *dpy;
94   Window window;
95   XWindowAttributes xgwa;
96   XFontStruct *font, *fontA, *fontB, *fontC;
97   unsigned long fg, bg;
98   GC gc;
99   int left_margin, right_margin;        /* for text wrapping */
100   int top_margin, bottom_margin;        /* for text scrolling */
101   Bool wrap_p;
102   Bool scroll_p;
103
104   Pixmap pixmap;                /* Source image used by BSOD_PIXMAP */
105
106   int x, y;                     /* current text-drawing position */
107   int current_left;             /* don't use this */
108
109   int pos;                      /* position in queue */
110   int queue_size;
111   struct bsod_event *queue;
112
113   unsigned long char_delay;     /* delay between printing characters */
114   unsigned long line_delay;     /* delay between printing lines */
115
116   Bool macx_eol_kludge;
117
118   void *closure;
119   int  (*draw_cb) (struct bsod_state *);
120   void (*free_cb) (struct bsod_state *);
121
122   async_load_state *img_loader;
123 };
124
125
126 # if !defined(__GNUC__) && !defined(__extension__)
127   /* don't warn about "string length is greater than the length ISO C89
128      compilers are required to support" in these string constants... */
129 #  define  __extension__ /**/
130 # endif
131
132
133 /* Draw text at the current position; align is LEFT, CENTER, RIGHT, or *_FULL
134    (meaning to clear the whole line margin to margin).
135  */
136 #define BSOD_TEXT(bst,align,string) do { \
137   ensure_queue (bst); \
138   (bst)->queue[(bst)->pos].type = (align); \
139   (bst)->queue[(bst)->pos].arg1 = (void *) strdup (__extension__ (string)); \
140   (bst)->queue[(bst)->pos].arg2 = (bst)->queue[(bst)->pos].arg1; \
141   (bst)->queue[(bst)->pos].arg3 = (void *) 0; \
142   (bst)->pos++; \
143   } while (0)
144
145 /* Flip the foreground and background colors
146  */
147 #define BSOD_INVERT(bst) do { \
148   ensure_queue (bst); \
149   (bst)->queue[(bst)->pos].type = INVERT; \
150   (bst)->pos++; \
151   } while (0)
152
153 /* Set the foreground and background colors to the given pixels
154  */
155 #define BSOD_COLOR(bst,fg,bg) do { \
156   ensure_queue (bst); \
157   (bst)->queue[(bst)->pos].type = COLOR; \
158   (bst)->queue[(bst)->pos].arg1 = (void *) fg; \
159   (bst)->queue[(bst)->pos].arg2 = (void *) bg; \
160   (bst)->pos++; \
161   } while (0)
162
163 /* Set the position of the next text.
164    Note that this is the baseline: lower left corner of next char printed.
165  */
166 #define BSOD_MOVETO(bst,x,y) do { \
167   ensure_queue (bst); \
168   (bst)->queue[(bst)->pos].type = MOVETO; \
169   (bst)->queue[(bst)->pos].arg1 = (void *) ((long) (x)); \
170   (bst)->queue[(bst)->pos].arg2 = (void *) ((long) (y)); \
171   (bst)->pos++; \
172   } while (0)
173
174 /* Delay for at least the given number of microseconds.
175  */
176 #define BSOD_PAUSE(bst,usec) do { \
177   ensure_queue (bst); \
178   (bst)->queue[(bst)->pos].type = PAUSE; \
179   (bst)->queue[(bst)->pos].arg1 = (void *) ((long) (usec)); \
180   (bst)->pos++; \
181   } while (0)
182
183 /* Set the delay after each character is printed.
184  */
185 #define BSOD_CHAR_DELAY(bst,usec) do { \
186   ensure_queue (bst); \
187   (bst)->queue[(bst)->pos].type = CHAR_DELAY; \
188   (bst)->queue[(bst)->pos].arg1 = (void *) ((long) (usec)); \
189   (bst)->pos++; \
190   } while (0)
191
192 /* Set the delay after each newline.
193  */
194 #define BSOD_LINE_DELAY(bst,usec) do { \
195   ensure_queue (bst); \
196   (bst)->queue[(bst)->pos].type = LINE_DELAY; \
197   (bst)->queue[(bst)->pos].arg1 = (void *) (usec); \
198   (bst)->pos++; \
199   } while (0)
200
201 /* Set the prevailing left/right margins (used when strings have
202    embedded newlines, and when centering or right-justifying text.)
203  */
204 #define BSOD_MARGINS(bst,left,right) do { \
205   ensure_queue (bst); \
206   (bst)->queue[(bst)->pos].type = MARGINS; \
207   (bst)->queue[(bst)->pos].arg1 = (void *) ((long) (left)); \
208   (bst)->queue[(bst)->pos].arg2 = (void *) ((long) (right)); \
209   (bst)->pos++; \
210   } while (0)
211
212 /* Draw a blinking cursor; type is CURSOR_BLOCK or CURSOR_LINE.
213    usec is how long 1/2 of a cycle is.  count is how many times to blink.
214    (You can pass a gigantic number if this is the last thing in your mode.)
215  */
216 #define BSOD_CURSOR(bst,ctype,usec,count) do { \
217   ensure_queue (bst); \
218   (bst)->queue[(bst)->pos].type = (ctype); \
219   (bst)->queue[(bst)->pos].arg1 = (void *) (usec); \
220   (bst)->queue[(bst)->pos].arg2 = (void *) (count); \
221   (bst)->pos++; \
222   } while (0)
223
224 /* Draw or fill a rectangle.  You can set line-width in the GC.
225  */
226 #define BSOD_RECT(bst,fill,x,y,w,h) do { \
227   ensure_queue (bst); \
228   (bst)->queue[(bst)->pos].type = RECT; \
229   (bst)->queue[(bst)->pos].arg1 = (void *) ((long) (fill)); \
230   (bst)->queue[(bst)->pos].arg2 = (void *) ((long) (x)); \
231   (bst)->queue[(bst)->pos].arg3 = (void *) ((long) (y)); \
232   (bst)->queue[(bst)->pos].arg4 = (void *) ((long) (w)); \
233   (bst)->queue[(bst)->pos].arg5 = (void *) ((long) (h)); \
234   (bst)->pos++; \
235   } while (0)
236
237 /* Copy a rect from the window, to the window.
238  */
239 #define BSOD_COPY(bst,srcx,srcy,w,h,tox,toy) do { \
240   ensure_queue (bst); \
241   (bst)->queue[(bst)->pos].type = COPY; \
242   (bst)->queue[(bst)->pos].arg1 = (void *) ((long) (srcx)); \
243   (bst)->queue[(bst)->pos].arg2 = (void *) ((long) (srcy)); \
244   (bst)->queue[(bst)->pos].arg3 = (void *) ((long) (w)); \
245   (bst)->queue[(bst)->pos].arg4 = (void *) ((long) (h)); \
246   (bst)->queue[(bst)->pos].arg5 = (void *) ((long) (tox)); \
247   (bst)->queue[(bst)->pos].arg6 = (void *) ((long) (toy)); \
248   (bst)->pos++; \
249   } while (0)
250
251 /* Copy a rect from bst->pixmap to the window.
252  */
253 #define BSOD_PIXMAP(bst,srcx,srcy,w,h,tox,toy) do { \
254   BSOD_COPY(bst,srcx,srcy,w,h,tox,toy); \
255   (bst)->queue[(bst)->pos-1].type = PIXMAP; \
256   } while (0)
257
258 /* Load a random image (or the desktop) onto the window.
259  */
260 #define BSOD_IMG(bst) do { \
261   ensure_queue (bst); \
262   (bst)->queue[(bst)->pos].type = IMG; \
263   (bst)->pos++; \
264   } while (0)
265
266 /* Switch between fonts A, B and C.
267  */
268 #define BSOD_FONT(bst,n) do { \
269   ensure_queue (bst); \
270   (bst)->queue[(bst)->pos].type = FONT; \
271   (bst)->queue[(bst)->pos].arg1 = (void *) ((long) (n)); \
272   (bst)->pos++; \
273   } while (0)
274
275 /* Jump around in the state table.  You can use this as the last thing 
276    in your state table to repeat the last N elements forever.
277  */
278 #define BSOD_LOOP(bst,off) do { \
279   ensure_queue (bst); \
280   (bst)->queue[(bst)->pos].type = LOOP; \
281   (bst)->queue[(bst)->pos].arg1 = (void *) (off); \
282   (bst)->pos++; \
283   } while (0)
284
285 /* Restart the whole thing from the beginning.
286  */
287 #define BSOD_RESET(bst) do { \
288   ensure_queue (bst); \
289   (bst)->queue[(bst)->pos].type = RESET; \
290   (bst)->pos++; \
291   } while (0)
292
293
294 static void
295 ensure_queue (struct bsod_state *bst)
296 {
297   int n;
298   if (bst->pos + 1 < bst->queue_size)
299     return;
300
301   n = bst->queue_size + 10;
302   if (n < 100) n *= 2;
303   n *= 1.2;
304
305   bst->queue = (struct bsod_event *) 
306     realloc (bst->queue, n * sizeof(*bst->queue));
307   if (!bst->queue) abort();
308   memset (bst->queue + bst->queue_size, 0, 
309           (n - bst->queue_size) * sizeof(*bst->queue));
310   bst->queue_size = n;
311 }
312
313
314 static void
315 position_for_text (struct bsod_state *bst, const char *line)
316 {
317   int max_width = 0;
318
319   const char *start = line;
320
321   if (bst->queue[bst->pos].type != LEFT &&
322       bst->queue[bst->pos].type != LEFT_FULL)
323     while (*start)
324       {
325         int dir, ascent, descent;
326         XCharStruct ov;
327         const char *end = start;
328         while (*end && *end != '\r' && *end != '\n')
329           end++;
330
331         XTextExtents (bst->font, start, end-start,
332                       &dir, &ascent, &descent, &ov);
333         if (ov.width > max_width)
334           max_width = ov.width;
335         if (!*end) break;
336         start = end+1;
337       }
338
339   switch (bst->queue[bst->pos].type) {
340   case LEFT:
341   case LEFT_FULL:
342     bst->current_left = bst->left_margin;
343     break;
344   case RIGHT:
345   case RIGHT_FULL:
346     bst->x = max_width - bst->right_margin;
347     bst->current_left = bst->x;
348     break;
349   case CENTER:
350   case CENTER_FULL:
351     {
352       int w = (bst->xgwa.width - bst->left_margin - bst->right_margin -
353                max_width);
354       if (w < 0) w = 0;
355       bst->x = bst->left_margin + (w / 2);
356       bst->current_left = bst->x;
357       break;
358     }
359   default:
360     abort();
361   }
362 }
363
364
365 static void
366 bst_crlf (struct bsod_state *bst)
367 {
368   int lh = bst->font->ascent + bst->font->descent;
369   bst->x = bst->current_left;
370   if (!bst->scroll_p ||
371       bst->y + lh < bst->xgwa.height - bst->bottom_margin)
372     bst->y += lh;
373   else
374     {
375       int w = bst->xgwa.width  - bst->right_margin - bst->left_margin;
376       int h = bst->xgwa.height - bst->top_margin - bst->bottom_margin;
377       XCopyArea (bst->dpy, bst->window, bst->window, bst->gc,
378                  bst->left_margin,
379                  bst->top_margin + lh,
380                  w, h - lh,
381                  bst->left_margin,
382                  bst->top_margin);
383       XClearArea (bst->dpy, bst->window,
384                   bst->left_margin, bst->top_margin + h - lh, w, lh, False);
385     }
386 }
387
388
389 static void
390 draw_char (struct bsod_state *bst, char c)
391 {
392   if (!c)
393     abort();
394   else if (c == '\r')
395     {
396       bst->x = bst->current_left;
397     }
398   else if (c == '\n')
399     {
400       if (bst->macx_eol_kludge)
401         {
402           /* Special case for the weird way OSX crashes print newlines... */
403           XDrawImageString (bst->dpy, bst->window, bst->gc, 
404                             bst->x, bst->y, " ", 1);
405           XDrawImageString (bst->dpy, bst->window, bst->gc, 
406                             bst->x, 
407                             bst->y + bst->font->ascent + bst->font->descent,
408                             " ", 1);
409         }
410       bst_crlf (bst);
411     }
412   else if (c == '\b')   /* backspace */
413     {
414       int cw = (bst->font->per_char
415                 ? bst->font->per_char['n'-bst->font->min_char_or_byte2].width
416                 : bst->font->min_bounds.width);
417       bst->x -= cw;
418       if (bst->x < bst->left_margin)
419         bst->x = bst->left_margin;
420     }
421   else
422     {
423       int dir, ascent, descent;
424       XCharStruct ov;
425       XTextExtents (bst->font, &c, 1, &dir, &ascent, &descent, &ov);
426
427       if (bst->wrap_p && 
428           bst->x + ov.width > bst->xgwa.width - bst->right_margin)
429         bst_crlf (bst);
430
431       XDrawImageString (bst->dpy, bst->window, bst->gc, 
432                         bst->x, bst->y, &c, 1);
433       bst->x += ov.width;
434     }
435 }
436
437
438 static long
439 bsod_pop (struct bsod_state *bst)
440 {
441   bsod_event_type type = bst->queue[bst->pos].type;
442
443   if (bst->draw_cb)
444     return bst->draw_cb (bst);
445
446   if (bst->pos < 0)   /* already done */
447     abort();
448
449   switch (type) {
450
451   case LEFT:   case LEFT_FULL:
452   case CENTER: case CENTER_FULL:
453   case RIGHT:  case RIGHT_FULL:
454     {
455       const char *s = (const char *) bst->queue[bst->pos].arg2;
456       char c;
457
458       if (! *s)
459         {
460           long delay = bst->line_delay;
461           bst->pos++;
462           bst->current_left = bst->left_margin;
463           return delay;
464         }
465
466       if (! bst->queue[bst->pos].arg3)    /* "done once" */
467         {
468           position_for_text (bst, s);
469           bst->queue[bst->pos].arg4 = (void *) bst->queue[bst->pos].type;
470           bst->queue[bst->pos].type = LEFT;
471
472           if (type == CENTER_FULL ||
473               type == LEFT_FULL ||
474               type == RIGHT_FULL)
475             {
476               XSetForeground (bst->dpy, bst->gc, bst->bg);
477               XFillRectangle (bst->dpy, bst->window, bst->gc,
478                               0,
479                               bst->y - bst->font->ascent,
480                               bst->xgwa.width,
481                               bst->font->ascent + bst->font->descent);
482               XSetForeground (bst->dpy, bst->gc, bst->fg);
483             }
484         }
485
486       c = *s++;
487       draw_char (bst, c);
488       bst->queue[bst->pos].arg2 = (void *) s;
489       bst->queue[bst->pos].arg3 = (void *) 1;  /* "done once" */
490
491       return (c == '\r' || c == '\n'
492               ? bst->line_delay
493               : bst->char_delay);
494     }
495   case INVERT:
496     {
497       unsigned long swap = bst->fg;
498       bst->fg = bst->bg;
499       bst->bg = swap;
500       XSetForeground (bst->dpy, bst->gc, bst->fg);
501       XSetBackground (bst->dpy, bst->gc, bst->bg);
502       bst->pos++;
503       return 0;
504     }
505   case COLOR:
506     {
507       bst->fg = (unsigned long) bst->queue[bst->pos].arg1;
508       bst->bg = (unsigned long) bst->queue[bst->pos].arg2;
509       XSetForeground (bst->dpy, bst->gc, bst->fg);
510       XSetBackground (bst->dpy, bst->gc, bst->bg);
511       bst->pos++;
512       return 0;
513     }
514   case MOVETO:
515     {
516       bst->x = (long) bst->queue[bst->pos].arg1;
517       bst->y = (long) bst->queue[bst->pos].arg2;
518       bst->pos++;
519       return 0;
520     }
521   case RECT:
522     {
523       int f = (long) bst->queue[bst->pos].arg1;
524       int x = (long) bst->queue[bst->pos].arg2;
525       int y = (long) bst->queue[bst->pos].arg3;
526       int w = (long) bst->queue[bst->pos].arg4;
527       int h = (long) bst->queue[bst->pos].arg5;
528       if (f)
529         XFillRectangle (bst->dpy, bst->window, bst->gc, x, y, w, h);
530       else
531         XDrawRectangle (bst->dpy, bst->window, bst->gc, x, y, w, h);
532       bst->pos++;
533       return 0;
534     }
535   case COPY:
536   case PIXMAP:
537     {
538       int srcx = (long) bst->queue[bst->pos].arg1;
539       int srcy = (long) bst->queue[bst->pos].arg2;
540       int w    = (long) bst->queue[bst->pos].arg3;
541       int h    = (long) bst->queue[bst->pos].arg4;
542       int tox  = (long) bst->queue[bst->pos].arg5;
543       int toy  = (long) bst->queue[bst->pos].arg6;
544       XCopyArea (bst->dpy, 
545                  (type == PIXMAP ? bst->pixmap : bst->window), 
546                  bst->window, bst->gc,
547                  srcx, srcy, w, h, tox, toy);
548       bst->pos++;
549       return 0;
550     }
551   case IMG:
552     {
553       if (bst->img_loader) abort();
554       bst->img_loader = load_image_async_simple (0, bst->xgwa.screen, 
555                                                  bst->window, bst->window,
556                                                  0, 0);
557       bst->pos++;
558       return 0;
559     }
560   case FONT:
561     {
562       switch ((long) bst->queue[bst->pos].arg1) {
563       case 0: bst->font = bst->fontA; break;
564       case 1: bst->font = bst->fontB; break;
565       case 2: bst->font = bst->fontC; break;
566       default: abort(); break;
567       }
568       XSetFont (bst->dpy, bst->gc, bst->font->fid);
569       bst->pos++;
570       return 0;
571     }
572   case PAUSE:
573     {
574       long delay = (long) bst->queue[bst->pos].arg1;
575       bst->pos++;
576       return delay;
577     }
578   case CHAR_DELAY:
579     {
580       bst->char_delay = (long) bst->queue[bst->pos].arg1;
581       bst->pos++;
582       return 0;
583     }
584   case LINE_DELAY:
585     {
586       bst->line_delay = (long) bst->queue[bst->pos].arg1;
587       bst->pos++;
588       return 0;
589     }
590   case MARGINS:
591     {
592       bst->left_margin  = (long) bst->queue[bst->pos].arg1;
593       bst->right_margin = (long) bst->queue[bst->pos].arg2;
594       bst->pos++;
595       return 0;
596     }
597   case CURSOR_BLOCK:
598   case CURSOR_LINE:
599     {
600       long delay = (long) bst->queue[bst->pos].arg1;
601       long count = (long) bst->queue[bst->pos].arg2;
602       int ox = bst->x;
603
604       if (type == CURSOR_BLOCK)
605         {
606           unsigned long swap = bst->fg;
607           bst->fg = bst->bg;
608           bst->bg = swap;
609           XSetForeground (bst->dpy, bst->gc, bst->fg);
610           XSetBackground (bst->dpy, bst->gc, bst->bg);
611           draw_char (bst, ' ');
612         }
613       else
614         {
615           draw_char (bst, (count & 1 ? ' ' : '_'));
616           draw_char (bst, ' ');
617         }
618
619       bst->x = ox;
620
621       count--;
622       bst->queue[bst->pos].arg2 = (void *) count;
623       if (count <= 0)
624         bst->pos++;
625
626       return delay;
627     }
628   case LOOP:
629     {
630       long off = (long) bst->queue[bst->pos].arg1;
631       bst->pos += off;
632       if (bst->pos < 0 || bst->pos >= bst->queue_size)
633         abort();
634       return 0;
635     }
636   case RESET:
637     {
638       int i;
639       for (i = 0; i < bst->queue_size; i++)
640         switch (bst->queue[i].type) {
641         case LEFT:   case LEFT_FULL:
642         case CENTER: case CENTER_FULL:
643         case RIGHT:  case RIGHT_FULL:
644           bst->queue[i].arg2 = bst->queue[i].arg1;
645           bst->queue[i].arg3 = 0;
646           bst->queue[i].type = (bsod_event_type) bst->queue[i].arg4;
647           break;
648         default: break;
649         }
650       bst->pos = 0;
651       return 0;
652     }
653   case EOF:
654     {
655       bst->pos = -1;
656       return -1;
657     }
658   default:
659     break;
660   }
661   abort();
662 }
663
664
665 static struct bsod_state *
666 make_bsod_state (Display *dpy, Window window,
667                  const char *name, const char *class)
668 {
669   XGCValues gcv;
670   struct bsod_state *bst;
671   char buf1[1024], buf2[1024];
672   char buf3[1024], buf4[1024];
673   char buf5[1024], buf6[1024];
674   char buf7[1024], buf8[1024];
675   const char *font1, *font2, *font3, *font4;
676
677   bst = (struct bsod_state *) calloc (1, sizeof (*bst));
678   bst->queue_size = 10;
679   bst->queue = (struct bsod_event *) calloc (bst->queue_size,
680                                              sizeof (*bst->queue));
681   bst->dpy = dpy;
682   bst->window = window;
683   XGetWindowAttributes (dpy, window, &bst->xgwa);
684
685   /* If the window is small:
686        use ".font" if it is loadable, else use ".font2".
687
688      If the window is big:
689        use ".bigFont" if it is loadable, else use ".bigFont2".
690    */
691   if (
692 # ifdef HAVE_MOBILE
693       1
694 # else
695       bst->xgwa.height < 640
696 # endif
697       )
698     {
699       sprintf (buf1, "%.100s.font", name);
700       sprintf (buf2, "%.100s.font", class);
701       sprintf (buf3, "%.100s.font2", name);
702       sprintf (buf4, "%.100s.font2", class);
703     }
704   else
705     {
706       sprintf (buf1, "%.100s.bigFont", name);
707       sprintf (buf2, "%.100s.bigFont", class);
708       sprintf (buf3, "%.100s.bigFont2", name);
709       sprintf (buf4, "%.100s.bigFont2", class);
710     }
711   sprintf (buf5, "%.100s.fontB", name);
712   sprintf (buf6, "%.100s.fontB", class);
713   sprintf (buf7, "%.100s.fontC", name);
714   sprintf (buf8, "%.100s.fontC", class);
715
716   font1 = get_string_resource (dpy, buf1, buf2);
717   font2 = get_string_resource (dpy, buf3, buf4);
718   font3 = get_string_resource (dpy, buf5, buf6);
719   font4 = get_string_resource (dpy, buf7, buf8);
720
721   /* If there was no ".mode.font2" resource also look for ".font2".
722      Under real X11, the wildcard does this, so this is redundant,
723      but jwxyz needs it because it doesn't implement wildcards.
724    */
725 # define RES2(VAR, BUF1, BUF2) do {                          \
726     if (! VAR) {                                             \
727       VAR = get_string_resource (dpy,                        \
728                                  strchr (BUF1, '.') + 1,     \
729                                  strchr (BUF2, '.') + 1);    \
730     }} while(0)
731   RES2 (font1, buf1, buf2);
732   RES2 (font2, buf3, buf4);
733   RES2 (font3, buf5, buf6);
734   RES2 (font4, buf7, buf8);
735 #undef RES2
736
737   if (font1)
738     bst->font = XLoadQueryFont (dpy, font1);
739   if (! bst->font && font2)
740     bst->font = XLoadQueryFont (dpy, font2);
741
742   /* If neither of those worked, try some defaults. */
743
744   if (! bst->font)
745     bst->font = XLoadQueryFont (dpy,"-*-courier-bold-r-*-*-*-120-*-*-m-*-*-*");
746   if (! bst->font)
747     bst->font = XLoadQueryFont (dpy, "fixed");
748   if (! bst->font)
749     abort();
750
751   if (font3)
752     bst->fontB = XLoadQueryFont (dpy, font3);
753   if (font4)
754     bst->fontC = XLoadQueryFont (dpy, font4);
755
756   if (! bst->fontB) bst->fontB = bst->font;
757   if (! bst->fontC) bst->fontC = bst->font;
758
759   bst->fontA = bst->font;
760
761
762   gcv.font = bst->font->fid;
763
764   sprintf (buf1, "%.100s.foreground", name);
765   sprintf (buf2, "%.100s.Foreground", class);
766   bst->fg = gcv.foreground = get_pixel_resource (dpy, bst->xgwa.colormap,
767                                                  buf1, buf2);
768   sprintf (buf1, "%.100s.background", name);
769   sprintf (buf2, "%.100s.Background", class);
770   bst->bg = gcv.background = get_pixel_resource (dpy, bst->xgwa.colormap,
771                                                  buf1, buf2);
772   bst->gc = XCreateGC (dpy, window, GCFont|GCForeground|GCBackground, &gcv);
773
774 #ifdef HAVE_JWXYZ
775   jwxyz_XSetAntiAliasing (dpy, bst->gc, True);
776 #endif
777
778   bst->left_margin = bst->right_margin = 10;
779   bst->x = bst->left_margin;
780   bst->y = bst->font->ascent + bst->left_margin;
781
782   XSetWindowBackground (dpy, window, gcv.background);
783   return bst;
784 }
785
786
787 static void
788 free_bsod_state (struct bsod_state *bst)
789 {
790   int i;
791
792   if (bst->free_cb)
793     bst->free_cb (bst);
794   if (bst->pixmap)
795     XFreePixmap(bst->dpy, bst->pixmap);
796
797   XFreeFont (bst->dpy, bst->font);
798   XFreeGC (bst->dpy, bst->gc);
799
800   for (i = 0; i < bst->queue_size; i++)
801     switch (bst->queue[i].type) {
802     case LEFT:   case LEFT_FULL:
803     case RIGHT:  case RIGHT_FULL:
804     case CENTER: case CENTER_FULL:
805       free ((char *) bst->queue[i].arg1);
806       break;
807     default:
808       break;
809     }
810
811   free (bst->queue);
812   free (bst);
813 }
814
815
816 static Pixmap
817 double_pixmap (Display *dpy, GC gc, Visual *visual, int depth, Pixmap pixmap,
818                int pix_w, int pix_h)
819 {
820   int x, y;
821   Pixmap p2 = XCreatePixmap(dpy, pixmap, pix_w*2, pix_h*2, depth);
822   XImage *i1 = XGetImage(dpy, pixmap, 0, 0, pix_w, pix_h, ~0L, ZPixmap);
823   XImage *i2 = XCreateImage(dpy, visual, depth, ZPixmap, 0, 0,
824                             pix_w*2, pix_h*2, 8, 0);
825   i2->data = (char *) calloc(i2->height, i2->bytes_per_line);
826   for (y = 0; y < pix_h; y++)
827     for (x = 0; x < pix_w; x++)
828       {
829         unsigned long p = XGetPixel(i1, x, y);
830         XPutPixel(i2, x*2,   y*2,   p);
831         XPutPixel(i2, x*2+1, y*2,   p);
832         XPutPixel(i2, x*2,   y*2+1, p);
833         XPutPixel(i2, x*2+1, y*2+1, p);
834       }
835   free(i1->data); i1->data = 0;
836   XDestroyImage(i1);
837   XPutImage(dpy, p2, gc, i2, 0, 0, 0, 0, i2->width, i2->height);
838   free(i2->data); i2->data = 0;
839   XDestroyImage(i2);
840   XFreePixmap(dpy, pixmap);
841   return p2;
842 }
843
844
845 /*****************************************************************************
846  *****************************************************************************/
847
848 static struct bsod_state *
849 windows_31 (Display *dpy, Window window)
850 {
851   struct bsod_state *bst = make_bsod_state (dpy, window, "windows", "Windows");
852   BSOD_INVERT (bst);
853   BSOD_TEXT   (bst, CENTER, "Windows\n");
854   BSOD_INVERT (bst);
855   BSOD_TEXT   (bst, CENTER,
856                "A fatal exception 0E has occured at F0AD:42494C4C\n"
857                "the current application will be terminated.\n"
858                "\n"
859                "* Press any key to terminate the current application.\n"
860                "* Press CTRL+ALT+DELETE again to restart your computer.\n"
861                "  You will lose any unsaved information in all applications.\n"
862                "\n"
863                "\n");
864   BSOD_TEXT   (bst, CENTER, "Press any key to continue");
865
866   bst->y = ((bst->xgwa.height -
867              ((bst->font->ascent + bst->font->descent) * 9))
868             / 2);
869
870   XClearWindow (dpy, window);
871   return bst;
872 }
873
874
875 static struct bsod_state *
876 windows_nt (Display *dpy, Window window)
877 {
878   struct bsod_state *bst = make_bsod_state (dpy, window, "nt", "NT");
879
880   BSOD_TEXT (bst, LEFT,
881    "*** STOP: 0x0000001E (0x80000003,0x80106fc0,0x8025ea21,0xfd6829e8)\n"
882    "Unhandled Kernel exception c0000047 from fa8418b4 (8025ea21,fd6829e8)\n"
883    "\n"
884    "Dll Base Date Stamp - Name             Dll Base Date Stamp - Name\n"
885    "80100000 2be154c9 - ntoskrnl.exe       80400000 2bc153b0 - hal.dll\n"
886    "80258000 2bd49628 - ncrc710.sys        8025c000 2bd49688 - SCSIPORT.SYS \n"
887    "80267000 2bd49683 - scsidisk.sys       802a6000 2bd496b9 - Fastfat.sys\n"
888    "fa800000 2bd49666 - Floppy.SYS         fa810000 2bd496db - Hpfs_Rec.SYS\n"
889    "fa820000 2bd49676 - Null.SYS           fa830000 2bd4965a - Beep.SYS\n"
890    "fa840000 2bdaab00 - i8042prt.SYS       fa850000 2bd5a020 - SERMOUSE.SYS\n"
891    "fa860000 2bd4966f - kbdclass.SYS       fa870000 2bd49671 - MOUCLASS.SYS\n"
892    "fa880000 2bd9c0be - Videoprt.SYS       fa890000 2bd49638 - NCC1701E.SYS\n"
893    "fa8a0000 2bd4a4ce - Vga.SYS            fa8b0000 2bd496d0 - Msfs.SYS\n"
894    "fa8c0000 2bd496c3 - Npfs.SYS           fa8e0000 2bd496c9 - Ntfs.SYS\n"
895    "fa940000 2bd496df - NDIS.SYS           fa930000 2bd49707 - wdlan.sys\n"
896    "fa970000 2bd49712 - TDI.SYS            fa950000 2bd5a7fb - nbf.sys\n"
897    "fa980000 2bd72406 - streams.sys        fa9b0000 2bd4975f - ubnb.sys\n"
898    "fa9c0000 2bd5bfd7 - usbser.sys         fa9d0000 2bd4971d - netbios.sys\n"
899    "fa9e0000 2bd49678 - Parallel.sys       fa9f0000 2bd4969f - serial.SYS\n"
900    "faa00000 2bd49739 - mup.sys            faa40000 2bd4971f - SMBTRSUP.SYS\n"
901    "faa10000 2bd6f2a2 - srv.sys            faa50000 2bd4971a - afd.sys\n"
902    "faa60000 2bd6fd80 - rdr.sys            faaa0000 2bd49735 - bowser.sys\n"
903    "\n"
904    "Address dword dump Dll Base                                      - Name\n"
905    "801afc20 80106fc0 80106fc0 00000000 00000000 80149905 : "
906      "fa840000 - i8042prt.SYS\n"
907    "801afc24 80149905 80149905 ff8e6b8c 80129c2c ff8e6b94 : "
908      "8025c000 - SCSIPORT.SYS\n"
909    "801afc2c 80129c2c 80129c2c ff8e6b94 00000000 ff8e6b94 : "
910      "80100000 - ntoskrnl.exe\n"
911    "801afc34 801240f2 80124f02 ff8e6df4 ff8e6f60 ff8e6c58 : "
912      "80100000 - ntoskrnl.exe\n"
913    "801afc54 80124f16 80124f16 ff8e6f60 ff8e6c3c 8015ac7e : "
914      "80100000 - ntoskrnl.exe\n"
915    "801afc64 8015ac7e 8015ac7e ff8e6df4 ff8e6f60 ff8e6c58 : "
916      "80100000 - ntoskrnl.exe\n"
917    "801afc70 80129bda 80129bda 00000000 80088000 80106fc0 : "
918      "80100000 - ntoskrnl.exe\n"
919    "\n"
920    "Kernel Debugger Using: COM2 (Port 0x2f8, Baud Rate 19200)\n"
921    "Restart and set the recovery options in the system control panel\n"
922    "or the /CRASHDEBUG system start option. If this message reappears,\n"
923    "contact your system administrator or technical support group."
924    );
925
926   bst->line_delay = 750;
927
928   XClearWindow (dpy, window);
929   return bst;
930 }
931
932
933 static struct bsod_state *
934 windows_2k (Display *dpy, Window window)
935 {
936   struct bsod_state *bst = make_bsod_state (dpy, window, "windows", "Windows");
937
938   BSOD_TEXT (bst, LEFT,
939     "*** STOP: 0x000000D1 (0xE1D38000,0x0000001C,0x00000000,0xF09D42DA)\n"
940     "DRIVER_IRQL_NOT_LESS_OR_EQUAL \n"
941     "\n"
942     "*** Address F09D42DA base at F09D4000, DateStamp 39f459ff - CRASHDD.SYS\n"
943     "\n"
944     "Beginning dump of physical memory\n");
945   BSOD_PAUSE (bst, 4000000);
946   BSOD_TEXT (bst, LEFT,
947     "Physical memory dump complete. Contact your system administrator or\n"
948     "technical support group.\n");
949
950   bst->left_margin = 40;
951   bst->y = (bst->font->ascent + bst->font->descent) * 10;
952   bst->line_delay = 750;
953
954   XClearWindow (dpy, window);
955   return bst;
956 }
957
958
959 static struct bsod_state *
960 windows_me (Display *dpy, Window window)
961 {
962   struct bsod_state *bst = make_bsod_state (dpy, window, "windows", "Windows");
963
964   BSOD_TEXT (bst, LEFT,
965     "Windows protection error.  You need to restart your computer.\n\n"
966     "System halted.");
967   BSOD_CURSOR (bst, CURSOR_LINE, 120000, 999999);
968
969   bst->left_margin = 40;
970   bst->y = ((bst->xgwa.height -
971              ((bst->font->ascent + bst->font->descent) * 3))
972             / 2);
973
974   XClearWindow (dpy, window);
975   return bst;
976 }
977
978
979 static struct bsod_state *
980 windows_xp (Display *dpy, Window window)
981 {
982   struct bsod_state *bst = make_bsod_state (dpy, window, "windows", "Windows");
983
984   BSOD_TEXT (bst, LEFT,  /* From Wm. Rhodes <xscreensaver@27.org> */
985       "A problem has been detected and windows has been shut down to prevent "
986       "damage\n"
987       "to your computer.\n"
988       "\n"
989       "If this is the first time you've seen this Stop error screen,\n"
990       "restart your computer. If this screen appears again, follow\n"
991       "these steps:\n"
992       "\n"
993       "Check to be sure you have adequate disk space. If a driver is\n"
994       "identified in the Stop message, disable the driver or check\n"
995       "with the manufacturer for driver updates. Try changing video\n"
996       "adapters.\n"
997       "\n"
998       "Check with your hardware vendor for any BIOS updates. Disable\n"
999       "BIOS memory options such as caching or shadowing. If you need\n"
1000       "to use Safe Mode to remove or disable components, restart your\n"
1001       "computer, press F8 to select Advanced Startup Options, and then\n"
1002       "select Safe Mode.\n"
1003       "\n"
1004       "Technical information:\n"
1005       "\n"
1006       "*** STOP: 0x0000007E (0xC0000005,0xF88FF190,0x0xF8975BA0,0xF89758A0)\n"
1007       "\n"
1008       "\n"
1009       "***  EPUSBDSK.sys - Address F88FF190 base at FF88FE000, datestamp "
1010       "3b9f3248\n"
1011       "\n"
1012       "Beginning dump of physical memory\n");
1013   BSOD_PAUSE (bst, 4000000);
1014   BSOD_TEXT (bst, LEFT,
1015       "Physical memory dump complete.\n"
1016       "Contact your system administrator or technical support group for "
1017       "further\n"
1018       "assistance.\n");
1019
1020   XClearWindow (dpy, window);
1021   return bst;
1022 }
1023
1024
1025 static struct bsod_state *
1026 windows_lh (Display *dpy, Window window)
1027 {
1028   struct bsod_state *bst = 
1029     make_bsod_state (dpy, window, "windowslh", "WindowsLH");
1030
1031   unsigned long fg = bst->fg;
1032   unsigned long bg = bst->bg;
1033   unsigned long bg2 = get_pixel_resource (dpy, bst->xgwa.colormap,
1034                                           "windowslh.background2",
1035                                           "WindowsLH.Background");
1036
1037   /* The "RSOD" that appeared with "Windows Longhorn 5048.050401-0536_x86fre"
1038      As reported by http://joi.ito.com/RedScreen.jpg
1039    */
1040   BSOD_COLOR (bst, bg, bg2);
1041   BSOD_TEXT (bst, CENTER_FULL, "Windows Boot Error\n");
1042   BSOD_COLOR (bst, fg, bg);
1043   BSOD_TEXT (bst, CENTER,
1044      "\n"
1045      "Windows Boot Manager has experienced a problem.\n"
1046      "\n"
1047      "\n"
1048      "    Status: 0xc000000f\n"
1049      "\n"
1050      "\n"
1051      "\n"
1052      "    Info: An error occurred transferring exectuion."  /* (sic) */
1053      "\n"
1054      "\n"
1055      "\n"
1056      "You can try to recover the system with the Microsoft Windows "
1057      "System Recovery\n"
1058      "Tools. (You might need to restart the system manually.)\n"
1059      "\n"
1060      "If the problem continues, please contact your system administrator "
1061      "or computer\n"
1062      "manufacturer.\n"
1063      );
1064   BSOD_MOVETO (bst, bst->left_margin, bst->xgwa.height - bst->font->descent);
1065   BSOD_COLOR (bst, bg, bg2);
1066   BSOD_TEXT (bst, LEFT_FULL, " SPACE=Continue\n");
1067
1068   bst->y = bst->font->ascent;
1069
1070   XClearWindow (dpy, window);
1071   return bst;
1072 }
1073
1074
1075 static struct bsod_state *
1076 windows_10 (Display *dpy, Window window)
1077 {
1078   struct bsod_state *bst = 
1079     make_bsod_state (dpy, window, "win10", "Win10");
1080
1081   int qr_width  = 41;
1082   int qr_height = 41;
1083   static const unsigned char qr_bits[] = {
1084     0xFF,0xFF,0xFF,0xFF,0xFF,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,
1085     0x03,0x9A,0x70,0xEE,0x80,0x01,0xFB,0x22,0xAA,0xA6,0xBE,0x01,
1086     0x8B,0x8E,0x74,0xE7,0xA2,0x01,0x8B,0xEE,0x42,0xC4,0xA2,0x01,
1087     0x8B,0x42,0x6E,0xED,0xA2,0x01,0xFB,0xDA,0x63,0xA6,0xBE,0x01,
1088     0x03,0xAA,0xAA,0xAA,0x80,0x01,0xFF,0x8B,0xD8,0x9D,0xFF,0x01,
1089     0x63,0x62,0xDA,0x1B,0x98,0x01,0x6F,0x67,0x98,0x9F,0xBC,0x01,
1090     0x4F,0xCC,0x55,0x81,0x83,0x01,0xB7,0x6D,0xFF,0x68,0xB2,0x01,
1091     0xC3,0x10,0x87,0x8B,0x96,0x01,0x6F,0xB1,0x91,0x58,0x94,0x01,
1092     0xE3,0x36,0x88,0x84,0xB8,0x01,0x83,0x9B,0xFE,0x59,0xD7,0x01,
1093     0x3B,0x74,0x98,0x5C,0xB4,0x01,0x37,0x75,0xDC,0x91,0xA6,0x01,
1094     0x77,0xDE,0x01,0x54,0xBA,0x01,0xBB,0x6D,0x8B,0xB9,0xB5,0x01,
1095     0x1F,0x06,0xBD,0x9B,0xB4,0x01,0xD3,0xBD,0x91,0x19,0x84,0x01,
1096     0x0B,0x20,0xD8,0x91,0xB4,0x01,0x33,0x95,0xBC,0x0A,0xD5,0x01,
1097     0xB3,0x60,0xDC,0xD9,0xB6,0x01,0xEF,0x77,0x18,0x09,0xA4,0x01,
1098     0xA3,0xC2,0x95,0x51,0xB2,0x01,0xDF,0x63,0xDB,0xBE,0xB3,0x01,
1099     0x03,0x08,0xC9,0x09,0xF0,0x01,0xFF,0xA3,0x19,0xBD,0xFB,0x01,
1100     0x03,0x2E,0x84,0xA5,0xAA,0x01,0xFB,0x9A,0xFC,0x9B,0xBB,0x01,
1101     0x8B,0x7E,0x9C,0x1D,0xB0,0x01,0x8B,0x6E,0x58,0xA1,0xDB,0x01,
1102     0x8B,0xDA,0xD5,0x65,0xA2,0x01,0xFB,0x72,0xFB,0xE9,0xF0,0x01,
1103     0x03,0x02,0x99,0x3B,0xB3,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0x01,
1104     0xFF,0xFF,0xFF,0xFF,0xFF,0x01};
1105   Pixmap pixmap;
1106
1107   const char *lines[] = {
1108     ":(\n",
1109     "\n",
1110     "Your PC ran into a problem and needs to restart. We're just\n",
1111     "collecting some error info, and then we'll restart for you.\n",
1112     "\n",
1113     "\n",
1114     "\n",
1115     "For more information about this issue and\n",
1116     "possible fixes, visit\n",
1117 /*  "https://www.jwz.org/xscreensaver\n",*/
1118     "http://youtu.be/-RjmN9RZyr4\n", 
1119     "\n",
1120     "If you call a support person, give them this info:\n",
1121     "Stop code CRITICAL_PROCESS_DIED", 
1122  };
1123   int i, y = 0, y0 = 0;
1124   int line_height0 = bst->fontB->ascent;
1125   int line_height1 = bst->fontA->ascent + bst->fontA->descent;
1126   int line_height2 = bst->fontC->ascent + bst->fontC->descent;
1127   int line_height = line_height0;
1128   int top, left0, left;
1129   int stop = 60 + (random() % 39);
1130
1131   line_height1 *= 1.3;
1132   line_height2 *= 1.5;
1133
1134   top = ((bst->xgwa.height - (line_height0 * 1 +
1135                               line_height1 * 6 +
1136                               line_height2 * 6))
1137          / 2);
1138
1139   {
1140     int dir, ascent, descent;
1141     XCharStruct ov;
1142     const char *s = lines[2];
1143     XTextExtents (bst->fontA, s, strlen(s),
1144                   &dir, &ascent, &descent, &ov);
1145     left = left0 = (bst->xgwa.width - ov.width) / 2;
1146   }
1147
1148   pixmap = XCreatePixmapFromBitmapData (dpy, window, (char *) qr_bits,
1149                                         qr_width, qr_height,
1150                                         bst->fg, bst->bg, bst->xgwa.depth);
1151   for (i = 0; i < 2; i++)
1152     {
1153       pixmap = double_pixmap (dpy, bst->gc, bst->xgwa.visual, bst->xgwa.depth,
1154                               pixmap, qr_width, qr_height);
1155       qr_width *= 2;
1156       qr_height *= 2;
1157     }
1158   bst->pixmap = pixmap;
1159
1160   y = top;
1161   line_height = line_height0;
1162   BSOD_FONT (bst, 1);
1163   for (i = 0; i < countof(lines); i++)
1164     {
1165       BSOD_MOVETO (bst, left, y);
1166       BSOD_TEXT (bst, LEFT, lines[i]);
1167       y += line_height;
1168       if (i == 0)
1169         {
1170           BSOD_FONT (bst, 0);
1171           line_height = line_height1;
1172         }
1173       else if (i == 4)
1174         {
1175           y0 = y;
1176           y += line_height / 2;
1177           BSOD_PIXMAP (bst, 0, 0, qr_width, qr_height, left, y + line_height1);
1178           BSOD_FONT (bst, 2);
1179           line_height = line_height2;
1180           left += qr_width + line_height2 / 2;
1181 # ifdef HAVE_MOBILE
1182           y -= 14;
1183 # endif
1184         }
1185     }
1186
1187   left = left0;
1188   BSOD_FONT (bst, 0);
1189   for (i = 0; i <= stop; i++)
1190     {
1191       char buf[100];
1192       sprintf (buf, "%d%% complete", i);
1193       BSOD_MOVETO (bst, left, y0);
1194       BSOD_TEXT (bst, LEFT, buf);
1195       BSOD_PAUSE (bst, 85000);
1196     }
1197   BSOD_PAUSE (bst, 3000000);
1198
1199   XClearWindow (dpy, window);
1200   return bst;
1201 }
1202
1203
1204 static struct bsod_state *
1205 windows_other (Display *dpy, Window window)
1206 {
1207   /* Lump all of the 2K-ish crashes together and select them randomly...
1208    */
1209   int which = (random() % 4);
1210   switch (which) {
1211   case 0: return windows_2k (dpy, window); break;
1212   case 1: return windows_me (dpy, window); break;
1213   case 2: return windows_xp (dpy, window); break;
1214   case 3: return windows_lh (dpy, window); break;
1215   default: abort(); break;
1216   }
1217 }
1218
1219
1220 /* As seen in Portal 2.  By jwz.
1221  */
1222 static struct bsod_state *
1223 glados (Display *dpy, Window window)
1224 {
1225   struct bsod_state *bst = make_bsod_state (dpy, window, "glaDOS", "GlaDOS");
1226   const char * panicstr[] = {
1227     "\n",
1228     "MOLTEN CORE WARNING\n",
1229     "\n",
1230     "An operator error exception has occurred at FISSREAC0020093:09\n",
1231     "FISSREAC0020077:14 FISSREAC0020023:17 FISSREAC0020088:22\n",
1232     "neutron multiplication rate at spikevalue 99999999\n",
1233     "\n",
1234     "* Press any key to vent radiological emissions into atmosphere.\n",
1235     "* Consult reactor core manual for instructions on proper reactor core\n",
1236     "maintenance and repair.\n",
1237     "\n",
1238     "Press any key to continue\n",
1239   };
1240
1241   int i;
1242
1243   bst->y = ((bst->xgwa.height -
1244              ((bst->font->ascent + bst->font->descent) * countof(panicstr)))
1245             / 2);
1246
1247   BSOD_MOVETO (bst, 0, bst->y);
1248   BSOD_INVERT (bst);
1249   BSOD_TEXT   (bst,  CENTER, "OPERATOR ERROR\n");
1250   BSOD_INVERT (bst);
1251   for (i = 0; i < countof(panicstr); i++)
1252     BSOD_TEXT (bst, CENTER, panicstr[i]);
1253   BSOD_PAUSE (bst, 1000000);
1254   BSOD_INVERT (bst);
1255   BSOD_RECT (bst, True, 0, 0, bst->xgwa.width, bst->xgwa.height);
1256   BSOD_INVERT (bst);
1257   BSOD_PAUSE (bst, 250000);
1258   BSOD_RESET (bst);
1259
1260   XClearWindow (dpy, window);
1261   return bst;
1262 }
1263
1264
1265
1266 /* SCO OpenServer 5 panic, by Tom Kelly <tom@ancilla.toronto.on.ca>
1267  */
1268 static struct bsod_state *
1269 sco (Display *dpy, Window window)
1270 {
1271   struct bsod_state *bst = make_bsod_state (dpy, window, "sco", "SCO");
1272
1273   BSOD_TEXT (bst, LEFT,
1274      "Unexpected trap in kernel mode:\n"
1275      "\n"
1276      "cr0 0x80010013     cr2  0x00000014     cr3 0x00000000  tlb  0x00000000\n"
1277      "ss  0x00071054    uesp  0x00012055     efl 0x00080888  ipl  0x00000005\n"
1278      "cs  0x00092585     eip  0x00544a4b     err 0x004d4a47  trap 0x0000000E\n"
1279      "eax 0x0045474b     ecx  0x0042544b     edx 0x57687920  ebx  0x61726520\n"
1280      "esp 0x796f7520     ebp  0x72656164     esi 0x696e6720  edi  0x74686973\n"
1281      "ds  0x3f000000     es   0x43494c48     fs  0x43525343  gs   0x4f4d4b53\n"
1282      "\n"
1283      "PANIC: k_trap - kernel mode trap type 0x0000000E\n"
1284      "Trying to dump 5023 pages to dumpdev hd (1/41), 63 pages per '.'\n"
1285     );
1286   BSOD_CHAR_DELAY (bst, 100000);
1287   BSOD_TEXT (bst, LEFT,
1288     "................................................................."
1289     "..............\n"
1290     );
1291   BSOD_CHAR_DELAY (bst, 0);
1292   BSOD_TEXT (bst, LEFT,
1293      "5023 pages dumped\n"
1294      "\n"
1295      "\n"
1296      );
1297   BSOD_PAUSE (bst, 2000000);
1298   BSOD_TEXT (bst, LEFT,
1299      "**   Safe to Power Off   **\n"
1300      "           - or -\n"
1301      "** Press Any Key to Reboot **\n"
1302     );
1303
1304   bst->y = ((bst->xgwa.height -
1305              ((bst->font->ascent + bst->font->descent) * 18)));
1306
1307   XClearWindow (dpy, window);
1308   return bst;
1309 }
1310
1311
1312 /* Linux (sparc) panic, by Tom Kelly <tom@ancilla.toronto.on.ca>
1313  */
1314 static struct bsod_state *
1315 sparc_linux (Display *dpy, Window window)
1316 {
1317   struct bsod_state *bst = make_bsod_state (dpy, window, 
1318                                             "sparclinux", "SparcLinux");
1319   bst->scroll_p = True;
1320   bst->y = bst->xgwa.height - bst->font->ascent - bst->font->descent;
1321
1322   BSOD_TEXT (bst, LEFT,
1323         "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
1324         "Unable to handle kernel paging request at virtual address f0d4a000\n"
1325         "tsk->mm->context = 00000014\n"
1326         "tsk->mm->pgd = f26b0000\n"
1327         "              \\|/ ____ \\|/\n"
1328         "              \"@'/ ,. \\`@\"\n"
1329         "              /_| \\__/ |_\\\n"
1330         "                 \\__U_/\n"
1331         "gawk(22827): Oops\n"
1332         "PSR: 044010c1 PC: f001c2cc NPC: f001c2d0 Y: 00000000\n"
1333         "g0: 00001000 g1: fffffff7 g2: 04401086 g3: 0001eaa0\n"
1334         "g4: 000207dc g5: f0130400 g6: f0d4a018 g7: 00000001\n"
1335         "o0: 00000000 o1: f0d4a298 o2: 00000040 o3: f1380718\n"
1336         "o4: f1380718 o5: 00000200 sp: f1b13f08 ret_pc: f001c2a0\n"
1337         "l0: efffd880 l1: 00000001 l2: f0d4a230 l3: 00000014\n"
1338         "l4: 0000ffff l5: f0131550 l6: f012c000 l7: f0130400\n"
1339         "i0: f1b13fb0 i1: 00000001 i2: 00000002 i3: 0007c000\n"
1340         "i4: f01457c0 i5: 00000004 i6: f1b13f70 i7: f0015360\n"
1341         "Instruction DUMP:\n"
1342     );
1343
1344   XClearWindow (dpy, window);
1345   return bst;
1346 }
1347
1348
1349 /* BSD Panic by greywolf@starwolf.com - modeled after the Linux panic above.
1350    By Grey Wolf <greywolf@siteROCK.com>
1351  */
1352 static struct bsod_state *
1353 bsd (Display *dpy, Window window)
1354 {
1355   struct bsod_state *bst = make_bsod_state (dpy, window, "bsd", "BSD");
1356
1357   const char * const panicstr[] = {
1358     "panic: ifree: freeing free inode\n",
1359     "panic: blkfree: freeing free block\n",
1360     "panic: improbability coefficient below zero\n",
1361     "panic: cgsixmmap\n",
1362     "panic: crazy interrupts\n",
1363     "panic: nmi\n",
1364     "panic: attempted windows install\n",
1365     "panic: don't\n",
1366     "panic: free inode isn't\n",
1367     "panic: cpu_fork: curproc\n",
1368     "panic: malloc: out of space in kmem_map\n",
1369     "panic: vogon starship detected\n",
1370     "panic: teleport chamber: out of order\n",
1371     "panic: Brain fried - core dumped\n"
1372    };
1373   int i, n, b;
1374   char syncing[80], bbuf[5];
1375
1376   for (i = 0; i < sizeof(syncing); i++)
1377     syncing[i] = 0;
1378
1379   i = (random() % (sizeof(panicstr) / sizeof(*panicstr)));
1380   BSOD_TEXT (bst, LEFT, panicstr[i]);
1381   BSOD_TEXT (bst, LEFT, "Syncing disks: ");
1382
1383   b = (random() % 40);
1384   for (n = 0; (n < 20) && (b > 0); n++)
1385     {
1386       if (i)
1387         {
1388           i = (random() & 0x7);
1389           b -= (random() & 0xff) % 20;
1390           if (b < 0)
1391             b = 0;
1392         }
1393       sprintf (bbuf, "%d ", b);
1394       BSOD_TEXT (bst, LEFT, bbuf);
1395       BSOD_PAUSE (bst, 1000000);
1396     }
1397
1398   BSOD_TEXT (bst, LEFT, "\n");
1399   BSOD_TEXT (bst, LEFT, (b ? "damn!" : "sunk!"));
1400   BSOD_TEXT (bst, LEFT, "\nRebooting\n");
1401
1402   bst->y = ((bst->xgwa.height -
1403              ((bst->font->ascent + bst->font->descent) * 4)));
1404
1405   XClearWindow (dpy, window);
1406   return bst;
1407 }
1408
1409
1410 static struct bsod_state *
1411 amiga (Display *dpy, Window window)
1412 {
1413   struct bsod_state *bst = make_bsod_state (dpy, window, "amiga", "Amiga");
1414
1415   Pixmap pixmap = 0;
1416   int pix_w = 0, pix_h = 0;
1417   int height;
1418   int lw = 10;
1419
1420   unsigned long bg2 = get_pixel_resource (dpy, bst->xgwa.colormap,
1421                                           "amiga.background2",
1422                                           "Amiga.Background");
1423
1424 # ifdef DO_XPM
1425   pixmap = xpm_data_to_pixmap (dpy, window, (char **) amiga_hand,
1426                                &pix_w, &pix_h, 0);
1427 # endif /* DO_XPM */
1428
1429   if (pixmap &&
1430       MIN (bst->xgwa.width, bst->xgwa.height) > 600) /* scale up the bitmap */
1431     {
1432       pixmap = double_pixmap (dpy, bst->gc, bst->xgwa.visual, bst->xgwa.depth,
1433                               pixmap, pix_w, pix_h);
1434       pix_w *= 2;
1435       pix_h *= 2;
1436     }
1437
1438   XSetLineAttributes (dpy, bst->gc, lw, LineSolid, CapButt, JoinMiter);
1439
1440   height = (bst->font->ascent + bst->font->descent) * 6;
1441
1442   BSOD_PAUSE (bst, 2000000);
1443   BSOD_COPY (bst, 0, 0, bst->xgwa.width, bst->xgwa.height - height, 0, height);
1444
1445   BSOD_INVERT (bst);
1446   BSOD_RECT (bst, True, 0, 0, bst->xgwa.width, height);
1447   BSOD_INVERT (bst);
1448   BSOD_TEXT (bst, CENTER,
1449              "\n"
1450              "Software failure.  Press left mouse button to continue.\n"
1451              "Guru Meditation #00000003.00C01570"
1452              );
1453   BSOD_RECT (bst, False, lw/2, lw/2, bst->xgwa.width - lw, height);
1454   BSOD_PAUSE (bst, 1000000);
1455   BSOD_INVERT (bst);
1456   BSOD_LOOP (bst, -3);
1457
1458   XSetWindowBackground (dpy, window, bg2);
1459   XClearWindow (dpy, window);
1460   XSetWindowBackground (dpy, window, bst->bg);
1461
1462   if (pixmap)
1463     {
1464       int x = (bst->xgwa.width - pix_w) / 2;
1465       int y = ((bst->xgwa.height - pix_h) / 2);
1466       XCopyArea (dpy, pixmap, bst->window, bst->gc, 0, 0, pix_w, pix_h, x, y);
1467     }
1468
1469   bst->y += lw;
1470
1471   return bst;
1472 }
1473
1474
1475
1476 /* Atari ST, by Marcus Herbert <rhoenie@nobiscum.de>
1477    Marcus had this to say:
1478
1479         Though I still have my Atari somewhere, I hardly remember
1480         the meaning of the bombs. I think 9 bombs was "bus error" or
1481         something like that.  And you often had a few bombs displayed
1482         quickly and then the next few ones coming up step by step.
1483         Perhaps somebody else can tell you more about it..  its just
1484         a quick hack :-}
1485  */
1486 static struct bsod_state *
1487 atari (Display *dpy, Window window)
1488 {
1489   struct bsod_state *bst = make_bsod_state (dpy, window, "atari", "Atari");
1490
1491   Pixmap pixmap = 0;
1492   int pix_w = atari_width;
1493   int pix_h = atari_height;
1494   int offset;
1495   int i, x, y;
1496
1497   pixmap = XCreatePixmapFromBitmapData (dpy, window, (char *) atari_bits,
1498                                         pix_w, pix_h,
1499                                         bst->fg, bst->bg, bst->xgwa.depth);
1500   pixmap = double_pixmap (dpy, bst->gc, bst->xgwa.visual, bst->xgwa.depth,
1501                           pixmap, pix_w, pix_h);
1502   pix_w *= 2;
1503   pix_h *= 2;
1504
1505   offset = pix_w;
1506   x = 0;
1507   y = bst->xgwa.height/2;
1508   if (y < 0) y = 0;
1509
1510   for (i = 1; i< 7; i++)
1511     BSOD_COPY (bst, x, y, pix_w, pix_h, (x + (i*offset)), y);
1512
1513   for (; i< 10; i++) 
1514     {
1515       BSOD_PAUSE (bst, 1000000);
1516       BSOD_COPY (bst, x, y, pix_w, pix_h, (x + (i*offset)), y);
1517     }
1518
1519   XClearWindow (dpy, window);
1520   XCopyArea (dpy, pixmap, window, bst->gc, 0, 0, pix_w, pix_h, x, y);
1521   XFreePixmap (dpy, pixmap);
1522
1523   return bst;
1524 }
1525
1526
1527 static struct bsod_state *
1528 mac (Display *dpy, Window window)
1529 {
1530   struct bsod_state *bst = make_bsod_state (dpy, window, "mac", "Mac");
1531
1532   Pixmap pixmap = 0;
1533   int pix_w = mac_width;
1534   int pix_h = mac_height;
1535   int offset = mac_height * 4;
1536   int i;
1537
1538   const char *string = ("0 0 0 0 0 0 0 F\n"
1539                         "0 0 0 0 0 0 0 3");
1540
1541   pixmap = XCreatePixmapFromBitmapData(dpy, window, (char *) mac_bits,
1542                                        mac_width, mac_height,
1543                                        bst->fg, bst->bg, bst->xgwa.depth);
1544
1545   for (i = 0; i < 2; i++)
1546     {
1547       pixmap = double_pixmap (dpy, bst->gc, bst->xgwa.visual, bst->xgwa.depth,
1548                               pixmap, pix_w, pix_h);
1549       pix_w *= 2; pix_h *= 2;
1550     }
1551
1552   bst->x = (bst->xgwa.width - pix_w) / 2;
1553   bst->y = (((bst->xgwa.height + offset) / 2) -
1554             pix_h -
1555             (bst->font->ascent + bst->font->descent) * 2);
1556   if (bst->y < 0) bst->y = 0;
1557
1558   XClearWindow (dpy, window);
1559   XCopyArea (dpy, pixmap, window, bst->gc, 0, 0, pix_w, pix_h, bst->x, bst->y);
1560   XFreePixmap (dpy, pixmap);
1561
1562   bst->y += offset + bst->font->ascent + bst->font->descent;
1563   BSOD_TEXT (bst, CENTER, string);
1564
1565   return bst;
1566 }
1567
1568
1569 static struct bsod_state *
1570 macsbug (Display *dpy, Window window)
1571 {
1572   struct bsod_state *bst = make_bsod_state (dpy, window, "macsbug", "MacsBug");
1573
1574   __extension__
1575   const char *left = ("    SP     \n"
1576                       " 04EB0A58  \n"
1577                       "58 00010000\n"
1578                       "5C 00010000\n"
1579                       "   ........\n"
1580                       "60 00000000\n"
1581                       "64 000004EB\n"
1582                       "   ........\n"
1583                       "68 0000027F\n"
1584                       "6C 2D980035\n"
1585                       "   ....-..5\n"
1586                       "70 00000054\n"
1587                       "74 0173003E\n"
1588                       "   ...T.s.>\n"
1589                       "78 04EBDA76\n"
1590                       "7C 04EBDA8E\n"
1591                       "   .S.L.a.U\n"
1592                       "80 00000000\n"
1593                       "84 000004EB\n"
1594                       "   ........\n"
1595                       "88 00010000\n"
1596                       "8C 00010000\n"
1597                       "   ...{3..S\n"
1598                       "\n"
1599                       "\n"
1600                       " CurApName \n"
1601                       "  Finder   \n"
1602                       "\n"
1603                       " 32-bit VM \n"
1604                       "SR Smxnzvc0\n"
1605                       "D0 04EC0062\n"
1606                       "D1 00000053\n"
1607                       "D2 FFFF0100\n"
1608                       "D3 00010000\n"
1609                       "D4 00010000\n"
1610                       "D5 04EBDA76\n"
1611                       "D6 04EBDA8E\n"
1612                       "D7 00000001\n"
1613                       "\n"
1614                       "A0 04EBDA76\n"
1615                       "A1 04EBDA8E\n"
1616                       "A2 A0A00060\n"
1617                       "A3 027F2D98\n"
1618                       "A4 027F2E58\n"
1619                       "A5 04EC04F0\n"
1620                       "A6 04EB0A86\n"
1621                       "A7 04EB0A58");
1622   const char *bottom = ("  _A09D\n"
1623                         "     +00884    40843714     #$0700,SR         "
1624                         "                  ; A973        | A973\n"
1625                         "     +00886    40843765     *+$0400           "
1626                         "                                | 4A1F\n"
1627                         "     +00888    40843718     $0004(A7),([0,A7[)"
1628                         "                  ; 04E8D0AE    | 66B8");
1629   __extension__
1630   const char * body = ("PowerPC unmapped memory exception at 003AFDAC "
1631                                                 "BowelsOfTheMemoryMgr+04F9C\n"
1632                       " Calling chain using A6/R1 links\n"
1633                       "  Back chain  ISA  Caller\n"
1634                       "  00000000    PPC  28C5353C  __start+00054\n"
1635                       "  24DB03C0    PPC  28B9258C  main+0039C\n"
1636                       "  24DB0350    PPC  28B9210C  MainEvent+00494\n"
1637                       "  24DB02B0    PPC  28B91B40  HandleEvent+00278\n"
1638                       "  24DB0250    PPC  28B83DAC  DoAppleEvent+00020\n"
1639                       "  24DB0210    PPC  FFD3E5D0  "
1640                                                 "AEProcessAppleEvent+00020\n"
1641                       "  24DB0132    68K  00589468\n"
1642                       "  24DAFF8C    68K  00589582\n"
1643                       "  24DAFF26    68K  00588F70\n"
1644                       "  24DAFEB3    PPC  00307098  "
1645                                                 "EmToNatEndMoveParams+00014\n"
1646                       "  24DAFE40    PPC  28B9D0B0  DoScript+001C4\n"
1647                       "  24DAFDD0    PPC  28B9C35C  RunScript+00390\n"
1648                       "  24DAFC60    PPC  28BA36D4  run_perl+000E0\n"
1649                       "  24DAFC10    PPC  28BC2904  perl_run+002CC\n"
1650                       "  24DAFA80    PPC  28C18490  Perl_runops+00068\n"
1651                       "  24DAFA30    PPC  28BE6CC0  Perl_pp_backtick+000FC\n"
1652                       "  24DAF9D0    PPC  28BA48B8  Perl_my_popen+00158\n"
1653                       "  24DAF980    PPC  28C5395C  sfclose+00378\n"
1654                       "  24DAF930    PPC  28BA568C  free+0000C\n"
1655                       "  24DAF8F0    PPC  28BA6254  pool_free+001D0\n"
1656                       "  24DAF8A0    PPC  FFD48F14  DisposePtr+00028\n"
1657                       "  24DAF7C9    PPC  00307098  "
1658                                                 "EmToNatEndMoveParams+00014\n"
1659                       "  24DAF780    PPC  003AA180  __DisposePtr+00010");
1660
1661   const char *s;
1662   int body_lines = 1;
1663
1664   int char_width, line_height;
1665   int col_right, row_top, row_bottom, page_right, page_bottom, body_top;
1666   int xoff, yoff;
1667
1668   unsigned long fg = bst->fg;
1669   unsigned long bg = bst->bg;
1670   unsigned long bc = get_pixel_resource (dpy, bst->xgwa.colormap,
1671                                          "macsbug.borderColor",
1672                                          "MacsBug.BorderColor");
1673
1674   for (s = body; *s; s++) if (*s == '\n') body_lines++;
1675
1676   char_width = (bst->font->per_char
1677                 ? bst->font->per_char['n'-bst->font->min_char_or_byte2].width
1678                 : bst->font->min_bounds.width);
1679   line_height = bst->font->ascent + bst->font->descent;
1680
1681   col_right   = char_width  * 12;  /* number of columns in `left' */
1682   page_bottom = line_height * 47;  /* number of lines in `left'   */
1683
1684   if (page_bottom > bst->xgwa.height) 
1685     page_bottom = bst->xgwa.height;
1686
1687   row_bottom = page_bottom - line_height;
1688   row_top    = row_bottom - (line_height * 4);
1689   page_right = col_right + (char_width * 88);
1690   body_top   = row_top - (line_height * body_lines);
1691
1692   page_bottom += 2;
1693   row_bottom += 2;
1694   body_top -= 4;
1695
1696   if (body_top > 4)
1697     body_top = 4;
1698
1699   xoff = (bst->xgwa.width  - page_right)  / 2;
1700   yoff = (bst->xgwa.height - page_bottom) / 2;
1701
1702   if (xoff < 0) xoff = 0;
1703   if (yoff < 0) yoff = 0;
1704
1705   BSOD_MARGINS (bst, xoff, yoff);
1706
1707   BSOD_COLOR (bst, bc, bg);
1708   BSOD_RECT (bst, True, 0, 0, bst->xgwa.width, bst->xgwa.height);
1709   BSOD_COLOR (bst, bg, bg);
1710   BSOD_RECT (bst, True, xoff-2, yoff, page_right+4, page_bottom);
1711   BSOD_COLOR (bst, fg, bg);
1712
1713   BSOD_MOVETO (bst, xoff, yoff + line_height);
1714   BSOD_TEXT (bst, LEFT, left);
1715   BSOD_MOVETO (bst, xoff+col_right, yoff + row_top + line_height);
1716   BSOD_TEXT (bst, LEFT, bottom);
1717
1718   BSOD_RECT (bst, True, xoff + col_right, yoff, 2, page_bottom);
1719   BSOD_RECT (bst, True, xoff + col_right, yoff + row_top, 
1720              page_right - col_right, 1);
1721   BSOD_RECT (bst, True, xoff + col_right, yoff + row_bottom, 
1722              page_right - col_right, 1);
1723   BSOD_RECT (bst, False, xoff-2, yoff, page_right+4, page_bottom);
1724
1725   BSOD_LINE_DELAY (bst, 500);
1726   BSOD_MOVETO (bst, 
1727                xoff + col_right + char_width, 
1728                yoff + body_top + line_height);
1729   BSOD_MARGINS (bst, xoff + col_right + char_width, yoff);
1730   BSOD_TEXT (bst, LEFT, body);
1731
1732   BSOD_RECT (bst, False, xoff-2, yoff, page_right+4, page_bottom); /* again */
1733
1734   BSOD_RECT (bst, False,
1735              xoff + col_right + (char_width/2)+2,
1736              yoff + row_bottom + 2,
1737              0,
1738              page_bottom - row_bottom - 4);
1739
1740   BSOD_PAUSE (bst, 666666);
1741   BSOD_INVERT (bst);
1742   BSOD_LOOP (bst, -3);
1743
1744   XClearWindow (dpy, window);
1745   return bst;
1746 }
1747
1748
1749 static struct bsod_state *
1750 mac1 (Display *dpy, Window window)
1751 {
1752   struct bsod_state *bst = make_bsod_state (dpy, window, "mac1", "Mac1");
1753
1754   Pixmap pixmap = 0;
1755   int pix_w = macbomb_width;
1756   int pix_h = macbomb_height;
1757   int x, y;
1758
1759   pixmap = XCreatePixmapFromBitmapData (dpy, window, (char *) macbomb_bits,
1760                                         macbomb_width, macbomb_height,
1761                                         bst->fg, bst->bg, bst->xgwa.depth);
1762
1763   x = (bst->xgwa.width - pix_w) / 2;
1764   y = (bst->xgwa.height - pix_h) / 2;
1765   if (y < 0) y = 0;
1766
1767   XClearWindow (dpy, window);
1768   XCopyArea (dpy, pixmap, window, bst->gc, 0, 0, pix_w, pix_h, x, y);
1769
1770   return bst;
1771 }
1772
1773
1774 /* This is what kernel panics looked like on MacOS X 10.0 through 10.1.5.
1775    In later releases, it's a graphic of a power button with text in
1776    English, French, German, and Japanese overlayed transparently.
1777  */
1778 static struct bsod_state *
1779 macx_10_0 (Display *dpy, Window window)
1780 {
1781   struct bsod_state *bst = make_bsod_state (dpy, window, "macx", "MacX");
1782
1783   XClearWindow (dpy, window);
1784   XSetForeground (dpy, bst->gc,
1785                   get_pixel_resource (dpy, bst->xgwa.colormap,
1786                                       "macx.textForeground",
1787                                       "MacX.TextForeground"));
1788   XSetBackground (dpy, bst->gc,
1789                   get_pixel_resource (dpy, bst->xgwa.colormap,
1790                                       "macx.textBackground",
1791                                       "MacX.TextBackground"));
1792
1793 # ifdef DO_XPM
1794   {
1795     Pixmap pixmap = 0;
1796     Pixmap mask = 0;
1797     int x, y, pix_w, pix_h;
1798     pixmap = xpm_data_to_pixmap (dpy, window, (char **) happy_mac,
1799                                  &pix_w, &pix_h, &mask);
1800
1801 # ifdef HAVE_MOBILE
1802     if (pixmap)
1803       {
1804         pixmap = double_pixmap (dpy, bst->gc, bst->xgwa.visual,
1805                                 bst->xgwa.depth, pixmap, pix_w, pix_h);
1806         mask = double_pixmap (dpy, bst->gc, bst->xgwa.visual,
1807                               1, mask, pix_w, pix_h);
1808         pix_w *= 2;
1809         pix_h *= 2;
1810       }
1811 # endif
1812
1813     x = (bst->xgwa.width - pix_w) / 2;
1814     y = (bst->xgwa.height - pix_h) / 2;
1815     if (y < 0) y = 0;
1816     XSetClipMask (dpy, bst->gc, mask);
1817     XSetClipOrigin (dpy, bst->gc, x, y);
1818     XCopyArea (dpy, pixmap, window, bst->gc, 0, 0, pix_w, pix_h, x, y);
1819     XSetClipMask (dpy, bst->gc, None);
1820     XFreePixmap (dpy, pixmap);
1821   }
1822 #endif /* DO_XPM */
1823
1824   bst->left_margin = 0;
1825   bst->right_margin = 0;
1826   bst->y = bst->font->ascent;
1827   bst->macx_eol_kludge = True;
1828   bst->wrap_p = True;
1829
1830   BSOD_PAUSE (bst, 3000000);
1831   BSOD_TEXT (bst, LEFT,
1832     "panic(cpu 0): Unable to find driver for this platform: "
1833     "\"PowerMac 3,5\".\n"
1834     "\n"
1835     "backtrace: 0x0008c2f4 0x0002a7a0 0x001f0204 0x001d4e4c 0x001d4c5c "
1836     "0x001a56cc 0x01d5dbc 0x001c621c 0x00037430 0x00037364\n"
1837     "\n"
1838     "\n"
1839     "\n"
1840     "No debugger configured - dumping debug information\n"
1841     "\n"
1842     "version string : Darwin Kernel Version 1.3:\n"
1843     "Thu Mar  1 06:56:40 PST 2001; root:xnu/xnu-123.5.obj~1/RELEASE_PPC\n"
1844     "\n"
1845     "\n"
1846     "\n"
1847     "\n"
1848     "DBAT0: 00000000 00000000\n"
1849     "DBAT1: 00000000 00000000\n"
1850     "DBAT2: 80001FFE 8000003A\n"
1851     "DBAT3: 90001FFE 9000003A\n"
1852     "MSR=00001030\n"
1853     "backtrace: 0x0008c2f4 0x0002a7a0 0x001f0204 0x001d4e4c 0x001d4c5c "
1854     "0x001a56cc 0x01d5dbc 0x001c621c 0x00037430 0x00037364\n"
1855     "\n"
1856     "panic: We are hanging here...\n");
1857
1858   return bst;
1859 }
1860
1861
1862 # ifdef DO_XPM
1863 static struct bsod_state *
1864 macx_10_2 (Display *dpy, Window window, Bool v10_3_p)
1865 {
1866   struct bsod_state *bst = make_bsod_state (dpy, window, "macx", "MacX");
1867
1868   Pixmap pixmap = 0;
1869   int pix_w = 0, pix_h = 0;
1870   int x, y;
1871
1872   pixmap = xpm_data_to_pixmap (dpy, window, 
1873                                (char **) (v10_3_p ? osx_10_3 : osx_10_2),
1874                                &pix_w, &pix_h, 0);
1875   if (! pixmap) abort();
1876
1877 #if 0
1878   if (bst->xgwa.height > 600)   /* scale up the bitmap */
1879     {
1880       pixmap = double_pixmap (dpy, bst->gc, bst->xgwa.visual, bst->xgwa.depth,
1881                               pixmap, pix_w, pix_h);
1882       if (! pixmap) abort();
1883       pix_w *= 2;
1884       pix_h *= 2;
1885     }
1886 #endif
1887
1888   BSOD_IMG (bst);
1889   BSOD_PAUSE (bst, 2000000);
1890
1891   bst->pixmap = pixmap;
1892
1893   x = (bst->xgwa.width - pix_w) / 2;
1894   y = ((bst->xgwa.height - pix_h) / 2);
1895   BSOD_PIXMAP (bst, 0, 0, pix_w, pix_h, x, y);
1896
1897   return bst;
1898 }
1899 # endif /* DO_XPM */
1900
1901
1902 /* 2006 Mac Mini with MacOS 10.6 failing with a bad boot drive. By jwz.
1903  */
1904 static struct bsod_state *
1905 mac_diskfail (Display *dpy, Window window)
1906 {
1907   struct bsod_state *bst = make_bsod_state (dpy, window, "macdisk", "Mac");
1908   int cw = (bst->font->per_char
1909             ? bst->font->per_char['n'-bst->font->min_char_or_byte2].width
1910             : bst->font->min_bounds.width);
1911   int h = bst->font->ascent + bst->font->descent;
1912   int L = (bst->xgwa.width - (cw * 80)) / 2;
1913   int T = (bst->xgwa.height - (h  * 10)) / 2;
1914
1915   unsigned long fg = bst->fg;
1916   unsigned long bg = bst->bg;
1917   unsigned long bg2 = get_pixel_resource (dpy, bst->xgwa.colormap,
1918                                           "macx.background",
1919                                           "Mac.Background");
1920   if (L < 0) L = 0;
1921   if (T < 0) T = 0;
1922
1923   bst->wrap_p = True;
1924   bst->scroll_p = True;
1925
1926   BSOD_COLOR(bst, bg2, bg);
1927   BSOD_RECT (bst, True, 0, 0, bst->xgwa.width, bst->xgwa.height);
1928   BSOD_PAUSE (bst, 3000000);
1929
1930   BSOD_COLOR(bst, bg, fg);
1931   BSOD_RECT (bst, True, 0, 0, bst->xgwa.width, bst->xgwa.height);
1932   BSOD_COLOR(bst, fg, bg);
1933
1934   BSOD_MARGINS (bst, L, L);
1935   BSOD_MOVETO (bst, L, T);
1936
1937   BSOD_TEXT (bst, LEFT,
1938              "efiboot loaded from device: Acpi(PNP0A03,0)/Pci*1F|2)/Ata"
1939              "(Primary,Slave)/HD(Part\n"
1940              "2,Sig8997E427-064E-4FE7-8CB9-F27A784B232C)\n"
1941              "boot file path: \\System\\Library\\CoreServices\\boot.efi\n"
1942              ".Loading kernel cache file 'System\\Library\\Caches\\"
1943              "com.apple.kext.caches\\Startup\\\n"
1944              "kernelcache_i386.2A14EC2C'\n"
1945              "Loading 'mach_kernel'...\n"
1946              );
1947   BSOD_CHAR_DELAY (bst, 7000);
1948   BSOD_TEXT (bst, LEFT,
1949              ".....................\n"
1950              );
1951   BSOD_CHAR_DELAY (bst, 0);
1952   BSOD_TEXT (bst, LEFT,
1953              "root device uuid is 'B62181B4-6755-3C27-BFA1-49A0E053DBD6\n"
1954              "Loading drivers...\n"
1955              "Loading System\\Library\\Caches\\com.apple.kext.caches\\"
1956              "Startup\\Extensions.mkext....\n"
1957              );
1958   BSOD_CHAR_DELAY (bst, 7000);
1959   BSOD_TEXT (bst, LEFT,
1960              "..............................................................."
1961              ".................\n"
1962              "..............................................................."
1963              ".................\n"
1964              "..............\n"
1965              );
1966   BSOD_INVERT (bst);
1967   BSOD_RECT (bst, True, 0, 0, bst->xgwa.width, bst->xgwa.height);
1968   BSOD_INVERT (bst);
1969
1970   BSOD_MARGINS (bst, 0, 0);
1971   BSOD_MOVETO (bst, 0, h);
1972
1973   BSOD_CHAR_DELAY (bst, 0);
1974   BSOD_LINE_DELAY (bst, 5000);
1975   BSOD_TEXT (bst, LEFT,
1976              "npvhash=4095\n"
1977              "PRE enabled\n"
1978              "Darwin Kernel Version 10.8.9: Tue Jun  7 16:33:36 PDT 2011;"
1979              " root:xnu-1504.15.3~1/RELEASE_I386\n"
1980              "vm_page_bootstrap: 508036 free pages and 16252 wired pages\n"
1981              "standard timeslicing quantum is 10000 us\n"
1982              "mig_table_max_displ = 73\n"
1983              "AppleACPICPU: ProcessorId=0 LocalApicId=0 Enabled\n"
1984              "AppleACPICPU: ProcessorId=1 LocalApicId=1 Enabled\n"
1985              "calling npo_policy_init for Quarantine\n"
1986              "Security policy loaded: Quaantine policy (Quarantine)\n"
1987              "calling npo_policy_init for Sandbox\n"
1988              "Security policy loaded: Seatbelt sandbox policy (Sandbox)\n"
1989              "calling npo_policy_init for TMSafetyNet\n"
1990              "Security policy loaded: Safety net for Time Machine "
1991              "(TMSafetyNet)\n"
1992              "Copyright (c) 1982, 1986, 1989, 1991, 1993\n"
1993              "The Regents of the University of California. All rights "
1994              "reserved.\n"
1995              "\n"
1996              "MAC Framework successfully initialized\n"
1997              "using 10485 buffer headers and 4096 cluster IO buffer headers\n"
1998              "IOAPIC: Version 0x20 Vectors 64:87\n"
1999              "ACPI: System State [S0 S3 S4 S5] (S3)\n"
2000              "PFM64 0x10000000, 0xf0000000\n"
2001              "[ PCI configuration begin ]\n"
2002              "PCI configuration changed (bridge=1 device=1 cardbus=0)\n"
2003              "[ PCI configuration end, bridges 4 devices 17 ]\n"
2004              "nbinit: done (64 MB memory set for nbuf pool)\n"
2005              "rooting via boot-uuid from /chosen: "
2006              "B62181B4-6755-3C27-BFA1-49A0E053DBD6\n"
2007              "Waiting on <dict ID=\"0\"><key>IOProviderClass</key>"
2008              "<string ID=\"1\">IOResources</string><key>IOResourceMatch</key>"
2009              "<string ID=\"2\">boot-uuid-nedia</string></dict>\n"
2010              "com.apple.AppleFSCCompressionTypeZlib kmod start\n"
2011              "com.apple.AppleFSCCompressionTypeZlib kmod succeeded\n"
2012              "AppleIntelCPUPowerManagementClient: ready\n"
2013              "FireWire (OHCI) Lucent ID 5811  built-in now active, GUID "
2014              "0019e3fffe97f8b4; max speed s400.\n"
2015              "Got boot device = IOService:/AppleACPIPlatformExpert/PCI000/"
2016              "AppleACPIPCI/SATA@1F,2/AppleAHCI/PRI202/IOAHCIDevice@0/"
2017              "AppleAHCIDiskDriver/IOAHCIBlockStorageDevice/"
2018              "IOBlockStorageDriver/ST96812AS Media/IOGUIDPartitionScheme/"
2019              "Customer02\n"
2020              );
2021   BSOD_PAUSE (bst, 1000000);
2022   BSOD_TEXT (bst, LEFT,
2023              "BSD root: Disk0s, major 14, minor 2\n"
2024              "[Bluetooth::CSRHIDTransition] switchtoHCIMode (legacy)\n"
2025              "[Bluetooth::CSRHIDTransition] transition complete.\n"
2026              "CSRUSBBluetoothHCIController::setupHardware super returned 0\n"
2027              );
2028   BSOD_PAUSE (bst, 3000000);
2029   BSOD_TEXT (bst, LEFT,
2030              "disk0s2: I/O error.\n"
2031              "0 [Level 3] [ReadUID 0] [Facility com.apple.system.fs] "
2032              "[ErrType IO] [ErrNo 5] [IOType Read] [PBlkNum 48424] "
2033              "[LBlkNum 1362] [FSLogMsgID 2009724291] [FSLogMsgOrder First]\n"
2034              "0 [Level 3] [ReadUID 0] [Facility com.apple.system.fs] "
2035              "[DevNode root_device] [MountPt /] [FSLogMsgID 2009724291] "
2036              "[FSLogMsgOrder Last]\n"
2037              "panic(cpu 0 caller 0x47f5ad): \"Process 1 exec of /sbin/launchd"
2038              " failed, errno 5\\n\"0/SourceCache/xnu/xnu-1504.15.3/bsd/kern/"
2039              "kern_exec.c:3145\n"
2040              "Debugger called: <panic>\n"
2041              "Backtrace (CPU 0), Frame : Return Address (4 potential args "
2042              "on stack)\n"
2043              "0x34bf3e48 : 0x21b837 (0x5dd7fc 0x34bf3e7c 0x223ce1 0x0)\n"
2044              "0x34bf3e98 : 0x47f5ad (0x5cf950 0x831c08 0x5 0x0)\n"
2045              "0x34bf3ef8 : 0x4696d2 (0x4800d20 0x1fe 0x45a69a0 0x80000001)\n"
2046              "0x34bf3f38 : 0x48fee5 (0x46077a8 0x84baa0 0x34bf3f88 "
2047              "0x34bf3f94)\n"
2048              "0x34bf3f68 : 0x219432 (0x46077a8 0xffffff7f 0x0 0x227c4b)\n"
2049              "0x34bf3fa8 : 0x2aacb4 (0xffffffff 0x1 0x22f8f5 0x227c4b)\n"
2050              "0x34bf3fc8 : 0x2a1976 (0x0 0x0 0x2a17ab 0x4023ef0)\n"
2051              "\n"
2052              "BSD process name corresponding to current thread: init\n"
2053              "\n"
2054              "Mac OS version:\n"
2055              "Not yet set\n"
2056              "\n"
2057              "Kernel version:\n"
2058              "Darwin Kernel version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; "
2059              "root:xnu-1504.15-3~1/RELEASE_I386\n"
2060              "System model name: Macmini1,1 (Mac-F4208EC0)\n"
2061              "\n"
2062              "System uptime in nanoseconds: 13239332027\n"
2063              );
2064   BSOD_CURSOR (bst, CURSOR_BLOCK, 500000, 999999);
2065
2066   XClearWindow (dpy, window);
2067
2068   return bst;
2069 }
2070
2071
2072
2073 static struct bsod_state *
2074 macx (Display *dpy, Window window)
2075 {
2076 # ifdef DO_XPM
2077   switch (random() % 4) {
2078   case 0: return macx_10_0 (dpy, window);        break;
2079   case 1: return macx_10_2 (dpy, window, False); break;
2080   case 2: return macx_10_2 (dpy, window, True);  break;
2081   case 3: return mac_diskfail (dpy, window); break;
2082   default: abort();
2083   }
2084 # else  /* !DO_XPM */
2085   switch (random() % 2) {
2086   case 0:  return macx_10_0 (dpy, window);    break;
2087   default: return mac_diskfail (dpy, window); break;
2088   }
2089 # endif /* !DO_XPM */
2090 }
2091
2092
2093 #ifndef HAVE_JWXYZ /* #### I have no idea how to implement this without
2094                            real plane-masks.  I don't think it would look
2095                            right if done with alpha-transparency... */
2096 /* blit damage
2097  *
2098  * by Martin Pool <mbp@samba.org>, Feb 2000.
2099  *
2100  * This is meant to look like the preferred failure mode of NCD
2101  * Xterms.  The parameters for choosing what to copy where might not
2102  * be quite right, but it looks about ugly enough.
2103  */
2104 static struct bsod_state *
2105 blitdamage (Display *dpy, Window window)
2106 {
2107   struct bsod_state *bst = 
2108     make_bsod_state (dpy, window, "blitdamage", "BlitDamage");
2109
2110   int i;
2111   int delta_x = 0, delta_y = 0;
2112   int w, h;
2113   int chunk_h, chunk_w;
2114   int steps;
2115   int src_x, src_y;
2116   int x, y;
2117   
2118   w = bst->xgwa.width;
2119   h = bst->xgwa.height;
2120
2121   XSetPlaneMask (dpy, bst->gc, random());
2122
2123   steps = 50;
2124   chunk_w = w / (random() % 1 + 1);
2125   chunk_h = h / (random() % 1 + 1);
2126   if (random() & 0x1000) 
2127     delta_y = random() % 600;
2128   if (!delta_y || (random() & 0x2000))
2129     delta_x = random() % 600;
2130   src_x = 0; 
2131   src_y = 0; 
2132   x = 0;
2133   y = 0;
2134   
2135   BSOD_IMG (bst);
2136   for (i = 0; i < steps; i++) {
2137     if (x + chunk_w > w) 
2138       x -= w;
2139     else
2140       x += delta_x;
2141     
2142     if (y + chunk_h > h)
2143       y -= h;
2144     else
2145       y += delta_y;
2146     
2147     BSOD_COPY (bst, src_x, src_y, chunk_w, chunk_h, x, y);
2148     BSOD_PAUSE (bst, 1000);
2149   }
2150
2151   return bst;
2152 }
2153 #endif /* !HAVE_JWXYZ */
2154
2155
2156 /*
2157  * OS/2 panics, by Knut St. Osmundsen <bird-xscreensaver@anduin.net>
2158  *
2159  * All but one messages are real ones, some are from my test machines
2160  * and system dumps, others are reconstructed from google results.
2161  * Please, don't be to hard if the formatting of the earlier systems
2162  * aren't 100% correct.
2163  */
2164 static struct bsod_state *
2165 os2 (Display *dpy, Window window)
2166 {
2167   struct bsod_state *bst = make_bsod_state (dpy, window, "os2", "OS2");
2168
2169   __extension__
2170   static const char * const os2_panics[] =
2171     { /* OS/2 2.0 trap - details are bogus (CR0++). */
2172       "TRAP 0002       ERRCD=0000  ERACC=****  ERLIM=********\n"
2173       "EAX=7d240a58  EBX=ff202fdc  ECX=00064423  EDX=00003624\n"
2174       "ESI=fff3272c  EDI=7d240004  EBP=00004a44  FLG=00003202\n"
2175       "CS:EIP=0160:fff702a6  CSACC=c09d  CSLIM=ffffffff\n"
2176       "SS:ESP=0030:00004a38  SSACC=1097  SSLIM=00003fff\n"
2177       "DS=0158  DSACC=c0f3  DSLIM=ffffffff  CR0=fffffffb\n"
2178       "ES=0158  ESACC=c0f3  ESLIM=ffffffff  CR2=1a060014\n"
2179       "FS=0000  FSACC=****  FSLIM=********\n"
2180       "GS=0000  GSACC=****  GSLIM=********\n"
2181       "\n"
2182       "The system detected an internal processing error\n"
2183       "at location ##0160:fff6453f - 000d:a53f\n"
2184       "60000, 9084\n"
2185       "\n"
2186       "038600d1\n"
2187       "Internal revision 6.307, 92/03/01\n"
2188       "\n",
2189
2190       /* warp 3 (early) */
2191       "TRAP 000e       ERRCD=0000  ERACC=****  ERLIM=********\n"
2192       "EAX=ff050c20  EBX=000000bb  ECX=ffff00c1  EDx=fff379b8\n"
2193       "ESI=ffe55a3c  EDI=00000000  EBP=00004eb8  FLG=00013282\n"
2194       "CS:EIP=0160:fff8dbb8  CSACC=c09b  CSLIM=ffffffff\n"
2195       "SS:EIP=0030:00004eb4  SSACC=1097  SSLIM=00003fff\n"
2196       "DS=0158  DSACC=c0f3  DSLIM=ffffffff  CR0=8001001b\n"
2197       "ES=0158  DSACC=c0f3  DSLIM=ffffffff  CR2=000000c7\n"
2198       "FS=0000  FSACC=****  FSLIM=********\n"
2199       "GS=0000  GSACC=****  GSLIM=********\n"
2200       "\n"
2201       "The system detected an internal processing error\n"
2202       "at location ##0160:fff66bf0 - 000d:9bf0.\n"
2203       "60000, 9084\n"
2204       "\n"
2205       "048600b4\n"
2206       "Internal revision 8.125, 94/02/16\n"
2207       "\n"
2208       "The system is stopped.  Record the location number of the error\n"
2209       "and contact your service representative.\n",
2210
2211       /* warp 3 */
2212       "TRAP 000e       ERRCD=0002  ERACC=****  ERLIM=********\n"
2213       "EAX=00000000  EBX=fdef1e0c  ECX=00003824  EDX=0000edf9\n"
2214       "ESI=fdf30e80  EDI=fc8b0000  EBP=00005658  FLG=00012246\n"
2215       "CS:EIP=0160:fff8ada3  CSACC=c09b  CSLIM=ffffffff\n"
2216       "SS:ESP=0030:000055d4  SSACC=1097  SSLIM=0000480f\n"
2217       "DS=0158  DSACC=c093  DSLIM=ffffffff  CR0=8001001b\n"
2218       "ES=0158  ESACC=c093  ESLIM=ffffffff  CR2=fc8b0000\n"
2219       "FS=03b8  FSACC=0093  FSLIM=00000023\n"
2220       "GS=0000  GSACC=****  GSLIM=********\n"
2221       "\n"
2222       "The system detected an internal processing error\n"
2223       "at location ##0160:fff5c364 - 000d:a364.\n"
2224       "60000, 9084\n"
2225       "\n"
2226       "05860526\n"
2227       "Internal revision 8200,94/11/07\n"
2228       "\n"
2229       "The system is stopped. Record all of the above information and\n"
2230       "contact your service representative.\n",
2231
2232       /* warp 3 (late) */
2233       "TRAP 000d       ERRCD=2200  ERACC=1092  ERLIM=00010fff\n"
2234       "EAX=0000802e  EBX=fff001c8  ECX=9bd80000  EDX=00000000\n"
2235       "ESI=fff09bd8  EDI=fdeb001b  EBP=00000000  FLG=00012012\n"
2236       "CS:EIP=0168:fff480a2  CSACC=c09b  CSLIM=ffffffff\n"
2237       "SS:ESP=00e8:00001f32  SSACC=0093  SSLIM=00001fff\n"
2238       "DS=0940  DSACC=0093  DSLIM=00000397  CR0=8001001b\n"
2239       "ES=00e8  ESACC=0093  ESLIM=00001fff  CR2=15760008\n"
2240       "FS=0000  FSACC=****  FSLIM=****\n"
2241       "GS=0000  GSACC=****  GSLIM=****\n"
2242       "\n"
2243       "The system detected an internal processing error\n"
2244       "at location ##0168:fff4b06e - 000e:c06e\n"
2245       "60000, 9084\n"
2246       "\n"
2247       "06860652\n"
2248       "Internal revision 8.259_uni,98/01/07\n"
2249       "\n"
2250       "The system is stopped. Record all of the above information and\n"
2251       "contact your service representative.\n",
2252
2253       /* Warp 4.52+ - the official r0trap.exe from the debugging classes */
2254       "Exception in module: OS2KRNL\n"
2255       "TRAP 000e       ERRCD=0002  ERACC=****  ERLIM=********\n"
2256       "EAX=00000001  EBX=80010002  ECX=ffed4638  EDX=0003f17b\n"
2257       "ESI=00000001  EDI=00000002  EBP=00005408  FLG=00012202\n"
2258       "CS:EIP=0168:fff3cd2e  CSACC=c09b  CSLIM=ffffffff\n"
2259       "SS:ESP=0030:000053ec  SSACC=1097  SSLIM=000044ff\n"
2260       "DS=0160  DSACC=c093  DSLIM=ffffffff  CR0=8001001b\n"
2261       "ES=0160  ESACC=c093  ESLIM=ffffffff  CR2=00000001\n"
2262       "FS=0000  FSACC=****  FSLIM=********\n"
2263       "GS=0000  GSACC=****  GSLIM=********\n"
2264       "\n"
2265       "The system detected an internal processing error at\n"
2266       "location ##0168:fff1e3f3 - 000e:c3f3.\n"
2267       "60000, 9084\n"
2268       "\n"
2269       "068606a0\n"
2270       "Internal revision 14.097_UNI\n"
2271       "\n"
2272       "The system is stopped. Record all of the above information and\n"
2273       "contact your service representative.\n",
2274
2275       /* Warp 4.52+, typical JFS problem. */
2276       "Exeption in module: JFS\n"
2277       "TRAP 0003       ERRCD=0000  ERACC=****  ERLIM=********\n"
2278       "EAX=00000000  EBX=ffffff05  ECX=00000001  EDX=f5cd8010\n"
2279       "ESI=000000e6  EDI=000000e7  EBP=f9c7378e  FLG=00002296\n"
2280       "CS:EIP=0168:f8df3250  CSACC=c09b  CSLIM=ffffffff\n"
2281       "SS:ESP=1550:fdc73778  SSACC=c093  SSLIM=ffffffff\n"
2282       "DS=0160  DSACC=c093  DSLIM=ffffffff  CR0=80010016\n"
2283       "ES=0160  ESACC=c093  DSLIM=ffffffff  CR2=05318000\n"
2284       "FS=03c0  FSACC=0093  DSLIM=00000023\n"
2285       "GS=0160  GSACC=c093  DSLIM=ffffffff\n"
2286       "\n"
2287       "The system detected an internal processing error\n"
2288       "at location ##0168:fff1e2ab - 000e:c2ab.\n"
2289       "60000, 9084\n"
2290       "\n"
2291       "07860695\n"
2292       "\n"
2293       "Internal revision 14.100c_UNI\n"
2294       "\n"
2295       "The system is stopped. Record all of the above information and\n"
2296       "contact your service representative.\n"
2297     };
2298
2299   BSOD_TEXT (bst, LEFT, os2_panics[random() % countof(os2_panics)]);
2300   BSOD_CURSOR (bst, CURSOR_LINE, 240000, 999999);
2301
2302   XClearWindow (dpy, window);
2303   return bst;
2304 }
2305
2306
2307 /* SPARC Solaris panic. Should look pretty authentic on Solaris boxes.
2308  * Anton Solovyev <solovam@earthlink.net>
2309  */ 
2310 static struct bsod_state *
2311 sparc_solaris (Display *dpy, Window window)
2312 {
2313   struct bsod_state *bst = make_bsod_state (dpy, window, "solaris", "Solaris");
2314   int i;
2315
2316   bst->scroll_p = True;
2317   bst->wrap_p = True;
2318   bst->left_margin = bst->right_margin = bst->xgwa.width  * 0.07;
2319   bst->top_margin = bst->bottom_margin = bst->xgwa.height * 0.07;
2320   bst->y = bst->top_margin + bst->font->ascent;
2321
2322   BSOD_IMG (bst);
2323   BSOD_PAUSE (bst, 3000000);
2324
2325   BSOD_INVERT(bst);
2326   BSOD_RECT (bst, True, 
2327              bst->left_margin, bst->top_margin,
2328              bst->xgwa.width - bst->left_margin - bst->right_margin,
2329              bst->xgwa.height - bst->top_margin - bst->bottom_margin);
2330   BSOD_INVERT(bst);
2331
2332   BSOD_TEXT (bst, LEFT,
2333     "BAD TRAP: cpu=0 type=0x31 rp=0x2a10043b5e0 addr=0xf3880 mmu_fsr=0x0\n"
2334     "BAD TRAP occurred in module \"unix\" due to an illegal access to a"
2335     " user address.\n"
2336     "adb: trap type = 0x31\n"
2337     "addr=0xf3880\n"
2338     "pid=307, pc=0x100306e4, sp=0x2a10043ae81, tstate=0x4480001602,"
2339     " context=0x87f\n"
2340     "g1-g7: 1045b000, 32f, 10079440, 180, 300000ebde8, 0, 30000953a20\n"
2341     "Begin traceback... sp = 2a10043ae81\n"
2342     "Called from 100bd060, fp=2a10043af31, args=f3700 300008cc988 f3880 0"
2343     " 1 300000ebde0.\n"
2344     "Called from 101fe1bc, fp=2a10043b011, args=3000045a240 104465a0"
2345     " 300008e47d0 300008e48fa 300008ae350 300008ae410\n"
2346     "Called from 1007c520, fp=2a10043b0c1, args=300008e4878 300003596e8 0"
2347     " 3000045a320 0 3000045a220\n"
2348     "Called from 1007c498, fp=2a10043b171, args=1045a000 300007847f0 20"
2349     " 3000045a240 1 0\n"
2350     "Called from 1007972c, fp=2a10043b221, args=1 300009517c0 30000951e58 1"
2351     " 300007847f0 0\n"
2352     "Called from 10031e10, fp=2a10043b2d1, args=3000095b0c8 0 300009396a8"
2353     " 30000953a20 0 1\n"
2354     "Called from 10000bdd8, fp=ffffffff7ffff1c1, args=0 57 100131480"
2355     " 100131480 10012a6e0 0\n"
2356     "End traceback...\n"
2357     "panic[cpu0]/thread=30000953a20: trap\n"
2358     "syncing file systems...");
2359
2360   BSOD_PAUSE (bst, 3000000);
2361
2362   BSOD_TEXT (bst, LEFT, " 1 done\n");
2363   BSOD_TEXT (bst, LEFT, "dumping to /dev/dsk/c0t0d0s3, offset 26935296\n");
2364   BSOD_PAUSE (bst, 2000000);
2365
2366
2367   for (i = 1; i <= 100; ++i)
2368     {
2369       char buf[100];
2370       sprintf (buf, "\b\b\b\b\b\b\b\b\b\b\b%3d%% done", i);
2371       BSOD_TEXT (bst, LEFT, buf);
2372       BSOD_PAUSE (bst, 100000);
2373     }
2374
2375   BSOD_TEXT (bst, LEFT,
2376     ": 2803 pages dumped, compression ratio 2.88, dump succeeded\n");
2377   BSOD_PAUSE (bst, 2000000);
2378
2379   BSOD_TEXT (bst, LEFT,
2380     "rebooting...\n"
2381     "Resetting ...");
2382
2383   return bst;
2384 }
2385
2386
2387 /* Linux panic and fsck, by jwz
2388  */
2389 static struct bsod_state *
2390 linux_fsck (Display *dpy, Window window)
2391 {
2392   struct bsod_state *bst = make_bsod_state (dpy, window, "linux", "Linux");
2393
2394   int i;
2395   const char *sysname;
2396   char buf[1024];
2397
2398   const char *linux_panic[] = {
2399    " kernel: Unable to handle kernel paging request at virtual "
2400      "address 0000f0ad\n",
2401    " kernel:  printing eip:\n",
2402    " kernel: c01becd7\n",
2403    " kernel: *pde = 00000000\n",
2404    " kernel: Oops: 0000\n",
2405    " kernel: CPU:    0\n",
2406    " kernel: EIP:    0010:[<c01becd7>]    Tainted: P \n",
2407    " kernel: EFLAGS: 00010286\n",
2408    " kernel: eax: 0000ff00   ebx: ca6b7e00   ecx: ce1d7a60   edx: ce1d7a60\n",
2409    " kernel: esi: ca6b7ebc   edi: 00030000   ebp: d3655ca0   esp: ca6b7e5c\n",
2410    " kernel: ds: 0018   es: 0018   ss: 0018\n",
2411    " kernel: Process crond (pid: 1189, stackpage=ca6b7000)\n",
2412    " kernel: Stack: d3655ca0 ca6b7ebc 00030054 ca6b7e7c c01c1e5b "
2413        "00000287 00000020 c01c1fbf \n",
2414    "",
2415    " kernel:        00005a36 000000dc 000001f4 00000000 00000000 "
2416        "ce046d40 00000001 00000000 \n",
2417    "", "", "",
2418    " kernel:        ffffffff d3655ca0 d3655b80 00030054 c01bef93 "
2419        "d3655ca0 ca6b7ebc 00030054 \n",
2420    "", "", "",
2421    " kernel: Call Trace:    [<c01c1e5b>] [<c01c1fbf>] [<c01bef93>] "
2422        "[<c01bf02b>] [<c0134c4f>]\n",
2423    "", "", "",
2424    " kernel:   [<c0142562>] [<c0114f8c>] [<c0134de3>] [<c010891b>]\n",
2425    " kernel: \n",
2426    " kernel: Code: 2a 00 75 08 8b 44 24 2c 85 c0 74 0c 8b 44 24 58 83 48 18 "
2427       "08 \n",
2428    0
2429   };
2430
2431   bst->scroll_p = True;
2432   bst->wrap_p = True;
2433   bst->left_margin = bst->right_margin = 10;
2434   bst->top_margin = bst->bottom_margin = 10;
2435
2436   sysname = "linux";
2437 # ifdef HAVE_UNAME
2438   {
2439     struct utsname uts;
2440     char *s;
2441     if (uname (&uts) >= 0)
2442       sysname = uts.nodename;
2443     s = strchr (sysname, '.');
2444     if (s) *s = 0;
2445   }
2446 # endif /* !HAVE_UNAME */
2447
2448
2449   BSOD_TEXT (bst, LEFT, "waiting for X server to shut down ");
2450   BSOD_PAUSE (bst, 100000);
2451   BSOD_TEXT (bst, LEFT,
2452              "XIO:  fatal IO error 2 (broken pipe) on X server \":0.0\"\n"
2453              "        after 339471 requests (339471 known processed) "
2454              "with 0 events remaining\n");
2455   BSOD_CHAR_DELAY (bst, 300000);
2456   BSOD_TEXT (bst, LEFT, ".........\n");
2457   BSOD_CHAR_DELAY (bst, 0);
2458   BSOD_TEXT (bst, LEFT, 
2459              "xinit:  X server slow to shut down, sending KILL signal.\n"
2460              "waiting for server to die ");
2461   BSOD_CHAR_DELAY (bst, 300000);
2462   BSOD_TEXT (bst, LEFT, "...\n");
2463   BSOD_CHAR_DELAY (bst, 0);
2464   BSOD_TEXT (bst, LEFT, "xinit:  Can't kill server\n");
2465   BSOD_PAUSE (bst, 2000000);
2466
2467   sprintf (buf, "\n%s Login: ", sysname);
2468   BSOD_TEXT (bst, LEFT, buf);
2469   BSOD_PAUSE (bst, 1000000);
2470   BSOD_TEXT (bst, LEFT,
2471     "\n\n"
2472     "Parallelizing fsck version 1.22 (22-Jun-2001)\n"
2473     "e2fsck 1.22, 22-Jun-2001 for EXT2 FS 0.5b, 95/08/09\n"
2474     "Warning!  /dev/hda1 is mounted.\n"
2475     "/dev/hda1 contains a file system with errors, check forced.\n");
2476   BSOD_PAUSE (bst, 1000000);
2477
2478   if (0 == random() % 2)
2479     BSOD_TEXT (bst, LEFT,
2480      "Couldn't find ext2 superblock, trying backup blocks...\n"
2481      "The filesystem size (according to the superblock) is 3644739 blocks\n"
2482      "The physical size of the device is 3636706 blocks\n"
2483      "Either the superblock or the partition table is likely to be corrupt!\n"
2484      "Abort<y>? no\n");
2485   BSOD_PAUSE (bst, 1000000);
2486
2487  AGAIN:
2488
2489   BSOD_TEXT (bst, LEFT, "Pass 1: Checking inodes, blocks, and sizes\n");
2490   BSOD_PAUSE (bst, 2000000);
2491
2492   i = (random() % 60) - 20;
2493   while (--i > 0)
2494     {
2495       int b = random() % 0xFFFF;
2496       sprintf (buf, "Deleted inode %d has zero dtime.  Fix<y>? yes\n\n", b);
2497       BSOD_TEXT (bst, LEFT, buf);
2498       BSOD_PAUSE (bst, 1000);
2499     }
2500
2501   i = (random() % 40) - 10;
2502   if (i > 0)
2503     {
2504       int g = random() % 0xFFFF;
2505       int b = random() % 0xFFFFFFF;
2506
2507       BSOD_PAUSE (bst, 1000000);
2508
2509       sprintf (buf, "Warning: Group %d's copy of the group descriptors "
2510                "has a bad block (%d).\n", g, b);
2511       BSOD_TEXT (bst, LEFT, buf);
2512
2513       b = random() % 0x3FFFFF;
2514       while (--i > 0)
2515         {
2516           b += random() % 0xFFFF;
2517           sprintf (buf,
2518                    "Error reading block %d (Attempt to read block "
2519                    "from filesystem resulted in short read) while doing "
2520                    "inode scan.  Ignore error<y>?",
2521                    b);
2522           BSOD_TEXT (bst, LEFT, buf);
2523           BSOD_PAUSE (bst, 10000);
2524           BSOD_TEXT (bst, LEFT, " yes\n\n");
2525         }
2526     }
2527
2528   if (0 == (random() % 10))
2529     {
2530       BSOD_PAUSE (bst, 1000000);
2531
2532       i = 3 + (random() % 10);
2533       while (--i > 0)
2534         {
2535           BSOD_TEXT (bst, LEFT,
2536                      "Could not allocate 256 block(s) for inode table: "
2537                      "No space left on device\n");
2538           BSOD_PAUSE (bst, 1000);
2539         }
2540       BSOD_TEXT (bst, LEFT, "Restarting e2fsck from the beginning...\n");
2541       BSOD_PAUSE (bst, 2000000);
2542
2543       goto AGAIN;
2544     }
2545
2546   i = (random() % 20) - 5;
2547
2548   if (i > 0)
2549     BSOD_PAUSE (bst, 1000000);
2550
2551   while (--i > 0)
2552     {
2553       int j = 5 + (random() % 10);
2554       int w = random() % 4;
2555
2556       while (--j > 0)
2557         {
2558           int b = random() % 0xFFFFF;
2559           int g = random() % 0xFFF;
2560
2561           if (0 == (random() % 10))
2562             b = 0;
2563           else if (0 == (random() % 10))
2564             b = -1;
2565
2566           if (w == 0)
2567             sprintf (buf,
2568                      "Inode table for group %d not in group.  (block %d)\n"
2569                      "WARNING: SEVERE DATA LOSS POSSIBLE.\n"
2570                      "Relocate<y>?",
2571                      g, b);
2572           else if (w == 1)
2573             sprintf (buf,
2574                      "Block bitmap for group %d not in group.  (block %d)\n"
2575                      "Relocate<y>?",
2576                      g, b);
2577           else if (w == 2)
2578             sprintf (buf,
2579                      "Inode bitmap %d for group %d not in group.\n"
2580                      "Continue<y>?",
2581                      b, g);
2582           else /* if (w == 3) */
2583             sprintf (buf,
2584                      "Bad block %d in group %d's inode table.\n"
2585                      "WARNING: SEVERE DATA LOSS POSSIBLE.\n"
2586                      "Relocate<y>?",
2587                      b, g);
2588
2589           BSOD_TEXT (bst, LEFT, buf);
2590           BSOD_TEXT (bst, LEFT, " yes\n\n");
2591           BSOD_PAUSE (bst, 1000);
2592         }
2593     }
2594
2595
2596   if (0 == random() % 10) goto PANIC;
2597   BSOD_TEXT (bst, LEFT, "Pass 2: Checking directory structure\n");
2598   BSOD_PAUSE (bst, 2000000);
2599
2600   i = (random() % 20) - 5;
2601   while (--i > 0)
2602     {
2603       int n = random() % 0xFFFFF;
2604       int o = random() % 0xFFF;
2605       sprintf (buf, "Directory inode %d, block 0, offset %d: "
2606                "directory corrupted\n"
2607                "Salvage<y>? ",
2608                n, o);
2609       BSOD_TEXT (bst, LEFT, buf);
2610       BSOD_PAUSE (bst, 1000);
2611       BSOD_TEXT (bst, LEFT, " yes\n\n");
2612
2613       if (0 == (random() % 100))
2614         {
2615           sprintf (buf, "Missing '.' in directory inode %d.\nFix<y>?", n);
2616           BSOD_TEXT (bst, LEFT, buf);
2617           BSOD_PAUSE (bst, 1000);
2618           BSOD_TEXT (bst, LEFT, " yes\n\n");
2619         }
2620     }
2621
2622   if (0 == random() % 10)
2623     goto PANIC;
2624
2625   BSOD_TEXT (bst, LEFT, 
2626              "Pass 3: Checking directory connectivity\n"
2627              "/lost+found not found.  Create? yes\n");
2628   BSOD_PAUSE (bst, 2000000);
2629
2630   /* Unconnected directory inode 4949 (/var/spool/squid/06/???)
2631      Connect to /lost+found<y>? yes
2632
2633      '..' in /var/spool/squid/06/08 (20351) is <The NULL inode> (0), should be 
2634      /var/spool/squid/06 (20350).
2635      Fix<y>? yes
2636
2637      Unconnected directory inode 128337 (/var/spool/squid/06/???)
2638      Connect to /lost+found<y>? yes
2639    */
2640
2641
2642   if (0 == random() % 10) goto PANIC;
2643   BSOD_TEXT (bst, LEFT,  "Pass 4: Checking reference counts\n");
2644   BSOD_PAUSE (bst, 2000000);
2645
2646   /* Inode 2 ref count is 19, should be 20.  Fix<y>? yes
2647
2648      Inode 4949 ref count is 3, should be 2.  Fix<y>? yes
2649
2650         ...
2651
2652      Inode 128336 ref count is 3, should be 2.  Fix<y>? yes
2653
2654      Inode 128337 ref count is 3, should be 2.  Fix<y>? yes
2655
2656    */
2657
2658
2659   if (0 == random() % 10) goto PANIC;
2660   BSOD_TEXT (bst, LEFT,  "Pass 5: Checking group summary information\n");
2661   BSOD_PAUSE (bst, 2000000);
2662
2663   i = (random() % 200) - 50;
2664   if (i > 0)
2665     {
2666       BSOD_TEXT (bst, LEFT,  "Block bitmap differences: ");
2667       while (--i > 0)
2668         {
2669           sprintf (buf, " %d", -(random() % 0xFFF));
2670           BSOD_TEXT (bst, LEFT, buf);
2671           BSOD_PAUSE (bst, 1000);
2672         }
2673       BSOD_TEXT (bst, LEFT, "\nFix? yes\n\n");
2674     }
2675
2676
2677   i = (random() % 100) - 50;
2678   if (i > 0)
2679     {
2680       BSOD_TEXT (bst, LEFT,  "Inode bitmap differences: ");
2681       while (--i > 0)
2682         {
2683           sprintf (buf, " %d", -(random() % 0xFFF));
2684           BSOD_TEXT (bst, LEFT, buf);
2685           BSOD_PAUSE (bst, 1000);
2686         }
2687       BSOD_TEXT (bst, LEFT,  "\nFix? yes\n\n");
2688     }
2689
2690   i = (random() % 20) - 5;
2691   while (--i > 0)
2692     {
2693       int g = random() % 0xFFFF;
2694       int c = random() % 0xFFFF;
2695       sprintf (buf,
2696                "Free blocks count wrong for group #0 (%d, counted=%d).\nFix? ",
2697                g, c);
2698       BSOD_TEXT (bst, LEFT, buf);
2699       BSOD_PAUSE (bst, 1000);
2700       BSOD_TEXT (bst, LEFT,  " yes\n\n");
2701     }
2702
2703  PANIC:
2704
2705   i = 0;
2706   BSOD_TEXT (bst, LEFT,  "\n\n");
2707   while (linux_panic[i])
2708     {
2709       time_t t = time ((time_t *) 0);
2710       struct tm *tm = localtime (&t);
2711       char prefix[100];
2712
2713       if (*linux_panic[i])
2714         {
2715           strftime (prefix, sizeof(prefix)-1, "%b %d %H:%M:%S ", tm);
2716           BSOD_TEXT (bst, LEFT,  prefix);
2717           BSOD_TEXT (bst, LEFT,  sysname);
2718           BSOD_TEXT (bst, LEFT,  linux_panic[i]);
2719           BSOD_PAUSE (bst, 1000);
2720         }
2721       else
2722         BSOD_PAUSE (bst, 300000);
2723
2724       i++;
2725     }
2726   BSOD_PAUSE (bst, 4000000);
2727
2728   XClearWindow(dpy, window);
2729   return bst;
2730 }
2731
2732
2733 /*
2734  * Linux (hppa) panic, by Stuart Brady <sdbrady@ntlworld.com>
2735  * Output courtesy of M. Grabert
2736  */
2737 static struct bsod_state *
2738 hppa_linux (Display *dpy, Window window)
2739 {
2740   struct bsod_state *bst = 
2741     make_bsod_state (dpy, window, "hppalinux", "HPPALinux");
2742
2743   int i = 0;
2744   const char *release, *sysname, *gccversion, *version;
2745   long int linedelay = 0;
2746
2747   __extension__
2748   struct { long int delay; const char *string; } linux_panic[] =
2749     {{ 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"
2750           "\n\n\n\n\n\n\n\n\n\n\n\n\n" },
2751      { 0, "Linux version %s (root@%s) (gcc version %s) %s\n" },
2752      { 4000, "FP[0] enabled: Rev 1 Model 16\n" },
2753      { 10, "The 32-bit Kernel has started...\n" },
2754      { -1, "Determining PDC firmware type: System Map.\n" },
2755      { -1, "model 00005bb0 00000481 00000000 00000002 7778df9f 100000f0 "
2756            "00000008 000000b2 000000b2\n" },
2757      { -1, "vers  00000203\n" },
2758      { -1, "CPUID vers 17 rev 7 (0x00000227)\n" },
2759      { -1, "capabilities 0x3\n" },
2760      { -1, "model 9000/785/C3000\n" },
2761      { -1, "Total Memory: 1024 Mb\n" },
2762      { -1, "On node 0 totalpages: 262144\n" },
2763      { -1, "  DMA zone: 262144 pages, LIFO batch:16\n" },
2764      { -1, "  Normal zone: 0 pages, LIFO batch:1\n" },
2765      { -1, "  HighMem zone: 0 pages, LIFO batch:1\n" },
2766      { -1, "LCD display at f05d0008,f05d0000 registered\n" },
2767      { -1, "Building zonelist for node : 0\n" },
2768      { -1, "Kernel command line: ide=nodma root=/dev/sda3 HOME=/ ip=off "
2769            "console=ttyS0 TERM=vt102 palo_kernel=2/vmlinux-2.6\n" },
2770      { -1, "ide_setup: ide=nodmaIDE: Prevented DMA\n" },
2771      { -1, "PID hash table entries: 16 (order 4: 128 bytes)\n" },
2772      {500, "Console: colour dummy device 160x64\n" },
2773      { 10, "Memory: 1034036k available\n" },
2774      { -1, "Calibrating delay loop... 796.67 BogoMIPS\n" },
2775      { -1, "Dentry cache hash table entries: 131072 (order: 7, 524288 "
2776            "bytes)\n" },
2777      { -1, "Inode-cache hash table entries: 65536 (order: 6, 262144 "
2778            "bytes)\n" },
2779      { -1, "Mount-cache hash table entries: 512 (order: 0, 4096 bytes)\n" },
2780      { -1, "POSIX conformance testing by UNIFIX\n" },
2781      { -1, "NET: Registered protocol family 16\n" },
2782      { 100, "Searching for devices...\n" },
2783      { 25, "Found devices:\n" },
2784      { 10, "1. Astro BC Runway Port at 0xfed00000 [10] "
2785            "{ 12, 0x0, 0x582, 0x0000b }\n" },
2786      { -1, "2. Elroy PCI Bridge at 0xfed30000 [10/0] "
2787            "{ 13, 0x0, 0x782, 0x0000a }\n" },
2788      { -1, "3. Elroy PCI Bridge at 0xfed32000 [10/1] "
2789            "{ 13, 0x0, 0x782, 0x0000a }\n" },
2790      { -1, "4. Elroy PCI Bridge at 0xfed38000 [10/4] "
2791            "{ 13, 0x0, 0x782, 0x0000a }\n" },
2792      { -1, "5. Elroy PCI Bridge at 0xfed3c000 [10/6] "
2793            "{ 13, 0x0, 0x782, 0x0000a }\n" },
2794      { -1, "6. AllegroHigh W at 0xfffa0000 [32] "
2795            "{ 0, 0x0, 0x5bb, 0x00004 }\n" },
2796      { -1, "7. Memory at 0xfed10200 [49] { 1, 0x0, 0x086, 0x00009 }\n" },
2797      { -1, "CPU(s): 1 x PA8500 (PCX-W) at 400.000000 MHz\n" },
2798      { -1, "SBA found Astro 2.1 at 0xfed00000\n" },
2799      { -1, "lba version TR2.1 (0x2) found at 0xfed30000\n" },
2800      { -1, "lba version TR2.1 (0x2) found at 0xfed32000\n" },
2801      { -1, "lba version TR2.1 (0x2) found at 0xfed38000\n" },
2802      { -1, "lba version TR2.1 (0x2) found at 0xfed3c000\n" },
2803      { 100, "SCSI subsystem initialized\n" },
2804      { 10, "drivers/usb/core/usb.c: registered new driver usbfs\n" },
2805      { -1, "drivers/usb/core/usb.c: registered new driver hub\n" },
2806      { -1, "ikconfig 0.7 with /proc/config*\n" },
2807      { -1, "Initializing Cryptographic API\n" },
2808      { 250, "SuperIO: probe of 0000:00:0e.0 failed with error -1\n" },
2809      { 20, "SuperIO: Found NS87560 Legacy I/O device at 0000:00:0e.1 "
2810            "(IRQ 64)\n" },
2811      { -1, "SuperIO: Serial port 1 at 0x3f8\n" },
2812      { -1, "SuperIO: Serial port 2 at 0x2f8\n" },
2813      { -1, "SuperIO: Parallel port at 0x378\n" },
2814      { -1, "SuperIO: Floppy controller at 0x3f0\n" },
2815      { -1, "SuperIO: ACPI at 0x7e0\n" },
2816      { -1, "SuperIO: USB regulator enabled\n" },
2817      { -1, "SuperIO: probe of 0000:00:0e.2 failed with error -1\n" },
2818      { -1, "Soft power switch enabled, polling @ 0xf0400804.\n" },
2819      { -1, "pty: 256 Unix98 ptys configured\n" },
2820      { -1, "Generic RTC Driver v1.07\n" },
2821      { -1, "Serial: 8250/16550 driver $" "Revision: 1.100 $ 13 ports, "
2822            "IRQ sharing disabled\n" },
2823      { -1, "ttyS0 at I/O 0x3f8 (irq = 0) is a 16550A\n" },
2824      { -1, "ttyS1 at I/O 0x2f8 (irq = 0) is a 16550A\n" },
2825      { -1, "Linux Tulip driver version 1.1.13 (May 11, 2002)\n" },
2826      { 150, "tulip0: no phy info, aborting mtable build\n" },
2827      { 10, "tulip0:  MII transceiver #1 config 1000 status 782d "
2828            "advertising 01e1.\n" },
2829      { -1, "eth0: Digital DS21143 Tulip rev 65 at 0xf4008000, "
2830            "00:10:83:F9:B4:34, IRQ 66.\n" },
2831      { -1, "Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2\n" },
2832      { -1, "ide: Assuming 33MHz system bus speed for PIO modes; "
2833            "override with idebus=xx\n" },
2834      { 100, "SiI680: IDE controller at PCI slot 0000:01:06.0\n" },
2835      { 10, "SiI680: chipset revision 2\n" },
2836      { -1, "SiI680: BASE CLOCK == 133\n" },
2837      { -1, "SiI680: 100% native mode on irq 128\n" },
2838      { -1, "    ide0: MMIO-DMA at 0xf4800000-0xf4800007 -- "
2839            "Error, MMIO ports already in use.\n" },
2840      { -1, "    ide1: MMIO-DMA at 0xf4800008-0xf480000f -- "
2841            "Error, MMIO ports already in use.\n" },
2842      { 5, "hda: TS130220A2, ATA DISK drive\n" },
2843      { -1, "      _______________________________\n" },
2844      { -1, "     < Your System ate a SPARC! Gah! >\n" },
2845      { -1, "      -------------------------------\n" },
2846      { -1, "             \\   ^__^\n" },
2847      { -1, "              \\  (xx)\\_______\n" },
2848      { -1, "                 (__)\\       )\\/\\\n" },
2849      { -1, "                  U  ||----w |\n" },
2850      { -1, "                     ||     ||\n" },
2851      { -1, "swapper (pid 1): Breakpoint (code 0)\n" },
2852      { -1, "\n" },
2853      { -1, "     YZrvWESTHLNXBCVMcbcbcbcbOGFRQPDI\n" },
2854      { -1, "PSW: 00000000000001001111111100001111 Not tainted\n" },
2855      { -1, "r00-03  4d6f6f21 1032f010 10208f34 103fc2e0\n" },
2856      { -1, "r04-07  103fc230 00000001 00000001 0000000f\n" },
2857      { -1, "r08-11  103454f8 000f41fa 372d3980 103ee404\n" },
2858      { -1, "r12-15  3ccbf700 10344810 103ee010 f0400004\n" },
2859      { -1, "r16-19  f00008c4 f000017c f0000174 00000000\n" },
2860      { -1, "r20-23  fed32840 fed32800 00000000 0000000a\n" },
2861      { -1, "r24-27  0000ffa0 000000ff 103fc2e0 10326010\n" },
2862      { -1, "r28-31  00000000 00061a80 4ff98340 10208f34\n" },
2863      { -1, "sr0-3   00000000 00000000 00000000 00000000\n" },
2864      { -1, "sr4-7   00000000 00000000 00000000 00000000\n" },
2865      { -1, "\n" },
2866      { -1, "IASQ: 00000000 00000000 IAOQ: 00000000 00000004\n" },
2867      { -1, " IIR: 00000000    ISR: 00000000  IOR: 00000000\n" },
2868      { -1, " CPU:        0   CR30: 4ff98000 CR31: 1037c000\n" },
2869      { -1, " ORIG_R28: 55555555\n" },
2870      { -1, " IAOQ[0]: 0x0\n" },
2871      { -1, " IAOQ[1]: 0x4\n" },
2872      { -1, " RP(r2): probe_hwif+0x218/0x44c\n" },
2873      { -1, "Kernel panic: Attempted to kill init!\n" },
2874      { 0, NULL }};
2875
2876   bst->scroll_p = True;
2877   bst->wrap_p = True;
2878   bst->left_margin = bst->right_margin = 10;
2879   bst->top_margin = bst->bottom_margin = 10;
2880
2881   release = "2.6.0-test11-pa2";
2882   sysname = "hppa";
2883   version = "#2 Mon Dec 8 06:09:27 GMT 2003";
2884 # ifdef HAVE_UNAME
2885   {
2886     struct utsname uts;
2887     char *s;
2888     if (uname (&uts) >= 0)
2889       {
2890         sysname = uts.nodename;
2891         if (!strcmp (uts.sysname, "Linux"))
2892           {
2893             release = uts.release;
2894             version = uts.version;
2895           }
2896       }
2897     s = strchr (sysname, '.');
2898     if (s) *s = 0;
2899   }
2900 # endif /* !HAVE_UNAME */
2901
2902 # if (defined (__GNUC__) && defined (__VERSION__))
2903   gccversion = __VERSION__;
2904 # else /* !(defined (__GNUC__) && defined (__VERSION__)) */
2905   gccversion = "3.3.2 (Debian)";
2906 # endif /* !(defined (__GNUC__) && defined (__VERSION__)) */
2907
2908   /* Insert current host name into banner on line 2 */
2909   {
2910     char ss[1024];
2911     snprintf (ss, 1024, linux_panic[1].string, 
2912               release, sysname, gccversion, version);
2913     linux_panic[1].string = ss;
2914   }
2915
2916   BSOD_PAUSE (bst, 100000);
2917   while (linux_panic[i].string)
2918     {
2919       if (linux_panic[i].delay != -1)
2920         linedelay = linux_panic[i].delay * 1000;
2921       BSOD_PAUSE (bst, linedelay);
2922       BSOD_TEXT (bst, LEFT, linux_panic[i].string);
2923       i++;
2924     }
2925
2926   bst->y = bst->xgwa.height - bst->font->ascent - bst->font->descent;
2927
2928   XClearWindow(dpy, window);
2929   return bst;
2930 }
2931
2932
2933 /* VMS by jwz (text sent by Roland Barmettler <roli@barmettler.net>)
2934  */
2935 static struct bsod_state *
2936 vms (Display *dpy, Window window)
2937 {
2938   struct bsod_state *bst = make_bsod_state (dpy, window, "vms", "VMS");
2939
2940   const char *sysname;
2941   int char_delay = 0;
2942   int dot_delay = 40000;
2943   int chunk_delay = 500000;
2944   char *s, *s1;
2945   int i;
2946   int arg_count;
2947
2948   __extension__
2949
2950   const char *lines[] = {
2951     "%CNXMAN,  Lost connection to system #\n"
2952     "%SHADOW-I-VOLPROC, DSA0: shadow master has changed.  "
2953     "Dump file WILL be written if system crashes.\n"
2954     "\n",
2955     "",
2956
2957     "%CNXMAN,  Quorum lost, blocking activity\n"
2958     "%CNXMAN,  Timed-out lost connection to system #\n"
2959     "%CNXMAN,  Timed-out lost connection to system #\n"
2960     "%CNXMAN,  Timed-out lost connection to system #\n"
2961     "%CNXMAN,  Proposing reconfiguration of the VMScluster\n",
2962     "",
2963
2964     "%CNXMAN,  Removed from VMScluster system #\n"
2965     "%CNXMAN,  Removed from VMScluster system #\n"
2966     "%CNXMAN,  Removed from VMScluster system #\n"
2967     "%CNXMAN,  Completing VMScluster state transition\n",
2968
2969     "\n"
2970     "**** OpenVMS (TM) Alpha Operating system V7.3-1   - BUGCHECK ****\n"
2971     "\n"
2972     "** Bugcheck code = 000005DC: CLUEXIT, Node voluntarily exiting "
2973     "VMScluster\n"
2974     "** Crash CPU: 00    Primary CPU: 00    Active CPUs: 00000001\n"
2975     "** Current Process = NULL\n"
2976     "** Current PSB ID = 00000001\n"
2977     "** Image Name =\n"
2978     "\n"
2979     "** Dumping error log buffers to HBVS unit 0\n"
2980     "**** Unable to dump error log buffers to remaining shadow set members\n"
2981     "** Error log buffers not dumped to HBVS unit 200\n"
2982     "\n"
2983     "** Dumping memory to HBVS unit 0\n"
2984     "**** Starting compressed selective memory dump at #...\n",
2985
2986     "...",
2987
2988     "\n"
2989     "**** Memory dump complete - not all processes or global pages saved\n",
2990
2991     "\n"
2992     "halted CPU 0\n",
2993     "",
2994
2995     "\n"
2996     "halt code = 5\n"
2997     "HALT instruction executed\n"
2998     "PC = ffffffff800c3884\n",
2999
3000     "\n"
3001     "CPU 0 booting\n",
3002
3003     "\n"
3004     "resetting all I/O buses\n"
3005     "\n"
3006     "\n"
3007     };
3008   char *args[8];
3009   int ids[3];
3010
3011   bst->scroll_p = True;
3012   bst->wrap_p = True;
3013   bst->left_margin = bst->right_margin = 10;
3014   bst->top_margin = bst->bottom_margin = 10;
3015
3016   sysname = "VMS001";
3017 # ifdef HAVE_UNAME
3018   {
3019     struct utsname uts;
3020     if (uname (&uts) >= 0)
3021       sysname = uts.nodename;
3022     s = strchr (sysname, '.');
3023     if (s) *s = 0;
3024   }
3025 # endif /* !HAVE_UNAME */
3026
3027   args[0] = malloc (strlen(sysname) + 7);
3028   strcpy (args[0], sysname);
3029   args[0][5] = 0;
3030
3031   /* Pick three numbers, 1-9, no overlaps. */
3032   ids[0] = 1 + (random() % 9);
3033   do { ids[1] = 1 + (random() % 9); } while (ids[1]==ids[0]);
3034   do { ids[2] = 1 + (random() % 9); } while (ids[2]==ids[0] || ids[2]==ids[1]);
3035
3036   i = strlen(args[0])-1;
3037   if (i < 6) i++;
3038   args[0][i] = '0' + ids[0];
3039   args[0][i+1] = 0;
3040
3041   for (s = args[0]; *s; s++)
3042     if (isalpha(*s)) *s = toupper (*s);
3043
3044   args[1] = strdup (args[0]);
3045   args[2] = strdup (args[0]); args[2][i] = '0' + ids[1];
3046   args[3] = strdup (args[0]); args[3][i] = '0' + ids[2];
3047
3048   args[4] = strdup (args[1]);
3049   args[5] = strdup (args[2]);
3050   args[6] = strdup (args[3]);
3051
3052   {
3053     time_t t = time ((time_t *) 0);
3054     struct tm *tm = localtime (&t);
3055     args[7] = malloc (30);
3056     strftime (args[7], 29, "%d-%b-%Y %H:%M", tm);
3057     for (s = args[7]; *s; s++)
3058       if (isalpha(*s)) *s = toupper (*s);
3059   }
3060
3061   arg_count = 0;
3062   for (i = 0; i < countof(lines); i++)
3063     {
3064       const char *fmt = lines[i];
3065       if (! strcmp (fmt, "..."))
3066         {
3067           int steps = 180 + (random() % 60);
3068           while (--steps >= 0)
3069             {
3070               BSOD_TEXT (bst, LEFT, ".");
3071               BSOD_PAUSE (bst, dot_delay);
3072             }
3073         }
3074       else
3075         {
3076           char *fmt2 = malloc (strlen (fmt) * 2 + 1);
3077           for (s = (char *) fmt, s1 = fmt2; *s; s++)
3078             {
3079               if (*s == '#')
3080                 {
3081                   strcpy (s1, args[arg_count++]);
3082                   s1 += strlen(s1);
3083                 }
3084               else
3085                 *s1++ = *s;
3086             }
3087           *s1 = 0;
3088           BSOD_CHAR_DELAY (bst, char_delay);
3089           BSOD_TEXT (bst, LEFT, fmt2);
3090           free (fmt2);
3091           BSOD_CHAR_DELAY (bst, 0);
3092           BSOD_PAUSE (bst, chunk_delay);
3093         }
3094     }
3095
3096   for (i = 0; i < countof (args); i++)
3097     free (args[i]);
3098
3099   XClearWindow(dpy, window);
3100   return bst;
3101 }
3102
3103
3104 /* HVX (formerly GCOS6) and TPS6 crash
3105    by Brian Garratt <brian-m.garratt@bull.co.uk>
3106
3107    GCOS6 is a Unix-like operating system developed by Honeywell in the
3108    1970s in collaboration with MIT and AT&T (who called their version
3109    UNIX).  Both are very much like MULTICS which Honeywell got from GE.
3110
3111    HVX ("High-performance Virtual System on Unix") is an AIX application
3112    which emulates GCOS6 hardware on RS6000-like machines.
3113  */
3114 static struct bsod_state *
3115 hvx (Display *dpy, Window window)
3116 {
3117   struct bsod_state *bst = make_bsod_state (dpy, window, "hvx", "HVX");
3118
3119   bst->scroll_p = True;
3120   bst->wrap_p = True;
3121   bst->y = bst->xgwa.height - bst->bottom_margin - bst->font->ascent;
3122
3123   BSOD_CHAR_DELAY (bst, 10000);
3124   BSOD_TEXT (bst, LEFT,
3125      "(TP) Trap no E   Effective address 00000000   Instruction D7DE\n"
3126      "(TP)  Registers :\n"
3127      "(TP)  B1 -> B7  03801B02  00000000  03880D45  038BABDB  0388AFFD"
3128      "  0389B3F8  03972317\n"
3129      "(TP)  R1 -> R7  0001  0007  F10F  090F  0020  0106  0272\n"
3130      "(TP)  P I Z M1  0388A18B  3232  0000 FF00\n"
3131      "(TP) Program counter is at offset 0028 from string YTPAD\n"
3132      "(TP) User id of task which trapped is LT 626\n"
3133      "(TP)?\n"
3134      );
3135   BSOD_PAUSE (bst, 1000000);
3136
3137   BSOD_CHAR_DELAY (bst, 100000);
3138   BSOD_TEXT (bst, LEFT, " TP CLOSE ALL");
3139
3140   BSOD_CHAR_DELAY (bst, 10000);
3141   BSOD_TEXT (bst, LEFT, "\n(TP)?\n");
3142   BSOD_PAUSE (bst, 1000000);
3143
3144   BSOD_CHAR_DELAY (bst, 100000);
3145   BSOD_TEXT (bst, LEFT, " TP ABORT -LT ALL");
3146
3147   BSOD_CHAR_DELAY (bst, 10000);
3148   BSOD_TEXT (bst, LEFT, "\n(TP)?\n");
3149   BSOD_PAUSE (bst, 1000000);
3150
3151   BSOD_CHAR_DELAY (bst, 100000);
3152   BSOD_TEXT (bst, LEFT, "  TP STOP KILL");
3153
3154   BSOD_CHAR_DELAY (bst, 10000);
3155   BSOD_TEXT (bst, LEFT,
3156      "\n"
3157      "(TP)?\n"
3158      "Core dumps initiated for selected HVX processes ...\n"
3159      "Core dumps complete.\n"
3160      "Fri Jul 19 15:53:09 2002\n"
3161      "Live registers for cp 0:\n"
3162      " P    =     7de3  IW=0000     I=32    CI=30000000   S=80006013"
3163      "   IV=aa0      Level=13\n"
3164      " R1-7 =       1f      913       13        4        8        0        0\n"
3165      " B1-7 =   64e71b      a93      50e   64e73c     6c2c     7000      b54\n"
3166      "Memory dump starting to file /var/hvx/dp01/diag/Level2 ...\n"
3167      "Memory dump complete.\n"
3168     );
3169
3170   XClearWindow(dpy, window);
3171   return bst;
3172 }
3173
3174
3175 /* HPUX panic, by Tobias Klausmann <klausman@schwarzvogel.de>
3176  */
3177 static struct bsod_state *
3178 hpux (Display *dpy, Window window)
3179 {
3180   struct bsod_state *bst = make_bsod_state (dpy, window, "hpux", "HPUX");
3181   const char *sysname;
3182   char buf[2048];
3183
3184   bst->scroll_p = True;
3185   bst->y = bst->xgwa.height - bst->bottom_margin - bst->font->ascent;
3186
3187   sysname = "HPUX";
3188 # ifdef HAVE_UNAME
3189   {
3190     struct utsname uts;
3191     char *s;
3192     if (uname (&uts) >= 0)
3193       sysname = uts.nodename;
3194     s = strchr (sysname, '.');
3195     if (s) *s = 0;
3196   }
3197 # endif /* !HAVE_UNAME */
3198
3199   BSOD_TEXT (bst, LEFT,
3200              "                                                       "
3201              "                                                       "
3202              "                                                       \n");
3203   sprintf (buf, "%.100s [HP Release B.11.00] (see /etc/issue)\n", sysname);
3204   BSOD_TEXT (bst, LEFT, buf);
3205   BSOD_PAUSE (bst, 1000000);
3206   BSOD_TEXT (bst, LEFT,
3207    "Console Login:\n"
3208    "\n"
3209    "     ******* Unexpected HPMC/TOC. Processor HPA FFFFFFFF'"
3210    "FFFA0000 *******\n"
3211    "                              GENERAL REGISTERS:\n"
3212    "r00/03 00000000'00000000 00000000'00000000 00000000'00000000 00000000'"
3213    "006C76C0\n"
3214    "r04/07 00000000'00000001 00000000'0126E328 00000000'00000000 00000000'"
3215    "0122B640\n"
3216    "r08/11 00000000'00000000 00000000'0198CFC0 00000000'000476FE 00000000'"
3217    "00000001\n"
3218    "r12/15 00000000'40013EE8 00000000'08000080 00000000'4002530C 00000000'"
3219    "4002530C\n"
3220    "r16/19 00000000'7F7F2A00 00000000'00000001 00000000'00000000 00000000'"
3221    "00000000\n"
3222    "r20/23 00000000'006C8048 00000000'00000001 00000000'00000000 00000000'"
3223    "00000000\n"
3224    "r24/27 00000000'00000000 00000000'00000000 00000000'00000000 00000000'"
3225    "00744378\n"
3226    "r28/31 00000000'00000000 00000000'007DD628 00000000'0199F2B0 00000000'"
3227    "00000000\n"
3228    "                              CONTROL REGISTERS:\n"
3229    "sr0/3  00000000'0F3B4000 00000000'0C2A2000 00000000'016FF800 00000000'"
3230    "00000000\n"
3231    "sr4/7  00000000'00000000 00000000'016FF800 00000000'0DBF1400 00000000'"
3232    "00000000\n"
3233    "pcq =  00000000'00000000.00000000'00104950 00000000'00000000.00000000'"
3234    "00104A14\n"
3235    "isr =  00000000'10240006 ior = 00000000'67D9E220 iir = 08000240 rctr = "
3236    "7FF10BB6\n"
3237    "\n"
3238    "pid reg cr8/cr9    00007700'0000B3A9 00000000'0000C5D8\n"
3239    "pid reg cr12/cr13  00000000'00000000 00000000'00000000\n"
3240    "ipsw = 000000FF'080CFF1F iva = 00000000'0002C000 sar = 3A ccr = C0\n"
3241    "tr0/3  00000000'006C76C0 00000000'00000001 00000000'00000000 00000000'"
3242    "7F7CE000\n"
3243    "tr4/7  00000000'03790000 0000000C'4FB68340 00000000'C07EE13F 00000000'"
3244    "0199F2B0\n"
3245    "eiem = FFFFFFF0'FFFFFFFF eirr = 80000000'00000000 itmr = 0000000C'"
3246    "4FD8EDE1\n"
3247    "cr1/4  00000000'00000000 00000000'00000000 00000000'00000000 00000000'"
3248    "00000000\n"
3249    "cr5/7  00000000'00000000 00000000'00000000 00000000'"
3250    "00000000\n"
3251    "                           MACHINE CHECK PARAMETERS:\n"
3252    "Check Type = 00000000 CPU STATE = 9E000001 Cache Check = 00000000\n"
3253    "TLB Check = 00000000 Bus Check = 00000000 PIM State = ? SIU "
3254    "Status = ????????\n"
3255    "Assists = 00000000 Processor = 00000000\n"
3256    "Slave Addr = 00000000'00000000 Master Addr = 00000000'00000000\n"
3257    "\n"
3258    "\n"
3259    "TOC,    pcsq.pcoq = 0'0.0'104950   , isr.ior = 0'10240006.0'67d9e220\n"
3260    "@(#)B2352B/9245XB HP-UX (B.11.00) #1: Wed Nov  5 22:38:19 PST 1997\n"
3261    "Transfer of control: (display==0xd904, flags==0x0)\n"
3262    "\n"
3263    "\n"
3264    "\n"
3265    "*** A system crash has occurred.  (See the above messages for details.)\n"
3266    "*** The system is now preparing to dump physical memory to disk, for use\n"
3267    "*** in debugging the crash.\n"
3268    "\n"
3269    "*** The dump will be a SELECTIVE dump:  40 of 256 megabytes.\n"
3270    "*** To change this dump type, press any key within 10 seconds.\n"
3271    "*** Proceeding with selective dump.\n"
3272    "\n"
3273    "*** The dump may be aborted at any time by pressing ESC.\n");
3274
3275   {
3276     int i;
3277     int steps = 11;
3278     int size = 40;
3279     for (i = 0; i <= steps; i++)
3280       {
3281         if (i > steps) i = steps;
3282         sprintf (buf, 
3283                "*** Dumping: %3d%% complete (%d of 40 MB) (device 64:0x2)\r",
3284                  i * 100 / steps,
3285                  i * size / steps);
3286         BSOD_TEXT (bst, LEFT, buf);
3287         BSOD_PAUSE (bst, 1500000);
3288       }
3289   }
3290
3291   BSOD_TEXT (bst, LEFT, "\n*** System rebooting.\n");
3292
3293   XClearWindow(dpy, window);
3294   return bst;
3295 }
3296
3297
3298 /* IBM OS/390 aka MVS aka z/OS.
3299    Text from Dan Espen <dane@mk.telcordia.com>.
3300    Apparently this isn't actually a crash, just a random session...
3301    But who can tell.
3302  */
3303 static struct bsod_state *
3304 os390 (Display *dpy, Window window)
3305 {
3306   struct bsod_state *bst = make_bsod_state (dpy, window, "os390", "OS390");
3307
3308   bst->scroll_p = True;
3309   bst->y = bst->xgwa.height - bst->bottom_margin - bst->font->ascent;
3310
3311   BSOD_LINE_DELAY (bst, 100000);
3312   BSOD_TEXT (bst, LEFT,
3313    "\n*** System rebooting.\n"
3314    "* ISPF Subtask abend *\n"
3315    "SPF      ENDED DUE TO ERROR+\n"
3316    "READY\n"
3317    "\n"
3318    "IEA995I SYMPTOM DUMP OUTPUT\n"
3319    "  USER COMPLETION CODE=0222\n"
3320    " TIME=23.00.51  SEQ=03210  CPU=0000  ASID=00AE\n"
3321    " PSW AT TIME OF ERROR  078D1000   859DAF18  ILC 2  INTC 0D\n"
3322    "   NO ACTIVE MODULE FOUND\n"
3323    "   NAME=UNKNOWN\n"
3324    "   DATA AT PSW  059DAF12 - 00181610  0A0D9180  70644710\n"
3325    "   AR/GR 0: 00000000/80000000   1: 00000000/800000DE\n"
3326    "         2: 00000000/196504DC   3: 00000000/00037A78\n"
3327    "         4: 00000000/00037B78   5: 00000000/0003351C\n"
3328    "         6: 00000000/0000F0AD   7: 00000000/00012000\n"
3329    "         8: 00000000/059DAF10   9: 00000000/0002D098\n"
3330    "         A: 00000000/059D9F10   B: 00000000/059D8F10\n"
3331    "         C: 00000000/859D7F10   D: 00000000/00032D60\n"
3332    "         E: 00000000/00033005   F: 01000002/00000041\n"
3333    " END OF SYMPTOM DUMP\n"
3334    "ISPS014 - ** Logical screen request failed - abend 0000DE **\n"
3335    "ISPS015 - ** Contact your system programmer or dialog developer.**\n"
3336    "*** ISPF Main task abend ***\n"
3337    "IEA995I SYMPTOM DUMP OUTPUT\n"
3338    "  USER COMPLETION CODE=0222\n"
3339    " TIME=23.00.52  SEQ=03211  CPU=0000  ASID=00AE\n"
3340    " PSW AT TIME OF ERROR  078D1000   8585713C  ILC 2  INTC 0D\n"
3341    "   ACTIVE LOAD MODULE           ADDRESS=05855000  OFFSET=0000213C\n"
3342    "   NAME=ISPMAIN\n"
3343    "   DATA AT PSW  05857136 - 00181610  0A0D9180  D3304770\n"
3344    "   GR 0: 80000000   1: 800000DE\n"
3345    "      2: 00015260   3: 00000038\n"
3346    "      4: 00012508   5: 00000000\n"
3347    "      6: 000173AC   7: FFFFFFF8\n"
3348    "      8: 05858000   9: 00012CA0\n"
3349    "      A: 05857000   B: 05856000\n"
3350    "      C: 85855000   D: 00017020\n"
3351    "      E: 85857104   F: 00000000\n"
3352    " END OF SYMPTOM DUMP\n"
3353    "READY\n"
3354    "***");
3355   BSOD_CURSOR (bst, CURSOR_LINE, 240000, 999999);
3356
3357   XClearWindow(dpy, window);
3358   return bst;
3359 }
3360
3361
3362 /* Compaq Tru64 Unix panic, by jwz as described by
3363    Tobias Klausmann <klausman@schwarzvogel.de>
3364  */
3365 static struct bsod_state *
3366 tru64 (Display *dpy, Window window)
3367 {
3368   struct bsod_state *bst = make_bsod_state (dpy, window, "tru64", "Tru64");
3369   const char *sysname;
3370   char buf[2048];
3371
3372   bst->scroll_p = True;
3373   bst->y = bst->xgwa.height - bst->bottom_margin - bst->font->ascent;
3374
3375   sysname = "127.0.0.1";
3376 # ifdef HAVE_UNAME
3377   {
3378     struct utsname uts;
3379     if (uname (&uts) >= 0)
3380       sysname = uts.nodename;
3381   }
3382 # endif /* !HAVE_UNAME */
3383
3384   sprintf (buf,
3385            "Compaq Tru64 UNIX V5.1B (Rev. 2650) (%.100s) console\n"
3386            "\n"
3387            "login: ",
3388            sysname);
3389   BSOD_TEXT (bst, LEFT, buf);
3390   BSOD_PAUSE (bst, 6000000);
3391
3392   BSOD_TEXT (bst, LEFT,
3393     "panic (cpu 0): trap: illegal instruction\n"
3394     "kernel inst fault=gentrap, ps=0x5, pc=0xfffffc0000593878, inst=0xaa\n"
3395     "kernel inst fault=gentrap, ps=0x5, pc=0xfffffc0000593878, inst=0xaa\n"
3396     "                                                                   \n"
3397     "DUMP: blocks available:  1571600\n"
3398     "DUMP: blocks wanted:      100802 (partial compressed dump) [OKAY]\n"
3399     "DUMP: Device     Disk Blocks Available\n"
3400     "DUMP: ------     ---------------------\n"
3401     "DUMP: 0x1300023  1182795 - 1571597 (of 1571598) [primary swap]\n"
3402     "DUMP.prom: Open: dev 0x5100041, block 2102016: SCSI 0 11 0 2 200 0 0\n"
3403     "DUMP: Writing header... [1024 bytes at dev 0x1300023, block 1571598]\n"
3404     "DUMP: Writing data");
3405
3406   {
3407     int i;
3408     int steps = 4 + (random() % 8);
3409     BSOD_CHAR_DELAY (bst, 1000000);
3410     for (i = 0; i < steps; i++)
3411       BSOD_TEXT (bst, LEFT, ".");
3412     BSOD_CHAR_DELAY (bst, 0);
3413     sprintf (buf, "[%dMB]\n", steps);
3414     BSOD_TEXT (bst, LEFT, buf);
3415   }
3416
3417   BSOD_TEXT (bst, LEFT,
3418     "DUMP: Writing header... [1024 bytes at dev 0x1300023, block 1571598]\n"
3419     "DUMP: crash dump complete.\n"
3420     "kernel inst fault=gentrap, ps=0x5, pc=0xfffffc0000593878, inst=0xaa\n"
3421     "                                                                   \n"
3422     "DUMP: second crash dump skipped: 'dump_savecnt' enforced.\n");
3423   BSOD_PAUSE (bst, 4000000);
3424
3425   BSOD_TEXT (bst, LEFT,
3426     "\n"
3427     "halted CPU 0\n"
3428     "\n"
3429     "halt code = 5\n"
3430     "HALT instruction executed\n"
3431     "PC = fffffc00005863b0\n");
3432   BSOD_PAUSE (bst, 3000000);
3433
3434   BSOD_TEXT (bst, LEFT,
3435     "\n"   
3436     "CPU 0 booting\n"
3437     "\n"
3438     "\n"
3439     "\n");
3440
3441   XClearWindow(dpy, window);
3442   return bst;
3443 }
3444
3445
3446 /* MS-DOS, by jwz
3447  */
3448 static struct bsod_state *
3449 msdos (Display *dpy, Window window)
3450 {
3451   struct bsod_state *bst = make_bsod_state (dpy, window, "msdos", "MSDOS");
3452
3453   BSOD_CHAR_DELAY (bst, 10000);
3454   BSOD_TEXT (bst, LEFT, "C:\\WINDOWS>");
3455   BSOD_CURSOR (bst, CURSOR_LINE, 200000, 8);
3456
3457   BSOD_CHAR_DELAY (bst, 200000);
3458   BSOD_TEXT (bst, LEFT, "dir a:");
3459   BSOD_PAUSE (bst, 1000000);
3460
3461   BSOD_CHAR_DELAY (bst, 10000);
3462   BSOD_TEXT (bst, LEFT, "\nNot ready reading drive A\nAbort, Retry, Fail?");
3463
3464   BSOD_CURSOR (bst, CURSOR_LINE, 200000, 10);
3465   BSOD_CHAR_DELAY (bst, 200000);
3466   BSOD_TEXT (bst, LEFT, "f");
3467   BSOD_PAUSE (bst, 1000000);
3468
3469   BSOD_CHAR_DELAY (bst, 10000);
3470   BSOD_TEXT (bst, LEFT,
3471              "\n\n\nNot ready reading drive A\nAbort, Retry, Fail?");
3472
3473   BSOD_CURSOR (bst, CURSOR_LINE, 200000, 10);
3474   BSOD_CHAR_DELAY (bst, 200000);
3475   BSOD_TEXT (bst, LEFT, "f");
3476   BSOD_PAUSE (bst, 1000000);
3477
3478   BSOD_CHAR_DELAY (bst, 10000);
3479   BSOD_TEXT (bst, LEFT, "\nVolume in drive A has no label\n\n"
3480                   "Not ready reading drive A\nAbort, Retry, Fail?");
3481
3482   BSOD_CURSOR (bst, CURSOR_LINE, 200000, 12);
3483   BSOD_CHAR_DELAY (bst, 200000);
3484   BSOD_TEXT (bst, LEFT, "a");
3485   BSOD_PAUSE (bst, 1000000);
3486
3487   BSOD_CHAR_DELAY (bst, 10000);
3488   BSOD_TEXT (bst, LEFT, "\n\nC:\\WINDOWS>");
3489
3490   BSOD_CURSOR (bst, CURSOR_LINE, 200000, 999999);
3491
3492   XClearWindow(dpy, window);
3493   return bst;
3494 }
3495
3496
3497 /* nvidia, by jwz.
3498  *
3499  * This is what happens if an Nvidia card goes into some crazy text mode.
3500  * Most often seen on the second screen of a dual-head system when the
3501  * proper driver isn't loaded.
3502  */
3503 typedef struct { int fg; int bg; int bit; Bool blink; } nvcell;
3504
3505 static void
3506 nvspatter (nvcell *grid, int rows, int cols, int ncolors, int nbits,
3507            Bool fill_p)
3508 {
3509   int max = rows * cols;
3510   int from = fill_p ?   0 : random() % (max - 1);
3511   int len  = fill_p ? max : random() % (cols * 4);
3512   int to = from + len;
3513   int i;
3514   Bool noisy = ((random() % 4) == 0);
3515   Bool diag = (noisy || fill_p) ? 0 : ((random() % 4) == 0);
3516
3517   int fg = random() % ncolors;
3518   int bg = random() % ncolors;
3519   int blink = ((random() % 4) == 0);
3520   int bit = (random() % nbits);
3521
3522   if (to > max) to = max;
3523
3524   if (diag)
3525     {
3526       int src = random() % (rows * cols);
3527       int len2 = (cols / 2) - (random() % 5);
3528       int j = src;
3529       for (i = from; i < to; i++, j++)
3530         {
3531           if (j > src + len2 || j >= max)
3532             j = src;
3533           if (i >= max) abort();
3534           if (j >= max) abort();
3535           grid[j] = grid[i];
3536         }
3537     }
3538   else
3539     for (i = from; i < to; i++)
3540       {
3541         nvcell *cell = &grid[i];
3542         cell->fg = fg;
3543         cell->bg = bg;
3544         cell->bit = bit;
3545         cell->blink = blink;
3546
3547         if (noisy)
3548           {
3549             fg = random() % ncolors;
3550             bg = random() % ncolors;
3551             blink = ((random() % 8) == 0);
3552           }
3553       }
3554 }
3555
3556 typedef struct {
3557   struct bsod_state *bst;
3558   GC gc1;
3559   Pixmap bits[5];
3560   int rows, cols;
3561   int cellw, cellh;
3562   nvcell *grid;
3563   int ncolors;
3564   unsigned long colors[256];
3565   int tick;
3566 } nvstate;
3567
3568
3569 static void
3570 nvidia_free (struct bsod_state *bst)
3571 {
3572   nvstate *nvs = (nvstate *) bst->closure;
3573   int i;
3574   XFreeColors (bst->dpy, bst->xgwa.colormap, nvs->colors, nvs->ncolors, 0);
3575   for (i = 0; i < countof(nvs->bits); i++)
3576     XFreePixmap (bst->dpy, nvs->bits[i]);
3577   XFreeGC (bst->dpy, nvs->gc1);
3578   free (nvs->grid);
3579   free (nvs);
3580 }
3581
3582 static int
3583 nvidia_draw (struct bsod_state *bst)
3584 {
3585   nvstate *nvs = (nvstate *) bst->closure;
3586   int x, y;
3587
3588   for (y = 0; y < nvs->rows; y++)
3589     for (x = 0; x < nvs->cols; x++)
3590       {
3591         nvcell *cell = &nvs->grid[y * nvs->cols + x];
3592         unsigned long fg = nvs->colors[cell->fg];
3593         unsigned long bg = nvs->colors[cell->bg];
3594         Bool flip = cell->blink && (nvs->tick & 1);
3595         XSetForeground (bst->dpy, bst->gc, flip ? fg : bg);
3596         XSetBackground (bst->dpy, bst->gc, flip ? bg : fg);
3597         XCopyPlane (bst->dpy, nvs->bits[cell->bit], bst->window, bst->gc,
3598                     0, 0, nvs->cellw, nvs->cellh,
3599                     x * nvs->cellw, y * nvs->cellh, 1L);
3600       }
3601
3602   nvs->tick++;
3603   if ((random() % 5) == 0)    /* change the display */
3604     nvspatter (nvs->grid, nvs->rows, nvs->cols, nvs->ncolors, 
3605                countof(nvs->bits), False);
3606
3607   return 250000;
3608 }
3609
3610
3611 static struct bsod_state *
3612 nvidia (Display *dpy, Window window)
3613 {
3614   struct bsod_state *bst = make_bsod_state (dpy, window, "nvidia", "nVidia");
3615   nvstate *nvs = (nvstate *) calloc (1, sizeof (*nvs));
3616
3617   XGCValues gcv;
3618   int i;
3619
3620   nvs->bst = bst;
3621   bst->closure = nvs;
3622   bst->draw_cb = nvidia_draw;
3623   bst->free_cb = nvidia_free;
3624
3625   nvs->cols = 80;
3626   nvs->rows = 25;
3627   nvs->cellw = bst->xgwa.width  / nvs->cols;
3628   nvs->cellh = bst->xgwa.height / nvs->rows;
3629   if (nvs->cellw < 8 || nvs->cellh < 18)
3630     nvs->cellw = 8, nvs->cellh = 18;
3631   nvs->cols = (bst->xgwa.width  / nvs->cellw) + 1;
3632   nvs->rows = (bst->xgwa.height / nvs->cellh) + 1;
3633
3634   nvs->grid = (nvcell *) calloc (sizeof(*nvs->grid), nvs->rows * nvs->cols);
3635
3636   /* Allocate colors
3637    */
3638   nvs->ncolors = 16;
3639   for (i = 0; i < nvs->ncolors; i++)
3640     {
3641       XColor c;
3642       c.red   = random() & 0xFFFF;
3643       c.green = random() & 0xFFFF;
3644       c.blue  = random() & 0xFFFF;
3645       c.flags = DoRed|DoGreen|DoBlue;
3646       XAllocColor (dpy, bst->xgwa.colormap, &c);
3647       nvs->colors[i] = c.pixel;
3648     }
3649
3650   /* Construct corrupted character bitmaps
3651    */
3652   for (i = 0; i < countof(nvs->bits); i++)
3653     {
3654       int j;
3655
3656       nvs->bits[i] = XCreatePixmap (dpy, window, nvs->cellw, nvs->cellh, 1);
3657       if (!nvs->gc1) nvs->gc1 = XCreateGC (dpy, nvs->bits[i], 0, &gcv);
3658
3659       XSetForeground (dpy, nvs->gc1, 0);
3660       XFillRectangle (dpy, nvs->bits[i], nvs->gc1, 0, 0, 
3661                       nvs->cellw, nvs->cellh);
3662       XSetForeground (dpy, nvs->gc1, 1);
3663
3664       if ((random() % 40) != 0)
3665         for (j = 0; j < ((nvs->cellw * nvs->cellh) / 16); j++)
3666           XFillRectangle (dpy, nvs->bits[i], nvs->gc1,
3667                           (random() % (nvs->cellw-2)) & ~1,
3668                           (random() % (nvs->cellh-2)) & ~1,
3669                           2, 2);
3670     }
3671
3672   /* Randomize the grid
3673    */
3674   nvspatter (nvs->grid, nvs->rows, nvs->cols, nvs->ncolors, 
3675              countof(nvs->bits), True);
3676   for (i = 0; i < 20; i++)
3677     nvspatter (nvs->grid, nvs->rows, nvs->cols, nvs->ncolors, 
3678                countof(nvs->bits), False);
3679
3680   return bst;
3681 }
3682
3683
3684 /*
3685  * Simulate various Apple ][ crashes. The memory map encouraged many programs
3686  * to use the primary hi-res video page for various storage, and the secondary
3687  * hi-res page for active display. When it crashed into Applesoft or the
3688  * monitor, it would revert to the primary page and you'd see memory garbage on
3689  * the screen. Also, it was common for copy-protected games to use the primary
3690  * text page for important code, because that made it really hard to
3691  * reverse-engineer them. The result often looked like what this generates.
3692  *
3693  * The Apple ][ logic and video hardware is in apple2.c. The TV is emulated by
3694  * analogtv.c for maximum realism
3695  *
3696  * Trevor Blackwell <tlb@tlb.org> 
3697  */
3698
3699 static const char * const apple2_basic_errors[]={
3700   "BREAK",
3701   "NEXT WITHOUT FOR",
3702   "SYNTAX ERROR",
3703   "RETURN WITHOUT GOSUB",
3704   "ILLEGAL QUANTITY",
3705   "OVERFLOW",
3706   "OUT OF MEMORY",
3707   "BAD SUBSCRIPT ERROR",
3708   "DIVISION BY ZERO",
3709   "STRING TOO LONG",
3710   "FORMULA TOO COMPLEX",
3711   "UNDEF'D FUNCTION",
3712   "OUT OF DATA"
3713 #if 0
3714   ,
3715   "DEFAULT ARGUMENTS ARE NOT ALLOWED IN DECLARATION OF FRIEND "
3716   "TEMPLATE SPECIALIZATION"
3717 #endif
3718
3719 };
3720 static const char * const apple2_dos_errors[]={
3721   "VOLUME MISMATCH",
3722   "I/O ERROR",
3723   "DISK FULL",
3724   "NO BUFFERS AVAILABLE",
3725   "PROGRAM TOO LARGE",
3726 };
3727
3728 static void a2controller_crash(apple2_sim_t *sim, int *stepno,
3729                                double *next_actiontime)
3730 {
3731   apple2_state_t *st=sim->st;
3732   char *s;
3733   int i;
3734
3735   struct mydata {
3736     int fillptr;
3737     int fillbyte;
3738   } *mine;
3739
3740   if (!sim->controller_data)
3741     sim->controller_data = calloc(sizeof(struct mydata),1);
3742   mine=(struct mydata *) sim->controller_data;
3743   
3744   switch(*stepno) {
3745   case 0:
3746     
3747     a2_init_memory_active(sim);
3748     sim->dec->powerup = 1000.0;
3749
3750     if (random()%3==0) {
3751       st->gr_mode=0;
3752       *next_actiontime+=0.4;
3753       *stepno=100;
3754     }
3755     else if (random()%4==0) {
3756       st->gr_mode=A2_GR_LORES;
3757       if (random()%3==0) st->gr_mode |= A2_GR_FULL;
3758       *next_actiontime+=0.4;
3759       *stepno=100;
3760     }
3761     else if (random()%2==0) {
3762       st->gr_mode=A2_GR_HIRES;
3763       *stepno=300;
3764     }
3765     else {
3766       st->gr_mode=A2_GR_HIRES;
3767       *next_actiontime+=0.4;
3768       *stepno=100;
3769     }
3770     break;
3771
3772   case 100:
3773     /* An illegal instruction or a reset caused it to drop into the
3774        assembly language monitor, where you could disassemble code & view
3775        data in hex. */
3776     if (random()%3==0) {
3777       char ibytes[128];
3778       char itext[128];
3779       int addr=0xd000+random()%0x3000;
3780       sprintf(ibytes,
3781               "%02X",random()%0xff);
3782       sprintf(itext,
3783               "???");
3784       sprintf(sim->printing_buf,
3785               "\n\n"
3786               "%04X: %-15s %s\n"
3787               " A=%02X X=%02X Y=%02X S=%02X F=%02X\n"
3788               "*",
3789               addr,ibytes,itext,
3790               random()%0xff, random()%0xff,
3791               random()%0xff, random()%0xff,
3792               random()%0xff);
3793       sim->printing=sim->printing_buf;
3794       a2_goto(st,23,1);
3795       if (st->gr_mode) {
3796         *stepno=180;
3797       } else {
3798         *stepno=200;
3799       }
3800       sim->prompt='*';
3801       *next_actiontime += 2.0 + (random()%1000)*0.0002;
3802     }
3803     else {
3804       /* Lots of programs had at least their main functionality in
3805          Applesoft Basic, which had a lot of limits (memory, string
3806          length, etc) and would sometimes crash unexpectedly. */
3807       sprintf(sim->printing_buf,
3808               "\n"
3809               "\n"
3810               "\n"
3811               "?%s IN %d\n"
3812               "\001]",
3813               apple2_basic_errors[random() %
3814                                   (sizeof(apple2_basic_errors)
3815                                    /sizeof(char *))],
3816               (1000*(random()%(random()%59+1)) +
3817                100*(random()%(random()%9+1)) +
3818                5*(random()%(random()%199+1)) +
3819                1*(random()%(random()%(random()%2+1)+1))));
3820       sim->printing=sim->printing_buf;
3821       a2_goto(st,23,1);
3822       *stepno=110;
3823       sim->prompt=']';
3824       *next_actiontime += 2.0 + (random()%1000)*0.0002;
3825     }
3826     break;
3827
3828   case 110:
3829     if (random()%3==0) {
3830       /* This was how you reset the Basic interpreter. The sort of
3831          incantation you'd have on a little piece of paper taped to the
3832          side of your machine */
3833       sim->typing="CALL -1370";
3834       *stepno=120;
3835     }
3836     else if (random()%2==0) {
3837       sim->typing="CATALOG\n";
3838       *stepno=170;
3839     }
3840     else {
3841       *next_actiontime+=1.0;
3842       *stepno=999;
3843     }
3844     break;
3845
3846   case 120:
3847     *stepno=130;
3848     *next_actiontime += 0.5;
3849     break;
3850
3851   case 130:
3852     st->gr_mode=0;
3853     a2_cls(st);
3854     a2_goto(st,0,16);
3855     for (s="APPLE ]["; *s; s++) a2_printc(st,*s);
3856     a2_goto(st,23,0);
3857     a2_printc(st,']');
3858     *next_actiontime+=1.0;
3859     *stepno=999;
3860     break;
3861
3862   case 170:
3863     if (random()%50==0) {
3864       sprintf(sim->printing_buf,
3865               "\nDISK VOLUME 254\n\n"
3866               " A 002 HELLO\n"
3867               "\n"
3868               "]");
3869       sim->printing=sim->printing_buf;
3870     }
3871     else {
3872       sprintf(sim->printing_buf,"\n?%s\n]",
3873               apple2_dos_errors[random()%
3874                                 (sizeof(apple2_dos_errors) /
3875                                  sizeof(char *))]);
3876       sim->printing=sim->printing_buf;
3877     }
3878     *stepno=999;
3879     *next_actiontime+=1.0;
3880     break;
3881
3882   case 180:
3883     if (random()%2==0) {
3884       /* This was how you went back to text mode in the monitor */
3885       sim->typing="FB4BG";
3886       *stepno=190;
3887     } else {
3888       *next_actiontime+=1.0;
3889       *stepno=999;
3890     }
3891     break;
3892
3893   case 190:
3894     st->gr_mode=0;
3895     a2_invalidate(st);
3896     a2_printc(st,'\n');
3897     a2_printc(st,'*');
3898     *stepno=200;
3899     *next_actiontime+=2.0;
3900     break;
3901
3902   case 200:
3903     /* This reset things into Basic */
3904     if (random()%2==0) {
3905       sim->typing="FAA6G";
3906       *stepno=120;
3907     }
3908     else {
3909       *stepno=999;
3910       *next_actiontime+=sim->delay;
3911     }
3912     break;
3913
3914   case 300:
3915     for (i=0; i<1500; i++) {
3916       a2_poke(st, mine->fillptr, mine->fillbyte);
3917       mine->fillptr++;
3918       mine->fillbyte = (mine->fillbyte+1)&0xff;
3919     }
3920     *next_actiontime += 0.08;
3921     /* When you hit c000, it changed video settings */
3922     if (mine->fillptr>=0xc000) {
3923       a2_invalidate(st);
3924       st->gr_mode=0;
3925     }
3926     /* And it seemed to reset around here, I dunno why */
3927     if (mine->fillptr>=0xcf00) *stepno=130;
3928     break;
3929
3930   case 999:
3931     break;
3932
3933   case A2CONTROLLER_FREE:
3934     free(mine);
3935     mine = 0;
3936     break;
3937   }
3938 }
3939
3940 static int
3941 a2_draw (struct bsod_state *bst)
3942 {
3943   apple2_sim_t *sim = (apple2_sim_t *) bst->closure;
3944   if (! sim) {
3945     sim = apple2_start (bst->dpy, bst->window, 9999999, a2controller_crash);
3946     bst->closure = sim;
3947   }
3948
3949   if (! apple2_one_frame (sim)) {
3950     bst->closure = 0;
3951   }
3952
3953   return 10000;
3954 }
3955
3956 static void
3957 a2_free (struct bsod_state *bst)
3958 {
3959   apple2_sim_t *sim = (apple2_sim_t *) bst->closure;
3960   if (sim) {
3961     sim->stepno = A2CONTROLLER_DONE;
3962     a2_draw (bst);              /* finish up */
3963     if (bst->closure) abort();  /* should have been freed by now */
3964   }
3965 }
3966
3967
3968 static struct bsod_state *
3969 apple2crash (Display *dpy, Window window)
3970 {
3971   struct bsod_state *bst = make_bsod_state (dpy, window, "apple2", "Apple2");
3972   bst->draw_cb = a2_draw;
3973   bst->free_cb = a2_free;
3974   return bst;
3975 }
3976
3977
3978 /* A crash spotted on a cash machine circa 2006, by jwz.  I didn't note
3979    what model it was; probably a Tranax Mini-Bank 1000 or similar vintage.
3980  */
3981 static struct bsod_state *
3982 atm (Display *dpy, Window window)
3983 {
3984   struct bsod_state *bst = make_bsod_state (dpy, window, "atm", "ATM");
3985
3986   Pixmap pixmap = 0;
3987   int pix_w = atm_width;
3988   int pix_h = atm_height;
3989   int x, y, i = 0;
3990   float scale = 0.48;
3991
3992   XClearWindow (dpy, window);
3993
3994   pixmap = XCreatePixmapFromBitmapData (dpy, window, (char *) atm_bits,
3995                                         atm_width, atm_height,
3996                                         bst->fg, bst->bg, bst->xgwa.depth);
3997
3998   while (pix_w <= bst->xgwa.width  * scale && 
3999          pix_h <= bst->xgwa.height * scale)
4000     {
4001       pixmap = double_pixmap (dpy, bst->gc, bst->xgwa.visual, bst->xgwa.depth,
4002                               pixmap, pix_w, pix_h);
4003       pix_w *= 2;
4004       pix_h *= 2;
4005       i++;
4006     }
4007
4008   x = (bst->xgwa.width  - pix_w) / 2;
4009   y = (bst->xgwa.height - pix_h) / 2;
4010   if (y < 0) y = 0;
4011
4012   if (i > 0)
4013     {
4014       int j;
4015       XSetForeground (dpy, bst->gc,
4016                       get_pixel_resource (dpy, bst->xgwa.colormap,
4017                                           "atm.background",
4018                                           "ATM.Background"));
4019       for (j = -1; j < pix_w; j += i+1)
4020         XDrawLine (bst->dpy, pixmap, bst->gc, j, 0, j, pix_h);
4021       for (j = -1; j < pix_h; j += i+1)
4022         XDrawLine (bst->dpy, pixmap, bst->gc, 0, j, pix_w, j);
4023     }
4024
4025   XCopyArea (dpy, pixmap, window, bst->gc, 0, 0, pix_w, pix_h, x, y);
4026
4027   XFreePixmap (dpy, pixmap);
4028
4029   return bst;
4030 }
4031
4032
4033 /* An Android phone boot loader, by jwz.
4034  */
4035 static struct bsod_state *
4036 android (Display *dpy, Window window)
4037 {
4038   struct bsod_state *bst = make_bsod_state (dpy, window, "android", "Android");
4039
4040   unsigned long bg = get_pixel_resource (dpy, bst->xgwa.colormap,
4041                                          "android.background",
4042                                          "Android.Background");
4043   unsigned long fg = get_pixel_resource (dpy, bst->xgwa.colormap,
4044                                          "android.foreground",
4045                                          "Android.Foreground");
4046   unsigned long c1 = get_pixel_resource (dpy, bst->xgwa.colormap,
4047                                          "android.color1",
4048                                          "Android.Foreground");
4049   unsigned long c2 = get_pixel_resource (dpy, bst->xgwa.colormap,
4050                                          "android.color2",
4051                                          "Android.Foreground");
4052   unsigned long c3 = get_pixel_resource (dpy, bst->xgwa.colormap,
4053                                          "android.color3",
4054                                          "Android.Foreground");
4055   unsigned long c4 = get_pixel_resource (dpy, bst->xgwa.colormap,
4056                                          "android.color4",
4057                                          "Android.Foreground");
4058   unsigned long c5 = get_pixel_resource (dpy, bst->xgwa.colormap,
4059                                          "android.color5",
4060                                          "Android.Foreground");
4061   unsigned long c6 = get_pixel_resource (dpy, bst->xgwa.colormap,
4062                                          "android.color6",
4063                                          "Android.Foreground");
4064   unsigned long c7 = get_pixel_resource (dpy, bst->xgwa.colormap,
4065                                          "android.color7",
4066                                          "Android.Foreground");
4067
4068   const char *lines0[] = {
4069     "Calculating... please wait\n",
4070     "osbl:     0x499DF907\n",
4071     "amss:     0x73162409\n",
4072     "hboot:    0xE46C3327\n",
4073     "boot:     0xBA570E7A\n",
4074     "recovery: 0xC8BBA213\n",
4075     "system:   0x87C3B1F0\n",
4076     "\n",
4077     "Press power key to go back.\n",
4078   };
4079
4080   const char *lines1[] = {
4081     "Checking SD card update...\n",
4082     "",
4083     "  SD Checking...\n",
4084     "  Failed to open zipfile\n",
4085     "  loading preload_content...\n",
4086     "  [Caution] Preload Content Not Found\n",
4087     "  loading HTCUpdateZipName image...\n",
4088     "",
4089     "  Checking...[PG46IMG.zip]\n",
4090     "Please plug off USB\n",
4091   };
4092
4093   const char *lines2[] = {
4094     "  SD Checking...\n",
4095     "  Loading...[PK76DIAG.zip]\n",
4096     "  No image!\n",
4097     "  Loading...[PK76DIAG.nbh]\n",
4098     "  No image or wrong image!\n",
4099     "  Loading...[PK76IMG.zip]\n",
4100     "  No image!\n",
4101     "  Loading...[PK76IMG.nbh]\n",
4102     "  No image or wrong image!\n",
4103     "  Loading...[PK76IMG.tar]\n",
4104     "  No image!\n",
4105     "  Loading...[PK76IMG.aes]\n",
4106     "  No image!\n",
4107     "  Loading...[PK76IMG.enc]\n",
4108     "  No image!\n",
4109   };
4110
4111   int cw = (bst->font->per_char
4112             ? bst->font->per_char['n'-bst->font->min_char_or_byte2].width
4113             : bst->font->min_bounds.width);
4114   int line_height = bst->font->ascent + bst->font->descent;
4115
4116   int state = 0;
4117
4118   Pixmap pixmap = 0;
4119   int pix_w = 0, pix_h = 0;
4120
4121 # ifdef DO_XPM
4122   pixmap = xpm_data_to_pixmap (dpy, window, (char **) android_skate,
4123                                &pix_w, &pix_h, 0);
4124   if (! pixmap) abort();
4125   bst->pixmap = pixmap;
4126 # endif /* DO_XPM */
4127
4128   bst->left_margin = (bst->xgwa.width - (cw * 40)) / 2;
4129   if (bst->left_margin < 0) bst->left_margin = 0;
4130
4131   while (1) {
4132     unsigned long delay =
4133       ((state == 0 || 
4134         state == countof(lines0) ||
4135         state == countof(lines0) + countof(lines1) ||
4136         state == countof(lines0) + countof(lines1) + countof(lines2))
4137                            ? 10000 : 0);
4138     BSOD_LINE_DELAY (bst, delay);
4139
4140     if (state <= countof(lines0) + countof(lines1) + countof(lines2))
4141       {
4142         BSOD_COLOR (bst, bg, bg);
4143         BSOD_RECT (bst, True, 0, 0, bst->xgwa.width, bst->xgwa.height);
4144         BSOD_COLOR (bst, bg, c1);
4145         BSOD_MOVETO (bst, bst->left_margin, bst->top_margin + line_height);
4146         BSOD_TEXT (bst, LEFT, "*** UNLOCKED ***\n");
4147         BSOD_COLOR (bst, c2, bg);
4148         BSOD_TEXT (bst, LEFT, 
4149                    "PRIMOU PVT SHIP S-OFF RL\n"
4150                    "HBOOT-1.17.0000\n"
4151                    "CPLD-None\n"
4152                    "MICROP-None\n"
4153                    "RADIO-3831.17.00.23_2\n"
4154                    "eMMC-bootmode: disabled\n"
4155                    "CPU-bootmode : disabled\n"
4156                    "HW Secure boot: enabled\n"
4157                    "MODEM PATH : OFF\n"
4158                    "May 15 2012, 10:28:15\n"
4159                    "\n");
4160         BSOD_COLOR (bst, bg, c3);
4161
4162         if (pixmap)
4163           {
4164             int x = (bst->xgwa.width - pix_w) / 2;
4165             int y = bst->xgwa.height - pix_h;
4166             BSOD_PIXMAP (bst, 0, 0, pix_w, pix_h, x, y);
4167           }
4168       }
4169
4170     if (state == countof(lines0) ||
4171         state == countof(lines0) + countof(lines1) ||
4172         state == countof(lines0) + countof(lines1) + countof(lines2))
4173       {
4174         BSOD_TEXT (bst, LEFT, "HBOOT USB\n");
4175         BSOD_COLOR (bst, c4, bg);
4176         BSOD_TEXT (bst, LEFT,
4177                    "\n"
4178                    "<VOL UP> to previous item\n"
4179                    "<VOL DOWN> to next item\n"
4180                    "<POWER> to select item\n"
4181                    "\n");
4182         BSOD_COLOR (bst, c5, bg); BSOD_TEXT (bst, LEFT, "FASTBOOT\n");
4183         BSOD_COLOR (bst, c6, bg); BSOD_TEXT (bst, LEFT, "RECOVERY\n");
4184         BSOD_COLOR (bst, c7, bg); BSOD_TEXT (bst, LEFT, "FACTORY RESET\n");
4185         BSOD_COLOR (bst, c3, bg); BSOD_TEXT (bst, LEFT, "SIMLOCK\n");
4186         BSOD_COLOR (bst, bg, c3); BSOD_TEXT (bst, LEFT, "HBOOT USB\n");
4187         BSOD_COLOR (bst, fg, bg); BSOD_TEXT (bst, LEFT, "IMAGE CRC\n");
4188         BSOD_COLOR (bst, c3, bg); BSOD_TEXT (bst, LEFT, "SHOW BARCODE\n");
4189         BSOD_PAUSE (bst, 3000000);
4190       }
4191     else if (state < countof(lines0))
4192       {
4193         BSOD_TEXT (bst, LEFT, "IMAGE CRC\n\n");
4194         BSOD_COLOR (bst, c5, bg);
4195         {
4196           int i;
4197           for (i = 0; i <= state; i++) {
4198             const char *s = lines0[i];
4199             BSOD_COLOR (bst, (strchr(s, ':') ? c7 : c3), bg);
4200             BSOD_TEXT (bst, LEFT, s);
4201           }
4202         }
4203         BSOD_PAUSE (bst, 500000);
4204         if (state == countof(lines0)-1)
4205           BSOD_PAUSE (bst, 2000000);
4206       }
4207     else if (state < countof(lines0) + countof(lines1))
4208       {
4209         BSOD_TEXT (bst, LEFT, "HBOOT\n\n");
4210         BSOD_COLOR (bst, c5, bg);
4211         {
4212           int i;
4213           for (i = countof(lines0); i <= state; i++) {
4214             const char *s = lines1[i - countof(lines0)];
4215             BSOD_COLOR (bst, (*s == ' ' ? c6 : c3), bg);
4216             BSOD_TEXT (bst, LEFT, s);
4217           }
4218         }
4219         BSOD_PAUSE (bst, 500000);
4220         if (state == countof(lines0) + countof(lines1) - 1)
4221           BSOD_PAUSE (bst, 2000000);
4222       }
4223     else if (state < countof(lines0) + countof(lines1) + countof(lines2))
4224       {
4225         BSOD_TEXT (bst, LEFT, "HBOOT USB\n\n");
4226         BSOD_COLOR (bst, c5, bg);
4227         {
4228           int i;
4229           for (i = countof(lines0) + countof(lines1); i <= state; i++) {
4230             const char *s = lines2[i - countof(lines0) - countof(lines1)];
4231             BSOD_COLOR (bst, (*s == ' ' ? c6 : c3), bg);
4232             BSOD_TEXT (bst, LEFT, s);
4233           }
4234         }
4235         BSOD_PAUSE (bst, 500000);
4236         if (state == countof(lines0) + countof(lines1) + countof(lines2)-1)
4237           BSOD_PAUSE (bst, 2000000);
4238       }
4239     else
4240       break;
4241
4242     state++;
4243   }
4244
4245   XClearWindow (dpy, window);
4246
4247   return bst;
4248 }
4249
4250
4251
4252
4253 /*****************************************************************************
4254  *****************************************************************************/
4255
4256
4257 static const struct {
4258   const char *name;
4259   struct bsod_state * (*fn) (Display *, Window);
4260 } all_modes[] = {
4261   { "Windows",          windows_31 },
4262   { "NT",               windows_nt },
4263   { "Win2K",            windows_other },
4264   { "Win10",            windows_10 },
4265   { "Amiga",            amiga },
4266   { "Mac",              mac },
4267   { "MacsBug",          macsbug },
4268   { "Mac1",             mac1 },
4269   { "MacX",             macx },
4270   { "SCO",              sco },
4271   { "HVX",              hvx },
4272   { "HPPALinux",        hppa_linux },
4273   { "SparcLinux",       sparc_linux },
4274   { "BSD",              bsd },
4275   { "Atari",            atari },
4276 #ifndef HAVE_JWXYZ
4277   { "BlitDamage",       blitdamage },
4278 #endif
4279   { "Solaris",          sparc_solaris },
4280   { "Linux",            linux_fsck },
4281   { "HPUX",             hpux },
4282   { "OS390",            os390 },
4283   { "Tru64",            tru64 },
4284   { "VMS",              vms },
4285   { "OS2",              os2 },
4286   { "MSDOS",            msdos },
4287   { "Nvidia",           nvidia },
4288   { "Apple2",           apple2crash },
4289   { "ATM",              atm },
4290   { "GLaDOS",           glados },
4291   { "Android",          android },
4292 };
4293
4294
4295 struct driver_state {
4296   const char *name;
4297   int only, which, next_one;
4298   int mode_duration;
4299   int delay_remaining;
4300   time_t start;
4301   Bool debug_p, cycle_p;
4302   struct bsod_state *bst;
4303 };
4304
4305
4306 static void
4307 hack_title (struct driver_state *dst)
4308 {
4309 # ifndef HAVE_JWXYZ
4310   char *oname = 0;
4311   XFetchName (dst->bst->dpy, dst->bst->window, &oname);
4312   if (oname && !strncmp (oname, "BSOD: ", 6)) {
4313     char *tail = oname + 4;
4314     char *s = strchr (tail+1, ':');
4315     char *nname;
4316     if (s) tail = s;
4317     nname = malloc (strlen (tail) + strlen (dst->name) + 20);
4318     sprintf (nname, "BSOD: %s%s", dst->name, tail);
4319     XStoreName (dst->bst->dpy, dst->bst->window, nname);
4320     free (nname);
4321   }
4322 # endif /* !HAVE_JWXYZ */
4323 }
4324
4325 static void *
4326 bsod_init (Display *dpy, Window window)
4327 {
4328   struct driver_state *dst = (struct driver_state *) calloc (1, sizeof(*dst));
4329   char *s;
4330
4331   dst->mode_duration = get_integer_resource (dpy, "delay", "Integer");
4332   if (dst->mode_duration < 3) dst->mode_duration = 3;
4333
4334   dst->debug_p = get_boolean_resource (dpy, "debug", "Boolean");
4335
4336   dst->only = -1;
4337   dst->next_one = -1;
4338   s = get_string_resource(dpy, "doOnly", "DoOnly");
4339   if (s && !strcasecmp (s, "cycle"))
4340     {
4341       dst->which = -1;
4342       dst->cycle_p = True;
4343     }
4344   else if (s && *s)
4345     {
4346       int count = countof(all_modes);
4347       for (dst->only = 0; dst->only < count; dst->only++)
4348         if (!strcasecmp (s, all_modes[dst->only].name))
4349           break;
4350       if (dst->only >= count)
4351         {
4352           fprintf (stderr, "%s: unknown -only mode: \"%s\"\n", progname, s);
4353           dst->only = -1;
4354         }
4355     }
4356   if (s) free (s);
4357
4358   dst->name = "none";
4359   dst->which = -1;
4360   return dst;
4361 }
4362
4363
4364 static unsigned long
4365 bsod_draw (Display *dpy, Window window, void *closure)
4366 {
4367   struct driver_state *dst = (struct driver_state *) closure;
4368   time_t now;
4369   int time_left;
4370
4371  AGAIN:
4372   now = time ((time_t *) 0);
4373   time_left = dst->start + dst->mode_duration - now;
4374
4375   if (dst->bst && dst->bst->img_loader)   /* still loading */
4376     {
4377       dst->bst->img_loader = 
4378         load_image_async_simple (dst->bst->img_loader, 0, 0, 0, 0, 0);
4379       return 100000;
4380     }
4381
4382  DELAY_NOW:
4383   /* Rather than returning a multi-second delay from the draw() routine,
4384      meaning "don't call us again for N seconds", we quantize that down
4385      to 1/10th second intervals so that it's more responsive to
4386      rotate/reshape events.
4387    */
4388   if (dst->delay_remaining)
4389     {
4390       int inc = 10000;
4391       int this_delay = MIN (dst->delay_remaining, inc);
4392       dst->delay_remaining = MAX (0, dst->delay_remaining - inc);
4393       return this_delay;
4394     }
4395
4396   if (! dst->bst && time_left > 0)      /* run completed; wait out the delay */
4397     {
4398       if (dst->debug_p)
4399         fprintf (stderr, "%s: %s: %d left\n", progname, dst->name, time_left);
4400       dst->start = 0;
4401       if (time_left > 5) time_left = 5;  /* Boooored now */
4402       dst->delay_remaining = 1000000 * time_left;
4403     }
4404
4405   else if (dst->bst)                    /* sub-mode currently running */
4406     {
4407       int this_delay = -1;
4408
4409       if (time_left > 0)
4410         this_delay = bsod_pop (dst->bst);
4411
4412       /* XSync (dpy, False);  slows down char drawing too much on HAVE_JWXYZ */
4413
4414       if (this_delay == 0)
4415         goto AGAIN;                     /* no delay, not expired: stay here */
4416       else if (this_delay >= 0)
4417         {
4418           dst->delay_remaining = this_delay;    /* return; time to sleep */
4419           goto DELAY_NOW;
4420         }
4421       else
4422         {                               /* sub-mode run completed or expired */
4423           if (dst->debug_p)
4424             fprintf (stderr, "%s: %s: done\n", progname, dst->name);
4425           free_bsod_state (dst->bst);
4426           dst->bst = 0;
4427           return 0;
4428         }
4429     }
4430   else                                  /* launch a new sub-mode */
4431     {
4432       if (dst->next_one >= 0)
4433         dst->which = dst->next_one, dst->next_one = -1;
4434       else if (dst->cycle_p)
4435         dst->which = (dst->which + 1) % countof(all_modes);
4436       else if (dst->only >= 0)
4437         dst->which = dst->only;
4438       else
4439         {
4440           int count = countof(all_modes);
4441           int i;
4442
4443           for (i = 0; i < 200; i++)
4444             {
4445               char name[100], class[100];
4446               int new_mode = (random() & 0xFF) % count;
4447
4448               if (i < 100 && new_mode == dst->which)
4449                 continue;
4450
4451               sprintf (name,  "do%s", all_modes[new_mode].name);
4452               sprintf (class, "Do%s", all_modes[new_mode].name);
4453
4454               if (get_boolean_resource (dpy, name, class))
4455                 {
4456                   dst->which = new_mode;
4457                   break;
4458                 }
4459             }
4460
4461           if (i >= 200)
4462             {
4463               fprintf (stderr, "%s: no display modes enabled?\n", progname);
4464               /* exit (-1); */
4465               dst->which = dst->only = 0;
4466             }
4467         }
4468           
4469       if (dst->debug_p)
4470         fprintf (stderr, "%s: %s: launch\n", progname, 
4471                  all_modes[dst->which].name);
4472
4473       /* Run the mode setup routine...
4474        */
4475       if (dst->bst) abort();
4476       dst->name  = all_modes[dst->which].name;
4477       dst->bst   = all_modes[dst->which].fn (dpy, window);
4478       dst->start = (dst->bst ? time ((time_t *) 0) : 0);
4479
4480       /* Reset the structure run state to the beginning,
4481          and do some sanitization of the cursor position
4482          before the first run.
4483        */
4484       if (dst->bst)
4485         {
4486           if (dst->debug_p)
4487             fprintf (stderr, "%s: %s: queue size: %d (%d)\n", progname, 
4488                      dst->name, dst->bst->pos, dst->bst->queue_size);
4489
4490           hack_title (dst);
4491           dst->bst->pos = 0;
4492           dst->bst->x = dst->bst->current_left = dst->bst->left_margin;
4493
4494           if (dst->bst->y < dst->bst->top_margin + dst->bst->font->ascent)
4495             dst->bst->y = dst->bst->top_margin + dst->bst->font->ascent;
4496         }
4497     }
4498
4499   return 0;
4500 }
4501
4502
4503 static void
4504 bsod_reshape (Display *dpy, Window window, void *closure, 
4505               unsigned int w, unsigned int h)
4506 {
4507   struct driver_state *dst = (struct driver_state *) closure;
4508
4509   if (dst->bst &&
4510       w == dst->bst->xgwa.width &&
4511       h == dst->bst->xgwa.height)
4512     return;
4513
4514   if (dst->debug_p)
4515     fprintf (stderr, "%s: %s: reshape reset\n", progname, dst->name);
4516
4517   /* just restart this mode and restart when the window is resized. */
4518   if (dst->bst)
4519     free_bsod_state (dst->bst);
4520   dst->bst = 0;
4521   dst->start = 0;
4522   dst->delay_remaining = 0;
4523   dst->next_one = dst->which;
4524   dst->name = "none";
4525   XClearWindow (dpy, window);
4526 }
4527
4528
4529 static Bool
4530 bsod_event (Display *dpy, Window window, void *closure, XEvent *event)
4531 {
4532   struct driver_state *dst = (struct driver_state *) closure;
4533   Bool reset_p = False;
4534
4535   /* pick a new mode and restart when mouse clicked, or certain keys typed. */
4536
4537   if (screenhack_event_helper (dpy, window, event))
4538     reset_p = True;
4539
4540   if (reset_p)
4541     {
4542       if (dst->debug_p)
4543         fprintf (stderr, "%s: %s: manual reset\n", progname, dst->name);
4544       if (dst->bst)
4545         free_bsod_state (dst->bst);
4546       dst->bst = 0;
4547       dst->start = 0;
4548       dst->delay_remaining = 0;
4549       dst->name = "none";
4550       XClearWindow (dpy, window);
4551       return True;
4552     }
4553   else
4554     return False;
4555 }
4556
4557
4558 static void
4559 bsod_free (Display *dpy, Window window, void *closure)
4560 {
4561   struct driver_state *dst = (struct driver_state *) closure;
4562   if (dst->bst)
4563     free_bsod_state (dst->bst);
4564   free (dst);
4565 }
4566
4567
4568 static const char *bsod_defaults [] = {
4569   "*delay:                 45",
4570   "*debug:                 False",
4571
4572   "*doOnly:                ",
4573   "*doWindows:             True",
4574   "*doNT:                  True",
4575   "*doWin2K:               True",
4576   "*doWin10:               True",
4577   "*doAmiga:               True",
4578   "*doMac:                 True",
4579   "*doMacsBug:             True",
4580   "*doMac1:                True",
4581   "*doMacX:                True",
4582   "*doSCO:                 True",
4583   "*doAtari:               False",      /* boring */
4584   "*doBSD:                 False",      /* boring */
4585   "*doLinux:               True",
4586   "*doSparcLinux:          False",      /* boring */
4587   "*doHPPALinux:           True",
4588   "*doBlitDamage:          True",
4589   "*doSolaris:             True",
4590   "*doHPUX:                True",
4591   "*doTru64:               True",
4592   "*doApple2:              True",
4593   "*doOS390:               True",
4594   "*doVMS:                 True",
4595   "*doHVX:                 True",
4596   "*doMSDOS:               True",
4597   "*doOS2:                 True",
4598   "*doNvidia:              True",
4599   "*doATM:                 True",
4600   "*doGLaDOS:              True",
4601   "*doAndroid:             True",
4602
4603   ".foreground:            White",
4604   ".background:            Black",
4605
4606   ".windows.foreground:    White",
4607   ".windows.background:    #0000AA",    /* EGA color 0x01. */
4608
4609   ".nt.foreground:         White",
4610   ".nt.background:         #0000AA",    /* EGA color 0x01. */
4611
4612   ".windowslh.foreground:  White",
4613   ".windowslh.background:  #AA0000",    /* EGA color 0x04. */
4614   ".windowslh.background2: #AAAAAA",    /* EGA color 0x07. */
4615
4616   ".win10.foreground:      White",
4617   ".win10.background:      #1070AA",
4618
4619   ".glaDOS.foreground:     White",
4620   ".glaDOS.background:     #0000AA",    /* EGA color 0x01. */
4621
4622   ".amiga.foreground:      #FF0000",
4623   ".amiga.background:      Black",
4624   ".amiga.background2:     White",
4625
4626   ".mac.foreground:        #BBFFFF",
4627   ".mac.background:        Black",
4628
4629   ".atari.foreground:      Black",
4630   ".atari.background:      White",
4631
4632   ".macsbug.foreground:    Black",
4633   ".macsbug.background:    White",
4634   ".macsbug.borderColor:   #AAAAAA",
4635
4636   ".mac1.foreground:       Black",
4637   ".mac1.background:       White",
4638
4639   ".macx.foreground:       White",
4640   ".macx.textForeground:   White",
4641   ".macx.textBackground:   Black",
4642   ".macx.background:       #888888",
4643
4644   ".sco.foreground:        White",
4645   ".sco.background:        Black",
4646
4647   ".hvx.foreground:        White",
4648   ".hvx.background:        Black",
4649
4650   ".linux.foreground:      White",
4651   ".linux.background:      Black",
4652
4653   ".hppalinux.foreground:  White",
4654   ".hppalinux.background:  Black",
4655
4656   ".sparclinux.foreground: White",
4657   ".sparclinux.background: Black",
4658
4659   ".bsd.foreground:        #c0c0c0",
4660   ".bsd.background:        Black",
4661
4662   ".solaris.foreground:    Black",
4663   ".solaris.background:    White",
4664
4665   ".hpux.foreground:       White",
4666   ".hpux.background:       Black",
4667
4668   ".os390.background:      Black",
4669   ".os390.foreground:      Red",
4670
4671   ".tru64.foreground:      White",
4672   ".tru64.background:      #0000AA",    /* EGA color 0x01. */
4673
4674   ".vms.foreground:        White",
4675   ".vms.background:        Black",
4676
4677   ".msdos.foreground:      White",
4678   ".msdos.background:      Black",
4679
4680   ".os2.foreground:        White",
4681   ".os2.background:        Black",
4682
4683   ".atm.foreground:        Black",
4684   ".atm.background:        #FF6600",
4685
4686   ".android.foreground:    Black",
4687   ".android.background:    White",
4688   ".android.color1:        #AA00AA", /* violet */
4689   ".android.color2:        #336633", /* green1 */
4690   ".android.color3:        #0000FF", /* blue */
4691   ".android.color4:        #CC7744", /* orange */
4692   ".android.color5:        #99AA55", /* green2 */
4693   ".android.color6:        #66AA33", /* green3 */
4694   ".android.color7:        #FF0000", /* red */
4695
4696   "*dontClearRoot:         True",
4697
4698   ANALOGTV_DEFAULTS
4699
4700 #ifdef HAVE_XSHM_EXTENSION
4701   "*useSHM:                True",
4702 #endif
4703
4704   "*fontB:                 ",
4705   "*fontC:                 ",
4706
4707 # if defined(USE_IPHONE)
4708
4709   "*font:                  PxPlus IBM VGA8 16, Courier-Bold 14",
4710   "*bigFont:               ",
4711   "*font2:                 ",
4712   "*bigFont2:              ",
4713
4714   ".mac.font:              Courier-Bold 18",
4715   ".macsbug.font:          Courier-Bold 8",
4716   ".macx.font:             Courier-Bold 14",
4717   ".macdisk.font:          Courier-Bold 14",
4718   ".msdos.font:            PxPlus IBM VGA8 32, Courier-Bold 28",
4719   ".nt.font:               PxPlus IBM VGA8 12, Courier-Bold 10",
4720   ".win10.font:            Arial 12, Helvetica 12",
4721   ".win10.bigFont:         Arial 12, Helvetica 12",
4722   ".win10.fontB:           Arial 50, Helvetica 50",
4723   ".win10.fontC:           Arial 9, Helvetica 9",
4724   ".win10.bigFont2:        ",
4725
4726 # elif defined(HAVE_ANDROID)
4727
4728   "*font:                  PxPlus IBM VGA8 16",
4729   "*bigFont:               ",
4730   "*font2:                 ",
4731   "*bigFont2:              ",
4732
4733   ".mac.font:              -*-courier-bold-r-*-*-*-180-*-*-m-*-*-*",
4734   ".macsbug.font:          -*-courier-bold-r-*-*-*-80-*-*-m-*-*-*",
4735   ".macx.font:             -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
4736   ".macdisk.font:          -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
4737   ".msdos.font:            PxPlus IBM VGA8 32",
4738   ".nt.font:               PxPlus IBM VGA8 12",
4739
4740   ".win10.font:            -*-helvetica-medium-r-*-*-*-120-*-*-*-*-*-*",
4741   ".win10.bigFont:         -*-helvetica-medium-r-*-*-*-120-*-*-*-*-*-*",
4742   ".win10.fontB:           -*-helvetica-medium-r-*-*-*-500-*-*-*-*-*-*",
4743   ".win10.fontC:           -*-helvetica-medium-r-*-*-*-90-*-*-*-*-*-*",
4744   ".win10.bigFont2:        ",
4745
4746 # elif defined(HAVE_COCOA)
4747
4748   "*font:                  PxPlus IBM VGA8 8,  Courier-Bold 9",
4749   "*bigFont:               PxPlus IBM VGA8 32, Courier-Bold 24",
4750   "*font2:                 ",
4751   "*bigFont2:              ",
4752
4753   ".mac.font:              Monaco 10, Courier-Bold 9",
4754   ".mac.bigFont:           Monaco 18, Courier-Bold 18",
4755
4756   ".macsbug.font:          Monaco 10, Courier-Bold 9",
4757   ".macsbug.bigFont:       Monaco 24, Courier-Bold 24",
4758
4759   ".macx.font:             Courier-Bold 9",
4760   ".macx.bigFont:          Courier-Bold 14",
4761   ".macdisk.font:          Courier-Bold 9",
4762   ".macdisk.bigFont:       Courier-Bold 18",
4763
4764   ".hvx.bigFont:           PxPlus IBM VGA8 16, Courier-Bold 14",
4765   ".hppalinux.bigFont:     PxPlus IBM VGA8 16, Courier-Bold 14",
4766   ".solaris.bigFont:       PxPlus IBM VGA8 16, Courier-Bold 14",
4767   ".linux.bigFont:         PxPlus IBM VGA8 16, Courier-Bold 14",
4768   ".hpux.bigFont:          PxPlus IBM VGA8 16, Courier-Bold 14",
4769   ".msdos.font:            PxPlus IBM VGA8 16, Courier-Bold 14",
4770
4771   ".win10.font:            Arial 24, Helvetica 24",
4772   ".win10.bigFont:         Arial 24, Helvetica 24",
4773   ".win10.fontB:           Arial 100, Helvetica 100",
4774   ".win10.fontC:           Arial 16, Helvetica 16",
4775   ".win10.bigFont2:        ",
4776
4777 # else   /* X11 */
4778
4779   "*font:                  9x15bold",
4780   "*font2:                 -*-courier-bold-r-*-*-*-120-*-*-m-*-*-*",
4781   "*bigFont:               -*-courier-bold-r-*-*-*-180-*-*-m-*-*-*",
4782   "*bigFont2:              -*-courier-bold-r-*-*-*-180-*-*-m-*-*-*",
4783
4784   ".macsbug.font:          -*-courier-medium-r-*-*-*-80-*-*-m-*-*-*",
4785   ".macsbug.bigFont:       -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
4786
4787   ".macdisk.font:          -*-courier-bold-r-*-*-*-80-*-*-m-*-*-*",
4788   ".macdisk.bigFont:       -*-courier-bold-r-*-*-*-100-*-*-m-*-*-*",
4789
4790   ".sco.font:              -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
4791   ".hvx.font:              -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
4792   ".hppalinux.bigFont:     -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
4793   ".sparclinux.bigFont:    -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
4794
4795   ".bsd.font:              vga",
4796   ".bsd.bigFont:           -sun-console-medium-r-*-*-22-*-*-*-m-*-*-*",
4797   ".bsd.bigFont2:          -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
4798
4799   ".solaris.font:          -sun-gallant-*-*-*-*-19-*-*-*-*-120-*-*",
4800   ".hpux.bigFont:          -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
4801   ".os390.bigFont:         -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
4802   ".tru64.bigFont:         -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
4803   ".vms.bigFont:           -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
4804   ".msdos.bigFont:         -*-courier-bold-r-*-*-*-140-*-*-m-*-*-*",
4805
4806   ".win10.font:            -*-helvetica-medium-r-*-*-*-180-*-*-*-*-*-*",
4807   ".win10.bigFont:         -*-helvetica-medium-r-*-*-*-180-*-*-*-*-*-*",
4808   ".win10.fontB:           -*-helvetica-medium-r-*-*-*-240-*-*-*-*-*-*",
4809   ".win10.fontC:           -*-helvetica-medium-r-*-*-*-140-*-*-*-*-*-*",
4810   ".win10.font2:           ",
4811   ".win10.bigFont2:        ",
4812
4813 # endif  /* X11 */
4814
4815   0
4816 };
4817
4818 static const XrmOptionDescRec bsod_options [] = {
4819   { "-delay",           ".delay",               XrmoptionSepArg, 0 },
4820   { "-only",            ".doOnly",              XrmoptionSepArg, 0 },
4821   { "-debug",           ".debug",               XrmoptionNoArg,  "True"  },
4822   { "-windows",         ".doWindows",           XrmoptionNoArg,  "True"  },
4823   { "-no-windows",      ".doWindows",           XrmoptionNoArg,  "False" },
4824   { "-nt",              ".doNT",                XrmoptionNoArg,  "True"  },
4825   { "-no-nt",           ".doNT",                XrmoptionNoArg,  "False" },
4826   { "-2k",              ".doWin2K",             XrmoptionNoArg,  "True"  },
4827   { "-no-2k",           ".doWin2K",             XrmoptionNoArg,  "False" },
4828   { "-win10",           ".doWin10",             XrmoptionNoArg,  "True"  },
4829   { "-no-win10",        ".doWin10",             XrmoptionNoArg,  "False" },
4830   { "-amiga",           ".doAmiga",             XrmoptionNoArg,  "True"  },
4831   { "-no-amiga",        ".doAmiga",             XrmoptionNoArg,  "False" },
4832   { "-mac",             ".doMac",               XrmoptionNoArg,  "True"  },
4833   { "-no-mac",          ".doMac",               XrmoptionNoArg,  "False" },
4834   { "-mac1",            ".doMac1",              XrmoptionNoArg,  "True"  },
4835   { "-no-mac1",         ".doMac1",              XrmoptionNoArg,  "False" },
4836   { "-macx",            ".doMacX",              XrmoptionNoArg,  "True"  },
4837   { "-no-macx",         ".doMacX",              XrmoptionNoArg,  "False" },
4838   { "-atari",           ".doAtari",             XrmoptionNoArg,  "True"  },
4839   { "-no-atari",        ".doAtari",             XrmoptionNoArg,  "False" },
4840   { "-macsbug",         ".doMacsBug",           XrmoptionNoArg,  "True"  },
4841   { "-no-macsbug",      ".doMacsBug",           XrmoptionNoArg,  "False" },
4842   { "-apple2",          ".doApple2",            XrmoptionNoArg,  "True"  },
4843   { "-no-apple2",       ".doApple2",            XrmoptionNoArg,  "False" },
4844   { "-sco",             ".doSCO",               XrmoptionNoArg,  "True"  },
4845   { "-no-sco",          ".doSCO",               XrmoptionNoArg,  "False" },
4846   { "-hvx",             ".doHVX",               XrmoptionNoArg,  "True"  },
4847   { "-no-hvx",          ".doHVX",               XrmoptionNoArg,  "False" },
4848   { "-bsd",             ".doBSD",               XrmoptionNoArg,  "True"  },
4849   { "-no-bsd",          ".doBSD",               XrmoptionNoArg,  "False" },
4850   { "-linux",           ".doLinux",             XrmoptionNoArg,  "True"  },
4851   { "-no-linux",        ".doLinux",             XrmoptionNoArg,  "False" },
4852   { "-hppalinux",       ".doHPPALinux",         XrmoptionNoArg,  "True"  },
4853   { "-no-hppalinux",    ".doHPPALinux",         XrmoptionNoArg,  "False" },
4854   { "-sparclinux",      ".doSparcLinux",        XrmoptionNoArg,  "True"  },
4855   { "-no-sparclinux",   ".doSparcLinux",        XrmoptionNoArg,  "False" },
4856   { "-blitdamage",      ".doBlitDamage",        XrmoptionNoArg,  "True"  },
4857   { "-no-blitdamage",   ".doBlitDamage",        XrmoptionNoArg,  "False" },
4858   { "-nvidia",          ".doNvidia",            XrmoptionNoArg,  "True"  },
4859   { "-no-nvidia",       ".doNvidia",            XrmoptionNoArg,  "False" },
4860   { "-solaris",         ".doSolaris",           XrmoptionNoArg,  "True"  },
4861   { "-no-solaris",      ".doSolaris",           XrmoptionNoArg,  "False" },
4862   { "-hpux",            ".doHPUX",              XrmoptionNoArg,  "True"  },
4863   { "-no-hpux",         ".doHPUX",              XrmoptionNoArg,  "False" },
4864   { "-os390",           ".doOS390",             XrmoptionNoArg,  "True"  },
4865   { "-no-os390",        ".doOS390",             XrmoptionNoArg,  "False" },
4866   { "-tru64",           ".doHPUX",              XrmoptionNoArg,  "True"  },
4867   { "-no-tru64",        ".doTru64",             XrmoptionNoArg,  "False" },
4868   { "-vms",             ".doVMS",               XrmoptionNoArg,  "True"  },
4869   { "-no-vms",          ".doVMS",               XrmoptionNoArg,  "False" },
4870   { "-msdos",           ".doMSDOS",             XrmoptionNoArg,  "True"  },
4871   { "-no-msdos",        ".doMSDOS",             XrmoptionNoArg,  "False" },
4872   { "-os2",             ".doOS2",               XrmoptionNoArg,  "True"  },
4873   { "-no-os2",          ".doOS2",               XrmoptionNoArg,  "False" },
4874   { "-atm",             ".doATM",               XrmoptionNoArg,  "True"  },
4875   { "-no-atm",          ".doATM",               XrmoptionNoArg,  "False" },
4876   { "-glados",          ".doGLaDOS",            XrmoptionNoArg,  "True"  },
4877   { "-no-glados",       ".doGLaDOS",            XrmoptionNoArg,  "False" },
4878   { "-android",         ".doAndroid",           XrmoptionNoArg,  "True"  },
4879   { "-no-android",      ".doAndroid",           XrmoptionNoArg,  "False" },
4880   ANALOGTV_OPTIONS
4881   { 0, 0, 0, 0 }
4882 };
4883
4884
4885 XSCREENSAVER_MODULE ("BSOD", bsod)