home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_PAS / TPPCX256.ZIP / UBGI256.PAS < prev    next >
Pascal/Delphi Source File  |  1993-12-21  |  2KB  |  87 lines

  1. {define VGA256 to link BGI256.OBJ driver}
  2. {NOTE: do not simultaneously link above with link in uVESA.TPU}
  3. {A+,B-,D-,G+,I-,L-,Q-,R-,S-,Y-}
  4. unit UBGI256;
  5. interface
  6.  
  7. CONST
  8.     Mode200  = 0;  {320x200x256}
  9.   Mode400  = 1;  {640x400x256}
  10.   Mode480  = 2;  {640x480x256}
  11.   Mode600  = 3;  {800x600x256}
  12.   Mode768  = 4;  {1024x768x256}
  13. {
  14.   if using VESA object, call any VESA mode methods with
  15.     the Vesa_Modes[Pred( <above graphmode constant> )] array.
  16.   The above modes are not strictly VESA, Only modes 1-4, so
  17.   the Vesa_Modes array is not in sync with the above constants.
  18.   ie: Vesa_Modes[0] is 640x400x256 which is this BGI's mode 1;
  19. }
  20. procedure InitBGI_BGI256;
  21. {The following function is used to sync the Vesa object with
  22.  the BGI driver, see EOF for example call}
  23. function Equate_VESAMode(CurrentMode: integer): integer;
  24.  
  25. implementation
  26. uses graph, Crt;
  27.  
  28. var
  29.   OldExitProc: pointer;
  30.  
  31. { This returns an index to the VESA_Modes array in UVESA unit
  32.     to match VESA hex mode number to the BGI256 driver mode }
  33. function Equate_VESAMode(CurrentMode: integer): integer;
  34. begin    Equate_VESAMode := Pred(CurrentMode); end;
  35.  
  36. {$ifdef VGA256 }
  37. procedure BGI256Proc; external;
  38. {$L BGI256.OBJ }
  39. {$endif}
  40.  
  41. function AutoDetect: integer; far;
  42. begin AutoDetect := 127; end;
  43.  
  44. procedure BGIExitProc; far;
  45. begin
  46.   ExitProc := OldExitProc;
  47.   Closegraph;
  48. end;
  49.  
  50. procedure InitBGI_BGI256;
  51. const
  52.   PathtoDriver: string = '\BP\BGI';
  53. var
  54.   Driver, Mode, Error: integer;
  55.  
  56.   function Ok: boolean;
  57.   begin Ok := GraphResult = grOk; end;
  58.  
  59. begin
  60.   OldExitProc := ExitProc;
  61.   ExitProc := @BGIExitProc;
  62.   DirectVideo := false;
  63.   Driver := InstallUserDriver('BGI256', @AutoDetect);
  64.   if not Ok then Exit;
  65.   {$ifdef VGA256}
  66.     if RegisterBGIDriver(@BGI256Proc) < 0 then Exit;
  67.   {$endif}
  68.   Driver := Detect;
  69.   InitGraph(Driver, Mode, PathToDriver);
  70.   if not OK then
  71.   begin
  72.       Writeln('ERROR: Unable to initialize graphics.');
  73.       Halt;
  74.   end;
  75. end;
  76.  
  77. end.
  78.  
  79. { typical program call---
  80.   Adapter := New(PVesa, Init);
  81.   InitBGI_BGI256;
  82.   SetGraphMode(Mode480);
  83.   ...now set Adapter instance in sync with BGI...
  84.   Adapter^.SetVesaMode(Vesa_Modes[Equate_VesaMode(Mode480)]);
  85.   -or-
  86.   Adapter^.GetStateInfo; (if in 13h)
  87. }