home *** CD-ROM | disk | FTP | other *** search
- <head>
- <title="...forever...">
- <font=monaco10.fnt>
- <font=newy36.fnt>
- <font=time24.fnt>
- <image=back.raw w=256 h=256 t=-1>
- <buf=4502>
- <bgcolor=-1>
- <background=0>
- <link_color=000>
- <module=console.mod>
- <pal=back.pal>
- colors:
- 251 - black
- </head>
- <body>
- <frame x=0 y=0 w=640 h=4502 b=-1 c=-1>
-
-
- .: GEM in one pill :.
- -----------------------------
- 5) VDI (Virtual Device Interface)
- --------------------------------------
-
- AES and VDI are independent. As it's well known AES relays on VDI graphical
- functions. From time to time they can get in conflict, one with each other.
-
- We can use VDI without calling the AES and we can use AES (functions displaying
- menu and dialog boxes) without the initialisation of VDI. But in the most
- cases, our programs will be using both of them. Why use the VDI? There are 200%
- faster solutions of drawing with the use of BIOS and XBIOS. The answer is
- simple, each addition such as graphics card or extended resolutions on Falcon
- are fully compatible with VDI, but not for sure with BIOS and XBIOS. It's
- rather question of reaching the widest user audience.
-
- REPETITION FROM THE VDI INITIALISATION
- Firstly we have to find the physical screen handle (PHYS_HANDLE from now on).
- AES sets it in the beginning, so we can get it with graf_handle() call. We need
- also the height in pixels of our standard text character.
-
- Using this handle (PHYS_HANDLE) we can open virtual workstation (screen is
- "virtual", the others are "real".) with v_openvwk(). This call returns an
- information about displayed screen together with VDI workstation handle
- (STAT_HANDLE) and this handle is used with all further VDI calls. If we have
- handle of VDI workstation, we open the sample window to display something.
- Problem is that VDI doesn't understand the absolute screen coordinates (640*480
- or anything else).How to find the correct coordinates? Remember that size of
- the area to display is (overall size of the window MINUS size of all gadgets
- like closers, sliders etc.). There is a solution. We know how to handle windows
- to draw within them. We use wind_get() with WORKXYWH flag to get four words
- filled with appropriate values (x,y,w,h). Now we have to convert them into VDI
- coordinates(x1,y1,x2,y2):
-
- VDI 3rd word = AES 3rd word + AES 1st word
- VDI 4rd word = AES 4th word + AES 2nd word
-
- AES 3rd word = VDI 3rd word - AES 1st word
- AES 4th word = VDI 4th word - AES 2nd word
-
- Now we have the rectangle in which we can do something. We need to specify the
- VDI clipping rectangle with vs_clip() to prevent the content of the window
- "spilling out" of it. As a parameter to this call we use handle of workstation,
- coordinates and TRUE flag to switch on the clipping and 0 flag with NULL
- rectangle to switch off the clipping. We have to switch off the clipping before
- we exit the program. Everything lets us to draw anything on the screen but in
- theory.
-
- BASIC IO
- There are two possible forms of the text output: text and graphical. The text
- one is easier one so we start with it first.
-
- Output comandds through VDI are quite simple. Firstly we can set all the
- details of the displayed text as we like. We do it with the following call. And
- remember that everything should be set BEFORE the outputting the text:
- - colour
- vst_color(handle, colour);
- colour is BLACK(1) as default.
-
- - rotate sets the text angle. Bitmap fonts can be turned in 90 degree steps,
- and vector ones freely:
- vst_rotate(handle, angle in degrees)
- angle = 0-normal, 90 - to the top of the screen, 180- upside down, 270 - to the
- bottom of hte screen.
-
- - justification this doesn't cover only right /left /center justification, but
- it has also vertical justification (with several "levels" of justify):
- SUBSCRIPT - text is jusified to the bottom line (descent)
- SUPERSCRIPT - text is jusified to the upper line (ascent)
- Normally, the standard settings are used with justification to the left and to
- the base. Justified text with microspaces is available through VDI (justified
- text where words are in one line without creating big gaps between them). But
- we have to use the special version of "text print" to use it. It cannot be
- setted by default.
- vst_alignment (handle, HALIGN, VALIGN, &HSET, &VSET);
- You set the flags that you want in HALIGN and VALIGN, but those that are set
- are returned in HSET and VSET. Some devices are not accepting all kinds of
- justification (but hopefully, screen accepts everything :) ).
-
- - effects we can add various effects. In case of GDOS fonts, it's better to use
- the bold version of the font rather than transform it to bold. We have several
- effects to choose: bold, underline, italic, outline, grey, shadow. Shadow isn't
- working at all with all the GDOS versions. vst_effects(handle, effect); Effects
- are set like oridinary binary flags. If effect = 0 text is normal.
-
- FUNCTIONS DISPLAYING TEXT
- Most basic one:
- v_gtext(handle,x,y,string);
- handle - VDI handle as usual, x,y -start coordinates, string - NULL terminated
- string.
- For text with microspaces:
- v_justified (handle, x,y,string, lenght, word_flag, character_flag);
- handle, x, y, string are as above. lenght is a area in pixels on which we want
- to spread the text. Flag of word /character indicates the justification between
- words /characters (0- no/ 1-yes).
-
- The best solution is to display all the characters that are fitting inside the
- window plus one additionally, automatically reducing screen area to redraw. We
- know the working area ( WORKXYWH flag with wind_get() remember?). So we can
- check the lenght of the each text string with:
- vqt_extent(handle, string, points);
- handle and string are obvious. points are four pairs of four words defining the
- minimal area in which fits the text. The proble is in the order of these pairs,
- the order depends from the mode (is the text displayed in 90 degree steps or is
- rotated freelly).
-
- So, we can loop everything, until we receive one (or a part) of the character,
- print the string and let the system to clean up everything (both variant of
- outputting text).
-
- BASIC VDI GRAPHIC FUNCTIONS
- VDI has several standard shapes to draw called GDP (Graphic Device Primitives).
- This means that EVERY device driver should support those functions (and we can
- assume that they are always available). One of the values from WORK_OUT [14]
- contains the number of available GDP functions in given device. They also
- contain the old settings (like colour), but they require other parameters
- before they can be used.
-
- GDP functions:
-
- a) filled bar
- v_bar (handle, points);
- handle - VDI handle
- points - points in VDI format
-
- b) arc
- v_arc (handle, x, y, radius,angle at start, angle at end);
- handle - VDI handle
- x,y - the coordinates of the centre of the circle
- radius - horizontal circle radius (horizontal is set by device coordinate
- system) angle at start, angle at end - the angle are in 1/10 of a degree with
- EAST as a 0.
-
- c) filled pie
- Problematic. Atari Compedium talks about v_pieslice(), compute! about v_pie().
- Check better the documentation of your compiler. Arguments are similar to those
- in v_arc ().
-
- d) filled circle
- v_circle (handle, x,y, radius);
- Everything self explanatory.
- handle - VDI handle
- x,y - the coordinates of the centre of the circle
-
- e) filled ellipse
-
- v_ellipse (handle, x, y, radius x, radius y);
- handle - VDI handle
- x,y - the coordinates of the centre of the circle
- radius x- horizontal radius
- radius y- vertical radius
- WARNING! If you don't use NDC, the shape is looking different in different
- resolutions.
-
- f) elliptic arc
-
- v_ellarc ( handle, x, y, radius x, radius y, angle at start, angle at end);
-
- g) filled elliptic pie
-
- v_ellpie (handle, x, y, radius x, radius y, angle at start, angle at end);
-
- h) rounded rectangle
- v_rbox(handle, points);
- handle - VDI handle
- points - in VDI format
-
- i) filled rounded rectangle
- v_rfbox(handle, points);
- as above...
-
- That's all if it comes about GDP, which with justified text should be present
- within every VDI. To be sure we can check all the functions after the opening
- of the VDI workstation. There are soe functions that are modyfying the VDI
- default settings:
-
- clipping rectangle (we know that already to well...)
- fill colour vsf_color();
- fill style vsf_interior();
- style index fill vsf_style();
- outline fill perimeter vsf_perimeter();
- line colour vsl_color();
- line style vsl_type();
- line width vsl_width();
-
- VDI BASIC DRAWING FUNCTIONS
- To draw anything we have to:
- - prepare the screen and palette,
- - set the required attributes. VDI can draw following shapes: pixels, crosses,
- stars, rectangles, x and diamonds.
-
- Attributes of drawing shapes we set with functions:
-
- vsm_color() - sets the colour (colour number from the palette), which is used
- by shape.
- vsm_height() - sets the size of the shape (doesn't work pixels).
- vsm_type() - sets the shape from the list of VDI shapes mentioned above.
-
- After setting of these parameters we can draw with v_pmarker(). We can also
- take a look at actually setted attributes with vqm_attributes(). Lines are much
- more complex. They take the attributes (colour, style, width, style of the
- lineend) setted by the group of functions vsl_xxx(). VDI function responsible
- for drawing lines is very flexible, but complicated a little:
-
- void v_pline (WORD handle, WORD amount of points, WORD *table of points);
- handle - VDI handle
- amount of points - an amount of pairs of the coordinates (x,y) in array of
- points describing vertices to draw. The end of the first line is treated, as
- the beginning of the second one:
-
- points_table[0], points_table[1] points_table[2], points_table[3]
- *---------------------------------*
- | |
- | |
- | |
- *---------------------------------*
- points_table[6],points_table[7] points_table[4],points_table[5]
-
- To draw every shape we need an array: (amount of sides+1) * 2 points. In a
- closed shape the first coordinates should be equal to the last in an array.
-
- VDI INQUIRE FUNCTIONS
- This group of functions is used to check the actual informations about the VDI.
- Most frequently used are:
-
- vq_chcells() - returns the size of screen in characters.
- vq_color() - returns the RGB value of specified colour number fro the palette.
- vq_curraddres() - returns the actual text cursor position.
- vq_extnd() - additional informations about actual device.
- vq_gdos() - checks if GDOS is installed and returns it type and version.
- vq_key_s() - returns the state of SHIFT/ ALT/ CONTROL keys.
- vq_mouse() - returns the state and position of mouse arrow.
- vqf_attributes() - returns the actual fill style
- vql_attributes() - returns the actual line settings
- vqm_attributes() - returns the actual marker (shape) settings.
- vqt_attributes() - returns the actual text settings.
- vqt_extent() - returns (in pixels) the area covered by text.
- v_get_pixel() - returns the colours of the chosen point on the screen.
-
- Most functions are working in similar way, they return the pointer to the array
- filled with values. (Take a look into Atari Compedium!).
-
- VDI INPUT FUNCTIONS
- Atari ST / TT/ Falcon have two major input devices - mouse and keyboard. Both
- sources can be read by VDI and AES. The differences lay are in the method
- getting the information. AES uses the message system and VDI must to ask the
- device for information (inquire or "poll").
- Both methods have their merits and flaws. The AES way consumes less cpu time,
- but VDI is able to fetch the info which we need, not when the message will be
- in the beginning of the que.
-
- Mouse
- VDI: uses vq_mouse() and vq_keys_s(). vq_mouse() returns 3 words. Two of them
- contain x, y coordinates and one word with two first bits reflecting the actual
- state of the mouse buttons.
- AES: uses evnt_mouse(). This call sits and waits until the desired event will
- occur, which is a mouse pointer entering the specified part of the screen and
- returns the information as above. BUT if the mouse pointer will not enter the
- specified part of the screen, system will not answer on other messages (will
- "jam"). Similar function call evnt_button() waits for specified mouse button
- press.
- Monitoring of both (and many other) messages requires the use of monolithic
- "combi-harvester" in shape of evnt_multi(). This function is ENORMOUS and takes
- 22 parameters which lets us to observe anything that AES reports.
-
- Keyboard:
- VDI: There are two possible ways of using the keyboard under VDI, which depend
- from the nature of the data at input. The input can be sampled (system doesn't
- wait for the RETURN before sending the keypresses) or inquired. But firstly we
- need to set correctly the text cursor. We have to set input mode:
- vrq_string() - inquiry mode
- vsm_string() - sample mode
- AES - is much simplier. During keyboard read the evnt_keybd() is used, which
- waits for a keypress or alternatively use the evnt_multi(). Both functions
- return one word. Less significant byte in word contains ASCII code, the most
- significant byte contains the keyboard code. The keyboard code is useful when
- the desired key doesn't posses the ASCII value (HELP key for instance).
-
- <link=art52e.scr>Go to PART #5</l>
- </frame>
- </body>
-
-