/***************************************************************************
 *
 *       "NoNukes!.c"*
 *       03-Aug-1987
 *
 *       A Nuclear Weapon Effects Simulator
 *
 *       From a Byte magazine artical, "LOCAL EFFECTS OF NUCLEAR WEAPONS",
 *         written by John R. Fanchi, December 1986.
 *
 * ====> Amiga version by Roger Holmstedt <====
 *
 *       ROGER_HOLMSTEDT@CUP.PORTAL.COM
 *       ROGER_HOLMSTEDT%CUP.PORTAL.COM@SUN.COM
 *       {UCBVAX!SUN,UUNET!PORTAL}!CUP.PORTAL.COM!ROGER_HOLMSTEDT
 *
 *       (MANX)
 *       Compile:  cc -Z2750 +ff NoNukes!.c
 *       Link:     ln NoNukes!.o -lm -lc
 *
 *      * I'm not really a hard core anti-nuke person, its just that 
 *        Reagan scares the hell out of me.  My Grandfather is as old 
 *        as Reagan.  We don't let Gramps play with the T.V. remote
 *        but Reagan has control of the button!  That's scary!  Well,
 *        if we can just get through to next November without Ronnie
 *        picking a fight with the "Evil Empire", we should be safe
 *        until the Republicans elect another old fart 30 years from now.
 *
 *        Besides, it seemed like a good name for the program.
 *
 *        Please post all flames to 'dev/null'.
 *
 *        Disclaimer:  No warranty expressed or implied!  If a nuke goes
 *                     off near you but the results differ from the
 *                     projections of this program, don't blame me.
 *
 *        Released to the Public Domain
 *
 **************************************************************************/

#include <exec/types.h>
#include <exec/execbase.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <libraries/mathffp.h>
#include <math.h>

struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct ExecBase *ExecBase;
struct MathBase *MathBase;
struct IntuiMessage *message;

#define INTUITION_REV 0L
#define GRAPHICS_REV 0L
#define EXEC_REV 0L
#define MATH_REV 0L

/* Things for gadgets */

/*  The header files needed for gadget definitions  */ 
#include <libraries/dosextens.h> 
#include <graphics/gfxbase.h> 
#include <graphics/gfx.h> 
#include <graphics/display.h> 

#include <graphics/text.h> 
#include <ctype.h> 

/*  Definitions for Gadget ID numbers               */ 
#define  MEGATONSGAD   0
#define  THERMAL_ENERGYGAD   1
#define  TRANSMISSIONGAD   2
#define  RANGEGAD   3
#define  HEIGHTGAD   4
#define  BOOMGAD   5

/**********************************************************************
 *  Text attribute structures used in rendering IntuiTexts
 **********************************************************************/

char def_font[] ="topaz.font";

struct TextAttr TxtAt_Plain = {	(UBYTE *)def_font, 8,
        FS_NORMAL, FPF_ROMFONT};

/**********************************************************************
 *  Border Definitions for boom gadget
 **********************************************************************/

SHORT boom_Pairs_1[] = {
  0,     0,   
  200,     0,   
  200,     11,   
  0,     11,   
  0,     0    
};
struct Border boom_bord_1 = {
  -1,  0,       /* LeftEdge, TopEdge */
  1,  3,  JAM2,  /* FrontPen, BackPen, DrawMode*/
  5,             /* Count of XY pairs */  
  (SHORT *)&boom_Pairs_1, /* XY pairs */
  NULL           /* Next Border */
};

/**********************************************************************
 *  IntuiTexts for the boom gadget.
 **********************************************************************/

struct IntuiText boom_Text_0 = {
   3, 0,     /* FrontPen, BackPen */
   JAM2,       /* DrawMode */
   8, 3,     /* LeftEdge, TopEdge */
   &TxtAt_Plain, /* ITextFont Pointer */ 
   /* The IText */
   (UBYTE *)"CLICK HERE TO DETONATE!",
   NULL
 };

/**********************************************************************
 *  Gadget Structure definition for the boom gadget.
 **********************************************************************/

