home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / virterm / curses.src < prev    next >
Encoding:
Text File  |  1988-05-03  |  24.2 KB  |  748 lines

  1. ::::::::::
  2. curses.a
  3. ::::::::::
  4. -------- SIMTEL20 Ada Software Repository Prologue ------------
  5. --                                                           -*
  6. -- Unit name    : curses interface package specification
  7. -- Version      : 1.0
  8. -- Author       : Steve Rosen
  9. --              : Siemens Research
  10. --              : 
  11. --              : 
  12. -- DDN Address  : vrdxhq!siemens!gypsy!rosen@seismo
  13. -- Copyright    : (c) 
  14. -- Date created :  6 August 1985
  15. -- Release date :  6 August 1985
  16. -- Last update  :  6 August 1985
  17. -- Machine/System Compiled/Run on : VADS VAX/UNIX 4.06
  18. --                                                           -*
  19. ---------------------------------------------------------------
  20. --                                                           -*
  21. -- Keywords     :  display, terminal update, screen
  22. ----------------:
  23. --
  24. -- Abstract     :  This package provides an interface to the UNIX
  25. ----------------:  curses package through Ada.
  26. --                                                           -*
  27. ------------------ Revision history ---------------------------
  28. --                                                           -*
  29. -- DATE         VERSION    AUTHOR                  HISTORY
  30. -- ???        0.0    Steve Rosen        Initial Release
  31. -- 8/6/85    1.0    Karl A. Nyberg        Release to SIMTEL
  32. --                                                           -*
  33. ------------------ Distribution and Copyright -----------------
  34. --                                                           -*
  35. -- This prologue must be included in all copies of this software.
  36. --
  37. -- This software is copyright by the author.
  38. --
  39. -- This software is released to the Ada community.
  40. -- This software is released to the Public Domain (note:
  41. --   software released to the Public Domain is not subject
  42. --   to copyright protection).
  43. -- Restrictions on use or distribution:  NONE
  44. --                                                           -*
  45. ------------------ Disclaimer ---------------------------------
  46. --                                                           -*
  47. -- This software and its documentation are provided "AS IS" and
  48. -- without any expressed or implied warranties whatsoever.
  49. -- No warranties as to performance, merchantability, or fitness
  50. -- for a particular purpose exist.
  51. --
  52. -- Because of the diversity of conditions and hardware under
  53. -- which this software may be used, no warranty of fitness for
  54. -- a particular purpose is offered.  The user is advised to
  55. -- test the software thoroughly before relying on it.  The user
  56. -- must assume the entire risk and liability of using this
  57. -- software.
  58. --
  59. -- In no event shall any person or organization of people be
  60. -- held responsible for any direct, indirect, consequential
  61. -- or inconsequential damages or lost profits.
  62. --                                                           -*
  63. -------------------END-PROLOGUE--------------------------------
  64.  
  65. with SYSTEM;
  66. with U_ENV;       -- This package requires the elaboration of U_ENV
  67.  
  68. package CURSES is
  69.  
  70.   UNDEFINED_WINDOW_ERROR: exception;
  71.  
  72.   type WINDOW is new SYSTEM.ADDRESS;
  73.   STDSCR: WINDOW;
  74.  
  75.   LINES:    constant POSITIVE := 23;
  76.   COLUMNS:  constant POSITIVE := 80;
  77.  
  78.   function INITSCR return WINDOW;
  79.   procedure DELWIN (WIN: WINDOW);
  80.   procedure ENDWIN;
  81.   
  82.   function NEWWIN (LINES, COLS, BEGIN_Y, BEGIN_X: INTEGER) return WINDOW;
  83.   function SUBWIN (WIN: WINDOW;
  84.            LINES, COLS, BEGIN_X, BEGIN_Y: INTEGER) return WINDOW;
  85.  
  86.   procedure MVWIN (WIN: WINDOW; Y, X: INTEGER);
  87.  
  88.   procedure ADDCH  (CH: CHARACTER);
  89.   procedure WADDCH (WIN: WINDOW; CH: CHARACTER);
  90.  
  91.   procedure ADDSTR  (S: STRING);
  92.   procedure WADDSTR (WIN: WINDOW; S: STRING);
  93.  
  94.   procedure BOX (WIN: WINDOW; VERTICAL:   CHARACTER := '|';
  95.                   HORIZONTAL: CHARACTER := '-');
  96.  
  97.   procedure CLEAR;
  98.   procedure WCLEAR(WIN: WINDOW);
  99.  
  100.   procedure CLEAROK (SCR: WINDOW; BOOLF: boolean);
  101.  
  102.   procedure CLRTOBOT;
  103.   procedure WCLRTOBOT (WIN: WINDOW);
  104.  
  105.   procedure CLRTOEOL;
  106.   procedure WCLRTOEOL (WIN: WINDOW);
  107.  
  108.   procedure DELCH;
  109.   procedure WDELCH (WIN: WINDOW);
  110.  
  111.   procedure DELETELN;
  112.   procedure WDELETELN (WIN: WINDOW);
  113.  
  114.   procedure ERASE;
  115.   procedure WERASE (WIN: WINDOW);
  116.  
  117.   procedure INSCH (CH: CHARACTER);
  118.   procedure WINSCH (WIN: WINDOW; CH: CHARACTER);
  119.  
  120.   procedure INSERTLN;
  121.   procedure WINSERTLN (WIN: WINDOW);
  122.  
  123.   procedure MOVE (Y, X: INTEGER);
  124.   procedure WMOVE (WIN: WINDOW; Y, X: INTEGER);
  125.  
  126.   procedure OVERLAY (WIN1, WIN2: WINDOW);
  127.   procedure OVERWRITE (WIN1, WIN2: WINDOW);
  128.  
  129.   procedure REFRESH;
  130.   procedure WREFRESH (WIN: WINDOW);
  131.  
  132.   procedure STANDOUT;
  133.   procedure WSTANDOUT (WIN: WINDOW);
  134.  
  135.   procedure STANDEND;
  136.   procedure WSTANDEND (WIN: WINDOW);
  137.  
  138.   private
  139.  
  140.     pragma INTERFACE (C, INITSCR);
  141.     pragma INTERFACE (C, DELWIN);
  142.     pragma INTERFACE (C, ENDWIN);
  143.     pragma INTERFACE (C, NEWWIN);
  144.     pragma INTERFACE (C, SUBWIN);
  145.     pragma INTERFACE (C, MVWIN);
  146.     pragma INTERFACE (C, WADDCH);
  147.     pragma INTERFACE (C, WADDSTR);
  148.     pragma INTERFACE (C, BOX);
  149.     pragma INTERFACE (C, WCLEAR);
  150.     pragma INTERFACE (C, CLEAROK);
  151.     pragma INTERFACE (C, WCLRTOBOT);
  152.     pragma INTERFACE (C, WCLRTOEOL);
  153.     pragma INTERFACE (C, WDELCH);
  154.     pragma INTERFACE (C, WDELETELN);
  155.     pragma INTERFACE (C, WERASE);
  156.     pragma INTERFACE (C, WINSCH);
  157.     pragma INTERFACE (C, WINSERTLN);
  158.     pragma INTERFACE (C, WMOVE);
  159.     pragma INTERFACE (C, OVERLAY);
  160.     pragma INTERFACE (C, OVERWRITE);
  161.     pragma INTERFACE (C, WREFRESH);
  162.     pragma INTERFACE (C, WSTANDOUT);
  163.     pragma INTERFACE (C, WSTANDEND);
  164.   
  165. end CURSES;
  166. ::::::::::
  167. curses_body.a
  168. ::::::::::
  169. -------- SIMTEL20 Ada Software Repository Prologue ------------
  170. --                                                           -*
  171. -- Unit name    : curses interface package body
  172. -- Version      : 1.0
  173. -- Author       : Steve Rosen
  174. --              : Siemens Research
  175. --              : 
  176. --              : 
  177. -- DDN Address  : vrdxhq!siemens!gypsy!rosen@seismo
  178. -- Copyright    : (c) 
  179. -- Date created :  6 August 1985
  180. -- Release date :  6 August 1985
  181. -- Last update  :  6 August 1985
  182. -- Machine/System Compiled/Run on : VADS VAX/UNIX 4.06
  183. --                                                           -*
  184. ---------------------------------------------------------------
  185. --                                                           -*
  186. -- Keywords     :  display, terminal update, screen
  187. ----------------:
  188. --
  189. -- Abstract     :  This package provides an interface to the UNIX
  190. ----------------:  curses package through Ada.
  191. --                                                           -*
  192. ------------------ Revision history ---------------------------
  193. --                                                           -*
  194. -- DATE         VERSION    AUTHOR                  HISTORY
  195. -- ???        0.0    Steve Rosen        Initial Release
  196. -- 8/6/85    1.0    Karl A. Nyberg        Release to SIMTEL
  197. --                                                           -*
  198. ------------------ Distribution and Copyright -----------------
  199. --                                                           -*
  200. -- This prologue must be included in all copies of this software.
  201. --
  202. -- This software is copyright by the author.
  203. --
  204. -- This software is released to the Ada community.
  205. -- This software is released to the Public Domain (note:
  206. --   software released to the Public Domain is not subject
  207. --   to copyright protection).
  208. -- Restrictions on use or distribution:  NONE
  209. --                                                           -*
  210. ------------------ Disclaimer ---------------------------------
  211. --                                     -*
  212. ------------------ Disclaimer ---------------------------------
  213. --                                                           -*
  214. -- This software and its documentation are provided "AS IS" and
  215. -- without any expressed or implied warranties whatsoever.
  216. -- No warranties as to performance, merchantability, or fitness
  217. -- for a particular purpose exist.
  218. --
  219. -- Because of the diversity of conditions and hardware under
  220. -- which this software may be used, no warranty of fitness for
  221. -- a particular purpose is offered.  The user is advised to
  222. -- test the software thoroughly before relying on it.  The user
  223. -- must assume the entire risk and liability of using this
  224. -- software.
  225. --
  226. -- In no event shall any person or organization of people be
  227. -- held responsible for any direct, indirect, consequential
  228. -- or inconsequential damages or lost profits.
  229. --                                                           -*
  230. -------------------END-PROLOGUE--------------------------------
  231.  
  232. package body CURSES is
  233.   
  234.   procedure ADDCH  (CH: CHARACTER) is
  235.   begin
  236.     if (STDSCR = WINDOW(0)) then
  237.       raise UNDEFINED_WINDOW_ERROR;
  238.     else
  239.       WADDCH (STDSCR, CH);
  240.     end if;
  241.   end ADDCH;
  242.  
  243.   procedure ADDSTR  (S: STRING) is
  244.   begin
  245.     if (STDSCR = WINDOW(0)) then
  246.       raise UNDEFINED_WINDOW_ERROR;
  247.     else
  248.       WADDSTR (STDSCR, S);
  249.     end if;
  250.   end ADDSTR;
  251.  
  252.   procedure CLEAR is
  253.   begin
  254.     if (STDSCR = WINDOW(0)) then
  255.       raise UNDEFINED_WINDOW_ERROR;
  256.     else
  257.       WCLEAR (STDSCR);
  258.     end if;
  259.   end CLEAR;
  260.  
  261.   procedure CLRTOBOT is
  262.   begin
  263.     if (STDSCR = WINDOW(0)) then
  264.       raise UNDEFINED_WINDOW_ERROR;
  265.     else
  266.       WCLRTOBOT (STDSCR);
  267.     end if;
  268.   end CLRTOBOT;
  269.  
  270.   procedure CLRTOEOL is
  271.   begin
  272.     if (STDSCR = WINDOW(0)) then
  273.       raise UNDEFINED_WINDOW_ERROR;
  274.     else
  275.       WCLRTOEOL (STDSCR);
  276.     end if;
  277.   end CLRTOEOL;
  278.  
  279.   procedure DELCH is
  280.   begin
  281.     if (STDSCR = WINDOW(0)) then
  282.       raise UNDEFINED_WINDOW_ERROR;
  283.     else
  284.       WDELCH (STDSCR);
  285.     end if;
  286.   end DELCH;
  287.  
  288.   procedure DELETELN is
  289.   begin
  290.     if (STDSCR = WINDOW(0)) then
  291.       raise UNDEFINED_WINDOW_ERROR;
  292.     else
  293.       WDELETELN (STDSCR);
  294.     end if;
  295.   end DELETELN;
  296.  
  297.   procedure ERASE is
  298.   begin
  299.     if (STDSCR = WINDOW(0)) then
  300.       raise UNDEFINED_WINDOW_ERROR;
  301.     else
  302.       WERASE (STDSCR);
  303.     end if;
  304.   end ERASE;
  305.  
  306.   procedure INSCH (CH: CHARACTER) is
  307.   begin
  308.     if (STDSCR = WINDOW(0)) then
  309.       raise UNDEFINED_WINDOW_ERROR;
  310.     else
  311.       WINSCH (STDSCR, CH);
  312.     end if;
  313.   end INSCH;
  314.  
  315.   procedure INSERTLN is
  316.   begin
  317.     if (STDSCR = WINDOW(0)) then
  318.       raise UNDEFINED_WINDOW_ERROR;
  319.     else
  320.       WINSERTLN (STDSCR);
  321.     end if;
  322.   end INSERTLN;
  323.  
  324.   procedure MOVE (Y, X: INTEGER) is
  325.   begin
  326.     if (STDSCR = WINDOW(0)) then
  327.       raise UNDEFINED_WINDOW_ERROR;
  328.     else
  329.       WMOVE (STDSCR, Y, X);
  330.     end if;
  331.   end MOVE;
  332.  
  333.   procedure REFRESH is
  334.   begin
  335.     if (STDSCR = WINDOW(0)) then
  336.       raise UNDEFINED_WINDOW_ERROR;
  337.     else
  338.       WREFRESH (STDSCR);
  339.     end if;
  340.   end REFRESH;
  341.  
  342.   procedure STANDOUT is
  343.   begin
  344.     if (STDSCR = WINDOW(0)) then
  345.       raise UNDEFINED_WINDOW_ERROR;
  346.     else
  347.       WSTANDOUT (STDSCR);
  348.     end if;
  349.   end STANDOUT;
  350.  
  351.   procedure STANDEND is
  352.   begin
  353.     if (STDSCR = WINDOW(0)) then
  354.       raise UNDEFINED_WINDOW_ERROR;
  355.     else
  356.       WSTANDEND (STDSCR);
  357.     end if;
  358.   end STANDEND;
  359.  
  360. begin
  361.   STDSCR := WINDOW(0);
  362. end CURSES;
  363. ::::::::::
  364. towers_of_hanoi.a
  365. ::::::::::
  366. -------- SIMTEL20 Ada Software Repository Prologue ------------
  367. --                                                           -*
  368. -- Unit name    : package specification for towers_of_hanoi
  369. -- Version      : 1.0
  370. -- Author       : Steve Rosen
  371. --              : Siemens Research
  372. --              : 
  373. --              : 
  374. -- DDN Address  : vrdxhq!siemens!gypsy!rosen@seismo
  375. -- Copyright    : (c) 
  376. -- Date created :  6 August 1985
  377. -- Release date :  6 August 1985
  378. -- Last update  :  6 August 1985
  379. -- Machine/System Compiled/Run on : VADS VAX/UNIX 4.06
  380. --                                                           -*
  381. ---------------------------------------------------------------
  382. --                                                           -*
  383. -- Keywords     :  display, hanoi
  384. ----------------:
  385. --
  386. -- Abstract     :  The package for a terminal-independent version
  387. ----------------:  of the towers of hanoi demo.
  388. --                                                           -*
  389. ------------------ Revision history ---------------------------
  390. --                                                           -*
  391. -- DATE         VERSION    AUTHOR                  HISTORY
  392. -- ???        0.0    Steve Rosen        Initial Release
  393. -- 8/6/85    1.0    Karl A. Nyberg        Release to SIMTEL
  394. --                                                           -*
  395. ------------------ Distribution and Copyright -----------------
  396. --                                                           -*
  397. -- This prologue must be included in all copies of this software.
  398. --
  399. -- This software is copyright by the author.
  400. --
  401. -- This software is released to the Ada community.
  402. -- This software is released to the Public Domain (note:
  403. --   software released to the Public Domain is not subject
  404. --   to copyright protection).
  405. -- Restrictions on use or distribution:  NONE
  406. --                                                           -*
  407. ------------------ Disclaimer ---------------------------------
  408. --                                                           -*
  409. -- This software and its documentation are provided "AS IS" and
  410. -- without any expressed or implied warranties whatsoever.
  411. -- No warranties as to performance, merchantability, or fitness
  412. -- for a particular purpose exist.
  413. --
  414. -- Because of the diversity of conditions and hardware under
  415. -- which this software may be used, no warranty of fitness for
  416. -- a particular purpose is offered.  The user is advised to
  417. -- test the software thoroughly before relying on it.  The user
  418. -- must assume the entire risk and liability of using this
  419. -- software.
  420. --
  421. -- In no event shall any person or organization of people be
  422. -- held responsible for any direct, indirect, consequential
  423. -- or inconsequential damages or lost profits.
  424. --                                                           -*
  425. -------------------END-PROLOGUE--------------------------------
  426.  
  427. -----------------------------------------
  428. --    TOWERS_OF_HANOI Specification    --
  429. -----------------------------------------
  430.  
  431. package TOWERS_OF_HANOI is
  432.  
  433.   MAX_DISCS: NATURAL := 13;
  434.   NO_DISCS: NATURAL := 5;
  435.  
  436.   type MOTION is (SMOOTH, FAST, TELEPORT);
  437.   DISPLAY_TYPE: MOTION := SMOOTH;
  438.  
  439.   type LOCATION is (LEFT, MIDDLE, RIGHT);
  440.  
  441.   COL: array (LOCATION) of NATURAL;
  442.   COUNT: array (LOCATION) of NATURAL;
  443.  
  444.   TOP:   constant NATURAL := MAX_DISCS + 5;
  445.  
  446.   BLANK: constant CHARACTER := ' ';
  447.   DISC:  constant CHARACTER := '=';
  448.  
  449.   procedure INITIAL;
  450.   procedure FINISH (S: STRING);
  451.   procedure DISPLAY (NUMBER: NATURAL);
  452.   procedure HANOI (NUMBER: NATURAL; START, INTER, FINISH: LOCATION);
  453.   procedure MOVE_DISC (NUMBER: NATURAL; START, FINISH: LOCATION);
  454.   procedure SHOW_DISC (NUMBER: NATURAL; START, FINISH: LOCATION);
  455.   procedure MAKE_DISC (NUMBER: NATURAL; PILE: LOCATION);
  456.   procedure RM_DISC (NUMBER: NATURAL; PILE: LOCATION);
  457.   procedure PLOT_DISC (NUMBER, Y, X: NATURAL; C: CHARACTER);
  458.  
  459. end TOWERS_OF_HANOI;
  460. ::::::::::
  461. towers_of_hanoi_body.a
  462. ::::::::::
  463. -------- SIMTEL20 Ada Software Repository Prologue ------------
  464. --                                                           -*
  465. -- Unit name    : package body for towers_of_hanoi
  466. -- Version      : 1.0
  467. -- Author       : Steve Rosen
  468. --              : Siemens Research
  469. --              : 
  470. --              : 
  471. -- DDN Address  : vrdxhq!siemens!gypsy!rosen@seismo
  472. -- Copyright    : (c) 
  473. -- Date created :  6 August 1985
  474. -- Release date :  6 August 1985
  475. -- Last update  :  6 August 1985
  476. -- Machine/System Compiled/Run on : VADS 4.06
  477. --                                                           -*
  478. ---------------------------------------------------------------
  479. --                                                           -*
  480. -- Keywords     :  display, hanoi
  481. ----------------:
  482. --
  483. -- Abstract     :  The body for a terminal-independent version
  484. ----------------:  of the towers of hanoi demo.
  485. --                                                           -*
  486. ------------------ Revision history ---------------------------
  487. --                                                           -*
  488. -- DATE         VERSION    AUTHOR                  HISTORY
  489. -- ???        0.0    Steve Rosen        Initial Release
  490. -- 8/6/85    1.0    Karl A. Nyberg        Release to SIMTEL
  491. --                                                           -*
  492. ------------------ Distribution and Copyright -----------------
  493. --                                                           -*
  494. -- This prologue must be included in all copies of this software.
  495. --
  496. -- This software is copyright by the author.
  497. --
  498. -- This software is released to the Ada community.
  499. -- This software is released to the Public Domain (note:
  500. --   software released to the Public Domain is not subject
  501. --   to copyright protection).
  502. -- Restrictions on use or distribution:  NONE
  503. --                                                           -*
  504. ------------------ Disclaimer ---------------------------------
  505. --                                                           -*
  506. -- This software and its documentation are provided "AS IS" and
  507. -- without any expressed or implied warranties whatsoever.
  508. -- No warranties as to performance, merchantability, or fitness
  509. -- for a particular purpose exist.
  510. --
  511. -- Because of the diversity of conditions and hardware under
  512. -- which this software may be used, no warranty of fitness for
  513. -- a particular purpose is offered.  The user is advised to
  514. -- test the software thoroughly before relying on it.  The user
  515. -- must assume the entire risk and liability of using this
  516. -- software.
  517. --
  518. -- In no event shall any person or organization of people be
  519. -- held responsible for any direct, indirect, consequential
  520. -- or inconsequential damages or lost profits.
  521. --                                                           -*
  522. -------------------END-PROLOGUE--------------------------------
  523.  
  524. -----------------------------------------
  525. --        TOWERS_OF_HANOI Body         --
  526. -----------------------------------------
  527.  
  528. with CURSES, TEXT_IO;
  529. use CURSES;
  530.  
  531. package body TOWERS_OF_HANOI is
  532.  
  533.   procedure INITIAL is
  534.   begin
  535.     COL(LEFT) := NO_DISCS;
  536.     COL(MIDDLE) := 3 * NO_DISCS;
  537.     COL(RIGHT) := 5 * NO_DISCS;
  538.     STDSCR := INITSCR;
  539.   --NOECHO;
  540.     DISPLAY(NO_DISCS);
  541.   end INITIAL;
  542.  
  543.   procedure FINISH (S: STRING) is
  544.   begin
  545.     MOVE (LINES - 2, 0);
  546.     REFRESH;
  547.     ENDWIN;
  548.     TEXT_IO.PUT_LINE(S);
  549.   end;
  550.  
  551.   procedure DISPLAY (NUMBER: NATURAL) is
  552.   begin
  553.     CLEAR;
  554.     STANDOUT;
  555.     MOVE(0, 0);
  556.     ADDSTR(" The Tower of Hanoi ");
  557.     STANDEND;
  558.     for I in reverse 1 .. NUMBER
  559.       loop
  560.     MAKE_DISC (I, LEFT);
  561.       end loop;
  562.   end DISPLAY;
  563.  
  564.   procedure HANOI (NUMBER: NATURAL; START, INTER, FINISH: LOCATION) is
  565.   begin
  566.     if (NUMBER > 0) then
  567.       HANOI (NUMBER - 1, START, FINISH, INTER);
  568.       MOVE_DISC (NUMBER, START, FINISH);
  569.       HANOI (NUMBER - 1, INTER, START, FINISH);
  570.     end if;
  571.   end HANOI;
  572.  
  573.   procedure MOVE_DISC (NUMBER: NATURAL; START, FINISH: LOCATION) is
  574.   begin
  575.     RM_DISC (NUMBER, START);
  576.     SHOW_DISC (NUMBER, START, FINISH);
  577.     MAKE_DISC (NUMBER, FINISH);
  578.   end MOVE_DISC;
  579.  
  580.   procedure SHOW_DISC (NUMBER: NATURAL; START, FINISH: LOCATION) is
  581.     X, Y, DIRECTION: INTEGER;
  582.   begin
  583.     if (COL(START) < COL(FINISH)) then
  584.       DIRECTION := +1;
  585.     else
  586.       DIRECTION := -1;
  587.     end if;
  588.  
  589.     if (DISPLAY_TYPE = TELEPORT) then
  590.       return;
  591.     end if;
  592.   
  593.     Y := COUNT(START);
  594.     while (Y < (NO_DISCS - 1))
  595.       loop
  596.     PLOT_DISC (NUMBER, Y, COL(START), BLANK);
  597.     if (DISPLAY_TYPE = SMOOTH) then
  598.       REFRESH;
  599.     end if;
  600.         PLOT_DISC (NUMBER, Y+1, COL(START), DISC);
  601.     if (DISPLAY_TYPE = SMOOTH) then
  602.       REFRESH;
  603.     end if;
  604.     Y := Y + 1;
  605.       end loop;
  606.     
  607.       REFRESH;
  608.       X := COL(START);
  609.       while (X /= COL(FINISH))
  610.     loop
  611.       PLOT_DISC (NUMBER, Y, X, BLANK);
  612.       PLOT_DISC (NUMBER, Y, X + DIRECTION, DISC);
  613.       if (DISPLAY_TYPE = SMOOTH) then
  614.         REFRESH;
  615.       end if;
  616.       X := X + DIRECTION;
  617.     end loop;
  618.       while (Y > COUNT(FINISH))
  619.     loop
  620.       PLOT_DISC(NUMBER, Y, COL(FINISH), BLANK);
  621.       Y := Y - 1;
  622.       IF (DISPLAY_TYPE = SMOOTH) then
  623.         REFRESH;
  624.       end if;
  625.       PLOT_DISC (NUMBER, Y, COL(FINISH), DISC);
  626.       if (DISPLAY_TYPE = SMOOTH) then
  627.         REFRESH;
  628.       end if;
  629.     end loop;
  630.       REFRESH;
  631.     end SHOW_DISC;
  632.  
  633.     procedure MAKE_DISC (NUMBER: NATURAL; PILE: LOCATION) is
  634.     begin
  635.       PLOT_DISC (NUMBER, COUNT(PILE), COL (PILE), DISC);
  636.       COUNT(PILE) := COUNT(PILE) + 1;
  637.       REFRESH;
  638.     end MAKE_DISC;
  639.  
  640.     procedure RM_DISC (NUMBER: NATURAL; PILE: LOCATION) is
  641.     begin
  642.       COUNT(PILE) := COUNT(PILE) - 1;
  643.       PLOT_DISC (NUMBER, COUNT(PILE), COL(PILE), BLANK);
  644.       REFRESH;
  645.     end RM_DISC;
  646.  
  647.     procedure PLOT_DISC (NUMBER, Y, X: NATURAL; C: CHARACTER) is
  648.     begin
  649.       MOVE (TOP - Y, X - NUMBER);
  650.       for I in 1 .. (2 * NUMBER)
  651.     loop
  652.       ADDCH (C);
  653.     end loop;
  654.     end PLOT_DISC;
  655.  
  656. end TOWERS_OF_HANOI;
  657. ::::::::::
  658. tower.a
  659. ::::::::::
  660. -------- SIMTEL20 Ada Software Repository Prologue ------------
  661. --                                                           -*
  662. -- Unit name    : tower.a - main program for towers of hanoi demo
  663. -- Version      : 1.0
  664. -- Author       : Steve Rosen
  665. --              : Siemens Research
  666. --              : 
  667. --              : 
  668. -- DDN Address  : vrdxhq!siemens!gypsy!rosen@seismo
  669. -- Copyright    : (c) 
  670. -- Date created :  6 August 1985
  671. -- Release date :  6 August 1985
  672. -- Last update  :  6 August 1985
  673. -- Machine/System Compiled/Run on : VADS VAX/UNIX 4.06
  674. --                                                           -*
  675. ---------------------------------------------------------------
  676. --                                                           -*
  677. -- Keywords     :  display, terminal update, screen
  678. ----------------:
  679. --
  680. -- Abstract     :  This procedure provides a demo of the towers of
  681. ----------------:  hanoi using UNIX curses that should be relatively
  682. ----------------:  terminal independent.
  683. --                                                           -*
  684. ------------------ Revision history ---------------------------
  685. --                                                           -*
  686. -- DATE         VERSION    AUTHOR                  HISTORY
  687. -- ???        0.0    Steve Rosen        Initial Release
  688. -- 8/6/85    1.0    Karl A. Nyberg        Release to SIMTEL
  689. --                                                           -*
  690. ------------------ Distribution and Copyright -----------------
  691. --                                                           -*
  692. -- This prologue must be included in all copies of this software.
  693. --
  694. -- This software is copyright by the author.
  695. --
  696. -- This software is released to the Ada community.
  697. -- This software is released to the Public Domain (note:
  698. --   software released to the Public Domain is not subject
  699. --   to copyright protection).
  700. -- Restrictions on use or distribution:  NONE
  701. --                                                           -*
  702. ------------------ Disclaimer ---------------------------------
  703. --                                                           -*
  704. -- This software and its documentation are provided "AS IS" and
  705. -- without any expressed or implied warranties whatsoever.
  706. -- No warranties as to performance, merchantability, or fitness
  707. -- for a particular purpose exist.
  708. --
  709. -- Because of the diversity of conditions and hardware under
  710. -- which this software may be used, no warranty of fitness for
  711. -- a particular purpose is offered.  The user is advised to
  712. -- test the software thoroughly before relying on it.  The user
  713. -- must assume the entire risk and liability of using this
  714. -- software.
  715. --
  716. -- In no event shall any person or organization of people be
  717. -- held responsible for any direct, indirect, consequential
  718. -- or inconsequential damages or lost profits.
  719. --                                                           -*
  720. -------------------END-PROLOGUE--------------------------------
  721.  
  722. -------------------------------
  723. --    The Main Procedure     --
  724. -------------------------------
  725.  
  726. with TOWERS_OF_HANOI;
  727. use TOWERS_OF_HANOI;
  728.  
  729. procedure TOWER is
  730. begin
  731.   INITIAL;
  732.   HANOI (NO_DISCS, LEFT, MIDDLE, RIGHT);
  733.   delay DURATION(NO_DISCS);
  734.   HANOI (NO_DISCS, RIGHT, MIDDLE, LEFT);
  735.   FINISH ("Done!");
  736. end TOWER;
  737. ::::::::::
  738. compile.ctl
  739. ::::::::::
  740. a.mklib -f .
  741. ada curses.a
  742. ada curses_body.a
  743. ada towers_of_hanoi.a
  744. ada towers_of_hanoi_body.a
  745. ada tower.a
  746. a.ld -o tower tower -lcurses -ltermlib
  747.  
  748.