Browse Source

+ Merged driver support from fixbranch

michael 24 years ago
parent
commit
148dbc6022
6 changed files with 392 additions and 120 deletions
  1. 59 32
      rtl/go32v2/video.pp
  2. 136 1
      rtl/inc/video.inc
  3. 32 2
      rtl/inc/videoh.inc
  4. 63 46
      rtl/os2/video.pp
  5. 52 13
      rtl/unix/video.pp
  6. 50 26
      rtl/win32/video.pp

+ 59 - 32
rtl/go32v2/video.pp

@@ -4,7 +4,7 @@
     Copyright (c) 1999-2000 by Florian Klaempfl
     Copyright (c) 1999-2000 by Florian Klaempfl
     member of the Free Pascal development team
     member of the Free Pascal development team
 
 
-    Video unit for linux
+    Video unit for DOS
 
 
     See the file COPYING.FPC, included in this distribution,
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
     for details about the copyright.
@@ -58,9 +58,11 @@ var r: trealregs;
     L: longint;
     L: longint;
     LSel,LSeg: word;
     LSel,LSeg: word;
     B: array[0..63] of byte;
     B: array[0..63] of byte;
-type TWord = word; PWord = ^TWord;
-var Size: word;
-    OK: boolean;
+type
+  TWord = word;
+  PWord = ^TWord;
+var
+  OK: boolean;
 begin
 begin
   L:=global_dos_alloc(64);
   L:=global_dos_alloc(64);
   LSeg:=(L shr 16);
   LSeg:=(L shr 16);
@@ -80,7 +82,7 @@ begin
   BIOSGetScreenMode:=OK;
   BIOSGetScreenMode:=OK;
 end;
 end;
 
 
-procedure InitVideo;
+procedure SysInitVideo;
 var
 var
   regs : trealregs;
   regs : trealregs;
 begin
 begin
@@ -122,7 +124,6 @@ begin
   VideoBufSize:=ScreenWidth*ScreenHeight*2;
   VideoBufSize:=ScreenWidth*ScreenHeight*2;
   GetMem(VideoBuf,VideoBufSize);
   GetMem(VideoBuf,VideoBufSize);
   GetMem(OldVideoBuf,VideoBufSize);
   GetMem(OldVideoBuf,VideoBufSize);
-  InitVideoCalled:=true;
   SetHighBitBlink;
   SetHighBitBlink;
   SetCursorType(LastCursorType);
   SetCursorType(LastCursorType);
   { ClearScreen; removed here
   { ClearScreen; removed here
@@ -130,31 +131,27 @@ begin
 end;
 end;
 
 
 
 
-procedure DoneVideo;
+procedure SysDoneVideo;
 begin
 begin
-  If InitVideoCalled then
-    Begin
-      LastCursorType:=GetCursorType;
-      ClearScreen;
-      SetCursorType(crUnderLine);
-      SetCursorPos(0,0);
-      FreeMem(VideoBuf,VideoBufSize);
-      VideoBuf:=nil;
-      FreeMem(OldVideoBuf,VideoBufSize);
-      OldVideoBuf:=nil;
-      InitVideoCalled:=false;
-      VideoBufSize:=0;
-    End;
+  LastCursorType:=GetCursorType;
+  ClearScreen;
+  SetCursorType(crUnderLine);
+  SetCursorPos(0,0);
+  FreeMem(VideoBuf,VideoBufSize);
+  VideoBuf:=nil;
+  FreeMem(OldVideoBuf,VideoBufSize);
+  OldVideoBuf:=nil;
+  VideoBufSize:=0;
 end;
 end;
 
 
 
 
-function GetCapabilities: Word;
+function SysGetCapabilities: Word;
 begin
 begin
-  GetCapabilities := $3F;
+  SysGetCapabilities := $3F;
 end;
 end;
 
 
 
 
-procedure SetCursorPos(NewCursorX, NewCursorY: Word);
+procedure SysSetCursorPos(NewCursorX, NewCursorY: Word);
 var
 var
   regs : trealregs;
   regs : trealregs;
 begin
 begin
@@ -170,28 +167,28 @@ end;
 { I don't know the maximum value for the scan line
 { I don't know the maximum value for the scan line
   probably 7 or 15 depending on resolution !!
   probably 7 or 15 depending on resolution !!
   }
   }
-function GetCursorType: Word;
+function SysGetCursorType: Word;
 var
 var
   regs : trealregs;
   regs : trealregs;
 begin
 begin
   regs.ah:=$03;
   regs.ah:=$03;
   regs.bh:=0;
   regs.bh:=0;
   realintr($10,regs);
   realintr($10,regs);
-  GetCursorType:=crHidden;
+  SysGetCursorType:=crHidden;
   if (regs.ch and $60)=0 then
   if (regs.ch and $60)=0 then
    begin
    begin
-     GetCursorType:=crBlock;
+     SysGetCursorType:=crBlock;
      if (regs.ch and $1f)<>0 then
      if (regs.ch and $1f)<>0 then
       begin
       begin
-        GetCursorType:=crHalfBlock;
+        SysGetCursorType:=crHalfBlock;
         if regs.cl+1=(regs.ch and $1F) then
         if regs.cl+1=(regs.ch and $1F) then
-         GetCursorType:=crUnderline;
+         SysGetCursorType:=crUnderline;
       end;
       end;
    end;
    end;
 end;
 end;
 
 
 
 
-procedure SetCursorType(NewType: Word);
+procedure SysSetCursorType(NewType: Word);
 var
 var
   regs : trealregs;
   regs : trealregs;
 const
 const
@@ -254,14 +251,14 @@ begin
   DoCustomMouse(false);
   DoCustomMouse(false);
 end;
 end;
 
 
-procedure ClearScreen;
+procedure SysClearScreen;
 begin
 begin
   FillWord(VideoBuf^,VideoBufSize shr 1,$0720);
   FillWord(VideoBuf^,VideoBufSize shr 1,$0720);
   UpdateScreen(true);
   UpdateScreen(true);
 end;
 end;
 
 
 
 
-procedure UpdateScreen(Force: Boolean);
+procedure SysUpdateScreen(Force: Boolean);
 begin
 begin
   if LockUpdateScreen<>0 then
   if LockUpdateScreen<>0 then
    exit;
    exit;
@@ -294,8 +291,22 @@ begin
   RegisterVideoMode(80, 50, True, @VideoModeSelector8x8, 0);
   RegisterVideoMode(80, 50, True, @VideoModeSelector8x8, 0);
 end;
 end;
 
 
+Const
+  SysVideoDriver : TVideoDriver = (
+    InitDriver : @SysInitVideo;
+    DoneDriver : @SysDoneVideo;
+    UpdateScreen : @SysUpdateScreen;
+    ClearScreen : @SysClearScreen;
+    SetVideoMode : Nil;
+    HasVideoMode : Nil;
+    SetCursorPos : @SysSetCursorPos;
+    GetCursorType : @SysGetCursorType;
+    SetCursorType : @SysSetCursorType;
+    GetCapabilities : @SysGetCapabilities
+  );
 
 
 initialization
 initialization
+  SetVideoDriver(SysVideoDriver);
   RegisterVideoModes;
   RegisterVideoModes;
 
 
 finalization
 finalization
@@ -303,9 +314,25 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2001-05-09 19:53:28  peter
+  Revision 1.3  2001-09-21 19:50:18  michael
+  + Merged driver support from fixbranch
+
+
+  Revision 1.2  2001/05/09 19:53:28  peter
     * removed asm for copy, use dosmemput (merged)
     * removed asm for copy, use dosmemput (merged)
 
 
+  Revision 1.1.2.4  2001/09/21 18:42:08  michael
+  + Implemented support for custom video drivers.
+
+  Revision 1.1.2.3  2001/05/06 21:54:23  carl
+  * bugfix of Windows NT double exception crash
+
+  Revision 1.1.2.2  2001/04/16 10:56:13  peter
+    * fixes for stricter compiler
+
+  Revision 1.1.2.1  2001/01/30 21:52:01  peter
+    * moved api utils to rtl
+
   Revision 1.1  2001/01/13 11:03:58  peter
   Revision 1.1  2001/01/13 11:03:58  peter
     * API 2 RTL commit
     * API 2 RTL commit
 
 

+ 136 - 1
rtl/inc/video.inc

@@ -12,6 +12,128 @@
 
 
  **********************************************************************}
  **********************************************************************}
 
 
