Browse Source

+ Merged video mode selection/setting system

michael 24 years ago
parent
commit
30ef883342
6 changed files with 538 additions and 519 deletions
  1. 83 73
      rtl/go32v2/video.pp
  2. 87 46
      rtl/inc/video.inc
  3. 26 31
      rtl/inc/videoh.inc
  4. 299 268
      rtl/os2/video.pp
  5. 22 49
      rtl/unix/video.pp
  6. 21 52
      rtl/win32/video.pp

+ 83 - 73
rtl/go32v2/video.pp

@@ -34,12 +34,8 @@ uses
 
 {$ASMMODE ATT}
 
-var
-  OldVideoBuf : PVideoBuf;
-
   { used to know if LastCursorType is valid }
 const
-  InitVideoCalled : boolean = false;
   LastCursorType : word = crUnderline;
 
 { allways set blink state again }
@@ -115,19 +111,8 @@ begin
   CursorLines:=regs.cl;
   CursorX:=regs.dl;
   CursorY:=regs.dh;
-  If InitVideoCalled then
-    Begin
-      FreeMem(VideoBuf,VideoBufSize);
-      FreeMem(OldVideoBuf,VideoBufSize);
-    End;
-{ allocate pmode memory buffer }
-  VideoBufSize:=ScreenWidth*ScreenHeight*2;
-  GetMem(VideoBuf,VideoBufSize);
-  GetMem(OldVideoBuf,VideoBufSize);
   SetHighBitBlink;
   SetCursorType(LastCursorType);
-  { ClearScreen; removed here
-    to be able to catch the content of the monitor }
 end;
 
 
@@ -137,11 +122,6 @@ begin
   ClearScreen;
   SetCursorType(crUnderLine);
   SetCursorPos(0,0);
-  FreeMem(VideoBuf,VideoBufSize);
-  VideoBuf:=nil;
-  FreeMem(OldVideoBuf,VideoBufSize);
-  OldVideoBuf:=nil;
-  VideoBufSize:=0;
 end;
 
 
@@ -214,8 +194,29 @@ begin
   realintr($10,regs);
 end;
 
+procedure SysUpdateScreen(Force: Boolean);
+begin
+  if not force then
+   begin
+     asm
+        movl    VideoBuf,%esi
+        movl    OldVideoBuf,%edi
+        movl    VideoBufSize,%ecx
+        shrl    $2,%ecx
+        repe
+        cmpsl
+        setne   force
+     end;
+   end;
+  if Force then
+   begin
+     dosmemput(videoseg,0,videobuf^,VideoBufSize);
+     move(videobuf^,oldvideobuf^,VideoBufSize);
+   end;
+end;
+
+Procedure DoSetVideoMode(Params: Longint);
 
-function DefaultVideoModeSelector(const VideoMode: TVideoMode; Params: Longint): Boolean;
 type
   wordrec=packed record
     lo,hi : word;
@@ -226,11 +227,10 @@ begin
   regs.ax:=wordrec(Params).lo;
   regs.bx:=wordrec(Params).hi;
   realintr($10,regs);
-  defaultvideomodeselector:=true;
-  DoCustomMouse(false);
 end;
 
-function VideoModeSelector8x8(const VideoMode: TVideoMode; Params: Longint): Boolean;
+Procedure SetVideo8x8;
+
 type
   wordrec=packed record
     lo,hi : word;
@@ -244,83 +244,93 @@ begin
   regs.ax:=$1112;
   regs.bx:=$0;
   realintr($10,regs);
-  videomodeselector8x8:=true;
-  ScreenColor:=true;
-  ScreenWidth:=80;
-  ScreenHeight:=50;
-  DoCustomMouse(false);
 end;
 
-procedure SysClearScreen;
+Const 
+  SysVideoModeCount = 5;
+  SysVMD : Array[0..SysVideoModeCount-1] of TVideoMode = (
+   (Col: 40; Row : 25;  Color : False),
+   (Col: 40; Row : 25;  Color : True),
+   (Col: 80; Row : 25;  Color : False),
+   (Col: 80; Row : 25;  Color : True),
+   (Col: 80; Row : 50;  Color : True)
+  );
+  
+Function SysSetVideoMode (Const Mode : TVideoMode) : Boolean;
+
+Var
+  I : Integer;
+
 begin
-  FillWord(VideoBuf^,VideoBufSize shr 1,$0720);
-  UpdateScreen(true);
+  I:=SysVideoModeCount-1;
+  SysSetVideoMode:=False;
+  While (I>=0) and Not SysSetVideoMode do
+    If (Mode.col=SysVMD[i].col) and
+       (Mode.Row=SysVMD[i].Row) and
+       (Mode.Color=SysVMD[i].Color) then
+      SysSetVideoMode:=True
+    else
+      Dec(I);  
+  If SysSetVideoMode then
+    begin
+    If (I<SysVideoModeCount-1) then
+      DoSetVideoMode(I)
+    else
+      SetVideo8x8;  
+    ScreenWidth:=SysVMD[I].Col;
+    ScreenHeight:=SysVMD[I].Row;
+    ScreenColor:=SysVMD[I].Color;
+    DoCustomMouse(false);
+    end;
 end;
+  
+Function SysGetVideoModeData (Index : Word; Var Data : TVideoMode) : boolean;
 
-
-procedure SysUpdateScreen(Force: Boolean);
 begin
-  if LockUpdateScreen<>0 then
-   exit;
-  if not force then
-   begin
-     asm
-        movl    VideoBuf,%esi
-        movl    OldVideoBuf,%edi
-        movl    VideoBufSize,%ecx
-        shrl    $2,%ecx
-        repe
-        cmpsl
-        setne   force
-     end;
-   end;
-  if Force then
-   begin
-     dosmemput(videoseg,0,videobuf^,VideoBufSize);
-     move(videobuf^,oldvideobuf^,VideoBufSize);
-   end;
+  SysGetVideoModeData:=(Index<=SysVideoModeCount);
+  If SysGetVideoModeData then
+    Data:=SysVMD[Index];
 end;
 
+Function SysGetVideoModeCount : Word;
 
-procedure RegisterVideoModes;
 begin
