2
$Id: video.inc,v 1.7 2002/09/07 15:07:46 peter Exp $
3
This file is part of the Free Pascal run time library.
4
Copyright (c) 1999-2000 by the Free Pascal development team
6
See the file COPYING.FPC, included in this distribution,
7
for details about the copyright.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
**********************************************************************}
16
LockUpdateScreen : Integer = 0;
18
Procedure LockScreenUpdate;
21
Inc(LockUpdateScreen);
24
Procedure UnLockScreenUpdate;
27
If LockUpdateScreen>0 then
28
Dec(LockUpdateScreen);
31
Function GetLockScreenCount : integer;
33
GetLockScreenCount:=LockUpdateScreen;
37
CurrentVideoDriver : TVideoDriver;
38
NextVideoMode : TVideoMode;
41
VideoInitialized : Boolean = False;
42
DriverInitialized : Boolean = False;
43
NextVideoModeSet : Boolean = False;
45
Function SetVideoDriver (Const Driver : TVideoDriver) : Boolean;
46
{ Sets the videodriver to be used }
48
If Not VideoInitialized then
50
CurrentVideoDriver:=Driver;
51
DriverInitialized:=true;
52
NextVideoModeSet:=false;
54
SetVideoDriver:=Not VideoInitialized;
57
Procedure GetVideoDriver (Var Driver : TVideoDriver);
58
{ Retrieves the current videodriver }
60
Driver:=CurrentVideoDriver;
63
{ ---------------------------------------------------------------------
64
External functions that use the video driver.
65
---------------------------------------------------------------------}
67
Procedure FreeVideoBuf;
70
if (VideoBuf<>Nil) then
80
Procedure AssignVideoBuf (OldCols, OldRows : Word);
82
Var NewVideoBuf,NewOldVideoBuf : PVideoBuf;
83
S,I,C,R,NewVideoBufSize : Integer;
86
S:=SizeOf(TVideoCell);
87
NewVideoBufSize:=ScreenWidth*ScreenHeight*S;
88
GetMem(NewVideoBuf,NewVideoBufSize);
89
GetMem(NewOldVideoBuf,NewVideoBufSize);
90
// Move contents of old videobuffers to new if there are any.
91
if (VideoBuf<>Nil) then
93
If (ScreenWidth<OldCols) then
97
If (ScreenHeight<OldRows) then
103
Move(VideoBuf^[I*OldCols],NewVideoBuf^[I*ScreenWidth],S*C);
104
Move(OldVideoBuf^[I*OldCols],NewOldVideoBuf^[I*ScreenWidth],S*C);
108
VideoBufSize:=NewVideoBufSize;
109
VideoBuf:=NewVideoBuf;
110
OldVideoBuf:=NewOldVideoBuf;
116
If Not VideoInitialized then
118
If Assigned(CurrentVideoDriver.InitDriver) then
119
CurrentVideoDriver.InitDriver;
120
VideoInitialized:=True;
121
if NextVideoModeSet then
122
SetVideoMode(NextVideoMode)
133
If VideoInitialized then
135
If Assigned(CurrentVideoDriver.DoneDriver) then
136
CurrentVideoDriver.DoneDriver;
138
VideoInitialized:=False;
142
Procedure UpdateScreen (Force : Boolean);
145
If (LockUpdateScreen<=0) and
146
Assigned(CurrentVideoDriver.UpdateScreen) then
147
CurrentVideoDriver.UpdateScreen(Force);
150
Procedure ClearScreen;
153
// Should this not be the current color ?
154
FillWord(VideoBuf^,VideoBufSize shr 1,$0720);
155
If Assigned(CurrentVideoDriver.ClearScreen) then
156
CurrentVideoDriver.ClearScreen
159
FillWord(OldVideoBuf^,VideoBufSize shr 1,$0720);
162
Procedure SetCursorType (NewType : Word);
165
if Assigned(CurrentVideoDriver.SetCursorType) then
166
CurrentVideoDriver.SetCursorType(NewType)
169
Function GetCursorType : Word;
172
if Assigned(CurrentVideoDriver.GetCursorType) then
173
GetCursorType:=CurrentVideoDriver.GetCursorType()
178
procedure SetCursorPos(NewCursorX, NewCursorY: Word);
181
If Assigned(CurrentVideoDriver.SetCursorPos) then
182
CurrentVideoDriver.SetCursorPos(NewCursorX, NewCursorY)
185
function GetCapabilities: Word;
187
If Assigned(CurrentVideoDriver.GetCapabilities) then
188
GetCapabilities:=CurrentVideoDriver.GetCapabilities()
194
{ ---------------------------------------------------------------------
196
---------------------------------------------------------------------}
199
procedure GetVideoMode(var Mode: TVideoMode);
201
Mode.Col := ScreenWidth;
202
Mode.Row := ScreenHeight;
203
Mode.Color := ScreenColor;
206
Function SetVideoMode(Const Mode: TVideoMode) : Boolean;
212
SetVideoMode:=DriverInitialized;
213
if not DriverInitialized then
215
If VideoInitialized then
219
If Assigned(CurrentVideoDriver.SetVideoMode) then
220
SetVideoMode:=CurrentVideoDriver.SetVideoMode(Mode)
225
AssignVideoBuf(OldC,Oldr);
230
NextVideoModeSet:=true;
235
Function GetVideoModeCount : Word;
238
If Assigned(CurrentVideoDriver.GetVideoModeCount) then
239
GetVideoModeCount:=CurrentVideoDriver.GetVideoModeCount()
241
GetVideoModeCount:=1;
244
Function GetVideoModeData(Index : Word; Var Data: TVideoMode) : Boolean;
247
If Assigned(CurrentVideoDriver.GetVideoModeData) then
248
GetVideoModeData:=CurrentVideoDriver.GetVideoModeData(Index,Data)
251
GetVideoModeData:=(Index=0);
252
If GetVideoModeData then
257
function DefaultErrorHandler(AErrorCode: Longint; AErrorInfo: Pointer): TErrorHandlerReturnValue;
259
ErrorCode := AErrorCode;
260
ErrorInfo := AErrorInfo;
261
DefaultErrorHandler := errAbort; { return error code }
266
Revision 1.7 2002/09/07 15:07:46 peter
267
* old logs removed and tabs fixed