2 * piano.c - a piano emulator
4 * $FreeBSD: src/games/piano/piano.c,v 1.7 1999/12/12 03:22:37 billf Exp $
5 * $DragonFly: src/games/piano/piano.c,v 1.2 2003/06/17 04:25:24 dillon Exp $
17 static char *initcmd = "t160 o1 l16 ml";
19 static char usage_msg[] =
20 "simple keyboard player V0.8086\n"
21 "usage: %s [-v][-i str]\n"
22 "\t-i str defaults 't160 o1 l16 ml'\n"
23 "function: play by console keyboard\n"
24 "\tESC to exit. Note keys are ...\n"
25 "\t1 2 4 5 7 8 9 - = \\\n"
26 "\t Q W E R T Y U I O P [ ]\n"
34 static char *kstr[256];
36 static struct kdef_t kdef[] = {
75 struct kdef_t *mv = kdef;
76 while (mv->str != NULL) {
77 kstr[mv->ch] = mv->str;
84 fdputs(const char *s, int fd, int echo)
86 int err, len = strlen(s);
88 err = write(fd, "\n", 1);
96 outspkr(const char *s)
98 int err = -1, fd = open("/dev/speaker", O_WRONLY);
100 fdputs(initcmd, fd, 0);
101 err = fdputs(s, fd, verbose);
116 while ((ch = getch()) != '\033') {
117 if (kstr[ch] != NULL) {
138 main(int argc, char *argv[])
140 int ch, ex, show_usage = 0;
142 while ((ch = getopt(argc, argv, "-vi:")) != -1) {
158 fprintf(stderr, usage_msg, myname);
161 printf("Type ESC to exit.\n");