home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- * gr.h
- *
- * Support routines for graphics mode.
- **********************************************************************
- This file is part of
-
- STK -- The sprite toolkit -- version 1.1
-
- Copyright (C) Jari Karjala 1991
-
- The sprite toolkit (STK) is a FreeWare toolkit for creating high
- resolution sprite graphics with PCompatible hardware. This toolkit
- is provided as is without any warranty or such thing. See the file
- COPYING for further information.
-
- **********************************************************************
- **********************************************************************/
-
- #if !defined(__GR_H_)
- #define __GR_H_
-
-
- /***** Variables *****/
-
- extern int gr_max_x;
- extern int gr_max_y;
- /**********************************************************************
- * The maximum coordinate values for current graphics adapter.
- * (It is faster to use variables instead of getmaxx() and getmaxy());
- **********************************************************************/
-
- extern int gr_text_mode;
- #define GR_MODE_OR (1<<0) /* OR the text over previous graphics */
- #define GR_MODE_CLEAR (1<<1) /* Clear the backgroud before print */
- #define GR_MODE_CLEAR_FAST (1<<2) /* Clear the bg before print FAST */
- /**********************************************************************
- * This variable defines the text writing mode when using gr_* functions
- * (default GR_MODE_CLEAR)
- *
- * The GR_MODE_CLEAR_FAST is limited to 8 pixel horizontal resolution,
- * i.e. coordinate positions (1,0) and (5,0) are considered to be same.
- **********************************************************************/
-
- extern unsigned char far *gr_font_addr;
- /*********************************************************************
- * Pointer into an byte array containing the character font for
- * 8x8 pixel fixed point font. Initialized to ROM font (FFA6:000E).
- * Used only with GR_MODE_CLEAR_FAST in those graphics modes which
- * are supported by the sprite functions.
- ********************************************************************/
-
- extern int gr_visualpage;
- extern int gr_activepage;
- /*********************************************************************
- * The current visual page and active drawing page, provided that
- * they have been changed only with gr_*page functions.
- ********************************************************************/
-
- extern char gr_keys[128];
- /**********************************************************************
- * Array of booleans for each key of the keyboard (indexed by the scan
- * code value). Non-zero if key is depressed, zero otherwise.
- * The array is updated during the kbd_grab, see the function
- * gr_start_kbd_grab below. For example gr_keys[GR_KEY_ESC] is 1
- * if Esc is currently depressed and 0 if not. Multiple simultaneous
- * keyspresses are detected correctly.
- **********************************************************************/
-
- /***** Function prototypes *****/
-
- void gr_detect(int type, int *graphdriver, int *graphmode);
- #define GR_TYPE_ANY 0 /* Any mode will do */
- #define GR_TYPE_SPR 1 /* The best possible mode for the sprite toolkit */
- /**********************************************************************
- * Detect the graphics card and mode of the system.
- * The type parameter can be used to specify special requests.
- *
- * graphdriver and graphmode parameters are returned. These values can
- * be used with the gr_start function. They contain the value -1
- * if some error occured (cannot find requested mode, etc)
- **********************************************************************/
-
- void gr_start(int *graphdriver, int *graphmode);
- /***************************************************************************
- * Initializes the graphics system.
- * Search BGI drivers from the path defined in the enviroment variable BGIDIR
- * or current directory.
- * Set videomode into the BIOS to fool mouse drivers with Hercules graphics.
- * Set gr_end at exit and ctrl-C signals.
- * Terminate with error message if initialization fails.
- *
- * graphdriver pointer to the driver ID (or DETECT)
- * graphmode pointer to the mode ID
- ***************************************************************************/
-
- void gr_end(void);
- /***************************************************************************
- * Returns to the text mode
- ***************************************************************************/
-
-
- void gr_setactivepage(int page);
- /*********************************************************************
- * Set the active graphics page for writing and reading (0/1).
- * Also set the 'gr_activepage' variable
- *********************************************************************/
-
- void gr_setvisualpage(int page);
- /*********************************************************************
- * Set the visual graphics page
- * Also set the 'gr_visualpage' variable
- *********************************************************************/
-
-
- void gr_putch(char ch);
- void gr_puts(char *s);
- void gr_printf(char *s,...);
- #define gr_gotoxy(x, y) moveto(x*8, y*8)
- /**********************************************************************
- * gr_putch, gr_puts, gr_printf work as the as in text modes.
- * '\n', '\r' are handled as in standard text modes.
- * The string to be output must not exceed 100 characters.
- * Scrolling or backspacing not implemented.
- **********************************************************************/
-
-
- void gr_center_printf(int y, char *s,...);
- /**********************************************************************
- * Print text horizontally centered.
- * (x centered, at given y in pixels).
- * The string to be output must not exceed 100 characters.
- **********************************************************************/
-
- void gr_xy_printf(int x, int y, char *s,...);
- /**********************************************************************
- * printf at the given position. (x and y in pixels)
- * The string to be output must not exceed 100 characters.
- **********************************************************************/
-
-
- void gr_dual_center_printf(int y, char *s,...);
- /**********************************************************************
- * Print text into both graphics pages at the given position.
- * (x centered, at given y in pixels)
- * The string to be output must not exceed 100 characters.
- **********************************************************************/
-
- void gr_dual_xy_printf(int x, int y, char *s,...);
- /**********************************************************************
- * printf into both graphics pages at the given position.
- * (x and y in pixels)
- * The string to be output in gr_printf must not exceed 100 characters.
- **********************************************************************/
-
- int gr_inkey(void);
- /**********************************************************************
- * Return a keypress if one pending, otherwise 0.
- * Extended codes contain 0 in the low byte.
- *
- * Keyboard buffer head and tail are set equal to disable auto-repeat,
- * but it doesn't always work...
- **********************************************************************/
-
- char *gr_gets(char *cpdest, int max_len);
- /**********************************************************************
- * Read a string from screen in graphics mode.
- * The result is placed into cpdest, at most max_len characters are
- * read (max_len must be less than 80). Return cpdest of NULL
- * Backspace deletes characters, Esc returns a NULL pointer.
- **********************************************************************/
-
- void gr_start_kbd_grab(void);
- /**********************************************************************
- * Set a new handler for the keyboard. This handler sets and resets
- * the gr_keys array values for each scancode received, then flushes the
- * keyboard buffer, and after that calls the old handler.
- **********************************************************************/
-
- void gr_end_kbd_grab(void);
- /**********************************************************************
- * End the kbd grab, ie restore the original keyboard handler.
- **********************************************************************/
-
- /**********************************************************************
- * Defines for the scan codes of some keys. See others from
- * some book, for example Peter Norton's Programmers guide or
- * perhaps you could figure them out just by counting keycaps...
- **********************************************************************/
- #define GR_KEY_ESC 1
- #define GR_KEY_1 2
- #define GR_KEY_2 3
- #define GR_KEY_3 4
- #define GR_KEY_4 5
- #define GR_KEY_5 6
- #define GR_KEY_6 7
- #define GR_KEY_7 8
- #define GR_KEY_8 9
- #define GR_KEY_9 10
- #define GR_KEY_0 11
-
- #define GR_KEY_TAB 15
- #define GR_KEY_Q 16
- #define GR_KEY_W 17
- #define GR_KEY_E 18
- #define GR_KEY_R 19
- #define GR_KEY_T 20
- #define GR_KEY_Y 21
- #define GR_KEY_U 22
- #define GR_KEY_I 23
- #define GR_KEY_O 24
- #define GR_KEY_P 25
-
- #define GR_KEY_A 30
- #define GR_KEY_S 31
- #define GR_KEY_D 32
- #define GR_KEY_F 33
- #define GR_KEY_G 34
- #define GR_KEY_H 35
- #define GR_KEY_J 36
- #define GR_KEY_K 37
- #define GR_KEY_L 38
-
- #define GR_KEY_Z 44
- #define GR_KEY_X 45
- #define GR_KEY_C 46
- #define GR_KEY_V 47
- #define GR_KEY_B 48
- #define GR_KEY_N 49
- #define GR_KEY_M 50
- #define GR_KEY_COMMA 51
- #define GR_KEY_DOT 52
-
- #define GR_KEY_SPACE 57
-
- #define GR_KEY_ARROW_UP 72
- #define GR_KEY_ARROW_DOWN 80
- #define GR_KEY_ARROW_LEFT 75
- #define GR_KEY_ARROW_RIGHT 77
-
- #endif
-