aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2014-07-20 16:17:22 +0300
committerFilippos Karapetis2014-07-20 17:10:55 +0300
commite663395435764f14fcf9b561af408b25521d16ce (patch)
tree8c3fe18fbc489e586c3a4eb189a3a9192fc93e1d /engines
parentb14a2599bcbb5fcec2e860e048081751dbde8162 (diff)
downloadscummvm-rg350-e663395435764f14fcf9b561af408b25521d16ce.tar.gz
scummvm-rg350-e663395435764f14fcf9b561af408b25521d16ce.tar.bz2
scummvm-rg350-e663395435764f14fcf9b561af408b25521d16ce.zip
SAGA: Add wrappers for queuing music events
Diffstat (limited to 'engines')
-rw-r--r--engines/saga/events.cpp12
-rw-r--r--engines/saga/events.h9
-rw-r--r--engines/saga/introproc_ite.cpp16
-rw-r--r--engines/saga/scene.cpp8
-rw-r--r--engines/saga/sfuncs_ihnm.cpp9
5 files changed, 25 insertions, 29 deletions
diff --git a/engines/saga/events.cpp b/engines/saga/events.cpp
index 013b019c9f..b7c3fa4d6e 100644
--- a/engines/saga/events.cpp
+++ b/engines/saga/events.cpp
@@ -583,6 +583,18 @@ EventColumns *Events::chain(EventColumns *eventColumns, const Event &event) {
return eventColumns;
}
+EventColumns *Events::chainMusic(EventColumns *eventColumns, long musicId, bool loop, long time) {
+ Event event;
+
+ event.type = kEvTOneshot;
+ event.code = kMusicEvent;
+ event.param = musicId;
+ event.param2 = loop ? MUSIC_NORMAL : MUSIC_LOOP;
+ event.op = kEventPlay;
+ event.time = time;
+ return chain(eventColumns, event);
+}
+
void Events::initializeEvent(Event &event) {
switch (event.type) {
case kEvTOneshot:
diff --git a/engines/saga/events.h b/engines/saga/events.h
index 6c423abb8c..84a62f5a3a 100644
--- a/engines/saga/events.h
+++ b/engines/saga/events.h
@@ -172,9 +172,18 @@ class Events {
return chain(NULL, event);
}
+ // Schedules a music event in the event list; returns a pointer to the scheduled
+ // event columns suitable for chaining if desired.
+ EventColumns *queueMusic(long musicId, bool loop = false, long time = 0) {
+ return chainMusic(NULL, musicId, loop, time);
+ }
+
// Places a 'event' on the end of an event columns given by 'eventColumns'
EventColumns *chain(EventColumns *eventColumns, const Event &event);
+ // Places a music 'event' on the end of an event columns given by 'eventColumns'
+ EventColumns *chainMusic(EventColumns *eventColumns, long musicId, bool loop = false, long time = 0);
+
private:
int handleContinuous(Event *event);
int handleOneShot(Event *event);
diff --git a/engines/saga/introproc_ite.cpp b/engines/saga/introproc_ite.cpp
index 33c757297f..ded1d1cd0e 100644
--- a/engines/saga/introproc_ite.cpp
+++ b/engines/saga/introproc_ite.cpp
@@ -365,13 +365,7 @@ int Scene::ITEIntroAnimProc(int param) {
_vm->_events->chain(eventColumns, event);
// Queue intro music playback
- event.type = kEvTOneshot;
- event.code = kMusicEvent;
- event.param = MUSIC_INTRO;
- event.param2 = MUSIC_LOOP;
- event.op = kEventPlay;
- event.time = 0;
- _vm->_events->chain(eventColumns, event);
+ _vm->_events->chainMusic(eventColumns, MUSIC_INTRO, true);
}
break;
case SCENE_END:
@@ -868,13 +862,7 @@ int Scene::ITEIntroValleyProc(int param) {
// Begin ITE title theme music
_vm->_music->stop();
- event.type = kEvTOneshot;
- event.code = kMusicEvent;
- event.param = MUSIC_TITLE_THEME;
- event.param2 = MUSIC_NORMAL;
- event.op = kEventPlay;
- event.time = 0;
- _vm->_events->chain(eventColumns, event);
+ _vm->_events->chainMusic(eventColumns, MUSIC_TITLE_THEME);
// Pause animation before logo
event.type = kEvTOneshot;
diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp
index e94effee07..f19645dd99 100644
--- a/engines/saga/scene.cpp
+++ b/engines/saga/scene.cpp
@@ -789,13 +789,7 @@ void Scene::loadScene(LoadSceneParams &loadSceneParams) {
if (_vm->getGameId() == GID_ITE) {
if (_sceneDescription.musicResourceId >= 0) {
- event.type = kEvTOneshot;
- event.code = kMusicEvent;
- event.param = _sceneDescription.musicResourceId;
- event.param2 = MUSIC_NORMAL;
- event.op = kEventPlay;
- event.time = 0;
- _vm->_events->queue(event);
+ _vm->_events->queueMusic(_sceneDescription.musicResourceId);
} else {
event.type = kEvTOneshot;
event.code = kMusicEvent;
diff --git a/engines/saga/sfuncs_ihnm.cpp b/engines/saga/sfuncs_ihnm.cpp
index 6957360942..e3e3c1ca11 100644
--- a/engines/saga/sfuncs_ihnm.cpp
+++ b/engines/saga/sfuncs_ihnm.cpp
@@ -421,14 +421,7 @@ void Script::sfQueueMusic(SCRIPTFUNC_PARAMS) {
warning("sfQueueMusic: Wrong song number (%d > %d)", param1, _vm->_music->_songTable.size() - 1);
} else {
_vm->_music->setVolume(_vm->_musicVolume, 1);
- event.type = kEvTOneshot;
- event.code = kMusicEvent;
- event.param = _vm->_music->_songTable[param1];
- event.param2 = param2 ? MUSIC_LOOP : MUSIC_NORMAL;
- event.op = kEventPlay;
- event.time = _vm->ticksToMSec(1000);
-
- _vm->_events->queue(event);
+ _vm->_events->queueMusic(_vm->_music->_songTable[param1], param2, _vm->ticksToMSec(1000));
if (!_vm->_scene->haveChapterPointsChanged()) {
_vm->_scene->setCurrentMusicTrack(param1);