-  RegisterVideoMode(40, 25, False,@DefaultVideoModeSelector, $00000000);
-  RegisterVideoMode(40, 25, True, @DefaultVideoModeSelector, $00000001);
-  RegisterVideoMode(80, 25, False,@DefaultVideoModeSelector, $00000002);
-  RegisterVideoMode(80, 25, True, @DefaultVideoModeSelector, $00000003);
-  RegisterVideoMode(80, 50, True, @VideoModeSelector8x8, 0);
+  SysGetVideoModeCount:=SysVideoModeCount;
 end;
 
 Const
   SysVideoDriver : TVideoDriver = (
-    InitDriver : @SysInitVideo;
-    DoneDriver : @SysDoneVideo;
-    UpdateScreen : @SysUpdateScreen;
-    ClearScreen : @SysClearScreen;
-    SetVideoMode : Nil;
-    HasVideoMode : Nil;
-    SetCursorPos : @SysSetCursorPos;
-    GetCursorType : @SysGetCursorType;
-    SetCursorType : @SysSetCursorType;
+    InitDriver      : @SysInitVideo;
+    DoneDriver      : @SysDoneVideo;
+    UpdateScreen    : @SysUpdateScreen;
+    ClearScreen     : Nil;
+    SetVideoMode    : @SysSetVideoMode;
+    GetVideoModeCount : @SysGetVideoModeCount;
+    GetVideoModeData : @SysGetVideoModedata;
+    SetCursorPos    : @SysSetCursorPos;
+    GetCursorType   : @SysGetCursorType;
+    SetCursorType   : @SysSetCursorType;
     GetCapabilities : @SysGetCapabilities
   );
 
 initialization
   SetVideoDriver(SysVideoDriver);
-  RegisterVideoModes;
-
-finalization
-  UnRegisterVideoModes;
 end.
 {
   $Log$
-  Revision 1.3  2001-09-21 19:50:18  michael
+  Revision 1.4  2001-10-06 22:28:24  michael
+  + Merged video mode selection/setting system
+
+  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)
 
+  Revision 1.1.2.5  2001/10/06 22:23:40  michael
+  + Better video mode selection/setting system
+
   Revision 1.1.2.4  2001/09/21 18:42:08  michael
   + Implemented support for custom video drivers.
 

+ 87 - 46
rtl/inc/video.inc

@@ -57,6 +57,52 @@ end;
   External functions that use the video driver.
   ---------------------------------------------------------------------}
 
+Procedure FreeVideoBuf;
+
+begin
+  if (VideoBuf<>Nil) then
+    begin
+    FreeMem(VideoBuf);
+    FreeMem(OldVideoBuf);
+    VideoBuf:=Nil;
+    OldVideoBuf:=Nil;
+    VideoBufSize:=0;
+    end;
+end;
+
+Procedure AssignVideoBuf (OldCols, OldRows : Word);
+
+Var NewVideoBuf,NewOldVideoBuf : PVideoBuf;
+    S,I,C,R,NewVideoBufSize : Integer;
+
+begin
+  S:=SizeOf(TVideoCell);
+  NewVideoBufSize:=ScreenWidth*ScreenHeight*S;
+  GetMem(NewVideoBuf,NewVideoBufSize);
+  GetMem(NewOldVideoBuf,NewVideoBufSize);
+  // Move contents of old videobuffers to new if there are any.
+  if (VideoBuf<>Nil) then
+    begin
+    If (ScreenWidth<OldCols) then
+      C:=ScreenWidth
+    else
+      C:=OldCols;  
+    If (ScreenHeight<OldRows) then
+      R:=ScreenHeight
+    else
+      R:=OldRows;  
+    For I:=0 to R-1 do
+      begin
+      Move(VideoBuf[I*S*OldCols],NewVideoBuf[I*S*ScreenWidth],S*C);
+      Move(OldVideoBuf[I*S*OldCols],NewOldVideoBuf[I*S*ScreenWidth],S*C);
+      end;
+    end;  
+  FreeVideoBuf;
+  VideoBufSize:=NewVideoBufSize;
+  VideoBuf:=NewVideoBuf;
+  OldVideoBuf:=NewOldVideoBuf;
+end;
+
 Procedure InitVideo;
 
 begin
@@ -64,10 +110,12 @@ begin
     begin
     If Assigned(CurrentVideoDriver.InitDriver) then
       CurrentVideoDriver.InitDriver;
-    VideoInitialized:=True;
+    AssignVideoBuf(0,0);
+    ClearScreen;
     end;
 end;
 
+
 Procedure DoneVideo;
 
 begin
@@ -75,6 +123,7 @@ begin
     begin
     If Assigned(CurrentVideoDriver.DoneDriver) then
       CurrentVideoDriver.DoneDriver;
+    FreeVideoBuf;  
     VideoInitialized:=False;
     end;
 end;
@@ -90,18 +139,12 @@ end;
 Procedure ClearScreen;
 
 begin
+  // Should this not be the current color ?
+  FillWord(VideoBuf^,VideoBufSize shr 1,$0720);
   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);
@@ -148,52 +191,44 @@ begin
   Mode.Color := ScreenColor;
 end;
 
+Function SetVideoMode(Const Mode: TVideoMode) : Boolean;
 
+Var
+  OldR,OldC: Word;
 
-procedure SetVideoMode(Mode: TVideoMode);
-var
-  P: PVideoModeList;
 begin
-  P := Modes;
-  while (P<>Nil) and ((P^.Row <> Mode.Row) or (P^.Col <> Mode.Col) or (P^.Color<>Mode.Color)) do
-    P := P^.Next;
-  if P <> nil then begin
-    DoneVideo;
-    ScreenWidth:=$ffff;
-    ScreenHeight:=$ffff;
-    P^.VideoModeSelector(PVideoMode(P)^, P^.Params);
-    InitVideo;
-   end
-   else begin
-    ErrorHandler(errVioNoSuchMode, @Mode);
-  end;
+  OldC:=ScreenWidth;
+  OldR:=ScreenHeight;
+  If Assigned(CurrentVideoDriver.SetVideoMode) then
+    SetVideoMode:=CurrentVideoDriver.SetVideoMode(Mode)
+  else
+    SetVideoMode:=False;
+  // Assign buffer
+  If SetVideoMode then
+    AssignVideoBuf(OldC,Oldr);
 end;
 
