
PROCEDURE Set800x600 (ModeNo : Byte; ScrMaxX,ScrMaxY : Word);

TYPE
   ModeTableT      =  record
                         Nuls,X1,Y1,X2,Y2,W1,W2    :  word;
                         Aspect,W3,ColorMode       :  word;
                      end;
   BgiT            =  record
                         ID,Backspaces             :  array[1..2] of byte;
                         Copyrite                  :  array[1..95] of byte;
                         CtrlZ                     :  byte;
                         Offset1,DriverNo1,Length1 :  word;
                         Version1,What1            :  word;
                         Nuls0                     :  array[1..18] of byte;
                         Offset2,DriverNo2,Length2 :  word;
                         Version2,What2            :  word;
                         DriverName                :  string[6];
                         Nuls1                     :  array[1..15] of byte;
                         Dispatcher                :  array[1..12] of byte;
                         Nuls2                     :  array[1..4] of byte;
                         Return1                   :  Byte;
                         Nuls3                     :  array[1..4] of byte;
                         Return2                   :  byte;
                         Functions                 :  array[0..45] of word;
                         Code1                     :  array[1..514] of byte;
                         Mode1String               :  string[13];
                         Nuls4                     :  byte;
                         Mode2String               :  string[13];
                         Nuls5                     :  byte;
                         Mode3String               :  string[13];
                         Nuls6                     :  byte;
                         Mode4String               :  string[18];
                         Nuls7                     :  byte;
                         ModeTablAdr               :  array[1..4] of word;
                         Mode1Table                :  ModeTableT;
                         Mode2Table                :  ModeTableT;
                         Mode3Table                :  ModeTableT;
                         Mode4Table                :  ModeTableT;
                         What3                     :  word;
                         SetModeAdrs               :  array[1..4] of word;
                         Code2                     :  array[1..445] of byte;
                         MaxX1,MaxY1               :  word;
                         SavTable1                 :  array[1..11] of byte;
                         SavSegment                :  word;
                         SavMode                   :  byte;
                         Code3                     :  array[1..8] of byte;
                         Mul80_1                   :  array[1..14] of byte;
                         Code4                     :  array[1..23] of byte;
                         Code5                     :  byte;
                         MaxY2                     :  word;
                         Code6                     :  byte;
                         ModeNo1                   :  byte;
                         Code7                     :  array[1..4] of byte;
                         Cols1                     :  byte;
                         Code8                     :  array[1..2] of byte;
                         BufSize1                  :  word;
                         Code9                     :  array[1..3] of byte;
                         MaxY3                     :  word;
                         Code10                    :  byte;
                         ModeNo2                   :  byte;
                         Code11                    :  byte;
                         BufSize2                  :  word;
                         Code12                    :  array[1..3] of byte;
                         MaxY4                     :  word;
                         Code13                    :  byte;
                         ModeNo3                   :  byte;
                         Code14                    :  array[1..3] of byte;
                         MaxY5                     :  word;
                         Code15                    :  byte;
                         ModeNo4                   :  byte;
                         Code16                    :  array[1..3] of byte;
                         MaxY6                     :  word;
                         Code17                    :  byte;
                         ModeNo5                   :  byte;
                         Code18                    :  byte;
                         BufSize3                  :  word;
                         Code19                    :  array[1..3] of byte;
                         BufSize4                  :  word;
                         Code20                    :  array[1..4] of byte;
                         Cols2                     :  byte;
                         Code21                    :  array[1..5] of byte;
                         MaxX2                     :  word;
                         Code22                    :  array[1..5] of byte;
                         MaxX3                     :  word;
                         Code23                    :  array[1..70] of byte;
                         Segment1                  :  word;
                         Code24                    :  array[1..196] of byte;
                         Mul80_2                   :  array[1..16] of byte;
                         Code25                    :  array[1..82] of byte;
                         Cols3                     :  byte;
                         Code26                    :  array[1..70] of byte;
                         Cols4                     :  byte;
                         Code27                    :  array[1..53] of byte;
                         Cols5                     :  byte;
                         Code28                    :  array[1..69] of byte;
                         Cols6                     :  byte;
                         Code29                    :  array[1..3060] of byte;
                         MaxY7                     :  word;
                         Code30                    :  array[1..5] of byte;
                         JNB2JMP                   :  byte;
                         Code31                    :  array[1..202] of byte;
                      end;

VAR
  BGIData     : ^BgiT;
  ModeTable   : ModeTableT;
  Cols        : Byte;
  BufSize,
  MaxX,MaxY,
  AspectRatio : Word;

BEGIN
  BGIData := @EgaVgaDriverProc;
  MaxX := 799;
  MaxY := 599;
  AspectRatio := 10000;
  Cols := lo((MaxX+1) div 8);
  BufSize := $FFF0;
  MaxX := ScrMaxX-1;
  MaxY := ScrMaxY-1;
  WITH BGIData^ DO BEGIN
      with ModeTable do
      begin
         Nuls := 0;
         X1 := MaxX; X2 := MaxX;
         Y1 := MaxY; Y2 := MaxY;
         W1 := $2328; W2 := $1B58; W3 := $0808;
         Aspect := AspectRatio;
         ColorMode := $9090;
      end;
      Mode1Table := ModeTable; Mode2Table := ModeTable;
      Mode3Table := ModeTable; Mode4Table := ModeTable;
      Cols1 := Cols; Cols2 := Cols; Cols3 := Cols; Cols4 := Cols;
      Cols5 := Cols; Cols6 := Cols;
      MaxX1 := MaxX; MaxX2 := MaxX; MaxX3 := MaxX;
      MaxY1 := MaxY; MaxY2 := MaxY; MaxY3 := MaxY; MaxY4 := MaxY;
      MaxY5 := MaxY; MaxY6 := MaxY; MaxY7 := MaxY;
      ModeNo1 := ModeNo; ModeNo2 := ModeNo; ModeNo3 := ModeNo;
      ModeNo4 := ModeNo; ModeNo5 := ModeNo;
      BufSize1 := BufSize;  BufSize2 := BufSize;
      BufSize3 := BufSize;  BufSize4 := BufSize;
      Mul80_1[ 1] := $90;   Mul80_1[ 2] := $90;   Mul80_1[ 3] := $52;
      Mul80_1[ 4] := $B8;   Mul80_1[ 5] := Cols;  Mul80_1[ 6] := $00;
      Mul80_1[ 7] := $F7;   Mul80_1[ 8] := $E7;   Mul80_1[ 9] := $89;
      Mul80_1[10] := $C7;   Mul80_1[11] := $5A;   Mul80_1[12] := $B1;
      Mul80_1[13] := $03;   Mul80_1[14] := $90;
      Mul80_2[ 1] := $52;   Mul80_2[ 2] := $89;   Mul80_2[ 3] := $C7;
      Mul80_2[ 4] := $B8;   Mul80_2[ 5] := Cols;  Mul80_2[ 6] := $00;
      Mul80_2[ 7] := $F7;   Mul80_2[ 8] := $E7;   Mul80_2[ 9] := $89;
      Mul80_2[10] := $C7;   Mul80_2[11] := $5A;   Mul80_2[12] := $90;
      Mul80_2[13] := $90;   Mul80_2[14] := $90;   Mul80_2[15] := $90;
      Mul80_2[16] := $90;
      JNB2JMP := $EB;
  END;
END;

