[comp.binaries.ibm.pc.d] Submission: AT setup program, with TP source

kaldis@gauss.rutgers.edu (Theodore A. Kaldis) (05/17/88)

There is a bug in the code of the AT SETUP program recently posted to the
.binaries group.  When the program exits without making any changes to the
setup, it resets the text mode by calling the Turbo procedure 'TextMode' with
a given parameter of 'LastMode'.  The problem here is that 'LastMode' gets set
to the *last*, **text** mode in use, not the *previous* mode--in this case the
current mode, since it is a text mode.  Since the program resets the mode to
40 column monochrome, calling 'TextMode(LastMode)' merely resets it to the
same mode again.  It is, really, superfluous.

Also (as the author/modifier of the code states), it does not list 720K and
1.44 eg. disks.  Moreover, it will not accommodate the EGA display mode type.

The following changes to the code will correct the bug, display the 3.5" disk
types, and accommodate the EGA:

{--------}

Modify the field range of the parameter list for the display type
 to accommodate the EGA:

     FieldRange: FieldEntList = 
    ([...]
     (PosX: 12; PosY: 20; lowend: 0; hiend: 3; adjust: 1),  { display }
                 { Change lowend from '1' to '0'. } 
     [...])

{--------}

Replace the type definition with the following, to display 3.5" disk types:

     FloppyNames: array[0..15, 1..5] of char = 
     ('none ', '360K ', '1.2M ', '720K ', '1.44M', ' # 5 ', ' # 6 ', ' # 7 ',
      ' # 8 ', ' # 9 ', ' # 10', ' # 11', ' # 12', ' # 13', ' # 14', ' # 15');

{--------}

Replace the type definition with the following to accommodate the EGA:

     DispNames: array[0..3, 1..8] of char = 
     ('EGA     ','Color 40','Color 80','Mono    ');

{--------}

Modify the initialization of the parameter list, so that the attribute
 for the display type is initially 0, indicating EGA:

     DefParams: ParamList =
     ( [...]
      0,        {Di}       { Change this from a '1' to a '0' }
      [...]);

{--------}

Add this line to the variable list to correct the bug:

     OrigMode: word;

{--------}

Replace this procedure with the following to correct the bug:

procedure SaveVideo(var A: byte;var B: Word);
begin
     A := TextAttr;
     B := LastMode
end; {SaveVideo}

{--------}

Replace the main program with the following to correct the bug:

begin {Main}
     SaveVideo(OldAttr,OrigMode);
     Initialize;
     Process;
     if SaveChanges then
          Terminate
     else
          TextMode(OrigMode);
     RestoreVideo(OldAttr);
end. {Main}
-- 
----------------------------------------------------------------------------
    Theodore A. Kaldis       |    kaldis@gauss.rutgers.edu
    P.O. Box #1212           |    {...}!rutgers!gauss.rutgers.edu!kaldis
    Woodbridge, NJ  07095    |    (201) 283-4855  (voice)
----------------------------------------------------------------------------