home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / CHOSNECK / CHOS2.ZIP / CHOSNECK.2ND / STUFF / DATAS.ZIP / ART52D.SCR < prev    next >
Encoding:
Text File  |  1989-06-08  |  13.7 KB  |  302 lines

  1. <head>
  2. <title="...forever...">
  3. <font=monaco10.fnt>
  4. <font=newy36.fnt>
  5. <font=time24.fnt>
  6. <image=back.raw w=256 h=256 t=-1>
  7. <buf=4502>
  8. <bgcolor=-1>
  9. <background=0> 
  10. <link_color=000>
  11. <module=console.mod>
  12. <pal=back.pal>
  13. colors:
  14. 251 - black
  15. </head>
  16. <body>
  17. <frame x=0 y=0 w=640 h=4502 b=-1 c=-1>
  18.  
  19.  
  20. .: GEM in one pill :.
  21. -----------------------------
  22. 5) VDI (Virtual Device Interface)
  23. --------------------------------------
  24.  
  25. AES  and  VDI  are  independent. As it's well known AES relays on VDI graphical 
  26. functions.  From time to time they can get in conflict, one with each other.
  27.  
  28. We can use VDI without calling the AES and we can use AES (functions displaying 
  29. menu  and  dialog  boxes)  without  the  initialisation of VDI. But in the most 
  30. cases, our programs will be using both of them. Why use the VDI? There are 200% 
  31. faster  solutions  of  drawing  with  the  use of BIOS and XBIOS. The answer is 
  32. simple,  each  addition such as graphics card or extended resolutions on Falcon 
  33. are  fully  compatible  with  VDI,  but  not for sure with BIOS and XBIOS. It's 
  34. rather question of reaching the widest user audience. 
  35.  
  36. REPETITION FROM THE VDI INITIALISATION
  37. Firstly  we  have to find the physical screen handle (PHYS_HANDLE from now on). 
  38. AES sets it in the beginning, so we can get it with graf_handle() call. We need 
  39. also the height in pixels of our standard text character. 
  40.  
  41. Using  this  handle  (PHYS_HANDLE)  we  can open virtual workstation (screen is 
  42. "virtual",  the  others  are  "real".)  with  v_openvwk(). This call returns an 
  43. information  about  displayed  screen  together  with  VDI  workstation  handle 
  44. (STAT_HANDLE)  and  this  handle is used with all further VDI calls. If we have 
  45. handle  of  VDI  workstation,  we  open the sample window to display something. 
  46. Problem is that VDI doesn't understand the absolute screen coordinates (640*480 
  47. or  anything  else).How  to find the correct coordinates? Remember that size of 
  48. the  area  to  display is (overall size of the window MINUS size of all gadgets 
  49. like closers, sliders etc.). There is a solution. We know how to handle windows 
  50. to  draw  within  them.  We use wind_get() with WORKXYWH flag to get four words 
  51. filled  with appropriate values (x,y,w,h). Now we have to convert them into VDI 
  52. coordinates(x1,y1,x2,y2): 
  53.  
  54. VDI 3rd word = AES 3rd word + AES 1st word
  55. VDI 4rd word = AES 4th word + AES 2nd word
  56.  
  57. AES 3rd word = VDI 3rd word - AES 1st word
  58. AES 4th word = VDI 4th word - AES 2nd word
  59.  
  60. Now  we have the rectangle in which we can do something. We need to specify the 
  61. VDI  clipping  rectangle  with  vs_clip()  to prevent the content of the window 
  62. "spilling out" of it. As a parameter to this call we use handle of workstation, 
  63. coordinates  and  TRUE  flag  to  switch  on  the clipping and 0 flag with NULL 
  64. rectangle to switch off the clipping. We have to switch off the clipping before 
  65. we  exit  the program. Everything lets us to draw anything on the screen but in 
  66. theory. 
  67.  
  68. BASIC IO
  69. There  are  two possible forms of the text output: text and graphical. The text 
  70. one is easier one so we start with it first. 
  71.  
  72. Output  comandds  through  VDI  are  quite  simple.  Firstly we can set all the 
  73. details of the displayed text as we like. We do it with the following call. And 
  74. remember that everything should be set BEFORE the outputting the text: 
  75. - colour
  76.   vst_color(handle, colour);
  77.   colour is BLACK(1) as default.
  78.  
  79. -  rotate  sets  the text angle. Bitmap fonts can be turned in 90 degree steps, 
  80. and vector ones freely: 
  81.   vst_rotate(handle, angle in degrees)
  82. angle = 0-normal, 90 - to the top of the screen, 180- upside down, 270 - to the 
  83. bottom of hte screen. 
  84.  
  85. -  justification this doesn't cover only right /left /center justification, but 
  86. it  has  also  vertical  justification  (with  several  "levels"  of  justify): 
  87.   SUBSCRIPT - text is jusified to the bottom line (descent) 
  88.   SUPERSCRIPT  - text is jusified to the upper line (ascent)
  89. Normally,  the standard settings are used with justification to the left and to 
  90. the  base.  Justified text with microspaces is available through VDI (justified 
  91. text  where  words are in one line without creating big gaps between them). But 
  92. we  have  to  use  the  special version of "text print" to use it. It cannot be 
  93. setted by default. 
  94.   vst_alignment (handle, HALIGN, VALIGN, &HSET, &VSET);
  95. You  set  the  flags that you want in HALIGN and VALIGN, but those that are set 
  96. are  returned  in  HSET  and  VSET. Some devices are not accepting all kinds of 
  97. justification (but hopefully, screen accepts everything :) ). 
  98.  
  99. - effects we can add various effects. In case of GDOS fonts, it's better to use
  100. the  bold version of the font rather than transform it to bold. We have several 
  101. effects to choose: bold, underline, italic, outline, grey, shadow. Shadow isn't 
  102. working at all with all the GDOS versions. vst_effects(handle, effect); Effects 
  103. are set like oridinary binary flags. If effect = 0 text is normal. 
  104.  
  105. FUNCTIONS DISPLAYING TEXT
  106. Most basic one:
  107.  v_gtext(handle,x,y,string);
  108. handle  - VDI handle as usual, x,y -start coordinates, string - NULL terminated 
  109. string. 
  110. For text with microspaces: 
  111.  v_justified (handle, x,y,string, lenght, word_flag, character_flag);
  112. handle,  x, y, string are as above. lenght is a area in pixels on which we want 
  113. to spread the text. Flag of word /character indicates the justification between 
  114. words /characters (0- no/ 1-yes). 
  115.  
  116. The  best solution is to display all the characters that are fitting inside the 
  117. window  plus one additionally, automatically reducing screen area to redraw. We 
  118. know  the  working  area  ( WORKXYWH flag with wind_get() remember?). So we can 
  119. check the lenght of the each text string with: 
  120.  vqt_extent(handle, string, points);
  121. handle and string are obvious. points are four pairs of four words defining the 
  122. minimal area in which fits the text. The proble is in the order of these pairs, 
  123. the order depends from the mode (is the text displayed in 90 degree steps or is 
  124. rotated freelly). 
  125.  
  126. So,  we can loop everything, until we receive one (or a part) of the character, 
  127. print  the  string  and  let the system to clean up everything (both variant of 
  128. outputting text). 
  129.  
  130. BASIC VDI GRAPHIC FUNCTIONS
  131. VDI has several standard shapes to draw called GDP (Graphic Device Primitives). 
  132. This  means that EVERY device driver should support those functions (and we can 
  133. assume  that  they  are always available). One of the values from WORK_OUT [14] 
  134. contains  the  number  of  available  GDP  functions in given device. They also 
  135. contain  the  old  settings  (like  colour),  but they require other parameters 
  136. before they can be used. 
  137.  
  138. GDP functions:
  139.  
  140. a) filled bar
  141. v_bar (handle, points);
  142. handle - VDI handle 
  143. points - points in VDI format
  144.  
  145. b) arc 
  146. v_arc (handle, x, y, radius,angle at start, angle at end);
  147. handle - VDI handle 
  148. x,y - the coordinates of the centre of the circle  
  149. radius  -  horizontal  circle  radius  (horizontal  is set by device coordinate 
  150. system)  angle  at start, angle at end - the angle are in 1/10 of a degree with 
  151. EAST as a 0. 
  152.  
  153. c) filled pie
  154. Problematic.  Atari Compedium talks about v_pieslice(), compute! about v_pie(). 
  155. Check better the documentation of your compiler. Arguments are similar to those 
  156. in v_arc (). 
  157.  
  158. d) filled circle
  159. v_circle (handle, x,y, radius);
  160. Everything self explanatory.
  161. handle - VDI handle 
  162. x,y - the coordinates of the centre of the circle  
  163.  
  164. e) filled ellipse
  165.  
  166. v_ellipse (handle, x, y, radius x, radius y);
  167. handle - VDI handle 
  168. x,y - the coordinates of the centre of the circle  
  169. radius x- horizontal radius
  170. radius y- vertical radius
  171. WARNING!  If  you  don't  use  NDC, the shape is looking different in different 
  172. resolutions. 
  173.  
  174. f) elliptic arc 
  175.  
  176. v_ellarc ( handle, x, y, radius x, radius y, angle at start, angle at end);
  177.  
  178. g) filled elliptic pie
  179.  
  180. v_ellpie (handle, x, y, radius x, radius y, angle at start, angle at end);
  181.  
  182. h) rounded rectangle
  183. v_rbox(handle, points);
  184. handle - VDI handle 
  185. points - in VDI format
  186.  
  187. i) filled rounded rectangle
  188. v_rfbox(handle, points);
  189. as above...
  190.  
  191. That's  all  if it comes about GDP, which with justified text should be present 
  192. within  every  VDI. To be sure we can check all the functions after the opening 
  193. of  the  VDI  workstation.  There  are soe functions that are modyfying the VDI 
  194. default settings: 
  195.  
  196. clipping rectangle (we know that already to well...)
  197. fill colour                vsf_color(); 
  198. fill style                  vsf_interior(); 
  199. style index fill          vsf_style(); 
  200. outline fill perimeter vsf_perimeter();
  201. line colour               vsl_color();
  202. line style                 vsl_type();
  203. line width                vsl_width();
  204.  
  205. VDI BASIC DRAWING FUNCTIONS
  206. To draw anything we have to:
  207. - prepare the screen and palette,
  208. -  set the required attributes. VDI can draw following shapes: pixels, crosses,
  209. stars, rectangles, x and diamonds. 
  210.  
  211. Attributes of drawing shapes we set with functions:
  212.  
  213. vsm_color()  -  sets the colour (colour number from the palette), which is used 
  214. by shape. 
  215. vsm_height() - sets the size of the shape (doesn't work pixels).
  216. vsm_type() - sets the shape from the list of VDI shapes mentioned above.
  217.  
  218. After  setting  of  these  parameters we can draw with v_pmarker(). We can also 
  219. take a look at actually setted attributes with vqm_attributes(). Lines are much 
  220. more  complex.  They  take  the  attributes (colour, style, width, style of the 
  221. lineend)  setted  by the group of functions vsl_xxx(). VDI function responsible 
  222. for drawing lines is very flexible, but complicated a little: 
  223.  
  224. void v_pline (WORD handle, WORD amount of points, WORD *table of points);
  225. handle - VDI handle 
  226. amount  of  points  -  an  amount of pairs of the coordinates (x,y) in array of 
  227. points  describing  vertices  to draw. The end of the first line is treated, as 
  228. the beginning of the second one: 
  229.  
  230. points_table[0], points_table[1]              points_table[2], points_table[3]
  231.                         *---------------------------------*
  232.                         |                                 |
  233.                         |                                 |
  234.                         |                                 |
  235.                         *---------------------------------*
  236. points_table[6],points_table[7]             points_table[4],points_table[5]
  237.  
  238. To  draw  every  shape  we  need an array: (amount of sides+1) * 2 points. In a 
  239. closed shape the first coordinates should be equal to the last in an array. 
  240.  
  241. VDI INQUIRE FUNCTIONS
  242. This group of functions is used to check the actual informations about the VDI. 
  243. Most frequently used are: 
  244.  
  245. vq_chcells()         - returns the size of screen in characters.
  246. vq_color()  - returns the RGB value of specified colour number fro the palette. 
  247. vq_curraddres() - returns the actual text cursor position. 
  248. vq_extnd()          - additional informations about actual device.
  249. vq_gdos()  -  checks  if  GDOS  is  installed  and returns it type and version. 
  250. vq_key_s() - returns the state of SHIFT/ ALT/ CONTROL keys. 
  251. vq_mouse()        - returns the state and position of mouse arrow.
  252. vqf_attributes()   - returns the actual fill style
  253. vql_attributes()   - returns the actual line settings
  254. vqm_attributes() - returns the actual marker (shape) settings.
  255. vqt_attributes()   - returns the actual text settings. 
  256. vqt_extent()       - returns (in pixels) the area covered by text.
  257. v_get_pixel()      - returns the colours of the chosen point on the screen.
  258.  
  259. Most functions are working in similar way, they return the pointer to the array 
  260. filled with values. (Take a look into Atari Compedium!). 
  261.  
  262. VDI INPUT FUNCTIONS
  263. Atari  ST  / TT/ Falcon have two major input devices - mouse and keyboard. Both 
  264. sources  can  be  read  by  VDI  and AES. The differences lay are in the method 
  265. getting  the  information.  AES uses the message system and VDI must to ask the 
  266. device for information (inquire or "poll"). 
  267. Both  methods  have their merits and flaws. The AES way consumes less cpu time, 
  268. but  VDI  is able to fetch the info which we need, not when the message will be 
  269. in the beginning of the que. 
  270.  
  271. Mouse
  272. VDI:  uses  vq_mouse() and vq_keys_s(). vq_mouse() returns 3 words. Two of them 
  273. contain x, y coordinates and one word with two first bits reflecting the actual 
  274. state of the mouse buttons. 
  275. AES:  uses  evnt_mouse(). This call sits and waits until the desired event will 
  276. occur,  which  is a mouse pointer entering the specified part of the screen and 
  277. returns  the  information as above. BUT if the mouse pointer will not enter the 
  278. specified  part  of  the screen, system will not answer on other messages (will 
  279. "jam").  Similar  function  call evnt_button() waits for specified mouse button 
  280. press. 
  281. Monitoring  of  both  (and  many other) messages requires the use of monolithic
  282. "combi-harvester" in shape of evnt_multi(). This function is ENORMOUS and takes 
  283. 22 parameters which lets us to observe anything that AES reports. 
  284.  
  285. Keyboard:
  286. VDI:  There are two possible ways of using the keyboard under VDI, which depend
  287. from  the nature of the data at input. The input can be sampled (system doesn't 
  288. wait  for the RETURN before sending the keypresses) or inquired. But firstly we 
  289. need to set correctly the text cursor. We have to set input mode: 
  290.  vrq_string()   - inquiry mode
  291.  vsm_string()  - sample mode
  292. AES  -  is  much simplier. During keyboard read the evnt_keybd() is used, which 
  293. waits  for  a  keypress  or  alternatively use the evnt_multi(). Both functions 
  294. return  one  word.  Less significant byte in word contains ASCII code, the most 
  295. significant  byte  contains the keyboard code. The keyboard code is useful when 
  296. the desired key doesn't posses the ASCII value (HELP key for instance).
  297.  
  298. <link=art52e.scr>Go to PART #5</l>
  299. </frame>
  300. </body>
  301.  
  302.