/* */

call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
call SysCls

call SysCurState OFF

No   = d2c(27)'[0;40;37m'
Yes  = d2c(27)'[1;40;33m'
Freq = d2c(27)'[1;40;32m'

dsc.2 = 'al480a.dsc'
dsc.3 = 'al600.dsc'
dsc.4 = 'al768.dsc'

color.1  = Yes
color.2  = No
color.3  = No
color.4  = No

Frr.1 = 0
Frr.2 = 1
Frr.3 = 1
Frr.4 = 1

Fre.1.0 = 0

/* 640 X 480 */
Fre.2.1 = '60 Hz'
Fre.2.2 = '72 Hz'
Fre.2.3 = '75 Hz'

Frc.2.1 = Freq
Frc.2.2 = No
Frc.2.3 = No

Val.2.1 = X2D(00)
Val.2.2 = X2D(02)
Val.2.3 = X2D(04)

Fre.2.0 = 3

/* 800 X 600 */
Fre.3.1 = '56 Hz'
Fre.3.2 = '60 Hz'
Fre.3.3 = '72 Hz'
Fre.3.4 = '75 Hz'

Frc.3.1 = Freq
Frc.3.2 = No
Frc.3.3 = No
Frc.3.4 = No

Val.3.1 = X2D(00)
Val.3.2 = X2D(08)
Val.3.3 = X2D(10)
Val.3.4 = X2D(18)

Fre.3.0 = 4

/* 1024 X 768 */
Fre.4.1 = '43 Hz'
Fre.4.2 = '60 Hz'
Fre.4.3 = '70 Hz'
Fre.4.4 = '72 Hz'
Fre.4.5 = '75 Hz'

Frc.4.1 = Freq
Frc.4.2 = No
Frc.4.3 = No
Frc.4.4 = No
Frc.4.5 = No

Val.4.1 = X2D(00)
Val.4.2 = X2D(20)
Val.4.3 = X2D(40)
Val.4.4 = X2D(60)
Val.4.5 = X2D(80)

Fre.4.0 = 5

SelCor = 1
Ch = 'M'

Select.1 = 'Standard VGA'
Select.2 = '640 X 480'
Select.3 = '800 X 600'
Select.4 = '1024 X 768'

Select.0 = 4

      say d2c(27)'[1;40;31m'
say '                             Avance Logic, Inc.'
say ''
say '                         Display Driver Mode Select'
say ''

do until wordpos(Ch, 'K M H P') = 0
     do i = 1 to Select.0
       col = i * 16
       col = col - 8
       say color.i
       parse value  SysCurPos( 6, col ) with row col
       say Select.i
     end
     do i = 2 to 4
       col = i * 16
       col = col - 6
       do j = 1 to Fre.i.0
          row = j * 2
          row = row + 8
          say frc.i.j
          parse value  SysCurPos( row, col ) with row col1
          say fre.i.j
       end
     end
     Ch=SysGetKey('NOECHO')
     if Ch='à' then
     Do
       Ch=SysGetKey('NOECHO')
       if Ch = 'K' then
       Do
         color.SelCor = No
         SelCor = SelCor - 1
         if SelCor = 0 then SelCor = 4
         color.SelCor = Yes
       End
       if Ch = 'M' then
       Do
         color.SelCor = No
         SelCor = SelCor + 1
         if SelCor = 5 then SelCor = 1
         color.SelCor = Yes
       End
       if Ch = 'H' then
       Do
         CC=Frr.SelCor
         Frc.SelCor.CC = No
         Frr.SelCor = Frr.SelCor - 1
         if Frr.SelCor = 0 then Frr.SelCor = Fre.SelCor.0
         CC=Frr.SelCor
         Frc.SelCor.CC = Freq
       End
       if Ch = 'P' then
       Do
         CC=Frr.SelCor
         Frc.SelCor.CC = No
         Frr.SelCor = Frr.SelCor + 1
         if Frr.SelCor > Fre.SelCor.0 then Frr.SelCor = 1
         CC=Frr.SelCor
         Frc.SelCor.CC = Freq
       End
     End
END
call SysCurState ON
Value = 0
do i = 2 to 4
   CC = Frr.i
   Value = Value + Val.i.CC
end
say No
if SelCor = 1 then
  Do
      '@rspdspi /pk:VGA /sk:none /s:c:\os2\install\vga /pd:c:\os2\install\psvga32.dsc'
      exit
  End
else
  Do
      call CheckDrv
      '@select 'Value
      '@rspdspi /pd:'dsc.SelCor' /s:. /sk:none'
  End
call SysCls
Return
CheckDrv: Procedure
     '@dir c:\os2\dll\ibmvga32.dll | find "4-03-95" >nul'
     if rc <> 0 then
        do
           '@rspdspi /pd:install.dsc /s:. /sk:none'
        end
Return