+Const
+  LockUpdateScreen : Integer = 0;
+
+Procedure LockScreenUpdate;
+
+begin
+  Inc(LockUpdateScreen);
+end;
+
+Procedure UnLockScreenUpdate;
+
+begin
+  Dec(LockUpdateScreen);
+end;
+
+Var 
+  CurrentVideoDriver : TVideoDriver;
+
+Const
+  VideoInitialized : Boolean = False;
+  
+Procedure SetVideoDriver (Const Driver : TVideoDriver);
+{ Sets the videodriver to be used }
+begin
+  If Not VideoInitialized then
+    CurrentVideoDriver:=Driver;
+end;
+
+Procedure GetVideoDriver (Var Driver : TVideoDriver);
+{ Retrieves the current videodriver }                                           
+begin
+  Driver:=CurrentVideoDriver;
+end;
+
+{ ---------------------------------------------------------------------
+  External functions that use the video driver.
+  ---------------------------------------------------------------------}
+
+Procedure InitVideo;
+
+begin
+  If Not VideoInitialized then
+    begin
+    If Assigned(CurrentVideoDriver.InitDriver) then
+      CurrentVideoDriver.InitDriver;
+    VideoInitialized:=True;  
+    end;  
+end;
+
+Procedure DoneVideo;
+
+begin
+  If VideoInitialized then
+    begin
+    If Assigned(CurrentVideoDriver.DoneDriver) then
+      CurrentVideoDriver.DoneDriver;
+    VideoInitialized:=False;  
+    end;  
+end;
+
+Procedure UpdateScreen (Force : Boolean);
+
+begin
+  If (LockUpdateScreen<=0) and
+     Assigned(CurrentVideoDriver.UpdateScreen) then
+      CurrentVideoDriver.UpdateScreen(Force);  
+end;
+
+Procedure ClearScreen;
+
+begin
+  If Assigned(CurrentVideoDriver.ClearScreen) then
+    CurrentVideoDriver.ClearScreen
+  else
+    begin
+    FillWord(VideoBuf^,VideoBufSize shr 1,$0720);
+    UpdateScreen(True);
+    // Is this needed ? 
+    {
+    CurrentX:=1;
+    CurrentY:=1;
+    }
+    end;
+end;
+
+Procedure SetCursorType (NewType : Word);
+
+begin
+  if Assigned(CurrentVideoDriver.SetCursorType) then
+    CurrentVideoDriver.SetCursorType(NewType)
+end;
+
+Function GetCursorType : Word;
+
+begin
+  if Assigned(CurrentVideoDriver.GetCursorType) then
+    GetCursorType:=CurrentVideoDriver.GetCursorType()
+  else
+    GetCursorType:=0;
+end;
+
+procedure SetCursorPos(NewCursorX, NewCursorY: Word);
+
+begin
+  If Assigned(CurrentVideoDriver.SetCursorPos) then
+    CurrentVideoDriver.SetCursorPos(NewCursorX, NewCursorY)
+end;
+
+function GetCapabilities: Word;
+begin
+  If Assigned(CurrentVideoDriver.GetCapabilities) then
+    GetCapabilities:=CurrentVideoDriver.GetCapabilities()
+  else
+    GetCapabilities:=0;  
+end;
+    
+
+{ ---------------------------------------------------------------------
+    General functions
+  ---------------------------------------------------------------------}
+  
+
 procedure GetVideoMode(var Mode: TVideoMode);
 procedure GetVideoMode(var Mode: TVideoMode);
 begin
 begin
   Mode.Col := ScreenWidth;
   Mode.Col := ScreenWidth;
@@ -19,6 +141,8 @@ begin
   Mode.Color := ScreenColor;
   Mode.Color := ScreenColor;
 end;
 end;
 
 
+
+
 procedure SetVideoMode(Mode: TVideoMode);
 procedure SetVideoMode(Mode: TVideoMode);
 var
 var
   P: PVideoModeList;
   P: PVideoModeList;
@@ -72,9 +196,20 @@ begin
   DefaultErrorHandler := errAbort; { return error code }
   DefaultErrorHandler := errAbort; { return error code }
 end;
 end;
 
 
+
+
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2001-01-13 11:13:12  peter
+  Revision 1.2  2001-09-21 19:50:18  michael
+  + Merged driver support from fixbranch
+
+  Revision 1.1.2.2  2001/09/21 18:42:08  michael
+  + Implemented support for custom video drivers.
+
+  Revision 1.1.2.1  2001/01/30 22:21:22  peter
+    * move api to rtl
+
+  Revision 1.1  2001/01/13 11:13:12  peter
     * API 2 RTL
     * API 2 RTL
 
 
 }
 }

+ 32 - 2
rtl/inc/videoh.inc

@@ -26,6 +26,19 @@ type
   TVideoBuf = array[0..32759] of TVideoCell;
   TVideoBuf = array[0..32759] of TVideoCell;
   PVideoBuf = ^TVideoBuf;
   PVideoBuf = ^TVideoBuf;
 
 
+  TVideoDriver = Record
+    InitDriver      : Procedure;
+    DoneDriver      : Procedure;
+    UpdateScreen    : Procedure(Force : Boolean);
+    ClearScreen     : Procedure;
+    SetVideoMode    : Procedure (Const Mode : TVideoMode; Params : Longint);
+    HasVideoMode    : Function (Const Mode : TVideoMode; Params : Longint) : Boolean; 
+    SetCursorPos    : procedure (NewCursorX, NewCursorY: Word);
+    GetCursorType   : function : Word;
+    SetCursorType   : procedure (NewType: Word);
+    GetCapabilities : Function : Word; 
+  end;
+
 const
 const
   { Foreground and background color constants }
   { Foreground and background color constants }
   Black         = 0;
   Black         = 0;
@@ -80,15 +93,24 @@ var
   ScreenColor  : Boolean;
   ScreenColor  : Boolean;
   CursorX,
   CursorX,
   CursorY      : Word;
   CursorY      : Word;
-  LockUpdateScreen : Word;
   VideoBuf     : PVideoBuf;
   VideoBuf     : PVideoBuf;
   VideoBufSize : Longint;
   VideoBufSize : Longint;
   CursorLines  : Byte;
   CursorLines  : Byte;
+
 const
 const
   LowAscii     : Boolean = true;
   LowAscii     : Boolean = true;
   NoExtendedFrame : Boolean = false;
   NoExtendedFrame : Boolean = false;
   FVMaxWidth = 132;
   FVMaxWidth = 132;
 
 
