video.pp 4.2 KB

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