2 * piano.c - a piano emulator
4 static const char rcsid[] =
5 "$FreeBSD: src/games/piano/piano.c,v 1.7 1999/12/12 03:22:37 billf Exp $";
16 static char *initcmd = "t160 o1 l16 ml";
18 static char usage_msg[] =
19 "simple keyboard player V0.8086\n"
20 "usage: %s [-v][-i str]\n"
21 "\t-i str defaults 't160 o1 l16 ml'\n"
22 "function: play by console keyboard\n"
23 "\tESC to exit. Note keys are ...\n"
24 "\t1 2 4 5 7 8 9 - = \\\n"
25 "\t Q W E R T Y U I O P [ ]\n"
33 static char *kstr[256];
35 static struct kdef_t kdef[] = {
74 struct kdef_t *mv = kdef;
75 while (mv->str != NULL) {
76 kstr[mv->ch] = mv->str;
83 fdputs(const char *s, int fd, int echo)
85 int err, len = strlen(s);
87 err = write(fd, "\n", 1);
95 outspkr(const char *s)
97 int err = -1, fd = open("/dev/speaker", O_WRONLY);
99 fdputs(initcmd, fd, 0);
100 err = fdputs(s, fd, verbose);
115 while ((ch = getch()) != '\033') {
116 if (kstr[ch] != NULL) {
137 main(int argc, char *argv[])
139 int ch, ex, show_usage = 0;
141 while ((ch = getopt(argc, argv, "-vi:")) != -1) {
157 fprintf(stderr, usage_msg, myname);
160 printf("Type ESC to exit.\n");