FreeCalypso > hg > freecalypso-tools
annotate target-utils/buzplayer/melentry.c @ 927:4e243402f453
rvinterf/lowlevel: use libprint for backslash-escape output
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 23 May 2023 03:59:42 +0000 |
parents | 9092ff68e37d |
children |
rev | line source |
---|---|
80
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include <sys/types.h> |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include <ctype.h> |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 #include <stdlib.h> |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 #include "types.h" |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include "melody.h" |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 extern struct melentry *melody_buf_start, *melody_buf_tailptr; |
823
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
8 extern int melody_mode; |
80
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 void |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 melody_init() |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 { |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 melody_buf_tailptr = melody_buf_start; |
823
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
14 melody_mode = 1; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
15 pwt_off(); |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
16 } |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
17 |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
18 void |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
19 melody_init_pwt() |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
20 { |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
21 melody_buf_tailptr = melody_buf_start; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
22 melody_mode = 2; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
23 pwt_on(); |
80
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 } |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 void |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 melody_entry(argbulk) |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 char *argbulk; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 { |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 char *argv[3]; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 u32 tone, dur; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 |
823
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
33 if (melody_mode != 1) { |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
34 printf("ERROR: wrong mode for melody entry\n"); |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
35 return; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
36 } |
80
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 if (parse_args(argbulk, 2, 2, argv, 0) < 0) |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 return; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 tone = strtoul(argv[0], 0, 0); |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 dur = strtoul(argv[1], 0, 0); |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 if (tone > 255 || dur < 1 || dur > 0xFFFF) { |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 printf("ERROR: argument(s) out of range\n"); |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 return; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 } |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 melody_buf_tailptr->tone = tone; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 melody_buf_tailptr->dur = dur; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 melody_buf_tailptr++; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 } |
823
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
49 |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
50 void |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
51 pwt_entry_note(argbulk) |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
52 char *argbulk; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
53 { |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
54 char *argv[4]; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
55 u32 tone, vol, dur; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
56 |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
57 if (melody_mode != 2) { |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
58 printf("ERROR: wrong mode for melody entry\n"); |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
59 return; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
60 } |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
61 if (parse_args(argbulk, 3, 3, argv, 0) < 0) |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
62 return; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
63 tone = strtoul(argv[0], 0, 0); |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
64 vol = strtoul(argv[1], 0, 0); |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
65 dur = strtoul(argv[2], 0, 0); |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
66 if (tone > 47 || vol > 63 || dur < 1 || dur > 0xFFFF) { |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
67 printf("ERROR: argument(s) out of range\n"); |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
68 return; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
69 } |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
70 melody_buf_tailptr->tone = tone; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
71 melody_buf_tailptr->vol = (vol << 1) | 1; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
72 melody_buf_tailptr->dur = dur; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
73 melody_buf_tailptr++; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
74 } |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
75 |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
76 void |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
77 pwt_entry_rest(argbulk) |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
78 char *argbulk; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
79 { |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
80 char *argv[2]; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
81 u32 dur; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
82 |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
83 if (melody_mode != 2) { |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
84 printf("ERROR: wrong mode for melody entry\n"); |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
85 return; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
86 } |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
87 if (parse_args(argbulk, 1, 1, argv, 0) < 0) |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
88 return; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
89 dur = strtoul(argv[0], 0, 0); |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
90 if (dur < 1 || dur > 0xFFFF) { |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
91 printf("ERROR: argument out of range\n"); |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
92 return; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
93 } |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
94 melody_buf_tailptr->tone = 0; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
95 melody_buf_tailptr->vol = 0; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
96 melody_buf_tailptr->dur = dur; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
97 melody_buf_tailptr++; |
9092ff68e37d
buzplayer: implement PWT mode melody entry
Mychaela Falconia <falcon@freecalypso.org>
parents:
80
diff
changeset
|
98 } |