home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d115 / marketroid.lha / Marketroid / src / marketroid.c < prev    next >
C/C++ Source or Header  |  1987-11-22  |  19KB  |  798 lines

  1. /*  :ts=8 bk=0
  2.  *
  3.  * marketroid.c:    The Killer Demo To End All Killer Demos (we hope).
  4.  *
  5.  * Leo L. Schwab            8710.2        (415) 456-3960
  6.  */
  7. #include <exec/types.h>
  8. #include <exec/memory.h>
  9. #include <intuition/intuition.h>
  10. #include "marketroid.h"
  11.  
  12. #define    ABS(x)        ((x) < 0 ? -(x) : (x))
  13. /*  Helpful macro  */
  14. #define    chkabort()    (GetMsg (win -> UserPort))
  15.  
  16.  
  17. extern struct obcontrol    *addobject();
  18.  
  19. extern struct object    ob_hero, ob_RJ, ob_dale, ob_jay, ob_bike;
  20. extern struct object    ob_grunt, ob_hulk, ob_brain, ob_spheroid, ob_tank,
  21.             ob_missile, ob_quark, ob_enforcer, ob_prog;
  22. extern struct object    ob_1K, ob_2K, ob_3K, ob_4K, ob_5K;
  23. extern struct object    ob_bptr1, ob_bptr2, ob_bptr3, ob_bptr4,
  24.             ob_skull, ob_mips;
  25.  
  26.  
  27. struct NewScreen scrdef = {
  28.     0, 0, 320, 200, 4,
  29.     0, 1,
  30.     NULL,
  31.     CUSTOMSCREEN,
  32.     NULL, NULL,
  33.     NULL, NULL,
  34. };
  35.  
  36. struct NewWindow windef = {
  37.     0, 0, 320, 200,
  38.     -1, -1,
  39.     MOUSEBUTTONS,
  40.     ACTIVATE | SIMPLE_REFRESH,
  41.     NULL, NULL,
  42.     (UBYTE *) "               Marketroid",
  43.     NULL,            /*  Filled in later  */
  44.     NULL,
  45.     0, 0, 0, 0,
  46.     CUSTOMSCREEN
  47. };
  48.  
  49. struct TextAttr robo8 = {
  50.     (STRPTR) "robotron.font",
  51.     8,
  52.     0,
  53.     FPF_DISKFONT
  54. };
  55.  
  56. struct TextAttr robo6 = {
  57.     (STRPTR) "robotron.font",
  58.     6,
  59.     0,
  60.     FPF_DISKFONT
  61. };
  62.  
  63.  
  64. /*  Color maps for background and color cycling  */
  65. UWORD colormap[] = {
  66.     0x000, 0xfff, 0xff0, 0xf80, 0xf00, 0xf0f, 0x0f0, 0x00f,
  67.     0x888, 0xb60, 0xc00, 0x00b, 0xc0c, 0x07f, 0x869, 0x557
  68. };
  69.  
  70. UWORD bgr[] = { 0x00f, 0x0f0, 0xf00 };
  71.  
  72. UWORD redpulse[] = { 0xf00, 0xf00, 0xff0 };
  73.  
  74. UWORD rpbpr[] = {
  75.     0xf00, 0xf04, 0xf08, 0xf0b, 0xf0f, 0xb0f, 0x70f, 0x40f,
  76.     0x00f, 0x40f, 0x80f, 0xb0f, 0xf0f, 0xf0b, 0xf08, 0xf04 
  77. };
  78.  
  79. UWORD spectrum[] = {
  80.     0xf00, 0xf30, 0xf60, 0xf80, 0xfb0, 0xfe0, 0xdf0, 0xaf0,
  81.     0x7f0, 0x4f0, 0x1f0, 0x0f2, 0x0f5, 0x0f8, 0x0fb, 0x0fe,
  82.     0x0df, 0x0af, 0x07f, 0x04f, 0x01f, 0x20f, 0x50f, 0x80f,
  83.     0xb0f, 0xd0f, 0xf0e, 0xf0b, 0xf08, 0xf05, 0xf03, 0xf01
  84. };
  85.  
  86. UWORD blackspectrum[] = {
  87.     0xc00, 0x900, 0x600, 0x300, 0x000, 0x004, 0x008, 0x00b,
  88.     0x00f, 0x04f, 0x08f, 0x0cf, 0x0fe, 0x0fa, 0x0f6, 0x0f2,
  89.     0x2f0, 0x6f0, 0xaf0, 0xef0, 0xfc0, 0xf80, 0xf40, 0xf00
  90. };
  91.  
  92.  
  93. /*  Border array  */
  94. WORD border[] = {
  95.     0, 10,  319, 10,  319, 199,  0, 199,
  96.     0, 11,  318, 11,  318, 198,  1, 198,
  97.     1, 10
  98. };
  99.  
  100.  
  101. /*  Strings for dotext()ing  */
  102. static char inspired[] = "\015INSPIRED BY HIS NEVER-ENDING\033\
  103. QUEST FOR PROGRESS,\033\
  104. IN \0171987\015, MAN PERFECTS THE \017AMIGA:";
  105.  
  106. static char advanced[] = "\012A COMPUTER SYSTEM SO ADVANCED\033\
  107. THAT ALL OTHER SYSTEMS\033\
  108. ARE INFERIOR.";
  109.  
  110. static char guided[] = "\014GUIDED BY THEIR CORPORATE GREED,\033\
  111. THE COMPETITION'S \017MARKETROIDS\014\033\
  112. CONCLUDE:";
  113.  
  114. static char destroyed[] = "\017THE AMIGA IS TOO SOPHISTICATED\033\
  115. FOR US TO COMPETE, AND THEREFORE\033\
  116. MUST BE DESTROYED.";
  117.  
  118. static char lasthope[] = "\015YOU ARE THE LAST HOPE OF AMIGA, INC.";
  119.  
  120. static char thanks[] = "\014THANKS TO AN ELECTRONICS ENGINEERING";
  121.  
  122. static char wizard[] = "WIZARD, YOU POSSESS SUPERCOMPUTING\033\
  123. POWER.";
  124.  
  125. static char mission[] = "\012YOUR MISSION IS TO\033\
  126. \017STOP THE MARKETROIDS\012 AND\033\
  127. \017SAVE THE LAST REAL HACKERS.";
  128.  
  129. static char apple[] = "\012THE FORCE OF ANTI-PROGRESS\033\
  130. PATHO-LOGICAL EUTHENIZER\033\
  131. \017(APPLE) MARKETROIDS\012 SEEK TO\033\
  132. DESTROY YOU.";
  133.  
  134. static char hulk[] = "\015THE HACKED-UP LOSING KLUDGE\033\
  135. \017(HULK) MARKETROIDS\015 SEEK OUT AND\033\
  136. ELIMINATE THE LAST REAL HACKERS.";
  137.  
  138. static char bogon[] = "\013THE \017BOGONS AND CRUFTIES\013 ARE\033\
  139. TRAINED TO CREATE \017MISINFORMATION AND\033\
  140. VAPORWARE MARKETROIDS.";
  141.  
  142. static char ibm[] = "\015BEWARE OF THE \017INGENIUS BRAIN\033\
  143. MARKETROIDS (IBM'S)\015 THAT POSSESS THE\033\
  144. ABILITY TO RE-TRAIN THE HACKERS INTO\033\
  145. SINISTER \017MS-DOS PROGRAMMERS.";
  146.  
  147. static char struggle[] = "\012AS YOU STRUGGLE TO SAVE HACKERDOM,\033\
  148. BE SURE TO AVOID \017BPTRS\012\033\
  149. IN YOUR PATH.";
  150.  
  151. static char bs[] = "\006NO BULLSHIT, JUST EXCELLENCE.";
  152.  
  153. static char hype[] = "\006NO HYPE, JUST EXCELLENCE.";
  154.  
  155. /*  Other stuff  */
  156. struct Screen        *scr;
  157. struct Window        *win;
  158. struct ViewPort        *vp;
  159. struct BitMap        *sbm;
  160. struct TextFont        *bigrobo, *smallrobo;
  161. UWORD            *blankspr;
  162. int            keyx;
  163. char            *keytext;
  164. char            marketroid1987[] = "MARKETROID: 1987";
  165. void            *IntuitionBase, *GfxBase, *DiskfontBase;
  166.  
  167. main (ac, av)
  168. char **av;
  169. {
  170.     struct RastPort        *rp;
  171.  
  172.     openstuff ();
  173.     sbm = scr -> ViewPort.RasInfo -> BitMap;
  174.     rp = &scr -> RastPort;
  175.     setbounds (2, 318, 12, 198);
  176.     coverpage ();
  177.  
  178.     SetFont (rp, bigrobo);
  179.     keytext = hype;
  180.     if (ac > 1)
  181.         if (*av[1] == '-' && av[1][1] == 'o')
  182.             keytext = bs;
  183.     keyx = 160 - TextLength (rp, &keytext[1], strlen (keytext) - 1L) / 2;
  184.  
  185.     while (1) {
  186.         /*  "Save the last real hackers"  */
  187.         save_em (rp);
  188.         if (chkabort())
  189.             break;
  190.  
  191.         /*  "MARKETROID:"  */
  192.         market (rp);
  193.         if (chkabort())
  194.             break;
  195.  
  196.         /*  The Main demo  */
  197.         if (maindemo (rp))
  198.             break;
  199.  
  200.         /*  Amiga.  No BS, just excellence.  */
  201.         amy (rp);
  202.         if (chkabort())
  203.             break;
  204.     }
  205.     SetSignal (0L, 1L << 12);        /*  Clear ^C signal  */
  206.     closestuff ();
  207. }
  208.  
  209. maindemo (rp)
  210. register struct RastPort *rp;
  211. {
  212.     extern struct List        guys;        /*  anim.c  */
  213.     register struct obcontrol    *hero, *thing;
  214.     struct obcontrol        *a, *b, *c, *d, *e, *f, *g;
  215.     register int            i, n, k;
  216.  
  217.     SetRast (rp, 0L);
  218.     openanim ();
  219.     opencycle (vp, colormap, 16);
  220.  
  221.     standardcycle ();
  222.  
  223.     /*  Draw border  */
  224.     SetFont (rp, bigrobo);
  225.     standardscreen (rp);
  226.  
  227.     /*  "Inspired by his never-ending quest for progress..."  */
  228.     dotext (inspired, 10, 50);    waittext ();    Delay (75L);
  229.     if (chkabort())    return (1);
  230.     dotext (advanced, 10, 80);    waittext ();    Delay (75L);
  231.     if (chkabort())    return (1);
  232.     dotext (guided, 10, 110);    waittext ();    Delay (75L);
  233.     if (chkabort())    return (1);
  234.     dotext (destroyed, 10, 140);    waittext ();    Delay (100L);
  235.     if (chkabort())    return (1);
  236.  
  237.     /*  "You are the last hope of Amiga, Inc..."  */
  238.     cls (rp);
  239.     SetAPen (rp, 1L);
  240.     Move (rp,
  241.           160 - TextLength (rp,
  242.                 marketroid1987,
  243.                 (long) strlen (marketroid1987)) / 2,
  244.           30L);
  245.     Text (rp, marketroid1987, (long) strlen (marketroid1987));
  246.  
  247.     hero = addobject (&ob_hero, 0, RIGHT, 2, 130);
  248.     dotext (lasthope, 10, 45);
  249.     while (hero->x + ob_hero.width < 160) {
  250.         animate (); WaitTOF ();
  251.     }
  252.     hero -> flags |= FREEZE;
  253.     setdir (hero, DOWN);
  254.     while (!textdone ()) {
  255.         animate (); WaitTOF ();
  256.     }
  257.     Delay (75L);
  258.     if (chkabort())    return (1);
  259.  
  260.     /*  "Thanks to an electronics engineering"  */
  261.     dotext (thanks, 10, 60);    waittext ();
  262.  
  263.     /*  "wizard, you possess supercomputing power."  */
  264.     dotext (wizard, 10, 68);
  265.     for (i=0; i<20; i++) {
  266.         if (rnd (2))
  267.             /*  Shoot left  */
  268.             addobject (&ob_mips, 1, LEFT,
  269.                    hero->x - ob_mips.width, 134);
  270.         else
  271.             /*  Shoot right  */
  272.             addobject (&ob_mips, 1, RIGHT,
  273.                    hero->x + ob_hero.width, 134);
  274.         for (n=0; n<10; n++) {
  275.             animate (); WaitTOF ();
  276.         }
  277.     }
  278.     do {
  279.         i = OFFSCREEN;
  280.         animate ();
  281.         WaitTOF ();
  282.         for (thing = (struct obcontrol *) guys.lh_Head;
  283.              thing -> node.ln_Succ;
  284.              thing = (struct obcontrol *) thing -> node.ln_Succ) {
  285.             if (thing == hero)
  286.                 continue;
  287.             i &= thing -> flags;
  288.         }
  289.     } while (!(i & OFFSCREEN));
  290.  
  291.     /*  Delete all MIPS objects  */
  292.     deleteallof (&ob_mips);
  293.     waittext ();    Delay (50L);
  294.     if (chkabort())    return (1);
  295.  
  296.     /*  "Your mission is to stop the marketroids..."  */
  297.     dotext (mission, 10, 90);    waittext ();    Delay (25L);
  298.     if (chkabort())    return (1);
  299.  
  300.     /*  (-=RJ=-, Dale, Jay)  */
  301.     a = addobject (&ob_RJ, 1, RIGHT, 60, 128);
  302.     SetDrMd (rp, JAM2);
  303.     SetAPen (rp, 12L);
  304.     SetFont (rp, smallrobo);
  305.     Move (rp, 52L, 155L);
  306.     Text (rp, "-=RJ=-", 6L);
  307.     for (i=0; i<100; i++) {
  308.         animate ();  WaitTOF ();
  309.     }
  310.     b = addobject (&ob_dale, 1, RIGHT, 50, 129);
  311.     Move (rp, 46L, 155L);
  312.     Text (rp, "DALE      ", 10L);
  313.     for (i=0; i<100; i++) {
  314.         animate ();  WaitTOF ();
  315.     }
  316.     c = addobject (&ob_jay, 1, RIGHT, 40, 129);
  317.     Move (rp, 40L, 155L);
  318.     Text (rp, "JAY       ", 10L);
  319.     for (i=0; i<100; i++) {
  320.         animate ();  WaitTOF ();
  321.     }
  322.  
  323.     /*  Hero picks up the hackers for points  */
  324.     hero -> flags &= ~FREEZE;
  325.     setdir (hero, LEFT);
  326.     while (hero -> x > a -> x) {
  327.         animate ();  WaitTOF ();
  328.     }
  329.     removeobject (a);
  330.     a = addobject (&ob_1K, 1, UP, hero->x, hero->y + 4);
  331.     while (hero -> x > b -> x) {
  332.         animate ();  WaitTOF ();
  333.     }
  334.     removeobject (b);
  335.     b = addobject (&ob_2K, 1, UP, hero->x, hero->y + 4);
  336.     while (hero -> x > c -> x) {
  337.         animate ();  WaitTOF ();
  338.     }
  339.     removeobject (c);
  340.     removeobject (a);
  341.     Move (rp, 40L, 155L);
  342.     Text (rp, "   ", 3L);
  343.     c = addobject (&ob_3K, 1, UP, hero->x, hero->y + 4);
  344.  
  345.     while (hero -> x > 40) {
  346.         animate ();  WaitTOF ();
  347.     }
  348.     removeobject (b);
  349.     setdir (hero, RIGHT);
  350.     while (hero -> x + ob_hero.width < c -> x) {
  351.         animate ();  WaitTOF ();
  352.     }
  353.     removeobject (c);
  354.     if (chkabort())    return (1);
  355.  
  356.  
  357.     setbounds (2, 318, 35, 120);
  358.     cls (rp);
  359.     setbounds (2, 318, 12, 198);
  360.     /*  "The force of Anti-Progress Patho-Locigal Euthenizer..."  */
  361.     dotext (apple, 10, 60);
  362.     n = k = 0;
  363.     while (hero -> x + ob_hero.width < 160) {
  364.         if (!(++n % 20)) {
  365.             addobject (&ob_grunt, 2, LEFT, 318, 130+rnd (51)-25);
  366.             k++;
  367.         }
  368.         animate ();
  369.         adjustgrunts ();
  370.         WaitTOF ();
  371.     }
  372.     hero -> flags |= FREEZE;
  373.     a = addobject (&ob_dale, 1, RIGHT, 60, 130);
  374.     i = 0;  c = NULL;
  375.     while (i < 600) {        /*  We'll 'break' out of this  */
  376.         if (++i == 100)
  377.             b = addobject (&ob_RJ, 1, RIGHT, 35, 130);
  378.  
  379.         if (!(++n % 20))
  380.             if (i < 200) {
  381.                 addobject
  382.                  (&ob_grunt, 2, LEFT,
  383.                   318, 130+rnd (51)-25);
  384.                 k++;
  385.             } else if (!c && k) {
  386.                 c = addobject
  387.                      (&ob_mips, 1, RIGHT,
  388.                       hero->x + ob_hero.width, 134);
  389.                 k--;
  390.             }
  391.  
  392.         if (i == 200)
  393.             setdir (a, DOWN);
  394.         if (i == 600)
  395.             setdir (a, LEFT);
  396.  
  397.         if (c)
  398.             if (dogruntkill (c)) {
  399.                 removeobject (c);  c = NULL;
  400.             }
  401.  
  402.         animate ();
  403.         adjustgrunts ();
  404.         WaitTOF ();
  405.     }
  406.     waittext ();
  407.     deleteallof (&ob_grunt);
  408.     if (chkabort())    return (1);
  409.  
  410.     /*  "The Hacked-Up Losing Kludge...."  */
  411.     hero -> flags &= ~FREEZE;
  412.     setbounds (2, 318, 35, 120);
  413.     cls (rp);
  414.     setbounds (2, 318, 12, 198);
  415.     setdir (hero, DOWN);
  416.     c = addobject (&ob_hulk, -1, RIGHT, 0, a->y - 2);
  417.     dotext (hulk, 10, 60);
  418.     while (hero->y < a-> y) {
  419.         animate ();  WaitTOF ();
  420.     }
  421.     setdir (hero, LEFT);
  422.     hero -> flags |= FREEZE;
  423.     while (c->x + ob_hulk.width < a->x + ob_dale.width) {
  424.         animate ();  WaitTOF ();
  425.     }
  426.     removeobject (a);
  427.     a = addobject (&ob_skull, 1, UP, c->x + 8, c->y + 2);
  428.     n = c->x;
  429.     k = c->y + ob_hulk.height + 8;
  430.     SetAPen (rp, 12L);
  431.     Move (rp, (long) n, (long) k);
  432.     Text (rp, "UNEXPANDABLE HULK", 17L);
  433.     for (i=0; i<3; i++) {
  434.         d = addobject (&ob_mips, 2, LEFT,
  435.                    hero->x - ob_hero.width, hero->y + 4);
  436.         while (d->x > c->x + ob_hulk.width) {
  437.             animate ();  WaitTOF ();
  438.         }
  439.         removeobject (d);
  440.     }
  441.     for (i=0; i<75; i++) {
  442.         animate ();  WaitTOF ();
  443.     }
  444.     setdir (c, UP);
  445.     while (c->y > b->y) {        /*  Walk up to RJ's level  */
  446.         animate ();  WaitTOF ();
  447.     }
  448.     SetAPen (rp, 0L);
  449.     Move (rp, (long) n, (long) k);
  450.     Text (rp, "                 ", 17L);
  451.     setdir (hero, DOWN);
  452.     setdir (c, RIGHT);
  453.     removeobject (a);
  454.     while (c->x + ob_hulk.width < b->x + ob_RJ.width) {
  455.         animate ();  WaitTOF ();
  456.     }
  457.     removeobject (b);
  458.     b = addobject (&ob_skull, 1, UP, c->x + 8, c->y + 2);
  459.     while (!(c->flags & OFFSCREEN)) {
  460.         animate ();  WaitTOF ();
  461.     }
  462.     removeobject (b);
  463.     removeobject (c);
  464.     waittext ();
  465.     if (chkabort())    return (1);
  466.  
  467.     /*  "The Bogons and Crufties...."  */
  468.     setbounds (2, 318, 35, 120);
  469.     cls (rp);
  470.     setbounds (2, 318, 12, 198);
  471.     dotext (bogon, 10, 60);
  472.     a = addobject (&ob_spheroid, 1, LEFT, 280, 130);
  473.     b = addobject (&ob_quark, 1, RIGHT, 20, hero->y + 10);
  474.     for (i=0; i<60; i++) {
  475.         animate ();  WaitTOF ();
  476.     }
  477.     setdir (hero, UP);
  478.     hero -> flags &= ~FREEZE;
  479.     while (hero->y > a->y + 25) {
  480.         animate ();  WaitTOF ();
  481.     }
  482.     c = addobject(&ob_enforcer, 1, LEFT, a->x + ob_spheroid.width, a->y);
  483.     d = addobject(&ob_tank, 1, RIGHT, b->x - ob_tank.width, b->y);
  484.     while (hero->y > c->y) {
  485.         animate ();  WaitTOF ();
  486.     }
  487.     setdir (hero, LEFT);
  488.     hero -> flags |= FREEZE;
  489.     while (!(a -> flags & OFFSCREEN)) {
  490.         animate ();  WaitTOF ();
  491.     }
  492.     e = addobject (&ob_mips, 1, LEFT,
  493.                hero->x - ob_mips.width, hero->y + 4);
  494.     while (e->x > c->x + ob_enforcer.width) {
  495.         animate ();  WaitTOF ();
  496.     }
  497.     removeobject (e);
  498.     setexplode (c);
  499.     setdir (hero, DOWN);
  500.     hero -> flags &= ~FREEZE;
  501.     while (hero->y < d->y) {
  502.         animate ();  WaitTOF ();
  503.     }
  504.     e = addobject (&ob_mips, 1, RIGHT,
  505.                hero->x + ob_hero.width, hero->y + 4);
  506.     setdir (hero, RIGHT);
  507.     hero -> flags |= FREEZE;
  508.     while (e->x + ob_mips.width < d->x) {
  509.         animate ();  WaitTOF ();
  510.     }
  511.     removeobject (a);
  512.     removeobject (e);
  513.     setexplode (d);
  514.     a = addobject (&ob_jay, 1, RIGHT, 80, hero->y - 15);
  515.     for (i=0; i<100; i++) {
  516.         animate ();  WaitTOF ();
  517.     }
  518.     removeobject (b);
  519.     removeobject (c);
  520.     removeobject (d);
  521.     setdir (hero, DOWN);
  522.     setdir (a, DOWN);
  523.     for (i=0; i<10; i++) {
  524.         animate ();  WaitTOF ();
  525.     }
  526.     while (!textdone ()) {
  527.         animate ();  WaitTOF ();
  528.     }
  529.     for (i=0; i<150; i++) {
  530.         animate ();  WaitTOF ();
  531.     }
  532.     if (chkabort())    return (1);
  533.  
  534.     /*  "Beware of the Ingenuis Brain Marketroids..."  */
  535.     setbounds (2, 318, 35, 120);
  536.     cls (rp);
  537.     setbounds (2, 318, 12, 198);
  538.     dotext (ibm, 10, 60);
  539.     b = addobject (&ob_brain, 1, RIGHT, 20, 130);
  540.     setdir (a, UP);
  541.     for (i=0; i<100; i++) {
  542.         animate ();  WaitTOF ();
  543.     }
  544.     setdir (b, DOWN);
  545.     c = addobject (&ob_missile, 1, RIGHT, b->x, b->y);
  546.     setdir (hero, UP);
  547.     hero -> flags &= ~FREEZE;
  548.     while (hero->y + 4 > c->y) {
  549.         animate ();  WaitTOF ();
  550.     }
  551.     setdir (hero, LEFT);
  552.     hero -> flags |= FREEZE;
  553.     d = addobject (&ob_mips, 1, LEFT,
  554.                hero->x - ob_mips.width, hero->y + 4);
  555.     while (d->x > c->x + ob_missile.width) {
  556.         animate ();  WaitTOF ();
  557.     }
  558.     removeobject (d);
  559.     removeobject (c);
  560.     while (b->y < a->y - 2) {
  561.         animate ();  WaitTOF ();
  562.     }
  563.     setdir (a, LEFT);
  564.     setdir (b, RIGHT);
  565.     while (b->x + ob_brain.width < a->x) {
  566.         animate ();  WaitTOF ();
  567.     }
  568.     BltBitMap (ob_brain.bitmap, (long) b->xoff, (long) b->yoff,
  569.            sbm, (long) b->x, (long) b->y,
  570.            (long) ob_brain.width, (long) ob_brain.height,
  571.            0x30L, 0xffL, NULL);
  572.     setdir (a, RIGHT);
  573.     for (i=0; i<200; i++) {
  574.         n = a->y + rnd (11) - 5L;
  575.         BltBitMap (ob_jay.bitmap, (long) a->xoff, (long) a->yoff,
  576.                sbm, (long) a->x, (long) n,
  577.                (long) ob_jay.width, (long) ob_jay.height,
  578.                0x30L, 0xffL, NULL);
  579.         WaitTOF ();
  580.         BltBitMap (ob_jay.bitmap, 0L, 0L,
  581.                sbm, (long) a->x, (long) n,
  582.                (long) ob_jay.width, (long) ob_jay.height,
  583.                0L, 0xffL, NULL);
  584.     }
  585.     i = a->x;  n = a->y;
  586.     removeobject (a);
  587.     a = addobject (&ob_prog, 1, RIGHT, i, n);
  588.     setdir (hero, DOWN);
  589.     hero -> flags &= ~FREEZE;
  590.     c = d = e = f = g = NULL;
  591.     while (1) {            /*  We'll be 'break'ing out  */
  592.         n++;
  593.         if (hero->y > b->y && !c) {
  594.             setdir (hero, LEFT);
  595.             hero -> flags |= FREEZE;
  596.             c = addobject (&ob_mips, 1, LEFT,
  597.                        hero->x - ob_mips.width, hero->y + 4);
  598.             i = 1;
  599.         }
  600.         if (i && !(b -> flags & EXPLODING))
  601.             if (c->x < b->x + ob_brain.width) {
  602.                 removeobject (c);
  603.                 setexplode (b);
  604.             }
  605.         if (!d && a->x > 230)
  606.             d = addobject (&ob_bptr1, 1, UP,
  607.                        a->x - ob_bptr1.width, a->y);
  608.         if (!e && a->x > 250)
  609.             e = addobject (&ob_bptr2, 1, UP,
  610.                        a->x - ob_bptr1.width, a->y);
  611.         if (!f && a->x > 270)
  612.             f = addobject (&ob_bptr3, 1, UP,
  613.                        a->x - ob_bptr1.width, a->y);
  614.         if (!g && a->x > 290)
  615.             g = addobject (&ob_bptr4, 1, UP,
  616.                        a->x - ob_bptr1.width, a->y);
  617.         if (a -> flags & OFFSCREEN)
  618.             break;
  619.  
  620.         animate ();
  621.         WaitTOF ();
  622.     }
  623.     removeobject (a);
  624.     removeobject (b);
  625.     waittext ();
  626.     setdir (hero, DOWN);
  627.     for (i=0; i<10; i++) {
  628.         animate ();  WaitTOF();
  629.     }
  630.     Delay (100L);
  631.     if (chkabort())    return (1);
  632.  
  633.     /*  "As you struggle to save hackerdom...."  */
  634.     setbounds (2, 318, 35, 120);
  635.     cls (rp);
  636.     setbounds (2, 318, 12, 198);
  637.     dotext (struggle, 10, 60);
  638.     waittext ();
  639.     setdir (hero, RIGHT);
  640.     hero -> flags &= ~FREEZE;
  641.     while (hero->x < 180) {
  642.         animate ();  WaitTOF ();
  643.     }
  644.     c = addobject (&ob_mips, 1, RIGHT, hero->x+ob_hero.width, hero->y+4);
  645.     while (c->x + ob_mips.width < d->x) {
  646.         animate ();  WaitTOF ();
  647.     }
  648.     removeobject (c);
  649.     c = addobject (&ob_mips, 1, RIGHT, hero->x+ob_hero.width, hero->y+4);
  650.     setexplode (d);
  651.     while (c->x + ob_mips.width < e->x) {
  652.         animate ();  WaitTOF ();
  653.     }
  654.     removeobject (c);
  655.     c = addobject (&ob_mips, 1, RIGHT, hero->x+ob_hero.width, hero->y+4);
  656.     setexplode (e);
  657.     while (c->x + ob_mips.width < f->x) {
  658.         animate ();  WaitTOF ();
  659.     }
  660.     removeobject (c);
  661.     setexplode (f);
  662.     while (hero->x < g->x) {
  663.         animate ();  WaitTOF ();
  664.     }
  665.     setexplode (hero);
  666.     for (n=0; n<100; n++) {
  667.         animate ();
  668.         WaitTOF ();
  669.     }
  670.  
  671.     closeanim ();
  672.     closecycle ();
  673.     return (0);
  674. }
  675.  
  676. standardscreen (rp)
  677. register struct RastPort *rp;
  678. {
  679.     SetAPen (rp, 4L);
  680.     Move (rp, 80L, 7L);
  681.     Text (rp, "00              00", 18L);
  682.     SetAPen (rp, 14L);
  683.     Move (rp, (long) border[0], (long) border[1]);
  684.     PolyDraw (rp, 9L, border);
  685. }
  686.  
  687. standardcycle ()
  688. {
  689.     addcycle (CYCLE_THROUGH, redpulse, 3, 10, 0, 6);
  690.     addcycle (CYCLE_THROUGH, bgr, 3, 11, 0, 8);
  691.     addcycle (CYCLE_THROUGH, rpbpr, 16, 12, 0, 4);
  692.     addcycle (CYCLE_THROUGH, spectrum, 32, 13, 0, 4);
  693.     addcycle (CYCLE_THROUGH, blackspectrum, 24, 14, 0, 2);
  694.     addcycle (CYCLE_RANDOM, NULL, 0, 15, 0, 2);
  695. }
  696.  
  697. adjustgrunts ()
  698. {
  699.     extern struct List        guys;
  700.     register struct obcontrol    *oc;
  701.  
  702.     for (oc = (struct obcontrol *) guys.lh_Head;
  703.          oc -> node.ln_Succ;
  704.          oc = (struct obcontrol *) oc -> node.ln_Succ) {
  705.         /*  Doncha just love all these hard-coded numbers!!??  */
  706.         if (oc -> ob == &ob_grunt)
  707.             if (oc -> y < 130)
  708.                 if ((oc->y - 130) + (oc->x - 275) < 0)
  709.                     setdir (oc, LEFT);
  710.                 else
  711.                     setdir (oc, DOWN);
  712.             else
  713.                 if ((oc->y - 134) - (oc->x - 275) < 0)
  714.                     setdir (oc, LEFT);
  715.                 else
  716.                     setdir (oc, UP);
  717.     }
  718. }
  719.  
  720. dogruntkill (mips)
  721. struct obcontrol *mips;
  722. {
  723.     register struct obcontrol    *oc;
  724.     register int            x = mips->x + mips->ob->width;
  725.  
  726.     for (oc = (struct obcontrol *) guys.lh_Head;
  727.          oc -> node.ln_Succ;
  728.          oc = (struct obcontrol *) oc -> node.ln_Succ)
  729.         if (oc -> ob == &ob_grunt && !(oc->flags & EXPLODING))
  730.             if (x > oc -> x) {
  731.                 setexplode (oc);
  732.                 return (1);
  733.             }
  734.     return (0);
  735. }
  736.  
  737. openstuff ()
  738. {
  739.     extern long        VBeamPos();
  740.  
  741.     if (!(IntuitionBase = OpenLibrary ("intuition.library", 0L)))
  742.         die ("-=RJ=- is on vacation.\n");
  743.  
  744.     if (!(GfxBase = OpenLibrary ("graphics.library", 0L)))
  745.         die ("Dale is not in.\n");
  746.  
  747.     if (!(DiskfontBase = OpenLibrary ("diskfont.library", 0L)))
  748.         die ("Can't open diskfont.library.\n");
  749.  
  750.     if (!(scr = OpenScreen (&scrdef)))
  751.         die ("Screen won't open.\n");
  752.     vp = &scr -> ViewPort;
  753.     LoadRGB4 (vp, colormap, 16L);
  754.  
  755.     windef.Screen = scr;
  756.     if (!(win = OpenWindow (&windef)))
  757.         die ("Window painted shut.\n");
  758.  
  759.     if (!(blankspr = AllocMem (12L, MEMF_CHIP | MEMF_CLEAR)))
  760.         die ("Pointer sprite memory allocation failed.\n");
  761.     SetPointer (win, blankspr, 1L, 16L, 0L, 0L);
  762.  
  763.     if (!(bigrobo = OpenDiskFont (&robo8)))
  764.         die ("Failed to open robotron.font.8\n");
  765.     if (!(smallrobo = OpenDiskFont (&robo6)))
  766.         die ("Failed to open robotron.font.6\n");
  767.  
  768.     rnd ((short) -VBeamPos());
  769.     openanim ();
  770.     opentext (&scr -> RastPort, bigrobo);
  771. }
  772.  
  773. closestuff ()
  774. {
  775.     closetext ();
  776.     closecycle ();
  777.     closeanim ();
  778.  
  779.     if (smallrobo)        CloseFont (smallrobo);
  780.     if (bigrobo)        CloseFont (bigrobo);
  781.     if (blankspr)        FreeMem (blankspr, 12L);
  782.     if (win)        CloseWindow (win);
  783.     if (scr)        CloseScreen (scr);
  784.     if (DiskfontBase)    CloseLibrary (DiskfontBase);
  785.     if (GfxBase)        CloseLibrary (GfxBase);
  786.     if (IntuitionBase)    CloseLibrary (IntuitionBase);
  787. }
  788.  
  789. die (str)
  790. char *str;
  791. {
  792.     extern long    Output();
  793.  
  794.     Write (Output (), str, (long) strlen (str));
  795.     closestuff ();
  796.     exit (20);
  797. }
  798.