FreeCalypso > hg > freecalypso-tools
changeset 80:eb5960dc258c
buzplayer: melody entry implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 27 Oct 2016 04:31:31 +0000 |
parents | 49d2684805b1 |
children | 8a200d65c6a0 |
files | target-utils/buzplayer/Makefile target-utils/buzplayer/cmdtab.c target-utils/buzplayer/melentry.c |
diffstat | 3 files changed, 39 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/target-utils/buzplayer/Makefile Thu Oct 27 04:18:38 2016 +0000 +++ b/target-utils/buzplayer/Makefile Thu Oct 27 04:31:31 2016 +0000 @@ -7,7 +7,7 @@ INSTDIR=/opt/freecalypso/target-bin PROG= buzplayer -OBJS= crt0.o cmdtab.o main.o mygetchar.o timer.o +OBJS= crt0.o cmdtab.o main.o melentry.o mygetchar.o timer.o LIBS= ../libcommon/libcommon.a ../libprintf/libprintf.a ../libbase/libbase.a LDS= ../env/iram.lds
--- a/target-utils/buzplayer/cmdtab.c Thu Oct 27 04:18:38 2016 +0000 +++ b/target-utils/buzplayer/cmdtab.c Thu Oct 27 04:31:31 2016 +0000 @@ -16,7 +16,12 @@ extern void abb_init(); extern void abb_power_off(); +extern void melody_init(); +extern void melody_entry(); + const struct cmdtab cmdtab[] = { + {"E", melody_entry}, + {"I", melody_init}, {"abbinit", abb_init}, {"abbr", cmd_abbr}, {"abbw", cmd_abbw},
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/target-utils/buzplayer/melentry.c Thu Oct 27 04:31:31 2016 +0000 @@ -0,0 +1,33 @@ +#include <sys/types.h> +#include <ctype.h> +#include <stdlib.h> +#include "types.h" +#include "melody.h" + +extern struct melentry *melody_buf_start, *melody_buf_tailptr; + +void +melody_init() +{ + melody_buf_tailptr = melody_buf_start; +} + +void +melody_entry(argbulk) + char *argbulk; +{ + char *argv[3]; + u32 tone, dur; + + if (parse_args(argbulk, 2, 2, argv, 0) < 0) + return; + tone = strtoul(argv[0], 0, 0); + dur = strtoul(argv[1], 0, 0); + if (tone > 255 || dur < 1 || dur > 0xFFFF) { + printf("ERROR: argument(s) out of range\n"); + return; + } + melody_buf_tailptr->tone = tone; + melody_buf_tailptr->dur = dur; + melody_buf_tailptr++; +}