2 unit IIUWGRAPH: class;
\r
4 { this predefined class enables basic graphic operations }
\r
6 { the early versions of library IIUWGRAPH have been elaborated by
\r
7 Piotr Carlsson, Miroslawa Milkowska, Janina Jankowska,
\r
8 Michal Jankowski at Institute of Informatics,
\r
9 University of Warsaw 1987,
\r
10 and added to Loglan system by Danuta Szczepanska 1987,
\r
11 the recent versions were done at LITA, Pau,
\r
13 Pawel Susicki (1991) for Unix
\r
14 Sebastien Bernard (1992) for ATARI
\r
17 fait à Pau, le {TIME \@ "d MMMM, yyyy"|6 August, 1993} A.S.}
\r
19 { the predefined class IIUWGRAPH is included in all versions of interpreter of Loglan, with the exception of the present version of interpreter for VAX/VMS.
\r
20 Each interpreter is equipped with one version of graphic library which corresponds to one of the following possibilities:
\r
21 - EGA card, (use egaint if you have a VGA card)
\r
23 - Hercules mono card,
\r
26 several variants are offered
\r
30 all above versions were tested in DOS 3.3 environment
\r
32 - an emulation of Hercules in a Xwindow for UNIX environment,
\r
34 - an emulation of IIUWGRAPH in ATARI STE environment.
\r
37 MM. Becourt et Larrieu did a multiwindow graphic co-process for the int Loglan interpreter in Unix & Xwindows environment. See the separate document on it.
\r
39 M. Larrieu did an experimental version of vgaint Loglan executor for the machines 386/486. }
\r
41 hidden MaxX, MaxY, current_X, current_Y, is_graphic_On,
\r
42 current_Colour, current_Background_Colour, current_Style,
\r
43 current_Palette, current_Pattern ;
\r
46 { Hercules EGA/VGA CGA
\r
49 const MaxX = 719 ; { 639 319 }
\r
50 MaxY = 347 ; { 349 199 }
\r
52 { the screen's coordinates are
\r
54 (0,0) ----------------------> (MaxX,0)
\r
59 (0, MaxY) (MaxX,MaxY)
\r
64 var currentDriver : integer, { see NOCARD below }
\r
65 current_X, current_Y: integer { it is the current position }
\r
66 is_graphic_On: Boolean, { evidently tells whether we are in graphics mode }
\r
67 current_Colour : integer, { }
\r
68 current_Background_Colour : integer,
\r
69 current_Style : integer, { }
\r
70 current_Palette : integer,
\r
73 unit GRON : procedure (i: integer);
\r
74 { procedure sets the monitor in graphic mode and clears the buffer of screen. The parameter is meaningless, the only exception is made for the IBM CGA card in this case if you have chosen the mode 320x200 pixels the the value 1 of the parameter means colours, the value 0 means a mono screen is connected to the card
\r
77 unit GROFF : procedure;
\r
78 { the procedure sets the monitor in the text mode filling it with spaces.
\r
79 DO NOT FORGET to set the monitor in the text mode before you terminate your program
\r
82 unit NOCARD : function : integer;
\r
83 { the value given by this function determines the type of the currently used monitor and it is equal to
\r
84 1 for Hercules mono card,
\r
86 3 for IBM CGA mono 320 x 200
\r
87 4 for IBM CGA mono 640 x 200
\r
90 ?? 7 for Unix versions equipped with XWindows
\r
91 You can not call the function nocard before GRON sets the graphic mode
\r
94 unit CLS : procedure;
\r
95 { the screen will be cleared and filled with colour 0 }
\r
97 unit HPAGE : procedure(nr, : integer, clear : boolean);
\r
98 { the procedure is applicable to the cards EGA/VGA and Hercules only!
\r
99 it selects a page of video memory with the number = nr,
\r
100 clears its contents if clear is set <>0,
\r
102 mode = 0 the content of the page is shown as text,
\r
103 mode = 1 the content of the page is shown graphically,
\r
104 mode = -1 a worktime buffer is associated with the page.
\r
105 Mode -1 does not change the number not the way it is shown. Mode 0 links the buffer with the selected page. For card Hercules only call HPAGE(0, 1, 1) is equivalent to call GRON(99) and call HPAGE(0, 0, 1) is equivalent to call GROFF.
\r
107 Example of an animating loop
\r
113 (* draw first image *)
\r
118 call HPAGE(1-nr, 1,0); (* displaying *)
\r
119 call HPAGE(nr, -1,1); (* buffering *)
\r
120 (* draw modified image *)
\r
128 unit VIDEO : procedure( A: array of integer);
\r
129 { this procedure can not be applied for the EGA/VGA card }
\r
130 { the worktime buffer will be associated with the array A.
\r
131 A call of VIDEO does not change the contents of the buffer.
\r
132 All subsequent calls of the procedures modifying the screen will
\r
133 concern the array A. The screen does not change.
\r
134 A ready image can be moved to the screen with the help of GETMAP/PUTMAP procedures or it can be stored on disk.
\r
135 The array should have 16 kBytes for IBM CGA card or
\r
136 32 kBytes for Hercules card.}
\r
138 { PROCEDURES CONTROLLING THE COLOURS }
\r
140 unit COLOR : procedure(co : integer);
\r
141 { sets current color to co
\r
142 for monochrome displays, 0 means black, non-0 - white
\r
143 for color displays, 0 means background
\r
148 unit STYLE : procedure(styl : integer);
\r
149 { sets style of lines and fill shades to a combination
\r
150 of current color and background color (for mono -
\r
151 white and black, respectively) according to 5 predefined
\r
161 where '*' means current color, '.' background colour
\r
162 When drawing the segments the subsequent pixels will have colour determined by cyclic application of style pattern. The first and the last pixels of a segment will have always current colour.
\r
163 When filling contours the given style will be applied to horizontal lines with even coordinate. The style for odd lines is determined automatically.
\r
164 The same applies for perpendicular lines.
\r
165 There are other possibilities of mixing colours, cf procedure PATERN.
\r
169 unit PATERN : procedure (par, par1, par2, par3 : integer);
\r
170 { sets style of lines and fill shades to an explicitly specified
\r
171 combination of colours. When drawing lines the only parameter of importance will be par. When filling the parameters par and par2 concern the horiwontal (resp. perpendicular) lines with the coordinate x (resp: y) even. lines
\r
172 combination of colors : "iv" for even scan lines, "io" for odd.
\r
173 Color encoding is decimal, allowing 4 pixels.
\r
174 Lines are drawn always according to "iv".
\r
178 call patern(1100,0011)
\r
180 call color(1), call style(3)
\r
183 call patern(1212,2121)
\r
184 produces a shade that cannot be otherwise achieved
\r
185 ( a dotted line consisting of pixels in colors 1 and 2 )
\r
189 unit BORDER : procedure (background_Colour: integer);
\r
190 [ IBM color mode only ]
\r
192 sets actual background color to i ( i = 0,1,...,15 )
\r
195 unit PALLET : procedure (nr : integer);
\r
198 the codes of colors are as follows
\r
216 the procedure does not applies for Hercules card}
\r
219 unit INTENS : procedure (i : integer);
\r
221 { changes current intensity, 1 means more intensity, 0 less;
\r
222 default intensity is 1
\r
223 Applies to IBM CGA only
\r
226 { PROCEDURES CONTROLLING POSITION }
\r
228 unit MOVE : procedure (x,y :integer);
\r
229 { procedure MOVE sets the current position on the screen on the pixel with coordinates
\r
232 { precondition of MOVE:
\r
233 0{SYMBOL 163 \f "Symbol"}x{SYMBOL 163 \f "Symbol"}MaxX & 0{SYMBOL 163 \f "Symbol"}y{SYMBOL 163 \f "Symbol"}MaxY
\r
236 unit INXPOS : function: integer;
\r
237 { function INXPOS returns the x coordinate of the current position }
\r
240 unit INYPOS : function : integer;
\r
241 { function INYPOS returns the y coordinate of the current position }
\r
244 unit PUSHXY : procedure;
\r
245 { pushes current position, color & style onto the stack.
\r
246 The stack is kept internally, max depth is 16
\r
250 unit POPXY: procedure;
\r
252 { restores position, color & style from internal stack }
\r
255 unit DIAGONAL : procedure;
\r
256 var ix, iy : integer;
\r
261 call DRAW(ix+10, iy+10);
\r
267 unit TRACK : procedure (x,y : integer);
\r
268 { displays a small (8*8) arrow-shaped cursor which can be moved around with cursor keys; a single keystroke moves
\r
269 it by 5 pixels, in NUM mode step size is 1 pixel;
\r
270 "home" key returns the cursor to the initial (x,y);
\r
271 "end" removes cursor from screen, and returns - the new current
\r
272 position can be read with "INXPOS" and "INYPOS" above.
\r
274 ATTENTION: if you have a mouse then read on the predefined class Mouse, which permits to control the mouse
\r
277 { PROCEDURES SERVING POINTS }
\r
279 unit POINT : procedure(x,y: integer);
\r
280 { moves current position to pixel (x,y) and sets it to current color
\r
283 unit INPIX : function (x,y : integer) : integer;
\r
285 moves to pixel (x,y) and returns its color setting;
\r
289 unit DRAW : procedure( x,y : integer);
\r
291 draws a line from current screen position to (x,y);
\r
292 sets current position to (x,y);
\r
293 line is drawn in current color, with both terminal pixels
\r
294 always turned white ( non-background) for non-black
\r
295 ( non-background ) line color.
\r
296 Bresenham's algorithm is used, pixels belonging to the segment change their state depending on current colour and style.
\r
299 unit CIRB : procedure (xi, yi, ri : integer, alfa, beta : real,
\r
300 cbord, fill, p, q : integer);
\r
303 draws a circle (or ellipse, depending on aspect value, see below),
\r
304 optionally filling its interior;
\r
305 does not preserve position;
\r
306 (xi,yi) - are center coordinates
\r
307 ri - radius in pixels (horizontally)
\r
308 alfa, beta - starting & ending angles; if alfa=beta a full
\r
309 circle is drawn; values should be given in radians;
\r
310 cbord - border color,
\r
311 fill - if fill <>0, interior is filled in current style&color
\r
312 p,q - aspect ratio; if p/q=1, a perfect circle is drawn,
\r
313 if p/q<1, the horizontal axis is longer,
\r
314 if p/q>1 - the vertical axis is longer;
\r
317 unit HFILL : procedure(x: integer);
\r
319 { fills current row (horizontally) from current position
\r
320 (INXPOS, INYPOS) up to (x,INYPOS) with bit pattern depending
\r
321 on current color, style and/or pattern and position on
\r
322 the screen in such a way that adjacent "hfill"ed" rows
\r
323 will produce a shade simulating color;
\r
325 ATTENTION hfill does not change current position;
\r
327 It is advised to use hfill when filling contours since it works faster then DRAW. Procedure hfill is capable to similate additional colours.
\r
330 unit VFILL : procedure(y: integer);
\r
332 { fills current column ( vertically ) from current
\r
333 position (INXPOS, INYPOS) up to (INXPOS, y) in a similiar way
\r
335 rectangular area "vfill'ed" is not distinguishable
\r
336 on the screen from same shape "hfill'ed", except that
\r
337 it will take much longer to fill.
\r
339 ATTENTION hfill does not change current position;
\r
341 { Procedures operating on bitmaps }
\r
343 unit GETMAP : function (x,y : integer) : arrayof integer;
\r
344 {saves rectangular area between current position as
\r
345 top left corner and (ix,iy) as bottom right corner,
\r
346 including border lines;
\r
347 position remains unchanged.
\r
348 array of integer should have
\r
349 4+(rows{SYMBOL 215 \f "Symbol"}{SYMBOL 233 \f "Symbol"}columns/8{SYMBOL 249 \f "Symbol"} {SYMBOL 215 \f "Symbol"}coeff)
\r
350 bytes. The coefficient coeff is 1 for Hercules, 2 for CGA, 4 for EGA card.
\r
351 ATTENTION: in DOS environment the size of the array may necessitate the use of loglan with the option H+, see also memavail
\r
355 unit PUTMAP : procedure ( a: array of integer);
\r
356 {sets rectangular area of screen pixels to that saved
\r
357 by "getmap" in "iarray";
\r
358 same size is restored, with top left corner in current
\r
360 position remains unchanged.
\r
362 unit ORMAP : procedure ( a : arrayof integer);
\r
363 {same as putmap, but saved bitmap is or'ed into screen
\r
364 rather than just set.
\r
367 unit XORMAP : procedure ( a: arrayof integer);
\r
368 {same as putmap, but saved bitmap is xor'ed into screen
\r
369 rather than just set.
\r
372 unit INKEY : function : integer;
\r
374 {returns next character from keyboard buffer;
\r
375 0 is returned if buffer is empty;
\r
376 special keys are returned as negative numbers;
\r
377 ALT-NUM method may be used for entering character codes
\r
378 above 127 (this makes entering special keys 128-132
\r
380 if a character is returned, it is also removed
\r
381 from the buffer, so MS-DOS will not see it (CTRL-C!);
\r
382 typeahead is allowed, echo is suppressed.
\r
385 unit HASCII : procedure
\r
386 {'xor's the character in a 8*8 box with top left corner
\r
387 in the current position;
\r
388 moves current position by (8,0);
\r
389 character code 0 sets complete box to black ( background ),
\r
390 with no change in position.
\r
391 BIOS ROM font for IBM color card is used. If the font
\r
392 table is not at F000:FA6E, the character will probably
\r
393 be unrecognizable, and most certainly wrong.
\r
394 For codes >127, table pointed to by interrupt vector 31
\r
398 {sets 8*8 horizontal font table address to iseg:ioffs.}
\r
402 {includes a copy of IBM ROM 8*8 font and returns address suitable for passing to "hfont";
\r
403 Use of "hfont8" makes program larger but quarantees BIOS ROM independence.}
\r
406 unit INHLINE : procedure (a: arrayof char; output n : integer);
\r
407 { reads a line of at most "n" characters from the keyboard, storing them in the "a" array; characters are echoed at current position with "hascii" as they are typed in; a blinking cursor prompts for the next character;
\r
408 BACKSPACE works as expected, RETURN completes the reading;
\r
409 typing "n"-th character also completes the line;
\r
410 "l" is blank filled up to "n" bytes;
\r
411 on return "n" is the total number of characters read. }
\r
414 unit OUTHLINE : procedure (a : arrayof char; n : integer);
\r
415 { calls "hascii" "n" times with subsequent bytes from "a" array as arguments; before each character is written, "hascii(0)" is called. }
\r
419 à Pau, le {DATE|06/08/93} {PAGE|4}
\r
421 Predefined class IIUWGRAPH {PAGE|3}
\r