home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / BOI200P.ZIP / SUPPORT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-12-14  |  28.3 KB  |  708 lines

  1. { $D-}  { Disable Debug Information }
  2. {$S-}  { Disable Stack Checking }
  3. {$V-}  { Disable String Checking }
  4.  
  5. Unit Support;
  6. { Part of BBS Onliner Interface }
  7. { Copyright (C) 1990, 1992 Andrew J. Mead
  8.   All Rights Reserved. }
  9.  
  10. { original version 9/5/90
  11.   history found in IOLIB.PAS }
  12.  
  13. INTERFACE
  14.  
  15. Uses
  16.   boidecl,
  17.   crt,
  18.   dos;
  19.  
  20. Const
  21.   bois_highscore = true;
  22.   bois_lowscore  = false;
  23.   bois_cash      = true;
  24.   bois_points    = false;
  25.  
  26. Var
  27.   playerpoints : longint;  { player score variable }
  28.  
  29. Procedure ABORTGAME(limit : byte);
  30. Procedure DISPLAYTEXT(dt_file : pathstr);
  31. Procedure LINEWRITE(lstr : string; colora, colorb :byte; lcheck : boolean);
  32. Procedure QUERYUSER(querylist : charset);
  33. Function WRITECOPY(askq : boolean) : boolean;
  34. Procedure ENDGAME(playstr : string; isvalid, iscash, gethigh : boolean);
  35.  
  36. IMPLEMENTATION
  37.  
  38. Uses
  39.   doorlib,
  40.   key,
  41.   getcmbbs,
  42.   iolib;
  43.  
  44. Var
  45.   bs_char : char;         { standard input character }
  46.   bs_etemp : boolean;
  47.  
  48. Procedure ABORTGAME; { notifies user that their "screen" is not large enough }
  49.   begin {* AbortGame *}
  50.     SendString('',true);
  51.     SendString('Your setup shows that your screen only displays ',false);
  52.     SendString(IntStr(boi_pagelength,0) + ' lines.',true);
  53.     SendString
  54.         ('This game requires a minimum of '+IntStr(limit,0)+' lines.',true);
  55.     SendString
  56.     ('Check your BBS settings and make the needed changes before trying again.',
  57.         true);
  58.     SendString
  59.         ('Thank you.  Please press almost any key to return to your BBS. ',
  60.         false);
  61.     ClearBuffers;
  62.     bs_char := ReadPortKey;
  63.     SendString('',true);
  64.     SendString('',true);
  65.     SendString('Please wait... returning to the BBS.',true);
  66.     Halt
  67.   end;  {* AbortGame *}
  68.  
  69. Procedure DISPLAYTEXT(  { display formatted text file }
  70.     dt_file : pathstr);   { file to be displayed }
  71.  
  72.   type
  73.     dmode = (send,endb,ende,wind,clr,skip);  { display modes }
  74.  
  75.   var
  76.     dt_f     : file;    { file handle for determining dt_file's size }
  77.     dt_t     : text;    { text file handle for dt_file }
  78.     dt_fsize : longint; { size of dt_file }
  79.     dt_buff  : pointer; { pointer to dt_file's input buffer }
  80.     buffsize : word;    { size of dt_file's input buffer }
  81.  
  82.     dt_mode  : dmode;   { current display mode }
  83.     dt_line  : string;  { current input display line }
  84.     dt_idx   : byte;    { index into dt_line }
  85.     dt_quit  : boolean; { user abort indicator }
  86.     endline  : boolean; { current line should be output with newline }
  87.  
  88.  { The first seven (7) characters of each line of a DisplayText text file    }
  89.  { are reserved for formatting information.  Here is the header layout:      }
  90.  { (Note: Windowing commands (W) don't follow the same format.               }
  91.  {                                                                           }
  92.  { byte  legal values  notes/meaning                                         }
  93.  {   1   + - C E B W   other values indicate comment, line is not processed  }
  94.  {   2      none       blank space                                           }
  95.  {   3      0..F       color value passed to PortBackground(color)           }
  96.  {   4      0..F       color value passed to PortColor(color,monochrome)     }
  97.  {   5      0..F       reserved                                              }
  98.  {   6      0..F       monochrome value passed to PortColor(color,monochrome)}
  99.  {   7      none       blank space                                           }
  100.  {                                                                           }
  101.  
  102.   Procedure SETVALUES(  { assign mode/endline parameters for current line }
  103.       dm : dmode;         { display mode }
  104.       el : boolean);      { endline indicator }
  105.  
  106.     begin {* DisplayText,SetValues *}
  107.       dt_mode := dm;
  108.       endline  := el
  109.     end;  {* DisplayText,SetValues *}
  110.  
  111.   begin {* DisplayText *}
  112.     { find out how large dt_file is }
  113.     Assign(dt_f,dt_file);
  114.     if OpenFile(dt_f,1,denynone + read_only,treset) <> 0 then Exit;
  115.     dt_fsize := FileSize(dt_f);
  116.     Close(dt_f);
  117.  
  118.     { create text input buffer for dt_file }
  119.     buffsize := MinL(dt_fsize,MinL(65520,MaxAvail));
  120.     GetMem(dt_buff,buffsize); { allocate buffer on heap }
  121.  
  122.     { open dt_file for processing }
  123.     Assign(dt_t,dt_file);
  124.     if OpenText(dt_t,denywrite + read_only,treset) <> 0 then Exit;
  125.     SetTextBuf(dt_t,dt_buff^,buffsize); { assign text buffer to file handle }
  126.     dt_quit := false;
  127.     repeat { process file }
  128.       begin
  129.         ReadLn(dt_t,dt_line);
  130.         if Length(dt_line) > 0 then
  131.           begin
  132.             case UpCase(dt_line[1]) of       { determine type of processing }
  133.                 '+' : SetValues(send, true);   { end-of-line marker }
  134.                 '-' : SetValues(send,false);   { line continuation marker }
  135.                 'C' : SetValues(clr ,false);   { clear window marker }
  136.                 'B' : SetValues(endb,false);   { page break marker }
  137.                 'E' : SetValues(ende,false);   { end of file marker }
  138.                 'W' : SetValues(wind,false);   { window definition marker }
  139.                 else  SetValues(skip,false)    { comment line, ignore }
  140.               end;
  141.             if dt_mode = wind then { determine window coordinates }
  142.               begin { "WF" means "Full Window" }
  143.                 if UpCase(dt_line[2]) = 'F' then
  144.                     PortWindow(1,1,80,boi_pagelength)
  145.                 else { declare window by coordinates }
  146.                   begin
  147.                     { this section not fleshed out }
  148.                   end
  149.               end
  150.             else if dt_mode <> skip then { if line to be shown, show it! }
  151.               begin
  152.                 if (Length(dt_line) >= 3) and (dt_line[3] <> ' ') then
  153.                     PortBackground(Hex(dt_line[3])); { background color }
  154.                 if (Length(dt_line) >= 6) and (dt_line[4] <> ' ') and
  155.                     (dt_line[6] <> ' ') then { text color }
  156.                     PortColor(Hex(dt_line[4]),Hex(dt_line[6]));
  157.                 if dt_mode = clr then ClrPortScr { clear window }
  158.                 else if dt_mode = endb then
  159.                   begin { page break / wait for user }
  160.                     SendString('Press almost any key to continue.',false);
  161.                     ClearBuffers;
  162.                     bs_char := ReadPortKey;
  163.                     if bs_char = #27 then dt_quit := true;
  164.                     PortColumnOne;
  165.                     ClrPortEOL
  166.                   end
  167.                 else if dt_mode = ende then
  168.                   begin { end of file / wait for user }
  169.                     SendString('',true);
  170.                     SendString('Press almost any key to continue game.',false);
  171.                     ClearBuffers;
  172.                     bs_char := ReadPortKey
  173.                   end
  174.                 else if Length(dt_line) > 7 then
  175.                   { show text one character at a time, allowing user to exit }
  176.                   { by pressing [ESC] or pause by pressing the spacebar. }
  177.                   begin
  178.                     dt_idx := 8; { set index into line }
  179.                     while (dt_idx <= Length(dt_line)) and (not dt_quit) do
  180.                       begin
  181.                         SendString(dt_line[dt_idx],false); { show character }
  182.                         Inc(dt_idx);
  183.                         while (PortKeyPressed) and (not dt_quit) do
  184.                           begin { process incoming key }
  185.                             bs_char := ReadPortKey;
  186.                             if bs_char = #27 then dt_quit := true { exit }
  187.                             else if bs_char = ' ' then { pause }
  188.                               begin
  189.                                 ClearBuffers;
  190.                                 while not PortKeyPressed do
  191.                                     if not in_dos^ then BOI_Wait;
  192.                                 bs_char := ReadPortKey;
  193.                                 if bs_char = #27 then dt_quit := true; { exit }
  194.                                 ClearBuffers
  195.                               end
  196.                             else ClearBuffers
  197.                           end
  198.                       end
  199.                   end
  200.               end;
  201.             if endline and (not dt_quit) then SendString('',true) { cr/lf }
  202.           end
  203.       end
  204.     until EOF(dt_t) or (dt_mode = ende) or dt_quit ;
  205.     Close(dt_t);
  206.     FreeMem(dt_buff,buffsize) { release buffer space from heap }
  207.   end;  {* DisplayText *}
  208.  
  209. Procedure LINEWRITE(    { option bar item display routine }
  210.     lstr   : string;      { string to display }
  211.     colora : byte;        { color to use for color modes }
  212.     colorb : byte;        { color to use for monochrome modes }
  213.     lcheck : boolean);    { is item active? }
  214.  
  215.   begin {* LineWrite *}
  216.     PortColor(colora,colorb);
  217.     SendString(lstr[1],false);
  218.     if lcheck then TextPortColor(white); { Highlight active items }
  219.     SendString(lstr[2],false);
  220.     if lcheck then PortColor(colora,colorb);
  221.     SendString(copy(lstr,3,length(lstr)),false)
  222.   end;  {* LineWrite *}
  223.  
  224. Procedure QUERYUSER(      { ask user what video mode they want }
  225.     querylist : charset);   { legal video modes }
  226.  
  227.   Procedure QUERYCHOICE(    { writes out one choice line }
  228.       qchar : char;           { selection character for choice }
  229.       qstr  : string);        { description of choice }
  230.  
  231.     begin {* QueryUser,QueryChoice *}
  232.       if qchar in querylist then
  233.           SendString('       "' + qchar + '" ' + qstr,true)
  234.     end;  {* QueryUser,QueryChoice *}
  235.  
  236.   Procedure SETVALUES(     { initialize graphic modes }
  237.       lcolor : boolean;      { local color/mono indicator }
  238.       rcolor : boolean;      { remote color/mono indicator }
  239.       grmode : boi_grmode);  { graphics mode to use }
  240.  
  241.     begin {* QueryUser,SetValues *}
  242.       boi_l_color := lcolor;
  243.       if not boi_local then
  244.         begin
  245.           boi_r_color := rcolor;
  246.           boi_r_grmode := grmode
  247.         end
  248.       else SetLocalGraphMode(grmode)
  249.     end;  {* QueryUser,SetValues *}
  250.  
  251.  
  252.   begin {* QueryUser *}
  253. {$IFDEF BOIDEBUG }
  254.     SendString('',true);
  255.     SendString('Running under '+boi_tstr+' mode.',true);
  256. {$ENDIF BOI DEBUG }
  257.     SendString('',true);
  258.     SendString('Before we get started, please pick a display mode: ',true);
  259.     SendString('',true);
  260.     if boi_local then { add CRT choices for local play }
  261.         querylist := querylist + ['C','M'];
  262.     QueryChoice('Q','None - Exit game now');
  263.     QueryChoice('0','ASCII text');
  264.     QueryChoice('1','ANSI Color');
  265.     QueryChoice('2','ANSI Monochrome');
  266.     QueryChoice('3','AVATAR/1 Color');
  267.     QueryChoice('4','AVATAR/1 Monochrome');
  268.     QueryChoice('C','Direct Video Color');
  269.     QueryChoice('M','Direct Video Monochrome');
  270.     SendString('',true);
  271.     repeat bs_char := UpCase(ReadPortKey)   { scan input stream }
  272.     until bs_char in querylist;             { until valid choice found }
  273.     case bs_char of
  274.         'Q' : Halt;
  275.         '0' : { ASCII mode }
  276.           begin
  277.             if not boi_local then boi_r_grmode := gr_ascii
  278.             else SetLocalGraphMode(gr_ascii)
  279.           end;
  280.         '1' : SetValues(true, true, gr_ansi);  { ANSI color mode }
  281.         '2' : SetValues(false,false,gr_ansi);  { ANSI monochrome mode }
  282.         '3' : SetValues(true, true, gr_avt);   { AVATAR color mode }
  283.         '4' : SetValues(false,false,gr_avt);   { AVATAR monochrome mode }
  284.  
  285.         'C' : { CRT color mode }
  286.           begin
  287.             boi_r_grmode := gr_none;
  288.             boi_l_grmode := gr_tpcrt;
  289.             boi_l_color := true
  290.           end;
  291.         'M' : { CRT monochrome mode }
  292.           begin
  293.             boi_r_grmode := gr_none;
  294.             boi_l_grmode := gr_tpcrt;
  295.             boi_l_color := false
  296.           end;
  297.       end;
  298.     SendString('',true);
  299.     PortColor(lightgreen,white);
  300.     SendString('Thank you.  Please enjoy the game.',true)
  301.   end;  {* QueryUser *}
  302.  
  303. Function WRITECOPY;         { Copyright screen }
  304.   begin {* WriteCopy *}
  305.     bs_etemp := boi_echo;
  306.     if not boi_local then boi_echo := true; { force local echo for copyright }
  307.     PortBackground(black);
  308.     PortColor(yellow,white);
  309.     ClrPortScr;
  310.     SendString(DoorName,false);
  311.     PortColor(cyan,lightgray);
  312.     SendString(' version ' + Version + '.',true);
  313.     SendString('Program Copyright (C) 1990,1992 Andrew J. Mead',true);
  314.     SendString('All Rights Reserved.',true);
  315.     SendString('',true);
  316. {* begin required portion *}
  317.     TextPortColor(white);
  318.     SendString('BBS Onliner Interface',false);
  319.     PortColor(cyan,lightgray);
  320.     SendString(' version ' + BOI_Version + '.',true);
  321.     SendString('Copyright(C) 1990,1992 Andrew J. Mead',true);
  322.     SendString('All Rights Reserved.',true);
  323.     SendString('Contact: POB 1155 Chapel Hill, NC 27514-1155',true);
  324. {* end required portion * }
  325.     SendString('',true);
  326.     if key_registered then {* rejoice, rejoice, rejoice *}
  327.       begin
  328.         PortColor(lightblue,white);
  329.         SendString(key_regname,false);
  330.         PortColor(cyan,lightgray);
  331.         SendString(' has registered this game.  SN: '+key_regnum,true);
  332.         PortColor(Random(7) + 9,white); { pick a random bright color }
  333.         SendString(key_regstr,true);
  334.         PortColor(cyan,lightgray);
  335.         SendString('Support your local BBSs that support ShareWare.',true)
  336.       end
  337.     else {* beg like a dog *}
  338.       begin
  339.         SendString('This is an Evaluation Copy of ',false);
  340.         PortColor(yellow,white);
  341.         SendString(DoorName,false);
  342.         PortColor(cyan,lightgray);
  343.         SendString('.',true);
  344.         SendString('If you like it, please help the SysOp register it.',true)
  345.       end;
  346.     GotoPorTXY(1,boi_pagelength);
  347.     PortColor(lightmagenta,lightgray);
  348.     if askq then SendString
  349.         ('Press "I" for instructions, or almost any other key to begin. ',false)
  350.     else SendString('Press almost any key to begin. ',false);
  351.     ClearBuffers;
  352.     bs_char := UpCase(ReadPortKey);
  353.     boi_echo := bs_etemp;  { restore original local echo status }
  354.     WriteCopy := bs_char = 'I'
  355.   end;  {* WriteCopy *}
  356.  
  357. Procedure ENDGAME(       { standard Hall of Fame }
  358.     playstr  : string;     { -type- of player }
  359.     isvalid  : boolean;    { is score valid for HOF contention? }
  360.     iscash   : boolean;    { is score in cash? (or points) }
  361.     gethigh  : boolean);   { is high (or low) score better }
  362.  
  363.   type
  364.     str40    = string [40];
  365.  
  366.     hofrec   = record         { Hall of Fame data file record }
  367.         hname  : str40;         { player name }
  368.         amount : longint;       { player score }
  369.         month  : word;          { month of game }
  370.         date   : word;          { day of month of game }
  371.         year   : word           { year of game }
  372.       end;
  373.     hofarr   = array [1..24] of hofrec;
  374.                              {  1..20 this month's top 20 }
  375.                              { 21..23 last month's top  3 }
  376.                              {     24 all time high score }
  377.  
  378.   var
  379.     hof_f       : file;      { file handle for data Hall of Fame }
  380.     hof_t       : text;      { file handle for text Hall of Fame }
  381.     hof_hall    : hofarr;    { Hall of Fame }
  382.     hof_old     : boolean;   { Hall of Fame needs to be updated indicator }
  383.     alltimebest : boolean;   { this score is the All Time Best }
  384.     updatetext  : boolean;   { text Hall of Fame needs to be updated }
  385.     nextmonth   : boolean;   { this games starts a new month }
  386.     topten      : boolean;   { this score is in this month's top ten }
  387.     usetemp     : boolean;   { storage for boi_usename value }
  388.     hof_idx     : byte;      { current place in Hall of Fame }
  389.     firstmatch  : byte;      { index to player's lowest score in Hall of Fame }
  390.     totalmatch  : byte;      { number of times this player is in Hall of Fame }
  391.  
  392.     eloop       : byte;      { temporary looping/counting variable }
  393.     extra       : word;      { temporary variables used for formatting output }
  394.     etemp       : byte;
  395.     enddoor     : string;
  396.     workline    : string;
  397.     tempname    : str40;
  398.  
  399.   Function HOFCHECK : boolean;  { does this score REALLY belong in HOF? }
  400.     var
  401.       hloop : byte;
  402.  
  403.     begin {* HofCheck *}
  404.       if boi_usename then
  405.         begin { find out if this score is within limit (/x:n), and what the }
  406.               { worst score this player has posted to the Hall of fame }
  407.           for hloop := 1 to 20 do if boi_username = hof_hall[hloop].hname then
  408.             begin
  409.               Inc(totalmatch); { Increment number of scores by this player }
  410.               if totalmatch = boi_hoflim then firstmatch := hloop
  411.             end;
  412.           HofCheck := (firstmatch = 21) or
  413.               (gethigh and (playerpoints > hof_hall[firstmatch].amount)) or
  414.               ((not gethigh) and (playerpoints < hof_hall[firstmatch].amount))
  415.         end
  416.       else HofCheck := true
  417.     end;  {* HofCheck *}
  418.  
  419.   Function GOODSCORE : boolean;   { does this score fit in the HOF? }
  420.     begin {* EndGame,fGoodScore *}
  421.       if gethigh then GoodScore := (playerpoints > hof_hall[20].amount)
  422.       else GoodScore := (playerpoints < hof_hall[20].amount) or
  423.           (hof_hall[20].amount = 0)
  424.     end;  {* EndGame,fGoodScore *}
  425.  
  426.   Function BETTERSCORE : boolean; { where in the HOF does this score fit? }
  427.     begin {* EndGame,fBetterScore *}
  428.       if gethigh then
  429.           BetterScore := (playerpoints > hof_hall[hof_idx - 1].amount)
  430.       else BetterScore := (playerpoints < hof_hall[hof_idx - 1].amount) or
  431.           (hof_hall[hof_idx - 1].amount = 0)
  432.     end;  {* EndGame,fBetterScore *}
  433.  
  434.   begin {* EndGame *}
  435.     updatetext  := false; { text Hall of Fame is fine the way it is }
  436.     nextmonth   := false; { the Hall of Fame is current for this month }
  437.     hof_old     := false; { the Hall of Fame data is up to date! }
  438.     firstmatch  := 21;    { this player's score doesn't make it in the HOF }
  439.     totalmatch  := 0;     { this player has no scores in the Hall of Fame }
  440.     alltimebest := false; { this score is definitely not the All Time Best }
  441.     usetemp     := boi_usename;  { save current player's name }
  442.     Assign(hof_f,boi_gamedir + DatHOF);
  443.     if Exist(boi_gamedir + DatHOF) then
  444.       begin { read in current Hall of Fame }
  445.         if OpenFile(hof_f,SizeOf(hof_hall),denywrite+read_only,treset) = 0 then;
  446.         BlockRead(hof_f,hof_hall,1);
  447.         Close(hof_f);
  448.         if (hof_hall[1].amount > 0) and
  449.             (boi_startdate[2] <> hof_hall[1].month) then
  450.           begin { this is a new month }
  451.             nextmonth := true;
  452.             updatetext := true;
  453.             Move(hof_hall[1],hof_hall[21],3*SizeOf(hof_hall[1]));
  454.                 { move top three scores to "last month'" section }
  455.             for eloop := 1 to 20 do with hof_hall[eloop] do
  456.               begin { reset top twenty for this month }
  457.                 hname := '';
  458.                 amount := 0;
  459.                 month := boi_startdate[2];
  460.                 date  := boi_startdate[3];
  461.                 year  := boi_startdate[1]
  462.               end;
  463.             if OpenFile(hof_f,SizeOf(hof_hall),denywrite + writeonly,
  464.                 trewrite) = 0 then;
  465.             BlockWrite(hof_f,hof_hall,1);
  466.             Close(hof_f)
  467.           end
  468.       end
  469.     else { create brand new Hall of Fame }
  470.       begin
  471.         FillChar(hof_hall,SizeOf(hof_hall),0);
  472.         for eloop := 1 to 24 do with hof_hall[eloop] do
  473.           begin { initialize entries }
  474.             hname := '';
  475.             amount := 0;
  476.             month := boi_startdate[2];
  477.             date  := boi_startdate[3];
  478.             year  := boi_startdate[1]
  479.           end
  480.       end;
  481.     if iscash then { show player their score as cash total }
  482.       begin
  483.         PortColor(brown,lightgray);
  484.         SendString(
  485.             'Your game has ended.  Your final holdings are worth ',false);
  486.         PortColor(yellow,white);
  487.         SendString('$',false);
  488.         PortColor(lightgreen,white);
  489.         SendString(IntStr(playerpoints,0),false);
  490.         PortColor(brown,lightgray);
  491.         SendString('.',true)
  492.       end
  493.     else { show player their score as point total }
  494.       begin
  495.         PortColor(brown,lightgray);
  496.         SendString('Your game has ended. Your final score is ',false);
  497.         PortColor(yellow,white);
  498.         SendString(IntStr(playerpoints,0),false);
  499.         PortColor(brown,lightgray);
  500.         SendString(' points.',true)
  501.       end;
  502.     if GoodScore and isvalid and HofCheck then { score belongs in Hall of Fame }
  503.       begin
  504.         hof_old := true;
  505.         PortColor(red,lightgray);
  506.         SendString('You have qualified for the ',false);
  507.         PortColor(lightred,white);
  508.         SendString('Hall of Fame',false);
  509.         PortColor(red,lightgray);
  510.         if boi_usename then { use player's user name }
  511.           begin
  512.             tempname := boi_username;
  513.             SendString('.',true)
  514.           end
  515.         else { ask player to supply name }
  516.           begin
  517.             SendString(', please enter your name:',true);
  518.             tempname[0] := chr(0);
  519.             PortColor(lightcyan,white);
  520.             GetString(tempname)
  521.           end;
  522.         hof_idx := 21;
  523.         while (hof_idx > 1) and BetterScore do { find out where score belongs }
  524.             Dec(hof_idx);
  525.         Move(hof_hall[hof_idx],               { move worse scores down in HOF }
  526.             hof_hall[hof_idx + 1],
  527.             (Min(firstmatch,20) - hof_idx) * SizeOf(hofrec));
  528.         hof_hall[hof_idx].hname := tempname;      { add player's data to HOF }
  529.         hof_hall[hof_idx].amount := playerpoints;
  530.         GetDate(hof_hall[hof_idx].year,hof_hall[hof_idx].month,
  531.             hof_hall[hof_idx].date,extra)
  532.       end;
  533.     PortWindow(1,1,80,boi_pagelength);
  534.     GotoPortXY(1,Min(24,boi_pagelength));
  535.     PortColor(brown,lightgray);
  536.     SendString('Press almost any key to see the Hall of Fame. ',false);
  537.     ClearBuffers;
  538.     bs_char := ReadPortKey;
  539.     boi_usename := false;
  540.     ClrPortScr;
  541.     PortColor(lightcyan,white);
  542.  
  543.     { display monthly Hall of Fame to user }
  544.     enddoor := DoorName;
  545.     etemp := Length(enddoor);
  546.     while Length(enddoor) < 50 do enddoor := ' ' + enddoor;
  547.     SendString(enddoor,false);
  548.     PortColor(lightgreen,white);
  549.     SendString(' Hall Of Fame',true);
  550.     Delete(enddoor,1,Length(enddoor) - etemp);
  551.     PortColor(brown,lightgray);
  552.     SendString(PadStr('Player  Rank       Amount    Date',67),true);
  553.     for eloop := 1 to 20 do with hof_hall[eloop] do
  554.         if amount > 0 then { only show legal entries }
  555.       begin { show line of Hall of Fame }
  556.         if hof_old and (eloop = hof_idx) then { highlight current score }
  557.             PortColor(lightblue,white)
  558.         else if eloop = 1 then                { highlight all time best }
  559.             TextPortColor(white)
  560.         else PortColor(green,lightgray);
  561.         SendString(PadStr(hname,40) + IntStr(eloop,5) + IntStr(amount,14) +
  562.             IntStr(month,5) + '/' + IntStr(date,0) +'/' + IntStr(year,0),false);
  563.         if hof_old and (eloop = hof_idx) then SendString(' <--',true)
  564.         else SendString('',true)
  565.       end;
  566.     SendString('',true);
  567.  
  568.     { update data Hall of Fame }
  569.     if hof_old then
  570.        begin
  571.         if (hof_idx = 1) and
  572.             ((gethigh) and (playerpoints > hof_hall[24].amount)) or
  573.             ((not gethigh) and ((playerpoints < hof_hall[24].amount) or
  574.             (hof_hall[24].amount = 0))) then
  575.           begin { this score is the all time best }
  576.             alltimebest := true;
  577.             Move(hof_hall[hof_idx],hof_hall[24],SizeOf(hof_hall[24]));
  578.             updatetext := true;
  579.           end
  580.         else if hof_idx <= 10 then
  581.           begin { text Hall of Fame needs to be updated }
  582.             topten := true;
  583.             updatetext := true
  584.           end;
  585.         { write data Hall of Fame }
  586.         if OpenFile(hof_f,SizeOf(hof_hall),denywrite+writeonly,trewrite)=0 then;
  587. {xxx}        BlockWrite(hof_f,hof_hall,1);
  588.         Close(hof_f)
  589.       end;
  590.  
  591.     { update text Hall of Fame }
  592.     if updatetext then
  593.       begin
  594.         Assign(hof_t,boi_texthof);
  595.         if OpenText(hof_t,denywrite + writeonly,trewrite) = 0 then;
  596.         workline := key_regstr + ' - ' + enddoor + ' - Hall Of Fame';
  597. { 1}    WriteLn(hof_t,workline:Length(workline) div 2 + 40);
  598. { 2}    WriteLn(hof_t);
  599.         if hof_hall[24].amount > 0 then
  600.           begin
  601.             workline := '- All Time Best Score -';
  602. { 3}        WriteLn(hof_t,workline:length(workline)div 2 + 45);
  603. { 4}        WriteLn(hof_t,hof_hall[24].hname:40,' ',hof_hall[24].amount:10,
  604.                 ' ',hof_hall[24].month:0,'/',hof_hall[24].date:0,'/',
  605.                 hof_hall[24].year:0)
  606.           end;
  607. { 5}    WriteLn(hof_t);
  608.         if hof_hall[21].amount > 0 then
  609.           begin
  610.             workline := '- Last Month''s Top Three -';
  611. { 6}        WriteLn(hof_t,workline:length(workline) div 2 + 45);
  612.             for eloop := 21 to 23 do if hof_hall[eloop].amount > 0 then
  613. { 7- 9}         WriteLn(hof_t,hof_hall[eloop].hname:40,' ',
  614.                 hof_hall[eloop].amount:10,' ',hof_hall[eloop].month:0,'/',
  615.                 hof_hall[eloop].date:0,'/',hof_hall[eloop].year:0);
  616. {10}         WriteLn(hof_t)
  617.           end;
  618.         workline := '- This Month''s Top ' + playstr + ' -';
  619. {11}    WriteLn(hof_t,workline:length(workline) div 2 + 45);
  620.         for eloop := 1 to 10 do if hof_hall[eloop].amount > 0 then
  621. {12-21}     WriteLn(hof_t,hof_hall[eloop].hname:40,' ',
  622.             hof_hall[eloop].amount:10,' ',hof_hall[eloop].month:0,'/',
  623.             hof_hall[eloop].date:0,'/',hof_hall[eloop].year:0);
  624.         Close(hof_t)
  625.       end;
  626.     SendString('',true);
  627.  
  628.     if alltimebest then
  629.       begin { tell player about it }
  630.         PortColor(brown,lightgray);
  631.         SendString('Your final amount was the ',false);
  632.         PortColor(yellow,white);
  633.         SendString('ALL-TIME BEST!!!',true)
  634.       end
  635.     else { recap player's score }
  636.       begin
  637.         PortColor(brown,lightgray);
  638.         SendString('Your final amount was ',false);
  639.         PortColor(yellow,white);
  640.         if iscash then { show score as cash value }
  641.           begin
  642.             SendString('$',false);
  643.             PortColor(lightgreen,white);
  644.             SendString(IntStr(playerpoints,0),false);
  645.             PortColor(brown,lightgray);
  646.             SendString('.',true)
  647.           end
  648.         else { show score as points value }
  649.           begin
  650.             SendString(IntStr(playerpoints,0),false);
  651.             PortColor(brown,lightgray);
  652.             SendString(' points.',true)
  653.           end
  654.       end;
  655.  
  656.     { see if player can, and if player wants to play anther game }
  657.     if boi_replay and ((not boi_usetime) or ((not boi_timexp) and
  658.         (boi_againtime < LeftTime))) then
  659.       begin
  660.         PortColor(brown,lightgray);
  661.         if boi_usetime then { tell player how much time they have left }
  662.           begin
  663.             SendString('You have less than ',false);
  664.             PortColor(yellow,white);
  665.             SendString(IntStr(LeftTime + 1,0),false);
  666.             PortColor(brown,lightgray);
  667.             SendString(' minutes remaining.',true)
  668.           end;
  669.         SendString('Would you like to play again? [Y/N] ',false);
  670.         ClearBuffers;
  671.         TextPortColor(white);
  672.         repeat bs_char := UpCase(ReadPortKey) until bs_char in ['Y','N'];
  673.         if bs_char = 'Y' then SendString('Yes',true) else SendString('No',true);
  674.         if bs_char = 'N' then boi_replay := false else boi_usename := usetemp
  675.       end
  676.     else boi_replay := false;
  677.     if not boi_replay then
  678.       begin { tell player they are about to leave game }
  679.         PortColor(brown,lightgray);
  680.         if key_registered then { tell them the BBS name }
  681.           begin
  682.             SendString('Press almost any key to return to ',false);
  683.             PortColor(random(7) + 1,white);
  684.             SendString(key_regstr,false);
  685.             PortColor(brown,lightgray);
  686.             SendString('.',false)
  687.           end
  688.         else SendString('Press almost any key to return to your BBS.',false);
  689.         ClearBuffers;
  690.         bs_char := ReadPortKey;
  691.         SendString('',true);
  692.         SendString('',true);
  693.         PortColor(brown,lightgray);
  694.         if key_registered then { tell them the BBS name again }
  695.           begin
  696.             SendString('Please wait.  Returning to ',false);
  697.             PortColor(random(7) + 1,white);
  698.             SendString(key_regstr,false);
  699.             PortColor(brown,lightgray);
  700.             SendString('.',true)
  701.            end
  702.          else SendString('Please wait.  Returning to the BBS.',true)
  703.       end
  704.   end;  {* EndGame *}
  705.  
  706. begin {* uSupport *}
  707. end.  {* uSupport *}
  708.