home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / TVAPP / APP28.PAS next >
Pascal/Delphi Source File  |  1993-09-30  |  3KB  |  104 lines

  1. unit App28;
  2.  
  3. { ---->>>> TApp28 <<<<--------------------------------------
  4.  
  5.   Last Update: 9/29/93
  6.   Author: Ed Jordan
  7.  
  8.                      --- WHAT IS IT? ---
  9.    TApp28 is a descendent of TApplication that can switch to a
  10.    28 line text mode (using an EGA 8x14 font) on VGA adaptors.
  11.    Since TApp28 checks for the presence of a VGA adaptor before
  12.    it activates 28-line mode, it should operate normally on other 
  13.    adaptors.
  14.  
  15.                      --- WHY USE IT? ---
  16.    Use TApp28 to squeeze in a few extra lines of text without 
  17.    resorting to the overly small 8x8, 50 line font.  Also use it
  18.    to give another video "option" to users of your programs.
  19.  
  20.                   --- HOW DO YOU USE IT? ---
  21.    1. List this unit in the USES clause of your TurboVision program.
  22.    2. Descend your application object from TApp28.
  23.    3. When you want to set the screen to 28-line mode, call
  24.  
  25.              SetScreenMode(ScreenMode or smFont8x14);
  26.  
  27.       See the HandleEvent method in the code for the demo program 
  28.       TEST28.PAS for another example of how to use SetScreenMode.
  29.  
  30.    (smFont8x14 is a constant defined in this unit.  It has no 
  31.    other meaning to TurboVision 2.0.)
  32.   ------------------------------------------------------------ }
  33.  
  34. interface
  35. uses Objects, App;
  36.  
  37.  
  38. { This constant may be incompatible with future TV versions.}
  39. const smFont8x14 = $0200;  
  40.  
  41. type
  42.   TApp28 = object(TApplication)
  43.     procedure SetScreenMode (Mode: Word); virtual;
  44.   end;
  45.  
  46. function VGADetected: Boolean;
  47.  
  48.  
  49.  
  50. implementation
  51. uses Dos, Drivers;
  52.  
  53.  
  54. { The Mouse driver divides each row into 8 vertical steps.}
  55. const MousePoints = 8;  
  56.  
  57. function VGADetected: Boolean;
  58. var Regs: Registers;
  59. begin
  60.   Regs.AX := $1A00;             { Read display codes function.}
  61.   Intr($10,Regs); 
  62.   VGADetected := Regs.AL = $1A;
  63. end;
  64.  
  65. procedure TApp28.SetScreenMode;
  66. var
  67.   CrtRows: byte absolute $0040:$0084;   { BIOS variable.}
  68.   Regs: Registers;
  69.   R: TRect;
  70. begin
  71.   { If 28 lines NOT requested, use inherited method only.}
  72.   if Mode and smFont8x14 = 0 then
  73.     TApplication.SetScreenMode(Mode)
  74.   { If 28 lines requested, use inherited, then make adjustments.}
  75.   else begin
  76.     TApplication.SetScreenMode(Mode and not smFont8x14);
  77.     if VGADetected then 
  78.     begin
  79.       ScreenMode := ScreenMode or smFont8x14;
  80.       HideMouse;
  81.       { Load 8x14 font.}
  82.       Regs.AX := $1111;                      { AL=$11 loads 8x14.}
  83.       Regs.BL := 0;                          { Load table 0.}
  84.       Intr($10,Regs);
  85.       { Update screen height variables.}
  86.       ScreenHeight := 28;                    { Update TV variable.}
  87.       CrtRows := 28;                         { Update BIOS variable.}
  88.       { Tell mouse that screen is deeper.}
  89.       if ButtonCount > 0 then                  { If mouse present...}
  90.       begin
  91.         Regs.AX := $0008;                      { Set mouse Y limits.}
  92.         Regs.CX := 0;                          { Minimum Y.}
  93.         Regs.DX := MousePoints*ScreenHeight-1; { Maximum Y.}
  94.         Intr($33,Regs);
  95.       end;
  96.       ShowMouse;
  97.       { Change bounds of application.}
  98.       R.Assign(0,0,ScreenWidth,ScreenHeight);
  99.       ChangeBounds(R);
  100.     end;
  101.   end;
  102. end;
  103.  
  104. end.