SCI: Turned SfxState into a proper class (i.e., convert the sfx_ funcs to member methods)
svn-id: r40973
This commit is contained in:
parent
56b1eb7d09
commit
d3bd7b622c
6 changed files with 283 additions and 305 deletions
|
@ -220,7 +220,7 @@ int game_init_sound(EngineState *s, int sound_flags) {
|
||||||
sound_flags |= SFX_STATE_FLAG_MULTIPLAY;
|
sound_flags |= SFX_STATE_FLAG_MULTIPLAY;
|
||||||
|
|
||||||
s->sfx_init_flags = sound_flags;
|
s->sfx_init_flags = sound_flags;
|
||||||
sfx_init(&s->_sound, s->resmgr, sound_flags);
|
s->_sound.sfx_init(s->resmgr, sound_flags);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -593,7 +593,7 @@ int game_exit(EngineState *s) {
|
||||||
s->_executionStack.clear();
|
s->_executionStack.clear();
|
||||||
|
|
||||||
if (!s->successor) {
|
if (!s->successor) {
|
||||||
sfx_exit(&s->_sound);
|
s->_sound.sfx_exit();
|
||||||
// Reinit because some other code depends on having a valid state
|
// Reinit because some other code depends on having a valid state
|
||||||
game_init_sound(s, SFX_STATE_FLAG_NOSOUND);
|
game_init_sound(s, SFX_STATE_FLAG_NOSOUND);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ static void script_set_priority(EngineState *s, reg_t obj, int priority) {
|
||||||
flags &= ~SCI1_SOUND_FLAG_SCRIPTED_PRI;
|
flags &= ~SCI1_SOUND_FLAG_SCRIPTED_PRI;
|
||||||
} else flags |= SCI1_SOUND_FLAG_SCRIPTED_PRI;
|
} else flags |= SCI1_SOUND_FLAG_SCRIPTED_PRI;
|
||||||
|
|
||||||
sfx_song_renice(&s->_sound, FROBNICATE_HANDLE(obj), priority);
|
s->_sound.sfx_song_renice(FROBNICATE_HANDLE(obj), priority);
|
||||||
PUT_SEL32V(obj, flags, flags);
|
PUT_SEL32V(obj, flags, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their
|
||||||
return;
|
return;
|
||||||
/* SCI01 and later explicitly poll for everything */
|
/* SCI01 and later explicitly poll for everything */
|
||||||
|
|
||||||
while ((result = sfx_poll(&s->_sound, &handle, &cue))) {
|
while ((result = s->_sound.sfx_poll(&handle, &cue))) {
|
||||||
reg_t obj = DEFROBNICATE_HANDLE(handle);
|
reg_t obj = DEFROBNICATE_HANDLE(handle);
|
||||||
if (!is_object(s, obj)) {
|
if (!is_object(s, obj)) {
|
||||||
warning("Non-object %04x:%04x received sound signal (%d/%d)", PRINT_REG(obj), result, cue);
|
warning("Non-object %04x:%04x received sound signal (%d/%d)", PRINT_REG(obj), result, cue);
|
||||||
|
@ -272,7 +272,7 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
case _K_SCI0_SOUND_INIT_HANDLE:
|
case _K_SCI0_SOUND_INIT_HANDLE:
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sciprintf("Initializing song number %d\n", GET_SEL32V(obj, number));
|
sciprintf("Initializing song number %d\n", GET_SEL32V(obj, number));
|
||||||
SCRIPT_ASSERT_ZERO(sfx_add_song(&s->_sound,
|
SCRIPT_ASSERT_ZERO(s->_sound.sfx_add_song(
|
||||||
build_iterator(s, number,
|
build_iterator(s, number,
|
||||||
SCI_SONG_ITERATOR_TYPE_SCI0,
|
SCI_SONG_ITERATOR_TYPE_SCI0,
|
||||||
handle),
|
handle),
|
||||||
|
@ -284,10 +284,8 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
|
|
||||||
case _K_SCI0_SOUND_PLAY_HANDLE:
|
case _K_SCI0_SOUND_PLAY_HANDLE:
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_PLAYING);
|
||||||
handle, SOUND_STATUS_PLAYING);
|
s->_sound.sfx_song_set_loops(handle, GET_SEL32V(obj, loop));
|
||||||
sfx_song_set_loops(&s->_sound,
|
|
||||||
handle, GET_SEL32V(obj, loop));
|
|
||||||
PUT_SEL32V(obj, state, _K_SOUND_STATUS_PLAYING);
|
PUT_SEL32V(obj, state, _K_SOUND_STATUS_PLAYING);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -297,31 +295,28 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
|
|
||||||
case _K_SCI0_SOUND_DISPOSE_HANDLE:
|
case _K_SCI0_SOUND_DISPOSE_HANDLE:
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_remove_song(&s->_sound, handle);
|
s->_sound.sfx_remove_song(handle);
|
||||||
}
|
}
|
||||||
PUT_SEL32V(obj, handle, 0x0000);
|
PUT_SEL32V(obj, handle, 0x0000);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _K_SCI0_SOUND_STOP_HANDLE:
|
case _K_SCI0_SOUND_STOP_HANDLE:
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
||||||
handle, SOUND_STATUS_STOPPED);
|
|
||||||
PUT_SEL32V(obj, state, SOUND_STATUS_STOPPED);
|
PUT_SEL32V(obj, state, SOUND_STATUS_STOPPED);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _K_SCI0_SOUND_SUSPEND_HANDLE:
|
case _K_SCI0_SOUND_SUSPEND_HANDLE:
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_SUSPENDED);
|
||||||
handle, SOUND_STATUS_SUSPENDED);
|
|
||||||
PUT_SEL32V(obj, state, SOUND_STATUS_SUSPENDED);
|
PUT_SEL32V(obj, state, SOUND_STATUS_SUSPENDED);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _K_SCI0_SOUND_RESUME_HANDLE:
|
case _K_SCI0_SOUND_RESUME_HANDLE:
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_PLAYING);
|
||||||
handle, SOUND_STATUS_PLAYING);
|
|
||||||
PUT_SEL32V(obj, state, SOUND_STATUS_PLAYING);
|
PUT_SEL32V(obj, state, SOUND_STATUS_PLAYING);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -345,16 +340,15 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
int vol = SKPV_OR_ALT(1, -1);
|
int vol = SKPV_OR_ALT(1, -1);
|
||||||
|
|
||||||
if (vol != -1)
|
if (vol != -1)
|
||||||
sfx_set_volume(&s->_sound, vol << 0xf);
|
s->_sound.sfx_set_volume(vol << 0xf);
|
||||||
else
|
else
|
||||||
s->r_acc = make_reg(0, sfx_get_volume(&s->_sound) >> 0xf);
|
s->r_acc = make_reg(0, s->_sound.sfx_get_volume() >> 0xf);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _K_SCI0_SOUND_UPDATE_VOL_PRI:
|
case _K_SCI0_SOUND_UPDATE_VOL_PRI:
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_loops(&s->_sound,
|
s->_sound.sfx_song_set_loops(handle, GET_SEL32V(obj, loop));
|
||||||
handle, GET_SEL32V(obj, loop));
|
|
||||||
script_set_priority(s, obj, GET_SEL32V(obj, pri));
|
script_set_priority(s, obj, GET_SEL32V(obj, pri));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -364,8 +358,7 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
/* FIXME: The next couple of lines actually STOP the handle, rather
|
/* FIXME: The next couple of lines actually STOP the handle, rather
|
||||||
** than fading it! */
|
** than fading it! */
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
||||||
handle, SOUND_STATUS_STOPPED);
|
|
||||||
PUT_SEL32V(obj, state, SOUND_STATUS_STOPPED);
|
PUT_SEL32V(obj, state, SOUND_STATUS_STOPPED);
|
||||||
PUT_SEL32V(obj, signal, -1);
|
PUT_SEL32V(obj, signal, -1);
|
||||||
}
|
}
|
||||||
|
@ -376,7 +369,7 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case _K_SCI0_SOUND_PLAY_NEXT:
|
case _K_SCI0_SOUND_PLAY_NEXT:
|
||||||
/* sfx_all_stop(&s->_sound);*/
|
/* s->_sound.sfx_all_stop();*/
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -467,9 +460,9 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
int vol = SKPV_OR_ALT(1, -1);
|
int vol = SKPV_OR_ALT(1, -1);
|
||||||
|
|
||||||
if (vol != -1)
|
if (vol != -1)
|
||||||
sfx_set_volume(&s->_sound, vol << 0xf);
|
s->_sound.sfx_set_volume(vol << 0xf);
|
||||||
else
|
else
|
||||||
s->r_acc = make_reg(0, sfx_get_volume(&s->_sound) >> 0xf);
|
s->r_acc = make_reg(0, s->_sound.sfx_get_volume() >> 0xf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _K_SCI01_SOUND_MUTE_SOUND : {
|
case _K_SCI01_SOUND_MUTE_SOUND : {
|
||||||
|
@ -498,12 +491,9 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
RESTORE_BEHAVIOR rb = (RESTORE_BEHAVIOR) UKPV(2); /* Too lazy to look up a default value for this */
|
RESTORE_BEHAVIOR rb = (RESTORE_BEHAVIOR) UKPV(2); /* Too lazy to look up a default value for this */
|
||||||
|
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_PLAYING);
|
||||||
handle, SOUND_STATUS_PLAYING);
|
s->_sound.sfx_song_set_loops(handle, looping);
|
||||||
sfx_song_set_loops(&s->_sound,
|
s->_sound.sfx_song_renice(handle, pri);
|
||||||
handle, looping);
|
|
||||||
sfx_song_renice(&s->_sound,
|
|
||||||
handle, pri);
|
|
||||||
song_lib_set_restore_behavior(s->_sound._songlib, handle, rb);
|
song_lib_set_restore_behavior(s->_sound._songlib, handle, rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,7 +506,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
|
|
||||||
if (obj.segment && (s->resmgr->testResource(kResourceTypeSound, number))) {
|
if (obj.segment && (s->resmgr->testResource(kResourceTypeSound, number))) {
|
||||||
sciprintf("Initializing song number %d\n", number);
|
sciprintf("Initializing song number %d\n", number);
|
||||||
SCRIPT_ASSERT_ZERO(sfx_add_song(&s->_sound,
|
SCRIPT_ASSERT_ZERO(s->_sound.sfx_add_song(
|
||||||
build_iterator(s, number,
|
build_iterator(s, number,
|
||||||
SCI_SONG_ITERATOR_TYPE_SCI1,
|
SCI_SONG_ITERATOR_TYPE_SCI1,
|
||||||
handle),
|
handle),
|
||||||
|
@ -528,9 +518,8 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
}
|
}
|
||||||
case _K_SCI01_SOUND_DISPOSE_HANDLE : {
|
case _K_SCI01_SOUND_DISPOSE_HANDLE : {
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
||||||
handle, SOUND_STATUS_STOPPED);
|
s->_sound.sfx_remove_song(handle);
|
||||||
sfx_remove_song(&s->_sound, handle);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -546,9 +535,8 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
//int vol = GET_SEL32V(obj, vol);
|
//int vol = GET_SEL32V(obj, vol);
|
||||||
int pri = GET_SEL32V(obj, pri);
|
int pri = GET_SEL32V(obj, pri);
|
||||||
|
|
||||||
sfx_song_set_loops(&s->_sound,
|
s->_sound.sfx_song_set_loops(handle, looping);
|
||||||
handle, looping);
|
s->_sound.sfx_song_renice(handle, pri);
|
||||||
sfx_song_renice(&s->_sound, handle, pri);
|
|
||||||
|
|
||||||
SCIkdebug(SCIkSOUND, "[sound01-update-handle] -- CUE %04x:%04x");
|
SCIkdebug(SCIkSOUND, "[sound01-update-handle] -- CUE %04x:%04x");
|
||||||
|
|
||||||
|
@ -562,8 +550,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
case _K_SCI01_SOUND_STOP_HANDLE : {
|
case _K_SCI01_SOUND_STOP_HANDLE : {
|
||||||
PUT_SEL32V(obj, signal, -1);
|
PUT_SEL32V(obj, signal, -1);
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
||||||
handle, SOUND_STATUS_STOPPED);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -573,8 +560,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
SOUND_STATUS_SUSPENDED : SOUND_STATUS_PLAYING;
|
SOUND_STATUS_SUSPENDED : SOUND_STATUS_PLAYING;
|
||||||
|
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, setstate);
|
||||||
handle, setstate);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -585,8 +571,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
/* FIXME: The next couple of lines actually STOP the song right away */
|
/* FIXME: The next couple of lines actually STOP the song right away */
|
||||||
PUT_SEL32V(obj, signal, -1);
|
PUT_SEL32V(obj, signal, -1);
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
||||||
handle, SOUND_STATUS_STOPPED);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -599,7 +584,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
int cue = 0;
|
int cue = 0;
|
||||||
|
|
||||||
while (result == SI_LOOP)
|
while (result == SI_LOOP)
|
||||||
result = sfx_poll_specific(&s->_sound, handle, &cue);
|
result = s->_sound.sfx_poll_specific(handle, &cue);
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
|
|
||||||
|
@ -645,7 +630,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
/* } */
|
/* } */
|
||||||
/* break; */
|
/* break; */
|
||||||
/* case 0xFF: /\* May be unnecessary *\/ */
|
/* case 0xFF: /\* May be unnecessary *\/ */
|
||||||
/* sfx_song_set_status(&s->_sound, */
|
/* s->_sound.sfx_song_set_status(*/
|
||||||
/* handle, SOUND_STATUS_STOPPED); */
|
/* handle, SOUND_STATUS_STOPPED); */
|
||||||
/* break; */
|
/* break; */
|
||||||
/* default : */
|
/* default : */
|
||||||
|
@ -673,7 +658,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
int controller = UKPV(3);
|
int controller = UKPV(3);
|
||||||
int param = UKPV(4);
|
int param = UKPV(4);
|
||||||
|
|
||||||
sfx_send_midi(&s->_sound, handle,
|
s->_sound.sfx_send_midi(handle,
|
||||||
channel, midiCmd, controller, param);
|
channel, midiCmd, controller, param);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -821,9 +806,8 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
song_t *song = song_lib_find(s->_sound._songlib, handle);
|
song_t *song = song_lib_find(s->_sound._songlib, handle);
|
||||||
|
|
||||||
if (GET_SEL32V(obj, nodePtr) && (song && number != song->resource_num)) {
|
if (GET_SEL32V(obj, nodePtr) && (song && number != song->resource_num)) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
||||||
handle, SOUND_STATUS_STOPPED);
|
s->_sound.sfx_remove_song(handle);
|
||||||
sfx_remove_song(&s->_sound, handle);
|
|
||||||
PUT_SEL32(obj, nodePtr, NULL_REG);
|
PUT_SEL32(obj, nodePtr, NULL_REG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -834,7 +818,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sciprintf("Initializing song number %d\n", number);
|
sciprintf("Initializing song number %d\n", number);
|
||||||
SCRIPT_ASSERT_ZERO(sfx_add_song(&s->_sound,
|
SCRIPT_ASSERT_ZERO(s->_sound.sfx_add_song(
|
||||||
build_iterator(s, number,
|
build_iterator(s, number,
|
||||||
SCI_SONG_ITERATOR_TYPE_SCI1,
|
SCI_SONG_ITERATOR_TYPE_SCI1,
|
||||||
handle),
|
handle),
|
||||||
|
@ -844,12 +828,9 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_PLAYING);
|
||||||
handle, SOUND_STATUS_PLAYING);
|
s->_sound.sfx_song_set_loops(handle, looping);
|
||||||
sfx_song_set_loops(&s->_sound,
|
s->_sound.sfx_song_renice(handle, pri);
|
||||||
handle, looping);
|
|
||||||
sfx_song_renice(&s->_sound,
|
|
||||||
handle, pri);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -860,14 +841,13 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
//int pri = GET_SEL32V(obj, pri);
|
//int pri = GET_SEL32V(obj, pri);
|
||||||
|
|
||||||
if (GET_SEL32V(obj, nodePtr)) {
|
if (GET_SEL32V(obj, nodePtr)) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
||||||
handle, SOUND_STATUS_STOPPED);
|
s->_sound.sfx_remove_song(handle);
|
||||||
sfx_remove_song(&s->_sound, handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.segment && (s->resmgr->testResource(kResourceTypeSound, number))) {
|
if (obj.segment && (s->resmgr->testResource(kResourceTypeSound, number))) {
|
||||||
sciprintf("Initializing song number %d\n", number);
|
sciprintf("Initializing song number %d\n", number);
|
||||||
SCRIPT_ASSERT_ZERO(sfx_add_song(&s->_sound,
|
SCRIPT_ASSERT_ZERO(s->_sound.sfx_add_song(
|
||||||
build_iterator(s, number,
|
build_iterator(s, number,
|
||||||
SCI_SONG_ITERATOR_TYPE_SCI1,
|
SCI_SONG_ITERATOR_TYPE_SCI1,
|
||||||
handle),
|
handle),
|
||||||
|
@ -879,17 +859,15 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
}
|
}
|
||||||
case _K_SCI1_SOUND_DISPOSE_HANDLE : {
|
case _K_SCI1_SOUND_DISPOSE_HANDLE : {
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
||||||
handle, SOUND_STATUS_STOPPED);
|
s->_sound.sfx_remove_song(handle);
|
||||||
sfx_remove_song(&s->_sound, handle);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _K_SCI1_SOUND_STOP_HANDLE : {
|
case _K_SCI1_SOUND_STOP_HANDLE : {
|
||||||
PUT_SEL32V(obj, signal, -1);
|
PUT_SEL32V(obj, signal, -1);
|
||||||
if (obj.segment) {
|
if (obj.segment) {
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
||||||
handle, SOUND_STATUS_STOPPED);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -906,9 +884,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
FADE_ACTION_FADE_AND_STOP :
|
FADE_ACTION_FADE_AND_STOP :
|
||||||
FADE_ACTION_FADE_AND_CONT;
|
FADE_ACTION_FADE_AND_CONT;
|
||||||
|
|
||||||
sfx_song_set_fade(&s->_sound,
|
s->_sound.sfx_song_set_fade(handle, &fade);
|
||||||
handle,
|
|
||||||
&fade);
|
|
||||||
|
|
||||||
/* FIXME: The next couple of lines actually STOP the handle, rather
|
/* FIXME: The next couple of lines actually STOP the handle, rather
|
||||||
** than fading it! */
|
** than fading it! */
|
||||||
|
@ -916,8 +892,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
PUT_SEL32V(obj, signal, -1);
|
PUT_SEL32V(obj, signal, -1);
|
||||||
PUT_SEL32V(obj, nodePtr, 0);
|
PUT_SEL32V(obj, nodePtr, 0);
|
||||||
PUT_SEL32V(obj, handle, 0);
|
PUT_SEL32V(obj, handle, 0);
|
||||||
sfx_song_set_status(&s->_sound,
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
||||||
handle, SOUND_STATUS_STOPPED);
|
|
||||||
} else {
|
} else {
|
||||||
// FIXME: Support fade-and-continue. For now, send signal right away.
|
// FIXME: Support fade-and-continue. For now, send signal right away.
|
||||||
PUT_SEL32V(obj, signal, -1);
|
PUT_SEL32V(obj, signal, -1);
|
||||||
|
@ -928,8 +903,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
case _K_SCI1_SOUND_HOLD_HANDLE : {
|
case _K_SCI1_SOUND_HOLD_HANDLE : {
|
||||||
int value = SKPV(2);
|
int value = SKPV(2);
|
||||||
|
|
||||||
sfx_song_set_hold(&s->_sound,
|
s->_sound.sfx_song_set_hold(handle, value);
|
||||||
handle, value);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _K_SCI1_SOUND_UNUSED2 : {
|
case _K_SCI1_SOUND_UNUSED2 : {
|
||||||
|
@ -956,7 +930,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
int cue = 0;
|
int cue = 0;
|
||||||
|
|
||||||
while (result == SI_LOOP)
|
while (result == SI_LOOP)
|
||||||
result = sfx_poll_specific(&s->_sound, handle, &cue);
|
result = s->_sound.sfx_poll_specific(handle, &cue);
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
|
|
||||||
|
@ -986,7 +960,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case _K_SCI1_SOUND_MIDI_SEND : {
|
case _K_SCI1_SOUND_MIDI_SEND : {
|
||||||
sfx_send_midi(&s->_sound, handle,
|
s->_sound.sfx_send_midi(handle,
|
||||||
UKPV(2), UKPV(3), UKPV(4), UKPV(5));
|
UKPV(2), UKPV(3), UKPV(4), UKPV(5));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -720,7 +720,7 @@ static void reconstruct_sounds(EngineState *s) {
|
||||||
oldstatus = seeker->status;
|
oldstatus = seeker->status;
|
||||||
seeker->status = SOUND_STATUS_STOPPED;
|
seeker->status = SOUND_STATUS_STOPPED;
|
||||||
seeker->it = ff;
|
seeker->it = ff;
|
||||||
sfx_song_set_status(&s->_sound, seeker->handle, oldstatus);
|
s->_sound.sfx_song_set_status(seeker->handle, oldstatus);
|
||||||
seeker = seeker->next;
|
seeker = seeker->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -770,7 +770,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
|
||||||
|
|
||||||
retval->saveLoadWithSerializer(ser); // FIXME: Error handling?
|
retval->saveLoadWithSerializer(ser); // FIXME: Error handling?
|
||||||
|
|
||||||
sfx_exit(&s->_sound);
|
s->_sound.sfx_exit();
|
||||||
|
|
||||||
// Set exec stack base to zero
|
// Set exec stack base to zero
|
||||||
retval->execution_stack_base = 0;
|
retval->execution_stack_base = 0;
|
||||||
|
@ -784,7 +784,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
|
||||||
retval->resmgr = s->resmgr;
|
retval->resmgr = s->resmgr;
|
||||||
|
|
||||||
temp = retval->_sound._songlib;
|
temp = retval->_sound._songlib;
|
||||||
sfx_init(&retval->_sound, retval->resmgr, s->sfx_init_flags);
|
retval->_sound.sfx_init(retval->resmgr, s->sfx_init_flags);
|
||||||
retval->sfx_init_flags = s->sfx_init_flags;
|
retval->sfx_init_flags = s->sfx_init_flags;
|
||||||
song_lib_free(retval->_sound._songlib);
|
song_lib_free(retval->_sound._songlib);
|
||||||
retval->_sound._songlib = temp;
|
retval->_sound._songlib = temp;
|
||||||
|
|
|
@ -2358,8 +2358,8 @@ static int c_sfx_remove(EngineState *s, const Common::Array<cmd_param_t> &cmdPar
|
||||||
int handle = FROBNICATE_HANDLE(id);
|
int handle = FROBNICATE_HANDLE(id);
|
||||||
|
|
||||||
if (id.segment) {
|
if (id.segment) {
|
||||||
sfx_song_set_status(&s->_sound, handle, SOUND_STATUS_STOPPED);
|
s->_sound.sfx_song_set_status(handle, SOUND_STATUS_STOPPED);
|
||||||
sfx_remove_song(&s->_sound, handle);
|
s->_sound.sfx_remove_song(handle);
|
||||||
PUT_SEL32V(id, signal, -1);
|
PUT_SEL32V(id, signal, -1);
|
||||||
PUT_SEL32V(id, nodePtr, 0);
|
PUT_SEL32V(id, nodePtr, 0);
|
||||||
PUT_SEL32V(id, handle, 0);
|
PUT_SEL32V(id, handle, 0);
|
||||||
|
@ -3257,7 +3257,7 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *
|
||||||
const char *commandstring;
|
const char *commandstring;
|
||||||
|
|
||||||
// Suspend music playing
|
// Suspend music playing
|
||||||
sfx_suspend(&s->_sound, 1);
|
s->_sound.sfx_suspend(true);
|
||||||
|
|
||||||
commandstring = _debug_get_input();
|
commandstring = _debug_get_input();
|
||||||
|
|
||||||
|
@ -3270,7 +3270,7 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *
|
||||||
sciprintf("\n");
|
sciprintf("\n");
|
||||||
|
|
||||||
// Resume music playing
|
// Resume music playing
|
||||||
sfx_suspend(&s->_sound, 0);
|
s->_sound.sfx_suspend(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -333,10 +333,10 @@ int sfx_get_player_polyphony() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _freeze_time(SfxState *self) {
|
void SfxState::freezeTime() {
|
||||||
/* Freezes the top song delay time */
|
/* Freezes the top song delay time */
|
||||||
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
||||||
song_t *song = self->_song;
|
song_t *song = _song;
|
||||||
|
|
||||||
while (song) {
|
while (song) {
|
||||||
song->_delay = song->_wakeupTime.frameDiff(ctime);
|
song->_delay = song->_wakeupTime.frameDiff(ctime);
|
||||||
|
@ -347,10 +347,10 @@ static void _freeze_time(SfxState *self) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _thaw_time(SfxState *self) {
|
void SfxState::thawTime() {
|
||||||
/* inverse of _freeze_time() */
|
/* inverse of freezeTime() */
|
||||||
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
||||||
song_t *song = self->_song;
|
song_t *song = _song;
|
||||||
|
|
||||||
while (song) {
|
while (song) {
|
||||||
song->_wakeupTime = ctime.addFrames(song->_delay);
|
song->_wakeupTime = ctime.addFrames(song->_delay);
|
||||||
|
@ -383,8 +383,8 @@ static void _dump_playing_list(SfxState *self, char *msg) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void _dump_songs(SfxState *self) {
|
|
||||||
#if 0
|
#if 0
|
||||||
|
static void _dump_songs(SfxState *self) {
|
||||||
song_t *song = self->_song;
|
song_t *song = self->_song;
|
||||||
|
|
||||||
fprintf(stderr, "Cue iterators:\n");
|
fprintf(stderr, "Cue iterators:\n");
|
||||||
|
@ -400,23 +400,23 @@ static void _dump_songs(SfxState *self) {
|
||||||
fprintf(stderr, "Audio iterator:\n");
|
fprintf(stderr, "Audio iterator:\n");
|
||||||
player->iterator_message(SongIterator::Message(0, SIMSG_PRINT(1)));
|
player->iterator_message(SongIterator::Message(0, SIMSG_PRINT(1)));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int is_playing(SfxState *self, song_t *song) {
|
bool SfxState::isPlaying(song_t *song) {
|
||||||
song_t *playing_song = self->_song;
|
song_t *playing_song = _song;
|
||||||
|
|
||||||
/* _dump_playing_list(self, "is-playing");*/
|
/* _dump_playing_list(this, "is-playing");*/
|
||||||
|
|
||||||
while (playing_song) {
|
while (playing_song) {
|
||||||
if (playing_song == song)
|
if (playing_song == song)
|
||||||
return 1;
|
return true;
|
||||||
playing_song = playing_song->next_playing;
|
playing_song = playing_song->next_playing;
|
||||||
}
|
}
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _sfx_set_song_status(SfxState *self, song_t *song, int status) {
|
void SfxState::setSongStatus(song_t *song, int status) {
|
||||||
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
@ -444,7 +444,7 @@ static void _sfx_set_song_status(SfxState *self, song_t *song, int status) {
|
||||||
song->_wakeupTime = ctime;
|
song->_wakeupTime = ctime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_playing(self, song))
|
if (isPlaying(song))
|
||||||
status = SOUND_STATUS_PLAYING;
|
status = SOUND_STATUS_PLAYING;
|
||||||
else
|
else
|
||||||
status = SOUND_STATUS_WAITING;
|
status = SOUND_STATUS_WAITING;
|
||||||
|
@ -460,11 +460,11 @@ static void _sfx_set_song_status(SfxState *self, song_t *song, int status) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update internal state iff only one song may be played */
|
/* Update internal state iff only one song may be played */
|
||||||
static void _update_single_song(SfxState *self) {
|
void SfxState::updateSingleSong() {
|
||||||
song_t *newsong = song_lib_find_active(self->_songlib);
|
song_t *newsong = song_lib_find_active(_songlib);
|
||||||
|
|
||||||
if (newsong != self->_song) {
|
if (newsong != _song) {
|
||||||
_freeze_time(self); /* Store song delay time */
|
freezeTime(); /* Store song delay time */
|
||||||
|
|
||||||
if (player)
|
if (player)
|
||||||
player->stop();
|
player->stop();
|
||||||
|
@ -475,25 +475,23 @@ static void _update_single_song(SfxState *self) {
|
||||||
|
|
||||||
/* Change song */
|
/* Change song */
|
||||||
if (newsong->status == SOUND_STATUS_WAITING)
|
if (newsong->status == SOUND_STATUS_WAITING)
|
||||||
_sfx_set_song_status(self, newsong,
|
setSongStatus(newsong, SOUND_STATUS_PLAYING);
|
||||||
SOUND_STATUS_PLAYING);
|
|
||||||
|
|
||||||
/* Change instrument mappings */
|
/* Change instrument mappings */
|
||||||
} else {
|
} else {
|
||||||
/* Turn off sound */
|
/* Turn off sound */
|
||||||
}
|
}
|
||||||
if (self->_song) {
|
if (_song) {
|
||||||
if (self->_song->status == SOUND_STATUS_PLAYING)
|
if (_song->status == SOUND_STATUS_PLAYING)
|
||||||
_sfx_set_song_status(self, newsong,
|
setSongStatus(newsong, SOUND_STATUS_WAITING);
|
||||||
SOUND_STATUS_WAITING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->_debug & SFX_DEBUG_SONGS) {
|
if (_debug & SFX_DEBUG_SONGS) {
|
||||||
sciprintf("[SFX] Changing active song:");
|
sciprintf("[SFX] Changing active song:");
|
||||||
if (!self->_song)
|
if (!_song)
|
||||||
sciprintf(" New song:");
|
sciprintf(" New song:");
|
||||||
else
|
else
|
||||||
sciprintf(" pausing %08lx, now playing", self->_song->handle);
|
sciprintf(" pausing %08lx, now playing", _song->handle);
|
||||||
|
|
||||||
if (newsong)
|
if (newsong)
|
||||||
sciprintf(" %08lx\n", newsong->handle);
|
sciprintf(" %08lx\n", newsong->handle);
|
||||||
|
@ -502,8 +500,8 @@ static void _update_single_song(SfxState *self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
self->_song = newsong;
|
_song = newsong;
|
||||||
_thaw_time(self); /* Recover song delay time */
|
thawTime(); /* Recover song delay time */
|
||||||
|
|
||||||
if (newsong && player) {
|
if (newsong && player) {
|
||||||
SongIterator *clonesong = newsong->it->clone(newsong->_delay);
|
SongIterator *clonesong = newsong->it->clone(newsong->_delay);
|
||||||
|
@ -514,17 +512,17 @@ static void _update_single_song(SfxState *self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void _update_multi_song(SfxState *self) {
|
void SfxState::updateMultiSong() {
|
||||||
song_t *oldfirst = self->_song;
|
song_t *oldfirst = _song;
|
||||||
song_t *oldseeker;
|
song_t *oldseeker;
|
||||||
song_t *newsong = song_lib_find_active(self->_songlib);
|
song_t *newsong = song_lib_find_active(_songlib);
|
||||||
song_t *newseeker;
|
song_t *newseeker;
|
||||||
song_t not_playing_anymore; /* Dummy object, referenced by
|
song_t not_playing_anymore; /* Dummy object, referenced by
|
||||||
** songs which are no longer
|
** songs which are no longer
|
||||||
** active. */
|
** active. */
|
||||||
|
|
||||||
/* _dump_playing_list(self, "before");*/
|
/* _dump_playing_list(this, "before");*/
|
||||||
_freeze_time(self); /* Store song delay time */
|
freezeTime(); /* Store song delay time */
|
||||||
|
|
||||||
if (!newsong)
|
if (!newsong)
|
||||||
return;
|
return;
|
||||||
|
@ -549,23 +547,21 @@ static void _update_multi_song(SfxState *self) {
|
||||||
for (newseeker = newsong; newseeker;
|
for (newseeker = newsong; newseeker;
|
||||||
newseeker = newseeker->next_playing) {
|
newseeker = newseeker->next_playing) {
|
||||||
newseeker->next_playing
|
newseeker->next_playing
|
||||||
= song_lib_find_next_active(self->_songlib,
|
= song_lib_find_next_active(_songlib, newseeker);
|
||||||
newseeker);
|
|
||||||
|
|
||||||
if (newseeker == newseeker->next_playing) { BREAKPOINT(); }
|
if (newseeker == newseeker->next_playing) { BREAKPOINT(); }
|
||||||
}
|
}
|
||||||
/* We now need to update the currently playing song list, because we're
|
/* We now need to update the currently playing song list, because we're
|
||||||
** going to use some functions that require this list to be in a sane
|
** going to use some functions that require this list to be in a sane
|
||||||
** state (particularly is_playing(), indirectly */
|
** state (particularly isPlaying(), indirectly */
|
||||||
self->_song = newsong;
|
_song = newsong;
|
||||||
|
|
||||||
/* Third, stop all old songs */
|
/* Third, stop all old songs */
|
||||||
for (oldseeker = oldfirst; oldseeker;
|
for (oldseeker = oldfirst; oldseeker;
|
||||||
oldseeker = oldseeker->next_stopping)
|
oldseeker = oldseeker->next_stopping)
|
||||||
if (oldseeker->next_playing == ¬_playing_anymore) {
|
if (oldseeker->next_playing == ¬_playing_anymore) {
|
||||||
_sfx_set_song_status(self, oldseeker,
|
setSongStatus(oldseeker, SOUND_STATUS_SUSPENDED);
|
||||||
SOUND_STATUS_SUSPENDED);
|
if (_debug & SFX_DEBUG_SONGS) {
|
||||||
if (self->_debug & SFX_DEBUG_SONGS) {
|
|
||||||
sciprintf("[SFX] Stopping song %lx\n", oldseeker->handle);
|
sciprintf("[SFX] Stopping song %lx\n", oldseeker->handle);
|
||||||
}
|
}
|
||||||
if (player && oldseeker->it)
|
if (player && oldseeker->it)
|
||||||
|
@ -575,27 +571,26 @@ static void _update_multi_song(SfxState *self) {
|
||||||
|
|
||||||
for (newseeker = newsong; newseeker; newseeker = newseeker->next_playing) {
|
for (newseeker = newsong; newseeker; newseeker = newseeker->next_playing) {
|
||||||
if (newseeker->status != SOUND_STATUS_PLAYING && player) {
|
if (newseeker->status != SOUND_STATUS_PLAYING && player) {
|
||||||
if (self->_debug & SFX_DEBUG_SONGS)
|
if (_debug & SFX_DEBUG_SONGS)
|
||||||
sciprintf("[SFX] Adding song %lx\n", newseeker->it->ID);
|
sciprintf("[SFX] Adding song %lx\n", newseeker->it->ID);
|
||||||
|
|
||||||
SongIterator *clonesong = newseeker->it->clone(newseeker->_delay);
|
SongIterator *clonesong = newseeker->it->clone(newseeker->_delay);
|
||||||
player->add_iterator(clonesong, g_system->getMillis());
|
player->add_iterator(clonesong, g_system->getMillis());
|
||||||
}
|
}
|
||||||
_sfx_set_song_status(self, newseeker,
|
setSongStatus(newseeker, SOUND_STATUS_PLAYING);
|
||||||
SOUND_STATUS_PLAYING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self->_song = newsong;
|
_song = newsong;
|
||||||
_thaw_time(self);
|
thawTime();
|
||||||
/* _dump_playing_list(self, "after");*/
|
/* _dump_playing_list(this, "after");*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update internal state */
|
/* Update internal state */
|
||||||
static void _update(SfxState *self) {
|
void SfxState::update() {
|
||||||
if (self->_flags & SFX_STATE_FLAG_MULTIPLAY)
|
if (_flags & SFX_STATE_FLAG_MULTIPLAY)
|
||||||
_update_multi_song(self);
|
updateMultiSong();
|
||||||
else
|
else
|
||||||
_update_single_song(self);
|
updateSingleSong();
|
||||||
}
|
}
|
||||||
|
|
||||||
int sfx_play_iterator_pcm(SongIterator *it, song_handle_t handle) {
|
int sfx_play_iterator_pcm(SongIterator *it, song_handle_t handle) {
|
||||||
|
@ -614,13 +609,13 @@ int sfx_play_iterator_pcm(SongIterator *it, song_handle_t handle) {
|
||||||
|
|
||||||
#define DELAY (1000000 / SFX_TICKS_PER_SEC)
|
#define DELAY (1000000 / SFX_TICKS_PER_SEC)
|
||||||
|
|
||||||
void sfx_init(SfxState *self, ResourceManager *resmgr, int flags) {
|
void SfxState::sfx_init(ResourceManager *resmgr, int flags) {
|
||||||
song_lib_init(&self->_songlib);
|
song_lib_init(&_songlib);
|
||||||
self->_song = NULL;
|
_song = NULL;
|
||||||
self->_flags = flags;
|
_flags = flags;
|
||||||
self->_debug = 0; /* Disable all debugging by default */
|
_debug = 0; /* Disable all debugging by default */
|
||||||
self->_soundSync = NULL;
|
_soundSync = NULL;
|
||||||
self->_audioResource = NULL;
|
_audioResource = NULL;
|
||||||
|
|
||||||
player = NULL;
|
player = NULL;
|
||||||
|
|
||||||
|
@ -656,7 +651,7 @@ void sfx_init(SfxState *self, ResourceManager *resmgr, int flags) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfx_exit(SfxState *self) {
|
void SfxState::sfx_exit() {
|
||||||
#ifdef DEBUG_SONG_API
|
#ifdef DEBUG_SONG_API
|
||||||
fprintf(stderr, "[sfx-core] Uninitialising\n");
|
fprintf(stderr, "[sfx-core] Uninitialising\n");
|
||||||
#endif
|
#endif
|
||||||
|
@ -666,55 +661,55 @@ void sfx_exit(SfxState *self) {
|
||||||
|
|
||||||
g_system->getMixer()->stopAll();
|
g_system->getMixer()->stopAll();
|
||||||
|
|
||||||
song_lib_free(self->_songlib);
|
song_lib_free(_songlib);
|
||||||
|
|
||||||
// Delete audio resources for CD talkie games
|
// Delete audio resources for CD talkie games
|
||||||
if (self->_audioResource) {
|
if (_audioResource) {
|
||||||
delete self->_audioResource;
|
delete _audioResource;
|
||||||
self->_audioResource = 0;
|
_audioResource = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfx_suspend(SfxState *self, int suspend) {
|
void SfxState::sfx_suspend(bool suspend) {
|
||||||
#ifdef DEBUG_SONG_API
|
#ifdef DEBUG_SONG_API
|
||||||
fprintf(stderr, "[sfx-core] Suspending? = %d\n", suspend);
|
fprintf(stderr, "[sfx-core] Suspending? = %d\n", suspend);
|
||||||
#endif
|
#endif
|
||||||
if (suspend && (!self->_suspended)) {
|
if (suspend && (!_suspended)) {
|
||||||
/* suspend */
|
/* suspend */
|
||||||
|
|
||||||
_freeze_time(self);
|
freezeTime();
|
||||||
if (player)
|
if (player)
|
||||||
player->pause();
|
player->pause();
|
||||||
/* Suspend song player */
|
/* Suspend song player */
|
||||||
|
|
||||||
} else if (!suspend && (self->_suspended)) {
|
} else if (!suspend && (_suspended)) {
|
||||||
/* unsuspend */
|
/* unsuspend */
|
||||||
|
|
||||||
_thaw_time(self);
|
thawTime();
|
||||||
if (player)
|
if (player)
|
||||||
player->resume();
|
player->resume();
|
||||||
|
|
||||||
/* Unsuspend song player */
|
/* Unsuspend song player */
|
||||||
}
|
}
|
||||||
|
|
||||||
self->_suspended = suspend;
|
_suspended = suspend;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sfx_poll(SfxState *self, song_handle_t *handle, int *cue) {
|
int SfxState::sfx_poll(song_handle_t *handle, int *cue) {
|
||||||
if (!self->_song)
|
if (!_song)
|
||||||
return 0; /* No milk today */
|
return 0; /* No milk today */
|
||||||
|
|
||||||
*handle = self->_song->handle;
|
*handle = _song->handle;
|
||||||
|
|
||||||
#ifdef DEBUG_SONG_API
|
#ifdef DEBUG_SONG_API
|
||||||
fprintf(stderr, "[sfx-core] Polling any (%08lx)\n", *handle);
|
fprintf(stderr, "[sfx-core] Polling any (%08lx)\n", *handle);
|
||||||
#endif
|
#endif
|
||||||
return sfx_poll_specific(self, *handle, cue);
|
return sfx_poll_specific(*handle, cue);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sfx_poll_specific(SfxState *self, song_handle_t handle, int *cue) {
|
int SfxState::sfx_poll_specific(song_handle_t handle, int *cue) {
|
||||||
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
||||||
song_t *song = self->_song;
|
song_t *song = _song;
|
||||||
|
|
||||||
while (song && song->handle != handle)
|
while (song && song->handle != handle)
|
||||||
song = song->next_playing;
|
song = song->next_playing;
|
||||||
|
@ -722,7 +717,7 @@ int sfx_poll_specific(SfxState *self, song_handle_t handle, int *cue) {
|
||||||
if (!song)
|
if (!song)
|
||||||
return 0; /* Song not playing */
|
return 0; /* Song not playing */
|
||||||
|
|
||||||
if (self->_debug & SFX_DEBUG_CUES) {
|
if (_debug & SFX_DEBUG_CUES) {
|
||||||
fprintf(stderr, "[SFX:CUE] Polled song %08lx ", handle);
|
fprintf(stderr, "[SFX:CUE] Polled song %08lx ", handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -736,13 +731,13 @@ int sfx_poll_specific(SfxState *self, song_handle_t handle, int *cue) {
|
||||||
switch (result) {
|
switch (result) {
|
||||||
|
|
||||||
case SI_FINISHED:
|
case SI_FINISHED:
|
||||||
_sfx_set_song_status(self, song, SOUND_STATUS_STOPPED);
|
setSongStatus(song, SOUND_STATUS_STOPPED);
|
||||||
_update(self);
|
update();
|
||||||
/* ...fall through... */
|
/* ...fall through... */
|
||||||
case SI_LOOP:
|
case SI_LOOP:
|
||||||
case SI_RELATIVE_CUE:
|
case SI_RELATIVE_CUE:
|
||||||
case SI_ABSOLUTE_CUE:
|
case SI_ABSOLUTE_CUE:
|
||||||
if (self->_debug & SFX_DEBUG_CUES) {
|
if (_debug & SFX_DEBUG_CUES) {
|
||||||
sciprintf(" => ");
|
sciprintf(" => ");
|
||||||
|
|
||||||
if (result == SI_FINISHED)
|
if (result == SI_FINISHED)
|
||||||
|
@ -766,7 +761,7 @@ int sfx_poll_specific(SfxState *self, song_handle_t handle, int *cue) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (self->_debug & SFX_DEBUG_CUES) {
|
if (_debug & SFX_DEBUG_CUES) {
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -776,8 +771,8 @@ int sfx_poll_specific(SfxState *self, song_handle_t handle, int *cue) {
|
||||||
/* Song basics */
|
/* Song basics */
|
||||||
/*****************/
|
/*****************/
|
||||||
|
|
||||||
int sfx_add_song(SfxState *self, SongIterator *it, int priority, song_handle_t handle, int number) {
|
int SfxState::sfx_add_song(SongIterator *it, int priority, song_handle_t handle, int number) {
|
||||||
song_t *song = song_lib_find(self->_songlib, handle);
|
song_t *song = song_lib_find(_songlib, handle);
|
||||||
|
|
||||||
#ifdef DEBUG_SONG_API
|
#ifdef DEBUG_SONG_API
|
||||||
fprintf(stderr, "[sfx-core] Adding song: %08lx at %d, it=%p\n", handle, priority, it);
|
fprintf(stderr, "[sfx-core] Adding song: %08lx at %d, it=%p\n", handle, priority, it);
|
||||||
|
@ -791,13 +786,13 @@ int sfx_add_song(SfxState *self, SongIterator *it, int priority, song_handle_t h
|
||||||
|
|
||||||
/* If we're already playing this, stop it */
|
/* If we're already playing this, stop it */
|
||||||
/* Tell player to shut up */
|
/* Tell player to shut up */
|
||||||
_dump_songs(self);
|
// _dump_songs(this);
|
||||||
|
|
||||||
if (player)
|
if (player)
|
||||||
player->iterator_message(SongIterator::Message(handle, SIMSG_STOP));
|
player->iterator_message(SongIterator::Message(handle, SIMSG_STOP));
|
||||||
|
|
||||||
if (song) {
|
if (song) {
|
||||||
_sfx_set_song_status(self, song, SOUND_STATUS_STOPPED);
|
setSongStatus( song, SOUND_STATUS_STOPPED);
|
||||||
|
|
||||||
fprintf(stderr, "Overwriting old song (%08lx) ...\n", handle);
|
fprintf(stderr, "Overwriting old song (%08lx) ...\n", handle);
|
||||||
if (song->status == SOUND_STATUS_PLAYING
|
if (song->status == SOUND_STATUS_PLAYING
|
||||||
|
@ -807,7 +802,7 @@ int sfx_add_song(SfxState *self, SongIterator *it, int priority, song_handle_t h
|
||||||
delete it;
|
delete it;
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
} else
|
||||||
song_lib_remove(self->_songlib, handle); /* No duplicates */
|
song_lib_remove(_songlib, handle); /* No duplicates */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,22 +811,22 @@ int sfx_add_song(SfxState *self, SongIterator *it, int priority, song_handle_t h
|
||||||
song->hold = 0;
|
song->hold = 0;
|
||||||
song->loops = 0;
|
song->loops = 0;
|
||||||
song->_wakeupTime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
song->_wakeupTime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
||||||
song_lib_add(self->_songlib, song);
|
song_lib_add(_songlib, song);
|
||||||
self->_song = NULL; /* As above */
|
_song = NULL; /* As above */
|
||||||
_update(self);
|
update();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfx_remove_song(SfxState *self, song_handle_t handle) {
|
void SfxState::sfx_remove_song(song_handle_t handle) {
|
||||||
#ifdef DEBUG_SONG_API
|
#ifdef DEBUG_SONG_API
|
||||||
fprintf(stderr, "[sfx-core] Removing song: %08lx\n", handle);
|
fprintf(stderr, "[sfx-core] Removing song: %08lx\n", handle);
|
||||||
#endif
|
#endif
|
||||||
if (self->_song && self->_song->handle == handle)
|
if (_song && _song->handle == handle)
|
||||||
self->_song = NULL;
|
_song = NULL;
|
||||||
|
|
||||||
song_lib_remove(self->_songlib, handle);
|
song_lib_remove(_songlib, handle);
|
||||||
_update(self);
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -842,25 +837,24 @@ void sfx_remove_song(SfxState *self, song_handle_t handle) {
|
||||||
|
|
||||||
#define ASSERT_SONG(s) if (!(s)) { warning("Looking up song handle %08lx failed in %s, L%d", handle, __FILE__, __LINE__); return; }
|
#define ASSERT_SONG(s) if (!(s)) { warning("Looking up song handle %08lx failed in %s, L%d", handle, __FILE__, __LINE__); return; }
|
||||||
|
|
||||||
void sfx_song_set_status(SfxState *self, song_handle_t handle, int status) {
|
void SfxState::sfx_song_set_status(song_handle_t handle, int status) {
|
||||||
song_t *song = song_lib_find(self->_songlib, handle);
|
song_t *song = song_lib_find(_songlib, handle);
|
||||||
ASSERT_SONG(song);
|
ASSERT_SONG(song);
|
||||||
#ifdef DEBUG_SONG_API
|
#ifdef DEBUG_SONG_API
|
||||||
fprintf(stderr, "[sfx-core] Setting song status to %d"
|
fprintf(stderr, "[sfx-core] Setting song status to %d"
|
||||||
" (0:stop, 1:play, 2:susp, 3:wait): %08lx\n", status, handle);
|
" (0:stop, 1:play, 2:susp, 3:wait): %08lx\n", status, handle);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_sfx_set_song_status(self, song, status);
|
setSongStatus(song, status);
|
||||||
|
|
||||||
_update(self);
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfx_song_set_fade(SfxState *self, song_handle_t handle,
|
void SfxState::sfx_song_set_fade(song_handle_t handle, fade_params_t *params) {
|
||||||
fade_params_t *params) {
|
|
||||||
#ifdef DEBUG_SONG_API
|
#ifdef DEBUG_SONG_API
|
||||||
static const char *stopmsg[] = {"??? Should not happen", "Do not stop afterwards", "Stop afterwards"};
|
static const char *stopmsg[] = {"??? Should not happen", "Do not stop afterwards", "Stop afterwards"};
|
||||||
#endif
|
#endif
|
||||||
song_t *song = song_lib_find(self->_songlib, handle);
|
song_t *song = song_lib_find(_songlib, handle);
|
||||||
|
|
||||||
ASSERT_SONG(song);
|
ASSERT_SONG(song);
|
||||||
|
|
||||||
|
@ -873,11 +867,11 @@ void sfx_song_set_fade(SfxState *self, song_handle_t handle,
|
||||||
|
|
||||||
SIMSG_SEND_FADE(song->it, params);
|
SIMSG_SEND_FADE(song->it, params);
|
||||||
|
|
||||||
_update(self);
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfx_song_renice(SfxState *self, song_handle_t handle, int priority) {
|
void SfxState::sfx_song_renice(song_handle_t handle, int priority) {
|
||||||
song_t *song = song_lib_find(self->_songlib, handle);
|
song_t *song = song_lib_find(_songlib, handle);
|
||||||
ASSERT_SONG(song);
|
ASSERT_SONG(song);
|
||||||
#ifdef DEBUG_SONG_API
|
#ifdef DEBUG_SONG_API
|
||||||
fprintf(stderr, "[sfx-core] Renicing song %08lx to %d\n",
|
fprintf(stderr, "[sfx-core] Renicing song %08lx to %d\n",
|
||||||
|
@ -886,11 +880,11 @@ void sfx_song_renice(SfxState *self, song_handle_t handle, int priority) {
|
||||||
|
|
||||||
song->priority = priority;
|
song->priority = priority;
|
||||||
|
|
||||||
_update(self);
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfx_song_set_loops(SfxState *self, song_handle_t handle, int loops) {
|
void SfxState::sfx_song_set_loops(song_handle_t handle, int loops) {
|
||||||
song_t *song = song_lib_find(self->_songlib, handle);
|
song_t *song = song_lib_find(_songlib, handle);
|
||||||
SongIterator::Message msg = SongIterator::Message(handle, SIMSG_SET_LOOPS(loops));
|
SongIterator::Message msg = SongIterator::Message(handle, SIMSG_SET_LOOPS(loops));
|
||||||
ASSERT_SONG(song);
|
ASSERT_SONG(song);
|
||||||
|
|
||||||
|
@ -906,8 +900,8 @@ void sfx_song_set_loops(SfxState *self, song_handle_t handle, int loops) {
|
||||||
player->iterator_message(msg);
|
player->iterator_message(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfx_song_set_hold(SfxState *self, song_handle_t handle, int hold) {
|
void SfxState::sfx_song_set_hold(song_handle_t handle, int hold) {
|
||||||
song_t *song = song_lib_find(self->_songlib, handle);
|
song_t *song = song_lib_find(_songlib, handle);
|
||||||
SongIterator::Message msg = SongIterator::Message(handle, SIMSG_SET_HOLD(hold));
|
SongIterator::Message msg = SongIterator::Message(handle, SIMSG_SET_HOLD(hold));
|
||||||
ASSERT_SONG(song);
|
ASSERT_SONG(song);
|
||||||
|
|
||||||
|
@ -930,7 +924,7 @@ static const int MIDI_cmdlen[16] = {0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
|
||||||
static const song_handle_t midi_send_base = 0xffff0000;
|
static const song_handle_t midi_send_base = 0xffff0000;
|
||||||
|
|
||||||
Common::Error sfx_send_midi(SfxState *self, song_handle_t handle, int channel,
|
Common::Error SfxState::sfx_send_midi(song_handle_t handle, int channel,
|
||||||
int command, int arg1, int arg2) {
|
int command, int arg1, int arg2) {
|
||||||
byte buffer[5];
|
byte buffer[5];
|
||||||
|
|
||||||
|
@ -975,22 +969,22 @@ Common::Error sfx_send_midi(SfxState *self, song_handle_t handle, int channel,
|
||||||
return Common::kNoError;
|
return Common::kNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sfx_get_volume(SfxState *self) {
|
int SfxState::sfx_get_volume() {
|
||||||
warning("FIXME: Implement volume");
|
warning("FIXME: Implement volume");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfx_set_volume(SfxState *self, int volume) {
|
void SfxState::sfx_set_volume(int volume) {
|
||||||
warning("FIXME: Implement volume");
|
warning("FIXME: Implement volume");
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfx_all_stop(SfxState *self) {
|
void SfxState::sfx_all_stop() {
|
||||||
#ifdef DEBUG_SONG_API
|
#ifdef DEBUG_SONG_API
|
||||||
fprintf(stderr, "[sfx-core] All stop\n");
|
fprintf(stderr, "[sfx-core] All stop\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
song_lib_free(self->_songlib);
|
song_lib_free(_songlib);
|
||||||
_update(self);
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace Sci
|
} // End of namespace Sci
|
||||||
|
|
|
@ -58,117 +58,127 @@ public: // FIXME, make private
|
||||||
uint _debug; /**< Debug flags */
|
uint _debug; /**< Debug flags */
|
||||||
ResourceSync *_soundSync; /**< Used by kDoSync for speech syncing in CD talkie games */
|
ResourceSync *_soundSync; /**< Used by kDoSync for speech syncing in CD talkie games */
|
||||||
AudioResource *_audioResource; /**< Used for audio resources in CD talkie games */
|
AudioResource *_audioResource; /**< Used for audio resources in CD talkie games */
|
||||||
|
|
||||||
|
public:
|
||||||
|
/***********/
|
||||||
|
/* General */
|
||||||
|
/***********/
|
||||||
|
|
||||||
|
/* Initializes the sound engine
|
||||||
|
** Parameters: (ResourceManager *) resmgr: Resource manager for initialization
|
||||||
|
** (int) flags: SFX_STATE_FLAG_*
|
||||||
|
*/
|
||||||
|
void sfx_init(ResourceManager *resmgr, int flags);
|
||||||
|
|
||||||
|
/** Deinitializes the sound subsystem. */
|
||||||
|
void sfx_exit();
|
||||||
|
|
||||||
|
/* Suspends/unsuspends the sound sybsystem
|
||||||
|
** Parameters: (int) suspend: Whether to suspend (non-null) or to unsuspend
|
||||||
|
*/
|
||||||
|
void sfx_suspend(bool suspend);
|
||||||
|
|
||||||
|
/* Polls the sound server for cues etc.
|
||||||
|
** Returns : (int) 0 if the cue queue is empty, SI_LOOP, SI_CUE, or SI_FINISHED otherwise
|
||||||
|
** (song_handle_t) *handle: The affected handle
|
||||||
|
** (int) *cue: The sound cue number (if SI_CUE), or the loop number (if SI_LOOP)
|
||||||
|
*/
|
||||||
|
int sfx_poll(song_handle_t *handle, int *cue);
|
||||||
|
|
||||||
|
/* Polls the sound server for cues etc.
|
||||||
|
** Parameters: (song_handle_t) handle: The handle to poll
|
||||||
|
** Returns : (int) 0 if the cue queue is empty, SI_LOOP, SI_CUE, or SI_FINISHED otherwise
|
||||||
|
** (int) *cue: The sound cue number (if SI_CUE), or the loop number (if SI_LOOP)
|
||||||
|
*/
|
||||||
|
int sfx_poll_specific(song_handle_t handle, int *cue);
|
||||||
|
|
||||||
|
/* Determines the current global volume settings
|
||||||
|
** Returns : (int) The global volume, between 0 (silent) and 127 (max. volume)
|
||||||
|
*/
|
||||||
|
int sfx_get_volume();
|
||||||
|
|
||||||
|
/* Determines the current global volume settings
|
||||||
|
** Parameters: (int) volume: The new global volume, between 0 and 127 (see above)
|
||||||
|
*/
|
||||||
|
void sfx_set_volume(int volume);
|
||||||
|
|
||||||
|
/* Stops all songs currently playing, purges song library
|
||||||
|
*/
|
||||||
|
void sfx_all_stop();
|
||||||
|
|
||||||
|
|
||||||
|
/*****************/
|
||||||
|
/* Song basics */
|
||||||
|
/*****************/
|
||||||
|
|
||||||
|
/* Adds a song to the internal sound library
|
||||||
|
** Parameters: (SongIterator *) it: The iterator describing the song
|
||||||
|
** (int) priority: Initial song priority (higher <-> more important)
|
||||||
|
** (song_handle_t) handle: The handle to associate with the song
|
||||||
|
** Returns : (int) 0 on success, nonzero on error
|
||||||
|
*/
|
||||||
|
int sfx_add_song(SongIterator *it, int priority, song_handle_t handle, int resnum);
|
||||||
|
|
||||||
|
|
||||||
|
/* Deletes a song and its associated song iterator from the song queue
|
||||||
|
** Parameters: (song_handle_t) handle: The song to remove
|
||||||
|
*/
|
||||||
|
void sfx_remove_song(song_handle_t handle);
|
||||||
|
|
||||||
|
|
||||||
|
/**********************/
|
||||||
|
/* Song modifications */
|
||||||
|
/**********************/
|
||||||
|
|
||||||
|
|
||||||
|
/* Sets the song status, i.e. whether it is playing, suspended, or stopped.
|
||||||
|
** Parameters: (song_handle_t) handle: Handle of the song to modify
|
||||||
|
** (int) status: The song status the song should assume
|
||||||
|
** WAITING and PLAYING are set implicitly and essentially describe the same state
|
||||||
|
** as far as this function is concerned.
|
||||||
|
*/
|
||||||
|
void sfx_song_set_status(song_handle_t handle, int status);
|
||||||
|
|
||||||
|
/* Sets the new song priority
|
||||||
|
** Parameters: (song_handle_t) handle: The handle to modify
|
||||||
|
** (int) priority: The priority to set
|
||||||
|
*/
|
||||||
|
void sfx_song_renice(song_handle_t handle, int priority);
|
||||||
|
|
||||||
|
/* Sets the number of loops for the specified song
|
||||||
|
** Parameters: (song_handle_t) handle: The song handle to reference
|
||||||
|
** (int) loops: Number of loops to set
|
||||||
|
*/
|
||||||
|
void sfx_song_set_loops(song_handle_t handle, int loops);
|
||||||
|
|
||||||
|
/* Sets the number of loops for the specified song
|
||||||
|
** Parameters: (song_handle_t) handle: The song handle to reference
|
||||||
|
** (int) hold: Number of loops to setn
|
||||||
|
*/
|
||||||
|
void sfx_song_set_hold(song_handle_t handle, int hold);
|
||||||
|
|
||||||
|
/* Instructs a song to be faded out
|
||||||
|
** Parameters: (song_handle_t) handle: The song handle to reference
|
||||||
|
** (fade_params_t *) fade_setup: The precise fade-out configuration to use
|
||||||
|
*/
|
||||||
|
void sfx_song_set_fade(song_handle_t handle, fade_params_t *fade_setup);
|
||||||
|
|
||||||
|
|
||||||
|
// Previously undocumented:
|
||||||
|
Common::Error sfx_send_midi(song_handle_t handle, int channel,
|
||||||
|
int command, int arg1, int arg2);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void freezeTime();
|
||||||
|
void thawTime();
|
||||||
|
|
||||||
|
bool isPlaying(song_t *song);
|
||||||
|
void setSongStatus(song_t *song, int status);
|
||||||
|
void updateSingleSong();
|
||||||
|
void updateMultiSong();
|
||||||
|
void update();
|
||||||
};
|
};
|
||||||
|
|
||||||
/***********/
|
|
||||||
/* General */
|
|
||||||
/***********/
|
|
||||||
|
|
||||||
/* Initializes the sound engine
|
|
||||||
** Parameters: (ResourceManager *) resmgr: Resource manager for initialization
|
|
||||||
** (int) flags: SFX_STATE_FLAG_*
|
|
||||||
*/
|
|
||||||
void sfx_init(SfxState *self, ResourceManager *resmgr, int flags);
|
|
||||||
|
|
||||||
/** Deinitializes the sound subsystem. */
|
|
||||||
void sfx_exit(SfxState *self);
|
|
||||||
|
|
||||||
/* Suspends/unsuspends the sound sybsystem
|
|
||||||
** Parameters: (int) suspend: Whether to suspend (non-null) or to unsuspend
|
|
||||||
*/
|
|
||||||
void sfx_suspend(SfxState *self, int suspend);
|
|
||||||
|
|
||||||
/* Polls the sound server for cues etc.
|
|
||||||
** Returns : (int) 0 if the cue queue is empty, SI_LOOP, SI_CUE, or SI_FINISHED otherwise
|
|
||||||
** (song_handle_t) *handle: The affected handle
|
|
||||||
** (int) *cue: The sound cue number (if SI_CUE), or the loop number (if SI_LOOP)
|
|
||||||
*/
|
|
||||||
int sfx_poll(SfxState *self, song_handle_t *handle, int *cue);
|
|
||||||
|
|
||||||
/* Polls the sound server for cues etc.
|
|
||||||
** Parameters: (song_handle_t) handle: The handle to poll
|
|
||||||
** Returns : (int) 0 if the cue queue is empty, SI_LOOP, SI_CUE, or SI_FINISHED otherwise
|
|
||||||
** (int) *cue: The sound cue number (if SI_CUE), or the loop number (if SI_LOOP)
|
|
||||||
*/
|
|
||||||
int sfx_poll_specific(SfxState *self, song_handle_t handle, int *cue);
|
|
||||||
|
|
||||||
/* Determines the current global volume settings
|
|
||||||
** Returns : (int) The global volume, between 0 (silent) and 127 (max. volume)
|
|
||||||
*/
|
|
||||||
int sfx_get_volume(SfxState *self);
|
|
||||||
|
|
||||||
/* Determines the current global volume settings
|
|
||||||
** Parameters: (int) volume: The new global volume, between 0 and 127 (see above)
|
|
||||||
*/
|
|
||||||
void sfx_set_volume(SfxState *self, int volume);
|
|
||||||
|
|
||||||
/* Stops all songs currently playing, purges song library
|
|
||||||
*/
|
|
||||||
void sfx_all_stop(SfxState *self);
|
|
||||||
|
|
||||||
|
|
||||||
/*****************/
|
|
||||||
/* Song basics */
|
|
||||||
/*****************/
|
|
||||||
|
|
||||||
/* Adds a song to the internal sound library
|
|
||||||
** Parameters: (SongIterator *) it: The iterator describing the song
|
|
||||||
** (int) priority: Initial song priority (higher <-> more important)
|
|
||||||
** (song_handle_t) handle: The handle to associate with the song
|
|
||||||
** Returns : (int) 0 on success, nonzero on error
|
|
||||||
*/
|
|
||||||
int sfx_add_song(SfxState *self, SongIterator *it, int priority, song_handle_t handle, int resnum);
|
|
||||||
|
|
||||||
|
|
||||||
/* Deletes a song and its associated song iterator from the song queue
|
|
||||||
** Parameters: (song_handle_t) handle: The song to remove
|
|
||||||
*/
|
|
||||||
void sfx_remove_song(SfxState *self, song_handle_t handle);
|
|
||||||
|
|
||||||
|
|
||||||
/**********************/
|
|
||||||
/* Song modifications */
|
|
||||||
/**********************/
|
|
||||||
|
|
||||||
|
|
||||||
/* Sets the song status, i.e. whether it is playing, suspended, or stopped.
|
|
||||||
** Parameters: (song_handle_t) handle: Handle of the song to modify
|
|
||||||
** (int) status: The song status the song should assume
|
|
||||||
** WAITING and PLAYING are set implicitly and essentially describe the same state
|
|
||||||
** as far as this function is concerned.
|
|
||||||
*/
|
|
||||||
void sfx_song_set_status(SfxState *self, song_handle_t handle, int status);
|
|
||||||
|
|
||||||
/* Sets the new song priority
|
|
||||||
** Parameters: (song_handle_t) handle: The handle to modify
|
|
||||||
** (int) priority: The priority to set
|
|
||||||
*/
|
|
||||||
void sfx_song_renice(SfxState *self, song_handle_t handle, int priority);
|
|
||||||
|
|
||||||
/* Sets the number of loops for the specified song
|
|
||||||
** Parameters: (song_handle_t) handle: The song handle to reference
|
|
||||||
** (int) loops: Number of loops to set
|
|
||||||
*/
|
|
||||||
void sfx_song_set_loops(SfxState *self, song_handle_t handle, int loops);
|
|
||||||
|
|
||||||
/* Sets the number of loops for the specified song
|
|
||||||
** Parameters: (song_handle_t) handle: The song handle to reference
|
|
||||||
** (int) hold: Number of loops to setn
|
|
||||||
*/
|
|
||||||
void sfx_song_set_hold(SfxState *self, song_handle_t handle, int hold);
|
|
||||||
|
|
||||||
/* Instructs a song to be faded out
|
|
||||||
** Parameters: (song_handle_t) handle: The song handle to reference
|
|
||||||
** (fade_params_t *) fade_setup: The precise fade-out configuration to use
|
|
||||||
*/
|
|
||||||
void sfx_song_set_fade(SfxState *self, song_handle_t handle, fade_params_t *fade_setup);
|
|
||||||
|
|
||||||
|
|
||||||
// Previously undocumented:
|
|
||||||
Common::Error sfx_send_midi(SfxState *self, song_handle_t handle, int channel,
|
|
||||||
int command, int arg1, int arg2);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // End of namespace Sci
|
} // End of namespace Sci
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue