Move HE specific stuff from class Sound to its new subclass SoundHE
svn-id: r22115
This commit is contained in:
parent
78dfa1f280
commit
d68f95b3be
13 changed files with 250 additions and 167 deletions
|
@ -33,7 +33,7 @@
|
||||||
#include "scumm/object.h"
|
#include "scumm/object.h"
|
||||||
#include "scumm/resource.h"
|
#include "scumm/resource.h"
|
||||||
#include "scumm/saveload.h"
|
#include "scumm/saveload.h"
|
||||||
#include "scumm/sound.h"
|
#include "scumm/he/sound_he.h"
|
||||||
#include "scumm/he/sprite_he.h"
|
#include "scumm/he/sprite_he.h"
|
||||||
#include "scumm/usage_bits.h"
|
#include "scumm/usage_bits.h"
|
||||||
#include "scumm/util.h"
|
#include "scumm/util.h"
|
||||||
|
@ -1154,8 +1154,8 @@ void Actor::drawActorCostume(bool hitTestMode) {
|
||||||
if (_vm->getTalkingActor() == _number && !_vm->_string[0].no_talk_anim) {
|
if (_vm->getTalkingActor() == _number && !_vm->_string[0].no_talk_anim) {
|
||||||
int talkState = 0;
|
int talkState = 0;
|
||||||
|
|
||||||
if (_vm->_sound->isSoundCodeUsed(1))
|
if (((SoundHE *)_vm->_sound)->isSoundCodeUsed(1))
|
||||||
talkState = _vm->_sound->getSoundVar(1, 19);
|
talkState = ((SoundHE *)_vm->_sound)->getSoundVar(1, 19);
|
||||||
if (talkState == 0)
|
if (talkState == 0)
|
||||||
talkState = _vm->_rnd.getRandomNumberRng(1, 10);
|
talkState = _vm->_rnd.getRandomNumberRng(1, 10);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include "scumm/he/intern_he.h"
|
#include "scumm/he/intern_he.h"
|
||||||
#include "scumm/resource.h"
|
#include "scumm/resource.h"
|
||||||
#include "scumm/he/resource_he.h"
|
#include "scumm/he/resource_he.h"
|
||||||
#include "scumm/sound.h"
|
#include "scumm/he/sound_he.h"
|
||||||
|
|
||||||
#include "sound/wave.h"
|
#include "sound/wave.h"
|
||||||
|
|
||||||
|
@ -1762,7 +1762,7 @@ int ScummEngine_v72he::getSoundResourceSize(int id) {
|
||||||
int offs, size;
|
int offs, size;
|
||||||
|
|
||||||
if (id > _numSounds) {
|
if (id > _numSounds) {
|
||||||
if (!_sound->getHEMusicDetails(id, offs, size)) {
|
if (!((SoundHE *)_sound)->getHEMusicDetails(id, offs, size)) {
|
||||||
debug(0, "getSoundResourceSize: musicID %d not found", id);
|
debug(0, "getSoundResourceSize: musicID %d not found", id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "scumm/resource.h"
|
#include "scumm/resource.h"
|
||||||
#include "scumm/he/resource_he.h"
|
#include "scumm/he/resource_he.h"
|
||||||
#include "scumm/scumm.h"
|
#include "scumm/scumm.h"
|
||||||
#include "scumm/sound.h"
|
#include "scumm/he/sound_he.h"
|
||||||
#include "scumm/he/sprite_he.h"
|
#include "scumm/he/sprite_he.h"
|
||||||
#include "scumm/util.h"
|
#include "scumm/util.h"
|
||||||
|
|
||||||
|
@ -1714,7 +1714,7 @@ void ScummEngine_v100he::o100_startSound() {
|
||||||
value = pop();
|
value = pop();
|
||||||
var = pop();
|
var = pop();
|
||||||
_heSndSoundId = pop();
|
_heSndSoundId = pop();
|
||||||
_sound->setSoundVar(_heSndSoundId, var, value);
|
((SoundHE *)_sound)->setSoundVar(_heSndSoundId, var, value);
|
||||||
break;
|
break;
|
||||||
case 92:
|
case 92:
|
||||||
_sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags);
|
_sound->addSoundToQueue(_heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags);
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "scumm/object.h"
|
#include "scumm/object.h"
|
||||||
#include "scumm/resource.h"
|
#include "scumm/resource.h"
|
||||||
#include "scumm/scumm.h"
|
#include "scumm/scumm.h"
|
||||||
#include "scumm/sound.h"
|
#include "scumm/he/sound_he.h"
|
||||||
#include "scumm/usage_bits.h"
|
#include "scumm/usage_bits.h"
|
||||||
#include "scumm/util.h"
|
#include "scumm/util.h"
|
||||||
#include "scumm/verbs.h"
|
#include "scumm/verbs.h"
|
||||||
|
@ -1151,7 +1151,7 @@ void ScummEngine_v60he::o60_soundOps() {
|
||||||
// Fatty Bear's Birthday surprise uses this when playing the
|
// Fatty Bear's Birthday surprise uses this when playing the
|
||||||
// piano, but only when using one of the digitized instruments.
|
// piano, but only when using one of the digitized instruments.
|
||||||
// See also o6_startSound().
|
// See also o6_startSound().
|
||||||
_sound->setOverrideFreq(arg);
|
((SoundHE *)_sound)->setOverrideFreq(arg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error("o60_soundOps: default case 0x%x", subOp);
|
error("o60_soundOps: default case 0x%x", subOp);
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include "scumm/resource.h"
|
#include "scumm/resource.h"
|
||||||
#include "scumm/he/resource_he.h"
|
#include "scumm/he/resource_he.h"
|
||||||
#include "scumm/scumm.h"
|
#include "scumm/scumm.h"
|
||||||
#include "scumm/sound.h"
|
#include "scumm/he/sound_he.h"
|
||||||
#include "scumm/verbs.h"
|
#include "scumm/verbs.h"
|
||||||
|
|
||||||
namespace Scumm {
|
namespace Scumm {
|
||||||
|
@ -438,7 +438,7 @@ void ScummEngine_v70he::o70_startSound() {
|
||||||
value = pop();
|
value = pop();
|
||||||
var = pop();
|
var = pop();
|
||||||
_heSndSoundId = pop();
|
_heSndSoundId = pop();
|
||||||
_sound->setSoundVar(_heSndSoundId, var, value);
|
((SoundHE *)_sound)->setSoundVar(_heSndSoundId, var, value);
|
||||||
break;
|
break;
|
||||||
case 25:
|
case 25:
|
||||||
value = pop();
|
value = pop();
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include "scumm/resource.h"
|
#include "scumm/resource.h"
|
||||||
#include "scumm/he/resource_he.h"
|
#include "scumm/he/resource_he.h"
|
||||||
#include "scumm/scumm.h"
|
#include "scumm/scumm.h"
|
||||||
#include "scumm/sound.h"
|
#include "scumm/he/sound_he.h"
|
||||||
#include "scumm/util.h"
|
#include "scumm/util.h"
|
||||||
#include "scumm/verbs.h"
|
#include "scumm/verbs.h"
|
||||||
|
|
||||||
|
@ -847,7 +847,7 @@ void ScummEngine_v72he::o72_setTimer() {
|
||||||
|
|
||||||
void ScummEngine_v72he::o72_getSoundPosition() {
|
void ScummEngine_v72he::o72_getSoundPosition() {
|
||||||
int snd = pop();
|
int snd = pop();
|
||||||
push(_sound->getSoundPos(snd));
|
push(((SoundHE *)_sound)->getSoundPos(snd));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScummEngine_v72he::o72_startScript() {
|
void ScummEngine_v72he::o72_startScript() {
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#include "scumm/resource.h"
|
#include "scumm/resource.h"
|
||||||
#include "scumm/he/resource_he.h"
|
#include "scumm/he/resource_he.h"
|
||||||
#include "scumm/scumm.h"
|
#include "scumm/scumm.h"
|
||||||
#include "scumm/sound.h"
|
#include "scumm/he/sound_he.h"
|
||||||
|
|
||||||
namespace Scumm {
|
namespace Scumm {
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ void ScummEngine_v80he::o80_stringToInt() {
|
||||||
void ScummEngine_v80he::o80_getSoundVar() {
|
void ScummEngine_v80he::o80_getSoundVar() {
|
||||||
int var = pop();
|
int var = pop();
|
||||||
int snd = pop();
|
int snd = pop();
|
||||||
push(_sound->getSoundVar(snd, var));
|
push(((SoundHE *)_sound)->getSoundVar(snd, var));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScummEngine_v80he::o80_localizeArrayToRoom() {
|
void ScummEngine_v80he::o80_localizeArrayToRoom() {
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "scumm/file.h"
|
#include "scumm/file.h"
|
||||||
#include "scumm/imuse/imuse.h"
|
#include "scumm/imuse/imuse.h"
|
||||||
#include "scumm/scumm.h"
|
#include "scumm/scumm.h"
|
||||||
#include "scumm/sound.h"
|
#include "scumm/he/sound_he.h"
|
||||||
#include "scumm/util.h"
|
#include "scumm/util.h"
|
||||||
|
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
|
@ -45,7 +45,125 @@
|
||||||
|
|
||||||
namespace Scumm {
|
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) {
|
if (_heChannel[chan].sound == 1) {
|
||||||
_vm->_haveMsg = 3;
|
_vm->_haveMsg = 3;
|
||||||
_vm->_talkDelay = 0;
|
_vm->_talkDelay = 0;
|
||||||
|
@ -69,7 +187,7 @@ void Sound::stopSoundChannel(int chan) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Sound::findFreeSoundChannel() {
|
int SoundHE::findFreeSoundChannel() {
|
||||||
int chan, min;
|
int chan, min;
|
||||||
|
|
||||||
min = _vm->VAR(_vm->VAR_RESERVED_SOUND_CHANNELS);
|
min = _vm->VAR(_vm->VAR_RESERVED_SOUND_CHANNELS);
|
||||||
|
@ -90,7 +208,7 @@ int Sound::findFreeSoundChannel() {
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Sound::isSoundCodeUsed(int sound) {
|
int SoundHE::isSoundCodeUsed(int sound) {
|
||||||
int chan = -1;
|
int chan = -1;
|
||||||
for (int i = 0; i < ARRAYSIZE(_heChannel); i ++) {
|
for (int i = 0; i < ARRAYSIZE(_heChannel); i ++) {
|
||||||
if (_heChannel[i].sound == sound)
|
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;
|
int chan = -1;
|
||||||
for (int i = 0; i < ARRAYSIZE(_heChannel); i ++) {
|
for (int i = 0; i < ARRAYSIZE(_heChannel); i ++) {
|
||||||
if (_heChannel[i].sound == sound)
|
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) {
|
if (_vm->_game.heversion >= 90 && var == 26) {
|
||||||
return isSoundCodeUsed(sound);
|
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");
|
checkRange(25, 0, var, "Illegal sound variable %d");
|
||||||
|
|
||||||
int chan = -1;
|
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;
|
_overrideFreq = freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::setupHEMusicFile() {
|
void SoundHE::setupHEMusicFile() {
|
||||||
int i, total_size;
|
int i, total_size;
|
||||||
Common::File musicFile;
|
Common::File musicFile;
|
||||||
Common::String buf(_vm->generateFilename(4));
|
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;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < _heMusicTracks; i++) {
|
for (i = 0; i < _heMusicTracks; i++) {
|
||||||
|
@ -205,7 +323,7 @@ bool Sound::getHEMusicDetails(int id, int &musicOffs, int &musicSize) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::processSoundCode() {
|
void SoundHE::processSoundCode() {
|
||||||
byte *codePtr;
|
byte *codePtr;
|
||||||
int chan, tmr, size, time;
|
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;
|
int arg, opcode, var, val;
|
||||||
|
|
||||||
while(READ_LE_UINT16(codePtr) != 0) {
|
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;
|
byte *ptr, *spoolPtr;
|
||||||
int size = -1;
|
int size = -1;
|
||||||
int priority, rate;
|
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;
|
byte *ptr;
|
||||||
int32 size;
|
int32 size;
|
||||||
|
|
||||||
|
|
74
engines/scumm/he/sound_he.h
Normal file
74
engines/scumm/he/sound_he.h
Normal file
|
@ -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
|
|
@ -45,6 +45,7 @@
|
||||||
#include "scumm/intern.h"
|
#include "scumm/intern.h"
|
||||||
#include "scumm/he/intern_he.h"
|
#include "scumm/he/intern_he.h"
|
||||||
#include "scumm/he/logic_he.h"
|
#include "scumm/he/logic_he.h"
|
||||||
|
#include "scumm/he/sound_he.h"
|
||||||
#include "scumm/player_nes.h"
|
#include "scumm/player_nes.h"
|
||||||
#include "scumm/player_v1.h"
|
#include "scumm/player_v1.h"
|
||||||
#include "scumm/player_v2.h"
|
#include "scumm/player_v2.h"
|
||||||
|
@ -944,7 +945,10 @@ int ScummEngine::init() {
|
||||||
_system->openCD(cd_num);
|
_system->openCD(cd_num);
|
||||||
|
|
||||||
// Create the sound manager
|
// Create the sound manager
|
||||||
_sound = new Sound(this);
|
if (_game.heversion > 0)
|
||||||
|
_sound = new SoundHE(this);
|
||||||
|
else
|
||||||
|
_sound = new Sound(this);
|
||||||
|
|
||||||
// Setup the music engine
|
// Setup the music engine
|
||||||
setupMusic(_game.midi);
|
setupMusic(_game.midi);
|
||||||
|
@ -1762,7 +1766,7 @@ load_game:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_game.heversion >= 80) {
|
if (_game.heversion >= 80) {
|
||||||
_sound->processSoundCode();
|
((SoundHE *)_sound)->processSoundCode();
|
||||||
}
|
}
|
||||||
runAllScripts();
|
runAllScripts();
|
||||||
checkExecVerbs();
|
checkExecVerbs();
|
||||||
|
|
|
@ -78,11 +78,8 @@ Sound::Sound(ScummEngine *parent)
|
||||||
_currentCDSound(0),
|
_currentCDSound(0),
|
||||||
_currentMusic(0),
|
_currentMusic(0),
|
||||||
_soundsPaused(false),
|
_soundsPaused(false),
|
||||||
_sfxMode(0),
|
_sfxMode(0) {
|
||||||
_heMusic(0),
|
|
||||||
_heMusicTracks(0) {
|
|
||||||
|
|
||||||
memset(_heChannel, 0, sizeof(_heChannel));
|
|
||||||
memset(_soundQue, 0, sizeof(_soundQue));
|
memset(_soundQue, 0, sizeof(_soundQue));
|
||||||
memset(_soundQue2, 0, sizeof(_soundQue2));
|
memset(_soundQue2, 0, sizeof(_soundQue2));
|
||||||
memset(_mouthSyncTimes, 0, sizeof(_mouthSyncTimes));
|
memset(_mouthSyncTimes, 0, sizeof(_mouthSyncTimes));
|
||||||
|
@ -91,20 +88,12 @@ Sound::Sound(ScummEngine *parent)
|
||||||
Sound::~Sound() {
|
Sound::~Sound() {
|
||||||
stopCDTimer();
|
stopCDTimer();
|
||||||
delete _sfxFile;
|
delete _sfxFile;
|
||||||
|
|
||||||
// HE Specific
|
|
||||||
free(_heMusic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags) {
|
void Sound::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags) {
|
||||||
if (_vm->VAR_LAST_SOUND != 0xFF)
|
if (_vm->VAR_LAST_SOUND != 0xFF)
|
||||||
_vm->VAR(_vm->VAR_LAST_SOUND) = sound;
|
_vm->VAR(_vm->VAR_LAST_SOUND) = sound;
|
||||||
|
|
||||||
if (heFlags & 16) {
|
|
||||||
playHESound(sound, heOffset, heChannel, heFlags);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// HE music resources are in separate file
|
// HE music resources are in separate file
|
||||||
if (sound <= _vm->_numSounds)
|
if (sound <= _vm->_numSounds)
|
||||||
_vm->ensureResourceLoaded(rtSound, sound);
|
_vm->ensureResourceLoaded(rtSound, sound);
|
||||||
|
@ -113,14 +102,6 @@ void Sound::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::addSoundToQueue2(int sound, int heOffset, int heChannel, int heFlags) {
|
void Sound::addSoundToQueue2(int sound, int heOffset, int heChannel, int heFlags) {
|
||||||
if (_vm->_game.heversion >= 60 && _soundQue2Pos) {
|
|
||||||
int i = _soundQue2Pos;
|
|
||||||
while (i--) {
|
|
||||||
if (_soundQue2[i].sound == sound && !(heFlags & 2))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(_soundQue2Pos < ARRAYSIZE(_soundQue2));
|
assert(_soundQue2Pos < ARRAYSIZE(_soundQue2));
|
||||||
_soundQue2[_soundQue2Pos].sound = sound;
|
_soundQue2[_soundQue2Pos].sound = sound;
|
||||||
_soundQue2[_soundQue2Pos].offset = heOffset;
|
_soundQue2[_soundQue2Pos].offset = heOffset;
|
||||||
|
@ -144,37 +125,14 @@ void Sound::processSound() {
|
||||||
|
|
||||||
void Sound::processSoundQueues() {
|
void Sound::processSoundQueues() {
|
||||||
int i = 0, num;
|
int i = 0, num;
|
||||||
int snd, heOffset, heChannel, heFlags;
|
int snd;
|
||||||
int data[16];
|
int data[16];
|
||||||
|
|
||||||
if (_vm->_game.heversion >= 72) {
|
while (_soundQue2Pos) {
|
||||||
for (i = 0; i <_soundQue2Pos; i++) {
|
_soundQue2Pos--;
|
||||||
snd = _soundQue2[i].sound;
|
snd = _soundQue2[_soundQue2Pos].sound;
|
||||||
heOffset = _soundQue2[i].offset;
|
if (snd)
|
||||||
heChannel = _soundQue2[i].channel;
|
playSound(snd);
|
||||||
heFlags = _soundQue2[i].flags;
|
|
||||||
if (snd) {
|
|
||||||
if (_vm->_game.heversion>= 60)
|
|
||||||
playHESound(snd, heOffset, heChannel, heFlags);
|
|
||||||
else
|
|
||||||
playSound(snd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_soundQue2Pos = 0;
|
|
||||||
} else {
|
|
||||||
while (_soundQue2Pos) {
|
|
||||||
_soundQue2Pos--;
|
|
||||||
snd = _soundQue2[_soundQue2Pos].sound;
|
|
||||||
heOffset = _soundQue2[_soundQue2Pos].offset;
|
|
||||||
heChannel = _soundQue2[_soundQue2Pos].channel;
|
|
||||||
heFlags = _soundQue2[_soundQue2Pos].flags;
|
|
||||||
if (snd) {
|
|
||||||
if (_vm->_game.heversion>= 60)
|
|
||||||
playHESound(snd, heOffset, heChannel, heFlags);
|
|
||||||
else
|
|
||||||
playSound(snd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (i < _soundQuePos) {
|
while (i < _soundQuePos) {
|
||||||
|
@ -726,18 +684,6 @@ int Sound::isSoundRunning(int sound) const {
|
||||||
if (sound == _currentCDSound)
|
if (sound == _currentCDSound)
|
||||||
return pollCD();
|
return pollCD();
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_vm->_mixer->isSoundIDActive(sound))
|
if (_vm->_mixer->isSoundIDActive(sound))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -814,18 +760,6 @@ bool Sound::isSoundInQueue(int sound) const {
|
||||||
void Sound::stopSound(int sound) {
|
void Sound::stopSound(int sound) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sound != 0 && sound == _currentCDSound) {
|
if (sound != 0 && sound == _currentCDSound) {
|
||||||
_currentCDSound = 0;
|
_currentCDSound = 0;
|
||||||
stopCD();
|
stopCD();
|
||||||
|
@ -838,16 +772,6 @@ void Sound::stopSound(int sound) {
|
||||||
if (_vm->_musicEngine)
|
if (_vm->_musicEngine)
|
||||||
_vm->_musicEngine->stopSound(sound);
|
_vm->_musicEngine->stopSound(sound);
|
||||||
|
|
||||||
for (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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAYSIZE(_soundQue2); i++) {
|
for (i = 0; i < ARRAYSIZE(_soundQue2); i++) {
|
||||||
if (_soundQue2[i].sound == sound) {
|
if (_soundQue2[i].sound == sound) {
|
||||||
_soundQue2[i].sound = 0;
|
_soundQue2[i].sound = 0;
|
||||||
|
@ -856,12 +780,6 @@ void Sound::stopSound(int sound) {
|
||||||
_soundQue2[i].flags = 0;
|
_soundQue2[i].flags = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_vm->_game.heversion >= 70 && sound == 1) {
|
|
||||||
_vm->_haveMsg = 3;
|
|
||||||
_vm->_talkDelay = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::stopAllSounds() {
|
void Sound::stopAllSounds() {
|
||||||
|
@ -938,10 +856,6 @@ void Sound::setupSound() {
|
||||||
|
|
||||||
_sfxFile = openSfxFile();
|
_sfxFile = openSfxFile();
|
||||||
|
|
||||||
if (_vm->_game.heversion >= 70) {
|
|
||||||
setupHEMusicFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_vm->_game.id == GID_FT) {
|
if (_vm->_game.id == GID_FT) {
|
||||||
_vm->VAR(_vm->VAR_VOICE_BUNDLE_LOADED) = _sfxFile->isOpen();
|
_vm->VAR(_vm->VAR_VOICE_BUNDLE_LOADED) = _sfxFile->isOpen();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SOUND_H
|
#ifndef SCUMM_SOUND_H
|
||||||
#define SOUND_H
|
#define SCUMM_SOUND_H
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "sound/audiostream.h"
|
#include "sound/audiostream.h"
|
||||||
|
@ -43,12 +43,10 @@ enum {
|
||||||
kTalkSoundID = 10000
|
kTalkSoundID = 10000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: Consider splitting Sound into even more subclasses.
|
||||||
|
// E.g. for v1-v4, v5, v6+, ...
|
||||||
class Sound : public Serializable {
|
class Sound : public Serializable {
|
||||||
#ifdef PALMOS_MODE
|
|
||||||
public:
|
public:
|
||||||
#else
|
|
||||||
protected:
|
|
||||||
#endif
|
|
||||||
enum SoundMode {
|
enum SoundMode {
|
||||||
kVOCMode,
|
kVOCMode,
|
||||||
kMP3Mode,
|
kMP3Mode,
|
||||||
|
@ -56,9 +54,7 @@ protected:
|
||||||
kFlacMode
|
kFlacMode
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef PALMOS_MODE
|
|
||||||
protected:
|
protected:
|
||||||
#endif
|
|
||||||
ScummEngine *_vm;
|
ScummEngine *_vm;
|
||||||
|
|
||||||
int16 _soundQuePos, _soundQue[0x100];
|
int16 _soundQuePos, _soundQue[0x100];
|
||||||
|
@ -88,14 +84,6 @@ protected:
|
||||||
int16 _currentCDSound;
|
int16 _currentCDSound;
|
||||||
int16 _currentMusic;
|
int16 _currentMusic;
|
||||||
|
|
||||||
struct HEMusic{
|
|
||||||
int32 id;
|
|
||||||
int32 offset;
|
|
||||||
int32 size;
|
|
||||||
};
|
|
||||||
HEMusic *_heMusic;
|
|
||||||
int16 _heMusicTracks;
|
|
||||||
|
|
||||||
public: // Used by createSound()
|
public: // Used by createSound()
|
||||||
struct {
|
struct {
|
||||||
int sound;
|
int sound;
|
||||||
|
@ -107,30 +95,28 @@ public: // Used by createSound()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Audio::SoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on
|
Audio::SoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on
|
||||||
Audio::SoundHandle _heSoundChannels[8];
|
|
||||||
|
|
||||||
bool _soundsPaused;
|
bool _soundsPaused;
|
||||||
byte _sfxMode;
|
byte _sfxMode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Sound(ScummEngine *parent);
|
Sound(ScummEngine *parent);
|
||||||
~Sound();
|
virtual ~Sound();
|
||||||
void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
|
virtual void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
|
||||||
void addSoundToQueue2(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);
|
||||||
void processSound();
|
void processSound();
|
||||||
void processSoundQueues();
|
|
||||||
|
|
||||||
void playSound(int soundID);
|
void playSound(int soundID);
|
||||||
void startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle *handle = NULL);
|
void startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle *handle = NULL);
|
||||||
void stopTalkSound();
|
void stopTalkSound();
|
||||||
bool isMouthSyncOff(uint pos);
|
bool isMouthSyncOff(uint pos);
|
||||||
int isSoundRunning(int sound) const;
|
virtual int isSoundRunning(int sound) const;
|
||||||
bool isSoundInUse(int sound) const;
|
bool isSoundInUse(int sound) const;
|
||||||
void stopSound(int sound);
|
virtual void stopSound(int sound);
|
||||||
void stopAllSounds();
|
void stopAllSounds();
|
||||||
void soundKludge(int *list, int num);
|
void soundKludge(int *list, int num);
|
||||||
void talkSound(uint32 a, uint32 b, int mode, int channel = 0);
|
void talkSound(uint32 a, uint32 b, int mode, int channel = 0);
|
||||||
void setupSound();
|
virtual void setupSound();
|
||||||
void pauseSounds(bool pause);
|
void pauseSounds(bool pause);
|
||||||
|
|
||||||
void startCDTimer();
|
void startCDTimer();
|
||||||
|
@ -142,21 +128,6 @@ public:
|
||||||
void updateCD();
|
void updateCD();
|
||||||
int getCurrentCDSound() const { return _currentCDSound; }
|
int getCurrentCDSound() const { return _currentCDSound; }
|
||||||
|
|
||||||
// HE specific
|
|
||||||
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);
|
|
||||||
|
|
||||||
// Used by the save/load system:
|
// Used by the save/load system:
|
||||||
void saveLoadWithSerializer(Serializer *ser);
|
void saveLoadWithSerializer(Serializer *ser);
|
||||||
|
|
||||||
|
@ -166,6 +137,8 @@ protected:
|
||||||
void processSfxQueues();
|
void processSfxQueues();
|
||||||
|
|
||||||
bool isSoundInQueue(int sound) const;
|
bool isSoundInQueue(int sound) const;
|
||||||
|
|
||||||
|
virtual void processSoundQueues();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include "scumm/he/intern_he.h"
|
#include "scumm/he/intern_he.h"
|
||||||
#endif
|
#endif
|
||||||
#include "scumm/verbs.h"
|
#include "scumm/verbs.h"
|
||||||
#include "scumm/sound.h"
|
#include "scumm/he/sound_he.h"
|
||||||
|
|
||||||
namespace Scumm {
|
namespace Scumm {
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ bool ScummEngine::handleNextCharsetCode(Actor *a, int *code) {
|
||||||
talk_sound_b = buffer[8] | (buffer[9] << 8) | (buffer[12] << 16) | (buffer[13] << 24);
|
talk_sound_b = buffer[8] | (buffer[9] << 8) | (buffer[12] << 16) | (buffer[13] << 24);
|
||||||
buffer += 14;
|
buffer += 14;
|
||||||
if (_game.heversion >= 60) {
|
if (_game.heversion >= 60) {
|
||||||
_sound->startHETalkSound(talk_sound_a);
|
((SoundHE *)_sound)->startHETalkSound(talk_sound_a);
|
||||||
} else {
|
} else {
|
||||||
_sound->talkSound(talk_sound_a, talk_sound_b, 2);
|
_sound->talkSound(talk_sound_a, talk_sound_b, 2);
|
||||||
}
|
}
|
||||||
|
@ -358,7 +358,7 @@ bool ScummEngine_v72he::handleNextCharsetCode(Actor *a, int *code) {
|
||||||
}
|
}
|
||||||
value[i] = 0;
|
value[i] = 0;
|
||||||
talk_sound_b = atoi(value);
|
talk_sound_b = atoi(value);
|
||||||
_sound->startHETalkSound(talk_sound_a);
|
((SoundHE *)_sound)->startHETalkSound(talk_sound_a);
|
||||||
break;
|
break;
|
||||||
case 104:
|
case 104:
|
||||||
_haveMsg = 0;
|
_haveMsg = 0;
|
||||||
|
@ -381,7 +381,7 @@ bool ScummEngine_v72he::handleNextCharsetCode(Actor *a, int *code) {
|
||||||
value[i] = 0;
|
value[i] = 0;
|
||||||
talk_sound_a = atoi(value);
|
talk_sound_a = atoi(value);
|
||||||
talk_sound_b = 0;
|
talk_sound_b = 0;
|
||||||
_sound->startHETalkSound(talk_sound_a);
|
((SoundHE *)_sound)->startHETalkSound(talk_sound_a);
|
||||||
break;
|
break;
|
||||||
case 119:
|
case 119:
|
||||||
_haveMsg = 0xFF;
|
_haveMsg = 0xFF;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue