aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sludge/backdrop.cpp5
-rw-r--r--engines/sludge/builtin.cpp4
-rw-r--r--engines/sludge/event.cpp3
-rw-r--r--engines/sludge/event.h2
-rw-r--r--engines/titanic/sound/qmixer.cpp13
-rw-r--r--engines/titanic/sound/qmixer.h3
-rw-r--r--engines/titanic/sound/sound.cpp1
-rw-r--r--engines/titanic/sound/sound_manager.cpp8
-rw-r--r--engines/titanic/sound/wave_file.cpp59
-rw-r--r--engines/titanic/sound/wave_file.h29
-rw-r--r--image/png.cpp2
11 files changed, 64 insertions, 65 deletions
diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index 5622d16a8c..23ddfe6bf5 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -224,6 +224,8 @@ bool GraphicsManager::reserveBackdrop() {
_vm->_evtMan->mouseX() = (int)((float)_vm->_evtMan->mouseX() / _cameraZoom);
_vm->_evtMan->mouseY() = (int)((float)_vm->_evtMan->mouseY() / _cameraZoom);
+ _backdropSurface.create(_sceneWidth, _sceneHeight, *_vm->getScreenPixelFormat());
+
return true;
}
@@ -444,7 +446,8 @@ bool GraphicsManager::loadHSI(Common::SeekableReadStream *stream, int x, int y,
}
// copy surface loaded to backdrop
- _backdropSurface.copyRectToSurface(tmp.getPixels(), tmp.pitch, x, y, tmp.w, tmp.h);
+ Graphics::TransparentSurface tmp_trans(tmp, false);
+ tmp_trans.blit(_backdropSurface, x, y);
tmp.free();
_origBackdropSurface.copyFrom(_backdropSurface);
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index 01d58a0815..6d7d571638 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -977,11 +977,9 @@ builtIn(callEvent) {
return BR_CONTINUE;
}
-bool reallyWantToQuit = false;
-
builtIn(quitGame) {
UNUSEDALL
- reallyWantToQuit = true;
+ g_sludge->_evtMan->quitGame();
return BR_CONTINUE;
}
diff --git a/engines/sludge/event.cpp b/engines/sludge/event.cpp
index 221140055c..c2997be078 100644
--- a/engines/sludge/event.cpp
+++ b/engines/sludge/event.cpp
@@ -43,6 +43,7 @@ EventManager::EventManager(SludgeEngine *vm) {
_vm = vm;
_weAreDoneSoQuit = 0;
+ _reallyWantToQuit = false;
_input.leftClick = _input.rightClick = _input.justMoved = _input.leftRelease = _input.rightRelease = false;
_input.keyPressed = 0;
@@ -129,7 +130,7 @@ void EventManager::checkInput() {
case Common::EVENT_QUIT:
_weAreDoneSoQuit = 1;
- // TODO: if reallyWantToQuit, popup a message box to confirm
+ // TODO: if _reallyWantToQuit, popup a message box to confirm
break;
default:
diff --git a/engines/sludge/event.h b/engines/sludge/event.h
index ddb973f4ec..691a0daa82 100644
--- a/engines/sludge/event.h
+++ b/engines/sludge/event.h
@@ -73,6 +73,7 @@ public:
void restore(FrozenStuffStruct *frozenStuff);
// Quit
+ void quitGame() { _weAreDoneSoQuit = true; /* _reallyWantToQuit = true; */ }
bool quit() { return _weAreDoneSoQuit; }
private:
@@ -80,6 +81,7 @@ private:
InputType _input;
int _weAreDoneSoQuit;
+ bool _reallyWantToQuit;
EventHandlers *_currentEvents;
};
diff --git a/engines/titanic/sound/qmixer.cpp b/engines/titanic/sound/qmixer.cpp
index b33601d82e..5c511c3cae 100644
--- a/engines/titanic/sound/qmixer.cpp
+++ b/engines/titanic/sound/qmixer.cpp
@@ -209,11 +209,8 @@ void QMixer::qsWaveMixPump() {
SoundEntry &sound = channel._sounds.front();
if (sound._started && !_mixer->isSoundHandleActive(sound._soundHandle)) {
if (sound._loops == -1 || sound._loops-- > 0) {
- // Need to loop the sound again
- sound._waveFile->audioStream()->rewind();
- _mixer->playStream(sound._waveFile->_soundType,
- &sound._soundHandle, sound._waveFile->audioStream(),
- -1, channel.getRawVolume(), 0, DisposeAfterUse::NO);
+ // Need to loop (replay) the sound again
+ sound._soundHandle = sound._waveFile->play(channel.getRawVolume());
} else {
// Sound is finished
if (sound._callback)
@@ -234,10 +231,8 @@ void QMixer::qsWaveMixPump() {
if (channel._resetDistance)
channel._distance = 0.0;
- // Calculate an effective volume based on distance of source
- _mixer->playStream(sound._waveFile->_soundType,
- &sound._soundHandle, sound._waveFile->audioStream(),
- -1, channel.getRawVolume(), 0, DisposeAfterUse::NO);
+ // Play the wave
+ sound._soundHandle = sound._waveFile->play(channel.getRawVolume());
sound._started = true;
}
}
diff --git a/engines/titanic/sound/qmixer.h b/engines/titanic/sound/qmixer.h
index b8c7f6dae2..17ca441e83 100644
--- a/engines/titanic/sound/qmixer.h
+++ b/engines/titanic/sound/qmixer.h
@@ -212,8 +212,9 @@ class QMixer {
byte getRawVolume() const;
};
private:
- Audio::Mixer *_mixer;
Common::Array<ChannelEntry> _channels;
+protected:
+ Audio::Mixer *_mixer;
public:
QMixer(Audio::Mixer *mixer);
virtual ~QMixer() {}
diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp
index c28823148e..fb8cc299df 100644
--- a/engines/titanic/sound/sound.cpp
+++ b/engines/titanic/sound/sound.cpp
@@ -129,7 +129,6 @@ CWaveFile *CSound::loadSound(const CString &name) {
// Found it, so move it to the front of the list and return
_sounds.remove(soundItem);
_sounds.push_front(soundItem);
- soundItem->_waveFile->reset();
return soundItem->_waveFile;
}
}
diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp
index df9183b9d8..514618783b 100644
--- a/engines/titanic/sound/sound_manager.cpp
+++ b/engines/titanic/sound/sound_manager.cpp
@@ -120,7 +120,7 @@ QSoundManager::~QSoundManager() {
}
CWaveFile *QSoundManager::loadSound(const CString &name) {
- CWaveFile *waveFile = new CWaveFile();
+ CWaveFile *waveFile = new CWaveFile(_mixer);
// Try to load the specified sound
if (!waveFile->loadSound(name)) {
@@ -132,7 +132,7 @@ CWaveFile *QSoundManager::loadSound(const CString &name) {
}
CWaveFile *QSoundManager::loadSpeech(CDialogueFile *dialogueFile, int speechId) {
- CWaveFile *waveFile = new CWaveFile();
+ CWaveFile *waveFile = new CWaveFile(_mixer);
// Try to load the specified sound
if (!waveFile->loadSpeech(dialogueFile, speechId)) {
@@ -144,7 +144,7 @@ CWaveFile *QSoundManager::loadSpeech(CDialogueFile *dialogueFile, int speechId)
}
CWaveFile *QSoundManager::loadMusic(const CString &name) {
- CWaveFile *waveFile = new CWaveFile();
+ CWaveFile *waveFile = new CWaveFile(_mixer);
// Try to load the specified sound
if (!waveFile->loadMusic(name)) {
@@ -156,7 +156,7 @@ CWaveFile *QSoundManager::loadMusic(const CString &name) {
}
CWaveFile *QSoundManager::loadMusic(CAudioBuffer *buffer, DisposeAfterUse::Flag disposeAfterUse) {
- CWaveFile *waveFile = new CWaveFile();
+ CWaveFile *waveFile = new CWaveFile(_mixer);
// Try to load the specified audio buffer
if (!waveFile->loadMusic(buffer, disposeAfterUse)) {
diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp
index e6232204e7..90367b00a8 100644
--- a/engines/titanic/sound/wave_file.cpp
+++ b/engines/titanic/sound/wave_file.cpp
@@ -64,13 +64,13 @@ bool AudioBufferStream::endOfData() const {
/*------------------------------------------------------------------------*/
-CWaveFile::CWaveFile() : _audioStream(nullptr),
+CWaveFile::CWaveFile(Audio::Mixer *mixer) : _mixer(mixer), _pendingAudioStream(nullptr),
_waveData(nullptr), _waveSize(0), _dataSize(0), _headerSize(0),
_rate(0), _flags(0), _wavType(0), _soundType(Audio::Mixer::kPlainSoundType) {
setup();
}
-CWaveFile::CWaveFile(QSoundManager *owner) : _audioStream(nullptr),
+CWaveFile::CWaveFile(QSoundManager *owner) : _pendingAudioStream(nullptr),
_waveData(nullptr), _waveSize(0), _dataSize(0), _headerSize(0),
_rate(0), _flags(0), _wavType(0), _soundType(Audio::Mixer::kPlainSoundType) {
setup();
@@ -85,10 +85,8 @@ void CWaveFile::setup() {
}
CWaveFile::~CWaveFile() {
- if (_audioStream) {
- //_soundManager->soundFreed(_soundHandle);
- delete _audioStream;
- }
+ // Delete any pending audio stream if it wasn't used
+ delete _pendingAudioStream;
if (_disposeAudioBuffer == DisposeAfterUse::YES && _audioBuffer)
delete _audioBuffer;
@@ -97,7 +95,7 @@ CWaveFile::~CWaveFile() {
}
uint CWaveFile::getDurationTicks() const {
- if (!_audioStream)
+ if (!_rate)
return 0;
// FIXME: The original uses acmStreamSize to calculate
@@ -105,12 +103,10 @@ uint CWaveFile::getDurationTicks() const {
// method works, for now I'm using a simple ratio of a
// sample output to input value
double newSize = (double)_dataSize * (1475712.0 / 199836.0);
- return (uint)(newSize * 1000.0 / _audioStream->getRate());
+ return (uint)(newSize * 1000.0 / _rate);
}
bool CWaveFile::loadSound(const CString &name) {
- assert(!_audioStream);
-
StdCWadFile file;
if (!file.open(name))
return false;
@@ -139,8 +135,6 @@ bool CWaveFile::loadSpeech(CDialogueFile *dialogueFile, int speechIndex) {
}
bool CWaveFile::loadMusic(const CString &name) {
- assert(!_audioStream);
-
StdCWadFile file;
if (!file.open(name))
return false;
@@ -161,7 +155,7 @@ bool CWaveFile::loadMusic(CAudioBuffer *buffer, DisposeAfterUse::Flag disposeAft
_disposeAudioBuffer = disposeAfterUse;
_loadMode = LOADMODE_AUDIO_BUFFER;
- _audioStream = new AudioBufferStream(_audioBuffer);
+ _pendingAudioStream = new AudioBufferStream(_audioBuffer);
return true;
}
@@ -176,28 +170,24 @@ void CWaveFile::load(byte *data, uint dataSize) {
_headerSize = wavStream.pos();
}
-Audio::SeekableAudioStream *CWaveFile::audioStream() {
- if (!_audioStream) {
- // No stream yet, so create one and give it control of the raw wave data
- assert(_waveData);
- _audioStream = Audio::makeWAVStream(
- new Common::MemoryReadStream(_waveData, _waveSize, DisposeAfterUse::YES),
+Audio::SeekableAudioStream *CWaveFile::createAudioStream() {
+ Audio::SeekableAudioStream *stream;
+
+ if (_pendingAudioStream) {
+ stream = _pendingAudioStream;
+ _pendingAudioStream = nullptr;
+ } else {
+ // Create a new ScummVM audio stream for the wave file data
+ stream = Audio::makeWAVStream(
+ new Common::MemoryReadStream(_waveData, _waveSize, DisposeAfterUse::NO),
DisposeAfterUse::YES);
- _waveData = nullptr;
}
- return _audioStream;
+ _rate = stream->getRate();
+ return stream;
}
-uint CWaveFile::getFrequency() {
- return audioStream()->getRate();
-}
-
-void CWaveFile::reset() {
- audioStream()->rewind();
-}
-
const int16 *CWaveFile::lock() {
enum { kWaveFormatPCM = 1 };
@@ -220,4 +210,13 @@ void CWaveFile::unlock(const int16 *ptr) {
// No implementation needed in ScummVM
}
-} // End of namespace Titanic z
+Audio::SoundHandle CWaveFile::play(byte volume) {
+ Audio::SeekableAudioStream *stream = createAudioStream();
+ Audio::SoundHandle handle;
+
+ _mixer->playStream(_soundType, &handle, stream, -1,
+ volume, 0, DisposeAfterUse::NO);
+ return handle;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h
index 6bd18989b9..c41d2a8fdc 100644
--- a/engines/titanic/sound/wave_file.h
+++ b/engines/titanic/sound/wave_file.h
@@ -37,6 +37,7 @@ class QSoundManager;
class CWaveFile {
private:
+ Audio::Mixer *_mixer;
byte *_waveData;
int _waveSize;
int _dataSize;
@@ -44,7 +45,7 @@ private:
int _rate;
byte _flags;
uint16 _wavType;
- Audio::SeekableAudioStream *_audioStream;
+ Audio::SeekableAudioStream *_pendingAudioStream;
private:
/**
* Handles setup of fields shared by the constructors
@@ -55,6 +56,11 @@ private:
* Gets passed the raw data for the wave file
*/
void load(byte *data, uint dataSize);
+
+ /**
+ * Returns a ScummVM Audio Stream for playback purposes
+ */
+ Audio::SeekableAudioStream *createAudioStream();
public:
Audio::Mixer::SoundType _soundType;
@@ -63,7 +69,7 @@ public:
DisposeAfterUse::Flag _disposeAudioBuffer;
int _channel;
public:
- CWaveFile();
+ CWaveFile(Audio::Mixer *mixer);
CWaveFile(QSoundManager *owner);
~CWaveFile();
@@ -80,11 +86,6 @@ public:
uint size() const { return _dataSize; }
/**
- * Returns a ScummVM Audio Stream for playback purposes
- */
- Audio::SeekableAudioStream *audioStream();
-
- /**
* Tries to load the specified wave file sound
*/
bool loadSound(const CString &name);
@@ -108,18 +109,13 @@ public:
* Returns true if the wave file has data loaded
*/
bool isLoaded() const {
- return _audioStream != nullptr || _waveData != nullptr;
+ return _waveData != nullptr;
}
/**
* Return the frequency of the loaded wave file
*/
- uint getFrequency();
-
- /**
- * Resets the music stream
- */
- void reset();
+ uint getFrequency() const { return _rate; }
/**
* Lock sound data for access
@@ -130,6 +126,11 @@ public:
* Unlock sound data after a prior call to lock
*/
void unlock(const int16 *ptr);
+
+ /**
+ * Plays the wave file
+ */
+ Audio::SoundHandle play(byte volume);
};
} // End of namespace Titanic
diff --git a/image/png.cpp b/image/png.cpp
index fc0daf99b5..cfbcba5206 100644
--- a/image/png.cpp
+++ b/image/png.cpp
@@ -250,7 +250,7 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const bool bottomUp) {
#ifdef USE_PNG
const Graphics::PixelFormat requiredFormat_3byte(3, 8, 8, 8, 0, 16, 8, 0, 0);
- const Graphics::PixelFormat requiredFormat_4byte(4, 8, 8, 8, 8, 16, 8, 0, 24);
+ const Graphics::PixelFormat requiredFormat_4byte(4, 8, 8, 8, 8, 0, 8, 16, 24);
if (input.format.bytesPerPixel == 3) {
if (input.format != requiredFormat_3byte) {