1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
{
$Id: video.pp,v 1.5 2004/10/03 20:16:43 armin Exp $
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
Video unit for netware
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
{ 2001/04/16 armin: first version for netware
2002/02/26 armin: changes for current fpc }
unit Video;
interface
{$i videoh.inc}
implementation
uses
dos;
{$i video.inc}
{$i nwsys.inc}
var
MaxVideoBufSize : DWord;
VideoBufAllocated: boolean;
procedure SysInitVideo;
VAR height,width : WORD;
startline, endline : BYTE;
begin
DoneVideo;
ScreenColor:= (_IsColorMonitor <> 0);
_GetSizeOfScreen (height, width);
ScreenWidth := width;
ScreenHeight:= height;
{ TDrawBuffer only has FVMaxWidth elements
larger values lead to crashes }
if ScreenWidth> FVMaxWidth then
ScreenWidth:=FVMaxWidth;
CursorX := _wherex;
CursorY := _wherey;
_GetCursorShape (startline,endline);
{if not ConsoleCursorInfo.bvisible then
CursorLines:=0
else
CursorLines:=ConsoleCursorInfo.dwSize;}
{ allocate back buffer }
MaxVideoBufSize:= ScreenWidth * ScreenHeight * 2;
VideoBufSize := ScreenWidth * ScreenHeight * 2;
LockUpdateScreen := 0;
end;
procedure SysDoneVideo;
begin
SetCursorType(crUnderLine);
end;
function SysGetCapabilities: Word;
begin
SysGetCapabilities:=cpColor or cpChangeCursor;
end;
procedure SysSetCursorPos(NewCursorX, NewCursorY: Word);
begin
_GotoXY (NewCursorX, NewCursorY);
end;
function SysGetCursorType: Word;
var startline, endline : byte;
begin
_GetCursorShape (startline, endline);
CASE startline of
1 : SysGetCursorType := crBlock;
5 : SysGetCursorType := crHalfBlock
ELSE
SysGetCursorType := crUnderline;
END;
{crHidden ?}
end;
procedure SysSetCursorType(NewType: Word);
begin
if newType=crHidden then
_HideInputCursor
else
begin
case NewType of
crUnderline:
_SetCursorShape (9,$A);
crHalfBlock:
_SetCursorShape (5,$A);
crBlock:
_SetCursorShape (1,$A);
end;
_DisplayInputCursor;
end;
end;
{procedure ClearScreen;
begin
FillWord(VideoBuf^,VideoBufSize div 2,$0720);
UpdateScreen(true);
end;}
procedure SysUpdateScreen(Force: Boolean);
begin
if VideoBuf = nil then exit;
if (LockUpdateScreen<>0) or (VideoBufSize = 0) then
exit;
if not force then
begin
asm
pushl %esi
pushl %edi
movl VideoBuf,%esi
movl OldVideoBuf,%edi
movl VideoBufSize,%ecx
shrl $2,%ecx
repe
cmpsl
setne force
popl %edi
popl %esi
end;
end;
if Force then
_CopyToScreenMemory (ScreenHeight, ScreenWidth, VideoBuf, 0, 0);
end;
Const
SysVideoModeCount = 1;
SysVMD : Array[0..SysVideoModeCount-1] of TVideoMode = (
(Col: 80; Row : 25; Color : True));
Function SysSetVideoMode (Const Mode : TVideoMode) : Boolean;
begin
SysSetVideoMode := ((Mode.Col = 80) AND (Mode.Row = 25) AND (Mode.Color));
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;
Const
SysVideoDriver : TVideoDriver = (
InitDriver : @SysInitVideo;
DoneDriver : @SysDoneVideo;
UpdateScreen : @SysUpdateScreen;
ClearScreen : Nil;
SetVideoMode : @SysSetVideoMode;
GetVideoModeCount : @SysGetVideoModeCount;
GetVideoModeData : @SysGetVideoModedata;
SetCursorPos : @SysSetCursorPos;
GetCursorType : @SysGetCursorType;
SetCursorType : @SysSetCursorType;
GetCapabilities : @SysGetCapabilities
);
initialization
VideoBufAllocated := false;
VideoBufSize := 0;
VideoBuf := nil;
SetVideoDriver (SysVideoDriver);
end.
|