aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJohannes Schickel2008-04-06 14:11:43 +0000
committerJohannes Schickel2008-04-06 14:11:43 +0000
commit22992f4aa5a4684a736f6e8daa957735c3389c03 (patch)
tree8729bed5b6168782955c49215e5b3b24c9cfbe88 /engines
parenta2e355d6715ffd6aa121c7dfdc357e56906c9ae8 (diff)
downloadscummvm-rg350-22992f4aa5a4684a736f6e8daa957735c3389c03.tar.gz
scummvm-rg350-22992f4aa5a4684a736f6e8daa957735c3389c03.tar.bz2
scummvm-rg350-22992f4aa5a4684a736f6e8daa957735c3389c03.zip
Implemented opcode 33 o2_loadSoundfile.
svn-id: r31425
Diffstat (limited to 'engines')
-rw-r--r--engines/kyra/kyra_v2.h1
-rw-r--r--engines/kyra/script_v2.cpp9
-rw-r--r--engines/kyra/sound.cpp3
-rw-r--r--engines/kyra/sound.h8
4 files changed, 20 insertions, 1 deletions
diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h
index 1475fc5d13..37cf51604a 100644
--- a/engines/kyra/kyra_v2.h
+++ b/engines/kyra/kyra_v2.h
@@ -950,6 +950,7 @@ protected:
int o2_drawShape(ScriptState *script);
int o2_addItemToCurScene(ScriptState *script);
int o2_checkForItem(ScriptState *script);
+ int o2_loadSoundFile(ScriptState *script);
int o2_removeItemSlotFromInventory(ScriptState *script);
int o2_defineItem(ScriptState *script);
int o2_removeItemFromInventory(ScriptState *script);
diff --git a/engines/kyra/script_v2.cpp b/engines/kyra/script_v2.cpp
index 77efc780a7..8bd4bb9df7 100644
--- a/engines/kyra/script_v2.cpp
+++ b/engines/kyra/script_v2.cpp
@@ -456,6 +456,13 @@ int KyraEngine_v2::o2_checkForItem(ScriptState *script) {
return findItem(stackPos(0), stackPos(1)) == -1 ? 0 : 1;
}
+int KyraEngine_v2::o2_loadSoundFile(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v2::o2_loadSoundFile(%p) (%d)", (const void *)script, stackPos(0));
+ if (_sound->hasTrack(stackPos(0)))
+ snd_playTheme(stackPos(0));
+ return 0;
+}
+
int KyraEngine_v2::o2_removeItemSlotFromInventory(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v2::o2_removeItemSlotFromInventory(%p) (%d)", (const void *)script, stackPos(0));
removeItemFromInventory(stackPos(0));
@@ -1839,7 +1846,7 @@ void KyraEngine_v2::setupOpcodeTable() {
OpcodeUnImpl(),
// 0x20
Opcode(o2_checkForItem),
- OpcodeUnImpl(),
+ Opcode(o2_loadSoundFile),
Opcode(o2_removeItemSlotFromInventory),
Opcode(o2_defineItem),
// 0x24
diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp
index 7e447e33c6..bcbc2b78df 100644
--- a/engines/kyra/sound.cpp
+++ b/engines/kyra/sound.cpp
@@ -489,6 +489,9 @@ void SoundMidiPC::beginFadeOut() {
void KyraEngine::snd_playTheme(int file, int track) {
debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_playTheme(%d)", file);
+ if (_curMusicTheme == file)
+ return;
+
_curSfxFile = _curMusicTheme = file;
_sound->loadSoundFile(_curMusicTheme);
_sound->playTrack(track);
diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h
index 70936b0191..abbffe16d2 100644
--- a/engines/kyra/sound.h
+++ b/engines/kyra/sound.h
@@ -105,6 +105,14 @@ public:
virtual void setSoundList(const AudioDataStruct *list) { _soundDataList = list; }
/**
+ * Checks if a given sound file is present
+ *
+ * @param track track number
+ * @return true if available, false otherwise
+ */
+ virtual bool hasTrack(uint file) { return (fileListEntry(file) != 0); }
+
+ /**
* Load a specifc sound file for use of
* playing music and sound effects.
*/