aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/he
diff options
context:
space:
mode:
authorMax Horn2006-04-23 18:52:39 +0000
committerMax Horn2006-04-23 18:52:39 +0000
commitd68f95b3be82fe0048b6ba72f70b80887214a0e6 (patch)
treeadd586af344a76ffe43ae8c6475207c12a851e47 /engines/scumm/he
parent78dfa1f28062378b98b204e9e10c4a8f182cf4c9 (diff)
downloadscummvm-rg350-d68f95b3be82fe0048b6ba72f70b80887214a0e6.tar.gz
scummvm-rg350-d68f95b3be82fe0048b6ba72f70b80887214a0e6.tar.bz2
scummvm-rg350-d68f95b3be82fe0048b6ba72f70b80887214a0e6.zip
Move HE specific stuff from class Sound to its new subclass SoundHE
svn-id: r22115
Diffstat (limited to 'engines/scumm/he')
-rw-r--r--engines/scumm/he/resource_he.cpp4
-rw-r--r--engines/scumm/he/script_v100he.cpp4
-rw-r--r--engines/scumm/he/script_v60he.cpp4
-rw-r--r--engines/scumm/he/script_v70he.cpp4
-rw-r--r--engines/scumm/he/script_v72he.cpp4
-rw-r--r--engines/scumm/he/script_v80he.cpp4
-rw-r--r--engines/scumm/he/sound_he.cpp146
-rw-r--r--engines/scumm/he/sound_he.h74
8 files changed, 218 insertions, 26 deletions
diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp
index 13d78c5517..11f25991e7 100644
--- a/engines/scumm/he/resource_he.cpp
+++ b/engines/scumm/he/resource_he.cpp
@@ -30,7 +30,7 @@
#include "scumm/he/intern_he.h"
#include "scumm/resource.h"
#include "scumm/he/resource_he.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
#include "sound/wave.h"
@@ -1762,7 +1762,7 @@ int ScummEngine_v72he::getSoundResourceSize(int id) {
int offs, size;
if (id > _numSounds) {
- if (!_sound->getHEMusicDetails(id, offs, size)) {
+ if (!((SoundHE *)_sound)->getHEMusicDetails(id, offs, size)) {
debug(0, "getSoundResourceSize: musicID %d not found", id);
return 0;
}
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 1e27977e0a..1551eca420 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -32,7 +32,7 @@
#include "scumm/resource.h"
#include "scumm/he/resource_he.h"
#include "scumm/scumm.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
#include "scumm/he/sprite_he.h"
#include "scumm/util.h"
@@ -1714,7 +1714,7 @@ void ScummEngine_v100he::o100_startSound() {
value = pop();
var = pop();
_heSndSoundId = pop();
- _sound->setSoundVar(_heSndSoundId, var, value);
+ ((SoundHE *)_sound)->setSoundVar(_heSndSoundId, var, value);
break;
case 92:
_sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags);
diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp
index 6d562cc163..d3748abb85 100644
--- a/engines/scumm/he/script_v60he.cpp
+++ b/engines/scumm/he/script_v60he.cpp
@@ -31,7 +31,7 @@
#include "scumm/object.h"
#include "scumm/resource.h"
#include "scumm/scumm.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
#include "scumm/usage_bits.h"
#include "scumm/util.h"
#include "scumm/verbs.h"
@@ -1151,7 +1151,7 @@ void ScummEngine_v60he::o60_soundOps() {
// Fatty Bear's Birthday surprise uses this when playing the
// piano, but only when using one of the digitized instruments.
// See also o6_startSound().
- _sound->setOverrideFreq(arg);
+ ((SoundHE *)_sound)->setOverrideFreq(arg);
break;
default:
error("o60_soundOps: default case 0x%x", subOp);
diff --git a/engines/scumm/he/script_v70he.cpp b/engines/scumm/he/script_v70he.cpp
index 15536fe895..bbbc218fde 100644
--- a/engines/scumm/he/script_v70he.cpp
+++ b/engines/scumm/he/script_v70he.cpp
@@ -33,7 +33,7 @@
#include "scumm/resource.h"
#include "scumm/he/resource_he.h"
#include "scumm/scumm.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
#include "scumm/verbs.h"
namespace Scumm {
@@ -438,7 +438,7 @@ void ScummEngine_v70he::o70_startSound() {
value = pop();
var = pop();
_heSndSoundId = pop();
- _sound->setSoundVar(_heSndSoundId, var, value);
+ ((SoundHE *)_sound)->setSoundVar(_heSndSoundId, var, value);
break;
case 25:
value = pop();
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index dea6e6a9ed..7f61a4fcbc 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -35,7 +35,7 @@
#include "scumm/resource.h"
#include "scumm/he/resource_he.h"
#include "scumm/scumm.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
#include "scumm/util.h"
#include "scumm/verbs.h"
@@ -847,7 +847,7 @@ void ScummEngine_v72he::o72_setTimer() {
void ScummEngine_v72he::o72_getSoundPosition() {
int snd = pop();
- push(_sound->getSoundPos(snd));
+ push(((SoundHE *)_sound)->getSoundPos(snd));
}
void ScummEngine_v72he::o72_startScript() {
diff --git a/engines/scumm/he/script_v80he.cpp b/engines/scumm/he/script_v80he.cpp
index cfcac4299a..8735e920c7 100644
--- a/engines/scumm/he/script_v80he.cpp
+++ b/engines/scumm/he/script_v80he.cpp
@@ -34,7 +34,7 @@
#include "scumm/resource.h"
#include "scumm/he/resource_he.h"
#include "scumm/scumm.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
namespace Scumm {
@@ -432,7 +432,7 @@ void ScummEngine_v80he::o80_stringToInt() {
void ScummEngine_v80he::o80_getSoundVar() {
int var = pop();
int snd = pop();
- push(_sound->getSoundVar(snd, var));
+ push(((SoundHE *)_sound)->getSoundVar(snd, var));
}
void ScummEngine_v80he::o80_localizeArrayToRoom() {
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index 86221aea88..e1bb5095c4 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -26,7 +26,7 @@
#include "scumm/file.h"
#include "scumm/imuse/imuse.h"
#include "scumm/scumm.h"
-#include "scumm/sound.h"
+#include "scumm/he/sound_he.h"
#include "scumm/util.h"
#include "common/config-manager.h"
@@ -45,7 +45,125 @@
namespace Scumm {
-void Sound::stopSoundChannel(int chan) {
+SoundHE::SoundHE(ScummEngine *parent)
+ :
+ Sound(parent),
+ _heMusic(0),
+ _heMusicTracks(0) {
+
+ memset(_heChannel, 0, sizeof(_heChannel));
+}
+
+SoundHE::~SoundHE() {
+ free(_heMusic);
+}
+
+void SoundHE::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags) {
+ if (_vm->VAR_LAST_SOUND != 0xFF)
+ _vm->VAR(_vm->VAR_LAST_SOUND) = sound;
+
+ if (heFlags & 16) {
+ playHESound(sound, heOffset, heChannel, heFlags);
+ return;
+ }
+
+ Sound::addSoundToQueue(sound, heOffset, heChannel, heFlags);
+}
+
+void SoundHE::addSoundToQueue2(int sound, int heOffset, int heChannel, int heFlags) {
+ int i = _soundQue2Pos;
+ while (i--) {
+ if (_soundQue2[i].sound == sound && !(heFlags & 2))
+ return;
+ }
+
+ Sound::addSoundToQueue2(sound, heOffset, heChannel, heFlags);
+}
+
+void SoundHE::processSoundQueues() {
+ int snd, heOffset, heChannel, heFlags;
+
+ if (_vm->_game.heversion >= 72) {
+ for (int i = 0; i <_soundQue2Pos; i++) {
+ snd = _soundQue2[i].sound;
+ heOffset = _soundQue2[i].offset;
+ heChannel = _soundQue2[i].channel;
+ heFlags = _soundQue2[i].flags;
+ if (snd)
+ playHESound(snd, heOffset, heChannel, heFlags);
+ }
+ _soundQue2Pos = 0;
+ } else {
+ while (_soundQue2Pos) {
+ _soundQue2Pos--;
+ snd = _soundQue2[_soundQue2Pos].sound;
+ heOffset = _soundQue2[_soundQue2Pos].offset;
+ heChannel = _soundQue2[_soundQue2Pos].channel;
+ heFlags = _soundQue2[_soundQue2Pos].flags;
+ if (snd)
+ playHESound(snd, heOffset, heChannel, heFlags);
+ }
+ }
+
+ Sound::processSoundQueues();
+}
+
+int SoundHE::isSoundRunning(int sound) const {
+ if (_vm->_game.heversion >= 70) {
+ if (sound >= 10000) {
+ return _vm->_mixer->getSoundID(_heSoundChannels[sound - 10000]);
+ }
+ } else if (_vm->_game.heversion >= 60) {
+ if (sound == -2) {
+ sound = _heChannel[0].sound;
+ } else if (sound == -1) {
+ sound = _currentMusic;
+ }
+ }
+
+ return Sound::isSoundRunning(sound);
+}
+
+void SoundHE::stopSound(int sound) {
+ if (_vm->_game.heversion >= 70) {
+ if ( sound >= 10000) {
+ stopSoundChannel(sound - 10000);
+ }
+ } else if (_vm->_game.heversion >= 60) {
+ if (sound == -2) {
+ sound = _heChannel[0].sound;
+ } else if (sound == -1) {
+ sound = _currentMusic;
+ }
+ }
+
+ Sound::stopSound(sound);
+
+ for (int i = 0; i < ARRAYSIZE(_heChannel); i++) {
+ if (_heChannel[i].sound == sound) {
+ _heChannel[i].sound = 0;
+ _heChannel[i].priority = 0;
+ _heChannel[i].sbngBlock = 0;
+ _heChannel[i].codeOffs = 0;
+ memset(_heChannel[i].soundVars, 0, sizeof(_heChannel[i].soundVars));
+ }
+ }
+
+ if (_vm->_game.heversion >= 70 && sound == 1) {
+ _vm->_haveMsg = 3;
+ _vm->_talkDelay = 0;
+ }
+}
+
+void SoundHE::setupSound() {
+ Sound::setupSound();
+
+ if (_vm->_game.heversion >= 70) {
+ setupHEMusicFile();
+ }
+}
+
+void SoundHE::stopSoundChannel(int chan) {
if (_heChannel[chan].sound == 1) {
_vm->_haveMsg = 3;
_vm->_talkDelay = 0;
@@ -69,7 +187,7 @@ void Sound::stopSoundChannel(int chan) {
}
}
-int Sound::findFreeSoundChannel() {
+int SoundHE::findFreeSoundChannel() {
int chan, min;
min = _vm->VAR(_vm->VAR_RESERVED_SOUND_CHANNELS);
@@ -90,7 +208,7 @@ int Sound::findFreeSoundChannel() {
return min;
}
-int Sound::isSoundCodeUsed(int sound) {
+int SoundHE::isSoundCodeUsed(int sound) {
int chan = -1;
for (int i = 0; i < ARRAYSIZE(_heChannel); i ++) {
if (_heChannel[i].sound == sound)
@@ -104,7 +222,7 @@ int Sound::isSoundCodeUsed(int sound) {
}
}
-int Sound::getSoundPos(int sound) {
+int SoundHE::getSoundPos(int sound) {
int chan = -1;
for (int i = 0; i < ARRAYSIZE(_heChannel); i ++) {
if (_heChannel[i].sound == sound)
@@ -119,7 +237,7 @@ int Sound::getSoundPos(int sound) {
}
}
-int Sound::getSoundVar(int sound, int var) {
+int SoundHE::getSoundVar(int sound, int var) {
if (_vm->_game.heversion >= 90 && var == 26) {
return isSoundCodeUsed(sound);
}
@@ -140,7 +258,7 @@ int Sound::getSoundVar(int sound, int var) {
}
}
-void Sound::setSoundVar(int sound, int var, int val) {
+void SoundHE::setSoundVar(int sound, int var, int val) {
checkRange(25, 0, var, "Illegal sound variable %d");
int chan = -1;
@@ -155,11 +273,11 @@ void Sound::setSoundVar(int sound, int var, int val) {
}
}
-void Sound::setOverrideFreq(int freq) {
+void SoundHE::setOverrideFreq(int freq) {
_overrideFreq = freq;
}
-void Sound::setupHEMusicFile() {
+void SoundHE::setupHEMusicFile() {
int i, total_size;
Common::File musicFile;
Common::String buf(_vm->generateFilename(4));
@@ -191,7 +309,7 @@ void Sound::setupHEMusicFile() {
}
}
-bool Sound::getHEMusicDetails(int id, int &musicOffs, int &musicSize) {
+bool SoundHE::getHEMusicDetails(int id, int &musicOffs, int &musicSize) {
int i;
for (i = 0; i < _heMusicTracks; i++) {
@@ -205,7 +323,7 @@ bool Sound::getHEMusicDetails(int id, int &musicOffs, int &musicSize) {
return 0;
}
-void Sound::processSoundCode() {
+void SoundHE::processSoundCode() {
byte *codePtr;
int chan, tmr, size, time;
@@ -252,7 +370,7 @@ void Sound::processSoundCode() {
}
}
-void Sound::processSoundOpcodes(int sound, byte *codePtr, int *soundVars) {
+void SoundHE::processSoundOpcodes(int sound, byte *codePtr, int *soundVars) {
int arg, opcode, var, val;
while(READ_LE_UINT16(codePtr) != 0) {
@@ -329,7 +447,7 @@ void Sound::processSoundOpcodes(int sound, byte *codePtr, int *soundVars) {
}
}
-void Sound::playHESound(int soundID, int heOffset, int heChannel, int heFlags) {
+void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags) {
byte *ptr, *spoolPtr;
int size = -1;
int priority, rate;
@@ -507,7 +625,7 @@ void Sound::playHESound(int soundID, int heOffset, int heChannel, int heFlags) {
}
}
-void Sound::startHETalkSound(uint32 offset) {
+void SoundHE::startHETalkSound(uint32 offset) {
byte *ptr;
int32 size;
diff --git a/engines/scumm/he/sound_he.h b/engines/scumm/he/sound_he.h
new file mode 100644
index 0000000000..033637590d
--- /dev/null
+++ b/engines/scumm/he/sound_he.h
@@ -0,0 +1,74 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2002-2006 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#ifndef SCUMM_HE_SOUND_HE_H
+#define SCUMM_HE_SOUND_HE_H
+
+#include "common/scummsys.h"
+#include "scumm/sound.h"
+
+namespace Scumm {
+
+class SoundHE : public Sound {
+protected:
+ struct HEMusic{
+ int32 id;
+ int32 offset;
+ int32 size;
+ };
+ HEMusic *_heMusic;
+ int16 _heMusicTracks;
+
+ Audio::SoundHandle _heSoundChannels[8];
+
+public:
+ SoundHE(ScummEngine *parent);
+ ~SoundHE();
+
+ virtual void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
+ virtual void addSoundToQueue2(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
+
+ virtual int isSoundRunning(int sound) const;
+ virtual void stopSound(int sound);
+ virtual void setupSound();
+
+ bool getHEMusicDetails(int id, int &musicOffs, int &musicSize);
+ int findFreeSoundChannel();
+ int isSoundCodeUsed(int sound);
+ int getSoundPos(int sound);
+ int getSoundVar(int sound, int var);
+ void setSoundVar(int sound, int var, int val);
+ void playHESound(int soundID, int heOffset, int heChannel, int heFlags);
+ void processSoundCode();
+ void processSoundOpcodes(int sound, byte *codePtr, int *soundVars);
+ void setOverrideFreq(int freq);
+ void setupHEMusicFile();
+ void startHETalkSound(uint32 offset);
+ void stopSoundChannel(int chan);
+
+protected:
+ virtual void processSoundQueues();
+};
+
+
+} // End of namespace Scumm
+
+#endif