]> git.sur5r.net Git - cc65/blob - include/conio.h
Merge remote-tracking branch 'upstream/master' into pcenginetarget
[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 #if !defined(_STDARG_H)
58 #  include <stdarg.h>
59 #endif
60
61 /* Include the correct machine-specific file */
62 #if defined(__APPLE2ENH__)
63 #  include <apple2enh.h>
64 #elif defined(__APPLE2__)
65 #  include <apple2.h>
66 #elif defined(__ATARI__)
67 #  include <atari.h>
68 #elif defined(__ATMOS__)
69 #  include <atmos.h>
70 #elif defined(__CBM__)
71 #  include <cbm.h>
72 #elif defined(__GEOS__)
73 #  include <geos.h>
74 #elif defined(__LUNIX__)
75 #  include <lunix.h>
76 #elif defined(__LYNX__)
77 #  include <lynx.h>
78 #elif defined(__NES__)
79 #  include <nes.h>
80 #elif defined(__OSIC1P__)
81 #  include <osic1p.h>
82 #elif defined(__PCE__)
83 #  include <pce.h>
84 #endif
85
86
87
88 /*****************************************************************************/
89 /*                                 Functions                                 */
90 /*****************************************************************************/
91
92
93
94 void clrscr (void);
95 /* Clear the whole screen and put the cursor into the top left corner */
96
97 unsigned char kbhit (void);
98 /* Return true if there's a key waiting, return false if not */
99
100 void __fastcall__ gotox (unsigned char x);
101 /* Set the cursor to the specified X position, leave the Y position untouched */
102
103 void __fastcall__ gotoy (unsigned char y);
104 /* Set the cursor to the specified Y position, leave the X position untouched */
105
106 void __fastcall__ gotoxy (unsigned char x, unsigned char y);
107 /* Set the cursor to the specified position */
108
109 unsigned char wherex (void);
110 /* Return the X position of the cursor */
111
112 unsigned char wherey (void);
113 /* Return the Y position of the cursor */
114
115 void __fastcall__ cputc (char c);
116 /* Output one character at the current cursor position */
117
118 void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);
119 /* Same as "gotoxy (x, y); cputc (c);" */
120
121 void __fastcall__ cputs (const char* s);
122 /* Output a NUL-terminated string at the current cursor position */
123
124 void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);
125 /* Same as "gotoxy (x, y); puts (s);" */
126
127 int cprintf (const char* format, ...);
128 /* Like printf(), but uses direct screen output */
129
130 int __fastcall__ vcprintf (const char* format, va_list ap);
131 /* Like vprintf(), but uses direct screen output */
132
133 char cgetc (void);
134 /* Return a character from the keyboard. If there is no character available,
135 ** the function waits until the user does press a key. If cursor is set to
136 ** 1 (see below), a blinking cursor is displayed while waiting.
137 */
138
139 int cscanf (const char* format, ...);
140 /* Like scanf(), but uses direct keyboard input */
141
142 int __fastcall__ vcscanf (const char* format, va_list ap);
143 /* Like vscanf(), but uses direct keyboard input */
144
145 unsigned char __fastcall__ cursor (unsigned char onoff);
146 /* If onoff is 1, a cursor is displayed when waiting for keyboard input. If
147 ** onoff is 0, the cursor is hidden when waiting for keyboard input. The
148 ** function returns the old cursor setting.
149 */
150
151 unsigned char __fastcall__ revers (unsigned char onoff);
152 /* Enable/disable reverse character display. This may not be supported by
153 ** the output device. Return the old setting.
154 */
155
156 unsigned char __fastcall__ textcolor (unsigned char color);
157 /* Set the color for text output. The old color setting is returned. */
158
159 unsigned char __fastcall__ bgcolor (unsigned char color);
160 /* Set the color for the background. The old color setting is returned. */
161
162 unsigned char __fastcall__ bordercolor (unsigned char color);
163 /* Set the color for the border. The old color setting is returned. */
164
165 void __fastcall__ chline (unsigned char length);
166 /* Output a horizontal line with the given length starting at the current
167 ** cursor position.
168 */
169
170 void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);
171 /* Same as "gotoxy (x, y); chline (length);" */
172
173 void __fastcall__ cvline (unsigned char length);
174 /* Output a vertical line with the given length at the current cursor
175 ** position.
176 */
177
178 void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);
179 /* Same as "gotoxy (x, y); cvline (length);" */
180
181 void __fastcall__ cclear (unsigned char length);
182 /* Clear part of a line (write length spaces). */
183
184 void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);
185 /* Same as "gotoxy (x, y); cclear (length);" */
186
187 void __fastcall__ screensize (unsigned char* x, unsigned char* y);
188 /* Return the current screen size. */
189
190 void __fastcall__ cputhex8 (unsigned char val);
191 void __fastcall__ cputhex16 (unsigned val);
192 /* These shouldn't be here... */
193
194
195
196 /*****************************************************************************/
197 /*                                  Macros                                   */
198 /*****************************************************************************/
199
200
201
202 /* On some platforms, functions are not available or are dummys. To suppress
203 ** the call to these functions completely, the platform header files may
204 ** define macros for these functions that start with an underline. If such a
205 ** macro exists, a new macro is defined here, that expands to the one with the
206 ** underline. The reason for this two stepped approach is that it is sometimes
207 ** necessary to take the address of the function, which is not possible when
208 ** using a macro. Since the function prototype is still present, #undefining
209 ** the macro will give access to the actual function.
210 */
211
212 #if defined(_textcolor)
213 #  define textcolor(x)          _textcolor(x)
214 #endif
215 #if defined(_bgcolor)
216 #  define bgcolor(x)            _bgcolor(x)
217 #endif
218 #if defined(_bordercolor)
219 #  define bordercolor(x)        _bordercolor(x)
220 #endif
221
222
223
224 /* End of conio.h */
225 #endif
226
227
228