-procedure RegisterVideoMode(Col, Row: Word; Color: Boolean; VideoModeSelector: TVideoModeSelector; Params: Longint);
-var
-  P: PVideoModeList;
+
+Function GetVideoModeCount : Word;
+
 begin
-  New(P);
-  P^.Col := Col;
-  P^.Row := Row;
-  P^.Color := Color;
-  P^.VideoModeSelector := VideoModeSelector;
-  P^.Params := Params;
-  P^.Next := Modes;
-  Modes := P;
+  If Assigned(CurrentVideoDriver.GetVideoModeCount) then
+    GetVideoModeCount:=GetVideoModeCount()
+  else
+    GetVideoModeCount:=1;
 end;
 
+Function GetVideoModeData(Index : Word; Var Data: TVideoMode) : Boolean;
 
-procedure UnRegisterVideoModes;
-var
-  P: PVideoModeList;
 begin
-  while assigned(modes) do
-   begin
-     p:=modes;
-     modes:=modes^.next;
-     dispose(p);
-   end;
+  If Assigned(CurrentVideoDriver.GetVideoModeData) then
+    GetVideoModeData:=CurrentVideoDriver.GetVideoModeData(Index,Data)
+  else
+    begin
+    GetVideoModeData:=(Index=0);
+    If GetVideoModeData then
+      GetVideoMode(Data);
+    end
 end;
 
 function DefaultErrorHandler(AErrorCode: Longint; AErrorInfo: Pointer): TErrorHandlerReturnValue;
