Partial merge of I/O management.
[super-star-trek.git] / sstlinux.c
1 #include <stdarg.h>
2 #include <ncurses/ncurses.h>
3
4 #include <sys/types.h>
5 #include <fcntl.h>
6 #include <sys/ioctl.h>
7 #include <linux/kd.h>
8
9 #include "sstlinux.h"
10
11 static int fd = 0;
12
13 #ifdef SERGEEV
14 int c_printf (char *format, ... )
15 {
16     char buffer[BUFSIZ]; /* Well, BUFSIZ is from ncurses...  */
17     va_list argp;
18     va_start(argp,format);
19     vsprintf(buffer,format,argp);
20     va_end(argp);
21     return waddstr(conio_scr,buffer);
22 }
23 #endif /* SERGEEV */
24
25 void sound(unsigned int freq)
26 {
27     if(fd==0) fd=open("/dev/console", O_RDONLY);
28     if(fd>0) ioctl(fd, KDMKTONE, 1193180/freq + (0xFFFF<<16));
29 }
30
31 void nosound(void)
32 {
33     if(fd>0) ioctl(fd, KDMKTONE, 0);
34 }