FreeCalypso > hg > fc-tourmaline
annotate src/cs/services/buzm/buzm_process.c @ 303:f76436d19a7a default tip
!GPRS config: fix long-standing AT+COPS chance hanging bug
There has been a long-standing bug in FreeCalypso going back years:
sometimes in the AT command bring-up sequence of an ACI-only MS,
the AT+COPS command would produce only a power scan followed by
cessation of protocol stack activity (only L1 ADC traces), instead
of the expected network search sequence. This behaviour was seen
in different FC firmware versions going back to Citrine, and seemed
to follow some law of chance, not reliably repeatable.
This bug has been tracked down and found to be specific to !GPRS
configuration, stemming from our TCS2/TCS3 hybrid and reconstruction
of !GPRS support that was bitrotten in TCS3.2/LoCosto version.
ACI module psa_mms.c, needed only for !GPRS, was missing in the TCS3
version and had to be pulled from TCS2 - but as it turns out,
there is a new field in the MMR_REG_REQ primitive that needs to be
set correctly, and that psa_mms.c module is the place where this
initialization needed to be added.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 08 Jun 2023 08:23:37 +0000 |
parents | 8dfdf88d632f |
children |
rev | line source |
---|---|
297
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we are going to implement the main process functions |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * for BUZM. |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include "buzm/buzm_env.h" |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include "buzm/buzm_func_i.h" |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include "rv/rv_general.h" |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include "rvf/rvf_api.h" |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "rvm/rvm_use_id_list.h" |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "ffs/ffs_api.h" |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "main/sys_types.h" |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "buzzer/pwt.h" |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 static void stop_current_melody(void) |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 PWT_stop_tone(); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 rvf_stop_timer(BUZM_TIMER); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 PWT_block_off(); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 ffs_close(buzm_env->ffs_fd); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 buzm_env->melody_running = FALSE; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 } |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 void buzm_process_start_req(struct buzm_start_msg *msg) |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 T_FFS_SIZE rdsize; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 /* stop any previous melody first */ |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (buzm_env->melody_running) { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 stop_current_melody(); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 rvf_send_trace("Melody play interrupted by new melody start",43, |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_MEDIUM, |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 BUZM_USE_ID); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 rdsize = ffs_read(msg->fd, (void *) buzm_env->chunk_buf, |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 sizeof(struct melody_entry) * MELODY_CHUNK_SIZE); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 if (rdsize < sizeof(struct melody_entry)) { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 ffs_close(msg->fd); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 rvf_send_trace("Error: invalid melody file", 26, NULL_PARAM, |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 RV_TRACE_LEVEL_ERROR, BUZM_USE_ID); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 return; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 } |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 /* start this melody */ |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 rvf_send_trace("Starting PWT melody play", 24, NULL_PARAM, |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 RV_TRACE_LEVEL_DEBUG_LOW, BUZM_USE_ID); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 PWT_block_on(); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 buzm_env->melody_running = TRUE; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 buzm_env->ffs_fd = msg->fd; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 buzm_env->play_volume = msg->volume; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 buzm_env->loop_mode = msg->loop; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 buzm_env->chunk_play_ptr = 0; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 buzm_env->chunk_end_ptr = rdsize / sizeof(struct melody_entry); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 buzm_env->melody_end_flag = FALSE; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 rvf_start_timer(BUZM_TIMER, 1, FALSE); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 } |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 void buzm_process_stop_req(struct buzm_stop_msg *msg) |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 if (buzm_env->melody_running) { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 stop_current_melody(); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 rvf_send_trace("Melody play stopped by command", 30, |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 BUZM_USE_ID); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 } else { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 rvf_send_trace("Redundant melody play stop command", 34, |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_MEDIUM, |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 BUZM_USE_ID); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 } |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 } |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 static void melody_loop_restart(void) |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 T_FFS_SIZE rdsize; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 ffs_seek(buzm_env->ffs_fd, 0, FFS_SEEK_SET); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 rdsize = ffs_read(buzm_env->ffs_fd, (void *) buzm_env->chunk_buf, |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 sizeof(struct melody_entry) * MELODY_CHUNK_SIZE); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 if (rdsize < sizeof(struct melody_entry)) { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 rvf_send_trace("Bad melody file on loop restart!", 32, |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 NULL_PARAM, RV_TRACE_LEVEL_ERROR, BUZM_USE_ID); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 PWT_block_off(); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 ffs_close(buzm_env->ffs_fd); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 buzm_env->melody_running = FALSE; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 return; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 } |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 buzm_env->chunk_play_ptr = 0; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 buzm_env->chunk_end_ptr = rdsize / sizeof(struct melody_entry); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 buzm_env->melody_end_flag = FALSE; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 rvf_start_timer(BUZM_TIMER, 1, FALSE); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 } |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 static void melody_normal_finish(void) |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 PWT_block_off(); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 ffs_close(buzm_env->ffs_fd); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 buzm_env->melody_running = FALSE; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 rvf_send_trace("Melody play finished", 20, NULL_PARAM, |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 RV_TRACE_LEVEL_DEBUG_LOW, BUZM_USE_ID); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 } |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 static void melody_end_process(void) |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 if (buzm_env->loop_mode) |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 melody_loop_restart(); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 else |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 melody_normal_finish(); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 } |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 void buzm_handle_timer(void) |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 struct melody_entry *curnote; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 UINT8 pwt_vol; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 T_FFS_SIZE rdsize; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 /* weed out any spurious timer hits */ |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 if (!buzm_env->melody_running) |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 return; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 /* real end of previous note or rest */ |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 PWT_stop_tone(); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 if (buzm_env->melody_end_flag) { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 melody_end_process(); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 return; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 } |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 curnote = buzm_env->chunk_buf + buzm_env->chunk_play_ptr; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 if (curnote->note_volume) { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 pwt_vol = ((buzm_env->play_volume * curnote->note_volume + 63) |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 >> 6) - 1; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 PWT_play_tone(curnote->pwt_note, pwt_vol); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 } |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 rvf_start_timer(BUZM_TIMER, curnote->duration, FALSE); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 buzm_env->chunk_play_ptr++; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 if (buzm_env->chunk_play_ptr < buzm_env->chunk_end_ptr) |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 return; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 /* do we have more? */ |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 rdsize = ffs_read(buzm_env->ffs_fd, (void *) buzm_env->chunk_buf, |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 sizeof(struct melody_entry) * MELODY_CHUNK_SIZE); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 if (rdsize < sizeof(struct melody_entry)) |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 buzm_env->melody_end_flag = TRUE; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 else { |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 buzm_env->chunk_play_ptr = 0; |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 buzm_env->chunk_end_ptr = rdsize / sizeof(struct melody_entry); |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 } |
8dfdf88d632f
BUZM SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 } |