[Scummvm-git-logs] scummvm master -> d592a671258bdb7a73461dc5e4df2da991c7b354
sluicebox
22204938+sluicebox at users.noreply.github.com
Tue Sep 1 17:36:53 UTC 2020
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:
5efa0eb70e SCI32: Read AIFF audio patch files
d592a67125 SCI32: Add kDoAudio support for Mac AIFF patch files
Commit: 5efa0eb70e99a2611584654de9f6065a0051535c
https://github.com/scummvm/scummvm/commit/5efa0eb70e99a2611584654de9f6065a0051535c
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2020-09-01T10:31:32-07:00
Commit Message:
SCI32: Read AIFF audio patch files
Used by LSL6 hires Mac
Changed paths:
engines/sci/resource.cpp
engines/sci/resource.h
engines/sci/resource_audio.cpp
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index a3fd436d7e..d8501d0405 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -848,6 +848,9 @@ void DirectoryResourceSource::scanSource(ResourceManager *resMan) {
resMan->readResourcePatchesBase36();
resMan->readWaveAudioPatches();
+#ifdef ENABLE_SCI32
+ resMan->readAIFFAudioPatches();
+#endif
}
void ExtMapResourceSource::scanSource(ResourceManager *resMan) {
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index cab7859ea7..9fe0f0aaa6 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -615,6 +615,13 @@ protected:
void readWaveAudioPatches();
void processWavePatch(ResourceId resourceId, const Common::String &name);
+ /**
+ * Process AIFF files as patches for Audio resources.
+ */
+#ifdef ENABLE_SCI32
+ void readAIFFAudioPatches();
+#endif
+
/**
* Applies to all versions before 0.000.395 (i.e. KQ4 old, XMAS 1988 and LSL2).
* Old SCI versions used two word header for script blocks (first word equal
diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp
index 6703f4feae..9c3dd9129e 100644
--- a/engines/sci/resource_audio.cpp
+++ b/engines/sci/resource_audio.cpp
@@ -265,6 +265,26 @@ void ResourceManager::readWaveAudioPatches() {
}
}
+#ifdef ENABLE_SCI32
+void ResourceManager::readAIFFAudioPatches() {
+ // LSL6 hires Mac is the only game that has AIFF audio patch files,
+ // which it plays with special overloads of kDoAudio. Restrict this
+ // scan to just this game since the filenames are so generic.
+ if (!(g_sci->getGameId() == GID_LSL6HIRES && _isSci2Mac)) {
+ return;
+ }
+
+ Common::ArchiveMemberList files;
+ SearchMan.listMatchingMembers(files, "####");
+
+ for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
+ Common::String name = (*x)->getName();
+
+ processWavePatch(ResourceId(kResourceTypeAudio, atoi(name.c_str())), name);
+ }
+}
+#endif
+
void ResourceManager::removeAudioResource(ResourceId resId) {
// Remove resource, unless it was loaded from a patch
if (_resMap.contains(resId)) {
Commit: d592a671258bdb7a73461dc5e4df2da991c7b354
https://github.com/scummvm/scummvm/commit/d592a671258bdb7a73461dc5e4df2da991c7b354
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2020-09-01T10:31:32-07:00
Commit Message:
SCI32: Add kDoAudio support for Mac AIFF patch files
Fixes LSL6 hires Mac aerobics room and end credits
Changed paths:
engines/sci/engine/kernel_tables.h
engines/sci/engine/ksound.cpp
engines/sci/sound/audio32.cpp
engines/sci/sound/audio32.h
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index bc419658bc..8079ad11d3 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -220,11 +220,12 @@ static const SciKernelMapSubEntry kDoAudio_subops[] = {
// kDoAudioWaitForPlay, but SSCI has no opcode 1 until
// SCI2.1early
{ SIG_SINCE_SCI21, 1, MAP_CALL(DoAudioWaitForPlay), "(i)(i)(i)(i)(i)(i)(i)", NULL },
- { SIG_SCI32, 2, MAP_CALL(DoAudioPlay), "(i)(i)(i)(i)(i)(i)(i)", NULL },
- { SIG_SCI32, 3, MAP_CALL(DoAudioStop), "(i)(i)(i)(i)(i)", NULL },
- { SIG_SCI32, 4, MAP_CALL(DoAudioPause), "(i)(i)(i)(i)(i)", NULL },
- { SIG_SCI32, 5, MAP_CALL(DoAudioResume), "(i)(i)(i)(i)(i)", kDoAudioResume_workarounds },
- { SIG_SCI32, 6, MAP_CALL(DoAudioPosition), "(i)(i)(i)(i)(i)", NULL },
+ // LSL6 hires Mac passes an extra filename string parameter to play AIFF files
+ { SIG_SCI32, 2, MAP_CALL(DoAudioPlay), "(i)(i)(i)(i)(i)([ir])(i)", NULL },
+ { SIG_SCI32, 3, MAP_CALL(DoAudioStop), "(i)(i)(i)(i)(i)(r)", NULL },
+ { SIG_SCI32, 4, MAP_CALL(DoAudioPause), "(i)(i)(i)(i)(i)(r)", NULL },
+ { SIG_SCI32, 5, MAP_CALL(DoAudioResume), "(i)(i)(i)(i)(i)(r)", kDoAudioResume_workarounds },
+ { SIG_SCI32, 6, MAP_CALL(DoAudioPosition), "(i)(i)(i)(i)(i)(r)", NULL },
{ SIG_SCI32, 7, MAP_CALL(DoAudioRate), "(i)", NULL },
{ SIG_SCI32, 8, MAP_CALL(DoAudioVolume), "(i)(i)(i)(i)(i)(i)", NULL },
{ SIG_SCI32, 9, MAP_CALL(DoAudioGetCapability), "", NULL },
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index 976c965ffa..99ded8ab1f 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -364,7 +364,7 @@ reg_t kDoAudioWaitForPlay(EngineState *s, int argc, reg_t *argv) {
}
}
- return g_sci->_audio32->kernelPlay(false, argc, argv);
+ return g_sci->_audio32->kernelPlay(false, s, argc, argv);
}
reg_t kDoAudioPlay(EngineState *s, int argc, reg_t *argv) {
@@ -372,23 +372,23 @@ reg_t kDoAudioPlay(EngineState *s, int argc, reg_t *argv) {
return make_reg(0, g_sci->_audio32->getNumActiveChannels());
}
- return g_sci->_audio32->kernelPlay(true, argc, argv);
+ return g_sci->_audio32->kernelPlay(true, s, argc, argv);
}
reg_t kDoAudioStop(EngineState *s, int argc, reg_t *argv) {
- return g_sci->_audio32->kernelStop(argc, argv);
+ return g_sci->_audio32->kernelStop(s, argc, argv);
}
reg_t kDoAudioPause(EngineState *s, int argc, reg_t *argv) {
- return g_sci->_audio32->kernelPause(argc, argv);
+ return g_sci->_audio32->kernelPause(s, argc, argv);
}
reg_t kDoAudioResume(EngineState *s, int argc, reg_t *argv) {
- return g_sci->_audio32->kernelResume(argc, argv);
+ return g_sci->_audio32->kernelResume(s, argc, argv);
}
reg_t kDoAudioPosition(EngineState *s, int argc, reg_t *argv) {
- return g_sci->_audio32->kernelPosition(argc, argv);
+ return g_sci->_audio32->kernelPosition(s, argc, argv);
}
reg_t kDoAudioRate(EngineState *s, int argc, reg_t *argv) {
@@ -403,7 +403,7 @@ reg_t kDoAudioRate(EngineState *s, int argc, reg_t *argv) {
}
reg_t kDoAudioVolume(EngineState *s, int argc, reg_t *argv) {
- return g_sci->_audio32->kernelVolume(argc, argv);
+ return g_sci->_audio32->kernelVolume(s, argc, argv);
}
reg_t kDoAudioGetCapability(EngineState *s, int argc, reg_t *argv) {
@@ -445,7 +445,7 @@ reg_t kDoAudioPreload(EngineState *s, int argc, reg_t *argv) {
}
reg_t kDoAudioFade(EngineState *s, int argc, reg_t *argv) {
- return g_sci->_audio32->kernelFade(argc, argv);
+ return g_sci->_audio32->kernelFade(s, argc, argv);
}
reg_t kDoAudioHasSignal(EngineState *s, int argc, reg_t *argv) {
@@ -453,17 +453,17 @@ reg_t kDoAudioHasSignal(EngineState *s, int argc, reg_t *argv) {
}
reg_t kDoAudioSetLoop(EngineState *s, int argc, reg_t *argv) {
- g_sci->_audio32->kernelLoop(argc, argv);
+ g_sci->_audio32->kernelLoop(s, argc, argv);
return s->r_acc;
}
reg_t kDoAudioPan(EngineState *s, int argc, reg_t *argv) {
- g_sci->_audio32->kernelPan(argc, argv);
+ g_sci->_audio32->kernelPan(s, argc, argv);
return s->r_acc;
}
reg_t kDoAudioPanOff(EngineState *s, int argc, reg_t *argv) {
- g_sci->_audio32->kernelPanOff(argc, argv);
+ g_sci->_audio32->kernelPanOff(s, argc, argv);
return s->r_acc;
}
diff --git a/engines/sci/sound/audio32.cpp b/engines/sci/sound/audio32.cpp
index 7e95d3875c..def8302df8 100644
--- a/engines/sci/sound/audio32.cpp
+++ b/engines/sci/sound/audio32.cpp
@@ -40,7 +40,6 @@
#include "sci/console.h" // for Console
#include "sci/engine/features.h" // for GameFeatures
#include "sci/engine/guest_additions.h" // for GuestAdditions
-#include "sci/engine/state.h" // for EngineState
#include "sci/engine/vm_types.h" // for reg_t, make_reg, NULL_REG
#include "sci/resource.h" // for ResourceId, ResourceType::kResour...
#include "sci/sci.h" // for SciEngine, g_sci, getSciVersion
@@ -468,7 +467,7 @@ uint8 Audio32::getNumUnlockedChannels() const {
return numChannels;
}
-int16 Audio32::findChannelByArgs(int argc, const reg_t *argv, const int startIndex, const reg_t soundNode) const {
+int16 Audio32::findChannelByArgs(EngineState *s, int argc, const reg_t *argv, const int startIndex, const reg_t soundNode) const {
// SSCI takes extra steps to skip the subop argument here, but argc/argv are
// already reduced by one in our engine by the kernel since these calls are
// always subops so we do not need to do anything extra
@@ -488,6 +487,17 @@ int16 Audio32::findChannelByArgs(int argc, const reg_t *argv, const int startInd
if (argc < 5) {
searchId = ResourceId(kResourceTypeAudio, argv[startIndex].toUint16());
+ } else if (argc == 6 && argv[startIndex + 5].isPointer()) {
+ // LSL6 hires Mac plays external AIFF files by passing filenames as strings.
+ // All other parameters are ignored.
+ const Common::String audioName = s->_segMan->getString(argv[startIndex + 5]);
+ uint16 audioNumber = atoi(audioName.c_str());
+ if (audioNumber == 0) {
+ // script passed a dummy value such as "XXXX" to indicate
+ // that all sounds should be stopped
+ return kAllChannels;
+ }
+ searchId = ResourceId(kResourceTypeAudio, audioNumber);
} else {
searchId = ResourceId(
kResourceTypeAudio36,
@@ -1186,17 +1196,32 @@ bool Audio32::hasSignal() const {
#pragma mark -
#pragma mark Kernel
-reg_t Audio32::kernelPlay(const bool autoPlay, const int argc, const reg_t *const argv) {
+reg_t Audio32::kernelPlay(const bool autoPlay, EngineState *s, const int argc, const reg_t *const argv) {
Common::StackLock lock(_mutex);
- const int16 channelIndex = findChannelByArgs(argc, argv, 0, NULL_REG);
+ int16 channelIndex = findChannelByArgs(s, argc, argv, 0, NULL_REG);
ResourceId resourceId;
bool loop;
int16 volume;
bool monitor = false;
reg_t soundNode = NULL_REG;
- if (argc >= 5) {
+ if (argc == 6 && argv[5].isPointer()) {
+ // LSL6 hires Mac plays external AIFF files by passing filenames as strings.
+ // All other parameters are ignored.
+ const Common::String audioName = s->_segMan->getString(argv[5]);
+ uint16 audioNumber = atoi(audioName.c_str());
+ resourceId = ResourceId(kResourceTypeAudio, audioNumber);
+ loop = false;
+ volume = Audio32::kMaxVolume;
+
+ // SSCI only plays one AIFF file at a time using this method. The game scripts
+ // rely on this and don't stop the previous AIFF before playing another.
+ // This entire scheme is only used in two rooms, so rather than track the
+ // AIFF channel, just stop all channels when an AIFF is played.
+ stop(kAllChannels);
+ channelIndex = kNoExistingChannel;
+ } else if (argc >= 5) {
resourceId = ResourceId(kResourceTypeAudio36, argv[0].toUint16(), argv[1].toUint16(), argv[2].toUint16(), argv[3].toUint16(), argv[4].toUint16());
if (argc < 6 || argv[5].toSint16() == 1) {
@@ -1260,31 +1285,31 @@ reg_t Audio32::kernelPlay(const bool autoPlay, const int argc, const reg_t *cons
return make_reg(0, play(channelIndex, resourceId, autoPlay, loop, volume, soundNode, monitor));
}
-reg_t Audio32::kernelStop(const int argc, const reg_t *const argv) {
+reg_t Audio32::kernelStop(EngineState *s, const int argc, const reg_t *const argv) {
Common::StackLock lock(_mutex);
- const int16 channelIndex = findChannelByArgs(argc, argv, 0, argc > 1 ? argv[1] : NULL_REG);
+ const int16 channelIndex = findChannelByArgs(s, argc, argv, 0, argc > 1 ? argv[1] : NULL_REG);
return make_reg(0, stop(channelIndex));
}
-reg_t Audio32::kernelPause(const int argc, const reg_t *const argv) {
+reg_t Audio32::kernelPause(EngineState *s, const int argc, const reg_t *const argv) {
Common::StackLock lock(_mutex);
- const int16 channelIndex = findChannelByArgs(argc, argv, 0, argc > 1 ? argv[1] : NULL_REG);
+ const int16 channelIndex = findChannelByArgs(s, argc, argv, 0, argc > 1 ? argv[1] : NULL_REG);
return make_reg(0, pause(channelIndex));
}
-reg_t Audio32::kernelResume(const int argc, const reg_t *const argv) {
+reg_t Audio32::kernelResume(EngineState *s, const int argc, const reg_t *const argv) {
Common::StackLock lock(_mutex);
- const int16 channelIndex = findChannelByArgs(argc, argv, 0, argc > 1 ? argv[1] : NULL_REG);
+ const int16 channelIndex = findChannelByArgs(s, argc, argv, 0, argc > 1 ? argv[1] : NULL_REG);
return make_reg(0, resume(channelIndex));
}
-reg_t Audio32::kernelPosition(const int argc, const reg_t *const argv) {
+reg_t Audio32::kernelPosition(EngineState *s, const int argc, const reg_t *const argv) {
Common::StackLock lock(_mutex);
- const int16 channelIndex = findChannelByArgs(argc, argv, 0, argc > 1 ? argv[1] : NULL_REG);
+ const int16 channelIndex = findChannelByArgs(s, argc, argv, 0, argc > 1 ? argv[1] : NULL_REG);
return make_reg(0, getPosition(channelIndex));
}
-reg_t Audio32::kernelVolume(const int argc, const reg_t *const argv) {
+reg_t Audio32::kernelVolume(EngineState *s, const int argc, const reg_t *const argv) {
Common::StackLock lock(_mutex);
const int16 volume = argc > 0 ? argv[0].toSint16() : -1;
@@ -1293,7 +1318,7 @@ reg_t Audio32::kernelVolume(const int argc, const reg_t *const argv) {
if (getSciVersion() == SCI_VERSION_3 && argc < 2) {
channelIndex = kAllChannels;
} else {
- channelIndex = findChannelByArgs(argc, argv, 1, argc > 2 ? argv[2] : NULL_REG);
+ channelIndex = findChannelByArgs(s, argc, argv, 1, argc > 2 ? argv[2] : NULL_REG);
}
if (volume != -1) {
@@ -1313,7 +1338,7 @@ reg_t Audio32::kernelMixing(const int argc, const reg_t *const argv) {
return make_reg(0, getAttenuatedMixing());
}
-reg_t Audio32::kernelFade(const int argc, const reg_t *const argv) {
+reg_t Audio32::kernelFade(EngineState *s, const int argc, const reg_t *const argv) {
if (argc < 4) {
return make_reg(0, 0);
}
@@ -1324,7 +1349,7 @@ reg_t Audio32::kernelFade(const int argc, const reg_t *const argv) {
// before the call, and then restored after the call. We just implemented
// findChannelByArgs in a manner that allows us to pass this information
// without messing with argc/argv instead
- const int16 channelIndex = findChannelByArgs(2, argv, 0, argc > 5 ? argv[5] : NULL_REG);
+ const int16 channelIndex = findChannelByArgs(s, 2, argv, 0, argc > 5 ? argv[5] : NULL_REG);
const int16 volume = argv[1].toSint16();
const int16 speed = argv[2].toSint16();
const int16 steps = argv[3].toSint16();
@@ -1333,19 +1358,19 @@ reg_t Audio32::kernelFade(const int argc, const reg_t *const argv) {
return make_reg(0, fadeChannel(channelIndex, volume, speed, steps, stopAfterFade));
}
-void Audio32::kernelLoop(const int argc, const reg_t *const argv) {
+void Audio32::kernelLoop(EngineState *s, const int argc, const reg_t *const argv) {
Common::StackLock lock(_mutex);
- const int16 channelIndex = findChannelByArgs(argc, argv, 0, argc == 3 ? argv[2] : NULL_REG);
+ const int16 channelIndex = findChannelByArgs(s, argc, argv, 0, argc == 3 ? argv[2] : NULL_REG);
const bool loop = argv[0].toSint16() != 0 && argv[0].toSint16() != 1;
setLoop(channelIndex, loop);
}
-void Audio32::kernelPan(const int argc, const reg_t *const argv) {
+void Audio32::kernelPan(EngineState *s, const int argc, const reg_t *const argv) {
Common::StackLock lock(_mutex);
- const int16 channelIndex = findChannelByArgs(argc, argv, 1, argc == 3 ? argv[2] : NULL_REG);
+ const int16 channelIndex = findChannelByArgs(s, argc, argv, 1, argc == 3 ? argv[2] : NULL_REG);
const int16 pan = argv[0].toSint16();
if (channelIndex != kNoExistingChannel) {
setPan(channelIndex, pan);
@@ -1354,10 +1379,10 @@ void Audio32::kernelPan(const int argc, const reg_t *const argv) {
}
}
-void Audio32::kernelPanOff(const int argc, const reg_t *const argv) {
+void Audio32::kernelPanOff(EngineState *s, const int argc, const reg_t *const argv) {
Common::StackLock lock(_mutex);
- const int16 channelIndex = findChannelByArgs(argc, argv, 0, argc == 2 ? argv[1] : NULL_REG);
+ const int16 channelIndex = findChannelByArgs(s, argc, argv, 0, argc == 2 ? argv[1] : NULL_REG);
if (channelIndex != kNoExistingChannel) {
setPan(channelIndex, -1);
}
diff --git a/engines/sci/sound/audio32.h b/engines/sci/sound/audio32.h
index 51e3b89cbe..6e23dd8891 100644
--- a/engines/sci/sound/audio32.h
+++ b/engines/sci/sound/audio32.h
@@ -29,6 +29,7 @@
#include "common/mutex.h" // for StackLock, Mutex
#include "common/scummsys.h" // for int16, uint8, uint32, uint16
#include "sci/resource.h" // for ResourceId
+#include "sci/engine/state.h" // for EngineState
#include "sci/engine/vm_types.h" // for reg_t, NULL_REG
#include "sci/video/robot_decoder.h" // for RobotAudioStream
@@ -250,7 +251,7 @@ public:
* @param startIndex The location of the audio resource information in the
* arguments list.
*/
- int16 findChannelByArgs(int argc, const reg_t *argv, const int startIndex, const reg_t soundNode) const;
+ int16 findChannelByArgs(EngineState *s, int argc, const reg_t *argv, const int startIndex, const reg_t soundNode) const;
/**
* Finds a channel that is already configured for the given audio sample.
@@ -636,17 +637,17 @@ private:
#pragma mark -
#pragma mark Kernel
public:
- reg_t kernelPlay(const bool autoPlay, const int argc, const reg_t *const argv);
- reg_t kernelStop(const int argc, const reg_t *const argv);
- reg_t kernelPause(const int argc, const reg_t *const argv);
- reg_t kernelResume(const int argc, const reg_t *const argv);
- reg_t kernelPosition(const int argc, const reg_t *const argv);
- reg_t kernelVolume(const int argc, const reg_t *const argv);
+ reg_t kernelPlay(const bool autoPlay, EngineState *s, const int argc, const reg_t *const argv);
+ reg_t kernelStop(EngineState *s, const int argc, const reg_t *const argv);
+ reg_t kernelPause(EngineState *s, const int argc, const reg_t *const argv);
+ reg_t kernelResume(EngineState *s, const int argc, const reg_t *const argv);
+ reg_t kernelPosition(EngineState *s, const int argc, const reg_t *const argv);
+ reg_t kernelVolume(EngineState *s, const int argc, const reg_t *const argv);
reg_t kernelMixing(const int argc, const reg_t *const argv);
- reg_t kernelFade(const int argc, const reg_t *const argv);
- void kernelLoop(const int argc, const reg_t *const argv);
- void kernelPan(const int argc, const reg_t *const argv);
- void kernelPanOff(const int argc, const reg_t *const argv);
+ reg_t kernelFade(EngineState *s, const int argc, const reg_t *const argv);
+ void kernelLoop(EngineState *s, const int argc, const reg_t *const argv);
+ void kernelPan(EngineState *s, const int argc, const reg_t *const argv);
+ void kernelPanOff(EngineState *s, const int argc, const reg_t *const argv);
#pragma mark -
#pragma mark Debugging
More information about the Scummvm-git-logs
mailing list