[Scummvm-cvs-logs] SF.net SVN: scummvm:[50519] scummvm/trunk/engines/draci
spalek at users.sourceforge.net
spalek at users.sourceforge.net
Wed Jun 30 10:27:10 CEST 2010
Revision: 50519
http://scummvm.svn.sourceforge.net/scummvm/?rev=50519&view=rev
Author: spalek
Date: 2010-06-30 08:27:09 +0000 (Wed, 30 Jun 2010)
Log Message:
-----------
Generalize the sound archive framework to be able to open new formats
Modified Paths:
--------------
scummvm/trunk/engines/draci/draci.cpp
scummvm/trunk/engines/draci/game.cpp
scummvm/trunk/engines/draci/game.h
scummvm/trunk/engines/draci/sound.cpp
scummvm/trunk/engines/draci/sound.h
Modified: scummvm/trunk/engines/draci/draci.cpp
===================================================================
--- scummvm/trunk/engines/draci/draci.cpp 2010-06-30 08:01:19 UTC (rev 50518)
+++ scummvm/trunk/engines/draci/draci.cpp 2010-06-30 08:27:09 UTC (rev 50519)
@@ -123,8 +123,8 @@
_itemImagesArchive = new BArchive(itemImagesPath);
_stringsArchive = new BArchive(stringsPath);
- _soundsArchive = new SoundArchive(soundsPath, kSoundsFrequency);
- _dubbingArchive = new SoundArchive(dubbingPath, kDubbingFrequency);
+ _soundsArchive = new LegacySoundArchive(soundsPath, kSoundsFrequency);
+ _dubbingArchive = new LegacySoundArchive(dubbingPath, kDubbingFrequency);
_sound = new Sound(_mixer);
MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM);
Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp 2010-06-30 08:01:19 UTC (rev 50518)
+++ scummvm/trunk/engines/draci/game.cpp 2010-06-30 08:27:09 UTC (rev 50519)
@@ -332,7 +332,7 @@
}
}
-int Game::inventoryPositionFromMouse() {
+int Game::inventoryPositionFromMouse() const {
const int column = CLIP(scummvm_lround(
(_vm->_mouse->getPosX() - kInventoryX + kInventoryItemWidth / 2.) /
kInventoryItemWidth) - 1, 0L, (long) kInventoryColumns - 1);
Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h 2010-06-30 08:01:19 UTC (rev 50518)
+++ scummvm/trunk/engines/draci/game.h 2010-06-30 08:27:09 UTC (rev 50519)
@@ -335,7 +335,7 @@
private:
void updateOrdinaryCursor();
void updateInventoryCursor();
- int inventoryPositionFromMouse();
+ int inventoryPositionFromMouse() const;
void handleOrdinaryLoop(int x, int y);
void handleInventoryLoop();
void handleDialogueLoop();
Modified: scummvm/trunk/engines/draci/sound.cpp
===================================================================
--- scummvm/trunk/engines/draci/sound.cpp 2010-06-30 08:01:19 UTC (rev 50518)
+++ scummvm/trunk/engines/draci/sound.cpp 2010-06-30 08:27:09 UTC (rev 50519)
@@ -39,7 +39,7 @@
namespace Draci {
-void SoundArchive::openArchive(const Common::String &path) {
+void LegacySoundArchive::openArchive(const Common::String &path) {
// Close previously opened archive (if any)
closeArchive();
@@ -103,12 +103,12 @@
}
/**
- * @brief SoundArchive close method
+ * @brief LegacySoundArchive close method
*
* Closes the currently opened archive. It can be called explicitly to
* free up memory.
*/
-void SoundArchive::closeArchive() {
+void LegacySoundArchive::closeArchive() {
clearCache();
delete _f;
_f = NULL;
@@ -123,7 +123,7 @@
* Clears the cache of the open files inside the archive without closing it.
* If the files are subsequently accessed, they are read from the disk.
*/
-void SoundArchive::clearCache() {
+void LegacySoundArchive::clearCache() {
// Delete all cached data
for (uint i = 0; i < _sampleCount; ++i) {
_samples[i].close();
@@ -137,7 +137,7 @@
*
* Loads individual samples from an archive to memory on demand.
*/
-SoundSample *SoundArchive::getSample(int i, uint freq) {
+SoundSample *LegacySoundArchive::getSample(int i, uint freq) {
// Check whether requested file exists
if (i < 0 || i >= (int) _sampleCount) {
return NULL;
Modified: scummvm/trunk/engines/draci/sound.h
===================================================================
--- scummvm/trunk/engines/draci/sound.h 2010-06-30 08:01:19 UTC (rev 50518)
+++ scummvm/trunk/engines/draci/sound.h 2010-06-30 08:27:09 UTC (rev 50519)
@@ -47,29 +47,62 @@
}
};
+/**
+ * An abstract wrapper around archives of sound samples or dubbing.
+ */
class SoundArchive {
public:
- SoundArchive(const Common::String &path, uint defaultFreq) :
+ SoundArchive() { }
+ virtual ~SoundArchive() { }
+
+ /**
+ * Returns the number of sound samples in the archive. Zero means that
+ * a fake empty archive has been opened and the caller may consider
+ * opening a different one, for example with compressed music.
+ */
+ virtual uint size() const = 0;
+
+ /**
+ * Checks whether there is an archive opened. Should be called before reading
+ * from the archive to check whether opening of the archive has succeeded.
+ */
+ virtual bool isOpen() const = 0;
+
+ /**
+ * Removes cached samples from memory.
+ */
+ virtual void clearCache() = 0;
+
+ /**
+ * Caches a given sample into memory and returns a pointer into it. We
+ * own the pointer. If freq is nonzero, then the sample is played at a
+ * different frequency (only used for uncompressed samples).
+ */
+ virtual SoundSample *getSample(int i, uint freq) = 0;
+};
+
+/**
+ * Reads CD.SAM (with dubbing) and CD2.SAM (with sound samples) from the
+ * original game.
+ */
+class LegacySoundArchive : public SoundArchive {
+public:
+ LegacySoundArchive(const Common::String &path, uint defaultFreq) :
_path(), _samples(NULL), _sampleCount(0), _defaultFreq(defaultFreq), _opened(false), _f(NULL) {
openArchive(path);
}
- ~SoundArchive() { closeArchive(); }
+ virtual ~LegacySoundArchive() { closeArchive(); }
void closeArchive();
void openArchive(const Common::String &path);
- uint size() const { return _sampleCount; }
- /**
- * Checks whether there is an archive opened. Should be called before reading
- * from the archive to check whether openArchive() succeeded.
- */
- bool isOpen() const { return _opened; }
+ virtual uint size() const { return _sampleCount; }
+ virtual bool isOpen() const { return _opened; }
- void clearCache();
+ virtual void clearCache();
+ virtual SoundSample *getSample(int i, uint freq);
- SoundSample *getSample(int i, uint freq);
-
private:
Common::String _path; ///< Path to file
SoundSample *_samples; ///< Internal array of files
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list