FreeCalypso > hg > freecalypso-tools
changeset 895:850b4f066d75
fc-buzplay: unified play command
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 03 Apr 2022 08:30:35 +0000 |
parents | 7ade15d4e0cb |
children | 0a2f50c571de |
files | loadtools/Makefile loadtools/bpdispatch.c loadtools/bpunify.c |
diffstat | 3 files changed, 70 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/loadtools/Makefile Sun Apr 03 08:11:05 2022 +0000 +++ b/loadtools/Makefile Sun Apr 03 08:30:35 2022 +0000 @@ -27,9 +27,9 @@ labaud.o lacrc32.o romload.o secondprog.o srecreader.o \ tpinterf.o tpinterf2.o tpinterfb.o ttypassthru.o -BUZPLAY_OBJS= bpdispatch.o bpmain.o buzplaybu.o buzplaypwt.o compalload.o \ - defpath.o flashstubs.o hexdecode.o hwparam.o labaud.o ltexit.o \ - ltpassthru.o romload.o srecreader.o tpinterf.o +BUZPLAY_OBJS= bpdispatch.o bpmain.o bpunify.o buzplaybu.o buzplaypwt.o \ + compalload.o defpath.o flashstubs.o hexdecode.o hwparam.o \ + labaud.o ltexit.o ltpassthru.o romload.o srecreader.o tpinterf.o ROMDUMP_OBJS= compalload.o defpath.o flashstubs.o hexdecode.o hwparam.o \ labaud.o ltexit.o romdump.o romload.o srecreader.o tpinterf.o \
--- a/loadtools/bpdispatch.c Sun Apr 03 08:11:05 2022 +0000 +++ b/loadtools/bpdispatch.c Sun Apr 03 08:30:35 2022 +0000 @@ -10,6 +10,7 @@ extern int cmd_baud(); extern int cmd_exit(); +extern int cmd_play(); extern int cmd_play_bu(); extern int cmd_play_pwt(); extern int loadtool_cmd_passthru(); @@ -25,7 +26,7 @@ {"baud", 0, 1, cmd_baud}, {"buzlev", 0, 1, loadtool_cmd_passthru}, {"exit", 0, 1, cmd_exit}, - {"play", 1, 1, cmd_play_bu}, + {"play", 1, 2, cmd_play}, {"play-bu", 1, 1, cmd_play_bu}, {"play-pwt", 1, 2, cmd_play_pwt}, {"playt", 1, 2, cmd_play_pwt},
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loadtools/bpunify.c Sun Apr 03 08:30:35 2022 +0000 @@ -0,0 +1,65 @@ +/* + * fc-buzplay: this module implements the unified 'play' command. + */ + +#include <sys/types.h> +#include <ctype.h> +#include <stdio.h> +#include <string.h> +#include <strings.h> +#include <stdlib.h> + +set_bu_volume(vol) + unsigned vol; +{ + char *targv[3], argbuf[16]; + + sprintf(argbuf, "%u", vol - 1); + targv[0] = "buzlev"; + targv[1] = argbuf; + targv[2] = 0; + tpinterf_make_cmd(targv); + if (tpinterf_send_cmd() < 0) + return(-1); + return tpinterf_pass_output(1); +} + +cmd_play(argc, argv) + char **argv; +{ + char *filename, *tail; + int pwt_mode, rc; + unsigned global_vol; + + filename = argv[1]; + tail = rindex(filename, '.'); + if (!tail) { +unknown: fprintf(stderr, + "unable to intuit format of %s, use play-bu or play-pwt\n", + filename); + return(-1); + } + if (!strcmp(tail, ".buz")) + pwt_mode = 0; + else if (!strcmp(tail, ".pwt")) + pwt_mode = 1; + else + goto unknown; + if (argv[2]) { + global_vol = strtoul(argv[2], 0, 0); + if (global_vol < 1 || global_vol > 64) { + fprintf(stderr, + "error: invalid global volume argument\n"); + return(-1); + } + } else + global_vol = 64; + if (pwt_mode) + return buzplay_pwt_file(filename, global_vol); + else { + rc = set_bu_volume(global_vol); + if (rc) + return(rc); + return buzplay_bu_file(filename); + } +}