FreeCalypso > hg > freecalypso-tools
view target-utils/buzplayer/melentry.c @ 926:6a0aa8d36d06
rvinterf backslash escape: introduce libprint
The new helper function library named libprint is meant to replace
the badly misnamed libg23, and will soon contain functions for
printing all of the same kinds of GPF TST packets that are now handled
in libg23. However, we are also moving safe_print_trace() from libasync
to this new library, and changing it to emit our new backslash escape
format.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 23 May 2023 03:47:46 +0000 |
parents | 9092ff68e37d |
children |
line wrap: on
line source
#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; extern int melody_mode; void melody_init() { melody_buf_tailptr = melody_buf_start; melody_mode = 1; pwt_off(); } void melody_init_pwt() { melody_buf_tailptr = melody_buf_start; melody_mode = 2; pwt_on(); } void melody_entry(argbulk) char *argbulk; { char *argv[3]; u32 tone, dur; if (melody_mode != 1) { printf("ERROR: wrong mode for melody entry\n"); return; } 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++; } void pwt_entry_note(argbulk) char *argbulk; { char *argv[4]; u32 tone, vol, dur; if (melody_mode != 2) { printf("ERROR: wrong mode for melody entry\n"); return; } if (parse_args(argbulk, 3, 3, argv, 0) < 0) return; tone = strtoul(argv[0], 0, 0); vol = strtoul(argv[1], 0, 0); dur = strtoul(argv[2], 0, 0); if (tone > 47 || vol > 63 || dur < 1 || dur > 0xFFFF) { printf("ERROR: argument(s) out of range\n"); return; } melody_buf_tailptr->tone = tone; melody_buf_tailptr->vol = (vol << 1) | 1; melody_buf_tailptr->dur = dur; melody_buf_tailptr++; } void pwt_entry_rest(argbulk) char *argbulk; { char *argv[2]; u32 dur; if (melody_mode != 2) { printf("ERROR: wrong mode for melody entry\n"); return; } if (parse_args(argbulk, 1, 1, argv, 0) < 0) return; dur = strtoul(argv[0], 0, 0); if (dur < 1 || dur > 0xFFFF) { printf("ERROR: argument out of range\n"); return; } melody_buf_tailptr->tone = 0; melody_buf_tailptr->vol = 0; melody_buf_tailptr->dur = dur; melody_buf_tailptr++; }