1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (c) 1983-2009 Kevin Rosenberg
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License (version 2) as
7 ** published by the Free Software Foundation.
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ** GNU General Public License for more details.
14 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 ******************************************************************************/
21 #include "ctsupport.h"
25 * cio_put_c Put a character on screen
29 * char c Character to write
32 * Color of character is determined by the global variable, crtv.text_attr.
35 * Cursor is advanced by one. If necessary, the cursor will wrap around
36 * and maybe the screen will scroll
48 * cio_put_cc Put a char on screen count times
51 * cio_put_cc (c, count)
52 * char c Character to write
53 * int count Number of characters to write
57 cio_put_cc (int c, int count)
59 for (int i = 0; i < count; i++)
65 cio_put_str (const char *str)
73 * kb_getc Get a character from the keyboard
79 * 1. This routine returns an EXTENTED ASCII code,
80 * the extended codes have a low byte of 0 and a distinctive
81 * high byte, such as 0x2D00 and 0x3200
82 * 2. This routine waits until a key has been typed
83 * 2. The keystroke will not be echoed.
86 unsigned int cio_kb_getc(void)
92 cio_kb_ungetc (unsigned int c)
98 * kb_gets Get a string from the keyboard
101 * str = kb_gets (str, maxlen)
102 * char *str Space to store input string
103 * int maxlen Maximum number of characters to read
104 * (Not including EOS)
106 * Backspace - erases character to the right
107 * Escape - erases to beginning of line
108 * Return - ends string (no not cause a linefeed)
112 cio_kb_gets (char *str, int maxlen)
114 return fgets(str, maxlen, stdin);
118 * kb_waitc Wait for a character from the keyboard
121 * key = kb_waitc (astr, estr, beep)
122 * int key Keystroke entered
123 * char *astr String of valid ascii characters
124 * bool beep If TRUE, beep when user hits invalid key
130 cio_kb_waitc (const char *astr, int beep_on_error)
135 if (strchr (astr, c) != NULL)
146 * beep sound a beep to user
154 cio_tone (2000.0, 0.3);
158 * tone play a frequency sound for some duration
161 * tone (freq, length)
162 * double freq frequency to play in Hertz
163 * double length duration to play note in seconds
167 cio_tone (double freq, double length)
170 fprintf(stdout, "\007");
172 cio_spkr_freq (freq); /* Set frequency of tone */
173 cio_spkr_on (); /* Turn on speaker */
174 pause (length); /* Pause for length seconds */
175 cio_spkr_off (); /* Turn off speaker */