@@ -207,12 +242,18 @@ end;
 
 {
   $Log$
-  Revision 1.3  2001-10-04 20:51:56  michael
+  Revision 1.4  2001-10-06 22:28:24  michael
+  + Merged video mode selection/setting system
+
+  Revision 1.3  2001/10/04 20:51:56  michael
   + merged function setvideodriver
 
   Revision 1.2  2001/09/21 19:50:18  michael
   + Merged driver support from fixbranch
 
+  Revision 1.1.2.5  2001/10/06 22:23:40  michael
+  + Better video mode selection/setting system
+
   Revision 1.1.2.4  2001/10/04 18:59:11  michael
   + Made setVideoDriver a function
 

+ 26 - 31
rtl/inc/videoh.inc

@@ -27,16 +27,18 @@ type
   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;
+    InitDriver        : Procedure;
+    DoneDriver        : Procedure;
+    UpdateScreen      : Procedure(Force : Boolean);
+    ClearScreen       : Procedure;
+    SetVideoMode      : Function (Const Mode : TVideoMode) : Boolean;
+    GetVideoModeCount : Function : Word;
+    GetVideoModeData  : Function(Index : Word; Var Data : TVideoMode) : Boolean;
+    SetCursorPos      : procedure (NewCursorX, NewCursorY: Word);
+    GetCursorType     : function : Word;
+    SetCursorType     : procedure (NewType: Word);
+    GetCapabilities   : Function : Word;
+    DefaultVideoMode  : TVideoMode;
   end;
 
 const
@@ -93,7 +95,8 @@ var
   ScreenColor  : Boolean;
   CursorX,
   CursorY      : Word;
-  VideoBuf     : PVideoBuf;
+  VideoBuf,
+  OldVideoBuf  : PVideoBuf;
   VideoBufSize : Longint;
   CursorLines  : Byte;
 
@@ -130,29 +133,15 @@ function GetCursorType: Word;
 { Return the cursor type: Hidden, UnderLine or Block }
 procedure SetCursorType(NewType: Word);
 { Set the cursor to the given type }
-function DefaultVideoModeSelector(const VideoMode: TVideoMode; Params: Longint): Boolean;
 
 procedure GetVideoMode(var Mode: TVideoMode);
 { Return dimensions of the current video mode }
-procedure SetVideoMode(Mode: TVideoMode);
+Function SetVideoMode(Const Mode: TVideoMode) : Boolean;
 { Set video-mode to have Mode dimensions, may return errVioNoSuchMode }
-procedure RegisterVideoMode(Col, Row: Word; Color: Boolean; VideoModeSelector: TVideoModeSelector; Params: Longint);
-{ Registers a video mode to be selectable by SetVideoMode }
-
-{ moved to interface because we need a way to retrieve the modes }
-{ System independent part }
-type
-  PVideoModeList = ^TVideoModeList;
-  TVideoModeList = record
-    Col, Row: Word;
-    Color: Boolean;
-    VideoModeSelector: TVideoModeSelector;
-    Params: Longint;
-    Next: PVideoModeList;
-  end;
-
-const
-  Modes: PVideoModeList = nil;
+Function GetVideoModeCount : Word;
+{ Get the number of video modes supported by this driver }
+Function GetVideoModeData(Index : Word; Var Data: TVideoMode) : Boolean;
+{ Get the data for Video mode Index. Index is zero based. }
 
 type
   TErrorHandlerReturnValue = (errRetry, errAbort, errContinue);
@@ -176,7 +165,10 @@ const
 
 {
   $Log$
-  Revision 1.4  2001-10-04 20:51:56  michael
+  Revision 1.5  2001-10-06 22:28:24  michael
+  + Merged video mode selection/setting system
+
+  Revision 1.4  2001/10/04 20:51:56  michael
   + merged function setvideodriver
 
   Revision 1.3  2001/09/21 19:50:18  michael
@@ -184,6 +176,9 @@ const
 
   Revision 1.2  2001/06/06 17:20:22  jonas
 
+  Revision 1.1.2.6  2001/10/06 22:23:40  michael
+  + Better video mode selection/setting system
+
   Revision 1.1.2.5  2001/10/04 18:59:11  michael
   + Made setVideoDriver a function
 

+ 299 - 268
rtl/os2/video.pp

@@ -40,45 +40,6 @@ var OrigCurType: TVioCursorInfo;
     OrigCurRow: word;
     OrigCurCol: word;
     CellHeight: byte;
-    OldVideoBuf: PVideoBuf;
-
-procedure TargetEntry;
-
-var P: PVideoModeList;
-    PScr: pointer;
-
-begin
-{Remember original video mode, cursor type and high bit behaviour setting}
-    OrigVioMode.cb := SizeOf (OrigVioMode);
-    VioGetMode (OrigVioMode, 0);
-    VioGetCurType (OrigCurType, 0);
-    VioGetCurPos (OrigCurRow, OrigCurCol, 0);
-    with OrigHighBit do
-        begin
-            cb := 6;
-            rType := 2;
-        end;
-    VioGetState (OrigHighBit, 0);
-{Register the curent video mode in Modes if not there yet}
-    with OrigVioMode do
-        begin
-            P := Modes;
-            while (P <> nil) and ((P^.Row <> Row) or (P^.Col <> Col)
-                                      or (P^.Color <> (Color >= Colors_16))) do
-                P := P^.Next;
-            if P = nil then
-{Assume we have at least 16 colours available in "colour" modes}
-                RegisterVideoMode (Col, Row, Color >= Colors_16,
-                                                @DefaultVideoModeSelector, 0);
-        end;
-{Get the address of the original videobuffer and size.}
-    if VioGetBuf (PScr, PWord (@OrigScreenSize)^, 0) = 0 then
-        begin
-            PScr := SelToFlat (TFarPtr (PScr));
-            GetMem (OrigScreen, OrigScreenSize);
-            Move (PScr^, OrigScreen^, OrigScreenSize);
-        end;
-end;
 
 procedure CheckCellHeight;
 
@@ -100,29 +61,6 @@ begin
 end;
 
 
-procedure RegisterVideoModes;
-begin
-{ BW modes are rejected on my (colour) configuration. I can't imagine
-  OS/2 running on MCGA anyway... ;-)
-
-    RegisterVideoMode (40, 25, False, @DefaultVideoModeSelector, 0);
-    RegisterVideoMode (80, 25, False, @DefaultVideoModeSelector, 0);
-}
-    RegisterVideoMode (40, 25, True, @DefaultVideoModeSelector, 0);
-    RegisterVideoMode (80, 25, True, @DefaultVideoModeSelector, 0);
-    RegisterVideoMode (80, 30, True, @DefaultVideoModeSelector, 0);
-    RegisterVideoMode (80, 43, True, @DefaultVideoModeSelector, 0);
-    RegisterVideoMode (80, 50, True, @DefaultVideoModeSelector, 0);
-
-{ The following modes wouldn't work on plain VGA; is it useful to check
-  for their availability on the program startup?
-
-    RegisterVideoMode (132, 25, True, @DefaultVideoModeSelector, 0);
-    RegisterVideoMode (132, 30, True, @DefaultVideoModeSelector, 0);
-    RegisterVideoMode (132, 43, True, @DefaultVideoModeSelector, 0);
-    RegisterVideoMode (132, 50, True, @DefaultVideoModeSelector, 0);
-}
-end;
 
 
 procedure SetHighBitBlink (Blink: boolean);
@@ -140,51 +78,49 @@ begin
 end;
 
 
+Var 
+  SysVideoBuf : PVideoBuf;
+
 procedure SysInitVideo;
 
 var MI: TVioModeInfo;
 
 begin
-  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;
+    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
+  if VioGetBuf (SysVideoBuf, PWord (@VideoBufSize)^, 0) = 0 then
+    begin
+    SysVideoBuf := SelToFlat (TFarPtr (SysVideoBuf));
+    SetHighBitBlink (true);
+    end
   else
-      ErrorHandler (errVioInit, nil);
+    ErrorHandler (errVioInit, nil);
 end;
 
 
 procedure SysSetCursorPos (NewCursorX, NewCursorY: word);
 
 begin
-    if VioSetCurPos (NewCursorY, NewCursorX, 0) = 0 then
-        begin
-            CursorX := NewCursorX;
-            CursorY := NewCursorY;
-        end
-    else
-        {Do not set an error code; people should fix invalid NewCursorX
-         or NewCursorY values when designing, there is no need for detecting
-         these errors at runtime.}
-        RunError (225);
+  if VioSetCurPos (NewCursorY, NewCursorX, 0) = 0 then
+    begin
+    CursorX := NewCursorX;
+    CursorY := NewCursorY;
+    end
+  else
+   {Do not set an error code; people should fix invalid NewCursorX
+    or NewCursorY values when designing, there is no need for detecting
+    these errors at runtime.}
+    RunError (225);
 end;
 
 
@@ -195,23 +131,23 @@ var CD: TVioCursorInfo;
 begin
     VioGetCurType (CD, 0);    {Never fails, because handle is default handle.}
     with CD do
-        begin
-            CursorLines := Succ (cEnd) - yStart;
-            if Attr = word (-1) then
-                SysGetCursorType := crHidden
-            else
-{Because the cursor's start and end lines are returned, we'll have
- to guess heuristically what cursor type we have.}
-                if CursorLines = 0 then
-{Probably this does not occur, but you'll never know.}
-                    SysGetCursorType := crHidden
-                else if CursorLines <= Succ (CellHeight div 4) then
-                    SysGetCursorType := crUnderline
-                else if CursorLines <= Succ (CellHeight div 2) then
-                    SysGetCursorType := crHalfBlock
-                else
-                    SysGetCursorType := crBlock;
-        end;
+      begin
+      CursorLines := Succ (cEnd) - yStart;
+      if Attr = word (-1) then
+         SysGetCursorType := crHidden
+      else
+       {Because the cursor's start and end lines are returned, we'll have
+        to guess heuristically what cursor type we have.}
+        if CursorLines = 0 then
+           {Probably this does not occur, but you'll never know.}
+           SysGetCursorType := crHidden
+         else if CursorLines <= Succ (CellHeight div 4) then
+           SysGetCursorType := crUnderline
+         else if CursorLines <= Succ (CellHeight div 2) then
+           SysGetCursorType := crHalfBlock
+         else
+           SysGetCursorType := crBlock;
+   end;
 end;
 
 
@@ -220,34 +156,34 @@ procedure SysSetCursorType (NewType: word);
 var CD: TVioCursorInfo;
 
 begin
-    VioGetCurType (CD, 0);
-    with CD do
+  VioGetCurType (CD, 0);
+  with CD do
+    begin
+    case NewType of
+      crHidden: Attr := word (-1);
+      crUnderline:
+        begin
+        Attr := 0;
+        yStart := word (-90);
+        cEnd := word (-100);
+        end;
+      crHalfBlock:
+        begin
+        Attr := 0;
+        yStart := word (-50);
+        cEnd := word (-100);
+        end;
+      crBlock:
         begin
-            case NewType of
-                crHidden: Attr := word (-1);
-                crUnderline:
-                    begin
-                        Attr := 0;
-                        yStart := word (-90);
-                        cEnd := word (-100);
-                    end;
-                crHalfBlock:
-                    begin
-                        Attr := 0;
-                        yStart := word (-50);
-                        cEnd := word (-100);
-                    end;
-                crBlock:
-                    begin
-                        Attr := 0;
-                        yStart := 0;
-                        cEnd := word (-100);
-                    end;
-            end;
-            VioSetCurType (CD, 0);
-            VioGetCurType (CD, 0);
-            CursorLines := Succ (cEnd) - yStart;
+        Attr := 0;
+        yStart := 0;
+        cEnd := word (-100);
         end;
+    end;
+    VioSetCurType (CD, 0);
+    VioGetCurType (CD, 0);
+    CursorLines := Succ (cEnd) - yStart;
+    end;
 end;
 
 
@@ -257,30 +193,27 @@ var PScr: pointer;
     ScrSize: cardinal;
 
 begin
-            LastCursorType := GetCursorType;
-            ClearScreen;
-{Restore original settings}
-            VioSetMode (OrigVioMode, 0);
-            CheckCellHeight;
+  LastCursorType := GetCursorType;
+  ClearScreen;
+  {Restore original settings}
+  VioSetMode (OrigVioMode, 0);
+  CheckCellHeight;
 {Set CursorX and CursorY}
-            SetCursorPos (0, 0);
-            VioSetState (OrigHighBit, 0);
-            VioSetCurType (OrigCurType, 0);
-            VioSetCurPos (OrigCurRow, OrigCurCol, 0);
-            FreeMem (OldVideoBuf, VideoBufSize);
-            OldVideoBuf := nil;
-            VideoBufSize := 0;
-            if (OrigScreenSize <> 0) and (OrigScreen <> nil) then
-                begin
-                    ScrSize := 0;
-                    if (VioGetBuf (PScr, PWord (@ScrSize)^, 0) = 0)
-                                            and (ScrSize = OrigScreenSize) then
-                        begin
-                            PScr := SelToFlat (TFarPtr (PScr));
-                            Move (OrigScreen^, PScr^, OrigScreenSize);
-                            VioShowBuf (0, ScrSize, 0);
-                        end;
-                end;
+  SetCursorPos (0, 0);
+  VioSetState (OrigHighBit, 0);
+  VioSetCurType (OrigCurType, 0);
+  VioSetCurPos (OrigCurRow, OrigCurCol, 0);
+  if (OrigScreenSize <> 0) and (OrigScreen <> nil) then
+    begin
+    ScrSize := 0;
+    if (VioGetBuf (PScr, PWord (@ScrSize)^, 0) = 0) and 
+       (ScrSize = OrigScreenSize) then
+      begin
+      PScr := SelToFlat (TFarPtr (PScr));
+      Move (OrigScreen^, PScr^, OrigScreenSize);
+      VioShowBuf (0, ScrSize, 0);
+      end;
+    end;
 end;
 
 
@@ -291,65 +224,126 @@ begin
 end;
 
 
-function DefaultVideoModeSelector (const VideoMode: TVideoMode; Params: longint): boolean;
+function SysVideoModeSelector (const VideoMode: TVideoMode): boolean;
 
 var OldMI, MI: TVioModeInfo;
 
 begin
-    OldMI.cb := SizeOf (OldMI);
-    if VioGetMode (OldMI, 0) <> 0 then
-        DefaultVideoModeSelector := false
-    else
+  OldMI.cb := SizeOf (OldMI);
+  if VioGetMode (OldMI, 0) <> 0 then
+    SysVideoModeSelector := false
+  else
+    begin
+    with MI do
+      begin
+      cb := 8;
+      fbType := 1;
+      if VideoMode.Color then
+        Color := Colors_16
+      else
+        Color := Colors_2;
+      Col := VideoMode.Col;
+      Row := VideoMode.Row;
+      end;
+    if VioSetMode (MI, 0) = 0 then
+      if VioGetBuf (SysVideoBuf, PWord (@VideoBufSize)^, 0) = 0 then
         begin
-            with MI do
-                begin
-                    cb := 8;
-                    fbType := 1;
-                    if VideoMode.Color then
-                        Color := Colors_16
-                    else
-                        Color := Colors_2;
-                    Col := VideoMode.Col;
-                    Row := VideoMode.Row;
-                end;
-            if VioSetMode (MI, 0) = 0 then
-                if VioGetBuf (VideoBuf, PWord (@VideoBufSize)^, 0) = 0 then
-                    begin
-                        VideoBuf := SelToFlat (TFarPtr (VideoBuf));
-                        DefaultVideoModeSelector := true;
-                        SetHighBitBlink (true);
-                        CheckCellHeight;
-                        SetCursorType (LastCursorType);
-                        ClearScreen;
-                    end
-                else
-                    begin
-                        DefaultVideoModeSelector := false;
-                        VioSetMode (OldMI, 0);
-                        VioGetBuf (VideoBuf, PWord (@VideoBufSize)^, 0);
-                        VideoBuf := SelToFlat (TFarPtr (VideoBuf));
-                        SetHighBitBlink (true);
-                        CheckCellHeight;
-                        SetCursorType (LastCursorType);
-                        ClearScreen;
-                    end
-            else
-                begin
-                    DefaultVideoModeSelector := false;
-                    VioGetBuf (VideoBuf, PWord (@VideoBufSize)^, 0);
-                    VideoBuf := SelToFlat (TFarPtr (VideoBuf));
-                    SetHighBitBlink (true);
-                    SetCursorType (LastCursorType);
-                end;
-        end;
+        SysVideoBuf := SelToFlat (TFarPtr (SysVideoBuf));
+        SysVideoModeSelector := true;
+        SetHighBitBlink (true);
+        CheckCellHeight;
+        SetCursorType (LastCursorType);
+        ClearScreen;
+        end
+      else
+        begin
+        SysVideoModeSelector := false;
+        VioSetMode (OldMI, 0);
+        VioGetBuf (SysVideoBuf, PWord (@VideoBufSize)^, 0);
+        SysVideoBuf := SelToFlat (TFarPtr (SysVideoBuf));
+        SetHighBitBlink (true);
+        CheckCellHeight;
+        SetCursorType (LastCursorType);
+        ClearScreen;
+        end
+    else
+      begin
+      SysVideoModeSelector := false;
+      VioGetBuf (SysVideoBuf, PWord (@VideoBufSize)^, 0);
+      SysVideoBuf := SelToFlat (TFarPtr (SysVideoBuf));
+      SetHighBitBlink (true);
+      SetCursorType (LastCursorType);
+      end;
+    end;
 end;
 
+Const 
+  SysVideoModeCount = 6;
+  SysVMD : Array[0..SysVideoModeCount-1] of TVideoMode = (
+   (Col: 40; Row: 25; Color: True),
+   (Col: 80; Row: 25; Color: True),
+   (Col: 80; Row: 30; Color: True),
+   (Col: 80; Row: 43; Color: True),
+   (Col: 80; Row: 50; Color: True),
+   (Col: 80; Row: 25; Color: True) // Reserved for TargetEntry
+  );
+
+{ .MVC. were commented:
+   BW modes are rejected on my (colour) configuration. I can't imagine
+   OS/2 running on MCGA anyway... ;-)
+   (Col: 40; Row: 25;Color: False),
+   (Col: 80; Row: 25;Color: False),
+   The following modes wouldn't work on plain VGA; is it useful to check
+   for their availability on the program startup?
+   (Col: 132;Row: 25;Color: True),
+   (Col: 132;Row: 30;Color: True),
+   (Col: 132;Row: 43;Color: True),
+   (Col: 132;Row: 50;Color: True),
+}
+
+Function SysSetVideoMode (Const Mode : TVideoMode) : Boolean;
+
+Var
+  I : Integer;
+
+begin
+  I:=SysVideoModeCount-1;
+  SysSetVideoMode:=False;
+  While (I>=0) and Not SysSetVideoMode do
+    If (Mode.col=SysVMD[i].col) and
+       (Mode.Row=SysVMD[i].Row) and
+       (Mode.Color=SysVMD[i].Color) then
+      SysSetVideoMode:=True
+    else
+      Dec(I);  
+  If SysSetVideoMode then
+    begin
+    SysVideoModeSelector(Mode);
+    ScreenWidth:=SysVMD[I].Col;
+    ScreenHeight:=SysVMD[I].Row;
+    ScreenColor:=SysVMD[I].Color;
+    end;
+end;
+  
+Function SysGetVideoModeData (Index : Word; Var Data : TVideoMode) : boolean;
+
+begin
+  SysGetVideoModeData:=(Index<=SysVideoModeCount);
+  If SysGetVideoModeData then
+    Data:=SysVMD[Index];
+end;
+
+Function SysGetVideoModeCount : Word;
+
+begin
+  SysGetVideoModeCount:=SysVideoModeCount;
+end;
 
 procedure SysClearScreen;
 
 begin
-    VioScrollDn (0, 0, word (-1), word (-1), word (-1), PWord (@EmptyCell)^, 0);
-    Move (VideoBuf^, OldVideoBuf^, VideoBufSize);
+  VioScrollDn (0, 0, word (-1), word (-1), word (-1), PWord (@EmptyCell)^, 0);
+  Move (VideoBuf^, OldVideoBuf^, VideoBufSize);
 end;
 
 
@@ -360,91 +354,128 @@ procedure SysUpdateScreen (Force: boolean);
 var SOfs, CLen: cardinal;
 
 begin
-    if LockUpdateScreen = 0 then
-        begin
-            if not (Force) then
-                asm
-                    cld
-                    mov esi, VideoBuf
-                    mov edi, OldVideoBuf
-                    mov eax, VideoBufSize
-                    mov ecx, eax
-                    shr ecx, 1
-                    shr ecx, 1
-                    repe
-                    cmpsd
-                    je @no_update
-                    inc ecx
-                    mov edx, eax
-                    mov ebx, ecx
-                    shl ebx, 1
-                    shl ebx, 1
-                    sub edx, ebx
-                    mov SOfs, edx
-                    mov Force, 1
-                    std
-                    mov edi, eax
-                    mov esi, VideoBuf
-                    add eax, esi
-                    sub eax, 4
-                    mov esi, eax
-                    mov eax, OldVideoBuf
-                    add eax, edi
-                    sub eax, 4
-                    mov edi, eax
-                    repe
-                    cmpsd
-                    inc ecx
-                    shl ecx, 1
-                    shl ecx, 1
-                    mov CLen, ecx
+  if not (Force) then
+    asm
+    cld
+    mov esi, VideoBuf
+    mov edi, OldVideoBuf
+    mov eax, VideoBufSize
+    mov ecx, eax
+    shr ecx, 1
+    shr ecx, 1
+    repe
+    cmpsd
+    je @no_update
+    inc ecx
+    mov edx, eax
+    mov ebx, ecx
+    shl ebx, 1
+    shl ebx, 1
+    sub edx, ebx
+    mov SOfs, edx
+    mov Force, 1
+    std
+    mov edi, eax
+    mov esi, VideoBuf
+    add eax, esi
+    sub eax, 4
+    mov esi, eax
+    mov eax, OldVideoBuf
+    add eax, edi
+    sub eax, 4
+    mov edi, eax
+    repe
+    cmpsd
+    inc ecx
+    shl ecx, 1
+    shl ecx, 1
+    mov CLen, ecx
 @no_update:
-                end
-            else
-                begin
-                    SOfs := 0;
-                    CLen := VideoBufSize;
-                end;
-            if Force then
-                begin
-                    VioShowBuf (SOfs, CLen, 0);
-                    Move (VideoBuf^ [SOfs div SizeOf (TVideoCell)],
-                            OldVideoBuf^ [SOfs div SizeOf (TVideoCell)], CLen);
-                end;
-        end;
+    end
+  else
+    begin
+    SOfs := 0;
+    CLen := VideoBufSize;
+    end;
+  // .MVC. Move video buffer to system video buffer.
+  Move(VideoBuf^,SysVideoBuf^,VideoBufSize);
+  if Force then
+    begin
+    VioShowBuf (SOfs, CLen, 0);
+    Move (VideoBuf^ [SOfs div SizeOf (TVideoCell)],
+          OldVideoBuf^ [SOfs div SizeOf (TVideoCell)], CLen);
+    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
+    InitDriver        : @SysInitVideo;
+    DoneDriver        : @SysDoneVideo;
+    UpdateScreen      : @SysUpdateScreen;
+    ClearScreen       : @SysClearScreen;
+    SetVideoMode      : @SysSetVideoMode;
+    GetVideoModeCount : @SysGetVideoModeCount;
+    GetVideoModeData  : @SysGetVideoModedata;
+    SetCursorPos      : @SysSetCursorPos;
+    GetCursorType     : @SysGetCursorType;
+    SetCursorType     : @SysSetCursorType;
+    GetCapabilities   : @SysGetCapabilities
   );
 
+procedure TargetEntry;
+
+var
+  PScr: pointer;
+
+begin
+{Remember original video mode, cursor type and high bit behaviour setting}
+  OrigVioMode.cb := SizeOf (OrigVioMode);
+  VioGetMode (OrigVioMode, 0);
+  VioGetCurType (OrigCurType, 0);
+  VioGetCurPos (OrigCurRow, OrigCurCol, 0);
+  with OrigHighBit do
+    begin
+    cb := 6;
+    rType := 2;
+    end;
+  VioGetState (OrigHighBit, 0);
+  { Register the curent video mode in reserved slot in System Modes}
+  with OrigVioMode do
+    begin
+    {Assume we have at least 16 colours available in "colour" modes}
+    SysVMD[SysVideoModeCount-1].Col:=Col;
+    SysVMD[SysVideoModeCount-1].Row:=Row;
+    SysVMD[SysVideoModeCount-1].Color:=(Color >= Colors_16);
+    end;
+  {Get the address of the original videobuffer and size.}
+  if VioGetBuf (PScr, PWord (@OrigScreenSize)^, 0) = 0 then
+    begin
+    PScr := SelToFlat (TFarPtr (PScr));
+    GetMem (OrigScreen, OrigScreenSize);
+    Move (PScr^, OrigScreen^, OrigScreenSize);
+    end;
+end;
+
+
 initialization
   SetVideoDriver(SysVideoDriver);
-  RegisterVideoModes;
   TargetEntry;
-
-finalization
-  UnRegisterVideoModes;
 end.
 
 {
   $Log$
-  Revision 1.5  2001-09-21 19:50:19  michael
+  Revision 1.6  2001-10-06 22:28:24  michael
+  + Merged video mode selection/setting system
+
+  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)
 
+  Revision 1.2.2.4  2001/10/06 22:23:40  michael
+  + Better video mode selection/setting system
+
   Revision 1.2.2.3  2001/09/21 18:42:08  michael
   + Implemented support for custom video drivers.
 

+ 22 - 49
rtl/unix/video.pp

@@ -1,6 +1,5 @@
 {
     $Id$
-
     This file is part of the Free Pascal run time library.
     Copyright (c) 1999-2000 by Florian Klaempfl
     member of the Free Pascal development team
@@ -32,7 +31,6 @@ var
   LastCursorType : byte;
   TtyFd: Longint;
   Console: Boolean;
-  OldVideoBuf: PVideoBuf;
 {$ifdef logging}
   f: file;
 
@@ -571,18 +569,6 @@ begin
 {$ifndef CPUI386}
   LowAscii:=false;
 {$endif CPUI386}
-  if VideoBufSize<>0 then
-   begin
-     clearscreen;
-     if Console then
-      SetCursorPos(1,1)
-     else
-      begin
-        if not SendEscapeSeqNdx(cursor_home) then
-          SendEscapeSeq(#27'[H');
-      end;
-     exit;
-   end;
   { check for tty }
   ThisTTY:=TTYName(stdinputhandle);
   if IsATTY(stdinputhandle) then
@@ -624,10 +610,6 @@ begin
      CursorX:=1;
      CursorY:=1;
      ScreenColor:=True;
-     { allocate pmode memory buffer }
-     VideoBufSize:=ScreenWidth*ScreenHeight*2;
-     GetMem(VideoBuf,VideoBufSize);
-     GetMem(OldVideoBuf,VideoBufSize);
      { Start with a clear screen }
      if not Console then
       begin
@@ -661,7 +643,6 @@ begin
          ACSIn:='';
          ACSOut:='';
        end;
-     ClearScreen;
 {$ifdef logging}
      assign(f,'video.log');
      rewrite(f,1);
@@ -675,10 +656,7 @@ end;
 
 procedure SysDoneVideo;
 begin
-  if VideoBufSize=0 then
-   exit;
   prepareDoneVideo;
-  ClearScreen;
   if Console then
    SetCursorPos(1,1)
   else
@@ -690,9 +668,6 @@ begin
      SetCursorType(crUnderLine);
      SendEscapeSeq(#27'[H');
    end;
-  FreeMem(VideoBuf,VideoBufSize);
-  FreeMem(OldVideoBuf,VideoBufSize);
-  VideoBufSize:=0;
   ACSIn:='';
   ACSOut:='';
   doneVideoDone;
@@ -709,14 +684,13 @@ end;
 
 procedure SysClearScreen;
 begin
-  FillWord(VideoBuf^,VideoBufSize shr 1,$0720);
   if Console then
-   UpdateScreen(true)
+    UpdateScreen(true)
   else
-   begin
-     SendEscapeSeq(#27'[0m');
-     SendEscapeSeqNdx(clear_screen);
-   end;
+    begin
+    SendEscapeSeq(#27'[0m');
+    SendEscapeSeqNdx(clear_screen);
+    end;
 end;
 
 
@@ -828,41 +802,37 @@ begin
   end;
 end;
 
-
-function DefaultVideoModeSelector(const VideoMode: TVideoMode; Params: Longint): Boolean;
-begin
-  DefaultVideoModeSelector:=false;
-end;
-
-
-procedure RegisterVideoModes;
-begin
-end;
-
 Const
+  SysVideoMode : TVideoMode = (
+    Col   : 80;
+    Row   : 25;
+    Color : True;
+  );
+
   SysVideoDriver : TVideoDriver = (
     InitDriver : @SysInitVideo;
     DoneDriver : @SysDoneVideo;
     UpdateScreen : @SysUpdateScreen;
     ClearScreen : @SysClearScreen;
     SetVideoMode : Nil;
-    HasVideoMode : Nil;
+    GetVideoModeCount : Nil;
+    GetVideoModeData : Nil;
     SetCursorPos : @SysSetCursorPos;
     GetCursorType : @SysGetCursorType;
     SetCursorType : @SysSetCursorType;
-    GetCapabilities : @SysGetCapabilities
+    GetCapabilities : @SysGetCapabilities;
+    DefaultVideoMode : (Col : 80; Row : 25;Color : True);
   );
 
 initialization
   SetVideoDriver(SysVideoDriver);
-  RegisterVideoModes;
-
-finalization
-  UnRegisterVideoModes;
 end.
 {
   $Log$
-  Revision 1.8  2001-09-21 19:50:19  michael
+  Revision 1.9  2001-10-06 22:28:25  michael
+  + Merged video mode selection/setting system
+
+  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
@@ -877,6 +847,9 @@ end.
   Revision 1.4  2001/07/30 21:38:55  peter
     * m68k updates merged
 
+  Revision 1.2.2.9  2001/10/06 22:23:41  michael
+  + Better video mode selection/setting system
+
   Revision 1.2.2.8  2001/09/21 18:42:09  michael
   + Implemented support for custom video drivers.
 

+ 21 - 52
rtl/win32/video.pp

@@ -27,11 +27,8 @@ uses
 {$i video.inc}
 
 var
-  OldVideoBuf : PVideoBuf;
   ConsoleInfo : TConsoleScreenBufferInfo;
   ConsoleCursorInfo : TConsoleCursorInfo;
-  MaxVideoBufSize : DWord;
-
 
 procedure SysInitVideo;
 
@@ -39,52 +36,37 @@ begin
   ScreenColor:=true;
   GetConsoleScreenBufferInfo(TextRec(Output).Handle, ConsoleInfo);
   GetConsoleCursorInfo(TextRec(Output).Handle, ConsoleCursorInfo);
-
-  with ConsoleInfo.srWindow do
-    begin
-       ScreenWidth:=right-left+1;
-       ScreenHeight:=bottom-top+1;
-    end;
-
-  { srWindow is sometimes bigger then dwMaximumWindowSize
-    this led to wrong ScreenWidth and ScreenHeight values PM }
-  { damned: its also sometimes less !! PM }
+  {
+    About the ConsoleCursorInfo record: There are 3 possible
+    structures in it that can be regarded as the 'screen':
+    - dwsize   : contains the cols & row in current screen buffer.
+    - srwindow : Coordinates (relative to buffer) of upper left 
+                 & lower right corners of visible console.
+    - dmMaximumWindowSize : Maximal size of Screen buffer.
+    The first implementation of video used srWindow. After some
+    bug-reports, this was switched to dwMaximumWindowSize.
+  }
   with ConsoleInfo.dwMaximumWindowSize do
     begin
-       {if ScreenWidth>X then}
-         ScreenWidth:=X;
-       {if ScreenHeight>Y then}
-         ScreenHeight:=Y;
+    ScreenWidth:=X;
+    ScreenHeight:=Y;
     end;
-
   { TDrawBuffer only has FVMaxWidth elements
     larger values lead to crashes }
   if ScreenWidth> FVMaxWidth then
     ScreenWidth:=FVMaxWidth;
-
   CursorX:=ConsoleInfo.dwCursorPosition.x;
   CursorY:=ConsoleInfo.dwCursorPosition.y;
   if not ConsoleCursorInfo.bvisible then
     CursorLines:=0
   else
     CursorLines:=ConsoleCursorInfo.dwSize;
-
-  { allocate back buffer }
-  MaxVideoBufSize:= ScreenWidth * ScreenHeight * 2;
-  VideoBufSize:=ScreenWidth*ScreenHeight*2;
-
-  GetMem(VideoBuf,MaxVideoBufSize);
-  GetMem(OldVideoBuf,MaxVideoBufSize);
 end;
 
 
 procedure SysDoneVideo;
 begin
   SetCursorType(crUnderLine);
-  FreeMem(VideoBuf,MaxVideoBufSize);
-  FreeMem(OldVideoBuf,MaxVideoBufSize);
-  VideoBufSize:=0;
-  VideoInitialized:=false;
 end;
 
 
@@ -145,16 +127,8 @@ begin
    SetConsoleCursorInfo(TextRec(Output).Handle,ConsoleCursorInfo);
 end;
 
-
-function DefaultVideoModeSelector(const VideoMode: TVideoMode; Params: Longint): Boolean;
-begin
-  DefaultVideoModeSelector:=true;
-end;
-
-
 procedure SysClearScreen;
 begin
-  FillWord(VideoBuf^,VideoBufSize div 2,$0720);
   UpdateScreen(true);
 end;
 
@@ -182,8 +156,6 @@ var
    smallforce  : boolean;
 (*
 begin
-  if LockUpdateScreen<>0 then
-   exit;
   if not force then
    begin
      asm
@@ -342,12 +314,6 @@ begin
    end;
 end;
 
-procedure RegisterVideoModes;
-begin
-  { don't know what to do for win32 (FK) }
-  RegisterVideoMode(80, 25, True, @DefaultVideoModeSelector, $00000003);
-end;
-
 Const
   SysVideoDriver : TVideoDriver = (
     InitDriver : @SysInitVideo;
@@ -355,7 +321,8 @@ Const
     UpdateScreen : @SysUpdateScreen;
     ClearScreen : @SysClearScreen;
     SetVideoMode : Nil;
-    HasVideoMode : Nil;
+    GetVideoModeCount : Nil;
+    GetVideoModeData : Nil;
     SetCursorPos : @SysSetCursorPos;
     GetCursorType : @SysGetCursorType;
     SetCursorType : @SysSetCursorType;
@@ -365,14 +332,13 @@ Const
 
 initialization
   SetVideoDriver(SysVideoDriver);
-  RegisterVideoModes;
-
-finalization
-  UnRegisterVideoModes;
 end.
 {
   $Log$
-  Revision 1.6  2001-09-21 19:50:19  michael
+  Revision 1.7  2001-10-06 22:28:24  michael
+  + Merged video mode selection/setting system
+
+  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
@@ -387,6 +353,9 @@ end.
   Revision 1.2  2001/04/10 21:28:36  peter
     * removed warnigns
 
+  Revision 1.1.2.6  2001/10/06 22:23:41  michael
+  + Better video mode selection/setting system
+
   Revision 1.1.2.5  2001/09/21 18:42:09  michael
   + Implemented support for custom video drivers.