Anders Hörnfeldt
/
coniolib
Port of Conio.h
h/conio.h@0:6c1bc9b3a347, 2010-04-19 (annotated)
- Committer:
- hornfeldt
- Date:
- Mon Apr 19 20:20:10 2010 +0000
- Revision:
- 0:6c1bc9b3a347
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hornfeldt | 0:6c1bc9b3a347 | 1 | /* |
hornfeldt | 0:6c1bc9b3a347 | 2 | conio.h |
hornfeldt | 0:6c1bc9b3a347 | 3 | Standard conio routines. |
hornfeldt | 0:6c1bc9b3a347 | 4 | Part of MicroVGA CONIO library / demo project |
hornfeldt | 0:6c1bc9b3a347 | 5 | Copyright (c) 2008-9 SECONS s.r.o., http://www.MicroVGA.com |
hornfeldt | 0:6c1bc9b3a347 | 6 | |
hornfeldt | 0:6c1bc9b3a347 | 7 | This program is free software: you can redistribute it and/or modify |
hornfeldt | 0:6c1bc9b3a347 | 8 | it under the terms of the GNU General Public License as published by |
hornfeldt | 0:6c1bc9b3a347 | 9 | the Free Software Foundation, either version 3 of the License, or |
hornfeldt | 0:6c1bc9b3a347 | 10 | (at your option) any later version. |
hornfeldt | 0:6c1bc9b3a347 | 11 | |
hornfeldt | 0:6c1bc9b3a347 | 12 | This program is distributed in the hope that it will be useful, |
hornfeldt | 0:6c1bc9b3a347 | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
hornfeldt | 0:6c1bc9b3a347 | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
hornfeldt | 0:6c1bc9b3a347 | 15 | GNU General Public License for more details. |
hornfeldt | 0:6c1bc9b3a347 | 16 | |
hornfeldt | 0:6c1bc9b3a347 | 17 | You should have received a copy of the GNU General Public License |
hornfeldt | 0:6c1bc9b3a347 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
hornfeldt | 0:6c1bc9b3a347 | 19 | */ |
hornfeldt | 0:6c1bc9b3a347 | 20 | |
hornfeldt | 0:6c1bc9b3a347 | 21 | #ifndef _INC_CONIO |
hornfeldt | 0:6c1bc9b3a347 | 22 | #define _INC_CONIO |
hornfeldt | 0:6c1bc9b3a347 | 23 | |
hornfeldt | 0:6c1bc9b3a347 | 24 | #ifdef __cplusplus |
hornfeldt | 0:6c1bc9b3a347 | 25 | extern "C" { |
hornfeldt | 0:6c1bc9b3a347 | 26 | #endif |
hornfeldt | 0:6c1bc9b3a347 | 27 | |
hornfeldt | 0:6c1bc9b3a347 | 28 | #if !defined(__COLORS) |
hornfeldt | 0:6c1bc9b3a347 | 29 | #define __COLORS |
hornfeldt | 0:6c1bc9b3a347 | 30 | // Compatible with DOS/WIN CONIO.H |
hornfeldt | 0:6c1bc9b3a347 | 31 | enum COLORS { |
hornfeldt | 0:6c1bc9b3a347 | 32 | BLACK = 0, /* dark colors */ |
hornfeldt | 0:6c1bc9b3a347 | 33 | RED, |
hornfeldt | 0:6c1bc9b3a347 | 34 | GREEN, |
hornfeldt | 0:6c1bc9b3a347 | 35 | BROWN, |
hornfeldt | 0:6c1bc9b3a347 | 36 | BLUE, |
hornfeldt | 0:6c1bc9b3a347 | 37 | MAGENTA, |
hornfeldt | 0:6c1bc9b3a347 | 38 | CYAN, |
hornfeldt | 0:6c1bc9b3a347 | 39 | LIGHTGRAY, |
hornfeldt | 0:6c1bc9b3a347 | 40 | DARKGRAY, /* light colors */ |
hornfeldt | 0:6c1bc9b3a347 | 41 | LIGHTRED, |
hornfeldt | 0:6c1bc9b3a347 | 42 | LIGHTGREEN, |
hornfeldt | 0:6c1bc9b3a347 | 43 | YELLOW, |
hornfeldt | 0:6c1bc9b3a347 | 44 | LIGHTBLUE, |
hornfeldt | 0:6c1bc9b3a347 | 45 | LIGHTMAGENTA, |
hornfeldt | 0:6c1bc9b3a347 | 46 | LIGHTCYAN, |
hornfeldt | 0:6c1bc9b3a347 | 47 | WHITE |
hornfeldt | 0:6c1bc9b3a347 | 48 | }; |
hornfeldt | 0:6c1bc9b3a347 | 49 | |
hornfeldt | 0:6c1bc9b3a347 | 50 | #define BLINK 128 |
hornfeldt | 0:6c1bc9b3a347 | 51 | #endif |
hornfeldt | 0:6c1bc9b3a347 | 52 | |
hornfeldt | 0:6c1bc9b3a347 | 53 | //defines max coordinates for checking overflow |
hornfeldt | 0:6c1bc9b3a347 | 54 | #define MAX_X 80 |
hornfeldt | 0:6c1bc9b3a347 | 55 | #define MAX_Y 25 |
hornfeldt | 0:6c1bc9b3a347 | 56 | |
hornfeldt | 0:6c1bc9b3a347 | 57 | // Compatible with Unix Curses |
hornfeldt | 0:6c1bc9b3a347 | 58 | #define ACS_ULCORNER (0xDA) /* upper left corner */ |
hornfeldt | 0:6c1bc9b3a347 | 59 | #define ACS_LLCORNER (0xC0) /* lower left corner */ |
hornfeldt | 0:6c1bc9b3a347 | 60 | #define ACS_URCORNER (0xBF) /* upper right corner */ |
hornfeldt | 0:6c1bc9b3a347 | 61 | #define ACS_LRCORNER (0xD9) /* lower right corner */ |
hornfeldt | 0:6c1bc9b3a347 | 62 | #define ACS_HLINE (0xC4) /* horizontal line */ |
hornfeldt | 0:6c1bc9b3a347 | 63 | #define ACS_VLINE (0xB3) /* vertical line */ |
hornfeldt | 0:6c1bc9b3a347 | 64 | #define ACS_LTEE (acs_map['t']) /* tee pointing right */ |
hornfeldt | 0:6c1bc9b3a347 | 65 | #define ACS_RTEE (acs_map['u']) /* tee pointing left */ |
hornfeldt | 0:6c1bc9b3a347 | 66 | #define ACS_BTEE (acs_map['v']) /* tee pointing up */ |
hornfeldt | 0:6c1bc9b3a347 | 67 | #define ACS_TTEE (acs_map['w']) /* tee pointing down */ |
hornfeldt | 0:6c1bc9b3a347 | 68 | #define ACS_PLUS (acs_map['n']) /* large plus or crossover */ |
hornfeldt | 0:6c1bc9b3a347 | 69 | #define ACS_S1 (acs_map['o']) /* scan line 1 */ |
hornfeldt | 0:6c1bc9b3a347 | 70 | #define ACS_S9 (acs_map['s']) /* scan line 9 */ |
hornfeldt | 0:6c1bc9b3a347 | 71 | #define ACS_DIAMOND (acs_map['`']) /* diamond */ |
hornfeldt | 0:6c1bc9b3a347 | 72 | #define ACS_CKBOARD (acs_map['a']) /* checker board (stipple) */ |
hornfeldt | 0:6c1bc9b3a347 | 73 | #define ACS_DEGREE (acs_map['f']) /* degree symbol */ |
hornfeldt | 0:6c1bc9b3a347 | 74 | #define ACS_PLMINUS (acs_map['g']) /* plus/minus */ |
hornfeldt | 0:6c1bc9b3a347 | 75 | #define ACS_BULLET (acs_map['~']) /* bullet */ |
hornfeldt | 0:6c1bc9b3a347 | 76 | /* Teletype 5410v1 symbols begin here */ |
hornfeldt | 0:6c1bc9b3a347 | 77 | #define ACS_LARROW (acs_map[',']) /* arrow pointing left */ |
hornfeldt | 0:6c1bc9b3a347 | 78 | #define ACS_RARROW (acs_map['+']) /* arrow pointing right */ |
hornfeldt | 0:6c1bc9b3a347 | 79 | #define ACS_DARROW (acs_map['.']) /* arrow pointing down */ |
hornfeldt | 0:6c1bc9b3a347 | 80 | #define ACS_UARROW (acs_map['-']) /* arrow pointing up */ |
hornfeldt | 0:6c1bc9b3a347 | 81 | #define ACS_BOARD (acs_map['h']) /* board of squares */ |
hornfeldt | 0:6c1bc9b3a347 | 82 | #define ACS_LANTERN (acs_map['i']) /* lantern symbol */ |
hornfeldt | 0:6c1bc9b3a347 | 83 | #define ACS_BLOCK (acs_map['0']) /* solid square block */ |
hornfeldt | 0:6c1bc9b3a347 | 84 | |
hornfeldt | 0:6c1bc9b3a347 | 85 | |
hornfeldt | 0:6c1bc9b3a347 | 86 | /* |
hornfeldt | 0:6c1bc9b3a347 | 87 | Low-level hardware routines |
hornfeldt | 0:6c1bc9b3a347 | 88 | Have to be defined by user |
hornfeldt | 0:6c1bc9b3a347 | 89 | */ |
hornfeldt | 0:6c1bc9b3a347 | 90 | |
hornfeldt | 0:6c1bc9b3a347 | 91 | extern void _putch (char ch); /* Writes a character directly to the console. */ |
hornfeldt | 0:6c1bc9b3a347 | 92 | extern int _getch (void); /* Reads a character directly from the console, without echo. */ |
hornfeldt | 0:6c1bc9b3a347 | 93 | extern int _kbhit (void); /* Determines if a keyboard key was pressed.*/ |
hornfeldt | 0:6c1bc9b3a347 | 94 | extern int get_esc_sec (void); |
hornfeldt | 0:6c1bc9b3a347 | 95 | |
hornfeldt | 0:6c1bc9b3a347 | 96 | #ifdef PIC18 |
hornfeldt | 0:6c1bc9b3a347 | 97 | #define ROMDEF const rom |
hornfeldt | 0:6c1bc9b3a347 | 98 | #else |
hornfeldt | 0:6c1bc9b3a347 | 99 | #define ROMDEF const |
hornfeldt | 0:6c1bc9b3a347 | 100 | #endif |
hornfeldt | 0:6c1bc9b3a347 | 101 | |
hornfeldt | 0:6c1bc9b3a347 | 102 | /* |
hornfeldt | 0:6c1bc9b3a347 | 103 | Standard conio routines |
hornfeldt | 0:6c1bc9b3a347 | 104 | Hardware/architecture/compiler independent |
hornfeldt | 0:6c1bc9b3a347 | 105 | */ |
hornfeldt | 0:6c1bc9b3a347 | 106 | extern void _cputs(ROMDEF char *s); /* Outputs a string directly to the console. */ |
hornfeldt | 0:6c1bc9b3a347 | 107 | extern char* _cgets(char *s); /* Gets a string directly from the console. */ |
hornfeldt | 0:6c1bc9b3a347 | 108 | |
hornfeldt | 0:6c1bc9b3a347 | 109 | extern void clrscr(void); |
hornfeldt | 0:6c1bc9b3a347 | 110 | extern void clreol(void); |
hornfeldt | 0:6c1bc9b3a347 | 111 | |
hornfeldt | 0:6c1bc9b3a347 | 112 | extern void gotoxy(char x, char y); |
hornfeldt | 0:6c1bc9b3a347 | 113 | |
hornfeldt | 0:6c1bc9b3a347 | 114 | extern void cursoron(void); |
hornfeldt | 0:6c1bc9b3a347 | 115 | extern void cursoroff(void); |
hornfeldt | 0:6c1bc9b3a347 | 116 | |
hornfeldt | 0:6c1bc9b3a347 | 117 | |
hornfeldt | 0:6c1bc9b3a347 | 118 | extern void textcolor(int color); |
hornfeldt | 0:6c1bc9b3a347 | 119 | extern void textbackground(int color); |
hornfeldt | 0:6c1bc9b3a347 | 120 | extern void textattr(int attr); |
hornfeldt | 0:6c1bc9b3a347 | 121 | |
hornfeldt | 0:6c1bc9b3a347 | 122 | |
hornfeldt | 0:6c1bc9b3a347 | 123 | #ifdef __cplusplus |
hornfeldt | 0:6c1bc9b3a347 | 124 | } |
hornfeldt | 0:6c1bc9b3a347 | 125 | #endif |
hornfeldt | 0:6c1bc9b3a347 | 126 | |
hornfeldt | 0:6c1bc9b3a347 | 127 | |
hornfeldt | 0:6c1bc9b3a347 | 128 | #endif /* _INC_CONIO */ |