struct Gadget boom = {
  NULL,     /* NextGadget pointer */
  380, 68,    /* LeftEdge, TopEdge  */
  200, 12,    /* Width, Height      */
  /* Gadget Flags */
  GADGHBOX,
  /* Activation Flags */
 GADGIMMEDIATE,
  /* GadgetType */
  BOOLGADGET,
  (APTR)&boom_bord_1,   /*  GadgetRender */
  NULL,    /* SelectRender */
   &boom_Text_0,  /* GadgetText */
  0x0,    /* MutualExclude */
  NULL,   /* SpecialInfo */
  BOOMGAD,    /* GadgetID         */
  0x1     /* UserData Pointer */
};

/**********************************************************************
 * Image structure for height proportional gadget knob.
 **********************************************************************/

struct Image height_knobim;

/**********************************************************************
 *  IntuiTexts for the height gadget.
 **********************************************************************/

struct IntuiText height_Text_0 = {
   1, 0,     /* FrontPen, BackPen */
   JAM2,       /* DrawMode */
   0, 13,     /* LeftEdge, TopEdge */
   &TxtAt_Plain, /* ITextFont Pointer */ 
   /* The IText */
   (UBYTE *)"Blast Height (in feet)",
   NULL
 };

/**********************************************************************
 * Proportional gadget info for the height gadget.
 **********************************************************************/

struct PropInfo height_prop_1 = {
   /* Flags                     */
   AUTOKNOB | FREEHORIZ,
  0x0000, 0x0000,   /* HorizPot, VertPot     */
  0x028F, 0x1000,   /* HorizBody, VertBody   */
   200,   12,   /* CWidth, CHeight       */
  0x1111, 0x1111,   /* HPotRes, VPotRes      */
     4,    2    /* LeftBorder, TopBorder */
};

/**********************************************************************
 *  Gadget Structure definition for the height gadget.
 **********************************************************************/

struct Gadget height = {
  &boom,     /* NextGadget pointer */
  380, 44,    /* LeftEdge, TopEdge  */
  200, 12,    /* Width, Height      */
  /* Gadget Flags */
   NULL,
  /* Activation Flags */
 GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,
  /* GadgetType */
  PROPGADGET,
  (APTR)&height_knobim,    /*  GadgetRender */
  NULL,    /* SelectRender */
   &height_Text_0,  /* GadgetText */
  0x0,    /* MutualExclude */
  (APTR)&height_prop_1,   /* SpecialInfo */
  HEIGHTGAD,    /* GadgetID         */
  0x10     /* UserData Pointer */
};

/**********************************************************************
 * Image structure for range proportional gadget knob.
 **********************************************************************/

struct Image range_knobim;

/**********************************************************************
 *  IntuiTexts for the range_energy gadget.
 **********************************************************************/

struct IntuiText range_Text_0 = {
   1, 0,     /* FrontPen, BackPen */
   JAM2,       /* DrawMode */
   0, 13,     /* LeftEdge, TopEdge */
   &TxtAt_Plain, /* ITextFont Pointer */ 
   /* The IText */
   (UBYTE *)"Distance (in miles)",
   NULL
 };

/**********************************************************************
 * Proportional gadget info for the range_energy gadget.
 **********************************************************************/

struct PropInfo range_prop_2 = {
   /* Flags                     */
   AUTOKNOB | FREEHORIZ,
  0x0000, 0x0000,   /* HorizPot, VertPot     */
  0x028F, 0x1000,   /* HorizBody, VertBody   */
   200,   12,   /* CWidth, CHeight       */
  0x1111, 0x1111,   /* HPotRes, VPotRes      */
     4,    2    /* LeftBorder, TopBorder */
};

/**********************************************************************
 *  Gadget Structure definition for the thermal_energy gadget.
 **********************************************************************/

struct Gadget range = {
 &height,     /* NextGadget pointer */
  380, 20,    /* LeftEdge, TopEdge  */
  200, 12,    /* Width, Height      */
  /* Gadget Flags */
   NULL,
  /* Activation Flags */
 GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,
  /* GadgetType */
  PROPGADGET,
  (APTR)&range_knobim,    /*  GadgetRender */
  NULL,    /* SelectRender */
   &range_Text_0,  /* GadgetText */
  0x0,    /* MutualExclude */
  (APTR)&range_prop_2,   /* SpecialInfo */
  RANGEGAD,    /* GadgetID         */
  0x10     /* UserData Pointer */
};

/**********************************************************************
 * Image structure for transmission proportional gadget knob.
 **********************************************************************/

struct Image transmission_knobim;

/**********************************************************************
 *  IntuiTexts for the transmission gadget.
 **********************************************************************/

struct IntuiText transmission_Text_0 = {
   1, 0,     /* FrontPen, BackPen */
   JAM2,       /* DrawMode */
   0, 13,     /* LeftEdge, TopEdge */
   &TxtAt_Plain, /* ITextFont Pointer */ 
   /* The IText */
   (UBYTE *)"Transmission Factor",
   NULL
 };

/**********************************************************************
 * Proportional gadget info for the transmission gadget.
 **********************************************************************/

struct PropInfo transmission_prop_3 = {
   /* Flags                     */
   AUTOKNOB | FREEHORIZ,
  0x0000, 0x0000,   /* HorizPot, VertPot     */
  0x0CCC, 0x1000,   /* HorizBody, VertBody   */
   200,   12,   /* CWidth, CHeight       */
  0x1111, 0x1111,   /* HPotRes, VPotRes      */
     4,    2    /* LeftBorder, TopBorder */
};

/**********************************************************************
 *  Gadget Structure definition for the transmission gadget.
 **********************************************************************/

struct Gadget transmission = {
  &range,     /* NextGadget pointer */
  60, 68,    /* LeftEdge, TopEdge  */
  200, 12,    /* Width, Height      */
  /* Gadget Flags */
   NULL,
  /* Activation Flags */
 GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,
  /* GadgetType */
  PROPGADGET,
  (APTR)&transmission_knobim,    /*  GadgetRender */
  NULL,    /* SelectRender */
   &transmission_Text_0,  /* GadgetText */
  0x0,    /* MutualExclude */
  (APTR)&transmission_prop_3,   /* SpecialInfo */
  TRANSMISSIONGAD,    /* GadgetID         */
  0x10     /* UserData Pointer */
};

/**********************************************************************
 * Image structure for thermal_energy proportional gadget knob.
 **********************************************************************/

struct Image thermal_energy_knobim;

/**********************************************************************
 *  IntuiTexts for the thermal_energy gadget.
 **********************************************************************/

struct IntuiText thermal_energy_Text_0 = {
   1, 0,     /* FrontPen, BackPen */
   JAM2,       /* DrawMode */
   0, 13,     /* LeftEdge, TopEdge */
   &TxtAt_Plain, /* ITextFont Pointer */ 
   /* The IText */
   (UBYTE *)"Thermal Energy Fraction",
   NULL
 };

/**********************************************************************
 * Proportional gadget info for the thermal_energy gadget.
 **********************************************************************/

struct PropInfo thermal_energy_prop_4 = {
   /* Flags                     */
   AUTOKNOB | FREEHORIZ,
  0x0000, 0x0000,   /* HorizPot, VertPot     */
  0x0CCC, 0x1000,   /* HorizBody, VertBody   */
   200,   12,   /* CWidth, CHeight       */
  0x1111, 0x1111,   /* HPotRes, VPotRes      */
     4,    2    /* LeftBorder, TopBorder */
};

/**********************************************************************
 *  Gadget Structure definition for the thermal_energy gadget.
 **********************************************************************/

struct Gadget thermal_energy = {
 &transmission,     /* NextGadget pointer */
  60, 44,    /* LeftEdge, TopEdge  */
  200, 12,    /* Width, Height      */
  /* Gadget Flags */
   NULL,
  /* Activation Flags */
 GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,
  /* GadgetType */
  PROPGADGET,
  (APTR)&thermal_energy_knobim,    /*  GadgetRender */
  NULL,    /* SelectRender */
   &thermal_energy_Text_0,  /* GadgetText */
  0x0,    /* MutualExclude */
  (APTR)&thermal_energy_prop_4,   /* SpecialInfo */
  THERMAL_ENERGYGAD,    /* GadgetID         */
  0x10     /* UserData Pointer */
};

