aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2005-08-30 11:16:11 +0000
committerEugene Sandulenko2005-08-30 11:16:11 +0000
commit349ab2007a23844a6e2b34d07775ebdd2b7c7158 (patch)
tree561bd1a8e0a8a9d4c8e589a621b2a096e475e004
parent43fc9012847e2a94e16392737b8cebf2e1fd1f18 (diff)
downloadscummvm-rg350-349ab2007a23844a6e2b34d07775ebdd2b7c7158.tar.gz
scummvm-rg350-349ab2007a23844a6e2b34d07775ebdd2b7c7158.tar.bz2
scummvm-rg350-349ab2007a23844a6e2b34d07775ebdd2b7c7158.zip
Implement sfPlayMusic for IHNM
svn-id: r18717
-rw-r--r--saga/music.cpp5
-rw-r--r--saga/music.h3
-rw-r--r--saga/rscfile.cpp21
-rw-r--r--saga/sfuncs.cpp15
4 files changed, 40 insertions, 4 deletions
diff --git a/saga/music.cpp b/saga/music.cpp
index eb12c5383b..028af66141 100644
--- a/saga/music.cpp
+++ b/saga/music.cpp
@@ -274,6 +274,9 @@ Music::Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver, int enable
smfParser = MidiParser::createParser_SMF();
_musicContext = _vm->_resource->getContext(GAME_MUSICFILE);
+
+ _songTableLen = 0;
+ _songTable = 0;
}
Music::~Music() {
@@ -283,6 +286,8 @@ Music::~Music() {
smfParser->setMidiDriver(NULL);
delete xmidiParser;
delete smfParser;
+
+ free(_songTable);
}
void Music::musicVolumeGaugeCallback(void *refCon) {
diff --git a/saga/music.h b/saga/music.h
index bb7d1f6d7e..05f8b49174 100644
--- a/saga/music.h
+++ b/saga/music.h
@@ -114,6 +114,9 @@ public:
void setVolume(int volume, int time = 1);
int getVolume() { return _currentVolume; }
+ int32 *_songTable;
+ int _songTableLen;
+
private:
SagaEngine *_vm;
Audio::Mixer *_mixer;
diff --git a/saga/rscfile.cpp b/saga/rscfile.cpp
index bd03068541..7a328c8158 100644
--- a/saga/rscfile.cpp
+++ b/saga/rscfile.cpp
@@ -26,6 +26,7 @@
#include "saga/actor.h"
#include "saga/interface.h"
+#include "saga/music.h"
#include "saga/rscfile.h"
#include "saga/sndres.h"
#include "saga/stream.h"
@@ -505,6 +506,7 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) {
_vm->_sndRes->_fxTable[i].res = fxS.readSint16LE();
_vm->_sndRes->_fxTable[i].vol = fxS.readSint16LE();
}
+ free(resourcePointer);
_vm->_interface->_defPortraits.freeMem();
_vm->_sprite->loadList(_metaResource.protagFaceSpritesID, _vm->_interface->_defPortraits);
@@ -520,7 +522,24 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) {
// TODO: cutawayList
- // TODO: songTable
+ // TODO: songTable Long
+ _vm->_resource->loadResource(resourceContext, _metaResource.songTableID,
+ resourcePointer, resourceLength);
+
+ if (resourceLength == 0) {
+ error("Resource::loadGlobalResources Can't load songs list for current track");
+ }
+
+ free(_vm->_music->_songTable);
+
+ _vm->_music->_songTableLen = resourceLength / 4;
+ _vm->_music->_songTable = (int32 *)malloc(sizeof(int32) * _vm->_music->_songTableLen);
+
+ MemoryReadStream songS(resourcePointer, resourceLength);
+
+ for (int i = 0; i < _vm->_music->_songTableLen; i++)
+ _vm->_music->_songTable[i] = songS.readSint32LE();
+ free(resourcePointer);
int voiceLUTResourceID = 0;
diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp
index eeff7361e9..ec0020967c 100644
--- a/saga/sfuncs.cpp
+++ b/saga/sfuncs.cpp
@@ -1640,11 +1640,20 @@ void Script::sfPlayMusic(SCRIPTFUNC_PARAMS) {
_vm->_music->stop();
}
} else {
- // TODO: Verify this
- int16 param1 = thread->pop() + 32;
+ int16 param1 = thread->pop();
int16 param2 = thread->pop();
- _vm->_music->play(param1, param2 ? MUSIC_LOOP: MUSIC_NORMAL);
+ if (param1 < 1) {
+ _vm->_music->stop();
+ return;
+ }
+
+ if (param1 > _vm->_music->_songTableLen) {
+ warning("sfPlayMusic: Wrong song number (%d > %d)", param1, _vm->_music->_songTableLen);
+ } else {
+ _vm->_music->setVolume(-1, 1);
+ _vm->_music->play(_vm->_music->_songTable[param1], param2 ? MUSIC_LOOP: MUSIC_NORMAL);
+ }
}
}