First round of changes from Stas Sergeev.
[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 int c_printf (char *format, ... )
14 {
15     char buffer[BUFSIZ]; /* Well, BUFSIZ is from ncurses...  */
16     va_list argp;
17     va_start(argp,format);
18     vsprintf(buffer,format,argp);
19     va_end(argp);
20     return waddstr(conio_scr,buffer);
21 }
22
23 void sound(unsigned int freq)
24 {
25     if(fd==0) fd=open("/dev/console", O_RDONLY);
26     if(fd>0) ioctl(fd, KDMKTONE, 1193180/freq + (0xFFFF<<16));
27 }
28
29 void nosound(void)
30 {
31     if(fd>0) ioctl(fd, KDMKTONE, 0);
32 }