1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: consoleio.cpp,v 1.3 2000/06/22 10:17:28 kevin Exp $
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License (version 2) as
9 ** published by the Free Software Foundation.
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
16 ** You should have received a copy of the GNU General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ******************************************************************************/
23 #include "ctsupport.h"
27 * cio_put_c Put a character on screen
31 * char c Character to write
34 * Color of character is determined by the global variable, crtv.text_attr.
37 * Cursor is advanced by one. If necessary, the cursor will wrap around
38 * and maybe the screen will scroll
50 * cio_put_cc Put a char on screen count times
53 * cio_put_cc (c, count)
54 * char c Character to write
55 * int count Number of characters to write
59 cio_put_cc (int c, int count)
61 for (int i = 0; i < count; i++)
67 cio_put_str (const char *str)
75 * kb_getc Get a character from the keyboard
81 * 1. This routine returns an EXTENTED ASCII code,
82 * the extended codes have a low byte of 0 and a distinctive
83 * high byte, such as 0x2D00 and 0x3200
84 * 2. This routine waits until a key has been typed
85 * 2. The keystroke will not be echoed.
88 unsigned int cio_kb_getc(void)
94 cio_kb_ungetc (unsigned int c)
100 * kb_gets Get a string from the keyboard
103 * str = kb_gets (str, maxlen)
104 * char *str Space to store input string
105 * int maxlen Maximum number of characters to read
106 * (Not including EOS)
108 * Backspace - erases character to the right
109 * Escape - erases to beginning of line
110 * Return - ends string (no not cause a linefeed)
114 cio_kb_gets (char *str, int maxlen)
116 return fgets(str, maxlen, stdin);
120 * kb_waitc Wait for a character from the keyboard
123 * key = kb_waitc (astr, estr, beep)
124 * int key Keystroke entered
125 * char *astr String of valid ascii characters
126 * bool beep If TRUE, beep when user hits invalid key
132 cio_kb_waitc (const char *astr, int beep_on_error)
137 if (strchr (astr, c) != NULL)
148 * beep sound a beep to user
156 cio_tone (2000.0, 0.3);
160 * tone play a frequency sound for some duration
163 * tone (freq, length)
164 * double freq frequency to play in Hertz
165 * double length duration to play note in seconds
169 cio_tone (double freq, double length)
172 fprintf(stdout, "\007");
174 cio_spkr_freq (freq); /* Set frequency of tone */
175 cio_spkr_on (); /* Turn on speaker */
176 pause (length); /* Pause for length seconds */
177 cio_spkr_off (); /* Turn off speaker */