1015
|
1 <appendix>
|
|
2 <title>The &b09; Graphics Interface Module</title>
|
|
3 <para>
|
|
4 The Graphics Interface module provides a simple and convenient
|
|
5 way to access the color graphics and joystick functions of the
|
|
6 Dragon Computer from &b09; programs. The module is a program
|
|
7 written in assembly language and stored in a file called "GFX". It
|
|
8 can be loaded into memory using the OS-9 "LOAD" command prior to or
|
|
9 after called &b09;, or it will be automatically called by &b09;
|
|
10 the first time it is referenced in a program if the "GFX" file is
|
|
11 located in the execution ("CMDS") directory.
|
|
12 </para>
|
|
13 <para>
|
|
14 "GFX" is called using the &b09; "RUN" statement. The first
|
|
15 parameter passed is the name of the graphics function desired.
|
|
16 Other parameters are used to pass coordinates, color modes, etc.
|
|
17 </para>
|
|
18 <para>
|
|
19 The are two basic graphics modes: 4-color having 128 by 192
|
|
20 pixel resolution, and 2-color having 256 by 192 pixel resolution.
|
|
21 The display is treated as a 256 by 192 point grid with coordinates
|
|
22 0,0 in the lower left-hand corner. X (horizontal) coordinates in
|
|
23 either mode must be in the range of 0 to 255. An X-coordinate
|
|
24 greater than 255 will cause a run-time error. Y coordinates
|
|
25 (vertical) must be in the range of 0 to 191. A number greater than
|
|
26 191 will be replaced by 191. Some of the graphics functions require
|
|
27 or optionally accept a color mode which controls the foreground
|
|
28 color and color set. The mode and color codes are given in the
|
|
29 table on the next page.
|
|
30 </para>
|
|
31 <beginpage/>
|
|
32 <table frame="none">
|
|
33 <title>Color Graphics Modes and Color Codes</title>
|
|
34 <tgroup cols="6">
|
|
35 <colspec colname="c1" colwidth="0.6in"/>
|
|
36 <colspec colname="c2" colwidth="0.4in"/>
|
|
37 <colspec colname="c3" colwidth="1in"/>
|
|
38 <colspec colname="c4" colwidth="1in"/>
|
|
39 <colspec colname="c5" colwidth="1in"/>
|
|
40 <colspec colname="c6" colwidth="1in"/>
|
|
41 <thead>
|
|
42 <row>
|
|
43 <entry morerows="1" namest="c2">Color Code</entry>
|
|
44 <entry align="center" namest="c3" nameend="c4">Two Color Format</entry>
|
|
45 <entry align="center" namest="c5" nameend="c6">Four Color Format</entry>
|
|
46 </row>
|
|
47 <row>
|
|
48 <entry namest="c3">Background</entry>
|
|
49 <entry namest="c4">Foreground</entry>
|
|
50 <entry namest="c5">Background</entry>
|
|
51 <entry namest="c6">Foreground</entry>
|
|
52 </row>
|
|
53 </thead>
|
|
54 <tbody>
|
|
55 <row>
|
|
56 <entry morerows="3" valign="middle">Color Set 1</entry>
|
|
57 <entry align="center">00</entry>
|
|
58 <entry align="left">Black</entry>
|
|
59 <entry align="left">Black</entry>
|
|
60 <entry align="left">Green</entry>
|
|
61 <entry align="left">Green</entry>
|
|
62 </row>
|
|
63 <row>
|
|
64 <entry align="center">01</entry>
|
|
65 <entry align="left">Black</entry>
|
|
66 <entry align="left">Green</entry>
|
|
67 <entry align="left">Green</entry>
|
|
68 <entry align="left">Yellow</entry>
|
|
69 </row>
|
|
70 <row>
|
|
71 <entry align="center">02</entry>
|
|
72 <entry namest="c5" align="left">Green</entry>
|
|
73 <entry align="left">Blue</entry>
|
|
74 </row>
|
|
75 <row rowsep="1">
|
|
76 <entry align="center">03</entry>
|
|
77 <entry namest="c5" align="left">Green</entry>
|
|
78 <entry align="left">Red</entry>
|
|
79 </row>
|
|
80 <row>
|
|
81 <entry morerows="3" valign="middle">Color Set 2</entry>
|
|
82 <entry align="center">04</entry>
|
|
83 <entry align="left">Black</entry>
|
|
84 <entry align="left">Black</entry>
|
|
85 <entry align="left">Buff</entry>
|
|
86 <entry align="left">Buff</entry>
|
|
87 </row>
|
|
88 <row>
|
|
89 <entry align="center" namest="c2">05</entry>
|
|
90 <entry align="left">Black</entry>
|
|
91 <entry align="left">Buff</entry>
|
|
92 <entry align="left">Buff</entry>
|
|
93 <entry align="left">Cyan</entry>
|
|
94 </row>
|
|
95 <row>
|
|
96 <entry align="center" namest="c2">06</entry>
|
|
97 <entry namest="c5" align="left">Buff</entry>
|
|
98 <entry align="left">Magenta</entry>
|
|
99 </row>
|
|
100 <row rowsep="1">
|
|
101 <entry align="center" namest="c2">07</entry>
|
|
102 <entry namest="c5" align="left">Buff</entry>
|
|
103 <entry align="left">Orange</entry>
|
|
104 </row>
|
|
105 <row>
|
|
106 <entry morerows="3" valign="middle">Color Set 3*</entry>
|
|
107 <entry align="center">08</entry>
|
|
108 <entry namest="c5" align="left">Black</entry>
|
|
109 <entry align="left">Black</entry>
|
|
110 </row>
|
|
111 <row>
|
|
112 <entry align="center" namest="c2">09</entry>
|
|
113 <entry namest="c5" align="left">Black</entry>
|
|
114 <entry align="left">Dark Green</entry>
|
|
115 </row>
|
|
116 <row>
|
|
117 <entry align="center" namest="c2">10</entry>
|
|
118 <entry namest="c5" align="left">Black</entry>
|
|
119 <entry align="left">Med. Green</entry>
|
|
120 </row>
|
|
121 <row rowsep="1">
|
|
122 <entry align="center" namest="c2">11</entry>
|
|
123 <entry namest="c5" align="left">Black</entry>
|
|
124 <entry align="left">Light Green</entry>
|
|
125 </row>
|
|
126 <row>
|
|
127 <entry morerows="3" valign="middle">Color Set 4*</entry>
|
|
128 <entry align="center">12</entry>
|
|
129 <entry namest="c5" align="left">Black</entry>
|
|
130 <entry align="left">Black</entry>
|
|
131 </row>
|
|
132 <row>
|
|
133 <entry align="center" namest="c2">13</entry>
|
|
134 <entry namest="c5" align="left">Black</entry>
|
|
135 <entry align="left">Green</entry>
|
|
136 </row>
|
|
137 <row>
|
|
138 <entry align="center" namest="c2">14</entry>
|
|
139 <entry namest="c5" align="left">Black</entry>
|
|
140 <entry align="left">Red</entry>
|
|
141 </row>
|
|
142 <row>
|
|
143 <entry align="center" namest="c2">15</entry>
|
|
144 <entry namest="c5" align="left">Black</entry>
|
|
145 <entry align="left">Buff</entry>
|
|
146 </row>
|
|
147 </tbody>
|
|
148 </tgroup>
|
|
149 </table>
|
|
150 <note>
|
|
151 <para>
|
|
152 Color Sets 3 and 4 are not available on PAL video system
|
|
153 (U.K. and European) models.
|
|
154 </para>
|
|
155 </note>
|
|
156 <bridgehead renderas="sect2">MODE</bridgehead>
|
|
157 <cmdsynopsis>
|
|
158 <command>RUN GFX("Mode",<replaceable>format,color</replaceable>)</command>
|
|
159 </cmdsynopsis>
|
|
160 <para>
|
|
161 MODE switches the screen from alphanumeric to graphics display mode,
|
|
162 and selects the screen mode and color mode. "Format" determines
|
|
163 between two-color (Format = 0), or four-color (Format = 1)
|
|
164 graphics modes. "Color" is the initial color code that specifies
|
|
165 the foreground color and color set.
|
|
166 </para>
|
|
167 <para>
|
|
168 This command must be given before aby other graphics command is
|
|
169 used. The first time MODE is called, it requests 6K bytres of memory
|
|
170 from OS-9 for use as the graphics display memory. MODE will return
|
|
171 an error if sufficient free memory is not available.
|
|
172 </para>
|
|
173 <para>
|
|
174 An example:
|
|
175 <programlisting>
|
|
176 RUN GFX("Mode",1,3)
|
|
177 </programlisting>
|
|
178 selects four-color mode graphics is used, and the initial
|
|
179 foreground color is red.
|
|
180 </para>
|
|
181 <bridgehead renderas="sect2">MOVE</bridgehead>
|
|
182 <cmdsynopsis>
|
|
183 <command>RUN GFX("Move",<replaceable>x,y</replaceable>)</command>
|
|
184 </cmdsynopsis>
|
|
185 <para>
|
|
186 MOVE positions the (invisible) graphics cursor to the specified
|
|
187 location without changing the display. X and Y are the coordinates
|
|
188 of the new position.
|
|
189 </para>
|
|
190 <para>
|
|
191 Example:
|
|
192 <programlisting>
|
|
193 RUN GFX("Move",0,0)
|
|
194 </programlisting>
|
|
195 This example positions the cursor in the lower left-hand corner.
|
|
196 </para>
|
|
197 <bridgehead renderas="sect2">COLOR</bridgehead>
|
|
198 <cmdsynopsis>
|
|
199 <command>RUN GFX("Color",<replaceable>color</replaceable>)</command>
|
|
200 </cmdsynopsis>
|
|
201 <para>
|
|
202 COLOR changes the current foreground color (and possibly the color
|
|
203 set). The current graphics mode and cursor position are not
|
|
204 changed. For example:
|
|
205 <programlisting>
|
|
206 RUN GFX("Color",0)
|
|
207 </programlisting>
|
|
208 changes the foreground color to green in four-color format (or
|
|
209 black in two-color format).
|
|
210 </para>
|
|
211 <bridgehead renderas="sect2">POINT</bridgehead>
|
|
212 <cmdsynopsis>
|
|
213 <command>RUN GFX("Point",<replaceable>x,y</replaceable>) or</command><sbr/>
|
|
214 <command>RUN GFX("Point",<replaceable>x,y,color</replaceable>)</command>
|
|
215 </cmdsynopsis>
|
|
216 <para>
|
|
217 POINT moves the graphics cursor to the specified X.Y coordinate and
|
|
218 sets the pixel at that coordinate to the current foreground color.
|
|
219 If the optional "Color" is specified, the current foreground color
|
|
220 is set to the given "Color". For example:
|
|
221 <programlisting>
|
|
222 RUN GFX("Point",0,192,1)
|
|
223 </programlisting>
|
|
224 Point moves the cursor to the upper left-hand corner and changes
|
|
225 the foreground color to green in two-color format, or it changes
|
|
226 the color to yellow in the four-color format.
|
|
227 </para>
|
|
228 <bridgehead renderas="sect2">CLEAR</bridgehead>
|
|
229 <cmdsynopsis>
|
|
230 <command>RUN GFX("Clear") or</command><sbr/>
|
|
231 <command>RUN GFX("Clear",<replaceable>color</replaceable>)</command>
|
|
232 </cmdsynopsis>
|
|
233 <para>
|
|
234 CLEAR resets all points on the screen to the background color, or
|
|
235 if the optional color is given presets the screen to that color.
|
|
236 The current graphics cursor is reset to (0,0).
|
|
237 </para>
|
|
238 <bridgehead renderas="sect2">LINE</bridgehead>
|
|
239 <cmdsynopsis>
|
|
240 <command>RUN GFX("Line",<replaceable>x2,y2</replaceable>)</command><sbr/>
|
|
241 <command>RUN GFX("Line",<replaceable>x2,y2,color</replaceable>)</command><sbr/>
|
|
242 <command>RUN GFX("Line",<replaceable>x1,y1,x2,y2</replaceable>)</command><sbr/>
|
|
243 <command>RUN GFX("Line",<replaceable>x1,y1,x2,y2,color</replaceable>)</command>
|
|
244 </cmdsynopsis>
|
|
245 <para>
|
|
246 LINE draw lines in various ways. If one coordinate is given, the
|
|
247 line will be drawn from the current graphics cursor position to the
|
|
248 coordinates specified. If two sets of coordinates are given, they
|
|
249 are used as the start and end points of the line. The line will be
|
|
250 drawn in the current foreground color unless a new color is given
|
|
251 as a parameter. After the line is drawn the graphics cursor will be
|
|
252 positioned at x2,y2. For example
|
|
253 <programlisting>
|
|
254 RUN GFX("Line",0,0,0,192)
|
|
255 </programlisting>
|
|
256 draws a line from (0,0) to (0,192).
|
|
257 <programlisting>
|
|
258 RUN GFX("line",24,65,2)
|
|
259 </programlisting>
|
|
260 draws a blue line (4-color mode) to point 24,65.
|
|
261 </para>
|
|
262 <bridgehead renderas="sect2">CIRCLE</bridgehead>
|
|
263 <cmdsynopsis>
|
|
264 <command>RUN GFX("Circle",<replaceable>radius</replaceable>)</command><sbr/>
|
|
265 <command>RUN GFX("Circle",<replaceable>radius,color</replaceable>)</command><sbr/>
|
|
266 <command>RUN GFX("Circle",<replaceable>x,y,radius</replaceable>)</command><sbr/>
|
|
267 <command>RUN GFX("Circle",<replaceable>x,y,radius,color</replaceable>)</command>
|
|
268 </cmdsynopsis>
|
|
269 <para>
|
|
270 CIRCLE draws a circle of the given radius. The current graphics
|
|
271 cursor position is assumed if no X,Y value is given. The current
|
|
272 foreground color is assumed if the Color parameter is not used.
|
|
273 The center of the circle must be on the screen.
|
|
274 </para>
|
|
275 <bridgehead renderas="sect2">ALPHA</bridgehead>
|
|
276 <cmdsynopsis>
|
|
277 <command>RUN GFX("Alpha")</command>
|
|
278 </cmdsynopsis>
|
|
279 <para>
|
|
280 Alpha is a quick convenient way of getting the screen back to
|
|
281 alphanumeric mode. When graphics mode is entered again, the screen
|
|
282 will show the previous unchanged graphics display.
|
|
283 </para>
|
|
284 <bridgehead renderas="sect2">QUIT</bridgehead>
|
|
285 <cmdsynopsis>
|
|
286 <command>RUN GFX("Quit")</command>
|
|
287 </cmdsynopsis>
|
|
288 <para>
|
|
289 QUIT switches the screen back to alpha mode and returns the 6K byte
|
|
290 graphics display memory to OS-9.
|
|
291 </para>
|
|
292 <bridgehead renderas="sect2">GLOC</bridgehead>
|
|
293 <cmdsynopsis>
|
|
294 <command>RUN GFX("Gloc",<replaceable>vdisp</replaceable>)</command>
|
|
295 </cmdsynopsis>
|
|
296 <para>
|
|
297 GLOC returns the address of the video display RAM as an integer number.
|
|
298 This address may be used in subsequent PEEK and POKE
|
|
299 operations to access the video display directly. GLOC can be used
|
|
300 to create special functions that are not available in the Graphics
|
|
301 Module.
|
|
302 </para>
|
|
303 <bridgehead renderas="sect2">GCOLR</bridgehead>
|
|
304 <cmdsynopsis>
|
|
305 <command>RUN GFX("Gcolr",<replaceable>color</replaceable>)</command><sbr/>
|
|
306 <command>RUN GFX("Gcolr",<replaceable>x,y,color</replaceable>)</command>
|
|
307 </cmdsynopsis>
|
|
308 <para>
|
|
309 GCOLR is used to read the color of the pixel at the current
|
|
310 graphics cursor position, or from the coordinates X,Y. The
|
|
311 parameter "Color" may be an integer or a byte variable in which the
|
|
312 color code is returned.
|
|
313 </para>
|
|
314 <bridgehead renderas="sect2">JOYSTK</bridgehead>
|
|
315 <cmdsynopsis>
|
|
316 <command>RUN GFX("Joystk",<replaceable>stick,fire,x,y</replaceable>)</command>
|
|
317 </cmdsynopsis>
|
|
318 <para>
|
|
319 JOYSTK returns the status of the specified joystick's Fire button,
|
|
320 and returns the X,Y position of the joystick. The Fire button may
|
|
321 be read as a BYTE, INTEGER, or a BOOLEAN value. Non-zero (TRUE)
|
|
322 means the button was pressed. The X,Y values returned may be BYTE
|
|
323 or INTEGER variables, and they will be in the range 0 to 63. The
|
|
324 Stick parameter may be BYTE or INTEGER, and should be 0 for
|
|
325 RIGHT, or 1 for LEFT, depending on whether the RIGHT or the LEFT
|
|
326 joystick is to be tested.
|
|
327 </para>
|
|
328 <para>
|
|
329 Example:
|
|
330 <programlisting>
|
|
331 RUN GRX("Joystk",1,leftfire,leftx,lefty)
|
|
332 </programlisting>
|
|
333 </para>
|
|
334 <bridgehead renderas="sect1">A Sample Graphics Program</bridgehead>
|
|
335 <para>
|
|
336 The program on the next page illustrates how the GFX module is
|
|
337 called and used. It creates an analog clock on the graphics
|
|
338 display.
|
|
339 </para>
|
|
340 <para>
|
|
341 <programlisting>
|
|
342 PROCEDURE clk
|
|
343 0000 (* Simple Clock Simulator *)
|
|
344 001C DIM time(4),last(4),xx(3),yy(3):INTEGER
|
|
345 0043 DIM x0,y0,radius,bkg:INTEGER
|
|
346 0056 DIM i,j,x1,y1,x2,y2:INTEGER
|
|
347 0071 DEG
|
|
348 0073 bkg=0
|
|
349 007A x0=128
|
|
350 0081 y0=96
|
|
351 0088 radius=95
|
|
352 008F RUN GFX("MODE",1,bkg+1)
|
|
353 00A5 RUN GFX("CLEAR")
|
|
354 00B2 RUN GFX("CIRCLE",x0,y0,radius)
|
|
355 00CF FOR i=0 to 89 STEP 6
|
|
356 00E4 x2=SIN(i)*radius
|
|
357 00F4 y2=COS(i)*radius
|
|
358 0104 x1=x2*.9
|
|
359 0115 y1=y2*.9
|
|
360 0126 j=MOD(i/30,3)+bkg+1
|
|
361 013B RUN GFX("LINE",x0+x1,y0+y1,x0+x2,y0+y2,j)
|
|
362 016C RUN GFX("LINE",x0-x1,y0-y1,x0-x2,y0-y2,j)
|
|
363 019D RUN GFX("LINE",x0+y1,y0-x1,x0+y2,y0-x2,j)
|
|
364 01CE RUN GFX("LINE",x0-y1,y0+x1,x0-y2,y0+x2,j)
|
|
365 01FF NEXT i
|
|
366 020A FOR i=1 TO 3
|
|
367 021A time(i)=0
|
|
368 0225 xx(i)=x0
|
|
369 0231 yy(i)=y0
|
|
370 023D NEXT i
|
|
371 0248 LOOP
|
|
372 024A time$=DATE$
|
|
373 0250 last=time
|
|
374 0258 time(3)=VAL(MID$(time$,16,2))*6
|
|
375 026E time(2)=VAL(MID$(time$(13,2))*6
|
|
376 0284 time(1)=MOD(VAL(MID$(time$,10,2))*30+time/2)/12,360)
|
|
377 02A9 j=last(3)
|
|
378 02B3 FOR i=3 TO 1 STEP -1
|
|
379 02C9 IF i=3 OR j=0 OR ABS(time(i)-last(i+1))<6 OR
|
|
380 ABS(time(i)-j)<6 THEN
|
|
381 0300 RUN GFX("LINE",x0,y0,xx(i),yy(i),bkg)
|
|
382 032B xx(i)=x0+SIN(time(i))*radius*(.3+i*.2)
|
|
383 035A yy(i)=y0+COS(time(i))*radius*(.3+i*.2)
|
|
384 0389 RUN GFX("LINE",x0,y0,xx(i),yy(i),bkg+i)
|
|
385 03B7 ENDIF
|
|
386 03B9 NEXT i
|
|
387 03C4 WHILE time$=DATE$ DO
|
|
388 03CF ENDWHILE
|
|
389 03D3 ENDLOOP
|
|
390 </programlisting>
|
|
391 </para>
|
|
392
|
|
393 </appendix>
|