diff options
author | Littleboy | 2011-06-24 10:56:49 -0400 |
---|---|---|
committer | Littleboy | 2011-06-24 10:56:49 -0400 |
commit | 5d020fffad44c78414b91de7c26653b11b78b60f (patch) | |
tree | 50899050b92b6e30f8bda0204d923c89aa5c7416 /engines/lastexpress/sound/entry.cpp | |
parent | 08375150ca0b4719ddda7932d5f5061fff225a28 (diff) | |
download | scummvm-rg350-5d020fffad44c78414b91de7c26653b11b78b60f.tar.gz scummvm-rg350-5d020fffad44c78414b91de7c26653b11b78b60f.tar.bz2 scummvm-rg350-5d020fffad44c78414b91de7c26653b11b78b60f.zip |
LASTEXPRESS: Refactor Sound class
- Move entry-related functions to separate class
- Move enumeration to shared header and rename FlagType to SoundFlag
Diffstat (limited to 'engines/lastexpress/sound/entry.cpp')
-rw-r--r-- | engines/lastexpress/sound/entry.cpp | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/engines/lastexpress/sound/entry.cpp b/engines/lastexpress/sound/entry.cpp new file mode 100644 index 0000000000..309996886a --- /dev/null +++ b/engines/lastexpress/sound/entry.cpp @@ -0,0 +1,151 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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. + * + */ + +#include "lastexpress/sound/entry.h" + +#include "lastexpress/game/sound.h" + +#include "lastexpress/helpers.h" +#include "lastexpress/lastexpress.h" + +#include "common/stream.h" + +namespace LastExpress { + +////////////////////////////////////////////////////////////////////////// +// SoundEntry +////////////////////////////////////////////////////////////////////////// +SoundEntry::SoundEntry(LastExpressEngine *engine) : _engine(engine) { + status.status = 0; + type = kSoundTypeNone; + + currentDataPtr = 0; + soundData = NULL; + + blockCount = 0; + time = 0; + + stream = NULL; + + field_34 = 0; + field_38 = 0; + field_3C = 0; + field_40 = 0; + entity = kEntityPlayer; + field_48 = 0; + field_4C = 0; + + subtitle = NULL; + + soundStream = NULL; +} + +SoundEntry::~SoundEntry() { + // Entries that have been queued would have their streamed disposed automatically + if (!soundStream) + SAFE_DELETE(stream); + + delete soundStream; + + _engine = NULL; +} + +void SoundEntry::setStatus(SoundFlag flag) { + SoundStatus statusFlag = (SoundStatus)flag; + if (!((statusFlag & 0xFF) & kSoundStatusClear1)) + statusFlag = (SoundStatus)(statusFlag | kSoundStatusClear2); + + if (((statusFlag & 0xFF00) >> 8) & kSoundStatusClear0) + status.status = (uint32)statusFlag; + else + status.status = (statusFlag | kSoundStatusClear4); +} + +void SoundEntry::setInCache() { + status.status |= kSoundStatusClear2; +} + +void SoundEntry::update(uint val) { + if (!(status.status3 & 64)) { + int value2 = val; + + status.status |= kSoundStatus_100000; + + if (val) { + if (getSound()->getFlag() & 32) { + field_40 = val; + value2 = val * 2 + 1; + } + + field_3C = value2; + } else { + field_3C = 0; + status.status |= kSoundStatus_40000000; + } + } +} + +void SoundEntry::updateState() { + if (getSound()->getFlag() & 32) { + if (type != kSoundType9 && type != kSoundType7 && type != kSoundType5) { + uint32 newStatus = status.status & kSoundStatusClear1; + + status.status &= kSoundStatusClearAll; + + field_40 = newStatus; + status.status |= newStatus * 2 + 1; + } + } + + status.status |= kSoundStatus_20; +} + +void SoundEntry::reset() { + status.status |= kSoundStatusRemoved; + entity = kEntityPlayer; + + if (stream) { + if (!soundStream) { + SAFE_DELETE(stream); + } else { + soundStream->stop(); + SAFE_DELETE(soundStream); + } + + stream = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +// SubtitleEntry +////////////////////////////////////////////////////////////////////////// +SubtitleEntry::SubtitleEntry() { + status.status = 0; + sound = NULL; + data = NULL; +} + +SubtitleEntry::~SubtitleEntry() { + SAFE_DELETE(data); +} + +} // End of namespace LastExpress |