     with ConsAKD; use ConsAKD;
     with InteAKD; use InteAKD;
     with FloaAKD; use FloaAKD;
     with MathAKD; use MathAKD;
     with SounAKD;
     with TextAKD; use TextAKD;
     with TTY;

     procedure HyperSoma is
     ----------------------------------------------------------------------
     ----------------------------------------------------------------------
       T         :  float   :=   0.5;
       Spike     :  float   := 100.0;
       dt        :  float   :=   0.001;
       V         :  float   :=   0.0;
       I         :  float   :=   0.0;
       I_Div     :  float   :=  10.0;
       I_Dec     :  float   :=   1.0;
       Deci      :  natural :=   6;
       dI_dt     :  float;
       dV_dt     :  float;
       Key       :  character;
     begin
       loop
	 Put_Line (
	   "HyperSoma (C) 1994 David W. Croft.  All rights reserved." );
	 New_Line;
	 Put_Line ( "Press 0 to pause or halt the simulation." );
	 Put_Line ( "Press 1 to 9 to inject current." );
	 New_Line;
	 I     := Ask     ( "Initial Injected Current :  ", I        );
	 V     := Ask     ( "Initial Membrane Voltage :  ", V        );
	 T     := Ask     ( "Threshold                :  ", T        );
	 Spike := Ask     ( "Hyperpolarization Level  :  ", Spike, T );
	 dt    := Ask     ( "Time Step                :  ", dt       );
	 I_Div := Ask     ( "Current Divider          :  ", I_Div    );
	 I_Dec := Ask     ( "Current Decay            :  ", I_Dec    );
	 Deci  := Ask_Nat ( "Decimal Places           :  ", Deci     );
	 dV_dt := Ask     ( "Voltage Velocity         :  ", dV_dt    );
	 loop
	   dV_dt := I + V * ( V - T );
	   V := V + dV_dt * dt;
	   dI_dt := -I * I_Dec;
	   I := I + dI_dt * dt;
	   if V >= Spike then
	     V := -Spike;
	     SounAKD.Speaker_Thump;
	   end if;
	   if TTY.Char_Ready then
	     Key := TTY.Get ( No_Echo => true );
	     exit when Key = '0';
	     I := I + float ( character'pos ( Key ) - 48 ) / I_Div;
	   end if;
	   begin
	     Put ( I      , 2, Deci, 0 ); Put ( "  " );
	     Put ( V      , 2, Deci, 0 ); Put ( "  " );
	     Put ( dV_dt  , 2, Deci, 0 ); Put ( "  " );
	     New_Line;
	   exception
	     when Layout_Error =>
	       Put (       I, 2, Deci, 4 ); Put ( "  " );
	       Put (       V, 2, Deci, 4 ); Put ( "  " );
	       Put ( dV_dt  , 2, Deci, 4 ); Put ( "  " );
	       New_Line;
	     when others =>
	       raise;
	   end;
	 end loop;
	 exit when not Ask_Bool ( "Continue? ", true );
       end loop;
     exception
       when others =>
	 Pause (
	   "An error has been detected.  Please press ENTER to exit..." );
	 raise;
     end HyperSoma;
