home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 145.lha / NoNukes!.c < prev    next >
C/C++ Source or Header  |  1986-11-21  |  25KB  |  890 lines

  1. /***************************************************************************
  2.  *
  3.  *       "NoNukes!.c"*
  4.  *       03-Aug-1987
  5.  *
  6.  *       A Nuclear Weapon Effects Simulator
  7.  *
  8.  *       From a Byte magazine artical, "LOCAL EFFECTS OF NUCLEAR WEAPONS",
  9.  *         written by John R. Fanchi, December 1986.
  10.  *
  11.  * ====> Amiga version by Roger Holmstedt <====
  12.  *
  13.  *       ROGER_HOLMSTEDT@CUP.PORTAL.COM
  14.  *       ROGER_HOLMSTEDT%CUP.PORTAL.COM@SUN.COM
  15.  *       {UCBVAX!SUN,UUNET!PORTAL}!CUP.PORTAL.COM!ROGER_HOLMSTEDT
  16.  *
  17.  *       (MANX)
  18.  *       Compile:  cc -Z2750 +ff NoNukes!.c
  19.  *       Link:     ln NoNukes!.o -lm -lc
  20.  *
  21.  *      * I'm not really a hard core anti-nuke person, its just that 
  22.  *        Reagan scares the hell out of me.  My Grandfather is as old 
  23.  *        as Reagan.  We don't let Gramps play with the T.V. remote
  24.  *        but Reagan has control of the button!  That's scary!  Well,
  25.  *        if we can just get through to next November without Ronnie
  26.  *        picking a fight with the "Evil Empire", we should be safe
  27.  *        until the Republicans elect another old fart 30 years from now.
  28.  *
  29.  *        Besides, it seemed like a good name for the program.
  30.  *
  31.  *        Please post all flames to 'dev/null'.
  32.  *
  33.  *        Disclaimer:  No warranty expressed or implied!  If a nuke goes
  34.  *                     off near you but the results differ from the
  35.  *                     projections of this program, don't blame me.
  36.  *
  37.  *        Released to the Public Domain
  38.  *
  39.  **************************************************************************/
  40.  
  41. #include <exec/types.h>
  42. #include <exec/execbase.h>
  43. #include <exec/memory.h>
  44. #include <intuition/intuition.h>
  45. #include <intuition/intuitionbase.h>
  46. #include <libraries/mathffp.h>
  47. #include <math.h>
  48.  
  49. struct IntuitionBase *IntuitionBase;
  50. struct GfxBase *GfxBase;
  51. struct ExecBase *ExecBase;
  52. struct MathBase *MathBase;
  53. struct IntuiMessage *message;
  54.  
  55. #define INTUITION_REV 0L
  56. #define GRAPHICS_REV 0L
  57. #define EXEC_REV 0L
  58. #define MATH_REV 0L
  59.  
  60. /* Things for gadgets */
  61.  
  62. /*  The header files needed for gadget definitions  */ 
  63. #include <libraries/dosextens.h> 
  64. #include <graphics/gfxbase.h> 
  65. #include <graphics/gfx.h> 
  66. #include <graphics/display.h> 
  67.  
  68. #include <graphics/text.h> 
  69. #include <ctype.h> 
  70.  
  71. /*  Definitions for Gadget ID numbers               */ 
  72. #define  MEGATONSGAD   0
  73. #define  THERMAL_ENERGYGAD   1
  74. #define  TRANSMISSIONGAD   2
  75. #define  RANGEGAD   3
  76. #define  HEIGHTGAD   4
  77. #define  BOOMGAD   5
  78.  
  79. /**********************************************************************
  80.  *  Text attribute structures used in rendering IntuiTexts
  81.  **********************************************************************/
  82.  
  83. char def_font[] ="topaz.font";
  84.  
  85. struct TextAttr TxtAt_Plain = {    (UBYTE *)def_font, 8,
  86.         FS_NORMAL, FPF_ROMFONT};
  87.  
  88. /**********************************************************************
  89.  *  Border Definitions for boom gadget
  90.  **********************************************************************/
  91.  
  92. SHORT boom_Pairs_1[] = {
  93.   0,     0,   
  94.   200,     0,   
  95.   200,     11,   
  96.   0,     11,   
  97.   0,     0    
  98. };
  99. struct Border boom_bord_1 = {
  100.   -1,  0,       /* LeftEdge, TopEdge */
  101.   1,  3,  JAM2,  /* FrontPen, BackPen, DrawMode*/
  102.   5,             /* Count of XY pairs */  
  103.   (SHORT *)&boom_Pairs_1, /* XY pairs */
  104.   NULL           /* Next Border */
  105. };
  106.  
  107. /**********************************************************************
  108.  *  IntuiTexts for the boom gadget.
  109.  **********************************************************************/
  110.  
  111. struct IntuiText boom_Text_0 = {
  112.    3, 0,     /* FrontPen, BackPen */
  113.    JAM2,       /* DrawMode */
  114.    8, 3,     /* LeftEdge, TopEdge */
  115.    &TxtAt_Plain, /* ITextFont Pointer */ 
  116.    /* The IText */
  117.    (UBYTE *)"CLICK HERE TO DETONATE!",
  118.    NULL
  119.  };
  120.  
  121. /**********************************************************************
  122.  *  Gadget Structure definition for the boom gadget.
  123.  **********************************************************************/
  124.  
  125. struct Gadget boom = {
  126.   NULL,     /* NextGadget pointer */
  127.   380, 68,    /* LeftEdge, TopEdge  */
  128.   200, 12,    /* Width, Height      */
  129.   /* Gadget Flags */
  130.   GADGHBOX,
  131.   /* Activation Flags */
  132.  GADGIMMEDIATE,
  133.   /* GadgetType */
  134.   BOOLGADGET,
  135.   (APTR)&boom_bord_1,   /*  GadgetRender */
  136.   NULL,    /* SelectRender */
  137.    &boom_Text_0,  /* GadgetText */
  138.   0x0,    /* MutualExclude */
  139.   NULL,   /* SpecialInfo */
  140.   BOOMGAD,    /* GadgetID         */
  141.   0x1     /* UserData Pointer */
  142. };
  143.  
  144. /**********************************************************************
  145.  * Image structure for height proportional gadget knob.
  146.  **********************************************************************/
  147.  
  148. struct Image height_knobim;
  149.  
  150. /**********************************************************************
  151.  *  IntuiTexts for the height gadget.
  152.  **********************************************************************/
  153.  
  154. struct IntuiText height_Text_0 = {
  155.    1, 0,     /* FrontPen, BackPen */
  156.    JAM2,       /* DrawMode */
  157.    0, 13,     /* LeftEdge, TopEdge */
  158.    &TxtAt_Plain, /* ITextFont Pointer */ 
  159.    /* The IText */
  160.    (UBYTE *)"Blast Height (in feet)",
  161.    NULL
  162.  };
  163.  
  164. /**********************************************************************
  165.  * Proportional gadget info for the height gadget.
  166.  **********************************************************************/
  167.  
  168. struct PropInfo height_prop_1 = {
  169.    /* Flags                     */
  170.    AUTOKNOB | FREEHORIZ,
  171.   0x0000, 0x0000,   /* HorizPot, VertPot     */
  172.   0x028F, 0x1000,   /* HorizBody, VertBody   */
  173.    200,   12,   /* CWidth, CHeight       */
  174.   0x1111, 0x1111,   /* HPotRes, VPotRes      */
  175.      4,    2    /* LeftBorder, TopBorder */
  176. };
  177.  
  178. /**********************************************************************
  179.  *  Gadget Structure definition for the height gadget.
  180.  **********************************************************************/
  181.  
  182. struct Gadget height = {
  183.   &boom,     /* NextGadget pointer */
  184.   380, 44,    /* LeftEdge, TopEdge  */
  185.   200, 12,    /* Width, Height      */
  186.   /* Gadget Flags */
  187.    NULL,
  188.   /* Activation Flags */
  189.  GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,
  190.   /* GadgetType */
  191.   PROPGADGET,
  192.   (APTR)&height_knobim,    /*  GadgetRender */
  193.   NULL,    /* SelectRender */
  194.    &height_Text_0,  /* GadgetText */
  195.   0x0,    /* MutualExclude */
  196.   (APTR)&height_prop_1,   /* SpecialInfo */
  197.   HEIGHTGAD,    /* GadgetID         */
  198.   0x10     /* UserData Pointer */
  199. };
  200.  
  201. /**********************************************************************
  202.  * Image structure for range proportional gadget knob.
  203.  **********************************************************************/
  204.  
  205. struct Image range_knobim;
  206.  
  207. /**********************************************************************
  208.  *  IntuiTexts for the range_energy gadget.
  209.  **********************************************************************/
  210.  
  211. struct IntuiText range_Text_0 = {
  212.    1, 0,     /* FrontPen, BackPen */
  213.    JAM2,       /* DrawMode */
  214.    0, 13,     /* LeftEdge, TopEdge */
  215.    &TxtAt_Plain, /* ITextFont Pointer */ 
  216.    /* The IText */
  217.    (UBYTE *)"Distance (in miles)",
  218.    NULL
  219.  };
  220.  
  221. /**********************************************************************
  222.  * Proportional gadget info for the range_energy gadget.
  223.  **********************************************************************/
  224.  
  225. struct PropInfo range_prop_2 = {
  226.    /* Flags                     */
  227.    AUTOKNOB | FREEHORIZ,
  228.   0x0000, 0x0000,   /* HorizPot, VertPot     */
  229.   0x028F, 0x1000,   /* HorizBody, VertBody   */
  230.    200,   12,   /* CWidth, CHeight       */
  231.   0x1111, 0x1111,   /* HPotRes, VPotRes      */
  232.      4,    2    /* LeftBorder, TopBorder */
  233. };
  234.  
  235. /**********************************************************************
  236.  *  Gadget Structure definition for the thermal_energy gadget.
  237.  **********************************************************************/
  238.  
  239. struct Gadget range = {
  240.  &height,     /* NextGadget pointer */
  241.   380, 20,    /* LeftEdge, TopEdge  */
  242.   200, 12,    /* Width, Height      */
  243.   /* Gadget Flags */
  244.    NULL,
  245.   /* Activation Flags */
  246.  GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,
  247.   /* GadgetType */
  248.   PROPGADGET,
  249.   (APTR)&range_knobim,    /*  GadgetRender */
  250.   NULL,    /* SelectRender */
  251.    &range_Text_0,  /* GadgetText */
  252.   0x0,    /* MutualExclude */
  253.   (APTR)&range_prop_2,   /* SpecialInfo */
  254.   RANGEGAD,    /* GadgetID         */
  255.   0x10     /* UserData Pointer */
  256. };
  257.  
  258. /**********************************************************************
  259.  * Image structure for transmission proportional gadget knob.
  260.  **********************************************************************/
  261.  
  262. struct Image transmission_knobim;
  263.  
  264. /**********************************************************************
  265.  *  IntuiTexts for the transmission gadget.
  266.  **********************************************************************/
  267.  
  268. struct IntuiText transmission_Text_0 = {
  269.    1, 0,     /* FrontPen, BackPen */
  270.    JAM2,       /* DrawMode */
  271.    0, 13,     /* LeftEdge, TopEdge */
  272.    &TxtAt_Plain, /* ITextFont Pointer */ 
  273.    /* The IText */
  274.    (UBYTE *)"Transmission Factor",
  275.    NULL
  276.  };
  277.  
  278. /**********************************************************************
  279.  * Proportional gadget info for the transmission gadget.
  280.  **********************************************************************/
  281.  
  282. struct PropInfo transmission_prop_3 = {
  283.    /* Flags                     */
  284.    AUTOKNOB | FREEHORIZ,
  285.   0x0000, 0x0000,   /* HorizPot, VertPot     */
  286.   0x0CCC, 0x1000,   /* HorizBody, VertBody   */
  287.    200,   12,   /* CWidth, CHeight       */
  288.   0x1111, 0x1111,   /* HPotRes, VPotRes      */
  289.      4,    2    /* LeftBorder, TopBorder */
  290. };
  291.  
  292. /**********************************************************************
  293.  *  Gadget Structure definition for the transmission gadget.
  294.  **********************************************************************/
  295.  
  296. struct Gadget transmission = {
  297.   &range,     /* NextGadget pointer */
  298.   60, 68,    /* LeftEdge, TopEdge  */
  299.   200, 12,    /* Width, Height      */
  300.   /* Gadget Flags */
  301.    NULL,
  302.   /* Activation Flags */
  303.  GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,
  304.   /* GadgetType */
  305.   PROPGADGET,
  306.   (APTR)&transmission_knobim,    /*  GadgetRender */
  307.   NULL,    /* SelectRender */
  308.    &transmission_Text_0,  /* GadgetText */
  309.   0x0,    /* MutualExclude */
  310.   (APTR)&transmission_prop_3,   /* SpecialInfo */
  311.   TRANSMISSIONGAD,    /* GadgetID         */
  312.   0x10     /* UserData Pointer */
  313. };
  314.  
  315. /**********************************************************************
  316.  * Image structure for thermal_energy proportional gadget knob.
  317.  **********************************************************************/
  318.  
  319. struct Image thermal_energy_knobim;
  320.  
  321. /**********************************************************************
  322.  *  IntuiTexts for the thermal_energy gadget.
  323.  **********************************************************************/
  324.  
  325. struct IntuiText thermal_energy_Text_0 = {
  326.    1, 0,     /* FrontPen, BackPen */
  327.    JAM2,       /* DrawMode */
  328.    0, 13,     /* LeftEdge, TopEdge */
  329.    &TxtAt_Plain, /* ITextFont Pointer */ 
  330.    /* The IText */
  331.    (UBYTE *)"Thermal Energy Fraction",
  332.    NULL
  333.  };
  334.  
  335. /**********************************************************************
  336.  * Proportional gadget info for the thermal_energy gadget.
  337.  **********************************************************************/
  338.  
  339. struct PropInfo thermal_energy_prop_4 = {
  340.    /* Flags                     */
  341.    AUTOKNOB | FREEHORIZ,
  342.   0x0000, 0x0000,   /* HorizPot, VertPot     */
  343.   0x0CCC, 0x1000,   /* HorizBody, VertBody   */
  344.    200,   12,   /* CWidth, CHeight       */
  345.   0x1111, 0x1111,   /* HPotRes, VPotRes      */
  346.      4,    2    /* LeftBorder, TopBorder */
  347. };
  348.  
  349. /**********************************************************************
  350.  *  Gadget Structure definition for the thermal_energy gadget.
  351.  **********************************************************************/
  352.  
  353. struct Gadget thermal_energy = {
  354.  &transmission,     /* NextGadget pointer */
  355.   60, 44,    /* LeftEdge, TopEdge  */
  356.   200, 12,    /* Width, Height      */
  357.   /* Gadget Flags */
  358.    NULL,
  359.   /* Activation Flags */
  360.  GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,
  361.   /* GadgetType */
  362.   PROPGADGET,
  363.   (APTR)&thermal_energy_knobim,    /*  GadgetRender */
  364.   NULL,    /* SelectRender */
  365.    &thermal_energy_Text_0,  /* GadgetText */
  366.   0x0,    /* MutualExclude */
  367.   (APTR)&thermal_energy_prop_4,   /* SpecialInfo */
  368.   THERMAL_ENERGYGAD,    /* GadgetID         */
  369.   0x10     /* UserData Pointer */
  370. };
  371.  
  372. /**********************************************************************
  373.  * Image structure for megatons proportional gadget knob.
  374.  **********************************************************************/
  375.  
  376. struct Image megatons_knobim;
  377.  
  378. /**********************************************************************
  379.  *  IntuiTexts for the megatons gadget.
  380.  **********************************************************************/
  381.  
  382. struct IntuiText megatons_Text_0 = {
  383.    1, 0,     /* FrontPen, BackPen */
  384.    JAM2,       /* DrawMode */
  385.    0, 13,     /* LeftEdge, TopEdge */
  386.    &TxtAt_Plain, /* ITextFont Pointer */ 
  387.    /* The IText */
  388.    (UBYTE *)"Weapon Yield",
  389.    NULL
  390.  };
  391.  
  392. /**********************************************************************
  393.  * Proportional gadget info for the megatons gadget.
  394.  **********************************************************************/
  395.  
  396. struct PropInfo megatons_prop_5 = {
  397.    /* Flags                     */
  398.    AUTOKNOB | FREEHORIZ,
  399.   0x0000, 0x0000,   /* HorizPot, VertPot     */
  400.   0x0333, 0x1000,   /* HorizBody, VertBody   */
  401.    200,   12,   /* CWidth, CHeight       */
  402.   0x1111, 0x1111,   /* HPotRes, VPotRes      */
  403.      4,    2    /* LeftBorder, TopBorder */
  404. };
  405.  
  406. /**********************************************************************
  407.  *  Gadget Structure definition for the megatons gadget.
  408.  **********************************************************************/
  409.  
  410. struct Gadget megatons = {
  411.  &thermal_energy,     /* NextGadget pointer */
  412.   60, 20,    /* LeftEdge, TopEdge  */
  413.   200, 12,    /* Width, Height      */
  414.   /* Gadget Flags */
  415.    NULL,
  416.   /* Activation Flags */
  417.  GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,
  418.   /* GadgetType */
  419.   PROPGADGET,
  420.   (APTR)&megatons_knobim,    /*  GadgetRender */
  421.   NULL,    /* SelectRender */
  422.    &megatons_Text_0,  /* GadgetText */
  423.   0x0,    /* MutualExclude */
  424.   (APTR)&megatons_prop_5,   /* SpecialInfo */
  425.   MEGATONSGAD,    /* GadgetID         */
  426.   0x10     /* UserData Pointer */
  427. };
  428.  
  429. /* End of things for gadgets */
  430.  
  431. main()
  432. {
  433.    struct NewWindow NewWindow;
  434.    struct Window *Window, *OpenWindow();
  435.    struct RastPort *RP;
  436.    struct IntuiMessage *GetMsg();
  437.    struct Gadget *igad;
  438.  
  439.    float H, D, TAU, TEF, Y;
  440.    double Q, Z, P, EMP, REMS, jnk1, jnk2, jnk3;
  441.    ULONG class;
  442.    USHORT gadgid;
  443.    USHORT casetest;
  444.    APTR address;
  445.    void *Move();
  446.    long *Text();
  447.    char txt[20];
  448.  
  449.   /* Open the libraries.    */
  450.  
  451.    void *OpenLibrary(); 
  452.  
  453.    IntuitionBase = (struct IntuitionBase *)
  454.       OpenLibrary("intuition.library",INTUITION_REV);
  455.    if(IntuitionBase == NULL)
  456.       {
  457.       Cleanup();
  458.       exit(FALSE);
  459.       }
  460.  
  461.    GfxBase = (struct GfxBase *) OpenLibrary("graphics.library",GRAPHICS_REV);
  462.    if(GfxBase == NULL)
  463.       {
  464.       Cleanup();
  465.       exit(FALSE);
  466.       }
  467.  
  468.    ExecBase = (struct ExecBase *) OpenLibrary("exec.library",EXEC_REV);
  469.    if(ExecBase == NULL)
  470.       {
  471.       Cleanup();
  472.       exit(FALSE);
  473.       }
  474.  
  475.    MathBase = (struct MathBase *) OpenLibrary("mathffp.library",MATH_REV);
  476.    if(MathBase == NULL)
  477.       {
  478.       Cleanup();
  479.       exit(FALSE);
  480.       }
  481.  
  482.    /* Initialize the NewWindow structure for the call to OpenWindow() */
  483.  
  484.    NewWindow.LeftEdge = 0;
  485.    NewWindow.TopEdge = 11;
  486.    NewWindow.Width = 640;
  487.    NewWindow.Height = 189;
  488.    NewWindow.DetailPen = 0;
  489.    NewWindow.BlockPen = 1;
  490.    NewWindow.Title = (UBYTE *)" Nuclear Weapon Effects Simulator! ";
  491.    NewWindow.Flags = WINDOWCLOSE | SMART_REFRESH | ACTIVATE | WINDOWDEPTH
  492.                      | NOCAREREFRESH;
  493.    NewWindow.IDCMPFlags = CLOSEWINDOW | GADGETDOWN | GADGETUP | MOUSEMOVE;
  494.    NewWindow.Type = WBENCHSCREEN;
  495.    NewWindow.FirstGadget = &megatons;
  496.    NewWindow.CheckMark = NULL;
  497.    NewWindow.Screen = NULL;
  498.    NewWindow.BitMap = NULL;
  499.    NewWindow.MinWidth = 640;
  500.    NewWindow.MinHeight = 189;
  501.    NewWindow.MaxWidth = 640;
  502.    NewWindow.MaxHeight = 189;
  503.  
  504.    /* Try to open the window. */
  505.  
  506.    if(( Window = (struct Window *) OpenWindow(&NewWindow)) == NULL)
  507.       {
  508.       Cleanup();
  509.       exit(FALSE);
  510.       }
  511.  
  512. /* Set the first Numbers */
  513. H = 0L;
  514. D = 0L;
  515. TAU = 0L;
  516. TEF = 0L;
  517. Y = 0L;
  518.  
  519. /* Print the first Numbers */
  520. RP = Window->RPort;
  521. SetAPen(RP,3L);
  522. SetDrMd(RP,JAM2);
  523.  
  524. Move(RP,10L,30L);
  525. Text(RP,"0.00",4L);
  526.  
  527. Move(RP,10L,54L);
  528. Text(RP,"0.00",4L);
  529.  
  530. Move(RP,10L,78L);
  531. Text(RP,"0.00",4L);
  532.  
  533. Move(RP,359L,30L);
  534. Text(RP,"0",1L);
  535.  
  536. Move(RP,359L,54L);
  537. Text(RP,"0",1L);
  538.  
  539. for(;;)
  540. {
  541.    if(( message = (struct IntuiMessage *) GetMsg(Window->UserPort)) == 0L)
  542.    {
  543.      Wait(1L << Window->UserPort->mp_SigBit);
  544.     continue;
  545.    }
  546.  
  547.    class = message->Class;
  548.    igad = (struct Gadget *) message->IAddress;
  549.    gadgid = igad->GadgetID;
  550.    ReplyMsg(message);
  551.  
  552.    switch (class)
  553.    {
  554.      case CLOSEWINDOW :
  555.         while (message =(struct IntuiMessage *)
  556.         GetMsg(Window->UserPort))
  557.         ReplyMsg(message);
  558.     CloseWindow(Window);
  559.     Cleanup();
  560.     exit(TRUE);
  561.     break;
  562.  
  563.      case GADGETDOWN :    
  564.     
  565.     switch (gadgid)
  566.     {
  567.         case BOOMGAD :
  568.             SetAPen(RP,1L);
  569.             SetDrMd(RP,JAM2);
  570.  
  571.         /* Set Mins */
  572.         if(D == 0)
  573.         D = .001;
  574.         else
  575.         D = D;
  576.  
  577.         if(H == 0)
  578.         H = .001;
  579.         else
  580.         H = H;
  581.         
  582.         if(Y == 0)
  583.         {
  584.             Move(RP,380L,90L);
  585.             Text(RP,"What luck, a DUD!", 17L);
  586.             SetAPen(RP,3L);
  587.             SetDrMd(RP,JAM2);
  588.             break;
  589.         }
  590.         else
  591.         {
  592.             Move(RP,380L,90L);
  593.             Text(RP,"                 ", 17L);
  594.         }
  595.  
  596.         /* Thermal Flux */
  597.             Q = 3000 * (TEF/20) * (TAU/20) * (Y/4) / (D * D);
  598. Move(RP,20L,100L);
  599. if(Q < 10L)
  600.   if(Q < 5L)
  601.      if(Q < 1L)
  602.          Text(RP,"Thermal flux has added to your tan.             ", 48L);
  603.      else
  604.          Text(RP,"Thermal flux has caused you second degree burns.", 48L);
  605.   else
  606.         Text(RP,"Thermal flux had caused you third degree burns. ", 48L);
  607. else
  608.         Text(RP,"Thermal flux has burned you to a crisp.         ", 48L);
  609.  
  610.         /* Blast Overpressure */
  611.             Z = (pow((double)(Y/4),(double)(.333))) / D;
  612.             jnk1 = 22.4 * (pow((double)Z,(double)3));
  613.             jnk2 = 15.8 * (pow((double)Z,(double)(1.5)));
  614.             P = jnk1 + jnk2;
  615. Move(RP,30L,110L);
  616. if(P < 20L)
  617.   if(P < 10L)
  618.     if(P < 5L)
  619.       if(P < 2L)
  620.          {
  621.      Text(RP,"OverPressure has not had a significant effect on wind", 53L);
  622.      Move(RP,30L,120L);
  623.      Text(RP,"conditions or the structures of buildings.           ", 53L);
  624.      Move(RP,30L,130L);
  625.      Text(RP,"                                                     ", 53L);
  626.      }
  627.       else
  628.          {
  629.          Text(RP,"OverPressure has caused winds in excess of           ", 53L);
  630.      Move(RP,30L,120L);
  631.      Text(RP,"70 miles per hour.                                   ", 53L);
  632.      Move(RP,30L,130L);
  633.      Text(RP,"                                                     ", 53L);
  634.      }
  635.     else
  636.        {
  637.          Text(RP,"OverPressure has caused winds in excess of           ", 53L);
  638.      Move(RP,30L,120L);
  639.      Text(RP,"160 miles per hour.  Unreinforced brick and          ", 53L);
  640.      Move(RP,30L,130L);
  641.      Text(RP,"wood houses are leveled.                             ", 53L);
  642.        }
  643.   else
  644.      {
  645.          Text(RP,"OverPressure has caused winds in excess of 300 miles ", 53L);
  646.      Move(RP,30L,120L);
  647.      Text(RP,"per hour.  Most factories and commercial buildings   ", 53L);
  648.      Move(RP,30L,130L);
  649.      Text(RP,"are leveled, as are small wood and brick residences. ", 53L);
  650.        
  651.      }
  652. else
  653.    {
  654.          Text(RP,"OverPressure has caused winds in excess of 500 miles ", 53L);
  655.      Move(RP,30L,120L);
  656.      Text(RP,"per hour.  Even multi-story reinforced concrete      ", 53L);
  657.      Move(RP,30L,130L);
  658.      Text(RP,"buildings are leveled.                               ", 53L);
  659.        
  660.    }
  661.  
  662.         /* EMP Range */
  663.             jnk1 = (H*3963)/5280;
  664.             jnk2 = 2*1000;
  665.             jnk3 = (jnk1*jnk2);
  666.             EMP = sqrt((double)jnk3);
  667. Move(RP,50L,180L);
  668. if(D > EMP)
  669.   Text(RP,"You are outside the range of the Electromagnetic pulse.", 55L);
  670. else
  671.   Text(RP,"You are inside the range of the Electromagnetic pulse. ", 55L);
  672.         /* Radiation Dosage */
  673.             jnk1 = 250 * 100;
  674.             jnk2 = 16 * 3.1416 * D * D;
  675.             jnk3 = ((jnk1 / jnk2) * (Y/4)) * 10;
  676.             REMS = jnk3;
  677. Move(RP,40L,140L);
  678. if(REMS < 5000L)
  679.   if(REMS < 1000L)
  680.     if(REMS < 600L)
  681.       if(REMS < 200L)
  682.         if(REMS < 100L)
  683.          {
  684.      Text(RP,"You have survived radiation exposure with NO effects.", 53L);
  685.      Move(RP,40L,150L);
  686.      Text(RP,"                                                     ", 53L);
  687.      Move(RP,40L,160L);
  688.      Text(RP,"                                                     ", 53L);
  689.      Move(RP,40L,170L);
  690.      Text(RP,"                                                     ", 53L);
  691.      }
  692.         else
  693.      {
  694.          Text(RP,"Radiation exposure had made you sick--vomiting,      ", 53L);
  695.      Move(RP,40L,150L);
  696.      Text(RP,"headache, some loss of white blood cells and         ", 53L);
  697.      Move(RP,40L,160L);
  698.      Text(RP,"dizziness. This is good. You will completely recover.", 53L);
  699.      Move(RP,40L,170L);
  700.      Text(RP,"                                                     ", 53L);
  701.      }
  702.       else
  703.          {
  704.          Text(RP,"Your symptoms range from leukopenia to hair loss     ", 53L);
  705.      Move(RP,40L,150L);
  706.      Text(RP,"because of radiation exposure.  Hospitalization is   ", 53L);
  707.      Move(RP,40L,160L);
  708.      Text(RP,"required and is available to you because you have a  ", 53L);
  709.      Move(RP,40L,170L);
  710.      Text(RP,"reasonable chance to live.                           ", 53L);
  711.      }
  712.     else
  713.        {
  714.          Text(RP,"You have very severe leukopenia and internal         ", 53L);
  715.      Move(RP,40L,150L);
  716.      Text(RP,"bleeding. Ulcers and infection is likely because of  ", 53L);
  717.      Move(RP,40L,160L);
  718.      Text(RP,"radiation exposure. You need hospitalization but none", 53L);
  719.      Move(RP,40L,170L);
  720.      Text(RP,"is available, you have less than a month to live.    ", 53L);
  721.        }
  722.   else
  723.      {
  724.          Text(RP,"You have diarrhea, fever and disturbance of you body ", 53L);
  725.      Move(RP,40L,150L);
  726.      Text(RP,"chemistry because of radiation exposure.  Treatment  ", 53L);
  727.      Move(RP,40L,160L);
  728.      Text(RP,"my alleviate pain, but it will not save your life.   ", 53L);
  729.          Move(RP,40L,170L);
  730.      Text(RP,"You have less that two weeks to live.                ", 53L);
  731.      }
  732. else
  733.    {
  734.          Text(RP,"You are experiencing convulsions, Tremors and ataxia ", 53L);
  735.      Move(RP,40L,150L);
  736.      Text(RP,"because of radiation exposure.                       ", 53L);
  737.      Move(RP,40L,160L);
  738.      Text(RP,"No treatment will help you.                          ", 53L);
  739.      Move(RP,40L,170L);
  740.      Text(RP,"                                                     ", 53L);
  741.    }
  742.         SetAPen(RP,3L);
  743.         SetDrMd(RP,JAM2);
  744.  
  745.         break;
  746.         
  747.         case HEIGHTGAD :
  748.             casetest = gadgid;
  749.             H = (heights(0));
  750.             sprintf(txt, "%6.0f", (H*1000L));
  751.             Move(RP, 319L, 54L);
  752.             Text(RP, txt, 6L);
  753.         break;
  754.             
  755.         case RANGEGAD :
  756.             casetest = gadgid;
  757.             D = (ranges(0));
  758.             sprintf(txt, "%3.0f", D);
  759.             Move(RP, 343L, 30L);
  760.             Text(RP, txt, 3L);
  761.     
  762.         break;
  763.  
  764.         case TRANSMISSIONGAD :
  765.             casetest = gadgid;
  766.             TAU = (trans(0));
  767.             sprintf(txt, "%3.3f", (TAU/20L));
  768.             Move(RP, 10L, 78L);
  769.             Text(RP, txt, 4L);
  770.     
  771.         break;
  772.  
  773.         case THERMAL_ENERGYGAD :
  774.             casetest = gadgid;
  775.             TEF = (thermal(0));
  776.             sprintf(txt, "%3.3f", (TEF/20L));
  777.             Move(RP, 10L, 54L);
  778.             Text(RP, txt, 4L);
  779.     
  780.         break;
  781.  
  782.         case MEGATONSGAD :
  783.             casetest = gadgid;
  784.             Y = (megs(0));
  785.             sprintf(txt, "%3.3f", (Y/4L));
  786.             Move(RP, 10L, 30L);
  787.             Text(RP, txt, 5L);
  788.     
  789.         break;
  790.     }/* End of SWITCH (gadgid) */
  791.     
  792.     break;
  793.      
  794.      case MOUSEMOVE :
  795.          switch (casetest)
  796.     {
  797.         case HEIGHTGAD :
  798.             H = (heights(0));
  799.             sprintf(txt, "%6.0f", (H*1000L));
  800.             Move(RP, 320L, 54L);
  801.             Text(RP, txt, 6L);
  802.     
  803.         break;
  804.             
  805.         case RANGEGAD :
  806.             D = (ranges(0));
  807.             sprintf(txt, "%3.0f", D);
  808.             Move(RP, 342L, 30L);
  809.             Text(RP, txt, 3L);
  810.     
  811.         break;
  812.  
  813.         case TRANSMISSIONGAD :
  814.             TAU = (trans(0));
  815.             sprintf(txt, "%3.3f", (TAU/20L));
  816.             Move(RP, 10L, 78L);
  817.             Text(RP, txt, 4L);
  818.     
  819.         break;
  820.  
  821.         case THERMAL_ENERGYGAD :
  822.             TEF = (thermal(0));
  823.             sprintf(txt, "%3.3f", (TEF/20L));
  824.             Move(RP, 10L, 54L);
  825.             Text(RP, txt, 4L);
  826.     
  827.         break;
  828.  
  829.         case MEGATONSGAD :
  830.             Y = (megs(0));
  831.             sprintf(txt, "%3.3f", (Y/4L));
  832.             Move(RP, 10L, 30L);
  833.             Text(RP, txt, 5L);
  834.     
  835.         break;
  836.  
  837.     }/* End of SWITCH (casetest) */
  838.    }/* End of SWITCH (class)*/
  839. }/* End of FOR */
  840. }/* End of MAIN */
  841.  
  842.  
  843. Cleanup()
  844. {
  845.     if (MathBase) CloseLibrary(MathBase);
  846.     if (ExecBase) CloseLibrary(ExecBase);
  847.     if (GfxBase) CloseLibrary(GfxBase);
  848.     if (IntuitionBase) CloseLibrary(IntuitionBase);
  849. }/* End of Cleanup() */
  850.  
  851.  
  852. megs()
  853. {
  854. float Y;
  855.     Y = (megatons_prop_5.HorizPot / 0x0333);
  856.     return Y;
  857. }
  858.  
  859.  
  860. thermal()
  861. {
  862. float TEF;
  863.     TEF = (thermal_energy_prop_4.HorizPot / 0x0CCC);
  864.     return TEF;
  865. }
  866.  
  867.  
  868. trans()
  869. {
  870. float TAU;
  871.     TAU = (transmission_prop_3.HorizPot / 0x0CCC);
  872.     return TAU;
  873. }
  874.  
  875.  
  876. ranges()
  877. {
  878. float D;
  879.     D = (range_prop_2.HorizPot / 0x028F);
  880.     return D;
  881. }
  882.  
  883.  
  884. heights()
  885. {
  886. float H;
  887.     H = (height_prop_1.HorizPot / 0x028F);
  888.     return H;
  889. }
  890.