FreeCalypso > hg > freecalypso-tools
annotate target-utils/buzplayer/melentry.c @ 495:06ad5e30e8d0
target-utils: wait_ARM_cycles() changed to 4 cycles per loop
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 25 May 2019 18:51:19 +0000 |
parents | eb5960dc258c |
children | 9092ff68e37d |
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; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 void |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 melody_init() |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 { |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 melody_buf_tailptr = melody_buf_start; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 } |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 void |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 melody_entry(argbulk) |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 char *argbulk; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 { |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 char *argv[3]; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 u32 tone, dur; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 if (parse_args(argbulk, 2, 2, argv, 0) < 0) |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 return; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 tone = strtoul(argv[0], 0, 0); |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 dur = strtoul(argv[1], 0, 0); |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 if (tone > 255 || dur < 1 || dur > 0xFFFF) { |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 printf("ERROR: argument(s) out of range\n"); |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 return; |
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 melody_buf_tailptr->tone = tone; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 melody_buf_tailptr->dur = dur; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 melody_buf_tailptr++; |
eb5960dc258c
buzplayer: melody entry implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } |