[Scummvm-git-logs] scummvm master -> 58e2d8873499fd47f3369cb9cfaedfabcfdab14a
sluicebox
noreply at scummvm.org
Mon Sep 9 00:19:48 UTC 2024
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b82a5a880a AGI: Cleanup SoundMgr
3b7a9e1663 AGI: Add setFlagOrVar()
58e2d88734 AGI: Fix message when GMM save/load unavailable
Commit: b82a5a880aa22426b60d55433a82c6171fae1928
https://github.com/scummvm/scummvm/commit/b82a5a880aa22426b60d55433a82c6171fae1928
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-09-08T17:15:18-07:00
Commit Message:
AGI: Cleanup SoundMgr
Changed paths:
engines/agi/sound.cpp
engines/agi/sound.h
diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp
index 1848e8b03c3..d85e09e8d71 100644
--- a/engines/agi/sound.cpp
+++ b/engines/agi/sound.cpp
@@ -98,17 +98,6 @@ const uint8 *PCjrSound::getVoicePointer(uint voiceNum) {
return _data + voiceStartOffset;
}
-#if 0
-static const uint16 period[] = {
- 1024, 1085, 1149, 1218, 1290, 1367,
- 1448, 1534, 1625, 1722, 1825, 1933
-};
-
-static int noteToPeriod(int note) {
- return 10 * (period[note % 12] >> (note / 12 - 3));
-}
-#endif
-
void SoundMgr::unloadSound(int resnum) {
if (_vm->_game.dirSound[resnum].flags & RES_LOADED) {
if (_vm->_game.sounds[resnum]->isPlaying()) {
@@ -184,6 +173,7 @@ void SoundMgr::stopSound() {
_endflag = -1;
}
+// FIXME: This is called from SoundGen classes on unsynchronized background threads.
void SoundMgr::soundIsFinished() {
if (_endflag != -1)
_vm->setFlag(_endflag, true);
@@ -225,10 +215,6 @@ SoundMgr::SoundMgr(AgiBase *agi, Audio::Mixer *pMixer) {
}
}
-void SoundMgr::setVolume(uint8 volume) {
- // TODO
-}
-
SoundMgr::~SoundMgr() {
stopSound();
diff --git a/engines/agi/sound.h b/engines/agi/sound.h
index 2d87598e9a8..2c6803e2548 100644
--- a/engines/agi/sound.h
+++ b/engines/agi/sound.h
@@ -95,10 +95,6 @@ public:
/**
* A named constructor for creating different types of AgiSound objects
* from a raw sound resource.
- *
- * NOTE: This function should take responsibility for freeing the raw resource
- * from memory using free() or delegate the responsibility onwards to some other
- * function!
*/
static AgiSound *createFromRawResource(uint8 *data, uint32 len, int resnum, int soundemu);
@@ -122,8 +118,6 @@ public:
SoundMgr(AgiBase *agi, Audio::Mixer *pMixer);
~SoundMgr();
- void setVolume(uint8 volume);
-
void unloadSound(int);
void startSound(int, int);
void stopSound();
Commit: 3b7a9e166364c2e3f41b95442835c3d9fec0acc7
https://github.com/scummvm/scummvm/commit/3b7a9e166364c2e3f41b95442835c3d9fec0acc7
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-09-08T17:15:19-07:00
Commit Message:
AGI: Add setFlagOrVar()
Changed paths:
engines/agi/agi.h
engines/agi/global.cpp
engines/agi/op_cmd.cpp
engines/agi/sound.cpp
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index e7530884fca..08bf10c5913 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -759,6 +759,8 @@ public:
bool getFlag(int16 flagNr);
void setFlag(int16 flagNr, bool newState);
void flipFlag(int16 flagNr);
+ /** Sets a flag in AGIv2+, sets a variable in AGIv1 */
+ void setFlagOrVar(int16 flagNr, bool newState);
const AGIGameDescription *_gameDescription;
diff --git a/engines/agi/global.cpp b/engines/agi/global.cpp
index b604de950f5..7d4b9d147fd 100644
--- a/engines/agi/global.cpp
+++ b/engines/agi/global.cpp
@@ -51,6 +51,14 @@ void AgiBase::flipFlag(int16 flagNr) {
*flagPtr ^= 1 << (flagNr & 0x07); // flip bit
}
+void AgiBase::setFlagOrVar(int16 flagNr, bool newState) {
+ if (getVersion() < 0x2000) {
+ _game.vars[flagNr] = (newState ? 1 : 0);
+ } else {
+ setFlag(flagNr, newState);
+ }
+}
+
void AgiEngine::setVar(int16 varNr, byte newValue) {
_game.vars[varNr] = newValue;
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index 336965b916d..22ec453e000 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -714,7 +714,7 @@ void cmdSound(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
vm->waitAnyKeyOrFinishedSound();
vm->_sound->stopSound();
}
- vm->setFlag(flagNr, true);
+ vm->setFlagOrVar(flagNr, true);
} else {
vm->_sound->startSound(resourceNr, flagNr);
}
@@ -1684,11 +1684,10 @@ void cmdFollowEgo(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
screenObj->follow_flag = followFlag;
screenObj->follow_count = 255;
+ vm->setFlagOrVar(screenObj->follow_flag, false);
if (vm->getVersion() < 0x2000) {
- vm->setVar(screenObj->follow_flag, 0);
screenObj->flags |= fUpdate | fAnimated;
} else {
- vm->setFlag(screenObj->follow_flag, false);
screenObj->flags |= fUpdate;
}
@@ -1712,11 +1711,10 @@ void cmdMoveObj(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
if (stepSize != 0)
screenObj->stepSize = stepSize;
+ vm->setFlagOrVar(screenObj->move_flag, false);
if (vm->getVersion() < 0x2000) {
- vm->setVar(moveFlag, 0);
screenObj->flags |= fUpdate | fAnimated;
} else {
- vm->setFlag(screenObj->move_flag, false);
screenObj->flags |= fUpdate;
}
diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp
index d85e09e8d71..98eb38e7007 100644
--- a/engines/agi/sound.cpp
+++ b/engines/agi/sound.cpp
@@ -143,11 +143,7 @@ void SoundMgr::startSound(int resnum, int flag) {
// Reset the flag
_endflag = flag;
- if (_vm->getVersion() < 0x2000) {
- _vm->_game.vars[_endflag] = 0;
- } else {
- _vm->setFlag(_endflag, false);
- }
+ _vm->setFlagOrVar(_endflag, false);
}
void SoundMgr::stopSound() {
@@ -163,11 +159,7 @@ void SoundMgr::stopSound() {
// This is needed all the time, some games wait until music got played and when a sound/music got stopped early
// it would otherwise block the game (for example Death Angel jingle in back door poker room in Police Quest 1, room 71)
if (_endflag != -1) {
- if (_vm->getVersion() < 0x2000) {
- _vm->_game.vars[_endflag] = 1;
- } else {
- _vm->setFlag(_endflag, true);
- }
+ _vm->setFlagOrVar(_endflag, true);
}
_endflag = -1;
@@ -176,7 +168,7 @@ void SoundMgr::stopSound() {
// FIXME: This is called from SoundGen classes on unsynchronized background threads.
void SoundMgr::soundIsFinished() {
if (_endflag != -1)
- _vm->setFlag(_endflag, true);
+ _vm->setFlagOrVar(_endflag, true);
if (_playingSound != -1)
_vm->_game.sounds[_playingSound]->stop();
Commit: 58e2d8873499fd47f3369cb9cfaedfabcfdab14a
https://github.com/scummvm/scummvm/commit/58e2d8873499fd47f3369cb9cfaedfabcfdab14a
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-09-08T17:15:19-07:00
Commit Message:
AGI: Fix message when GMM save/load unavailable
The message intended for PreAGI games was applied to all games
when save/load was temporarily unavailable.
See: ae05b7a7513f4924e0762e87d80f80146b69c50e
Changed paths:
engines/agi/metaengine.cpp
diff --git a/engines/agi/metaengine.cpp b/engines/agi/metaengine.cpp
index aafe35d90d5..d378ef4c681 100644
--- a/engines/agi/metaengine.cpp
+++ b/engines/agi/metaengine.cpp
@@ -403,46 +403,48 @@ SaveStateDescriptor AgiMetaEngine::querySaveMetaInfos(const char *target, int sl
namespace Agi {
bool AgiBase::canLoadGameStateCurrently(Common::U32String *msg) {
- if (!(getGameType() == GType_PreAGI)) {
- if (getFlag(VM_FLAG_MENUS_ACCESSIBLE)) {
- if (!_noSaveLoadAllowed) {
- if (!cycleInnerLoopIsActive()) {
- // We can't allow to restore a game, while inner loop is active
- // For example Mixed Up Mother Goose has an endless loop for user name input
- // Which means even if we abort the inner loop, the game would keep on calling
- // GetString() until something is entered. And this would of course also happen
- // right after restoring a saved game.
- return true;
- }
+ if (getGameType() == GType_PreAGI) {
+ if (msg)
+ *msg = _("This game does not support loading");
+ return false;
+ }
+
+ if (getFlag(VM_FLAG_MENUS_ACCESSIBLE)) {
+ if (!_noSaveLoadAllowed) {
+ if (!cycleInnerLoopIsActive()) {
+ // We can't allow to restore a game, while inner loop is active
+ // For example Mixed Up Mother Goose has an endless loop for user name input
+ // Which means even if we abort the inner loop, the game would keep on calling
+ // GetString() until something is entered. And this would of course also happen
+ // right after restoring a saved game.
+ return true;
}
}
}
- if (msg)
- *msg = _("This game does not support loading");
-
return false;
}
bool AgiBase::canSaveGameStateCurrently(Common::U32String *msg) {
+ if (getGameType() == GType_PreAGI) {
+ if (msg)
+ *msg = _("This game does not support saving");
+ return false;
+ }
+
if (getGameID() == GID_BC) // Technically in Black Cauldron we may save anytime
return true;
- if (!(getGameType() == GType_PreAGI)) {
- if (getFlag(VM_FLAG_MENUS_ACCESSIBLE)) {
- if (!_noSaveLoadAllowed) {
- if (!cycleInnerLoopIsActive()) {
- if (promptIsEnabled()) {
- return true;
- }
+ if (getFlag(VM_FLAG_MENUS_ACCESSIBLE)) {
+ if (!_noSaveLoadAllowed) {
+ if (!cycleInnerLoopIsActive()) {
+ if (promptIsEnabled()) {
+ return true;
}
}
}
}
- if (msg)
- *msg = _("This game does not support saving");
-
return false;
}
More information about the Scummvm-git-logs
mailing list