aboutsummaryrefslogtreecommitdiff
path: root/engines/dm/dm.cpp
diff options
context:
space:
mode:
authorBendegúz Nagy2016-08-19 11:49:29 +0200
committerBendegúz Nagy2016-08-26 23:02:22 +0200
commitefac7b5eb0dd90bc45761a666d8b68ddad703d19 (patch)
tree849ff961ae5d989a4561c482ceabd7e9797de8ac /engines/dm/dm.cpp
parent5cb1d02972bd13130e6b177dea6e35045ae54055 (diff)
downloadscummvm-rg350-efac7b5eb0dd90bc45761a666d8b68ddad703d19.tar.gz
scummvm-rg350-efac7b5eb0dd90bc45761a666d8b68ddad703d19.tar.bz2
scummvm-rg350-efac7b5eb0dd90bc45761a666d8b68ddad703d19.zip
DM: Add loading from game
Diffstat (limited to 'engines/dm/dm.cpp')
-rw-r--r--engines/dm/dm.cpp43
1 files changed, 40 insertions, 3 deletions
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index 634ddb51c3..2003ace00f 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -207,6 +207,8 @@ DMEngine::DMEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst),
debug("DMEngine::DMEngine");
_saveThumbnail = nullptr;
+ _canLoadFromGMM = false;
+ _loadSaveSlotAtRuntime = -1;
}
DMEngine::~DMEngine() {
@@ -243,6 +245,26 @@ bool DMEngine::hasFeature(EngineFeature f) const {
(f == kSupportsLoadingDuringRuntime);
}
+Common::Error DMEngine::loadGameState(int slot) {
+ if (f435_loadgame(slot) != kM1_LoadgameFailure) {
+ _displayMan->fillScreen(k0_ColorBlack);
+ _displayMan->f436_STARTEND_FadeToPalette(_displayMan->_palDungeonView[0]);
+ _g298_newGame = k0_modeLoadSavedGame;
+
+ f462_startGame();
+ _g523_restartGameRequest = false;
+ _eventMan->f77_hideMouse();
+ _eventMan->f357_discardAllInput();
+ return Common::kNoError;
+ }
+
+ return Common::kNoGameDataFoundError;
+}
+
+bool DMEngine::canLoadGameStateCurrently() {
+ return _canLoadFromGMM;
+}
+
void DMEngine::f22_delay(uint16 verticalBlank) {
for (uint16 i = 0; i < verticalBlank * 2; ++i) {
_eventMan->processInput();
@@ -386,9 +408,18 @@ Common::Error DMEngine::run() {
f463_initializeGame();
while (true) {
f2_gameloop();
+
if (_engineShouldQuit)
return Common::kNoError;
- f444_endGame(_championMan->_g303_partyDead);
+
+ if (_loadSaveSlotAtRuntime == -1)
+ f444_endGame(_championMan->_g303_partyDead);
+ else {
+ loadGameState(_loadSaveSlotAtRuntime);
+ _menuMan->f457_drawEnabledMenus();
+ _displayMan->updateScreen();
+ _loadSaveSlotAtRuntime = -1;
+ }
}
return Common::kNoError;
@@ -403,10 +434,13 @@ void DMEngine::f2_gameloop() {
_dungeonMan->_g308_partyDir = kDirWest;
}
+ _canLoadFromGMM = true;
_g318_waitForInputMaxVerticalBlankCount = 10;
while (true) {
- if (_engineShouldQuit)
+ if (_engineShouldQuit) {
+ _canLoadFromGMM = false;
return;
+ }
// DEBUG CODE
for (int16 i = 0; i < _championMan->_g305_partyChampionCount; ++i) {
@@ -495,8 +529,10 @@ void DMEngine::f2_gameloop() {
}
_eventMan->f380_processCommandQueue();
- if (_engineShouldQuit)
+ if (_engineShouldQuit || _loadSaveSlotAtRuntime != -1) {
+ _canLoadFromGMM = false;
return;
+ }
_displayMan->updateScreen();
if (!_g321_stopWaitingForPlayerInput) {
_eventMan->f363_highlightBoxDisable();
@@ -508,6 +544,7 @@ void DMEngine::f2_gameloop() {
} while (!_g321_stopWaitingForPlayerInput || !_g301_gameTimeTicking);
}
+ _canLoadFromGMM = false;
}
int16 DMEngine::M1_ordinalToIndex(int16 val) {