+Procedure LockScreenUpdate;
+{ Increments the screen update lock count with one.}
+Procedure UnlockScreenUpdate;
+{ Decrements the screen update lock count with one.}
+Procedure SetVideoDriver (Const Driver : TVideoDriver);
+{ Sets the videodriver to be used }
+Procedure GetVideoDriver (Var Driver : TVideoDriver);
+{ Retrieves the current videodriver }
+
 procedure InitVideo;
 procedure InitVideo;
 { Initializes the video subsystem }
 { Initializes the video subsystem }
 procedure DoneVideo;
 procedure DoneVideo;
@@ -152,7 +174,15 @@ const
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2001-06-06 17:20:22  jonas
+  Revision 1.3  2001-09-21 19:50:18  michael
+  + Merged driver support from fixbranch
+
+  Revision 1.2  2001/06/06 17:20:22  jonas
+
+  Revision 1.1.2.3  2001/09/21 18:42:08  michael
+  + Implemented support for custom video drivers.
+
+  Revision 1.1.2.2  2001/06/06 14:27:14  jonas
     * fixed wrong typed constant procvars in preparation of my fix which will
     * fixed wrong typed constant procvars in preparation of my fix which will
       disallow them in FPC mode (plus some other unmerged changes since
       disallow them in FPC mode (plus some other unmerged changes since
       LAST_MERGE)
       LAST_MERGE)

+ 63 - 46
rtl/os2/video.pp

@@ -29,7 +29,6 @@ uses
 
 
 
 
 const
 const
-    InitVideoCalled: boolean = false;
     LastCursorType: word = crUnderline;
     LastCursorType: word = crUnderline;
     EmptyCell: cardinal = $0720;
     EmptyCell: cardinal = $0720;
     OrigScreen: PVideoBuf = nil;
     OrigScreen: PVideoBuf = nil;
@@ -141,41 +140,39 @@ begin
 end;
 end;
 
 
 
 
-procedure InitVideo;
+procedure SysInitVideo;
 
 
 var MI: TVioModeInfo;
 var MI: TVioModeInfo;
 
 
 begin
 begin
-    if InitVideoCalled then
-        FreeMem (OldVideoBuf, VideoBufSize);
-    OldVideoBuf := nil;
-    InitVideoCalled := true;
-    VideoBufSize := 0;
-    MI.cb := SizeOf (MI);
-    VioGetMode (MI, 0);
-    with MI do
-        begin
-            ScreenWidth := Col;
-            ScreenHeight := Row;
-            ScreenColor := Color >= Colors_16;
-        end;
-    VioGetCurPos (CursorY, CursorX, 0);
-    LowAscii := true;
-    SetCursorType (LastCursorType);
-{Get the address of the videobuffer.}
-    if VioGetBuf (VideoBuf, PWord (@VideoBufSize)^, 0) = 0 then
-        begin
-            VideoBuf := SelToFlat (TFarPtr (VideoBuf));
-            SetHighBitBlink (true);
-            GetMem (OldVideoBuf, VideoBufSize);
-            Move (VideoBuf^, OldVideoBuf^, VideoBufSize);
-        end
-    else
-        ErrorHandler (errVioInit, nil);
+  FreeMem (OldVideoBuf, VideoBufSize);
+  OldVideoBuf := nil;
+  VideoBufSize := 0;
+  MI.cb := SizeOf (MI);
+  VioGetMode (MI, 0);
+  with MI do
+      begin
+          ScreenWidth := Col;
+          ScreenHeight := Row;
+          ScreenColor := Color >= Colors_16;
+      end;
+  VioGetCurPos (CursorY, CursorX, 0);
+  LowAscii := true;
+  SetCursorType (LastCursorType);
+{ Get the address of the videobuffer.}
+  if VioGetBuf (VideoBuf, PWord (@VideoBufSize)^, 0) = 0 then
+      begin
+          VideoBuf := SelToFlat (TFarPtr (VideoBuf));
+          SetHighBitBlink (true);
+          GetMem (OldVideoBuf, VideoBufSize);
+          Move (VideoBuf^, OldVideoBuf^, VideoBufSize);
+      end
+  else
+      ErrorHandler (errVioInit, nil);
 end;
 end;
 
 
 
 
-procedure SetCursorPos (NewCursorX, NewCursorY: word);
+procedure SysSetCursorPos (NewCursorX, NewCursorY: word);
 
 
 begin
 begin
     if VioSetCurPos (NewCursorY, NewCursorX, 0) = 0 then
     if VioSetCurPos (NewCursorY, NewCursorX, 0) = 0 then
@@ -191,7 +188,7 @@ begin
 end;
 end;
 
 
 
 
-function GetCursorType: word;
+function SysGetCursorType: word;
 
 
 var CD: TVioCursorInfo;
 var CD: TVioCursorInfo;
 
 
