     with ConsAKD; use ConsAKD;
     with CursAKD;
     with InteAKD; use InteAKD;
     with FloaAKD; use FloaAKD;
     with HyperMus; use HyperMus;
     with HyperNet; use HyperNet;
     with MathAKD; use MathAKD;
--   with SounAKD; use SounAKD;
     with TextAKD; use TextAKD;
     with TTY    ;

     package body HyperDis is
     ----------------------------------------------------------------------
     ----------------------------------------------------------------------

     procedure Axons_Display (
       Axons    : in     Axons_Type;
       N_Last   : in     natural;
       Deci     : in     positive;
       Segments : in     positive ) is
     ----------------------------------------------------------------------
     begin
       for Segment in 1..Segments loop
	 for Axon in 0..N_Last loop
	   if Axon > 0 then
	     Put ( ' ' );
	   end if;
	   Put ( Axons ( Axon ) ( Segment ), 2, 1, 2 );
	 end loop;
	 New_Line;
       end loop;
     end Axons_Display;

     procedure Neurons_Display (
       Neurons : in     Neurons_Type;
       N_Last  : in     natural;
       Deci    : in     positive ) is
     ----------------------------------------------------------------------
     begin
       for Neuron in 0..N_Last loop
	 if Neuron > 0 then
	   Put ( ' ' );
	 end if;
	 Put ( Neurons ( Neuron ).Nt, 2, Deci - 4, 3 );
       end loop;
       New_Line;
       for Neuron in 0..N_Last loop
	 if Neuron > 0 then
	   Put ( ' ' );
	 end if;
	 Put ( -Neurons ( Neuron ).Im, 2, Deci - 4, 3 );
       end loop;
       New_Line;
       for Neuron in 0..N_Last loop
	 if Neuron > 0 then
	   Put ( ' ' );
	 end if;
	 Put ( Neurons ( Neuron ).Vm, 2, Deci - 4, 3 );
       end loop;
       New_Line;
       for Neuron in 0..N_Last loop
	 if Neuron > 0 then
	   Put ( ' ' );
	 end if;
	 Put ( Neurons ( Neuron ).Error, 2, Deci - 4, 3 );
       end loop;
       New_Line;
       for Neuron in 0..N_Last loop
	 if Neuron > 0 then
	   Put ( ' ' );
	 end if;
	 Put ( Neurons ( Neuron ).V_Avg, 2, Deci - 4, 3 );
       end loop;
     end Neurons_Display;

     procedure Options_Setup (
       Opt     : in out Options_Type;
       Axons   : in out Axons_Type;
       Neurons : in out Neurons_Type;
       Weights : in out Weights_Type ) is
     ----------------------------------------------------------------------
     begin
       loop
	 Clear_Screen;
	 Put_Line ( Copyright );
	 New_Line;
	 Put_Line ( " 0:  Quit" );
	 Put_Line ( " 1:  Play" );
	 Put ( " 2:  Delay (" ); Put ( Opt.Screen_Delay, 1, Opt.Deci, 4 ); Put_Line ( ")" );
	 Put ( " 3:  Time Step (" ); Put ( Opt.dt, 1, Opt.Deci, 4 );  Put_Line ( ")" );
	 Put ( " 4:  Time Lag (" ); Put ( Opt.Time_Lag, 1, Opt.Deci, 4 ); Put_Line ( ")" );
	 Put ( " 5:  Neuron Last (" ); Put ( integer'image ( Opt.N_Last ) ); Put_Line ( ")" );
	 Put ( " 6:  Threshold (" ); Put ( Opt.Threshold, 1, Opt.Deci, 4 ); Put_Line ( ")" );
	 Put ( " 7:  Spike (" ); Put ( Opt.Spike, 1, Opt.Deci, 4 ); Put_Line ( ")" );
	 Put ( " 8:  Time Peak (" ); Put ( Opt.Time_Peak, 1, Opt.Deci, 4 ); Put_Line ( ")" );
	 Put ( " 9:  Wgt Shu (" ); Put ( Opt.Wgt_Shu ); Put_Line ( ")" );
	 Put ( "10:  Refresh Rate (" ); Put ( Opt.Refresh_Rate ); Put_Line ( ")" );
	 Put ( "11:  Tones On (" ); Put ( Opt.Tones_On ); Put_Line ( ")" );
	 Put ( "12:  Max. Weight (" ); Put ( Opt.W_Max, 1, Opt.Deci, 4 ); Put_Line ( ")" );
	 Put_Line ( "13:  Re-initialize neuron voltages and currents" );
	 Put_Line ( "14:  Re-initialize weights" );
	 Put ( "15:  G Leak (" ); Put ( Opt.G_Leak, 1, Opt.Deci, 4 ); Put_Line ( ")" );
--       Put ( "16:  Nt max (" ); Put ( Opt.Nt_Max, 1, Opt.Deci, 4 ); Put_Line ( ")" );
	 Put ( "17:  Learn Rate (" ); Put ( Opt.Learn_Rate, 1, Opt.Deci, 4 ); Put_Line ( ")" );
	 Put ( "18:  Auto Rate (" ); Put ( Opt.Auto_Rate ); Put_Line ( ")" );
--         Put_Line ( "15:  Save your current weights to disk" );
--         Put_Line ( "16:  Load weights from disk" );
--         Put_Line ( "17:  Save network states and weights to disk" );
--         Put_Line ( "18:  Load network states and weights from disk" );
	 Put ( "19:  Training On (" ); Put ( boolean'image ( Opt.Training_On ) ); Put_Line ( ")" );
	 Put_Line ( "20:  Set training music" );
	 New_Line;
	 case Ask_Nat ( "Option? ", 1, 0, 20 ) is
	   when  0 =>
	     Opt.Quit := true;
	     exit;
	   when  1 => exit;
	   when  2 =>
	     Opt.Screen_Delay
	       := Ask ( "Screen Delay: ", Opt.Screen_Delay );
	   when  3 =>
	     Opt.dt := Ask ( "Time Step   : ", Opt.dt );
	     Opt.Time_Lag := Ask  ( "Time_Lag    : ", Opt.Time_Lag,
	       Opt.dt, Opt.dt * float ( Segments_Max ) );
	   when  4 =>
	     Opt.Time_Lag := Ask  ( "Time_Lag    : ", Opt.Time_Lag,
	       Opt.dt, Opt.dt * float ( Segments_Max ) );
	   when  5 =>
	     Opt.N_Last := Ask_Nat  (
	       "Neuron Last: ", Opt.N_Last, 0, Neuron_Max );
	     Opt.Deci := 80 / ( Opt.N_Last + 1 ) - 4;
	     if Opt.Deci > 14 then
	       Opt.Deci := 14;
	     end if;
	   when  6 => Opt.Threshold
	     := Ask      ( "Threshold   : ", Opt.Threshold    );
	   when  7 => Opt.Spike
	     := Ask      ( "Spike       : ", Opt.Spike, Opt.Threshold );
	   when  8 =>
	     Opt.Time_Peak := Ask ( "Time_Peak: ", Opt.Time_Peak, 0.0 );
	   when  9 =>
	     Opt.Wgt_Shu := not Opt.Wgt_Shu;
	   when 10 => Opt.Refresh_Rate
	     := Ask_Nat ( "Refresh Rate (0 = Off): ", Opt.Refresh_Rate );
	   when 11 => Opt.Tones_On := not Opt.Tones_On;
	   when 12 => Opt.W_Max
	     := Ask      ( "Weight Max. : ", Opt.W_Max        );
	   when 13 =>
	     Reset ( Axons, Neurons, Weights );
	   when 14 =>
	     Weights := ( others => ( others => Weight_Def ) );
	   when 15 =>
	     Opt.G_Leak := Ask ( "G Leak: ", Opt.G_Leak, 0.0 );
--         when 16 =>
--           Opt.Nt_Max := Ask ( "Nt maximum: ", Opt.Nt_Max, 0.0 );
	   when 17 =>
	     Opt.Learn_Rate := Ask ( "Learn Rate  : ", Opt.Learn_Rate, 0.0 );
	     Opt.Learn_Init := Opt.Learn_Rate;
	   when 18 =>
	     Opt.Auto_Rate := not Opt.Auto_Rate;
	   when 19 =>
	     Opt.Training_On := not Opt.Training_On;
	   when 20 =>
	     Music_Set ( Opt.Music );
	   when others =>
	     Put_Line ( "That option is currently not available." );
	     Pause;
	 end case;
       end loop;
     end Options_Setup;

     procedure Weights_Display (
       Weights : in     Weights_Type;
       N_Last  : in     natural;
       Deci    : in     positive ) is
     ----------------------------------------------------------------------
     begin
       CursAKD.Move ( 2, 0 );
       for Neuron in 0..N_Last loop
	 for Pre_Neuron in 0..N_Last loop
	   if Pre_Neuron > 0 then
	     Put ( ' ' );
	   end if;
	   Put (
--           Weights ( Neuron, Pre_Neuron ).Pre *
	     ( Weights ( Neuron, Pre_Neuron ).Dep
	     - Weights ( Neuron, Pre_Neuron ).Shu ), 2, Deci - 4, 3 );
	 end loop;
	 New_Line;
       end loop;
--     New_Line;
--     for Neuron in 0..N_Last loop
--       for Pre_Neuron in 0..N_Last loop
--         if Pre_Neuron > 0 then
--           Put ( ' ' );
--         end if;
--         Put ( Weights ( Neuron, Pre_Neuron ).Pre, 2, Deci - 4, 3 );
--       end loop;
--       New_Line;
--     end loop;
     end Weights_Display;

     ----------------------------------------------------------------------
     ----------------------------------------------------------------------
     end HyperDis;
