home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 September / Simtel20_Sept92.cdr / msdos / hypertxt / hyperrez.arc / HRCTP.ARC / HRCTP1.PAS < prev   
Pascal/Delphi Source File  |  1989-03-08  |  6KB  |  217 lines

  1. {
  2.   HRPATCH.PAS  Version 1.3
  3.   08 March 1989
  4.   Written by David Gwillim  
  5.  
  6.   Released to the Public Domain.
  7.  
  8.            *** Compile with Turbo Pascal version 4.0 or 5.0 ***
  9.  
  10.   The purpose of this utility fix a bug in the testing for a valid video
  11.   mode for HR to pop-up during and to permit the alteration of the
  12.   characters used to delimit the hypertext link fields in HyperRez files
  13.   in the event that conflict arises out of the use of the standard '<'
  14.   and '>'. The program is specific to a particular version of HR.EXE as
  15.   the characters are hard coded in the program. For other versions of
  16.   the program the typed constants VidCheck, StartPos, EndPos and
  17.   HRfilesize would have to be appropriately altered.
  18.  
  19.   (*
  20.   Ideas for possible character pairs for hyperlink field delimeters:
  21.  
  22.           <LINK00>        >LINK00<
  23.           (LINK00)        )LINK00(
  24.           [LINK00]        ]LINK00[
  25.           ≤LINK00≥        ≥LINK00≤
  26.           ▌LINK00▐        ▐LINK00▌
  27.           «LINK00»        «LINK00»
  28.           ≡LINK00■        ■LINK00≡
  29.           ∙LINK00·        ·LINK00∙
  30.           ⌡LINK00⌠        ⌠LINK00⌡
  31.           ⌐LINK00¬        ¬LINK00⌐
  32.           ┌LINK00┐        ┐LINK00┌
  33.           °LINK00º        ºLINK00°
  34.           ∞LINK00        LINK00∞
  35.           LINK00        LINK00
  36.           LINK00        LINK00
  37.           LINK00        LINK00
  38.  
  39.   *)
  40.   Byte Sequences to look for in the HR.EXE file to locate the
  41.   offsets where the constant values for '<' and '>' are located:
  42.  
  43.                              HRCT1 (HRN.EXE  17903  3-06-89  10:40p)
  44.   '<' (03CH)                 
  45.       74 0E 3C [3C] 75 EA    0A43
  46.          80 3F [3C] 75 ED    106E
  47.       8B EC B8 [3C] 00 50    12D8
  48.       74 2B B8 [3C] 00 50    1336
  49.          80 3C [3C] 75 15    14D6
  50.          80 3F [3C] 75 09    16D9
  51.          80 38 [3C] 75 A5    173D
  52.          80 3F [3C] 75 E2    1C5F
  53.  
  54.  
  55.   '>' (03EH)
  56.       74 34 3C [3E] 75 EA    0A1D
  57.          80 3F [3E] 75 ED    1050
  58.       74 2B B8 [3E] 00 50    12EE
  59.       8B EC B8 [3E] 00 50    1320
  60.          80 3D [3E] 75 09    14E2
  61.          80 3F [3E] 74 07    16E2
  62.          80 38 [3E] 75 9C    1746
  63.          80 3F [3E] 75 E2    1C88
  64.  
  65.    FileSize                 17903
  66.  
  67.    Video mode test bug correction patch (won't pop up in modes 2, 1 or 0)
  68.    byte sequence to look for:
  69.  
  70.                              HRCT
  71.  
  72.       3D 03 00 [74] 05       295B    code for a JE instruction
  73.  
  74.       patch to
  75.  
  76.       3D 03 00 [7E] 05               code for a JLE instruction
  77.  
  78.  
  79.   }
  80.  
  81. const
  82.    {The StartPos and EndPos arrays contain the file offsets of the
  83.     occurrences in the HyperRez program code where the hypertext
  84.     link delimeter characters (normally '<' and '>') occur.}
  85.    { Current version 6 values }
  86.    StartPos : array[1..8] of word = ($0A43,$106E,$12D8,$1336,$14D6,$16D9,$173D,$1C5F);
  87.    EndPos   : array[1..8] of word = ($0A1D,$1050,$12EE,$1320,$14E2,$16E2,$1746,$1C88);
  88.  
  89.    { for patching error in video mode check }
  90.    VidCheck : word = ($295B);
  91.    Jle : byte = $7E;   { Jump Less than or equal to CPU instruction }
  92.  
  93.    {HRfilesize is the length of the HyperRez program file for
  94.     which the above offsets are valid}
  95.    HRfilesize : word = 17903;
  96.  
  97. var
  98.    F : file of char;
  99.    Ch : char;
  100.    StartChStr,EndChStr : string[3];
  101.    StartCh,EndCh : char;
  102.    Fname : string[65];
  103.    Fposn : word;
  104.  
  105. procedure ShowDelimeters(Msg : string);
  106. begin
  107.    write(Msg);
  108.    for Fposn := 1 to 8 do
  109.    begin
  110.       seek(F,StartPos[Fposn]);
  111.       read(F,Ch);
  112.       write(Ch);
  113.    end;
  114.    for Fposn := 1 to 8 do
  115.    begin
  116.       seek(F,EndPos[Fposn]);
  117.       read(F,Ch);
  118.       write(Ch);
  119.    end;
  120.    writeln;
  121. end;
  122.  
  123. procedure ShowUsage;
  124. begin
  125.    writeln('     Usage: HRPATCH PROGNAME.EXE START END');
  126.    writeln('     Where START and END are the ASCII values');
  127.    writeln('     of the characters to be used as hypertext');
  128.    writeln('     link field delimeters for HyperRez.');
  129.    Halt;
  130. end;
  131.  
  132. procedure SetDelimeters;
  133. var
  134.    Tmp : byte;
  135.    Err : integer;
  136.    BadNumber : boolean;
  137. begin
  138.    BadNumber := False;
  139.    if (StartChStr = '') or (EndChStr = '') then
  140.       ShowUsage;
  141.    Val(StartChStr,Tmp,Err);
  142.    if (Err = 0) and (Tmp <> 0) then
  143.       StartCh := char(Tmp)
  144.    else
  145.       BadNumber := True;
  146.    Val(EndChStr,Tmp,Err);
  147.    if (Err = 0) and (Tmp <> 0) then
  148.       EndCh := char(Tmp)
  149.    else
  150.       BadNumber := True;
  151.    if BadNumber then
  152.    begin
  153.       writeln('The ASCII values for Start and End characters');
  154.       writeln('must be in the range 1..255');
  155.       writeln('File ',Fname,' not changed.');
  156.       Halt;
  157.    end;
  158.    if StartCh = EndCh then
  159.    begin
  160.       writeln('The starting and ending characters may not be the same.');
  161.       writeln('File ',Fname,' not changed.');
  162.       Halt;
  163.    end;
  164.    for Fposn := 1 to 8 do
  165.    begin
  166.       seek(F,StartPos[Fposn]);
  167.       write(F,StartCh);
  168.    end;
  169.    for Fposn := 1 to 8 do
  170.    begin
  171.       seek(F,EndPos[Fposn]);
  172.       write(F,EndCh);
  173.    end;
  174.    ShowDelimeters('    New delimeters: ');
  175.    writeln;
  176.    writeln('Patching video mode check so HyperRez works with');
  177.    writeln('text video modes 0, 1 and 2 as well as 3 and 7.');
  178.    Seek(F,VidCheck);
  179.    write(F,char(Jle));
  180.    close(F);
  181. end;
  182.  
  183. procedure Initialize;
  184. begin
  185.    writeln('┌──────────────────────────────────────────────────┐');
  186.    writeln('│ HyperRez Patch Program Version 1.2 - 03 Mar 1989 │');
  187.    writeln('│      Written by David Gwillim for HRCT.EXE       │');
  188.    writeln('└──────────────────────────────────────────────────┘');
  189.    writeln;
  190.    Fname := ParamStr(1);
  191.    if Fname = '' then
  192.       ShowUsage;
  193.    assign(F,Fname);
  194.    {$I-}
  195.    reset(F);
  196.    {$I+}
  197.    if IOresult <> 0 then
  198.    begin
  199.       writeln('File not found: ',Fname);
  200.       Halt;
  201.    end;
  202.    if FileSize(F) <> HRfilesize then
  203.    begin
  204.       writeln('Internal values unsuitable for configuring ',Fname,'.');
  205.       writeln('You will need to recompile HRPATCH.PAS with updated information.');
  206.       Halt;
  207.    end;
  208.    ShowDelimeters('Current delimeters: ');
  209.    StartChStr := ParamStr(2);
  210.    EndChStr := ParamStr(3);
  211. end;
  212.  
  213. begin
  214.    Initialize;
  215.    SetDelimeters;
  216. end.
  217.