4 * Interface to various vaguely BBC-like bits of the OS
6 * © 1994-1998 Straylight
9 /*----- Licensing note ----------------------------------------------------*
11 * This file is part of Straylight's Steel library.
13 * Steel is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
18 * Steel is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with Steel. If not, write to the Free Software Foundation,
25 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 /*----- VDU driver interface ----------------------------------------------*
37 * It's highly unlikely that any of these calls will return an error unless
38 * you're trying to use them from a print loop.
43 * Write character c to the VDU drivers
83 os_error *bbc_vdu(bbc_vduCode c);
87 * Write halfword hw to the VDU drivers (e.g. for coordinates)
90 os_error *bbc_vduw(int hw);
94 * Write a stream of characters to the VDU drivers. The correct number of
95 * characters for the VDU command given in the first character is expected:
96 * strange things may happen if you don't give the right number.
99 os_error *bbc_vduq(bbc_vduCode c,...);
101 /* --- bbc_stringprint --- *
103 * Writes a null-terminated string pointed to by p to the VDU drivers
106 os_error *bbc_stringprint(const char *p);
113 os_error *bbc_cls(void);
115 /* --- bbc_colour --- *
117 * Sets the text colour to be col. Set bit 7 of col to set the background
121 os_error *bbc_colour(int col);
123 /* --- bbc_pos and bbc_vpos --- *
125 * Return the x or y position of the text cursor respectively.
133 * Moves the text cursor to a specified position on the screen.
136 os_error *bbc_tab(int x,int y);
138 /*----- Graphics interface ------------------------------------------------*/
140 /* --- bbc_plot --- *
142 * Plots something specified by action at position x,y
148 bbc_SolidExFinal=0x08,
150 bbc_DottedExFinal=0x18,
151 bbc_SolidExInit=0x20,
152 bbc_SolidExBoth=0x28,
153 bbc_DottedExInit=0x30,
154 bbc_DottedExBoth=0x38,
156 bbc_HorizLineFillNB=0x48,
157 bbc_TriangleFill=0x50,
158 bbc_HorizLineFillB=0x58,
159 bbc_RectangleFill=0x60,
160 bbc_HorizLineFillF=0x68,
161 bbc_ParallelFill=0x70,
162 bbc_HorizLineFillNF=0x78,
163 bbc_FloodToBack=0x80,
164 bbc_FloodToFore=0x88,
172 bbc_EllipseFill=0xC8,
173 bbc_GraphicsChar=0xD0,
191 os_error *bbc_plot(int action,int x,int y);
193 /* --- bbc_move --- *
195 * Moves the graphics cursor to x,y
198 os_error *bbc_move(int x,int y);
200 /* --- bbc_moveby --- *
202 * Translates the graphics cursor by x,y
205 os_error *bbc_moveby(int x,int y);
207 /* --- bbc_draw --- *
209 * Draws a line from the graphics cursor position to x,y
212 os_error *bbc_draw(int x,int y);
214 /* --- bbc_drawby --- *
216 * Draws a line from the graphics cursor position to the point x to the
217 * right of and y above the graphics cursor position
220 os_error *bbc_drawby(int x,int y);
222 /* --- bbc_rectangle --- *
224 * Draws a rectangle with bottom left point at x,y, width w and height h
227 os_error *bbc_rectangle(int x,int y,int w,int h);
229 /* --- bbc_rectanglefill --- *
231 * Draws a filled rectangle with bottom left point at x,y, width w and
235 os_error *bbc_rectanglefill(int x,int y,int w,int h);
237 /* --- bbc_circle --- *
239 * Draws a circle, centre at x,y with radius r
242 os_error *bbc_circle(int x,int y,int r);
244 /* --- bbc_circlefill --- *
246 * Draws a filled in circle, centre at x,y with radius r
249 os_error *bbc_circlefill(int x,int y,int r);
251 /* --- bbc_origin --- *
253 * Sets the graphics origin to the point x,y (relative to the bottom left
254 * corner of the screen)
257 os_error *bbc_origin(int x,int y);
259 /* --- bbc_gwindow --- *
261 * Sets the graphics clipping window to the rectangle whose bottom left and
262 * top right corners are x0,y0 and x1,y1
265 os_error *bbc_gwindow(int x0,int y0,int x1,int y1);
269 * Clears the graphics clipping window
272 os_error *bbc_clg(void);
274 /* --- bbc_fill --- *
276 * Flood fills the area containing the point x,y to the current foreground
277 * colour. The area is expected to currently be coloured in the current
281 os_error *bbc_fill(int x,int y);
283 /* --- bbc_gcol --- *
285 * Sets the current GCOL action to action and the current graphics colour to
286 * col. Set bit 7 of col to choose the background colour.
289 os_error *bbc_gcol(int action,int col);
291 /* --- bbc_tint --- *
293 * Sets the current tint (if in a 256-colour mode) to tint specified. Note
294 * that tint values should be between 0 and 3, not 0x00 to 0xC0.
299 bbc_TextForegroundTint,
300 bbc_TextBackgroundTint,
301 bbc_GraphicsForegroundTint,
302 bbc_GraphicsBackgroundTint
306 os_error *bbc_tint(bbc_tintAction action,int col);
308 /* --- bbc_palette --- *
310 * Sets logical colour col to be `physical' colour mode, or to the palette
311 * entry red,green,blue.
316 /* --- BBC-style solid colours --- */
327 /* --- BBC-style really yukky flashing colours --- */
329 bbc_palFlashBlackWhite,
331 bbc_palFlashGreenMagenta,
332 bbc_palFlashYellowBlue,
333 bbc_palFlashBlueYellow,
334 bbc_palFlashMagentaGreen,
336 bbc_palFlashWhiteBack,
338 /* --- Other special values (use red,green,blue values) --- */
341 bbc_palFirstFlashRGB,
342 bbc_palSecondFlashRGB,
346 /* --- Special flags to OR in --- */
352 os_error *bbc_palette(int col,bbc_palMode mode,int red,int green,int blue);
354 /* --- bbc_point --- *
356 * Returns the logical colour of the point at position x,y. Doesn't return
357 * the tint in 256-colour modes. Returns 255 if the point is offscreen or
361 int bbc_point(int x,int y);
363 /*----- Screen mode handling ----------------------------------------------*/
365 /* --- bbc_mode --- *
367 * Sets the screen mode to mode
370 os_error *bbc_mode(int mode);
372 /* --- bbc_vduvar --- *
374 * Reads the value of the VDU variable var and returns it
443 int bbc_vduvar(int var);
445 /* --- bbc_vduvars --- *
447 * Reads a collection of VDU variables into an array. The variables to be
448 * read are held in the `in' array, which is terminated by a -1 entry. The
449 * values are stored in the same order in the `out' array.
452 os_error *bbc_vduvars(int in[],int out[]);
454 /* --- bbc_modevar --- *
456 * Returns the value of mode variable var for mode m
459 int bbc_modevar(int m,int var);
461 /*----- Keyboard and cursor handling --------------------------------------*/
465 * Waits for a keypress and returns the ASCII code. Returns 0x1?? if Escape
471 /* --- bbc_inkey --- *
473 * Return value depends on action:
475 * action == 0xFF00: Return OS version identifier
476 * action == 0xFFkk: Return whether key with internal code kk ^ 255 is
478 * action == 0xtttt: Wait tttt centiseconds for a keypress and return ASCII
482 int bbc_inkey(int action);
484 /* --- bbc_cursor --- *
486 * Sets cursor mode according to value of action:
488 * action == 0: Turn cursor off
489 * action == 1: Turn cursor on
490 * action == 2: Make cursor steady
491 * action == 3: Make cursor flash
494 os_error *bbc_cursor(int action);
496 /*----- Mouse control -----------------------------------------------------*/
498 /* --- bbc_mouse --- *
500 * Reads the mouse coordinates into *x,*y, button status int *b and time of
501 * mouse event into *t. Any of these may be 0 to indicate `don't care'.
504 os_error *bbc_mouse(int *x,int *y,int *b,int *t);
506 /* --- bbc_mouserect --- *
508 * Sets the mouse bounding rectangle to have bottom left coordinate x0,y0
509 * and top right coordinate x1,y1
512 os_error *bbc_mouserect(int x0,int y0,int x1,int y1);
514 /*----- Strangeness -------------------------------------------------------*/
516 /* --- bbc_adval --- *
518 * If I knew, I wouldn't be here.
523 /*----- Sound calls -------------------------------------------------------*/
525 /* --- bbc_getbeat --- *
527 * Reads the beat counter
530 int bbc_getbeat(void);
532 /* --- bbc_getbeats --- *
534 * Reads the length of a bar in beats
537 int bbc_getbeats(void);
539 /* --- bbc_setbeats --- *
541 * Sets the bar length
544 os_error *bbc_setbeats(int beats);
546 /* --- bbc_gettempo --- *
548 * Reads the beat speed
551 int bbc_gettempo(void);
553 /* --- bbc_settempo --- *
555 * Sets the beat speed
558 os_error *bbc_settempo(int tempo);
560 /* --- bbc_sound --- *
562 * Makes a sound on channel chan with amplitude a, pitch p and duration d
563 * at time t. t==-2 for `right now'. Doesn't return an error.
566 os_error *bbc_sound(int chan,int a,int p,int d,int t);
568 /* --- bbc_soundoff and bbc_soundon --- *
570 * Disable and enable the sound system
573 os_error *bbc_soundoff(void);
574 os_error *bbc_soundon(void);
576 /* --- bbc_stereo --- *
578 * Sets the stereo position of channel chan to pos
581 os_error *bbc_stereo(int chan,int pos);
583 /* --- bbc_voices --- *
585 * Sets the number of voices (channels ) to be n
588 os_error *bbc_voices(int n);