FreeCalypso > hg > freecalypso-tools
annotate target-utils/buzplayer/melplay.c @ 999:30fad2b3afd2
doc/Flash-write-protection: document flash lock-state retrieval
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 04 Dec 2023 20:40:50 +0000 |
parents | 158dd05fb9f9 |
children |
rev | line source |
---|---|
81
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include "types.h" |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include "melody.h" |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 extern struct melentry *melody_buf_start, *melody_buf_tailptr; |
824
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
5 extern int melody_mode; |
81
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #define ARMIO_LOAD_TIM (*(volatile u16 *) 0xFFFE4808) |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #define BUZZ_LIGHT_REG (*(volatile u16 *) 0xFFFE480E) |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
824
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
10 #define PWT_FRC_REG (*(volatile u8 *) 0xFFFE8800) |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
11 #define PWT_VCR_REG (*(volatile u8 *) 0xFFFE8801) |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
12 |
81
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 void |
824
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
14 melody_play_bu() |
81
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 { |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 struct melentry *p; |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 int count; |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 wait_for_tdma_frame(); |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 for (p = melody_buf_start; p < melody_buf_tailptr; p++) { |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 if (p->tone) { |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 ARMIO_LOAD_TIM = p->tone; |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 BUZZ_LIGHT_REG = 1; |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 } else |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 BUZZ_LIGHT_REG = 0; |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 for (count = p->dur; count; count--) |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 wait_for_tdma_frame(); |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 BUZZ_LIGHT_REG = 0; |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 } |
8a200d65c6a0
buzplayer: play implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 } |
824
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
31 |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
32 void |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
33 melody_play_pwt() |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
34 { |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
35 struct melentry *p; |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
36 int count; |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
37 |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
38 wait_for_tdma_frame(); |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
39 for (p = melody_buf_start; p < melody_buf_tailptr; p++) { |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
40 PWT_FRC_REG = p->tone; |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
41 PWT_VCR_REG = p->vol; |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
42 for (count = p->dur; count; count--) |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
43 wait_for_tdma_frame(); |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
44 PWT_VCR_REG = 0; |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
45 } |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
46 } |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
47 |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
48 void |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
49 melody_play() |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
50 { |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
51 switch (melody_mode) { |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
52 case 1: |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
53 melody_play_bu(); |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
54 return; |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
55 case 2: |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
56 melody_play_pwt(); |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
57 return; |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
58 default: |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
59 printf("ERROR: no melody entered\n"); |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
60 } |
158dd05fb9f9
buzplayer: implement PWT mode melody play
Mychaela Falconia <falcon@freecalypso.org>
parents:
81
diff
changeset
|
61 } |