[Scummvm-git-logs] scummvm master -> ad91c57ebe32d62e97c399521f155670e52ea401

sev- sev at scummvm.org
Sun Jul 4 22:56:23 UTC 2021


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
3fd1f5adba SAGA2: Play click sounds
ad91c57ebe SAGA2: Implement sfx playback


Commit: 3fd1f5adbaab48db5883f1012ea80ffb04cff440
    https://github.com/scummvm/scummvm/commit/3fd1f5adbaab48db5883f1012ea80ffb04cff440
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-05T00:56:08+02:00

Commit Message:
SAGA2: Play click sounds

Changed paths:
    engines/saga2/audio.cpp
    engines/saga2/audio.h
    engines/saga2/fta.h
    engines/saga2/main.cpp


diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index 8c906e78a7..767dc27319 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -25,6 +25,8 @@
  */
 
 #include "common/config-manager.h"
+#include "audio/audiostream.h"
+#include "audio/decoders/raw.h"
 
 #include "saga2/saga2.h"
 #include "saga2/audio.h"
@@ -50,21 +52,17 @@ const uint32        baseMusicID     = MKTAG('M', 'I', 'L', 'O'),
                     loopedID        = MKTAG('L', 'O', 'O', 'P'),
                     voiceID         = MKTAG('T', 'A', 'L', 'K');
 
-extern hResource        *soundResFile;          // script resources
-extern hResource        *voiceResFile;          // script resources
+extern hResource *soundResFile;          // script resources
+extern hResource *voiceResFile;          // script resources
 
-extern int32            clickSizes[];
-extern uint8            *clickData[];
+extern int32 clickSizes[];
+extern uint8 *clickData[];
 
 
-soundSegment            currentMidi;
-soundSegment            currentLoop;
+soundSegment currentMidi;
+soundSegment currentLoop;
 
-hResContext         *voiceRes,
-                    *musicRes,
-                    *soundRes,
-                    *loopRes,
-                    *longRes;
+hResContext *voiceRes, *musicRes, *soundRes, *loopRes, *longRes;
 
 
 static audioAttenuationFunction oldAttenuator;
@@ -291,8 +289,9 @@ void playMusic(uint32 s) {
 void playMemSound(uint32 s) {
 	debugC(1, kDebugSound, "playMemSound(%s)", tag2strP(s));
 
-	if (bufCheckResID(NULL, s))
-		audio->queueSound(s, 1, Here);
+	Audio::AudioStream *aud = Audio::makeRawStream(clickData[s], clickSizes[s], 22050, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN, DisposeAfterUse::NO);
+
+	g_system->getMixer()->playStream(Audio::Mixer::kSFXSoundType, &audio->_clickSoundHandle, aud);
 }
 
 //-----------------------------------------------------------------------
diff --git a/engines/saga2/audio.h b/engines/saga2/audio.h
index 69e5d0213c..709d116f52 100644
--- a/engines/saga2/audio.h
+++ b/engines/saga2/audio.h
@@ -99,6 +99,7 @@ public:
 	Audio::SoundHandle _speechSoundHandle;
 	Audio::SoundHandle _sfxSoundHandle;
 	Audio::SoundHandle _bgmSoundHandle;
+	Audio::SoundHandle _clickSoundHandle;
 	Common::Queue<SoundInstance> _speechQueue;
 	Common::Queue<SoundInstance> _sfxQueue;
 	Common::Queue<SoundInstance> _bgmQueue;
diff --git a/engines/saga2/fta.h b/engines/saga2/fta.h
index 073e697043..9fc872cd4e 100644
--- a/engines/saga2/fta.h
+++ b/engines/saga2/fta.h
@@ -163,6 +163,7 @@ void  *LoadFile(char *filename);             // load file into buffer
 //  Resource loading
 
 void *LoadResource(hResContext *con, uint32 id, const char desc[]);
+void dumpResource(hResContext *con, uint32 id);
 Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, const char desc[]);
 
 //  Directory control
diff --git a/engines/saga2/main.cpp b/engines/saga2/main.cpp
index 30a263b6a6..e51990ee76 100644
--- a/engines/saga2/main.cpp
+++ b/engines/saga2/main.cpp
@@ -530,6 +530,29 @@ Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, co
 	return new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES);
 }
 
