[Scummvm-git-logs] scummvm master -> ca36141f9b502d412171da1b7c54d3ac37262b8c
AndywinXp
noreply at scummvm.org
Thu Aug 3 21:58:44 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ca36141f9b JANITORIAL: SCUMM: Remove magic numbers from DiMUSE engine
Commit: ca36141f9b502d412171da1b7c54d3ac37262b8c
https://github.com/scummvm/scummvm/commit/ca36141f9b502d412171da1b7c54d3ac37262b8c
Author: AndywinXp (andywinxp at gmail.com)
Date: 2023-08-03T23:58:38+02:00
Commit Message:
JANITORIAL: SCUMM: Remove magic numbers from DiMUSE engine
Also improve readability on some bits
Changed paths:
engines/scumm/imuse_digi/dimuse_defs.h
engines/scumm/imuse_digi/dimuse_engine.cpp
engines/scumm/imuse_digi/dimuse_scripts.cpp
engines/scumm/imuse_digi/dimuse_triggers.cpp
diff --git a/engines/scumm/imuse_digi/dimuse_defs.h b/engines/scumm/imuse_digi/dimuse_defs.h
index 7c105132a2b..d0d900d1da1 100644
--- a/engines/scumm/imuse_digi/dimuse_defs.h
+++ b/engines/scumm/imuse_digi/dimuse_defs.h
@@ -124,6 +124,9 @@ namespace Scumm {
#define DIMUSE_C_PROCESS_STREAMS 27
#define DIMUSE_C_FEED_STREAM 29
+// Trigger callback command ID
+#define DIMUSE_C_SCRIPT_CALLBACK 0
+
// Block IDs for the Creative Voice File format
// used within Full Throttle and The Dig (demo)
#define VOC_DIGI_DATA_BLOCK 1
diff --git a/engines/scumm/imuse_digi/dimuse_engine.cpp b/engines/scumm/imuse_digi/dimuse_engine.cpp
index 6b463c38306..c874c7f576d 100644
--- a/engines/scumm/imuse_digi/dimuse_engine.cpp
+++ b/engines/scumm/imuse_digi/dimuse_engine.cpp
@@ -226,7 +226,7 @@ int IMuseDigital::startVoice(int soundId, const char *soundName, byte speakingAc
// see Sound::extractSyncsFromDiMUSEMarker() for details.
// Setting up a trigger with an empty marker is a shortcut for
// activating the trigger for any marker.
- diMUSESetTrigger(kTalkSoundID, 0, 21);
+ diMUSESetTrigger(kTalkSoundID, 0, DIMUSE_C_GET_MARKER_SYNCS);
diMUSEStartStream(kTalkSoundID, 127, DIMUSE_BUFFER_SPEECH);
diMUSESetParam(kTalkSoundID, DIMUSE_P_GROUP, DIMUSE_GROUP_SPEECH);
diff --git a/engines/scumm/imuse_digi/dimuse_scripts.cpp b/engines/scumm/imuse_digi/dimuse_scripts.cpp
index d630b904e6c..7c363f40a99 100644
--- a/engines/scumm/imuse_digi/dimuse_scripts.cpp
+++ b/engines/scumm/imuse_digi/dimuse_scripts.cpp
@@ -610,7 +610,7 @@ void IMuseDigital::playDigMusic(const char *songName, const imuseDigTable *table
if (table->transitionType == 4) {
_stopSequenceFlag = 0;
- diMUSESetTrigger(table->soundId, MKTAG('_', 'e', 'n', 'd'), 0);
+ diMUSESetTrigger(table->soundId, MKTAG('_', 'e', 'n', 'd'), DIMUSE_C_SCRIPT_CALLBACK);
}
if (oldSoundId) {
@@ -656,7 +656,7 @@ void IMuseDigital::playDigMusic(const char *songName, const imuseDigTable *table
break;
case 6:
_stopSequenceFlag = 0;
- diMUSESetTrigger(DIMUSE_SMUSH_SOUNDID + DIMUSE_BUFFER_MUSIC, MKTAG('_', 'e', 'n', 'd'), 0);
+ diMUSESetTrigger(DIMUSE_SMUSH_SOUNDID + DIMUSE_BUFFER_MUSIC, MKTAG('_', 'e', 'n', 'd'), DIMUSE_C_SCRIPT_CALLBACK);
break;
case 7:
if (oldSoundId)
@@ -749,7 +749,7 @@ void IMuseDigital::playComiDemoMusic(const char *songName, const imuseComiTable
diMUSESetParam(table->soundId, DIMUSE_P_GROUP, DIMUSE_GROUP_MUSICEFF); // Repeated intentionally
break;
default:
- debug(5, "IMuseDigital::playDigMusic(): bogus or unused transition type, ignored");
+ debug(5, "IMuseDigital::playComiDemoMusic(): bogus or unused transition type, ignored");
break;
}
}
@@ -838,7 +838,7 @@ void IMuseDigital::playComiMusic(const char *songName, const imuseComiTable *tab
if (table->transitionType == 4) {
_stopSequenceFlag = 0;
- diMUSESetTrigger(table->soundId, MKTAG('_', 'e', 'n', 'd'), 0);
+ diMUSESetTrigger(table->soundId, MKTAG('_', 'e', 'n', 'd'), DIMUSE_C_SCRIPT_CALLBACK);
}
if (oldSoundId) {
@@ -869,10 +869,10 @@ void IMuseDigital::playComiMusic(const char *songName, const imuseComiTable *tab
switch (table->transitionType) {
case 12:
diMUSESetHook(oldSoundId, table->hookId);
- diMUSESetTrigger(oldSoundId, MKTAG('e', 'x', 'i', 't'), 26, oldSoundId, table->soundId, fadeDelay, 1, 0);
- diMUSESetTrigger(oldSoundId, MKTAG('e', 'x', 'i', 't'), 12, table->soundId, DIMUSE_P_VOLUME, 127);
- diMUSESetTrigger(oldSoundId, MKTAG('e', 'x', 'i', 't'), 12, table->soundId, DIMUSE_P_GROUP, 4);
- diMUSESetTrigger(oldSoundId, MKTAG('e', 'x', 'i', 't'), 15, table->soundId, hookId);
+ diMUSESetTrigger(oldSoundId, MKTAG('e', 'x', 'i', 't'), DIMUSE_C_SWITCH_STREAM, oldSoundId, table->soundId, fadeDelay, 1, 0);
+ diMUSESetTrigger(oldSoundId, MKTAG('e', 'x', 'i', 't'), DIMUSE_C_SET_PARAM, table->soundId, DIMUSE_P_VOLUME, 127);
+ diMUSESetTrigger(oldSoundId, MKTAG('e', 'x', 'i', 't'), DIMUSE_C_SET_PARAM, table->soundId, DIMUSE_P_GROUP, DIMUSE_GROUP_MUSICEFF);
+ diMUSESetTrigger(oldSoundId, MKTAG('e', 'x', 'i', 't'), DIMUSE_C_SET_HOOK, table->soundId, hookId);
diMUSEProcessStreams();
break;
default:
@@ -900,7 +900,7 @@ void IMuseDigital::playComiMusic(const char *songName, const imuseComiTable *tab
break;
case 6:
_stopSequenceFlag = 0;
- diMUSESetTrigger(DIMUSE_SMUSH_SOUNDID + DIMUSE_BUFFER_MUSIC, MKTAG('_', 'e', 'n', 'd'), 0);
+ diMUSESetTrigger(DIMUSE_SMUSH_SOUNDID + DIMUSE_BUFFER_MUSIC, MKTAG('_', 'e', 'n', 'd'), DIMUSE_C_SCRIPT_CALLBACK);
break;
case 7:
if (oldSoundId)
@@ -914,7 +914,7 @@ void IMuseDigital::playComiMusic(const char *songName, const imuseComiTable *tab
if (oldSoundId)
diMUSESetHook(oldSoundId, table->hookId);
_stopSequenceFlag = 0;
- diMUSESetTrigger(oldSoundId, MKTAG('_', 'e', 'n', 'd'), 0);
+ diMUSESetTrigger(oldSoundId, MKTAG('_', 'e', 'n', 'd'), DIMUSE_C_SCRIPT_CALLBACK);
break;
default:
debug(5, "IMuseDigital::playComiMusic(): bogus transition type, ignored");
diff --git a/engines/scumm/imuse_digi/dimuse_triggers.cpp b/engines/scumm/imuse_digi/dimuse_triggers.cpp
index c2e4a1f2c7b..753f31c09e0 100644
--- a/engines/scumm/imuse_digi/dimuse_triggers.cpp
+++ b/engines/scumm/imuse_digi/dimuse_triggers.cpp
@@ -186,7 +186,7 @@ void IMuseDigiTriggersHandler::processTriggers(int soundId, char *marker) {
_trigs[l].sound = 0;
debug(5, "IMuseDigiTriggersHandler::processTriggers(): executing trigger for soundId %d and marker '%s'", soundId, marker);
- if (_trigs[l].opcode == 0) {
+ if (_trigs[l].opcode == DIMUSE_C_SCRIPT_CALLBACK) {
// Call the script callback (a function which sets _stoppingSequence to 1)
_engine->scriptTriggerCallback(_textBuffer);
} else {
@@ -259,7 +259,9 @@ void IMuseDigiTriggersHandler::loop() {
_defers[l].counter--;
if (_defers[l].counter == 1) {
- if (_defers[l].opcode != 0) {
+ if (_defers[l].opcode == DIMUSE_C_SCRIPT_CALLBACK) {
+ _engine->scriptTriggerCallback(_trigs[l].text);
+ } else {
if (_defers[l].opcode < 30) {
_engine->cmdsHandleCmd(_trigs[l].opcode, nullptr,
_trigs[l].a, _trigs[l].b,
@@ -268,8 +270,6 @@ void IMuseDigiTriggersHandler::loop() {
_trigs[l].g, _trigs[l].h,
_trigs[l].i, _trigs[l].j);
}
- } else {
- _engine->scriptTriggerCallback(_trigs[l].text);
}
}
}
@@ -282,7 +282,8 @@ int IMuseDigiTriggersHandler::countPendingSounds(int soundId) {
continue;
int opcode = _trigs[l].opcode;
- if ((opcode == 8 && _trigs[l].a == soundId) || (opcode == 26 && _trigs[l].b == soundId)) {
+ if ((opcode == DIMUSE_C_START_SND && _trigs[l].a == soundId) ||
+ (opcode == DIMUSE_C_SWITCH_STREAM && _trigs[l].b == soundId)) {
r++;
}
}
@@ -292,7 +293,8 @@ int IMuseDigiTriggersHandler::countPendingSounds(int soundId) {
continue;
int opcode = _defers[l].opcode;
- if ((opcode == 8 && _defers[l].a == soundId) || (opcode == 26 && _defers[l].b == soundId)) {
+ if ((opcode == DIMUSE_C_START_SND && _defers[l].a == soundId) ||
+ (opcode == DIMUSE_C_SWITCH_STREAM && _defers[l].b == soundId)) {
r++;
}
}
More information about the Scummvm-git-logs
mailing list