diff -ur ScummVM-cvs20020910/scummvm/scumm/imuse.cpp ScummVM-cvs20020910+hack/scummvm/scumm/imuse.cpp
old
|
new
|
|
170 | 170 | int query_param(int param); |
171 | 171 | |
172 | 172 | int fade_vol(byte vol, int time); |
| 173 | bool is_fading_out(); |
173 | 174 | void sequencer_timer(); |
174 | 175 | }; |
175 | 176 | |
… |
… |
|
185 | 186 | |
186 | 187 | void initialize() { |
187 | 188 | active = false; |
188 | | } void on_timer(); |
| 189 | } |
| 190 | void on_timer(bool probe); |
| 191 | byte fading_to(); |
189 | 192 | }; |
190 | 193 | |
191 | 194 | struct SustainingNotes { |
… |
… |
|
1134 | 1137 | for (i = ARRAYSIZE(_volume_fader); i != 0; i--, vf++) { |
1135 | 1138 | if (vf->active) { |
1136 | 1139 | _active_volume_faders = true; |
1137 | | vf->on_timer(); |
| 1140 | vf->on_timer(false); |
1138 | 1141 | } |
1139 | 1142 | } |
1140 | 1143 | } |
1141 | 1144 | |
1142 | | void VolumeFader::on_timer() |
| 1145 | void VolumeFader::on_timer(bool probe) |
1143 | 1146 | { |
1144 | 1147 | byte newvol; |
1145 | 1148 | |
… |
… |
|
1152 | 1155 | } |
1153 | 1156 | |
1154 | 1157 | if (curvol != newvol) { |
| 1158 | curvol = newvol; |
1155 | 1159 | if (!newvol) { |
1156 | | player->clear(); |
| 1160 | if (!probe) |
| 1161 | player->clear(); |
1157 | 1162 | active = false; |
1158 | 1163 | return; |
1159 | 1164 | } |
1160 | | curvol = newvol; |
1161 | | player->set_vol(newvol); |
| 1165 | if (!probe) |
| 1166 | player->set_vol(newvol); |
1162 | 1167 | } |
1163 | 1168 | |
1164 | 1169 | if (!--num_steps) { |
… |
… |
|
1166 | 1171 | } |
1167 | 1172 | } |
1168 | 1173 | |
| 1174 | byte VolumeFader::fading_to() |
| 1175 | { |
| 1176 | byte newvol; |
| 1177 | byte orig_curvol; |
| 1178 | uint16 orig_speed_lo_counter, orig_num_steps; |
| 1179 | |
| 1180 | if (!active) |
| 1181 | return 127; |
| 1182 | |
| 1183 | // It would be so much easier to just store the fade-to volume in a |
| 1184 | // variable, but then we'd have to break savegame compatibility. So |
| 1185 | // instead we do a "dry run" fade. |
| 1186 | |
| 1187 | orig_speed_lo_counter = speed_lo_counter; |
| 1188 | orig_num_steps = num_steps; |
| 1189 | orig_curvol = curvol; |
| 1190 | |
| 1191 | while (active) |
| 1192 | on_timer(true); |
| 1193 | |
| 1194 | active = true; |
| 1195 | newvol = curvol; |
| 1196 | |
| 1197 | speed_lo_counter = orig_speed_lo_counter; |
| 1198 | num_steps = orig_num_steps; |
| 1199 | curvol = orig_curvol; |
| 1200 | |
| 1201 | return newvol; |
| 1202 | } |
| 1203 | |
1169 | 1204 | int IMuseInternal::get_sound_status(int sound) |
1170 | 1205 | { |
1171 | 1206 | int i; |
1172 | 1207 | Player *player; |
1173 | 1208 | |
1174 | 1209 | for (i = ARRAYSIZE(_players), player = _players; i != 0; i--, player++) { |
1175 | | if (player->_active && player->_id == (uint16)sound) |
| 1210 | if (player->_active && player->_id == (uint16)sound) { |
| 1211 | // Assume that anyone asking for the sound status is |
| 1212 | // really asking "is it ok if I start playing this |
| 1213 | // sound now?" So if the sound is about to fade out, |
| 1214 | // shut it down and pretend it wasn't playing. |
| 1215 | if (player->is_fading_out()) { |
| 1216 | player->clear(); |
| 1217 | continue; |
| 1218 | } |
1176 | 1219 | return 1; |
| 1220 | } |
1177 | 1221 | } |
1178 | 1222 | return get_queue_sound_status(sound); |
1179 | 1223 | } |
… |
… |
|
1781 | 1825 | return 0; |
1782 | 1826 | } |
1783 | 1827 | |
| 1828 | bool Player::is_fading_out() |
| 1829 | { |
| 1830 | VolumeFader *vf = _se->_volume_fader; |
| 1831 | int i; |
| 1832 | |
| 1833 | for (i = 0; i < 8; i++, vf++) { |
| 1834 | if (vf->active && vf->direction < 0 && vf->player == this && vf->fading_to() == 0) |
| 1835 | return true; |
| 1836 | } |
| 1837 | return false; |
| 1838 | } |
| 1839 | |
1784 | 1840 | void Player::clear() |
1785 | 1841 | { |
1786 | 1842 | uninit_seq(); |