home *** CD-ROM | disk | FTP | other *** search
/ Game-A-Roma (Doom Edition) / GAME_A_ROMA.iso / games / big2 / go-help.inc < prev    next >
Text File  |  1985-09-19  |  8KB  |  305 lines

  1. {
  2.    ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐
  3.    ├─┼─┼─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┼─┤
  4.    ├─┼─┤          GO-HELP.PAS include module.          ├─┼─┤
  5.    ├─┼─┤          Last modified:  09/19/85             ├─┼─┤
  6.    ├─┼─┼─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┼─┼─┤
  7.    └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘
  8.  
  9.  Note:  To incorporate this system into other programs,  modify
  10.         and include this file and all statements in GO-MOKU.PAS
  11.         marked with a comment contain:  ... Help system ...
  12. }
  13.  
  14. procedure Help;
  15. const
  16.   MaxLines = 50;                 { Max # lines read into help screen }
  17.   FirstCol = 50;                            { Inside the help window }
  18.   FirstRow =  8;
  19.   LastCol  = 75;
  20.   LastRow  = 21;
  21.   HelpFileName : string[20] = 'GO-MOKU.HLP';
  22.  
  23. type
  24.   RowType     = string[25];
  25.   ScreenArray = array[1..MaxLines] of RowType;    { Stores help text }
  26.  
  27. var
  28.   HelpFile : Text;                                   { The help file }
  29.   HelpText : ScreenArray;                { Storage for the help file }
  30.   LastLineRead : integer;    { The last line read from the help file }
  31.   BorderTop, BorderBottom,           { Help screen border boundaries }
  32.   BorderLeft, BorderRight : byte;
  33.  
  34. procedure DrawBorder;
  35. { Draw a border around the help window }
  36. const
  37.   VerticalBorder = #186; HorizontalBorder = #205;
  38.   UpLeft         = #201; UpRight          = #187;
  39.   DownLeft       = #200; DownRight        = #188;
  40. var
  41.   Row, Col : integer;
  42. begin
  43.   BorderTop := 1;  BorderBottom := 16;
  44.   BorderLeft := 1; BorderRight := 29;
  45.   ClrScr;
  46.   TextColor(NormalColor - 8);
  47.   GotoXY(BorderLeft, BorderTop);
  48.   Write(UpLeft);
  49.   for Col := BorderLeft + 1 to BorderRight - 22 do
  50.     Write(HorizontalBorder);
  51.   TextColor(NormalColor);
  52.   Write(' GOMOKU HELP ');
  53.   TextColor(NormalColor - 8);
  54.   for Col := BorderLeft + 20 to BorderRight - 1 do
  55.     Write(HorizontalBorder);
  56.   Write(UpRight);
  57.   for Row := BorderTop + 1 to BorderBottom - 1 do
  58.   begin
  59.     GotoXY(BorderLeft, Row);
  60.     Write(VerticalBorder);
  61.     GotoXY(BorderRight, Row);
  62.     Write(VerticalBorder);
  63.   end;
  64.   GotoXY(BorderLeft, BorderBottom);
  65.   Write(DownLeft);
  66.   for Col := BorderLeft + 1 to BorderRight - 1 do
  67.     Write(HorizontalBorder);
  68.   Write(DownRight);
  69. end; { DrawBorder }
  70.  
  71. procedure DrawHelpLine;
  72. { Draws a help line below the help window }
  73. begin
  74.   GotoXY(BorderLeft + 1, BorderBottom + 1);
  75.   WriteHelp(#24 + #196, 1);
  76.   WriteHelp(#25 + #196 + 'Scroll   ', 1);
  77.   WriteHelp('PgUp' + #196, 4);
  78.   WriteHelp('PgDn' + #196 + 'Page', 4);
  79. end; { DrawHelpLine }
  80.  
  81. function ReadHelpFile : boolean;
  82. { Reads in the help file and returns
  83.   true if the read was successful    }
  84. var
  85.   Ch : char;
  86.  
  87. procedure LoadArray;
  88. { Stores the help file into an array }
  89. begin
  90.   GotoXY(1, 2);
  91.   ClrEOL;
  92.   WriteLn(' Reading Text . . .');
  93.   FillChar(HelpText, SizeOf(HelpText), #0); { Initialize array }
  94.   LastLineRead := 0;
  95.   while not EOF(HelpFile) and (LastLineRead < MaxLines) do
  96.   begin
  97.     LastLineRead := LastLineRead + 1;
  98.     ReadLn(HelpFile, HelpText[LastLineRead]);
  99.   end;
  100.   if not EOF(HelpFile) then
  101.   begin
  102.     WriteLn;
  103.     WriteLn;
  104.     WriteLn('Sorry, this program only');
  105.     WriteLn('reads ', MaxLines, ' lines of text.');
  106.   end;
  107. end; { LoadArray }
  108.  
  109. begin { ReadHelpFile }
  110.   Window(FirstCol, FirstRow, LastCol, LastRow);
  111.   GotoXY(1, 1);
  112.   ClrScr;
  113.   GotoXY(1, 1);
  114.   WriteLn;
  115.   Write('Looking for ', HelpFileName);
  116.   Assign(HelpFile, HelpFileName);
  117.   {$I-}
  118.   Reset(HelpFile);
  119.   {$I+}
  120.   if IOresult <> 0 then
  121.   begin
  122.     GotoXY(1, 2);
  123.     ClrEOL;
  124.     WriteLn(HelpFileName, ' not found.');
  125.     Write('Press <ESC> ');
  126.     Read(KBD, Ch);
  127.     ReadHelpFile := false;
  128.   end
  129.   else
  130.   begin
  131.     LoadArray;
  132.     if LastLineRead < 1 then
  133.     begin
  134.       ClrScr;
  135.       GotoXY(1, 2);
  136.       ClrEOL;
  137.       WriteLn('The help file is empty.');
  138.       Write('Press <ESC> ');
  139.       Read(KBD, Ch);
  140.       ReadHelpFile := false;
  141.     end
  142.     else
  143.     begin
  144.       ReadHelpFile := true;
  145.       FileRead := true;
  146.     end;
  147.   end;
  148. end; { ReadHelpFile }
  149.  
  150. procedure Displayfile;
  151. { Display the help file in the help window }
  152. const
  153.   PgDn   = #81;
  154.   PgUp   = #73;
  155.   ScrlDn = #80;
  156.   ScrlUp = #72;
  157.   Esc    = #27;
  158. var
  159.   TopLine, BottomLine, MaxRows   : integer;
  160.   PgCommand                      : char;
  161.  
  162. procedure DisplayPage(TopLine, BottomLine : integer);
  163. { Display a page of text in the help window }
  164. var
  165.   Row : integer;
  166. begin
  167.   ClrScr;
  168.   for Row := TopLine to BottomLine do
  169.   begin
  170.     if Row <> BottomLine then
  171.       WriteLn(HelpText[row])
  172.     else
  173.       Write(HelpText[row]);
  174.   end;
  175.   GotoXY(1, LastRow);
  176. end; { DisplayPage }
  177.  
  178. procedure PageDown(var TopLine, BottomLine : integer);
  179. { Page down in the help window }
  180. begin
  181.   if BottomLine + 1 <= LastLineRead then
  182.   begin
  183.     if (BottomLine + MaxRows) > LastLineRead then
  184.       BottomLine := LastLineRead
  185.     else
  186.       BottomLine := BottomLine + MaxRows;
  187.     if (BottomLine - MaxRows + 1) >= 1 then
  188.       TopLine := (BottomLine - MaxRows + 1)
  189.     else
  190.       TopLine := 1;
  191.     DisplayPage(TopLine, BottomLine);
  192.   end;
  193. end; { PageDown }
  194.  
  195. procedure PageUp(var TopLine, BottomLine : integer);
  196. { Page up in the help window }
  197. begin
  198.   if TopLine > 1 then
  199.   begin
  200.     if (TopLine - MaxRows) > 1 then                 { Set TopLine    }
  201.       TopLine := TopLine - MaxRows
  202.     else
  203.       TopLine := 1;
  204.     if (TopLine + MaxRows - 1) > LastLineRead then  { Set BottomLine }
  205.       BottomLine := LastLineRead
  206.     else
  207.       BottomLine := TopLine + MaxRows - 1;
  208.     DisplayPage(TopLine, BottomLine);
  209.   end;
  210. end; { PageUp }
  211.  
  212. procedure ScrollUp(var TopLine, BottomLine : integer);
  213. { Scroll the help screen up one line }
  214. begin
  215.   if TopLine > 1 then
  216.   begin
  217.     if (BottomLine - TopLine + 1) >= MaxRows then  { screen was full }
  218.       BottomLine := BottomLine - 1;
  219.     TopLine := TopLine - 1;
  220.     GotoXY(1, MaxRows);
  221.     DelLine;
  222.     GotoXY(1, 1);
  223.     InsLine;
  224.     Write(HelpText[TopLine]);
  225.     GotoXY(1, MaxRows);
  226.   end;
  227. end; { ScrollUp }
  228.  
  229. procedure ScrollDown(var TopLine, BottomLine : integer);
  230. { Scroll the help screen down one line }
  231. begin
  232.   if BottomLine < LastLineRead then
  233.   begin
  234.     TopLine := TopLine + 1;
  235.     BottomLine := BottomLine + 1;
  236.     GotoXY(1, 1);
  237.     DelLine;
  238.     GotoXY(1, MaxRows);
  239.     InsLine;
  240.     Write(HelpText[BottomLine]);
  241.     GotoXY(1, MaxRows);
  242.   end;
  243. end; { ScrollDown }
  244.  
  245. procedure Init;
  246. { Initialization routine }
  247. begin
  248.   MaxRows := LastRow - FirstRow + 1;
  249.   TopLine := 1;
  250.   if MaxRows > LastLineRead then
  251.     BottomLine := LastLineRead
  252.   else
  253.     BottomLine := MaxRows;
  254.   DisplayPage(TopLine, BottomLine);  { Show first page }
  255. end; { Init }
  256.  
  257. begin { Displayfile }
  258.   Init;
  259.   repeat
  260.     Read(KBD, PgCommand);
  261.     PgCommand := UpCase(PgCommand);
  262.     if (PgCommand = CtrlC) or (PgCommand = 'Q') then
  263.       Abort;
  264.     if (PgCommand = Esc) and KeyPressed then
  265.     begin
  266.       Read(KBD, PgCommand);
  267.       PgCommand := UpCase(PgCommand);
  268.       case PgCommand of
  269.         PgDn   : PageDown(TopLine, BottomLine);
  270.         PgUp   : PageUp(TopLine, BottomLine);
  271.         ScrlDn : ScrollDown(TopLine, BottomLine);
  272.         ScrlUp : ScrollUp(TopLine, BottomLine);
  273.       end;
  274.     end;
  275.   until (PgCommand = Esc) and (not KeyPressed);
  276. end; { Displayfile }
  277.  
  278. begin { Help }
  279.   GotoXY(49, 5);                     { Display help commands }
  280.   WriteHelp('ESC-Exits Help', 3);
  281.   Window(FirstCol - 2, FirstRow - 1, LastCol + 1, LastRow + 2);
  282.   GotoXY(1, 1);
  283.   DrawBorder;
  284.   DrawHelpLine;
  285.   if FileRead then                            { Display help }
  286.   begin
  287.     Window(FirstCol, FirstRow, LastCol, LastRow);
  288.     GotoXY(1, 1);
  289.     Displayfile;
  290.   end
  291.   else
  292.   if ReadHelpFile then                { Help read from disk?  }
  293.     Displayfile;
  294.   Window(FirstCol - 2, FirstRow - 1,           { Close window }
  295.          LastCol + 1, LastRow + 2);
  296.   GotoXY(1, 1);
  297.   ClrScr;
  298.   Window(1, 1, 80, 25);                      { Restore screen }
  299.   GotoXY(1, 1);
  300.   GotoXY(49, 5);
  301.   WriteHelp('?-for Help    ', 1);              { Restore menu }
  302. end; { Help }
  303.  
  304. { ================ End Of On-Line Help Module =============== }
  305.