mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 13:50:13 +00:00
SCI: Renamed sfx_state_t -> SfxState, preparing it to become a class eventually
svn-id: r40958
This commit is contained in:
parent
e23e1ffcb7
commit
d70504c910
@ -220,7 +220,7 @@ int game_init_sound(EngineState *s, int sound_flags) {
|
||||
sound_flags |= SFX_STATE_FLAG_MULTIPLAY;
|
||||
|
||||
s->sfx_init_flags = sound_flags;
|
||||
sfx_init(&s->sound, s->resmgr, sound_flags);
|
||||
sfx_init(&s->_sound, s->resmgr, sound_flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -593,7 +593,7 @@ int game_exit(EngineState *s) {
|
||||
s->_executionStack.clear();
|
||||
|
||||
if (!s->successor) {
|
||||
sfx_exit(&s->sound);
|
||||
sfx_exit(&s->_sound);
|
||||
// Reinit because some other code depends on having a valid state
|
||||
game_init_sound(s, SFX_STATE_FLAG_NOSOUND);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ static void script_set_priority(EngineState *s, reg_t obj, int priority) {
|
||||
flags &= ~SCI1_SOUND_FLAG_SCRIPTED_PRI;
|
||||
} else flags |= SCI1_SOUND_FLAG_SCRIPTED_PRI;
|
||||
|
||||
sfx_song_renice(&s->sound, FROBNICATE_HANDLE(obj), priority);
|
||||
sfx_song_renice(&s->_sound, FROBNICATE_HANDLE(obj), priority);
|
||||
PUT_SEL32V(obj, flags, flags);
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ void process_sound_events(EngineState *s) { /* Get all sound events, apply their
|
||||
return;
|
||||
/* SCI01 and later explicitly poll for everything */
|
||||
|
||||
while ((result = sfx_poll(&s->sound, &handle, &cue))) {
|
||||
while ((result = sfx_poll(&s->_sound, &handle, &cue))) {
|
||||
reg_t obj = DEFROBNICATE_HANDLE(handle);
|
||||
if (!is_object(s, obj)) {
|
||||
warning("Non-object %04x:%04x received sound signal (%d/%d)", PRINT_REG(obj), result, cue);
|
||||
@ -264,7 +264,7 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
case _K_SCI0_SOUND_INIT_HANDLE:
|
||||
if (obj.segment) {
|
||||
sciprintf("Initializing song number %d\n", GET_SEL32V(obj, number));
|
||||
SCRIPT_ASSERT_ZERO(sfx_add_song(&s->sound,
|
||||
SCRIPT_ASSERT_ZERO(sfx_add_song(&s->_sound,
|
||||
build_iterator(s, number,
|
||||
SCI_SONG_ITERATOR_TYPE_SCI0,
|
||||
handle),
|
||||
@ -276,9 +276,9 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
case _K_SCI0_SOUND_PLAY_HANDLE:
|
||||
if (obj.segment) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_PLAYING);
|
||||
sfx_song_set_loops(&s->sound,
|
||||
sfx_song_set_loops(&s->_sound,
|
||||
handle, GET_SEL32V(obj, loop));
|
||||
PUT_SEL32V(obj, state, _K_SOUND_STATUS_PLAYING);
|
||||
}
|
||||
@ -289,14 +289,14 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
case _K_SCI0_SOUND_DISPOSE_HANDLE:
|
||||
if (obj.segment) {
|
||||
sfx_remove_song(&s->sound, handle);
|
||||
sfx_remove_song(&s->_sound, handle);
|
||||
}
|
||||
PUT_SEL32V(obj, handle, 0x0000);
|
||||
break;
|
||||
|
||||
case _K_SCI0_SOUND_STOP_HANDLE:
|
||||
if (obj.segment) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_STOPPED);
|
||||
PUT_SEL32V(obj, state, SOUND_STATUS_STOPPED);
|
||||
}
|
||||
@ -304,7 +304,7 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
case _K_SCI0_SOUND_SUSPEND_HANDLE:
|
||||
if (obj.segment) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_SUSPENDED);
|
||||
PUT_SEL32V(obj, state, SOUND_STATUS_SUSPENDED);
|
||||
}
|
||||
@ -312,7 +312,7 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
case _K_SCI0_SOUND_RESUME_HANDLE:
|
||||
if (obj.segment) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_PLAYING);
|
||||
PUT_SEL32V(obj, state, SOUND_STATUS_PLAYING);
|
||||
}
|
||||
@ -337,15 +337,15 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int vol = SKPV_OR_ALT(1, -1);
|
||||
|
||||
if (vol != -1)
|
||||
sfx_set_volume(&s->sound, vol << 0xf);
|
||||
sfx_set_volume(&s->_sound, vol << 0xf);
|
||||
else
|
||||
s->r_acc = make_reg(0, sfx_get_volume(&s->sound) >> 0xf);
|
||||
s->r_acc = make_reg(0, sfx_get_volume(&s->_sound) >> 0xf);
|
||||
}
|
||||
break;
|
||||
|
||||
case _K_SCI0_SOUND_UPDATE_VOL_PRI:
|
||||
if (obj.segment) {
|
||||
sfx_song_set_loops(&s->sound,
|
||||
sfx_song_set_loops(&s->_sound,
|
||||
handle, GET_SEL32V(obj, loop));
|
||||
script_set_priority(s, obj, GET_SEL32V(obj, pri));
|
||||
}
|
||||
@ -356,7 +356,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
|
||||
** than fading it! */
|
||||
if (obj.segment) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_STOPPED);
|
||||
PUT_SEL32V(obj, state, SOUND_STATUS_STOPPED);
|
||||
PUT_SEL32V(obj, signal, -1);
|
||||
@ -368,7 +368,7 @@ reg_t kDoSound_SCI0(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
break;
|
||||
|
||||
case _K_SCI0_SOUND_PLAY_NEXT:
|
||||
/* sfx_all_stop(&s->sound);*/
|
||||
/* sfx_all_stop(&s->_sound);*/
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -459,9 +459,9 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int vol = SKPV_OR_ALT(1, -1);
|
||||
|
||||
if (vol != -1)
|
||||
sfx_set_volume(&s->sound, vol << 0xf);
|
||||
sfx_set_volume(&s->_sound, vol << 0xf);
|
||||
else
|
||||
s->r_acc = make_reg(0, sfx_get_volume(&s->sound) >> 0xf);
|
||||
s->r_acc = make_reg(0, sfx_get_volume(&s->_sound) >> 0xf);
|
||||
break;
|
||||
}
|
||||
case _K_SCI01_SOUND_MUTE_SOUND : {
|
||||
@ -490,13 +490,13 @@ 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 */
|
||||
|
||||
if (obj.segment) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_PLAYING);
|
||||
sfx_song_set_loops(&s->sound,
|
||||
sfx_song_set_loops(&s->_sound,
|
||||
handle, looping);
|
||||
sfx_song_renice(&s->sound,
|
||||
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);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -508,7 +508,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
|
||||
if (obj.segment && (s->resmgr->testResource(kResourceTypeSound, number))) {
|
||||
sciprintf("Initializing song number %d\n", number);
|
||||
SCRIPT_ASSERT_ZERO(sfx_add_song(&s->sound,
|
||||
SCRIPT_ASSERT_ZERO(sfx_add_song(&s->_sound,
|
||||
build_iterator(s, number,
|
||||
SCI_SONG_ITERATOR_TYPE_SCI1,
|
||||
handle),
|
||||
@ -520,9 +520,9 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
case _K_SCI01_SOUND_DISPOSE_HANDLE : {
|
||||
if (obj.segment) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_STOPPED);
|
||||
sfx_remove_song(&s->sound, handle);
|
||||
sfx_remove_song(&s->_sound, handle);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -538,9 +538,9 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
//int vol = GET_SEL32V(obj, vol);
|
||||
int pri = GET_SEL32V(obj, pri);
|
||||
|
||||
sfx_song_set_loops(&s->sound,
|
||||
sfx_song_set_loops(&s->_sound,
|
||||
handle, looping);
|
||||
sfx_song_renice(&s->sound, handle, pri);
|
||||
sfx_song_renice(&s->_sound, handle, pri);
|
||||
|
||||
SCIkdebug(SCIkSOUND, "[sound01-update-handle] -- CUE %04x:%04x");
|
||||
|
||||
@ -554,7 +554,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
case _K_SCI01_SOUND_STOP_HANDLE : {
|
||||
PUT_SEL32V(obj, signal, -1);
|
||||
if (obj.segment) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_STOPPED);
|
||||
}
|
||||
break;
|
||||
@ -565,7 +565,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
SOUND_STATUS_SUSPENDED : SOUND_STATUS_PLAYING;
|
||||
|
||||
if (obj.segment) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, setstate);
|
||||
}
|
||||
break;
|
||||
@ -577,7 +577,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 */
|
||||
PUT_SEL32V(obj, signal, -1);
|
||||
if (obj.segment) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_STOPPED);
|
||||
}
|
||||
break;
|
||||
@ -591,7 +591,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int cue = 0;
|
||||
|
||||
while (result == SI_LOOP)
|
||||
result = sfx_poll_specific(&s->sound, handle, &cue);
|
||||
result = sfx_poll_specific(&s->_sound, handle, &cue);
|
||||
|
||||
switch (result) {
|
||||
|
||||
@ -637,7 +637,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
/* } */
|
||||
/* break; */
|
||||
/* case 0xFF: /\* May be unnecessary *\/ */
|
||||
/* sfx_song_set_status(&s->sound, */
|
||||
/* sfx_song_set_status(&s->_sound, */
|
||||
/* handle, SOUND_STATUS_STOPPED); */
|
||||
/* break; */
|
||||
/* default : */
|
||||
@ -665,7 +665,7 @@ reg_t kDoSound_SCI01(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int controller = UKPV(3);
|
||||
int param = UKPV(4);
|
||||
|
||||
sfx_send_midi(&s->sound, handle,
|
||||
sfx_send_midi(&s->_sound, handle,
|
||||
channel, midiCmd, controller, param);
|
||||
break;
|
||||
}
|
||||
@ -810,12 +810,12 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int looping = GET_SEL32V(obj, loop);
|
||||
//int vol = GET_SEL32V(obj, vol);
|
||||
int pri = GET_SEL32V(obj, pri);
|
||||
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)) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_STOPPED);
|
||||
sfx_remove_song(&s->sound, handle);
|
||||
sfx_remove_song(&s->_sound, handle);
|
||||
PUT_SEL32(obj, nodePtr, NULL_REG);
|
||||
}
|
||||
|
||||
@ -826,7 +826,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
sciprintf("Initializing song number %d\n", number);
|
||||
SCRIPT_ASSERT_ZERO(sfx_add_song(&s->sound,
|
||||
SCRIPT_ASSERT_ZERO(sfx_add_song(&s->_sound,
|
||||
build_iterator(s, number,
|
||||
SCI_SONG_ITERATOR_TYPE_SCI1,
|
||||
handle),
|
||||
@ -836,11 +836,11 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
|
||||
if (obj.segment) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_PLAYING);
|
||||
sfx_song_set_loops(&s->sound,
|
||||
sfx_song_set_loops(&s->_sound,
|
||||
handle, looping);
|
||||
sfx_song_renice(&s->sound,
|
||||
sfx_song_renice(&s->_sound,
|
||||
handle, pri);
|
||||
}
|
||||
|
||||
@ -852,14 +852,14 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
//int pri = GET_SEL32V(obj, pri);
|
||||
|
||||
if (GET_SEL32V(obj, nodePtr)) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_STOPPED);
|
||||
sfx_remove_song(&s->sound, handle);
|
||||
sfx_remove_song(&s->_sound, handle);
|
||||
}
|
||||
|
||||
if (obj.segment && (s->resmgr->testResource(kResourceTypeSound, number))) {
|
||||
sciprintf("Initializing song number %d\n", number);
|
||||
SCRIPT_ASSERT_ZERO(sfx_add_song(&s->sound,
|
||||
SCRIPT_ASSERT_ZERO(sfx_add_song(&s->_sound,
|
||||
build_iterator(s, number,
|
||||
SCI_SONG_ITERATOR_TYPE_SCI1,
|
||||
handle),
|
||||
@ -871,16 +871,16 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
case _K_SCI1_SOUND_DISPOSE_HANDLE : {
|
||||
if (obj.segment) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_STOPPED);
|
||||
sfx_remove_song(&s->sound, handle);
|
||||
sfx_remove_song(&s->_sound, handle);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case _K_SCI1_SOUND_STOP_HANDLE : {
|
||||
PUT_SEL32V(obj, signal, -1);
|
||||
if (obj.segment) {
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_STOPPED);
|
||||
}
|
||||
break;
|
||||
@ -898,7 +898,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
FADE_ACTION_FADE_AND_STOP :
|
||||
FADE_ACTION_FADE_AND_CONT;
|
||||
|
||||
sfx_song_set_fade(&s->sound,
|
||||
sfx_song_set_fade(&s->_sound,
|
||||
handle,
|
||||
&fade);
|
||||
|
||||
@ -908,7 +908,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
PUT_SEL32V(obj, signal, -1);
|
||||
PUT_SEL32V(obj, nodePtr, 0);
|
||||
PUT_SEL32V(obj, handle, 0);
|
||||
sfx_song_set_status(&s->sound,
|
||||
sfx_song_set_status(&s->_sound,
|
||||
handle, SOUND_STATUS_STOPPED);
|
||||
} else {
|
||||
// FIXME: Support fade-and-continue. For now, send signal right away.
|
||||
@ -920,7 +920,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
case _K_SCI1_SOUND_HOLD_HANDLE : {
|
||||
int value = SKPV(2);
|
||||
|
||||
sfx_song_set_hold(&s->sound,
|
||||
sfx_song_set_hold(&s->_sound,
|
||||
handle, value);
|
||||
break;
|
||||
}
|
||||
@ -948,7 +948,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
int cue = 0;
|
||||
|
||||
while (result == SI_LOOP)
|
||||
result = sfx_poll_specific(&s->sound, handle, &cue);
|
||||
result = sfx_poll_specific(&s->_sound, handle, &cue);
|
||||
|
||||
switch (result) {
|
||||
|
||||
@ -978,7 +978,7 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
break;
|
||||
}
|
||||
case _K_SCI1_SOUND_MIDI_SEND : {
|
||||
sfx_send_midi(&s->sound, handle,
|
||||
sfx_send_midi(&s->_sound, handle,
|
||||
UKPV(2), UKPV(3), UKPV(4), UKPV(5));
|
||||
break;
|
||||
}
|
||||
@ -1006,19 +1006,19 @@ reg_t kDoAudio(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
Audio::Mixer *mixer = g_system->getMixer();
|
||||
int sampleLen = 0;
|
||||
|
||||
if (!s->sound.audioResource)
|
||||
s->sound.audioResource = new AudioResource(s->resmgr, s->version);
|
||||
if (!s->_sound._audioResource)
|
||||
s->_sound._audioResource = new AudioResource(s->resmgr, s->version);
|
||||
|
||||
switch (UKPV(0)) {
|
||||
case kSciAudioWPlay:
|
||||
case kSciAudioPlay:
|
||||
s->sound.audioResource->stop();
|
||||
s->_sound._audioResource->stop();
|
||||
|
||||
if (argc == 2) { // KQ5CD, KQ6 floppy
|
||||
Audio::AudioStream *audioStream = s->sound.audioResource->getAudioStream(UKPV(1), &sampleLen);
|
||||
Audio::AudioStream *audioStream = s->_sound._audioResource->getAudioStream(UKPV(1), &sampleLen);
|
||||
|
||||
if (audioStream)
|
||||
mixer->playInputStream(Audio::Mixer::kSpeechSoundType, s->sound.audioResource->getAudioHandle(), audioStream);
|
||||
mixer->playInputStream(Audio::Mixer::kSpeechSoundType, s->_sound._audioResource->getAudioHandle(), audioStream);
|
||||
} else if (argc == 6) { // SQ4CD or newer
|
||||
// TODO
|
||||
warning("kDoAudio: Play called with new semantics - 5 parameters: %d %d %d %d %d", UKPV(1), UKPV(2), UKPV(3), UKPV(4), UKPV(5));
|
||||
@ -1027,18 +1027,18 @@ reg_t kDoAudio(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
return make_reg(0, sampleLen); // return sample length in ticks
|
||||
case kSciAudioStop:
|
||||
s->sound.audioResource->stop();
|
||||
s->_sound._audioResource->stop();
|
||||
break;
|
||||
case kSciAudioPause:
|
||||
s->sound.audioResource->pause();
|
||||
s->_sound._audioResource->pause();
|
||||
break;
|
||||
case kSciAudioResume:
|
||||
s->sound.audioResource->resume();
|
||||
s->_sound._audioResource->resume();
|
||||
break;
|
||||
case kSciAudioPosition:
|
||||
return make_reg(0, s->sound.audioResource->getAudioPosition());
|
||||
return make_reg(0, s->_sound._audioResource->getAudioPosition());
|
||||
case kSciAudioRate:
|
||||
s->sound.audioResource->setAudioRate(UKPV(1));
|
||||
s->_sound._audioResource->setAudioRate(UKPV(1));
|
||||
break;
|
||||
case kSciAudioVolume:
|
||||
mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, UKPV(1));
|
||||
@ -1048,7 +1048,7 @@ reg_t kDoAudio(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
// In SCI1.1: tests for digital audio support
|
||||
return make_reg(0, 1);
|
||||
} else {
|
||||
s->sound.audioResource->setAudioLang(SKPV(1));
|
||||
s->_sound._audioResource->setAudioLang(SKPV(1));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -1062,15 +1062,15 @@ reg_t kDoSync(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
switch (UKPV(0)) {
|
||||
case kSciAudioSyncStart:
|
||||
if (argc == 3) { // KQ5CD, KQ6 floppy
|
||||
if (s->sound.soundSync) {
|
||||
s->resmgr->unlockResource(s->sound.soundSync, s->sound.soundSync->number, kResourceTypeSync);
|
||||
if (s->_sound._soundSync) {
|
||||
s->resmgr->unlockResource(s->_sound._soundSync, s->_sound._soundSync->number, kResourceTypeSync);
|
||||
}
|
||||
|
||||
// Load sound sync resource and lock it
|
||||
s->sound.soundSync = (ResourceSync *)s->resmgr->findResource(kResourceTypeSync, UKPV(2), 1);
|
||||
s->_sound._soundSync = (ResourceSync *)s->resmgr->findResource(kResourceTypeSync, UKPV(2), 1);
|
||||
|
||||
if (s->sound.soundSync) {
|
||||
s->sound.soundSync->startSync(s, argv[1]);
|
||||
if (s->_sound._soundSync) {
|
||||
s->_sound._soundSync->startSync(s, argv[1]);
|
||||
} else {
|
||||
// Notify the scripts to stop sound sync
|
||||
PUT_SEL32V(argv[1], syncCue, -1);
|
||||
@ -1083,15 +1083,15 @@ reg_t kDoSync(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||
}
|
||||
break;
|
||||
case kSciAudioSyncNext:
|
||||
if (s->sound.soundSync) {
|
||||
s->sound.soundSync->nextSync(s, argv[1]);
|
||||
if (s->_sound._soundSync) {
|
||||
s->_sound._soundSync->nextSync(s, argv[1]);
|
||||
}
|
||||
break;
|
||||
case kSciAudioSyncStop:
|
||||
if (s->sound.soundSync) {
|
||||
s->sound.soundSync->stopSync();
|
||||
s->resmgr->unlockResource(s->sound.soundSync, s->sound.soundSync->number, kResourceTypeSync);
|
||||
s->sound.soundSync = NULL;
|
||||
if (s->_sound._soundSync) {
|
||||
s->_sound._soundSync->stopSync();
|
||||
s->resmgr->unlockResource(s->_sound._soundSync, s->_sound._soundSync->number, kResourceTypeSync);
|
||||
s->_sound._soundSync = NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -231,8 +231,8 @@ void syncWithSerializer(Common::Serializer &s, Class &obj) {
|
||||
sync_reg_t(s, obj.reg);
|
||||
}
|
||||
|
||||
static void sync_sfx_state_t(Common::Serializer &s, sfx_state_t &obj) {
|
||||
sync_songlib_t(s, obj.songlib);
|
||||
static void sync_sfx_state_t(Common::Serializer &s, SfxState &obj) {
|
||||
sync_songlib_t(s, obj._songlib);
|
||||
}
|
||||
|
||||
static void sync_SavegameMetadata(Common::Serializer &s, SavegameMetadata &obj) {
|
||||
@ -268,7 +268,7 @@ void EngineState::saveLoadWithSerializer(Common::Serializer &s) {
|
||||
|
||||
syncArray<Class>(s, _classtable);
|
||||
|
||||
sync_sfx_state_t(s, sound);
|
||||
sync_sfx_state_t(s, _sound);
|
||||
}
|
||||
|
||||
void LocalVariables::saveLoadWithSerializer(Common::Serializer &s) {
|
||||
@ -695,10 +695,10 @@ static void reconstruct_sounds(EngineState *s) {
|
||||
song_t *seeker;
|
||||
SongIteratorType it_type = s->resmgr->_sciVersion >= SCI_VERSION_01 ? SCI_SONG_ITERATOR_TYPE_SCI1 : SCI_SONG_ITERATOR_TYPE_SCI0;
|
||||
|
||||
if (s->sound.songlib.lib)
|
||||
seeker = *(s->sound.songlib.lib);
|
||||
if (s->_sound._songlib.lib)
|
||||
seeker = *(s->_sound._songlib.lib);
|
||||
else {
|
||||
song_lib_init(&s->sound.songlib);
|
||||
song_lib_init(&s->_sound._songlib);
|
||||
seeker = NULL;
|
||||
}
|
||||
|
||||
@ -720,7 +720,7 @@ static void reconstruct_sounds(EngineState *s) {
|
||||
oldstatus = seeker->status;
|
||||
seeker->status = SOUND_STATUS_STOPPED;
|
||||
seeker->it = ff;
|
||||
sfx_song_set_status(&s->sound, seeker->handle, oldstatus);
|
||||
sfx_song_set_status(&s->_sound, seeker->handle, oldstatus);
|
||||
seeker = seeker->next;
|
||||
}
|
||||
}
|
||||
@ -770,7 +770,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
|
||||
|
||||
retval->saveLoadWithSerializer(ser); // FIXME: Error handling?
|
||||
|
||||
sfx_exit(&s->sound);
|
||||
sfx_exit(&s->_sound);
|
||||
|
||||
// Set exec stack base to zero
|
||||
retval->execution_stack_base = 0;
|
||||
@ -783,11 +783,11 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
|
||||
|
||||
retval->resmgr = s->resmgr;
|
||||
|
||||
temp = retval->sound.songlib;
|
||||
sfx_init(&retval->sound, retval->resmgr, s->sfx_init_flags);
|
||||
temp = retval->_sound._songlib;
|
||||
sfx_init(&retval->_sound, retval->resmgr, s->sfx_init_flags);
|
||||
retval->sfx_init_flags = s->sfx_init_flags;
|
||||
song_lib_free(retval->sound.songlib);
|
||||
retval->sound.songlib = temp;
|
||||
song_lib_free(retval->_sound._songlib);
|
||||
retval->_sound._songlib = temp;
|
||||
|
||||
_reset_graphics_input(retval);
|
||||
reconstruct_stack(retval);
|
||||
@ -851,11 +851,11 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
|
||||
retval->pic_priority_table = (int*)gfxop_get_pic_metainfo(retval->gfx_state);
|
||||
retval->_gameName = obj_get_name(retval, retval->game_obj);
|
||||
|
||||
retval->sound.it = NULL;
|
||||
retval->sound.flags = s->sound.flags;
|
||||
retval->sound.song = NULL;
|
||||
retval->sound.suspended = s->sound.suspended;
|
||||
retval->sound.debug = s->sound.debug;
|
||||
retval->_sound._it = NULL;
|
||||
retval->_sound._flags = s->_sound._flags;
|
||||
retval->_sound._song = NULL;
|
||||
retval->_sound._suspended = s->_sound._suspended;
|
||||
retval->_sound._debug = s->_sound._debug;
|
||||
reconstruct_sounds(retval);
|
||||
|
||||
// Message state:
|
||||
|
@ -555,7 +555,7 @@ int objinfo(EngineState *s, reg_t pos);
|
||||
void song_lib_dump(const songlib_t &songlib, int line);
|
||||
|
||||
static int c_songlib_print(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
|
||||
song_lib_dump(s->sound.songlib, __LINE__);
|
||||
song_lib_dump(s->_sound._songlib, __LINE__);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2343,7 +2343,7 @@ static int c_sfx_debuglog(EngineState *s, const Common::Array<cmd_param_t> &cmdP
|
||||
{"Song cue polling and delivery", 'c', SFX_DEBUG_CUES}
|
||||
};
|
||||
|
||||
return c_handle_config_update(sfx_debug_modes, SFX_DEBUG_MODES, "sound subsystem", (int *)&(s->sound.debug), cmdParams);
|
||||
return c_handle_config_update(sfx_debug_modes, SFX_DEBUG_MODES, "sound subsystem", (int *)&(s->_sound._debug), cmdParams);
|
||||
}
|
||||
|
||||
static int c_sfx_remove(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
|
||||
@ -2351,8 +2351,8 @@ static int c_sfx_remove(EngineState *s, const Common::Array<cmd_param_t> &cmdPar
|
||||
int handle = FROBNICATE_HANDLE(id);
|
||||
|
||||
if (id.segment) {
|
||||
sfx_song_set_status(&s->sound, handle, SOUND_STATUS_STOPPED);
|
||||
sfx_remove_song(&s->sound, handle);
|
||||
sfx_song_set_status(&s->_sound, handle, SOUND_STATUS_STOPPED);
|
||||
sfx_remove_song(&s->_sound, handle);
|
||||
PUT_SEL32V(id, signal, -1);
|
||||
PUT_SEL32V(id, nodePtr, 0);
|
||||
PUT_SEL32V(id, handle, 0);
|
||||
@ -3250,7 +3250,7 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *
|
||||
const char *commandstring;
|
||||
|
||||
// Suspend music playing
|
||||
sfx_suspend(&s->sound, 1);
|
||||
sfx_suspend(&s->_sound, 1);
|
||||
|
||||
commandstring = _debug_get_input();
|
||||
|
||||
@ -3263,7 +3263,7 @@ void script_debug(EngineState *s, reg_t *pc, StackPtr *sp, StackPtr *pp, reg_t *
|
||||
sciprintf("\n");
|
||||
|
||||
// Resume music playing
|
||||
sfx_suspend(&s->sound, 0);
|
||||
sfx_suspend(&s->_sound, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,6 @@ EngineState::EngineState() : _dirseeker(this) {
|
||||
gfx_state = 0;
|
||||
old_screen = 0;
|
||||
|
||||
memset(&sound, 0, sizeof(sound)); // FIXME: Remove this once/if we C++ify sfx_state_t
|
||||
sfx_init_flags = 0;
|
||||
sound_volume = 0;
|
||||
sound_mute = 0;
|
||||
|
@ -129,7 +129,7 @@ public:
|
||||
GfxState *gfx_state; /**< Graphics state and driver */
|
||||
gfx_pixmap_t *old_screen; /**< Old screen content: Stored during kDrawPic() for kAnimate() */
|
||||
|
||||
sfx_state_t sound; /**< sound subsystem */
|
||||
SfxState _sound; /**< sound subsystem */
|
||||
int sfx_init_flags; /**< flags the sfx subsystem was initialised with */
|
||||
unsigned int sound_volume; /**< 0x0 -> 0xf Current volume of sound system */
|
||||
unsigned int sound_mute; /**< 0 = not, else == saved value */
|
||||
|
@ -63,10 +63,10 @@ int sfx_get_player_polyphony() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _freeze_time(sfx_state_t *self) {
|
||||
static void _freeze_time(SfxState *self) {
|
||||
/* Freezes the top song delay time */
|
||||
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
||||
song_t *song = self->song;
|
||||
song_t *song = self->_song;
|
||||
|
||||
while (song) {
|
||||
song->_delay = song->_wakeupTime.frameDiff(ctime);
|
||||
@ -77,13 +77,25 @@ static void _freeze_time(sfx_state_t *self) {
|
||||
}
|
||||
}
|
||||
|
||||
static void _thaw_time(SfxState *self) {
|
||||
/* inverse of _freeze_time() */
|
||||
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
||||
song_t *song = self->_song;
|
||||
|
||||
while (song) {
|
||||
song->_wakeupTime = ctime.addFrames(song->_delay);
|
||||
|
||||
song = song->next_playing;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Unreferenced - removed
|
||||
static void _dump_playing_list(sfx_state_t *self, char *msg) {
|
||||
song_t *song = self->song;
|
||||
static void _dump_playing_list(SfxState *self, char *msg) {
|
||||
song_t *song = self->_song;
|
||||
|
||||
fprintf(stderr, "[] Song list : [ ");
|
||||
song = *(self->songlib.lib);
|
||||
song = *(self->_songlib.lib);
|
||||
while (song) {
|
||||
fprintf(stderr, "%08lx:%d ", song->handle, song->status);
|
||||
song = song->next_playing;
|
||||
@ -101,12 +113,12 @@ static void _dump_playing_list(sfx_state_t *self, char *msg) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static void _dump_songs(sfx_state_t *self) {
|
||||
static void _dump_songs(SfxState *self) {
|
||||
#if 0
|
||||
song_t *song = self->song;
|
||||
song_t *song = self->_song;
|
||||
|
||||
fprintf(stderr, "Cue iterators:\n");
|
||||
song = *(self->songlib.lib);
|
||||
song = *(self->_songlib.lib);
|
||||
while (song) {
|
||||
fprintf(stderr, " **\tHandle %08x (p%d): status %d\n",
|
||||
song->handle, song->priority, song->status);
|
||||
@ -121,20 +133,8 @@ static void _dump_songs(sfx_state_t *self) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _thaw_time(sfx_state_t *self) {
|
||||
/* inverse of _freeze_time() */
|
||||
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
||||
song_t *song = self->song;
|
||||
|
||||
while (song) {
|
||||
song->_wakeupTime = ctime.addFrames(song->_delay);
|
||||
|
||||
song = song->next_playing;
|
||||
}
|
||||
}
|
||||
|
||||
static int is_playing(sfx_state_t *self, song_t *song) {
|
||||
song_t *playing_song = self->song;
|
||||
static int is_playing(SfxState *self, song_t *song) {
|
||||
song_t *playing_song = self->_song;
|
||||
|
||||
/* _dump_playing_list(self, "is-playing");*/
|
||||
|
||||
@ -146,7 +146,7 @@ static int is_playing(sfx_state_t *self, song_t *song) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _sfx_set_song_status(sfx_state_t *self, song_t *song, int status) {
|
||||
static void _sfx_set_song_status(SfxState *self, song_t *song, int status) {
|
||||
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
||||
|
||||
switch (status) {
|
||||
@ -190,10 +190,10 @@ static void _sfx_set_song_status(sfx_state_t *self, song_t *song, int status) {
|
||||
}
|
||||
|
||||
/* Update internal state iff only one song may be played */
|
||||
static void _update_single_song(sfx_state_t *self) {
|
||||
song_t *newsong = song_lib_find_active(self->songlib);
|
||||
static void _update_single_song(SfxState *self) {
|
||||
song_t *newsong = song_lib_find_active(self->_songlib);
|
||||
|
||||
if (newsong != self->song) {
|
||||
if (newsong != self->_song) {
|
||||
_freeze_time(self); /* Store song delay time */
|
||||
|
||||
if (player)
|
||||
@ -212,18 +212,18 @@ static void _update_single_song(sfx_state_t *self) {
|
||||
} else {
|
||||
/* Turn off sound */
|
||||
}
|
||||
if (self->song) {
|
||||
if (self->song->status == SOUND_STATUS_PLAYING)
|
||||
if (self->_song) {
|
||||
if (self->_song->status == SOUND_STATUS_PLAYING)
|
||||
_sfx_set_song_status(self, newsong,
|
||||
SOUND_STATUS_WAITING);
|
||||
}
|
||||
|
||||
if (self->debug & SFX_DEBUG_SONGS) {
|
||||
if (self->_debug & SFX_DEBUG_SONGS) {
|
||||
sciprintf("[SFX] Changing active song:");
|
||||
if (!self->song)
|
||||
if (!self->_song)
|
||||
sciprintf(" New song:");
|
||||
else
|
||||
sciprintf(" pausing %08lx, now playing", self->song->handle);
|
||||
sciprintf(" pausing %08lx, now playing", self->_song->handle);
|
||||
|
||||
if (newsong)
|
||||
sciprintf(" %08lx\n", newsong->handle);
|
||||
@ -232,7 +232,7 @@ static void _update_single_song(sfx_state_t *self) {
|
||||
}
|
||||
|
||||
|
||||
self->song = newsong;
|
||||
self->_song = newsong;
|
||||
_thaw_time(self); /* Recover song delay time */
|
||||
|
||||
if (newsong && player) {
|
||||
@ -244,10 +244,10 @@ static void _update_single_song(sfx_state_t *self) {
|
||||
}
|
||||
|
||||
|
||||
static void _update_multi_song(sfx_state_t *self) {
|
||||
song_t *oldfirst = self->song;
|
||||
static void _update_multi_song(SfxState *self) {
|
||||
song_t *oldfirst = self->_song;
|
||||
song_t *oldseeker;
|
||||
song_t *newsong = song_lib_find_active(self->songlib);
|
||||
song_t *newsong = song_lib_find_active(self->_songlib);
|
||||
song_t *newseeker;
|
||||
song_t not_playing_anymore; /* Dummy object, referenced by
|
||||
** songs which are no longer
|
||||
@ -279,7 +279,7 @@ static void _update_multi_song(sfx_state_t *self) {
|
||||
for (newseeker = newsong; newseeker;
|
||||
newseeker = newseeker->next_playing) {
|
||||
newseeker->next_playing
|
||||
= song_lib_find_next_active(self->songlib,
|
||||
= song_lib_find_next_active(self->_songlib,
|
||||
newseeker);
|
||||
|
||||
if (newseeker == newseeker->next_playing) { BREAKPOINT(); }
|
||||
@ -287,7 +287,7 @@ static void _update_multi_song(sfx_state_t *self) {
|
||||
/* 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
|
||||
** state (particularly is_playing(), indirectly */
|
||||
self->song = newsong;
|
||||
self->_song = newsong;
|
||||
|
||||
/* Third, stop all old songs */
|
||||
for (oldseeker = oldfirst; oldseeker;
|
||||
@ -295,7 +295,7 @@ static void _update_multi_song(sfx_state_t *self) {
|
||||
if (oldseeker->next_playing == ¬_playing_anymore) {
|
||||
_sfx_set_song_status(self, oldseeker,
|
||||
SOUND_STATUS_SUSPENDED);
|
||||
if (self->debug & SFX_DEBUG_SONGS) {
|
||||
if (self->_debug & SFX_DEBUG_SONGS) {
|
||||
sciprintf("[SFX] Stopping song %lx\n", oldseeker->handle);
|
||||
}
|
||||
if (player && oldseeker->it)
|
||||
@ -305,7 +305,7 @@ static void _update_multi_song(sfx_state_t *self) {
|
||||
|
||||
for (newseeker = newsong; newseeker; newseeker = newseeker->next_playing) {
|
||||
if (newseeker->status != SOUND_STATUS_PLAYING && player) {
|
||||
if (self->debug & SFX_DEBUG_SONGS)
|
||||
if (self->_debug & SFX_DEBUG_SONGS)
|
||||
sciprintf("[SFX] Adding song %lx\n", newseeker->it->ID);
|
||||
|
||||
SongIterator *clonesong = newseeker->it->clone(newseeker->_delay);
|
||||
@ -315,14 +315,14 @@ static void _update_multi_song(sfx_state_t *self) {
|
||||
SOUND_STATUS_PLAYING);
|
||||
}
|
||||
|
||||
self->song = newsong;
|
||||
self->_song = newsong;
|
||||
_thaw_time(self);
|
||||
/* _dump_playing_list(self, "after");*/
|
||||
}
|
||||
|
||||
/* Update internal state */
|
||||
static void _update(sfx_state_t *self) {
|
||||
if (self->flags & SFX_STATE_FLAG_MULTIPLAY)
|
||||
static void _update(SfxState *self) {
|
||||
if (self->_flags & SFX_STATE_FLAG_MULTIPLAY)
|
||||
_update_multi_song(self);
|
||||
else
|
||||
_update_single_song(self);
|
||||
@ -344,13 +344,13 @@ int sfx_play_iterator_pcm(SongIterator *it, song_handle_t handle) {
|
||||
|
||||
#define DELAY (1000000 / SFX_TICKS_PER_SEC)
|
||||
|
||||
void sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) {
|
||||
song_lib_init(&self->songlib);
|
||||
self->song = NULL;
|
||||
self->flags = flags;
|
||||
self->debug = 0; /* Disable all debugging by default */
|
||||
self->soundSync = NULL;
|
||||
self->audioResource = NULL;
|
||||
void sfx_init(SfxState *self, ResourceManager *resmgr, int flags) {
|
||||
song_lib_init(&self->_songlib);
|
||||
self->_song = NULL;
|
||||
self->_flags = flags;
|
||||
self->_debug = 0; /* Disable all debugging by default */
|
||||
self->_soundSync = NULL;
|
||||
self->_audioResource = NULL;
|
||||
|
||||
player = NULL;
|
||||
|
||||
@ -386,7 +386,7 @@ void sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags) {
|
||||
}
|
||||
}
|
||||
|
||||
void sfx_exit(sfx_state_t *self) {
|
||||
void sfx_exit(SfxState *self) {
|
||||
#ifdef DEBUG_SONG_API
|
||||
fprintf(stderr, "[sfx-core] Uninitialising\n");
|
||||
#endif
|
||||
@ -399,20 +399,20 @@ void sfx_exit(sfx_state_t *self) {
|
||||
|
||||
g_system->getMixer()->stopAll();
|
||||
|
||||
song_lib_free(self->songlib);
|
||||
song_lib_free(self->_songlib);
|
||||
|
||||
// Delete audio resources for CD talkie games
|
||||
if (self->audioResource) {
|
||||
delete self->audioResource;
|
||||
self->audioResource = 0;
|
||||
if (self->_audioResource) {
|
||||
delete self->_audioResource;
|
||||
self->_audioResource = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void sfx_suspend(sfx_state_t *self, int suspend) {
|
||||
void sfx_suspend(SfxState *self, int suspend) {
|
||||
#ifdef DEBUG_SONG_API
|
||||
fprintf(stderr, "[sfx-core] Suspending? = %d\n", suspend);
|
||||
#endif
|
||||
if (suspend && (!self->suspended)) {
|
||||
if (suspend && (!self->_suspended)) {
|
||||
/* suspend */
|
||||
|
||||
_freeze_time(self);
|
||||
@ -420,7 +420,7 @@ void sfx_suspend(sfx_state_t *self, int suspend) {
|
||||
player->pause();
|
||||
/* Suspend song player */
|
||||
|
||||
} else if (!suspend && (self->suspended)) {
|
||||
} else if (!suspend && (self->_suspended)) {
|
||||
/* unsuspend */
|
||||
|
||||
_thaw_time(self);
|
||||
@ -430,19 +430,19 @@ void sfx_suspend(sfx_state_t *self, int suspend) {
|
||||
/* Unsuspend song player */
|
||||
}
|
||||
|
||||
self->suspended = suspend;
|
||||
self->_suspended = suspend;
|
||||
}
|
||||
|
||||
int sfx_poll(sfx_state_t *self, song_handle_t *handle, int *cue) {
|
||||
int sfx_poll(SfxState *self, song_handle_t *handle, int *cue) {
|
||||
/* 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)
|
||||
*/
|
||||
if (!self->song)
|
||||
if (!self->_song)
|
||||
return 0; /* No milk today */
|
||||
|
||||
*handle = self->song->handle;
|
||||
*handle = self->_song->handle;
|
||||
|
||||
#ifdef DEBUG_SONG_API
|
||||
fprintf(stderr, "[sfx-core] Polling any (%08lx)\n", *handle);
|
||||
@ -450,9 +450,9 @@ int sfx_poll(sfx_state_t *self, song_handle_t *handle, int *cue) {
|
||||
return sfx_poll_specific(self, *handle, cue);
|
||||
}
|
||||
|
||||
int sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue) {
|
||||
int sfx_poll_specific(SfxState *self, song_handle_t handle, int *cue) {
|
||||
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
||||
song_t *song = self->song;
|
||||
song_t *song = self->_song;
|
||||
|
||||
while (song && song->handle != handle)
|
||||
song = song->next_playing;
|
||||
@ -460,7 +460,7 @@ int sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue) {
|
||||
if (!song)
|
||||
return 0; /* Song not playing */
|
||||
|
||||
if (self->debug & SFX_DEBUG_CUES) {
|
||||
if (self->_debug & SFX_DEBUG_CUES) {
|
||||
fprintf(stderr, "[SFX:CUE] Polled song %08lx ", handle);
|
||||
}
|
||||
|
||||
@ -480,7 +480,7 @@ int sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue) {
|
||||
case SI_LOOP:
|
||||
case SI_RELATIVE_CUE:
|
||||
case SI_ABSOLUTE_CUE:
|
||||
if (self->debug & SFX_DEBUG_CUES) {
|
||||
if (self->_debug & SFX_DEBUG_CUES) {
|
||||
sciprintf(" => ");
|
||||
|
||||
if (result == SI_FINISHED)
|
||||
@ -504,7 +504,7 @@ int sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (self->debug & SFX_DEBUG_CUES) {
|
||||
if (self->_debug & SFX_DEBUG_CUES) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
@ -514,8 +514,8 @@ int sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue) {
|
||||
/* Song basics */
|
||||
/*****************/
|
||||
|
||||
int sfx_add_song(sfx_state_t *self, SongIterator *it, int priority, song_handle_t handle, int number) {
|
||||
song_t *song = song_lib_find(self->songlib, handle);
|
||||
int sfx_add_song(SfxState *self, SongIterator *it, int priority, song_handle_t handle, int number) {
|
||||
song_t *song = song_lib_find(self->_songlib, handle);
|
||||
|
||||
#ifdef DEBUG_SONG_API
|
||||
fprintf(stderr, "[sfx-core] Adding song: %08lx at %d, it=%p\n", handle, priority, it);
|
||||
@ -545,7 +545,7 @@ int sfx_add_song(sfx_state_t *self, SongIterator *it, int priority, song_handle_
|
||||
delete it;
|
||||
return -1;
|
||||
} else
|
||||
song_lib_remove(self->songlib, handle); /* No duplicates */
|
||||
song_lib_remove(self->_songlib, handle); /* No duplicates */
|
||||
|
||||
}
|
||||
|
||||
@ -554,21 +554,21 @@ int sfx_add_song(sfx_state_t *self, SongIterator *it, int priority, song_handle_
|
||||
song->hold = 0;
|
||||
song->loops = 0;
|
||||
song->_wakeupTime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
|
||||
song_lib_add(self->songlib, song);
|
||||
self->song = NULL; /* As above */
|
||||
song_lib_add(self->_songlib, song);
|
||||
self->_song = NULL; /* As above */
|
||||
_update(self);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sfx_remove_song(sfx_state_t *self, song_handle_t handle) {
|
||||
void sfx_remove_song(SfxState *self, song_handle_t handle) {
|
||||
#ifdef DEBUG_SONG_API
|
||||
fprintf(stderr, "[sfx-core] Removing song: %08lx\n", handle);
|
||||
#endif
|
||||
if (self->song && self->song->handle == handle)
|
||||
self->song = NULL;
|
||||
if (self->_song && self->_song->handle == handle)
|
||||
self->_song = NULL;
|
||||
|
||||
song_lib_remove(self->songlib, handle);
|
||||
song_lib_remove(self->_songlib, handle);
|
||||
_update(self);
|
||||
}
|
||||
|
||||
@ -580,8 +580,8 @@ void sfx_remove_song(sfx_state_t *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; }
|
||||
|
||||
void sfx_song_set_status(sfx_state_t *self, song_handle_t handle, int status) {
|
||||
song_t *song = song_lib_find(self->songlib, handle);
|
||||
void sfx_song_set_status(SfxState *self, song_handle_t handle, int status) {
|
||||
song_t *song = song_lib_find(self->_songlib, handle);
|
||||
ASSERT_SONG(song);
|
||||
#ifdef DEBUG_SONG_API
|
||||
fprintf(stderr, "[sfx-core] Setting song status to %d"
|
||||
@ -593,12 +593,12 @@ void sfx_song_set_status(sfx_state_t *self, song_handle_t handle, int status) {
|
||||
_update(self);
|
||||
}
|
||||
|
||||
void sfx_song_set_fade(sfx_state_t *self, song_handle_t handle,
|
||||
void sfx_song_set_fade(SfxState *self, song_handle_t handle,
|
||||
fade_params_t *params) {
|
||||
#ifdef DEBUG_SONG_API
|
||||
static const char *stopmsg[] = {"??? Should not happen", "Do not stop afterwards", "Stop afterwards"};
|
||||
#endif
|
||||
song_t *song = song_lib_find(self->songlib, handle);
|
||||
song_t *song = song_lib_find(self->_songlib, handle);
|
||||
|
||||
ASSERT_SONG(song);
|
||||
|
||||
@ -614,8 +614,8 @@ void sfx_song_set_fade(sfx_state_t *self, song_handle_t handle,
|
||||
_update(self);
|
||||
}
|
||||
|
||||
void sfx_song_renice(sfx_state_t *self, song_handle_t handle, int priority) {
|
||||
song_t *song = song_lib_find(self->songlib, handle);
|
||||
void sfx_song_renice(SfxState *self, song_handle_t handle, int priority) {
|
||||
song_t *song = song_lib_find(self->_songlib, handle);
|
||||
ASSERT_SONG(song);
|
||||
#ifdef DEBUG_SONG_API
|
||||
fprintf(stderr, "[sfx-core] Renicing song %08lx to %d\n",
|
||||
@ -627,8 +627,8 @@ void sfx_song_renice(sfx_state_t *self, song_handle_t handle, int priority) {
|
||||
_update(self);
|
||||
}
|
||||
|
||||
void sfx_song_set_loops(sfx_state_t *self, song_handle_t handle, int loops) {
|
||||
song_t *song = song_lib_find(self->songlib, handle);
|
||||
void sfx_song_set_loops(SfxState *self, song_handle_t handle, int loops) {
|
||||
song_t *song = song_lib_find(self->_songlib, handle);
|
||||
SongIterator::Message msg = SongIterator::Message(handle, SIMSG_SET_LOOPS(loops));
|
||||
ASSERT_SONG(song);
|
||||
|
||||
@ -644,8 +644,8 @@ void sfx_song_set_loops(sfx_state_t *self, song_handle_t handle, int loops) {
|
||||
player->iterator_message(msg);
|
||||
}
|
||||
|
||||
void sfx_song_set_hold(sfx_state_t *self, song_handle_t handle, int hold) {
|
||||
song_t *song = song_lib_find(self->songlib, handle);
|
||||
void sfx_song_set_hold(SfxState *self, song_handle_t handle, int hold) {
|
||||
song_t *song = song_lib_find(self->_songlib, handle);
|
||||
SongIterator::Message msg = SongIterator::Message(handle, SIMSG_SET_HOLD(hold));
|
||||
ASSERT_SONG(song);
|
||||
|
||||
@ -668,7 +668,7 @@ static const int MIDI_cmdlen[16] = {0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
static const song_handle_t midi_send_base = 0xffff0000;
|
||||
|
||||
Common::Error sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
|
||||
Common::Error sfx_send_midi(SfxState *self, song_handle_t handle, int channel,
|
||||
int command, int arg1, int arg2) {
|
||||
byte buffer[5];
|
||||
|
||||
@ -713,21 +713,21 @@ Common::Error sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
int sfx_get_volume(sfx_state_t *self) {
|
||||
int sfx_get_volume(SfxState *self) {
|
||||
warning("FIXME: Implement volume");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sfx_set_volume(sfx_state_t *self, int volume) {
|
||||
void sfx_set_volume(SfxState *self, int volume) {
|
||||
warning("FIXME: Implement volume");
|
||||
}
|
||||
|
||||
void sfx_all_stop(sfx_state_t *self) {
|
||||
void sfx_all_stop(SfxState *self) {
|
||||
#ifdef DEBUG_SONG_API
|
||||
fprintf(stderr, "[sfx-core] All stop\n");
|
||||
#endif
|
||||
|
||||
song_lib_free(self->songlib);
|
||||
song_lib_free(self->_songlib);
|
||||
_update(self);
|
||||
}
|
||||
|
||||
|
@ -48,61 +48,62 @@ struct fade_params_t;
|
||||
#define SFX_DEBUG_CUES (1 << 1) /* Debug cues, loops, and
|
||||
** song completions */
|
||||
|
||||
struct sfx_state_t {
|
||||
SongIterator *it; /* The song iterator at the heart of things */
|
||||
unsigned int flags; /* SFX_STATE_FLAG_* */
|
||||
songlib_t songlib; /* Song library */
|
||||
song_t *song; /* Active song, or start of active song chain */
|
||||
int suspended; /* Whether we are suspended */
|
||||
unsigned int debug; /* Debug flags */
|
||||
ResourceSync *soundSync; /* Used by kDoSync for speech syncing in CD talkie games */
|
||||
AudioResource *audioResource; /* Used for audio resources in CD talkie games */
|
||||
class SfxState {
|
||||
public: // FIXME, make private
|
||||
SongIterator *_it; /**< The song iterator at the heart of things */
|
||||
uint _flags; /**< SFX_STATE_FLAG_* */
|
||||
songlib_t _songlib; /**< Song library */
|
||||
song_t *_song; /**< Active song, or start of active song chain */
|
||||
bool _suspended; /**< Whether we are suspended */
|
||||
uint _debug; /**< Debug flags */
|
||||
ResourceSync *_soundSync; /**< Used by kDoSync for speech syncing in CD talkie games */
|
||||
AudioResource *_audioResource; /**< Used for audio resources in CD talkie games */
|
||||
};
|
||||
|
||||
/***********/
|
||||
/* General */
|
||||
/***********/
|
||||
|
||||
void sfx_init(sfx_state_t *self, ResourceManager *resmgr, int flags);
|
||||
void sfx_init(SfxState *self, ResourceManager *resmgr, int flags);
|
||||
/* Initializes the sound engine
|
||||
** Parameters: (ResourceManager *) resmgr: Resource manager for initialization
|
||||
** (int) flags: SFX_STATE_FLAG_*
|
||||
*/
|
||||
|
||||
void sfx_exit(sfx_state_t *self);
|
||||
void sfx_exit(SfxState *self);
|
||||
/* Deinitializes the sound subsystem
|
||||
*/
|
||||
|
||||
void sfx_suspend(sfx_state_t *self, int suspend);
|
||||
void sfx_suspend(SfxState *self, int suspend);
|
||||
/* Suspends/unsuspends the sound sybsystem
|
||||
** Parameters: (int) suspend: Whether to suspend (non-null) or to unsuspend
|
||||
*/
|
||||
|
||||
int sfx_poll(sfx_state_t *self, song_handle_t *handle, int *cue);
|
||||
int sfx_poll(SfxState *self, song_handle_t *handle, int *cue);
|
||||
/* 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_specific(sfx_state_t *self, song_handle_t handle, int *cue);
|
||||
int sfx_poll_specific(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_get_volume(sfx_state_t *self);
|
||||
int sfx_get_volume(SfxState *self);
|
||||
/* Determines the current global volume settings
|
||||
** Returns : (int) The global volume, between 0 (silent) and 127 (max. volume)
|
||||
*/
|
||||
|
||||
void sfx_set_volume(sfx_state_t *self, int volume);
|
||||
void sfx_set_volume(SfxState *self, int volume);
|
||||
/* Determines the current global volume settings
|
||||
** Parameters: (int) volume: The new global volume, between 0 and 127 (see above)
|
||||
*/
|
||||
|
||||
void sfx_all_stop(sfx_state_t *self);
|
||||
void sfx_all_stop(SfxState *self);
|
||||
/* Stops all songs currently playing, purges song library
|
||||
*/
|
||||
|
||||
@ -111,7 +112,7 @@ void sfx_all_stop(sfx_state_t *self);
|
||||
/* Song basics */
|
||||
/*****************/
|
||||
|
||||
int sfx_add_song(sfx_state_t *self, SongIterator *it, int priority, song_handle_t handle, int resnum);
|
||||
int sfx_add_song(SfxState *self, SongIterator *it, int priority, song_handle_t handle, int resnum);
|
||||
/* Adds a song to the internal sound library
|
||||
** Parameters: (SongIterator *) it: The iterator describing the song
|
||||
** (int) priority: Initial song priority (higher <-> more important)
|
||||
@ -120,7 +121,7 @@ int sfx_add_song(sfx_state_t *self, SongIterator *it, int priority, song_handle_
|
||||
*/
|
||||
|
||||
|
||||
void sfx_remove_song(sfx_state_t *self, song_handle_t handle);
|
||||
void sfx_remove_song(SfxState *self, song_handle_t handle);
|
||||
/* Deletes a song and its associated song iterator from the song queue
|
||||
** Parameters: (song_handle_t) handle: The song to remove
|
||||
*/
|
||||
@ -131,7 +132,7 @@ void sfx_remove_song(sfx_state_t *self, song_handle_t handle);
|
||||
/**********************/
|
||||
|
||||
|
||||
void sfx_song_set_status(sfx_state_t *self, song_handle_t handle, int status);
|
||||
void sfx_song_set_status(SfxState *self, song_handle_t handle, int status);
|
||||
/* 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
|
||||
@ -139,25 +140,25 @@ void sfx_song_set_status(sfx_state_t *self, song_handle_t handle, int status);
|
||||
** as far as this function is concerned.
|
||||
*/
|
||||
|
||||
void sfx_song_renice(sfx_state_t *self, song_handle_t handle, int priority);
|
||||
void sfx_song_renice(SfxState *self, song_handle_t handle, int priority);
|
||||
/* Sets the new song priority
|
||||
** Parameters: (song_handle_t) handle: The handle to modify
|
||||
** (int) priority: The priority to set
|
||||
*/
|
||||
|
||||
void sfx_song_set_loops(sfx_state_t *self, song_handle_t handle, int loops);
|
||||
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) loops: Number of loops to set
|
||||
*/
|
||||
|
||||
void sfx_song_set_hold(sfx_state_t *self, song_handle_t handle, int hold);
|
||||
void sfx_song_set_hold(SfxState *self, song_handle_t handle, int hold);
|
||||
/* 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_fade(sfx_state_t *self, song_handle_t handle, fade_params_t *fade_setup);
|
||||
void sfx_song_set_fade(SfxState *self, song_handle_t handle, fade_params_t *fade_setup);
|
||||
/* 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
|
||||
@ -165,7 +166,7 @@ void sfx_song_set_fade(sfx_state_t *self, song_handle_t handle, fade_params_t *f
|
||||
|
||||
|
||||
// Previously undocumented:
|
||||
Common::Error sfx_send_midi(sfx_state_t *self, song_handle_t handle, int channel,
|
||||
Common::Error sfx_send_midi(SfxState *self, song_handle_t handle, int channel,
|
||||
int command, int arg1, int arg2);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user