[Scummvm-git-logs] scummvm master -> fb9a96d0f8002f108b2e6c0d690849aba80b2fcb
bluegr
noreply at scummvm.org
Sun Jan 16 11:55:18 UTC 2022
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:
fb9a96d0f8 SCI: Add WIP code for saving via GMM and autosaving (still disabled)
Commit: fb9a96d0f8002f108b2e6c0d690849aba80b2fcb
https://github.com/scummvm/scummvm/commit/fb9a96d0f8002f108b2e6c0d690849aba80b2fcb
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-01-16T13:54:57+02:00
Commit Message:
SCI: Add WIP code for saving via GMM and autosaving (still disabled)
We check if the user has control, which seems to be working as intended,
but music is not resumed properly after loading, so it's disabled for
now
Changed paths:
engines/sci/engine/guest_additions.cpp
engines/sci/engine/guest_additions.h
engines/sci/engine/selector.cpp
engines/sci/engine/selector.h
engines/sci/metaengine.cpp
diff --git a/engines/sci/engine/guest_additions.cpp b/engines/sci/engine/guest_additions.cpp
index 34056d42065..4456b705ce8 100644
--- a/engines/sci/engine/guest_additions.cpp
+++ b/engines/sci/engine/guest_additions.cpp
@@ -150,6 +150,26 @@ bool GuestAdditions::shouldSyncAudioToScummVM() const {
return false;
}
+bool GuestAdditions::userHasControl() {
+ const reg_t user = _segMan->findObjectByName("User");
+ const Object *userObject = _segMan->getObject(user);
+
+ // Selectors input/canInput and controls should be available at all times, except
+ // in games that don't have selector vocab 997 (e.g. some game demos and LB2 floppy)
+ const bool hasInputSelector = userObject->locateVarSelector(_segMan, SELECTOR(input)) >= 0;
+ const bool hasCanInputSelector = userObject->locateVarSelector(_segMan, SELECTOR(canInput)) >= 0;
+ const bool hasControlsSelector = userObject->locateVarSelector(_segMan, SELECTOR(controls)) >= 0;
+
+ if ((hasInputSelector || hasCanInputSelector) && hasControlsSelector) {
+ const Selector inputSelector = hasInputSelector ? SELECTOR(input) : SELECTOR(canInput);
+ const int16 input = readSelectorValue(_segMan, user, inputSelector);
+ const int16 controls = readSelectorValue(_segMan, user, SELECTOR(controls));
+ return input && controls;
+ } else {
+ return false;
+ }
+}
+
#pragma mark -
#pragma mark Hooks
diff --git a/engines/sci/engine/guest_additions.h b/engines/sci/engine/guest_additions.h
index b565771c7a7..c2a564a5ff3 100644
--- a/engines/sci/engine/guest_additions.h
+++ b/engines/sci/engine/guest_additions.h
@@ -121,6 +121,11 @@ public:
*/
bool kDoSoundMasterVolumeHook(const int volume) const;
+ /**
+ * Determines whether the user has control.
+ */
+ bool userHasControl();
+
#ifdef ENABLE_SCI32
/**
* Guest additions hook for SciEngine::initGame.
diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp
index 98f3313e20f..8a8bacd1623 100644
--- a/engines/sci/engine/selector.cpp
+++ b/engines/sci/engine/selector.cpp
@@ -172,6 +172,9 @@ void Kernel::mapSelectors() {
FIND_SELECTOR(owner);
FIND_SELECTOR(curPos);
FIND_SELECTOR(update);
+ FIND_SELECTOR(canInput);
+ FIND_SELECTOR(input);
+ FIND_SELECTOR(controls);
#ifdef ENABLE_SCI32
FIND_SELECTOR(data);
@@ -231,7 +234,6 @@ void Kernel::mapSelectors() {
FIND_SELECTOR(scratch);
FIND_SELECTOR(num);
FIND_SELECTOR(reallyRestore);
- FIND_SELECTOR(canInput);
FIND_SELECTOR(bookMark);
FIND_SELECTOR(fileNumber);
FIND_SELECTOR(description);
diff --git a/engines/sci/engine/selector.h b/engines/sci/engine/selector.h
index 0e2df2b7b83..ae498eb45e7 100644
--- a/engines/sci/engine/selector.h
+++ b/engines/sci/engine/selector.h
@@ -139,6 +139,10 @@ struct SelectorCache {
Selector curPos; // for LSL6 volume sync
Selector update; // for LSL6 volume sync
+ Selector canInput; // for Phant2 restore from launcher and checking if user has input
+ Selector input; // for checking if user has input
+ Selector controls; // for checking if user has input
+
#ifdef ENABLE_SCI32
Selector data; // Used by Array()/String()
Selector picture; // Used to hold the picture ID for SCI32 pictures
@@ -189,7 +193,6 @@ struct SelectorCache {
Selector scratch; // for Phant2 save/load patching
Selector num; // for Phant2 restore from launcher
Selector reallyRestore; // for Phant2 restore from launcher
- Selector canInput; // for Phant2 restore from launcher
Selector bookMark; // for Phant2 auto-save
Selector fileNumber; // for RAMA save/load
Selector description; // for RAMA save/load
diff --git a/engines/sci/metaengine.cpp b/engines/sci/metaengine.cpp
index 7c1059dea9e..c542ebe0a49 100644
--- a/engines/sci/metaengine.cpp
+++ b/engines/sci/metaengine.cpp
@@ -32,6 +32,7 @@
#include "sci/sci.h"
#include "sci/dialogs.h"
+#include "sci/engine/guest_additions.h"
#include "sci/engine/kernel.h"
#include "sci/engine/savegame.h"
#include "sci/engine/script.h"
@@ -329,6 +330,8 @@ bool SciEngine::hasFeature(EngineFeature f) const {
// d) for sci0/sci01 games we should at least wait till status bar got drawn, although this may not be enough
// we can't make sure that the scripts are fine with us saving at a specific location, doing so may work sometimes
// and some other times it won't work.
+ // Update: We now have a function that can check if user input is enabled, userHasControl,
+ // which works, but the music isn't properly resumed after load yet.
}
SaveStateList SciMetaEngine::listSaves(const char *target) const {
@@ -469,6 +472,8 @@ bool SciEngine::canLoadGameStateCurrently() {
bool SciEngine::canSaveGameStateCurrently() {
// see comment about kSupportsSavingDuringRuntime in SciEngine::hasFeature
return false;
+ // TODO: This seems to be working, but music isn't resumed properly yet
+ //return !_gamestate->executionStackBase && _guestAdditions->userHasControl();
}
} // End of namespace Sci
More information about the Scummvm-git-logs
mailing list