@@ -201,24 +198,24 @@ begin
         begin
         begin
             CursorLines := Succ (cEnd) - yStart;
             CursorLines := Succ (cEnd) - yStart;
             if Attr = word (-1) then
             if Attr = word (-1) then
-                GetCursorType := crHidden
+                SysGetCursorType := crHidden
             else
             else
 {Because the cursor's start and end lines are returned, we'll have
 {Because the cursor's start and end lines are returned, we'll have
  to guess heuristically what cursor type we have.}
  to guess heuristically what cursor type we have.}
                 if CursorLines = 0 then
                 if CursorLines = 0 then
 {Probably this does not occur, but you'll never know.}
 {Probably this does not occur, but you'll never know.}
-                    GetCursorType := crHidden
+                    SysGetCursorType := crHidden
                 else if CursorLines <= Succ (CellHeight div 4) then
                 else if CursorLines <= Succ (CellHeight div 4) then
-                    GetCursorType := crUnderline
+                    SysGetCursorType := crUnderline
                 else if CursorLines <= Succ (CellHeight div 2) then
                 else if CursorLines <= Succ (CellHeight div 2) then
-                    GetCursorType := crHalfBlock
+                    SysGetCursorType := crHalfBlock
                 else
                 else
-                    GetCursorType := crBlock;
+                    SysGetCursorType := crBlock;
         end;
         end;
 end;
 end;
 
 
 
 
-procedure SetCursorType (NewType: word);
+procedure SysSetCursorType (NewType: word);
 
 
 var CD: TVioCursorInfo;
 var CD: TVioCursorInfo;
 
 
@@ -254,14 +251,12 @@ begin
 end;
 end;
 
 
 
 
-procedure DoneVideo;
+procedure SysDoneVideo;
 
 
 var PScr: pointer;
 var PScr: pointer;
     ScrSize: cardinal;
     ScrSize: cardinal;
 
 
 begin
 begin
-    if InitVideoCalled then
-        begin
             LastCursorType := GetCursorType;
             LastCursorType := GetCursorType;
             ClearScreen;
             ClearScreen;
 {Restore original settings}
 {Restore original settings}
@@ -275,7 +270,6 @@ begin
             FreeMem (OldVideoBuf, VideoBufSize);
             FreeMem (OldVideoBuf, VideoBufSize);
             OldVideoBuf := nil;
             OldVideoBuf := nil;
             VideoBufSize := 0;
             VideoBufSize := 0;
-            InitVideoCalled := false;
             if (OrigScreenSize <> 0) and (OrigScreen <> nil) then
             if (OrigScreenSize <> 0) and (OrigScreen <> nil) then
                 begin
                 begin
                     ScrSize := 0;
                     ScrSize := 0;
@@ -287,14 +281,13 @@ begin
                             VioShowBuf (0, ScrSize, 0);
                             VioShowBuf (0, ScrSize, 0);
                         end;
                         end;
                 end;
                 end;
-        end;
 end;
 end;
 
 
 
 
-function GetCapabilities: word;
+function SysGetCapabilities: word;
 
 
 begin
 begin
-    GetCapabilities := $3F;
+  SysGetCapabilities := $3F;
 end;
 end;
 
 
 
 
@@ -352,7 +345,7 @@ begin
 end;
 end;
 
 
 
 
-procedure ClearScreen;
+procedure SysClearScreen;
 
 
 begin
 begin
     VioScrollDn (0, 0, word (-1), word (-1), word (-1), PWord (@EmptyCell)^, 0);
     VioScrollDn (0, 0, word (-1), word (-1), word (-1), PWord (@EmptyCell)^, 0);
@@ -362,7 +355,7 @@ end;
 
 
 {$ASMMODE INTEL}
 {$ASMMODE INTEL}
 
 
-procedure UpdateScreen (Force: boolean);
+procedure SysUpdateScreen (Force: boolean);
 
 
 var SOfs, CLen: cardinal;
 var SOfs, CLen: cardinal;
 
 
@@ -421,7 +414,22 @@ begin
         end;
         end;
 end;
 end;
 
 
+Const
+  SysVideoDriver : TVideoDriver = (
+    InitDriver : @SysInitVideo;
+    DoneDriver : @SysDoneVideo;
+    UpdateScreen : @SysUpdateScreen;
+    ClearScreen : @SysClearScreen;
+    SetVideoMode : Nil;
+    HasVideoMode : Nil;
+    SetCursorPos : @SysSetCursorPos;
+    GetCursorType : @SysGetCursorType;
+    SetCursorType : @SysSetCursorType;
+    GetCapabilities : @SysGetCapabilities
+  );
+
 initialization
 initialization
+  SetVideoDriver(SysVideoDriver);
   RegisterVideoModes;
   RegisterVideoModes;
   TargetEntry;
   TargetEntry;
 
 
@@ -431,9 +439,18 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2001-02-04 01:55:05  hajny
+  Revision 1.5  2001-09-21 19:50:19  michael
+  + Merged driver support from fixbranch
+
+  Revision 1.4  2001/02/04 01:55:05  hajny
     * one more correction (not crucial)
     * one more correction (not crucial)
 
 
+  Revision 1.2.2.3  2001/09/21 18:42:08  michael
+  + Implemented support for custom video drivers.
+
+  Revision 1.2.2.2  2001/02/04 02:02:28  hajny
+    * corrections from the main branch merged
+
   Revision 1.3  2001/02/01 21:35:36  hajny
   Revision 1.3  2001/02/01 21:35:36  hajny
     * correction of a previously introduced bug
     * correction of a previously introduced bug
 
 

+ 52 - 13
rtl/unix/video.pp

@@ -1,5 +1,6 @@
 {
 {
     $Id$
     $Id$
+
     This file is part of the Free Pascal run time library.
     This file is part of the Free Pascal run time library.
     Copyright (c) 1999-2000 by Florian Klaempfl
     Copyright (c) 1999-2000 by Florian Klaempfl
     member of the Free Pascal development team
     member of the Free Pascal development team
@@ -46,6 +47,7 @@ const
 {$endif I386}
 {$endif I386}
 
 
 const
 const
+
   can_delete_term : boolean = false;
   can_delete_term : boolean = false;
   ACSIn : string = '';
   ACSIn : string = '';
   ACSOut : string = '';
   ACSOut : string = '';
@@ -554,7 +556,7 @@ begin
   restoreRawSettings(preInitVideoTio);
   restoreRawSettings(preInitVideoTio);
 end;
 end;
 
 
-procedure InitVideo;
+procedure SysInitVideo;
 const
 const
   fontstr : string[3]=#27'(K';
   fontstr : string[3]=#27'(K';
 var
 var
@@ -671,7 +673,7 @@ begin
    ErrorCode:=errVioInit; { not a TTY }
    ErrorCode:=errVioInit; { not a TTY }
 end;
 end;
 
 
-procedure DoneVideo;
+procedure SysDoneVideo;
 begin
 begin
   if VideoBufSize=0 then
   if VideoBufSize=0 then
    exit;
    exit;
@@ -705,7 +707,7 @@ begin
 end;
 end;
 
 
 
 
-procedure ClearScreen;
+procedure SysClearScreen;
 begin
 begin
   FillWord(VideoBuf^,VideoBufSize shr 1,$0720);
   FillWord(VideoBuf^,VideoBufSize shr 1,$0720);
   if Console then
   if Console then
@@ -718,14 +720,12 @@ begin
 end;
 end;
 
 
 
 
-procedure UpdateScreen(Force: Boolean);
+procedure SysUpdateScreen(Force: Boolean);
 var
 var
   DoUpdate : boolean;
   DoUpdate : boolean;
   i : longint;
   i : longint;
   p1,p2 : plongint;
   p1,p2 : plongint;
 begin
 begin
-  if LockUpdateScreen<>0 then
-   exit;
   if not force then
   if not force then
    begin
    begin
 {$ifdef i386}
 {$ifdef i386}
@@ -772,14 +772,14 @@ begin
 end;
 end;
 
 
 
 
-function GetCapabilities: Word;
+function SysGetCapabilities: Word;
 begin
 begin
 { about cpColor... we should check the terminfo database... }
 { about cpColor... we should check the terminfo database... }
-  GetCapabilities:=cpUnderLine + cpBlink + cpColor;
+  SysGetCapabilities:=cpUnderLine + cpBlink + cpColor;
 end;
 end;
 
 
 
 
-procedure SetCursorPos(NewCursorX, NewCursorY: Word);
+procedure SysSetCursorPos(NewCursorX, NewCursorY: Word);
 var
 var
   Pos : array [1..2] of Byte;
   Pos : array [1..2] of Byte;
 begin
 begin
@@ -800,13 +800,13 @@ begin
 end;
 end;
 
 
 
 
-function GetCursorType: Word;
+function SysGetCursorType: Word;
 begin
 begin
-  GetCursorType:=LastCursorType;
+  SysGetCursorType:=LastCursorType;
 end;
 end;
 
 
 
 
-procedure SetCursorType(NewType: Word);
+procedure SysSetCursorType(NewType: Word);
 begin
 begin
   LastCursorType:=NewType;
   LastCursorType:=NewType;
   case NewType of
   case NewType of
@@ -839,7 +839,22 @@ procedure RegisterVideoModes;
 begin
 begin
 end;
 end;
 
 
+Const
+  SysVideoDriver : TVideoDriver = (
+    InitDriver : @SysInitVideo;
+    DoneDriver : @SysDoneVideo;
+    UpdateScreen : @SysUpdateScreen;
+    ClearScreen : @SysClearScreen;
+    SetVideoMode : Nil;
+    HasVideoMode : Nil;
+    SetCursorPos : @SysSetCursorPos;
+    GetCursorType : @SysGetCursorType;
+    SetCursorType : @SysSetCursorType;
+    GetCapabilities : @SysGetCapabilities
+  );
+
 initialization
 initialization
+  SetVideoDriver(SysVideoDriver);
   RegisterVideoModes;
   RegisterVideoModes;
 
 
 finalization
 finalization
@@ -847,7 +862,10 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2001-08-30 20:55:08  peter
+  Revision 1.8  2001-09-21 19:50:19  michael
+  + Merged driver support from fixbranch
+
+  Revision 1.7  2001/08/30 20:55:08  peter
     * v10 merges
     * v10 merges
 
 
   Revision 1.6  2001/08/01 21:42:05  peter
   Revision 1.6  2001/08/01 21:42:05  peter
@@ -859,6 +877,27 @@ end.
   Revision 1.4  2001/07/30 21:38:55  peter
   Revision 1.4  2001/07/30 21:38:55  peter
     * m68k updates merged
     * m68k updates merged
 
 
+  Revision 1.2.2.8  2001/09/21 18:42:09  michael
+  + Implemented support for custom video drivers.
+
+  Revision 1.2.2.7  2001/08/28 12:23:15  pierre
+   * set skipped to true if changing line and force is false to avoid problems if terminal reports less columns as available
+
+  Revision 1.2.2.6  2001/08/01 10:50:59  pierre
+   * avoid warning for m68k cpu
+
+  Revision 1.2.2.5  2001/07/30 23:34:51  pierre
+   * make tchattr record endian dependant
+
+  Revision 1.2.2.4  2001/07/29 20:25:18  pierre
+   * fix wrong deref in generic compare code
+
+  Revision 1.2.2.3  2001/07/13 14:49:08  pierre
+   + implement videobuf comparaison for non i386 cpus
+
+  Revision 1.2.2.2  2001/01/30 22:23:44  peter
+    * unix back to linux
+
   Revision 1.3  2001/07/13 22:05:09  peter
   Revision 1.3  2001/07/13 22:05:09  peter
     * cygwin updates
     * cygwin updates
 
 

+ 50 - 26
rtl/win32/video.pp

@@ -32,13 +32,10 @@ var
   ConsoleCursorInfo : TConsoleCursorInfo;
   ConsoleCursorInfo : TConsoleCursorInfo;
   MaxVideoBufSize : DWord;
   MaxVideoBufSize : DWord;
 
 
-const
-  VideoInitialized : boolean = false;
 
 
-procedure InitVideo;
+procedure SysInitVideo;
+
 begin
 begin
-  if VideoInitialized then
-    DoneVideo;
   ScreenColor:=true;
   ScreenColor:=true;
   GetConsoleScreenBufferInfo(TextRec(Output).Handle, ConsoleInfo);
   GetConsoleScreenBufferInfo(TextRec(Output).Handle, ConsoleInfo);
   GetConsoleCursorInfo(TextRec(Output).Handle, ConsoleCursorInfo);
   GetConsoleCursorInfo(TextRec(Output).Handle, ConsoleCursorInfo);
@@ -78,30 +75,26 @@ begin
 
 
   GetMem(VideoBuf,MaxVideoBufSize);
   GetMem(VideoBuf,MaxVideoBufSize);
   GetMem(OldVideoBuf,MaxVideoBufSize);
   GetMem(OldVideoBuf,MaxVideoBufSize);
-  VideoInitialized:=true;
 end;
 end;
 
 
 
 
-procedure DoneVideo;
+procedure SysDoneVideo;
 begin
 begin
   SetCursorType(crUnderLine);
   SetCursorType(crUnderLine);
-  if VideoInitialized then
-    begin
-      FreeMem(VideoBuf,MaxVideoBufSize);
-      FreeMem(OldVideoBuf,MaxVideoBufSize);
-    end;
+  FreeMem(VideoBuf,MaxVideoBufSize);
+  FreeMem(OldVideoBuf,MaxVideoBufSize);
   VideoBufSize:=0;
   VideoBufSize:=0;
   VideoInitialized:=false;
   VideoInitialized:=false;
 end;
 end;
 
 
 
 
-function GetCapabilities: Word;
+function SysGetCapabilities: Word;
 begin
 begin
-  GetCapabilities:=cpColor or cpChangeCursor;
+  SysGetCapabilities:=cpColor or cpChangeCursor;
 end;
 end;
 
 
 
 
-procedure SetCursorPos(NewCursorX, NewCursorY: Word);
+procedure SysSetCursorPos(NewCursorX, NewCursorY: Word);
 var
 var
   pos : COORD;
   pos : COORD;
 begin
 begin
@@ -113,24 +106,24 @@ begin
 end;
 end;
 
 
 
 
-function GetCursorType: Word;
+function SysGetCursorType: Word;
 begin
 begin
    GetConsoleCursorInfo(TextRec(Output).Handle,ConsoleCursorInfo);
    GetConsoleCursorInfo(TextRec(Output).Handle,ConsoleCursorInfo);
    if not ConsoleCursorInfo.bvisible then
    if not ConsoleCursorInfo.bvisible then
-     GetCursorType:=crHidden
+     SysGetCursorType:=crHidden
    else
    else
      case ConsoleCursorInfo.dwSize of
      case ConsoleCursorInfo.dwSize of
         1..30:
         1..30:
-          GetCursorType:=crUnderline;
+          SysGetCursorType:=crUnderline;
         31..70:
         31..70:
-          GetCursorType:=crHalfBlock;
+          SysGetCursorType:=crHalfBlock;
         71..100:
         71..100:
-          GetCursorType:=crBlock;
+          SysGetCursorType:=crBlock;
      end;
      end;
 end;
 end;
 
 
 
 
-procedure SetCursorType(NewType: Word);
+procedure SysSetCursorType(NewType: Word);
 begin
 begin
    GetConsoleCursorInfo(TextRec(Output).Handle,ConsoleCursorInfo);
    GetConsoleCursorInfo(TextRec(Output).Handle,ConsoleCursorInfo);
    if newType=crHidden then
    if newType=crHidden then
@@ -159,7 +152,7 @@ begin
 end;
 end;
 
 
 
 
-procedure ClearScreen;
+procedure SysClearScreen;
 begin
 begin
   FillWord(VideoBuf^,VideoBufSize div 2,$0720);
   FillWord(VideoBuf^,VideoBufSize div 2,$0720);
   UpdateScreen(true);
   UpdateScreen(true);
@@ -171,7 +164,7 @@ function WriteConsoleOutput(hConsoleOutput:HANDLE; lpBuffer:pointer; dwBufferSiz
    var lpWriteRegion:SMALL_RECT):WINBOOL; external 'kernel32' name 'WriteConsoleOutputA';
    var lpWriteRegion:SMALL_RECT):WINBOOL; external 'kernel32' name 'WriteConsoleOutputA';
 {$ENDIF}
 {$ENDIF}
 
 
-procedure UpdateScreen(Force: Boolean);
+procedure SysUpdateScreen(Force: Boolean);
 type TmpRec = Array[0..(1024*32) - 1] of TCharInfo;
 type TmpRec = Array[0..(1024*32) - 1] of TCharInfo;
 
 
 type WordRec = record
 type WordRec = record
@@ -242,8 +235,6 @@ var
    x1,y1,x2,y2 : longint;
    x1,y1,x2,y2 : longint;
 
 
 begin
 begin
-  if LockUpdateScreen<>0 then
-   exit;
   if force then
   if force then
    smallforce:=true
    smallforce:=true
   else
   else
@@ -357,8 +348,23 @@ begin
   RegisterVideoMode(80, 25, True, @DefaultVideoModeSelector, $00000003);
   RegisterVideoMode(80, 25, True, @DefaultVideoModeSelector, $00000003);
 end;
 end;
 
 
+Const
+  SysVideoDriver : TVideoDriver = (
+    InitDriver : @SysInitVideo;
+    DoneDriver : @SysDoneVideo;
+    UpdateScreen : @SysUpdateScreen;
+    ClearScreen : @SysClearScreen;
+    SetVideoMode : Nil;
+    HasVideoMode : Nil;
+    SetCursorPos : @SysSetCursorPos;
+    GetCursorType : @SysGetCursorType;
+    SetCursorType : @SysSetCursorType;
+    GetCapabilities : @SysGetCapabilities
+
+  );
 
 
 initialization
 initialization
+  SetVideoDriver(SysVideoDriver);
   RegisterVideoModes;
   RegisterVideoModes;
 
 
 finalization
 finalization
@@ -366,7 +372,10 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2001-08-01 18:01:20  peter
+  Revision 1.6  2001-09-21 19:50:19  michael
+  + Merged driver support from fixbranch
+
+  Revision 1.5  2001/08/01 18:01:20  peter
     * WChar fix to compile also with 1.0.x
     * WChar fix to compile also with 1.0.x
 
 
   Revision 1.4  2001/07/30 15:01:12  marco
   Revision 1.4  2001/07/30 15:01:12  marco
@@ -378,6 +387,21 @@ end.
   Revision 1.2  2001/04/10 21:28:36  peter
   Revision 1.2  2001/04/10 21:28:36  peter
     * removed warnigns
     * removed warnigns
 
 
+  Revision 1.1.2.5  2001/09/21 18:42:09  michael
+  + Implemented support for custom video drivers.
+
+  Revision 1.1.2.4  2001/06/12 22:34:20  pierre
+   * avoid crash at exit of IDE
+
+  Revision 1.1.2.3  2001/04/10 20:33:04  peter
+    * remove some warnings
+
+  Revision 1.1.2.2  2001/04/02 13:29:41  pierre
+   * avoid crash if DoneVideo called twice
+
+  Revision 1.1.2.1  2001/01/30 21:52:03  peter
+    * moved api utils to rtl
+
   Revision 1.1  2001/01/13 11:03:59  peter
   Revision 1.1  2001/01/13 11:03:59  peter
     * API 2 RTL commit
     * API 2 RTL commit