r3: Initial revision
[ctsim.git] / include / cio.h
1 #ifndef __CIO_H
2 #define __CIO_H
3
4 struct crtv_st {
5     int init;           /* True if initialized */
6     int bios_mode;      /* Current BIOS crt mode */
7     int text_attr;      /* Current text attribute */
8     int act_page;       /* Active page */
9     int tcols, trows;   /* Maximum text coords */
10     int xmax, ymax;     /* Maximum x, y for both text & graphic modes */
11     int cx, cy;         /* Current x, y position */
12 }; 
13
14 #ifndef DEFINE_CRTV
15    extern struct crtv_st crtv;
16 #endif
17
18 /*----------------------------------------------------------------------*/
19
20 #define CRT_ROWS  25
21 #define CRT_COLS  80
22
23 /* crt modes */
24
25 #define GM_TEXT40    1     /* color */
26 #define GM_TEXT80    3     /* color */
27 #define GM_320x200   4     /* color */
28 #define GM_640x200   6
29 #define GM_MONOTEXT  7
30 #define GM_E320x200 13
31 #define GM_E640x200 14
32 #define GM_MONOGRF  15
33 #define GM_ENHANCED 16
34
35 #define GM_640x480x16   0x12
36 #define GM_640x480x256  0x2E
37 #define GM_1024x768x16  0x37
38 #define GM_1024x768x256 0x38
39
40
41
42 #define GM_TEXT      -1
43 #define GM_HIGHRES   -2
44 #define GM_MEDRES    -3
45
46 #define CRT_NONE    -1
47 #define CRT_MONO     0
48 #define CRT_COLOR    1
49 #define CRT_ENHANCED 2
50
51 /*----------------------------------------------------------------------*/
52
53 #define  ATTR_NORMAL     7
54 #define  ATTR_REVERSE   14
55 #define  ATTR_HIGHLIGHT 15
56
57 #define C_BLACK      0                  /* color codes */
58 #define C_BLUE       1
59 #define C_GREEN      2
60 #define C_CYAN       3
61 #define C_RED        4
62 #define C_MAGENTA    5
63 #define C_BROWN      6
64 #define C_WHITE      7
65 #define C_GREY       8
66 #define C_LTBLUE     9
67 #define C_LTGREEN   10
68 #define C_LTCYAN    11
69 #define C_LTRED     12
70 #define C_LTMAGENTA 13
71 #define C_YELLOW    14
72 #define C_LTWHITE   15
73
74 /*----------------------------------------------------------------------*/
75
76 /* screen character codes */
77
78 #define SC_BKSP           8
79 #define SC_TAB            9
80 #define SC_BLANK        ' '
81
82 #define SC_TOP_LEFT     218
83 #define SC_TOP_RIGHT    191
84 #define SC_BOTT_LEFT    192
85 #define SC_BOTT_RIGHT   217
86 #define SC_HORIZ        196
87 #define SC_VERTICAL     179
88
89
90 #define WAITKEY()       {cio_kb_clr(); while (cio_kb_read() == 0);}
91
92 /* biosf.c */
93 void b_setcpos(int col, int row, int page);
94 void crt_wrt_cca(int c, int attr, int count, int page);
95 void crt_wrt_ca(int c, int attr, int page);
96 void crt_wrt_stra(const char *str, int count, int attr, int row, int col, int page);
97 /* c_restor.c */
98 void crt_restore(const char *fname);
99 /* c_save.c */
100 int crt_save(const char *fname);
101 /* center.c */
102 int crt_center_line(const char *str);
103 /* clreol.c */
104 void crt_clreol(void);
105 /* clrline.c */
106 void crt_clrline(unsigned int line);
107 /* clrscrn.c */
108 void crt_clrscrn(void);
109 /* cpos.c */
110 void crt_tab(unsigned int n);
111 void crt_save_cpos(void);
112 void crt_restore_cpos(void);
113 /* cprintf.c */
114 void cio_printf(const char *cs, ...);
115 void cio_aprintf(const int attr, const char *cs, ...);
116 /* cputs.c */
117 void cputs(const char *s);
118 /* crt_data.c */
119 /* ctype.c */
120 void crt_set_ctype(int start, int end);
121 void crt_cursor_off(void);
122 void crt_cursor_on(void);
123 /* dispcard.c */
124 int crt_disp_card(void);
125 /* fill_eol.c */
126 void crt_fill_eol(int c, int attr);
127 /* frame.c */
128 int crt_frame(int ulcol, int ulrow, int lrcol, int lrrow, int attr, int nlines);
129 /* get_ca.c */
130 void crt_get_ca(int *c, int *attr);
131 /* getmon.c */
132 int crt_get_mon(void);
133 void crt_set_mon(int mon);
134 /* getstate.c */
135 void crt_get_state(void);
136 /* mode.c */
137 void crt_set_mode(int mode, int cls);
138 int crt_get_mode(void);
139 int crt_bios_code(int mode);
140 /* put_ca.c */
141 void crt_set_text_clr(int fclr, int bclr);
142 int crt_get_texta(void);
143 void crt_set_texta(int a);
144 int crt_blank_attr(void);
145 void crt_put_ca(int c, int attr);
146 void crt_put_c(int c);
147 void crt_put_cc(int c, int count);
148 void crt_put_cca(int c, int attr, int count);
149 void crt_put_str(const char *str);
150 void crt_put_stra(const char *str, int attr);
151 void crt_inc_col(int count);
152 void crt_dec_col(int count);
153 void crt_dec_row(int count);
154 /* scrollup.c */
155 void crt_scrollup(int xmin, int ymin, int xmax, int ymax, int nline, int attr);
156 /* setcpos.c */
157 void crt_set_cpos(int col, int row);
158 void crt_get_cpos(int *col, int *row);
159 /* setpage.c */
160 void crt_set_page(int page);
161 /* setpal.c */
162 void crt_set_palette(int id, int color);
163 void crt_set_color_table(char *color_table);
164 void crt_set_border(int bcolor);
165 int crt_calc_color(double nr, double ng, double nb);
166 int crt_icalc_color(int r, int g, int b);
167
168 /* beep.c */
169 void cio_beep(void);
170 /* kb_chk.c */
171 int cio_kb_chk(void);
172 /* kb_clr.c */
173 void cio_kb_clr(void);
174 /* kb_getc.c */
175 unsigned int cio_kb_getc(void);
176 void cio_kb_ungetc(unsigned int c);
177 /* kb_gets.c */
178 char *cio_kb_gets(char *str, int maxlen);
179 /* kb_read.c */
180 unsigned int cio_kb_read(void);
181 void cio_kb_unread(unsigned int c);
182 /* kb_waitc.c */
183 unsigned int cio_kb_waitc(const char *astr, const char *estr, int beep_on_error);
184 /* speaker.c */
185 void cio_spkr_freq(double freq);
186 void cio_spkr_divisor(unsigned int div);
187 void cio_spkr_on(void);
188 void cio_spkr_off(void);
189 /* tone.c */
190 void cio_tone(double freq, double length);
191 /* check_kb */
192 int cio_check_kb_escape(void);
193
194 #endif