+void dumpResource(hResContext *con, uint32 id) {
+	int32 size = con->size(id);
+	if (size <= 0 || !con->seek(id)) {
+		error("dumpResource(): Error reading resource ID '%s'.", tag2str(id));
+	}
+
+	byte *buffer = (byte *)malloc(size);
+	con->read(buffer, size);
+	con->rest();
+
+	Common::DumpFile out;
+
+	Common::String path = Common::String::format("./dumps/mus%s.dat", tag2strP(id));
+
+	if (out.open(path, true)) {
+		out.write(buffer, size);
+		out.flush();
+		out.close();
+	}
+
+	free(buffer);
+}
+
 typedef hResource *pHResource;
 
 inline char drive(char *path) {


Commit: ad91c57ebe32d62e97c399521f155670e52ea401
    https://github.com/scummvm/scummvm/commit/ad91c57ebe32d62e97c399521f155670e52ea401
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-07-05T00:56:08+02:00

Commit Message:
SAGA2: Implement sfx playback

Changed paths:
    engines/saga2/audio.cpp
    engines/saga2/audio.h


diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp
index 767dc27319..e083bd3362 100644
--- a/engines/saga2/audio.cpp
+++ b/engines/saga2/audio.cpp
@@ -568,7 +568,8 @@ audioInterface::~audioInterface() {
 }
 
 void audioInterface::initAudioInterface(hResContext *musicContext) {
-	_music = new Music(musicContext, g_system->getMixer());
+	_mixer = g_system->getMixer();
+	_music = new Music(musicContext, _mixer);
 }
 
 void audioInterface::cleanupAudioInterface(void) {
@@ -585,21 +586,33 @@ void audioInterface::resumeGameClock(void) {
 
 bool audioInterface::playFlag(void) {
 	debugC(5, kDebugSound, "STUB: audioInterface::playFlag()");
-	bool isSoundActive = g_system->getMixer()->isSoundHandleActive(_speechSoundHandle);
-	return !isSoundActive && _speechQueue.size() > 0;
+	return _speechQueue.size() > 0 || _sfxQueue.size() > 0;
 }
 
 void audioInterface::playMe(void) {
 	warning("STUB: audioInterface::PlayMe()");
-	SoundInstance si = _speechQueue.pop();
 
-	Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, si.seg, "voice data");
+	if (_speechQueue.size() > 0 && !_mixer->isSoundHandleActive(_speechSoundHandle)) {
+		SoundInstance si = _speechQueue.pop();
 
-	Audio::AudioStream *aud = makeShortenStream(*stream);
+		Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, si.seg, "voice data");
 
-	g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_speechSoundHandle, aud);
+		Audio::AudioStream *aud = makeShortenStream(*stream);
 
-	delete stream;
+		_mixer->playStream(Audio::Mixer::kSpeechSoundType, &_speechSoundHandle, aud);
+
+		delete stream;
+	}
+
+	if (_sfxQueue.size() > 0 && !_mixer->isSoundHandleActive(_sfxSoundHandle)) {
+		SoundInstance si = _sfxQueue.pop();
+
+		Common::SeekableReadStream *stream = loadResourceToStream(soundRes, si.seg, "sound data");
+
+		Audio::AudioStream *aud = Audio::makeRawStream(stream, 22050, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN);
+
+		_mixer->playStream(Audio::Mixer::kSFXSoundType, &audio->_sfxSoundHandle, aud);
+	}
 }
 
 void audioInterface::playMusic(soundSegment s, int16 loopFactor, sampleLocation where) {
diff --git a/engines/saga2/audio.h b/engines/saga2/audio.h
index 709d116f52..7a4edaae12 100644
--- a/engines/saga2/audio.h
+++ b/engines/saga2/audio.h
@@ -105,6 +105,8 @@ public:
 	Common::Queue<SoundInstance> _bgmQueue;
 	audioAttenuationFunction attenuator;
 
+	Audio::Mixer *_mixer;
+
 private:
 	char                    status[256];       // audio status messages
 




More information about the Scummvm-git-logs mailing list