SVGACORE.DEF 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. FOREIGN DEFINITION MODULE SvgaCore;
  2. (*
  3. **
  4. ** !! LOW LEVEL MODULE !!
  5. ** !! NOT FOR DIRECT USER IMPORT !!
  6. **
  7. **
  8. **
  9. ** Kevin Baker,
  10. ** CSP-960 Project, Semester 2, 1992
  11. **
  12. **
  13. ** Implementation:
  14. **
  15. ** Currently only SVGA 256 colour operations are supported. It is
  16. ** possible to switch to a Super EGA mode but there are no graphics
  17. ** primitives implemented.
  18. *)
  19. IMPORT IMPLEMENTATION FROM "svgacore.obj" ;
  20. FROM GrafCore IMPORT WriteMode;
  21. FROM SYSTEM IMPORT BYTE,ADDRESS;
  22. FROM Types IMPORT SHORTCARD, BYTECARD;
  23. CONST
  24. (* ======================== Video modes ========================= *)
  25. SEGA_Mode_0 = 60; (* 800 x 600 16 colours !! UNSUPPORTED *)
  26. SEGA_Mode_1 = 61; (* 1024 x 768 16 colours !! UNSUPPORTED *)
  27. SEGA_Mode_2 = 62; (* 1280 x 1024 16 colours !! UNSUPPORTED *)
  28. SVGA_Mode_0 = 80; (* 640 x 400 256 colours *)
  29. SVGA_Mode_1 = 81; (* 640 x 480 256 colours *)
  30. SVGA_Mode_2 = 82; (* 800 x 600 256 colours *)
  31. SVGA_Mode_3 = 83; (* 1024 x 768 256 colours *)
  32. SVGA_Mode_4 = 84; (* 1280 x 1024 256 colours *)
  33. TYPE
  34. Colour = RECORD
  35. red : BYTECARD;
  36. green : BYTECARD;
  37. blue : BYTECARD;
  38. END;
  39. Palette256 = ARRAY[0..255] OF Colour;
  40. CardType = SET OF (Vesa, Ativga, Everex, Compaq, Ncr, Trident8800,
  41. Trident8900, Video7, Genoa, Cirrus, Paradise,
  42. Chipstech, Tseng, Tseng4000, Aheada, Aheadb, Oaktech);
  43. VAR
  44. vga512,
  45. vga1024,
  46. cirrus,
  47. everex,
  48. paradise,
  49. tseng,
  50. trident,
  51. t8900,
  52. ativga,
  53. aheada,
  54. aheadb,
  55. oaktech,
  56. video7,
  57. chipstech,
  58. tseng4,
  59. genoa,
  60. ncr,
  61. compaq,
  62. vesa : BOOLEAN;
  63. curbk,
  64. maxx,
  65. maxy,
  66. xwidth : SHORTCARD;
  67. PROCEDURE TextMode;
  68. (*
  69. ** Place card in text mode 3. Present for testing purposes
  70. *)
  71. PROCEDURE DetectSVGA() : BOOLEAN;
  72. (*
  73. ** Returns TRUE if svga card detected
  74. ** FALSE if svga not detected
  75. *)
  76. PROCEDURE GetVideoModeSVGA(VAR textcols : CARDINAL) : CARDINAL;
  77. (*
  78. ** Returns the current video mode, and sets the variable textcols to
  79. ** the number of text columns for that mode.
  80. *)
  81. PROCEDURE SetSvgaMode(mode : CARDINAL);
  82. (*
  83. ** Switches video mode. Assumes that video mode is one of the supported
  84. ** SVGA/SEGA graphics modes - [60..62,80..84]
  85. ** If video mode is not one of these values, does nothing.
  86. *)
  87. PROCEDURE SetWriteModeSVGA(wmode : WriteMode);
  88. (*
  89. ** Sets the default method for interaction with background pixels in
  90. ** line drawing, block restoration, and char/string output.
  91. ** If default method is replaceMode, object overwrites the current screen
  92. ** contents; if the default method is xorMode, the object is XORed with
  93. ** the current screen contents, and so on.
  94. *)
  95. PROCEDURE ConfigureSvgaCore(card : CARDINAL);
  96. (*
  97. ** Configure SvgaCore driver to the card type specified. This is usually
  98. ** called internally by DetectSVGA when the card is identified but in some
  99. ** cases the Detect procedure may fail. In this case ConfigureSvgaCore can
  100. ** be called to configure the driver to a particular card.
  101. **
  102. ** ConfigureSvgaCore expects the following global variables to be
  103. ** intialized prior to its call
  104. **
  105. ** vga512 -> TRUE if 512K ram present FALSE if not
  106. ** vga1024 -> TRUE if 1Meg ram present FALSE if not
  107. **
  108. **
  109. ** Example:
  110. ** DetectSVGA wrongly detected the Adapter, but the user is sure that
  111. ** his adapter is one of the supported types, e.g. Trident
  112. **
  113. ** He knows the card has 1 Meg of ram so he sets up the library like so
  114. **
  115. ** vga512 := TRUE;
  116. ** vga1024 := TRUE;
  117. ** ConfigureSvgaCore(trident);
  118. **
  119. *)
  120. (*========================================================*)
  121. (*== ==*)
  122. (*== Return the colour value of a specified pixel ==*)
  123. (*== ==*)
  124. (*========================================================*)
  125. PROCEDURE RdPxlSVGA(x1, y1 : INTEGER) : CARDINAL;
  126. (*========================================================*)
  127. (*== ==*)
  128. (*== Set a pixel in specified colour ==*)
  129. (*== ==*)
  130. (*========================================================*)
  131. PROCEDURE WrPxlSVGA(x1, y1 : INTEGER;Colour : CARDINAL);
  132. (*========================================================*)
  133. (*== ==*)
  134. (*== Draw a line from (x1,y1) to (x2,y2) in ==*)
  135. (*== specified colour ==*)
  136. (*== ==*)
  137. (*========================================================*)
  138. PROCEDURE LineSVGA(x1, y1,
  139. x2, y2 : INTEGER;
  140. colour : CARDINAL);
  141. (*========================================================*)
  142. (*== ==*)
  143. (*== Write a character at specified screen position ==*)
  144. (*== (x,y) refers to coordinates of top-left hand ==*)
  145. (*== corner of the rectangular cell in which the char ==*)
  146. (*== is drawn. The character itself is drawn in the ==*)
  147. (*== colour "fg", while the rest of the cell is in ==*)
  148. (*== colour "bg". ==*)
  149. (*== fg. The character cell is 8 pixels wide ==*)
  150. (*========================================================*)
  151. PROCEDURE WrCharSVGA(ch : CHAR; col, row : INTEGER; fg, bg : CARDINAL);
  152. (*========================================================*)
  153. (*== ==*)
  154. (*== Write a string at a specified screen position ==*)
  155. (*== ==*)
  156. (*========================================================*)
  157. PROCEDURE WrStrSVGA(str : ARRAY OF CHAR;
  158. x, y : INTEGER;
  159. fg, bg : CARDINAL);
  160. (*========================================================*)
  161. (*== ==*)
  162. (*== Clear the screen with specified colour ==*)
  163. (*== ==*)
  164. (*========================================================*)
  165. PROCEDURE ClsSVGA(colour : CARDINAL);
  166. (*========================================================*)
  167. (*== ==*)
  168. (*== Block save/restore images to and from screen and ==*)
  169. (*== memory ==*)
  170. (*== ==*)
  171. (*========================================================*)
  172. PROCEDURE BlockSaveSVGA(block : ADDRESS;
  173. x1, y1,
  174. x2, y2 : INTEGER) : SHORTCARD;
  175. (*
  176. ** Stores graphics data in colour plane bitmap format at the
  177. ** specified address. Used for SVGA modes 80,81,82,83,84.
  178. **
  179. ** IT IS THE RESPONSIBILITY OF THE CALLER TO ENSURE THAT ENOUGH
  180. ** CONTIGUOUS ALLOCATED MEMORY IS AVAILABLE AT THE SPECIFIED ADDRESS !
  181. **
  182. ** The space required can be calculated via the formula
  183. **
  184. ** (x2 - x1 + 1)*(y2 - y1 + 1) + 5
  185. **
  186. ** e.g. for BlockSaveSVGA(blk,100,100,200,200)
  187. ** (200 - 100 + 1) * (200 - 100 + 1) + 5
  188. ** => 101 * 101 + 5
  189. ** => 10206 bytes
  190. **
  191. ** IMPLEMENTATION RESTRICTION : THE LARGEST MEMORY BLOCK THAT CAN BE
  192. ** WRITTEN IN A SINGLE CALL IS 64k bytes.
  193. **
  194. ** Returns the number of bytes storage actually written.
  195. *)
  196. PROCEDURE BlockRestoreSVGA(block : ADDRESS;
  197. x1, y1 : INTEGER);
  198. (*
  199. ** Restores a block in a 256 colour SVGA mode
  200. *)
  201. (*========================================================*)
  202. (*== ==*)
  203. (*== Set/Get the VGA 256 colour palette registers ==*)
  204. (*== ==*)
  205. (*========================================================*)
  206. PROCEDURE SetPal256( PaletteBuffer : ADDRESS;
  207. StartIndex,
  208. NumberOfCol : SHORTCARD);
  209. (*
  210. ** Set the VGA colour palette.
  211. ** PaletteBuffer -> points to buffer with 3 bytes for each colour to be set.
  212. ** StartIndex -> colour register to start from
  213. ** NumberOfCol -> number of colour registers to set
  214. *)
  215. PROCEDURE GetPal256( PaletteBuffer : ADDRESS;
  216. StartIndex,
  217. NumberOfCol : SHORTCARD);
  218. (*
  219. ** PaletteBuffer -> points to buffer with 3 bytes for each colour read.
  220. ** StartIndex -> colour register to start from
  221. ** NumberOfCol -> number of colour registers to read
  222. *)
  223. END SvgaCore.