diff options
author | jkh <jkh@FreeBSD.org> | 1995-04-28 17:38:08 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-04-28 17:38:08 +0000 |
commit | 0b82ba3bb61f246d381f376fca0c8070e9216ff2 (patch) | |
tree | 93a73f44430f9723543ed74fed13dfc3e82d6bc8 | |
parent | a94803da3b0bb61df4ae5bf5cdb0624a80ac3ca1 (diff) | |
parent | cd7f88cc8db2624e31ec0837b6e1dddf97893db2 (diff) | |
download | FreeBSD-src-0b82ba3bb61f246d381f376fca0c8070e9216ff2.zip FreeBSD-src-0b82ba3bb61f246d381f376fca0c8070e9216ff2.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r8136,
which included commits to RCS files with non-trunk default branches.
-rw-r--r-- | games/piano/Makefile | 8 | ||||
-rw-r--r-- | games/piano/README | 12 | ||||
-rw-r--r-- | games/piano/piano.6 | 57 | ||||
-rw-r--r-- | games/piano/piano.c | 166 |
4 files changed, 243 insertions, 0 deletions
diff --git a/games/piano/Makefile b/games/piano/Makefile new file mode 100644 index 0000000..d3e671f --- /dev/null +++ b/games/piano/Makefile @@ -0,0 +1,8 @@ +# @(#)Makefile 8.1 (Berkeley) 5/31/93 + +PROG= piano +MAN6= piano.6 +DPADD= ${LIBCURSES} ${LIBTERMCAP} +LDADD= -lcurses -ltermcap + +.include <bsd.prog.mk> diff --git a/games/piano/README b/games/piano/README new file mode 100644 index 0000000..c4b13ad --- /dev/null +++ b/games/piano/README @@ -0,0 +1,12 @@ +Hello. I've been using FreeBSD from version 1.0 1993 and very happy. +One of my favorite is /dev/speaker. Here is my /dev/speaker +application named `piano' which is a piano/organ emulator. I'd like +to contribute this program to FreeBSD if you like it. + +This directory contains sources, Makefile and man page. + +Make sure to config /dev/speaker and make it writable. Please select +appropriate owner/group/mode for /dev/speaker and piano. + +._. . ._ _.. _ .... . .._. .. _. . __ ._ _. .._ ._ ._.. +candy@kgc.co.jp (Toshihiro Kanda) or zw6t-knd@asahi-net.or.jp diff --git a/games/piano/piano.6 b/games/piano/piano.6 new file mode 100644 index 0000000..289ac13 --- /dev/null +++ b/games/piano/piano.6 @@ -0,0 +1,57 @@ +.Dd Feb 3, 1995 +.Dt "PIANO" 6 +.Os +.Sh NAME +.Nm piano +.Nd "a piano emulator" +.Sh SYNOPSIS +.Nm piano +.Op Fl vV +.Op Fl i Ar string +.Sh DESCRIPTION +The +.Nm piano +plays note by typing +.Em "QWERTYUIOP[]" +or +.Em "12 45 789 -=" . +Type +.Em ESC +key to quit +.Nm piano . +.Nm Piano +uses +.Em /dev/speaker . +.Pp +Available option: +.Bl -tag -width flag +.It Fl v +The +.Fl v +option causes +.Nm piano +to generate +.Em "play-string language" . +.It Fl V +The +.Fl V +option is for +.Nm piano +usage. +.It Fl i Ar string +The +.Fl i +option initializes +.Em /dev/speaker +by +.Ar string . +The default value is 't160 o1 l16 ml'. +.El +.Sh FILES +.Bl -tag -width /dev/speakerxx +.It Pa /dev/speaker +speaker device file +.Sh SEE ALSO +.Xr spkr 4 +.Sh AUTHOR +Toshihiro Kanda <candy@kgc.co.jp> Nov. 1993 diff --git a/games/piano/piano.c b/games/piano/piano.c new file mode 100644 index 0000000..cb60405 --- /dev/null +++ b/games/piano/piano.c @@ -0,0 +1,166 @@ +/* + * piano.c - a piano emulator + */ +static char rcsid[] = "$Id$"; +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <curses.h> + +#include <unistd.h> +#include <sys/file.h> + +char *myname; +int verbose; +static char *initcmd = "t160 o1 l16 ml"; + +static char usage_msg[] = + "simple keyboard player V0.8086\n" + "usage: %s [-v][-i str]\n" + "\t-i str defaults 't160 o1 l16 ml'\n" + "function: play by console keyboard\n" + "\tESC to exit. Note keys are ...\n" + "\t1 2 4 5 7 8 9 - = \\\n" + "\t Q W E R T Y U I O P [ ]\n" + ; + +struct kdef_t { + int ch; + char *str; +}; + +static char *kstr[256]; + +static struct kdef_t kdef[] = { + /* white key */ + { '\t', "<g>" }, + { 'q', "<a>" }, + { 'w', "<b>" }, + { 'e', "c" }, + { 'r', "d" }, + { 't', "e" }, + { 'y', "f" }, + { 'u', "g" }, + { 'i', "a" }, + { 'o', "b" }, + { 'p', ">c<" }, + { '[', ">d<" }, + { ']', ">e<" }, + { '\n', ">f<" }, + { '\r', ">f<" }, + /* black key */ + { '`', "<f#>" }, + { '1', "<g#>" }, + { '2', "<a#>" }, + /*{ '3', "<b#>" },*/ + { '4', "c#" }, + { '5', "d#" }, + /*{ '6', "e#" },*/ + { '7', "f#" }, + { '8', "g#" }, + { '9', "a#" }, + /*{ '0', "b#" },*/ + { '-', ">c#<" }, + { '=', ">d#<" }, + /*{ '\', ">e#<" },*/ + { '\177', ">f#<" }, + { '\0', NULL } +}; + +static int +init_kstr(void) +{ + struct kdef_t *mv = kdef; + while (mv->str != NULL) { + kstr[mv->ch] = mv->str; + mv++; + }/* while */ + return 0; +}/* init_kstr */ + +static int +fdputs(const char *s, int fd, int echo) +{ + int err, len = strlen(s); + write(fd, s, len); + err = write(fd, "\n", 1); + if (echo) { + fputs(s, stdout); + } + return err; +}/* fdputs */ + +static int +outspkr(const char *s) +{ + int err = -1, fd = open("/dev/speaker", O_WRONLY); + if (fd >= 0) { + fdputs(initcmd, fd, 0); + err = fdputs(s, fd, verbose); + close(fd); + } + return err; +}/* outspkr */ + +static int +nain(void) +{ + int ch; + initscr(); + noecho(); + nonl(); + raw(); + init_kstr(); + while ((ch = getch()) != '\033') { + if (kstr[ch] != NULL) { + outspkr(kstr[ch]); + } + else { + if (verbose) { + switch (ch) { + case ' ': + fputs(" ", stdout); + break; + case '\b': + fputs("\b", stdout); + break; + }/* switch */ + } + } + }/* while */ + endwin(); + return 0; +}/* nain */ + +int +main(int argc, char *argv[]) +{ + extern char *optarg; + extern int optind, opterr; + int ch, ex, show_usage = 0; + myname = argv[0]; + while ((ch = getopt(argc, argv, "-vi:")) != EOF) { + switch (ch) { + default: + case 'V': + show_usage++; + break; + case 'v': + verbose++; + break; + case 'i': + initcmd = optarg; + break; + }/* switch */ + }/* while */ + ex = 1; + if (show_usage) { + fprintf(stderr, usage_msg, myname); + } + else { + printf("Type ESC to exit.\n"); + ex = 0; + nain(); + } + return ex; +}/* main */ |