/**********************************************************************
 * Image structure for megatons proportional gadget knob.
 **********************************************************************/

struct Image megatons_knobim;

/**********************************************************************
 *  IntuiTexts for the megatons gadget.
 **********************************************************************/

struct IntuiText megatons_Text_0 = {
   1, 0,     /* FrontPen, BackPen */
   JAM2,       /* DrawMode */
   0, 13,     /* LeftEdge, TopEdge */
   &TxtAt_Plain, /* ITextFont Pointer */ 
   /* The IText */
   (UBYTE *)"Weapon Yield",
   NULL
 };

/**********************************************************************
 * Proportional gadget info for the megatons gadget.
 **********************************************************************/

struct PropInfo megatons_prop_5 = {
   /* Flags                     */
   AUTOKNOB | FREEHORIZ,
  0x0000, 0x0000,   /* HorizPot, VertPot     */
  0x0333, 0x1000,   /* HorizBody, VertBody   */
   200,   12,   /* CWidth, CHeight       */
  0x1111, 0x1111,   /* HPotRes, VPotRes      */
     4,    2    /* LeftBorder, TopBorder */
};

/**********************************************************************
 *  Gadget Structure definition for the megatons gadget.
 **********************************************************************/

struct Gadget megatons = {
 &thermal_energy,     /* NextGadget pointer */
  60, 20,    /* LeftEdge, TopEdge  */
  200, 12,    /* Width, Height      */
  /* Gadget Flags */
   NULL,
  /* Activation Flags */
 GADGIMMEDIATE | RELVERIFY | FOLLOWMOUSE,
  /* GadgetType */
  PROPGADGET,
  (APTR)&megatons_knobim,    /*  GadgetRender */
  NULL,    /* SelectRender */
   &megatons_Text_0,  /* GadgetText */
  0x0,    /* MutualExclude */
  (APTR)&megatons_prop_5,   /* SpecialInfo */
  MEGATONSGAD,    /* GadgetID         */
  0x10     /* UserData Pointer */
};

/* End of things for gadgets */

