aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/dc/vmsave.cpp19
-rw-r--r--backends/platform/n64/framfs_save_manager.h3
-rw-r--r--backends/platform/n64/pakfs_save_manager.h4
-rw-r--r--common/file.cpp2
-rw-r--r--common/file.h2
-rw-r--r--common/memstream.h4
-rw-r--r--common/stream.cpp2
-rw-r--r--common/stream.h8
-rw-r--r--common/zlib.cpp6
-rw-r--r--engines/mohawk/dialogs.cpp13
-rw-r--r--engines/mohawk/dialogs.h4
-rw-r--r--engines/mohawk/myst.cpp2
-rw-r--r--engines/mohawk/riven.cpp2
-rw-r--r--engines/titanic/core/game_object.cpp12
-rw-r--r--engines/titanic/core/game_object.h2
-rw-r--r--engines/titanic/module.mk2
-rw-r--r--engines/titanic/sound/proximity.cpp (renamed from engines/titanic/support/proximity.cpp)2
-rw-r--r--engines/titanic/sound/proximity.h (renamed from engines/titanic/support/proximity.h)0
-rw-r--r--engines/titanic/sound/sound.cpp114
-rw-r--r--engines/titanic/sound/sound.h64
-rw-r--r--engines/titanic/sound/sound_manager.cpp13
-rw-r--r--engines/titanic/sound/sound_manager.h55
-rw-r--r--engines/titanic/sound/wave_file.cpp5
-rw-r--r--engines/titanic/sound/wave_file.h2
-rw-r--r--engines/titanic/true_talk/dialogue_file.h6
-rw-r--r--engines/titanic/true_talk/true_talk_manager.cpp6
-rw-r--r--engines/wage/detection.cpp15
-rw-r--r--engines/wage/saveload.cpp6
-rw-r--r--graphics/module.mk2
29 files changed, 283 insertions, 94 deletions
diff --git a/backends/platform/dc/vmsave.cpp b/backends/platform/dc/vmsave.cpp
index 75fc1ed0df..d896ba1299 100644
--- a/backends/platform/dc/vmsave.cpp
+++ b/backends/platform/dc/vmsave.cpp
@@ -269,15 +269,16 @@ public:
class OutVMSave : public Common::OutSaveFile {
private:
char *buffer;
- int pos, size, committed;
+ int _pos, size, committed;
char filename[16];
bool iofailed;
public:
uint32 write(const void *buf, uint32 cnt);
+ virtual int32 pos() const { return _pos; }
OutVMSave(const char *_filename)
- : pos(0), committed(-1), iofailed(false)
+ : _pos(0), committed(-1), iofailed(false)
{
strncpy(filename, _filename, 16);
buffer = new char[size = MAX_SAVE_SIZE];
@@ -320,14 +321,14 @@ void OutVMSave::finalize()
extern const char *gGameName;
extern Icon icon;
- if (committed >= pos)
+ if (committed >= _pos)
return;
char *data = buffer;
- int len = pos;
+ int len = _pos;
vmsaveResult r = writeSaveGame(gGameName, data, len, filename, icon);
- committed = pos;
+ committed = _pos;
if (r != VMSAVE_OK)
iofailed = true;
displaySaveResult(r);
@@ -386,13 +387,13 @@ bool InVMSave::seek(int32 offs, int whence)
uint32 OutVMSave::write(const void *buf, uint32 cnt)
{
int nbyt = cnt;
- if (pos + nbyt > size) {
- cnt = (size - pos);
+ if (_pos + nbyt > size) {
+ cnt = (size - _pos);
nbyt = cnt;
}
if (nbyt)
- memcpy(buffer + pos, buf, nbyt);
- pos += nbyt;
+ memcpy(buffer + _pos, buf, nbyt);
+ _pos += nbyt;
return cnt;
}
diff --git a/backends/platform/n64/framfs_save_manager.h b/backends/platform/n64/framfs_save_manager.h
index a066854aab..9bd4ee579e 100644
--- a/backends/platform/n64/framfs_save_manager.h
+++ b/backends/platform/n64/framfs_save_manager.h
@@ -71,6 +71,9 @@ private:
public:
uint32 write(const void *buf, uint32 cnt);
+ virtual int32 pos() const {
+ return framfs_tell(fd);
+ }
OutFRAMSave(const char *_filename) : fd(NULL) {
fd = framfs_open(_filename, "w");
diff --git a/backends/platform/n64/pakfs_save_manager.h b/backends/platform/n64/pakfs_save_manager.h
index ec66c80b73..0c08f0c506 100644
--- a/backends/platform/n64/pakfs_save_manager.h
+++ b/backends/platform/n64/pakfs_save_manager.h
@@ -72,6 +72,10 @@ private:
public:
uint32 write(const void *buf, uint32 cnt);
+ virtual int32 pos() const {
+ return pakfs_tell(fd);
+ }
+
OutPAKSave(const char *_filename) : fd(NULL) {
fd = pakfs_open(_filename, "w");
}
diff --git a/common/file.cpp b/common/file.cpp
index 16e6a0df1a..4d9c630076 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -202,4 +202,6 @@ bool DumpFile::flush() {
return _handle->flush();
}
+int32 DumpFile::pos() const { return _handle->pos(); }
+
} // End of namespace Common
diff --git a/common/file.h b/common/file.h
index c055acc57d..3d174834e9 100644
--- a/common/file.h
+++ b/common/file.h
@@ -161,6 +161,8 @@ public:
virtual uint32 write(const void *dataPtr, uint32 dataSize);
virtual bool flush();
+
+ virtual int32 pos() const;
};
} // End of namespace Common
diff --git a/common/memstream.h b/common/memstream.h
index 94407f5cc9..59d5f15b1a 100644
--- a/common/memstream.h
+++ b/common/memstream.h
@@ -111,7 +111,7 @@ public:
return dataSize;
}
- uint32 pos() const { return _pos; }
+ int32 pos() const { return _pos; }
uint32 size() const { return _bufSize; }
virtual bool err() const { return _err; }
@@ -201,7 +201,7 @@ public:
return dataSize;
}
- uint32 pos() const { return _pos; }
+ int32 pos() const { return _pos; }
uint32 size() const { return _size; }
byte *getData() { return _data; }
diff --git a/common/stream.cpp b/common/stream.cpp
index 45060b9db5..a8446a9086 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -500,6 +500,8 @@ public:
virtual bool flush() { return flushBuffer(); }
+ virtual int32 pos() const { return _pos; }
+
};
} // End of anonymous namespace
diff --git a/common/stream.h b/common/stream.h
index abe5192b70..c6c300fa97 100644
--- a/common/stream.h
+++ b/common/stream.h
@@ -103,6 +103,14 @@ public:
flush();
}
+ /**
+ * Obtains the current value of the stream position indicator of the
+ * stream.
+ *
+ * @return the current position indicator, or -1 if an error occurred.
+ */
+ virtual int32 pos() const = 0;
+
// The remaining methods all have default implementations; subclasses
// need not (and should not) overload them.
diff --git a/common/zlib.cpp b/common/zlib.cpp
index c22ea1e660..39130beb4e 100644
--- a/common/zlib.cpp
+++ b/common/zlib.cpp
@@ -316,6 +316,7 @@ protected:
ScopedPtr<WriteStream> _wrapped;
z_stream _stream;
int _zlibErr;
+ uint32 _pos;
void processData(int flushType) {
// This function is called by both write() and finalize().
@@ -333,7 +334,7 @@ protected:
}
public:
- GZipWriteStream(WriteStream *w) : _wrapped(w), _stream() {
+ GZipWriteStream(WriteStream *w) : _wrapped(w), _stream(), _pos(0) {
assert(w != 0);
// Adding 16 to windowBits indicates to zlib that it is supposed to
@@ -403,8 +404,11 @@ public:
// ... and flush it to disk
processData(Z_NO_FLUSH);
+ _pos += dataSize - _stream.avail_in;
return dataSize - _stream.avail_in;
}
+
+ virtual int32 pos() const { return _pos; }
};
#endif // USE_ZLIB
diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp
index 8c11e3a5e9..38be98dfec 100644
--- a/engines/mohawk/dialogs.cpp
+++ b/engines/mohawk/dialogs.cpp
@@ -92,7 +92,7 @@ enum {
MohawkOptionsDialog::MohawkOptionsDialog(MohawkEngine *vm) :
GUI::Dialog(0, 0, 360, 200),
- _vm(vm) {
+ _vm(vm), _loadSlot(-1) {
_loadButton = new GUI::ButtonWidget(this, 245, 25, 100, 25, _("~L~oad"), 0, kLoadCmd);
_saveButton = new GUI::ButtonWidget(this, 245, 60, 100, 25, _("~S~ave"), 0, kSaveCmd);
new GUI::ButtonWidget(this, 245, 95, 100, 25, _("~Q~uit"), 0, kQuitCmd);
@@ -112,6 +112,7 @@ MohawkOptionsDialog::~MohawkOptionsDialog() {
void MohawkOptionsDialog::open() {
GUI::Dialog::open();
+ _loadSlot = -1;
_loadButton->setEnabled(_vm->canLoadGameStateCurrently());
_saveButton->setEnabled(_vm->canSaveGameStateCurrently());
}
@@ -133,12 +134,14 @@ void MohawkOptionsDialog::save() {
}
void MohawkOptionsDialog::load() {
- int slot = _loadDialog->runModalWithCurrentTarget();
+ // Do not load the game state from insite the dialog loop to
+ // avoid mouse cursor glitches (see bug #7164). Instead store
+ // the slot to load and let the code exectuting the dialog do
+ // the load after the dialog finished running.
+ _loadSlot = _loadDialog->runModalWithCurrentTarget();
- if (slot >= 0) {
- _vm->loadGameState(slot);
+ if (_loadSlot >= 0)
close();
- }
}
void MohawkOptionsDialog::reflowLayout() {
diff --git a/engines/mohawk/dialogs.h b/engines/mohawk/dialogs.h
index 3cfb628f9d..99db641948 100644
--- a/engines/mohawk/dialogs.h
+++ b/engines/mohawk/dialogs.h
@@ -81,6 +81,8 @@ public:
virtual void open() override;
virtual void reflowLayout() override;
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;
+
+ int getLoadSlot() const {return _loadSlot;}
private:
MohawkEngine *_vm;
@@ -90,6 +92,8 @@ private:
GUI::SaveLoadChooser *_loadDialog;
GUI::SaveLoadChooser *_saveDialog;
+
+ int _loadSlot;
void save();
void load();
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 633b67f7e9..a1c6d0e748 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -309,6 +309,8 @@ Common::Error MohawkEngine_Myst::run() {
_canSafelySaveLoad = true;
runDialog(*_optionsDialog);
+ if (_optionsDialog->getLoadSlot() >= 0)
+ loadGameState(_optionsDialog->getLoadSlot());
_canSafelySaveLoad = false;
if (_needsPageDrop) {
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index aa168a38d8..b05b76da30 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -258,6 +258,8 @@ void MohawkEngine_Riven::handleEvents() {
break;
case Common::KEYCODE_F5:
runDialog(*_optionsDialog);
+ if (_optionsDialog->getLoadSlot() >= 0)
+ loadGameState(_optionsDialog->getLoadSlot());
updateZipMode();
break;
case Common::KEYCODE_r:
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index c04f2e17f4..30366398c1 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -644,7 +644,17 @@ int CGameObject::playSound(const CString &name, int val2, int val3, int val4) {
int CGameObject::playSound(const CString &name, CProximity &prox) {
if (prox._field28 == 2) {
- // TODO
+ // If the proximity doesn't have a position defined, default it to
+ // the position of the view to which the game object belongs
+ if (prox._posX == 0.0 && prox._posY == 0.0 && prox._posZ == 0.0)
+ findView()->getPosition(prox._posX, prox._posY, prox._posZ);
+ }
+
+ CGameManager *gameManager = getGameManager();
+ if (gameManager) {
+ g_vm->_filesManager->preload(name);
+
+ gameManager->_sound.playSound(name, prox);
}
return 0;
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index abb7e999d6..ec7f77cff6 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -26,7 +26,7 @@
#include "titanic/support/mouse_cursor.h"
#include "titanic/support/credit_text.h"
#include "titanic/support/movie_range_info.h"
-#include "titanic/support/proximity.h"
+#include "titanic/sound/proximity.h"
#include "titanic/support/rect.h"
#include "titanic/support/movie_clip.h"
#include "titanic/core/named_item.h"
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 61e8071fba..b4780d8a5c 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -402,6 +402,7 @@ MODULE_OBJS := \
sound/music_room.o \
sound/music_player.o \
sound/node_auto_sound_player.o \
+ sound/proximity.o \
sound/restricted_auto_music_player.o \
sound/room_auto_sound_player.o \
sound/room_trigger_auto_music_player.o \
@@ -460,7 +461,6 @@ MODULE_OBJS := \
support/movie_range_info.o \
support/movie_manager.o \
support/credit_text.o \
- support/proximity.o \
support/rect.o \
support/screen_manager.o \
support/simple_file.o \
diff --git a/engines/titanic/support/proximity.cpp b/engines/titanic/sound/proximity.cpp
index 9784ae353b..af23b7bd5f 100644
--- a/engines/titanic/support/proximity.cpp
+++ b/engines/titanic/sound/proximity.cpp
@@ -20,7 +20,7 @@
*
*/
-#include "titanic/support/proximity.h"
+#include "titanic/sound/proximity.h"
#include "titanic/true_talk/tt_talker.h"
namespace Titanic {
diff --git a/engines/titanic/support/proximity.h b/engines/titanic/sound/proximity.h
index 4427574f40..4427574f40 100644
--- a/engines/titanic/support/proximity.h
+++ b/engines/titanic/sound/proximity.h
diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp
index 7968a088da..e8084d79e0 100644
--- a/engines/titanic/sound/sound.cpp
+++ b/engines/titanic/sound/sound.cpp
@@ -71,12 +71,39 @@ void CSound::fn3(int handle, int val2, int val3) {
warning("TODO: CSound::fn3");
}
-int CSound::playSpeech(CDialogueFile *dialogueFile, int speechId, const CProximity &prox) {
- warning("TODO: CSound::playSpeech");
- return 0;
+void CSound::fn4(WaveFile *waveFile, int val) {
+ // TODO
}
-uint CSound::loadSound(const CString &name) {
+void CSound::checkSounds() {
+ for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) {
+ CSoundItem *soundItem = *i;
+ if (soundItem->_field24 && soundItem->_field28) {
+ if (_soundManager.isActive(soundItem->_waveFile)) {
+ _sounds.remove(soundItem);
+ delete soundItem;
+ }
+ }
+ }
+}
+
+void CSound::removeOldest() {
+ for (CSoundItemList::iterator i = _sounds.reverse_begin();
+ i != _sounds.end(); --i) {
+ CSoundItem *soundItem = *i;
+ if (soundItem->_field28 && !_soundManager.isActive(soundItem->_waveFile)) {
+ _sounds.remove(soundItem);
+ delete soundItem;
+ break;
+ }
+ }
+}
+
+WaveFile *CSound::getTrueTalkSound(CDialogueFile *dialogueFile, int index) {
+ return loadSpeech(dialogueFile, index);
+}
+
+WaveFile *CSound::loadSound(const CString &name) {
checkSounds();
// Check whether an entry for the given name is already active
@@ -86,16 +113,16 @@ uint 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);
- return soundItem->_soundHandle;
+ return soundItem->_waveFile;
}
}
// Create new sound item
CSoundItem *soundItem = new CSoundItem(name);
- soundItem->_soundHandle = _soundManager.loadSound(name);
+ soundItem->_waveFile = _soundManager.loadSound(name);
- if (!soundItem->_soundHandle) {
- // Could load sound, so destroy new item and return
+ if (!soundItem->_waveFile) {
+ // Couldn't load sound, so destroy new item and return
delete soundItem;
return 0;
}
@@ -108,36 +135,65 @@ uint CSound::loadSound(const CString &name) {
if (_sounds.size() > 10)
removeOldest();
- return soundItem->_soundHandle;
+ return soundItem->_waveFile;
}
-void CSound::checkSounds() {
- for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) {
- CSoundItem *soundItem = *i;
- if (soundItem->_field24 && soundItem->_field28) {
- if (_soundManager.isActive(soundItem->_soundHandle)) {
- _sounds.remove(soundItem);
- delete soundItem;
- }
- }
- }
+int CSound::playSound(const CString &name, CProximity &prox) {
+ WaveFile *waveFile = loadSound(name);
+ if (!waveFile)
+ return -1;
+
+ prox._field6C = waveFile->fn1();
+ fn4(waveFile, prox._field60);
+
+ return _soundManager.playSound(*waveFile, prox);
}
-void CSound::removeOldest() {
- for (CSoundItemList::iterator i = _sounds.reverse_begin();
- i != _sounds.end(); --i) {
+WaveFile *CSound::loadSpeech(CDialogueFile *dialogueFile, int speechId) {
+ checkSounds();
+
+ // Check whether an entry for the given name is already active
+ for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) {
CSoundItem *soundItem = *i;
- if (soundItem->_field28 && !_soundManager.isActive(soundItem->_soundHandle)) {
+ if (soundItem->_dialogueFileHandle == dialogueFile->getFile()
+ && soundItem->_speechId == speechId) {
+ // Found it, so move it to the front of the list and return
_sounds.remove(soundItem);
- delete soundItem;
- break;
+ _sounds.push_front(soundItem);
+ return soundItem->_waveFile;
}
}
+
+ // Create new sound item
+ CSoundItem *soundItem = new CSoundItem(dialogueFile->getFile(), speechId);
+ soundItem->_waveFile = _soundManager.loadSpeech(dialogueFile, speechId);
+
+ if (!soundItem->_waveFile) {
+ // Couldn't load speech, so destroy new item and return
+ delete soundItem;
+ return 0;
+ }
+
+ // Add the item to the list of sounds
+ _sounds.push_front(soundItem);
+
+ // If there are more than 10 sounds loaded, remove the last one,
+ // which is the least recently used of all of them
+ if (_sounds.size() > 10)
+ removeOldest();
+
+ return soundItem->_waveFile;
}
-CSoundItem *CSound::getTrueTalkSound(CDialogueFile *dialogueFile, int index) {
- warning("TODO: CSound::getTrueTalkSound");
- return nullptr;
+int CSound::playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &prox) {
+ WaveFile *waveFile = loadSpeech(dialogueFile, speechId);
+ if (!waveFile)
+ return -1;
+
+ prox._field6C = waveFile->fn1();
+ fn4(waveFile, prox._field60);
+
+ return _soundManager.playSound(*waveFile, prox);
}
-} // End of namespace Titanic z
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/sound.h b/engines/titanic/sound/sound.h
index f550493624..c14c9e17c4 100644
--- a/engines/titanic/sound/sound.h
+++ b/engines/titanic/sound/sound.h
@@ -24,8 +24,9 @@
#define TITANIC_SOUND_H
#include "titanic/support/simple_file.h"
-#include "titanic/support/proximity.h"
+#include "titanic/sound/proximity.h"
#include "titanic/sound/sound_manager.h"
+#include "titanic/sound/wave_file.h"
#include "titanic/core/list.h"
#include "titanic/core/view_item.h"
#include "titanic/true_talk/dialogue_file.h"
@@ -37,16 +38,18 @@ class CGameManager;
class CSoundItem : public ListItem {
public:
CString _name;
- int _soundHandle;
- int _field1C;
- int _field20;
+ WaveFile *_waveFile;
+ File *_dialogueFileHandle;
+ int _speechId;
int _field24;
int _field28;
public:
- CSoundItem() : ListItem(), _soundHandle(0), _field1C(0),
- _field20(0), _field24(0), _field28(0) {}
- CSoundItem(const CString &name) : ListItem(), _name(name),
- _soundHandle(0), _field1C(0), _field20(0), _field24(0), _field28(0) {}
+ CSoundItem() : ListItem(), _waveFile(nullptr), _dialogueFileHandle(nullptr),
+ _speechId(0), _field24(0), _field28(0) {}
+ CSoundItem(const CString &name) : ListItem(), _name(name), _waveFile(nullptr),
+ _dialogueFileHandle(nullptr), _speechId(0), _field24(0), _field28(0) {}
+ CSoundItem(File *dialogueFile, int speechId) : ListItem(), _waveFile(nullptr),
+ _dialogueFileHandle(dialogueFile), _speechId(speechId), _field24(0), _field28(0) {}
int fn1();
};
@@ -109,25 +112,48 @@ public:
*/
void preEnterView(CViewItem *newView, bool isNewRoom);
- /**
- * Load a sound
- * @param name Name of sound resource
- * @returns Sound handle Id
- */
- uint loadSound(const CString &name);
-
bool fn1(int val);
void fn2(int handle);
void fn3(int handle, int val2, int val3);
+ void fn4(WaveFile *waveFile, int val);
+
+ void managerProc8(int v) { _soundManager.proc8(v); }
+
+ /**
+ * Loads a TrueTalk dialogue
+ * @param dialogueFile Dialogue file reference
+ * @param speechId Speech Id within dialogue
+ * @returns Wave file instance
+ */
+ WaveFile *getTrueTalkSound(CDialogueFile *dialogueFile, int index);
+
+ /**
+ * Load a speech resource
+ * @param dialogueFile Dialogue file reference
+ * @param speechId Speech Id within dialogue
+ * @returns Wave file instance
+ */
+ WaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId);
/**
* Play a speech
+ * @param dialogueFile Dialogue file reference
+ * @param speechId Speech Id within dialogue
+ * @param prox Proximity instance
*/
- int playSpeech(CDialogueFile *dialogueFile, int speechId, const CProximity &prox);
-
- void managerProc8(int v) { _soundManager.proc8(v); }
+ int playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &prox);
- CSoundItem *getTrueTalkSound(CDialogueFile *dialogueFile, int index);
+ /**
+ * Load a sound
+ * @param name Name of sound resource
+ * @returns Sound item record
+ */
+ WaveFile *loadSound(const CString &name);
+
+ /**
+ * Play a sound
+ */
+ int playSound(const CString &name, CProximity &prox);
};
} // End of namespace Titanic
diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp
index 1cafe3bafa..61ad59ce7f 100644
--- a/engines/titanic/sound/sound_manager.cpp
+++ b/engines/titanic/sound/sound_manager.cpp
@@ -34,14 +34,14 @@ QSoundManager::QSoundManager() : _field18(0), _field1C(0) {
Common::fill(&_field4A0[0], &_field4A0[16], 0);
}
-int QSoundManager::loadSound(const CString &name) {
+WaveFile *QSoundManager::loadSound(const CString &name) {
warning("TODO");
- return 0;
+ return nullptr;
}
-int QSoundManager::proc4() const {
+WaveFile *QSoundManager::loadSpeech(CDialogueFile *dialogueFile, int speechId) {
warning("TODO");
- return 0;
+ return nullptr;
}
int QSoundManager::proc5() const {
@@ -49,8 +49,9 @@ int QSoundManager::proc5() const {
return 0;
}
-void QSoundManager::proc6() {
+int QSoundManager::playSound(WaveFile &soundRes, CProximity &prox) {
warning("TODO");
+ return 0;
}
void QSoundManager::proc7() {
@@ -86,7 +87,7 @@ bool QSoundManager::proc14() {
return false;
}
-bool QSoundManager::isActive(int handle) const {
+bool QSoundManager::isActive(const WaveFile *waveFile) const {
warning("TODO");
return false;
}
diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h
index a65162d779..85ee00a3f7 100644
--- a/engines/titanic/sound/sound_manager.h
+++ b/engines/titanic/sound/sound_manager.h
@@ -24,6 +24,9 @@
#define TITANIC_SOUND_MANAGER_H
#include "titanic/support/simple_file.h"
+#include "titanic/sound/proximity.h"
+#include "titanic/sound/wave_file.h"
+#include "titanic/true_talk/dialogue_file.h"
namespace Titanic {
@@ -41,13 +44,24 @@ public:
/**
* Loads a sound
* @param name Name of sound resource
- * @returns Loaded sound handle
+ * @returns Loaded wave file
*/
- virtual int loadSound(const CString &name) { return 0; }
+ virtual WaveFile *loadSound(const CString &name) { return nullptr; }
+
+ /**
+ * Loads a speech resource from a dialogue file
+ * @param name Name of sound resource
+ * @returns Loaded wave file
+ */
+ virtual WaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId) { return 0; }
- virtual int proc4() const { return 0; }
virtual int proc5() const { return 0; }
- virtual void proc6() = 0;
+
+ /**
+ * Start playing a previously loaded wave file
+ */
+ virtual int playSound(WaveFile &waveFile, CProximity &prox) = 0;
+
virtual void proc7() = 0;
virtual void proc8(int v) = 0;
virtual void proc9() {}
@@ -56,7 +70,12 @@ public:
virtual void proc12() {}
virtual void proc13() {}
virtual bool proc14() = 0;
- virtual bool isActive(int handle) const { return false; }
+
+ /**
+ * Returns true if the given sound is currently active
+ */
+ virtual bool isActive(const WaveFile *waveFile) const { return false; }
+
virtual int proc16() const { return 0; }
virtual void WaveMixPump() {}
@@ -115,13 +134,24 @@ public:
/**
* Loads a sound
* @param name Name of sound resource
- * @returns Loaded sound handle
+ * @returns Loaded wave file
*/
- virtual int loadSound(const CString &name);
+ virtual WaveFile *loadSound(const CString &name);
+
+ /**
+ * Loads a speech resource from a dialogue file
+ * @param name Name of sound resource
+ * @returns Loaded wave file
+ */
+ virtual WaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId);
- virtual int proc4() const;
virtual int proc5() const;
- virtual void proc6();
+
+ /**
+ * Start playing a previously loaded sound resource
+ */
+ virtual int playSound(WaveFile &waveFile, CProximity &prox);
+
virtual void proc7();
virtual void proc8(int v);
virtual void proc9();
@@ -130,7 +160,12 @@ public:
virtual void proc12();
virtual void proc13();
virtual bool proc14();
- virtual bool isActive(int handle) const;
+
+ /**
+ * Returns true if the given sound is currently active
+ */
+ virtual bool isActive(const WaveFile *soundRes) const;
+
virtual int proc16() const;
virtual void WaveMixPump();
diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp
index 288f5f525d..2459f1eee6 100644
--- a/engines/titanic/sound/wave_file.cpp
+++ b/engines/titanic/sound/wave_file.cpp
@@ -24,4 +24,9 @@
namespace Titanic {
+int WaveFile::fn1() {
+ // TODO
+ return 0;
+}
+
} // End of namespace Titanic z
diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h
index 0bb836ef74..b27e5e7707 100644
--- a/engines/titanic/sound/wave_file.h
+++ b/engines/titanic/sound/wave_file.h
@@ -47,6 +47,8 @@ public:
WaveFile() : _field0(2), _field4(0), _field8(0), _handle(0),
_owner(nullptr), _field14(1), _field18(0), _field1C(0),
_field20(0), _field24(0), _field28(0), _field2C(-1) {}
+
+ int fn1();
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/dialogue_file.h b/engines/titanic/true_talk/dialogue_file.h
index 299d01daa8..19e94cf9b9 100644
--- a/engines/titanic/true_talk/dialogue_file.h
+++ b/engines/titanic/true_talk/dialogue_file.h
@@ -23,7 +23,7 @@
#ifndef TITANIC_DIALOGUE_FILE_H
#define TITANIC_DIALOGUE_FILE_H
-#include "common/file.h"
+#include "titanic/support/simple_file.h"
#include "titanic/support/string.h"
namespace Titanic {
@@ -51,7 +51,7 @@ struct DialogueResource {
class CDialogueFile {
private:
- Common::File _file;
+ File _file;
Common::Array<DialogueIndexEntry> _index;
Common::Array<DialogueResource> _cache;
private:
@@ -68,6 +68,8 @@ public:
*/
void clear();
+ File *getFile() { return &_file; }
+
/**
* Sets up a text entry within the dialogue file for access
*/
diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp
index 072832af4d..977fc892c6 100644
--- a/engines/titanic/true_talk/true_talk_manager.cpp
+++ b/engines/titanic/true_talk/true_talk_manager.cpp
@@ -408,10 +408,10 @@ int CTrueTalkManager::readDialogSound() {
_field18 = 0;
for (uint idx = 0; idx < _titleEngine._indexes.size(); ++idx) {
- CSoundItem *soundItem = _gameManager->_sound.getTrueTalkSound(
+ WaveFile *waveFile = _gameManager->_sound.getTrueTalkSound(
_dialogueFile, _titleEngine._indexes[idx] - _dialogueId);
- if (soundItem) {
- _field18 = soundItem->fn1();
+ if (waveFile) {
+ _field18 = waveFile->fn1();
}
}
diff --git a/engines/wage/detection.cpp b/engines/wage/detection.cpp
index e14a952588..a27bfd7fde 100644
--- a/engines/wage/detection.cpp
+++ b/engines/wage/detection.cpp
@@ -99,7 +99,7 @@ SaveStateList WageMetaEngine::listSaves(const char *target) const {
const uint32 WAGEflag = MKTAG('W','A','G','E');
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
- char saveDesc[31];
+ char saveDesc[128] = {0};
Common::String pattern = target;
pattern += ".###";
@@ -113,9 +113,18 @@ SaveStateList WageMetaEngine::listSaves(const char *target) const {
if (slotNum >= 0 && slotNum <= 999) {
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
+ saveDesc[0] = 0;
+ in->seek(in->size() - 8);
+ uint32 offset = in->readUint32BE();
uint32 type = in->readUint32BE();
- if (type == WAGEflag)
- in->read(saveDesc, 31);
+ if (type == WAGEflag) {
+ in->seek(offset);
+
+ type = in->readUint32BE();
+ if (type == WAGEflag) {
+ in->read(saveDesc, 127);
+ }
+ }
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
delete in;
}
diff --git a/engines/wage/saveload.cpp b/engines/wage/saveload.cpp
index 78e8d389d3..c3b20bdf2f 100644
--- a/engines/wage/saveload.cpp
+++ b/engines/wage/saveload.cpp
@@ -335,6 +335,10 @@ int WageEngine::saveGame(const Common::String &fileName, const Common::String &d
}
// the following is appended by ScummVM
+ int32 appendixOffset = out->pos();
+ if (appendixOffset < 0) {
+ warning("OutSaveFile::pos() failed");
+ }
out->writeUint32BE(WAGEflag);
// Write description of saved game, limited to WAGE_SAVEDGAME_DESCRIPTION_LEN characters + terminating NUL
@@ -352,6 +356,8 @@ int WageEngine::saveGame(const Common::String &fileName, const Common::String &d
// Thumbnail
Graphics::saveThumbnail(*out);
+ out->writeUint32BE(appendixOffset);
+
// this one to make checking easier:
// it couldn't be added to the beginning
// and we won't be able to find it in the middle,
diff --git a/graphics/module.mk b/graphics/module.mk
index f0f5af6c00..1c87e74ba7 100644
--- a/graphics/module.mk
+++ b/graphics/module.mk
@@ -15,7 +15,7 @@ MODULE_OBJS := \
macgui/macmenu.o \
macgui/macwindow.o \
macgui/macwindowborder.o \
- macgui/macwindowmanager.o\
+ macgui/macwindowmanager.o \
managed_surface.o \
nine_patch.o \
pixelformat.o \