aboutsummaryrefslogtreecommitdiff
path: root/engines/sword2/sword2.cpp
diff options
context:
space:
mode:
authorFabio Battaglia2009-04-07 19:52:46 +0000
committerFabio Battaglia2009-04-07 19:52:46 +0000
commitdc9c538a62d64b40c3a39a673d2f680fa9422f41 (patch)
treeda10a2ff6b6804e714fb124aac805445fe204058 /engines/sword2/sword2.cpp
parentb80abe318d65679d5c0cd8a94a8c106534d240ea (diff)
downloadscummvm-rg350-dc9c538a62d64b40c3a39a673d2f680fa9422f41.tar.gz
scummvm-rg350-dc9c538a62d64b40c3a39a673d2f680fa9422f41.tar.bz2
scummvm-rg350-dc9c538a62d64b40c3a39a673d2f680fa9422f41.zip
Sword2: PSX version support, and GMM loading/saving
svn-id: r39896
Diffstat (limited to 'engines/sword2/sword2.cpp')
-rw-r--r--engines/sword2/sword2.cpp92
1 files changed, 89 insertions, 3 deletions
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index af40e7d635..78fb890deb 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -51,6 +51,7 @@
#include "sword2/router.h"
#include "sword2/screen.h"
#include "sword2/sound.h"
+#include "sword2/saveload.h"
namespace Sword2 {
@@ -104,7 +105,9 @@ bool Sword2MetaEngine::hasFeature(MetaEngineFeature f) const {
bool Sword2::Sword2Engine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL) ||
- (f == kSupportsSubtitleOptions);
+ (f == kSupportsSubtitleOptions) ||
+ (f == kSupportsSavingDuringRuntime) ||
+ (f == kSupportsLoadingDuringRuntime);
}
GameList Sword2MetaEngine::getSupportedGames() const {
@@ -299,6 +302,8 @@ Sword2Engine::Sword2Engine(OSystem *syst) : Engine(syst) {
_gameCycle = 0;
_gameSpeed = 1;
+ _gmmLoadSlot = -1; // Used to manage GMM Loading
+
syst->getEventManager()->registerRandomSource(_rnd, "sword2");
}
@@ -429,8 +434,8 @@ Common::Error Sword2Engine::run() {
if (!dialog.runModal())
startGame();
}
- } else if (!_bootParam && saveExists()) {
- int32 pars[2] = { 221, FX_LOOP };
+ } else if (!_bootParam && saveExists() && !isPsx()) { // Initial load/restart panel disabled in PSX
+ int32 pars[2] = { 221, FX_LOOP }; // version because of missing panel resources
bool result;
_mouse->setMouse(NORMAL_MOUSE_ID);
@@ -465,6 +470,26 @@ Common::Error Sword2Engine::run() {
}
#endif
+ // Handle GMM Loading
+ if (_gmmLoadSlot != -1) {
+
+ // Hide mouse cursor and fade screen
+ _mouse->hideMouse();
+ _screen->fadeDown();
+
+ // Clean up and load game
+ _logic->_router->freeAllRouteMem();
+
+ // TODO: manage error handling
+ restoreGame(_gmmLoadSlot);
+
+ // Reset load slot
+ _gmmLoadSlot = -1;
+
+ // Show mouse
+ _mouse->addHuman();
+ }
+
KeyboardEvent *ke = keyboardEvent();
if (ke) {
@@ -805,4 +830,65 @@ uint32 Sword2Engine::getMillis() {
return _system->getMillis();
}
+Common::Error Sword2Engine::saveGameState(int slot, const char *desc) {
+ uint32 saveVal = saveGame(slot, (byte *)desc);
+
+ if (saveVal == SR_OK)
+ return Common::kNoError;
+ else if (saveVal == SR_ERR_WRITEFAIL || saveVal == SR_ERR_FILEOPEN)
+ return Common::kWritingFailed;
+ else
+ return Common::kUnknownError;
+}
+
+bool Sword2Engine::canSaveGameStateCurrently() {
+ bool canSave = true;
+
+ // No save if dead
+ if (_logic->readVar(DEAD))
+ canSave = false;
+
+ // No save if mouse not shown
+ else if (_mouse->getMouseStatus())
+ canSave = false;
+ // No save if inside a menu
+ else if (_mouse->getMouseMode() == MOUSE_system_menu)
+ canSave = false;
+
+ // No save if fading
+ else if (_screen->getFadeStatus())
+ canSave = false;
+
+ return canSave;
+}
+
+Common::Error Sword2Engine::loadGameState(int slot) {
+
+ // Prepare the game to load through GMM
+ _gmmLoadSlot = slot;
+
+ // TODO: error handling.
+ return Common::kNoError;
+}
+
+bool Sword2Engine::canLoadGameStateCurrently() {
+ bool canLoad = true;
+
+ // No load if mouse is disabled
+ if (_mouse->getMouseStatus())
+ canLoad = false;
+ // No load if mouse is in system menu
+ else if (_mouse->getMouseMode() == MOUSE_system_menu)
+ canLoad = false;
+ // No load if we are fading
+ else if (_screen->getFadeStatus())
+ canLoad = false;
+
+ // But if we are dead, ignore previous conditions
+ if (_logic->readVar(DEAD))
+ canLoad = true;
+
+ return canLoad;
+}
+
} // End of namespace Sword2