main()
{
   struct NewWindow NewWindow;
   struct Window *Window, *OpenWindow();
   struct RastPort *RP;
   struct IntuiMessage *GetMsg();
   struct Gadget *igad;

   float H, D, TAU, TEF, Y;
   double Q, Z, P, EMP, REMS, jnk1, jnk2, jnk3;
   ULONG class;
   USHORT gadgid;
   USHORT casetest;
   APTR address;
   void *Move();
   long *Text();
   char txt[20];

  /* Open the libraries.    */

   void *OpenLibrary(); 

   IntuitionBase = (struct IntuitionBase *)
      OpenLibrary("intuition.library",INTUITION_REV);
   if(IntuitionBase == NULL)
      {
      Cleanup();
      exit(FALSE);
      }

   GfxBase = (struct GfxBase *) OpenLibrary("graphics.library",GRAPHICS_REV);
   if(GfxBase == NULL)
      {
      Cleanup();
      exit(FALSE);
      }

   ExecBase = (struct ExecBase *) OpenLibrary("exec.library",EXEC_REV);
   if(ExecBase == NULL)
      {
      Cleanup();
      exit(FALSE);
      }

   MathBase = (struct MathBase *) OpenLibrary("mathffp.library",MATH_REV);
   if(MathBase == NULL)
      {
      Cleanup();
      exit(FALSE);
      }

   /* Initialize the NewWindow structure for the call to OpenWindow() */

   NewWindow.LeftEdge = 0;
   NewWindow.TopEdge = 11;
   NewWindow.Width = 640;
   NewWindow.Height = 189;
   NewWindow.DetailPen = 0;
   NewWindow.BlockPen = 1;
   NewWindow.Title = (UBYTE *)" Nuclear Weapon Effects Simulator! ";
   NewWindow.Flags = WINDOWCLOSE | SMART_REFRESH | ACTIVATE | WINDOWDEPTH
                     | NOCAREREFRESH;
   NewWindow.IDCMPFlags = CLOSEWINDOW | GADGETDOWN | GADGETUP | MOUSEMOVE;
   NewWindow.Type = WBENCHSCREEN;
   NewWindow.FirstGadget = &megatons;
   NewWindow.CheckMark = NULL;
   NewWindow.Screen = NULL;
   NewWindow.BitMap = NULL;
   NewWindow.MinWidth = 640;
   NewWindow.MinHeight = 189;
   NewWindow.MaxWidth = 640;
   NewWindow.MaxHeight = 189;

   /* Try to open the window. */

   if(( Window = (struct Window *) OpenWindow(&NewWindow)) == NULL)
      {
      Cleanup();
      exit(FALSE);
      }

/* Set the first Numbers */
H = 0L;
D = 0L;
TAU = 0L;
TEF = 0L;
Y = 0L;

/* Print the first Numbers */
RP = Window->RPort;
SetAPen(RP,3L);
SetDrMd(RP,JAM2);

Move(RP,10L,30L);
Text(RP,"0.00",4L);

Move(RP,10L,54L);
Text(RP,"0.00",4L);

Move(RP,10L,78L);
Text(RP,"0.00",4L);

Move(RP,359L,30L);
Text(RP,"0",1L);

Move(RP,359L,54L);
Text(RP,"0",1L);

for(;;)
{
   if(( message = (struct IntuiMessage *) GetMsg(Window->UserPort)) == 0L)
   {
     Wait(1L << Window->UserPort->mp_SigBit);
	continue;
   }

   class = message->Class;
   igad = (struct Gadget *) message->IAddress;
   gadgid = igad->GadgetID;
   ReplyMsg(message);

   switch (class)
   {
     case CLOSEWINDOW :
        while (message =(struct IntuiMessage *)
		GetMsg(Window->UserPort))
		ReplyMsg(message);
	CloseWindow(Window);
	Cleanup();
	exit(TRUE);
	break;

     case GADGETDOWN :	
	
	switch (gadgid)
	{
		case BOOMGAD :
			SetAPen(RP,1L);
			SetDrMd(RP,JAM2);

		/* Set Mins */
		if(D == 0)
		D = .001;
		else
		D = D;

		if(H == 0)
		H = .001;
		else
		H = H;
		
		if(Y == 0)
		{
			Move(RP,380L,90L);
			Text(RP,"What luck, a DUD!", 17L);
			SetAPen(RP,3L);
			SetDrMd(RP,JAM2);
			break;
		}
		else
		{
			Move(RP,380L,90L);
			Text(RP,"                 ", 17L);
		}

		/* Thermal Flux */
			Q = 3000 * (TEF/20) * (TAU/20) * (Y/4) / (D * D);
Move(RP,20L,100L);
if(Q < 10L)
  if(Q < 5L)
     if(Q < 1L)
     	Text(RP,"Thermal flux has added to your tan.             ", 48L);
     else
     	Text(RP,"Thermal flux has caused you second degree burns.", 48L);
  else
        Text(RP,"Thermal flux had caused you third degree burns. ", 48L);
else
        Text(RP,"Thermal flux has burned you to a crisp.         ", 48L);

		/* Blast Overpressure */
			Z = (pow((double)(Y/4),(double)(.333))) / D;
			jnk1 = 22.4 * (pow((double)Z,(double)3));
			jnk2 = 15.8 * (pow((double)Z,(double)(1.5)));
			P = jnk1 + jnk2;
Move(RP,30L,110L);
if(P < 20L)
  if(P < 10L)
    if(P < 5L)
      if(P < 2L)
         {
	 Text(RP,"OverPressure has not had a significant effect on wind", 53L);
	 Move(RP,30L,120L);
	 Text(RP,"conditions or the structures of buildings.           ", 53L);
	 Move(RP,30L,130L);
	 Text(RP,"                                                     ", 53L);
	 }
      else
         {
         Text(RP,"OverPressure has caused winds in excess of           ", 53L);
	 Move(RP,30L,120L);
	 Text(RP,"70 miles per hour.                                   ", 53L);
	 Move(RP,30L,130L);
	 Text(RP,"                                                     ", 53L);
	 }
    else
       {
         Text(RP,"OverPressure has caused winds in excess of           ", 53L);
	 Move(RP,30L,120L);
	 Text(RP,"160 miles per hour.  Unreinforced brick and          ", 53L);
	 Move(RP,30L,130L);
	 Text(RP,"wood houses are leveled.                             ", 53L);
       }
  else
     {
         Text(RP,"OverPressure has caused winds in excess of 300 miles ", 53L);
	 Move(RP,30L,120L);
	 Text(RP,"per hour.  Most factories and commercial buildings   ", 53L);
	 Move(RP,30L,130L);
	 Text(RP,"are leveled, as are small wood and brick residences. ", 53L);
       
     }
else
   {
         Text(RP,"OverPressure has caused winds in excess of 500 miles ", 53L);
	 Move(RP,30L,120L);
	 Text(RP,"per hour.  Even multi-story reinforced concrete      ", 53L);
	 Move(RP,30L,130L);
	 Text(RP,"buildings are leveled.                               ", 53L);
       
   }

		/* EMP Range */
			jnk1 = (H*3963)/5280;
			jnk2 = 2*1000;
			jnk3 = (jnk1*jnk2);
			EMP = sqrt((double)jnk3);
Move(RP,50L,180L);
if(D > EMP)
  Text(RP,"You are outside the range of the Electromagnetic pulse.", 55L);
else
  Text(RP,"You are inside the range of the Electromagnetic pulse. ", 55L);
		/* Radiation Dosage */
			jnk1 = 250 * 100;
			jnk2 = 16 * 3.1416 * D * D;
			jnk3 = ((jnk1 / jnk2) * (Y/4)) * 10;
			REMS = jnk3;
Move(RP,40L,140L);
if(REMS < 5000L)
  if(REMS < 1000L)
    if(REMS < 600L)
      if(REMS < 200L)
        if(REMS < 100L)
         {
	 Text(RP,"You have survived radiation exposure with NO effects.", 53L);
	 Move(RP,40L,150L);
	 Text(RP,"                                                     ", 53L);
	 Move(RP,40L,160L);
	 Text(RP,"                                                     ", 53L);
	 Move(RP,40L,170L);
	 Text(RP,"                                                     ", 53L);
	 }
        else
	 {
         Text(RP,"Radiation exposure had made you sick--vomiting,      ", 53L);
	 Move(RP,40L,150L);
	 Text(RP,"headache, some loss of white blood cells and         ", 53L);
	 Move(RP,40L,160L);
	 Text(RP,"dizziness. This is good. You will completely recover.", 53L);
	 Move(RP,40L,170L);
	 Text(RP,"                                                     ", 53L);
	 }
      else
         {
         Text(RP,"Your symptoms range from leukopenia to hair loss     ", 53L);
	 Move(RP,40L,150L);
	 Text(RP,"because of radiation exposure.  Hospitalization is   ", 53L);
	 Move(RP,40L,160L);
	 Text(RP,"required and is available to you because you have a  ", 53L);
	 Move(RP,40L,170L);
	 Text(RP,"reasonable chance to live.                           ", 53L);
	 }
    else
       {
         Text(RP,"You have very severe leukopenia and internal         ", 53L);
	 Move(RP,40L,150L);
	 Text(RP,"bleeding. Ulcers and infection is likely because of  ", 53L);
	 Move(RP,40L,160L);
	 Text(RP,"radiation exposure. You need hospitalization but none", 53L);
	 Move(RP,40L,170L);
	 Text(RP,"is available, you have less than a month to live.    ", 53L);
       }
  else
     {
         Text(RP,"You have diarrhea, fever and disturbance of you body ", 53L);
	 Move(RP,40L,150L);
	 Text(RP,"chemistry because of radiation exposure.  Treatment  ", 53L);
	 Move(RP,40L,160L);
	 Text(RP,"my alleviate pain, but it will not save your life.   ", 53L);
         Move(RP,40L,170L);
	 Text(RP,"You have less that two weeks to live.                ", 53L);
     }
else
   {
         Text(RP,"You are experiencing convulsions, Tremors and ataxia ", 53L);
	 Move(RP,40L,150L);
	 Text(RP,"because of radiation exposure.                       ", 53L);
	 Move(RP,40L,160L);
	 Text(RP,"No treatment will help you.                          ", 53L);
	 Move(RP,40L,170L);
	 Text(RP,"                                                     ", 53L);
   }
		SetAPen(RP,3L);
		SetDrMd(RP,JAM2);

		break;
		
		case HEIGHTGAD :
			casetest = gadgid;
			H = (heights(0));
			sprintf(txt, "%6.0f", (H*1000L));
			Move(RP, 319L, 54L);
			Text(RP, txt, 6L);
		break;
			
		case RANGEGAD :
			casetest = gadgid;
			D = (ranges(0));
			sprintf(txt, "%3.0f", D);
			Move(RP, 343L, 30L);
			Text(RP, txt, 3L);
	
		break;

		case TRANSMISSIONGAD :
			casetest = gadgid;
			TAU = (trans(0));
			sprintf(txt, "%3.3f", (TAU/20L));
			Move(RP, 10L, 78L);
			Text(RP, txt, 4L);
	
		break;

		case THERMAL_ENERGYGAD :
			casetest = gadgid;
			TEF = (thermal(0));
			sprintf(txt, "%3.3f", (TEF/20L));
			Move(RP, 10L, 54L);
			Text(RP, txt, 4L);
	
		break;

		case MEGATONSGAD :
			casetest = gadgid;
			Y = (megs(0));
			sprintf(txt, "%3.3f", (Y/4L));
			Move(RP, 10L, 30L);
			Text(RP, txt, 5L);
	
		break;
	}/* End of SWITCH (gadgid) */
	
	break;
     
     case MOUSEMOVE :
     	switch (casetest)
	{
		case HEIGHTGAD :
			H = (heights(0));
			sprintf(txt, "%6.0f", (H*1000L));
			Move(RP, 320L, 54L);
			Text(RP, txt, 6L);
	
		break;
			
		case RANGEGAD :
			D = (ranges(0));
			sprintf(txt, "%3.0f", D);
			Move(RP, 342L, 30L);
			Text(RP, txt, 3L);
	
		break;

		case TRANSMISSIONGAD :
			TAU = (trans(0));
			sprintf(txt, "%3.3f", (TAU/20L));
			Move(RP, 10L, 78L);
			Text(RP, txt, 4L);
	
		break;

		case THERMAL_ENERGYGAD :
			TEF = (thermal(0));
			sprintf(txt, "%3.3f", (TEF/20L));
			Move(RP, 10L, 54L);
			Text(RP, txt, 4L);
	
		break;

		case MEGATONSGAD :
			Y = (megs(0));
			sprintf(txt, "%3.3f", (Y/4L));
			Move(RP, 10L, 30L);
			Text(RP, txt, 5L);
	
		break;

	}/* End of SWITCH (casetest) */
   }/* End of SWITCH (class)*/
}/* End of FOR */
}/* End of MAIN */


Cleanup()
{
	if (MathBase) CloseLibrary(MathBase);
	if (ExecBase) CloseLibrary(ExecBase);
	if (GfxBase) CloseLibrary(GfxBase);
	if (IntuitionBase) CloseLibrary(IntuitionBase);
}/* End of Cleanup() */


megs()
{
float Y;
	Y = (megatons_prop_5.HorizPot / 0x0333);
	return Y;
}


thermal()
{
float TEF;
	TEF = (thermal_energy_prop_4.HorizPot / 0x0CCC);
	return TEF;
}


trans()
{
float TAU;
	TAU = (transmission_prop_3.HorizPot / 0x0CCC);
	return TAU;
}


ranges()
{
float D;
	D = (range_prop_2.HorizPot / 0x028F);
	return D;
}


heights()
{
float H;
	H = (height_prop_1.HorizPot / 0x028F);
	return H;
}
