]> git.sur5r.net Git - cc65/blob - include/conio.h
Fixed _textcolor definition.
[cc65] / include / conio.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                  conio.h                                  */
4 /*                                                                           */
5 /*                            Direct console I/O                             */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2007 Ullrich von Bassewitz                                       */
10 /*               Roemerstrasse 52                                            */
11 /*               D-70794 Filderstadt                                         */
12 /* EMail:        uz@cc65.org                                                 */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 /*
37 ** This is the direct console interface for cc65. I do not like the function
38 ** names very much, but the first version started as a rewrite of Borland's
39 ** conio, and, even if the interface has changed, the names did not.
40 **
41 ** The interface does direct screen I/O, so it is fast enough for most
42 ** programs. I did not implement text windows, since many applications do
43 ** not need them and should not pay for the additional overhead. It should
44 ** be easy to add text windows on a higher level if needed,
45 **
46 ** Most routines do not check the parameters. This may be unfortunate but is
47 ** also related to speed. The coordinates are always 0/0 based.
48 */
49
50
51
52 #ifndef _CONIO_H
53 #define _CONIO_H
54
55
56
57 #include <stdarg.h>
58 #include <target.h>
59
60
61
62 /*****************************************************************************/
63 /*                                 Functions                                 */
64 /*****************************************************************************/
65
66
67
68 void clrscr (void);
69 /* Clear the whole screen and put the cursor into the top left corner */
70
71 unsigned char kbhit (void);
72 /* Return true if there's a key waiting, return false if not */
73
74 void __fastcall__ gotox (unsigned char x);
75 /* Set the cursor to the specified X position, leave the Y position untouched */
76
77 void __fastcall__ gotoy (unsigned char y);
78 /* Set the cursor to the specified Y position, leave the X position untouched */
79
80 void __fastcall__ gotoxy (unsigned char x, unsigned char y);
81 /* Set the cursor to the specified position */
82
83 unsigned char wherex (void);
84 /* Return the X position of the cursor */
85
86 unsigned char wherey (void);
87 /* Return the Y position of the cursor */
88
89 void __fastcall__ cputc (char c);
90 /* Output one character at the current cursor position */
91
92 void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);
93 /* Same as "gotoxy (x, y); cputc (c);" */
94
95 void __fastcall__ cputs (const char* s);
96 /* Output a NUL-terminated string at the current cursor position */
97
98 void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);
99 /* Same as "gotoxy (x, y); puts (s);" */
100
101 int cprintf (const char* format, ...);
102 /* Like printf(), but uses direct screen output */
103
104 int __fastcall__ vcprintf (const char* format, va_list ap);
105 /* Like vprintf(), but uses direct screen output */
106
107 char cgetc (void);
108 /* Return a character from the keyboard. If there is no character available,
109 ** the function waits until the user does press a key. If cursor is set to
110 ** 1 (see below), a blinking cursor is displayed while waiting.
111 */
112
113 int cscanf (const char* format, ...);
114 /* Like scanf(), but uses direct keyboard input */
115
116 int __fastcall__ vcscanf (const char* format, va_list ap);
117 /* Like vscanf(), but uses direct keyboard input */
118
119 char cpeekc (void);
120 /* Return the character from the current cursor position */
121
122 unsigned char cpeekcolor (void);
123 /* Return the color from the current cursor position */
124
125 unsigned char cpeekrevers (void);
126 /* Return the reverse attribute from the current cursor position.
127 ** If the character is reversed, then return 1; return 0 otherwise.
128 */
129
130 void __fastcall__ cpeeks (char* s, unsigned int length);
131 /* Return a string of the characters that start at the current cursor position.
132 ** Put the string into the buffer to which "s" points.  The string will have
133 ** "length" characters, then will be '\0'-terminated.
134 */
135
136 unsigned char __fastcall__ cursor (unsigned char onoff);
137 /* If onoff is 1, a cursor is displayed when waiting for keyboard input. If
138 ** onoff is 0, the cursor is hidden when waiting for keyboard input. The
139 ** function returns the old cursor setting.
140 */
141
142 unsigned char __fastcall__ revers (unsigned char onoff);
143 /* Enable/disable reverse character display. This may not be supported by
144 ** the output device. Return the old setting.
145 */
146
147 unsigned char __fastcall__ textcolor (unsigned char color);
148 /* Set the color for text output. The old color setting is returned. */
149
150 unsigned char __fastcall__ bgcolor (unsigned char color);
151 /* Set the color for the background. The old color setting is returned. */
152
153 unsigned char __fastcall__ bordercolor (unsigned char color);
154 /* Set the color for the border. The old color setting is returned. */
155
156 void __fastcall__ chline (unsigned char length);
157 /* Output a horizontal line with the given length starting at the current
158 ** cursor position.
159 */
160
161 void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);
162 /* Same as "gotoxy (x, y); chline (length);" */
163
164 void __fastcall__ cvline (unsigned char length);
165 /* Output a vertical line with the given length at the current cursor
166 ** position.
167 */
168
169 void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);
170 /* Same as "gotoxy (x, y); cvline (length);" */
171
172 void __fastcall__ cclear (unsigned char length);
173 /* Clear part of a line (write length spaces). */
174
175 void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);
176 /* Same as "gotoxy (x, y); cclear (length);" */
177
178 void __fastcall__ screensize (unsigned char* x, unsigned char* y);
179 /* Return the current screen size. */
180
181 void __fastcall__ cputhex8 (unsigned char val);
182 void __fastcall__ cputhex16 (unsigned val);
183 /* These shouldn't be here... */
184
185
186
187 /*****************************************************************************/
188 /*                                  Macros                                   */
189 /*****************************************************************************/
190
191
192
193 /* On some platforms, functions are not available or are dummys. To suppress
194 ** the call to these functions completely, the platform header files may
195 ** define macros for these functions that start with an underline. If such a
196 ** macro exists, a new macro is defined here, that expands to the one with the
197 ** underline. The reason for this two stepped approach is that it is sometimes
198 ** necessary to take the address of the function, which is not possible when
199 ** using a macro. Since the function prototype is still present, #undefining
200 ** the macro will give access to the actual function.
201 */
202
203 #ifdef _textcolor
204 #  define textcolor(x)          _textcolor(x)
205 #endif
206 #ifdef _bgcolor
207 #  define bgcolor(x)            _bgcolor(x)
208 #endif
209 #ifdef _bordercolor
210 #  define bordercolor(x)        _bordercolor(x)
211 #endif
212 #ifdef _cpeekcolor
213 #  define cpeekcolor(x)         _cpeekcolor(x)
214 #endif
215
216
217
218 /* End of conio.h */
219 #endif