[Scummvm-cvs-logs] scummvm master -> 07994fb3610ddf1b3b23fbd53aaff44a4626f756
bluegr
bluegr at gmail.com
Thu Dec 13 02:10:48 CET 2012
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
576d92e286 TINSEL: Clean up the sound code
fe3737f7a3 TINSEL: Remove outdated comment
a3f22b8804 TINSEL: Unify the PSX graphics drawing code with the rest
07994fb361 TINSEL: Add support for the digitized music in DW1 Mac
Commit: 576d92e2861d6b94be0c19a557f92f7ce13a17f4
https://github.com/scummvm/scummvm/commit/576d92e2861d6b94be0c19a557f92f7ce13a17f4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2012-12-12T15:58:47-08:00
Commit Message:
TINSEL: Clean up the sound code
Changed paths:
engines/tinsel/sound.cpp
engines/tinsel/sound.h
engines/tinsel/tinlib.cpp
diff --git a/engines/tinsel/sound.cpp b/engines/tinsel/sound.cpp
index c7b295f..794e3f7 100644
--- a/engines/tinsel/sound.cpp
+++ b/engines/tinsel/sound.cpp
@@ -74,7 +74,7 @@ SoundManager::~SoundManager() {
*/
// playSample for DiscWorld 1
bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::SoundHandle *handle) {
- // Floppy version has no sample file
+ // Floppy version has no sample file.
if (!_vm->isCD())
return false;
@@ -369,7 +369,6 @@ bool SoundManager::offscreenChecks(int x, int &y) {
}
int8 SoundManager::getPan(int x) {
-
if (x == -1)
return 0;
@@ -416,14 +415,13 @@ bool SoundManager::sampleExists(int id) {
/**
* Returns true if a sample is currently playing.
*/
-bool SoundManager::sampleIsPlaying(int id) {
+bool SoundManager::sampleIsPlaying() {
if (!TinselV2)
return _vm->_mixer->isSoundHandleActive(_channels[kChannelTinsel1].handle);
for (int i = 0; i < kNumChannels; i++)
- if (_channels[i].sampleNum == id)
- if (_vm->_mixer->isSoundHandleActive(_channels[i].handle))
- return true;
+ if (_vm->_mixer->isSoundHandleActive(_channels[i].handle))
+ return true;
return false;
}
@@ -432,8 +430,6 @@ bool SoundManager::sampleIsPlaying(int id) {
* Stops any currently playing sample.
*/
void SoundManager::stopAllSamples() {
- // stop currently playing sample
-
if (!TinselV2) {
_vm->_mixer->stopHandle(_channels[kChannelTinsel1].handle);
return;
@@ -466,12 +462,21 @@ void SoundManager::setSFXVolumes(uint8 volume) {
_vm->_mixer->setChannelVolume(_channels[i].handle, volume);
}
+void SoundManager::showSoundError(const char *errorMsg, const char *soundFile) {
+ Common::String msg;
+ msg = Common::String::format(errorMsg, soundFile);
+ GUI::MessageDialog dialog(msg, "OK");
+ dialog.runModal();
+
+ error(msg.c_str());
+}
+
/**
* Opens and inits all sound sample files.
*/
void SoundManager::openSampleFiles() {
// Floppy and demo versions have no sample files, except for the Discworld 2 demo
- if (!_vm->isCD() || TinselV0)
+ if (!_vm->isCD())
return;
TinselFile f;
@@ -480,42 +485,26 @@ void SoundManager::openSampleFiles() {
// already allocated
return;
- // open sample index file in binary mode
+ // Open sample index (*.idx) in binary mode
if (f.open(_vm->getSampleIndex(g_sampleLanguage))) {
- // get length of index file
- f.seek(0, SEEK_END); // move to end of file
- _sampleIndexLen = f.pos(); // get file pointer
- f.seek(0, SEEK_SET); // back to beginning
-
+ uint32 fileSize = f.size();
+ _sampleIndex = (uint32 *)malloc(fileSize);
if (_sampleIndex == NULL) {
- // allocate a buffer for the indices
- _sampleIndex = (uint32 *)malloc(_sampleIndexLen);
-
- // make sure memory allocated
- if (_sampleIndex == NULL) {
- // disable samples if cannot alloc buffer for indices
- // TODO: Disabled sound if we can't load the sample index?
- return;
- }
+ showSoundError(NO_MEM, _vm->getSampleIndex(g_sampleLanguage));
+ return;
}
- // load data
- if (f.read(_sampleIndex, _sampleIndexLen) != (uint32)_sampleIndexLen)
- // file must be corrupt if we get to here
- error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
-
- // close the file
- f.close();
-
- // convert file size to size in DWORDs
- _sampleIndexLen /= sizeof(uint32);
+ _sampleIndexLen = fileSize / 4; // total sample of indices (DWORDs)
-#ifdef SCUMM_BIG_ENDIAN
- // Convert all ids from LE to native format
+ // Load data
for (int i = 0; i < _sampleIndexLen; ++i) {
- _sampleIndex[i] = SWAP_BYTES_32(_sampleIndex[i]);
+ _sampleIndex[i] = f.readUint32LE();
+ if (f.err()) {
+ showSoundError(FILE_READ_ERROR, _vm->getSampleIndex(g_sampleLanguage));
+ }
}
-#endif
+
+ f.close();
// Detect format of soundfile by looking at 1st sample-index
switch (TO_BE_32(_sampleIndex[0])) {
@@ -523,48 +512,31 @@ void SoundManager::openSampleFiles() {
debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected MP3 sound-data");
_soundMode = kMP3Mode;
break;
-
case MKTAG('O','G','G',' '):
debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected OGG sound-data");
_soundMode = kVorbisMode;
break;
-
case MKTAG('F','L','A','C'):
debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected FLAC sound-data");
_soundMode = kFLACMode;
break;
-
default:
debugC(DEBUG_DETAILED, kTinselDebugSound, "Detected original sound-data");
break;
}
- // Normally the 1st sample-index points to nothing at all
+
+ // Normally the 1st sample index points to nothing at all. We use it to
+ // determine if the game's sample files have been compressed, thus restore
+ // it here
_sampleIndex[0] = 0;
} else {
- char buf[50];
- sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleIndex(g_sampleLanguage));
- GUI::MessageDialog dialog(buf, "OK");
- dialog.runModal();
-
- error(CANNOT_FIND_FILE, _vm->getSampleIndex(g_sampleLanguage));
+ showSoundError(FILE_READ_ERROR, _vm->getSampleIndex(g_sampleLanguage));
}
- // open sample file in binary mode
+ // Open sample file (*.smp) in binary mode
if (!_sampleStream.open(_vm->getSampleFile(g_sampleLanguage))) {
- char buf[50];
- sprintf(buf, CANNOT_FIND_FILE, _vm->getSampleFile(g_sampleLanguage));
- GUI::MessageDialog dialog(buf, "OK");
- dialog.runModal();
-
- error(CANNOT_FIND_FILE, _vm->getSampleFile(g_sampleLanguage));
+ showSoundError(FILE_READ_ERROR, _vm->getSampleFile(g_sampleLanguage));
}
-
-/*
- // gen length of the largest sample
- sampleBuffer.size = _sampleStream.readUint32LE();
- if (_sampleStream.eos() || _sampleStream.err())
- error(FILE_IS_CORRUPT, _vm->getSampleFile(g_sampleLanguage));
-*/
}
void SoundManager::closeSampleStream() {
diff --git a/engines/tinsel/sound.h b/engines/tinsel/sound.h
index d7083b3..ea5eb45 100644
--- a/engines/tinsel/sound.h
+++ b/engines/tinsel/sound.h
@@ -115,11 +115,13 @@ public:
void setSFXVolumes(uint8 volume);
bool sampleExists(int id);
- bool sampleIsPlaying(int id = -1);
+ bool sampleIsPlaying();
- // TODO: Internal method, make this protected?
void openSampleFiles();
void closeSampleStream();
+
+private:
+ void showSoundError(const char *errorMsg, const char *soundFile);
};
} // End of namespace Tinsel
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index 058f8eb..6a396b9 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -3684,7 +3684,7 @@ static void TranslucentIndex(unsigned index) {
}
/**
- * Play a sample.
+ * Play a sample (DW1 only).
*/
static void TryPlaySample(CORO_PARAM, int sample, bool bComplete, bool escOn, int myEscape) {
CORO_BEGIN_CONTEXT;
Commit: fe3737f7a3a39a5a9ffa88403fa374837315e3a8
https://github.com/scummvm/scummvm/commit/fe3737f7a3a39a5a9ffa88403fa374837315e3a8
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2012-12-12T15:59:33-08:00
Commit Message:
TINSEL: Remove outdated comment
Changed paths:
engines/tinsel/tinsel.h
diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h
index 32e2184..ec504b6 100644
--- a/engines/tinsel/tinsel.h
+++ b/engines/tinsel/tinsel.h
@@ -78,7 +78,7 @@ enum TinselGameFeatures {
/**
* The following is the ScummVM definitions of the various Tinsel versions:
* TINSEL_V0 - This was an early engine version that was only used in the Discworld 1
- * demo. It is not currently supported.
+ * demo.
* TINSEL_V1 - This was the engine version used by Discworld 1. Note that there were two
* major releases: an earlier version that used *.gra files, and a later one that
* used *.scn files, and contained certain script and engine bugfixes. In ScummVM,
Commit: a3f22b88042d2dbbcbe5a82689da16183e974c7a
https://github.com/scummvm/scummvm/commit/a3f22b88042d2dbbcbe5a82689da16183e974c7a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2012-12-12T16:00:59-08:00
Commit Message:
TINSEL: Unify the PSX graphics drawing code with the rest
This is nitpicking, for uniformity which I forgot to add in a previous
cleanup commit
Changed paths:
engines/tinsel/graphics.cpp
diff --git a/engines/tinsel/graphics.cpp b/engines/tinsel/graphics.cpp
index 38e32b4..5f200b5 100644
--- a/engines/tinsel/graphics.cpp
+++ b/engines/tinsel/graphics.cpp
@@ -850,7 +850,7 @@ void DrawObject(DRAWOBJECT *pObj) {
if (TinselV2)
t2WrtNonZero(pObj, srcPtr, destPtr, typeId >= 0x40, (typeId & 0x10) != 0);
else if (TinselV1PSX)
- PsxDrawTiles(pObj, srcPtr, destPtr, typeId >= 0x40, psxFourBitClut, psxSkipBytes, psxMapperTable, true);
+ PsxDrawTiles(pObj, srcPtr, destPtr, typeId == 0x41, psxFourBitClut, psxSkipBytes, psxMapperTable, true);
else if (TinselV1Mac)
{} // TODO
else if (TinselV1)
Commit: 07994fb3610ddf1b3b23fbd53aaff44a4626f756
https://github.com/scummvm/scummvm/commit/07994fb3610ddf1b3b23fbd53aaff44a4626f756
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2012-12-12T17:09:41-08:00
Commit Message:
TINSEL: Add support for the digitized music in DW1 Mac
Changed paths:
engines/tinsel/music.cpp
engines/tinsel/sound.cpp
engines/tinsel/sound.h
diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp
index 91f0312..dab2a89 100644
--- a/engines/tinsel/music.cpp
+++ b/engines/tinsel/music.cpp
@@ -135,10 +135,10 @@ bool PlayMidiSequence(uint32 dwFileOffset, bool bLoop) {
if (ConfMan.hasKey("mute"))
mute = ConfMan.getBool("mute");
- // TODO: The Macintosh version of DW1 does not use MIDI for music
+ // The Macintosh version of DW1 uses raw PCM for music
if (TinselV1Mac)
- return true;
-
+ return _vm->_sound->playDW1MacMusic(dwFileOffset);
+
SetMidiVolume(mute ? 0 : _vm->_config->_musicVolume);
// the index and length of the last tune loaded
@@ -285,7 +285,8 @@ void OpenMidiFiles() {
if (TinselV0 || TinselV2)
return;
- // TODO: The Macintosh version of DW1 does not use MIDI for music
+ // The Macintosh version of DW1 does not use MIDI for music.
+ // It uses PCM music instead, which is quite big to be preloaded here.
if (TinselV1Mac)
return;
diff --git a/engines/tinsel/sound.cpp b/engines/tinsel/sound.cpp
index 794e3f7..886f10c 100644
--- a/engines/tinsel/sound.cpp
+++ b/engines/tinsel/sound.cpp
@@ -177,6 +177,48 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound
return true;
}
+bool SoundManager::playDW1MacMusic(int dwFileOffset) {
+ Common::File s;
+
+ if (!s.open("midi.dat"))
+ error(CANNOT_FIND_FILE, "midi.dat");
+
+ s.seek(dwFileOffset);
+ uint32 length = s.readUint32BE();
+
+ // TODO: It's a bad idea to load the music track in a buffer.
+ // We should use a readStream instead, and keep midi.dat open.
+ // However, the track lengths aren't that big (about 1-4MB),
+ // so this shouldn't be a major issue.
+ byte *soundData = (byte *)malloc(length);
+ assert(soundData);
+
+ // read all of the sample
+ if (s.read(soundData, length) != length)
+ error(FILE_IS_CORRUPT, "midi.dat");
+
+ Common::SeekableReadStream *memStream = new Common::MemoryReadStream(soundData, length);
+
+ Audio::SoundHandle *handle = &_channels[kChannelDW1MacMusic].handle;
+ //_channels[kChannelDW1MacMusic].sampleNum = dwFileOffset;
+
+ // Stop any previously playing music track
+ _vm->_mixer->stopHandle(*handle);
+
+ // FIXME: Should set this in a different place ;)
+ _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _vm->_config->_musicVolume);
+
+ // TODO: Compression support (MP3/OGG/FLAC) for midi.dat in DW1 Mac
+ Audio::RewindableAudioStream *musicStream = Audio::makeRawStream(memStream, 22050, Audio::FLAG_UNSIGNED, DisposeAfterUse::YES);
+
+ if (musicStream)
+ _vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, handle, Audio::makeLoopingAudioStream(musicStream, 0));
+
+ s.close();
+
+ return true;
+}
+
// playSample for DiscWorld 2
bool SoundManager::playSample(int id, int sub, bool bLooped, int x, int y, int priority,
Audio::Mixer::SoundType type, Audio::SoundHandle *handle) {
diff --git a/engines/tinsel/sound.h b/engines/tinsel/sound.h
index ea5eb45..8510c16 100644
--- a/engines/tinsel/sound.h
+++ b/engines/tinsel/sound.h
@@ -51,7 +51,8 @@ protected:
enum {
kChannelTalk = 0,
kChannelTinsel1 = 0, // Always using this channel for DW1
- kChannelSFX = 1
+ kChannelSFX = 1,
+ kChannelDW1MacMusic = 2
};
static const int kNumChannels = kChannelSFX + kNumSFX;
@@ -108,6 +109,7 @@ public:
bool playSample(int id, Audio::Mixer::SoundType type, Audio::SoundHandle *handle = 0);
bool playSample(int id, int sub, bool bLooped, int x, int y, int priority,
Audio::Mixer::SoundType type, Audio::SoundHandle *handle = 0);
+ bool playDW1MacMusic(int dwFileOffset);
void stopAllSamples(); // Stops any currently playing sample
void stopSpecSample(int id, int sub = 0); // Stops a specific sample
More information about the Scummvm-git-logs
mailing list