From 8fddc1258118ff5b32fc594dc9892f76244af474 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 25 Nov 2006 09:28:00 +0000 Subject: Support loading saves from command line. svn-id: r24787 --- engines/cine/cine.cpp | 23 ++++++++++---- engines/cine/cine.h | 7 ++++ engines/cine/main_loop.cpp | 79 ++++++++++++++++++++++++---------------------- engines/cine/various.cpp | 6 ++-- 4 files changed, 68 insertions(+), 47 deletions(-) (limited to 'engines') diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index 41cc95d0ad..375258a666 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -52,8 +52,6 @@ Common::SaveFileManager *g_saveFileMan; CineEngine *g_cine; -static void initialize(); - CineEngine::CineEngine(OSystem *syst) : Engine(syst) { Common::addSpecialDebugLevel(kCineDebugScript, "Script", "Script debug level"); @@ -115,7 +113,7 @@ int CineEngine::go() { } -static void initialize() { +void CineEngine::initialize() { uint16 i; setupOpcodes(); @@ -194,10 +192,23 @@ static void initialize() { freePrcLinkedList(); - loadPrc(BOOT_PRC_NAME); - strcpy(currentPrcName, BOOT_PRC_NAME); + _preLoad = false; + if (ConfMan.hasKey("save_slot")) { + char saveNameBuffer[256]; + + sprintf(saveNameBuffer, "%s.%1d", _targetName.c_str(), ConfMan.getInt("save_slot")); + + bool res = makeLoad(saveNameBuffer); - setMouseCursor(MOUSE_CURSOR_NORMAL); + if (res) + _preLoad = true; + } + + if (!_preLoad) { + loadPrc(BOOT_PRC_NAME); + strcpy(currentPrcName, BOOT_PRC_NAME); + setMouseCursor(MOUSE_CURSOR_NORMAL); + } } } // End of namespace Cine diff --git a/engines/cine/cine.h b/engines/cine/cine.h index e0996419ce..db1c32f4a8 100644 --- a/engines/cine/cine.h +++ b/engines/cine/cine.h @@ -88,6 +88,13 @@ public: void makeSystemMenu(void); const CINEGameDescription *_gameDescription; + +private: + void initialize(void); + bool makeLoad(char *saveName); + void mainLoop(int bootScriptIdx); + + bool _preLoad; }; extern CineEngine *g_cine; diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp index 7eafa0b88e..b3d60ca547 100644 --- a/engines/cine/main_loop.cpp +++ b/engines/cine/main_loop.cpp @@ -178,65 +178,68 @@ int getKeyData() { return k; } -void mainLoop(int bootScriptIdx) { +void CineEngine::mainLoop(int bootScriptIdx) { uint16 var_6; uint16 quitFlag; uint16 i; byte di; uint16 mouseButton; - freeAnimDataTable(); - resetMessageHead(); - resetSeqList(); - resetglobalScriptsHead(); - resetObjectScriptHead(); - resetBgIncrustList(); + quitFlag = 0; - setTextWindow(0, 0, 20, 200); + if (_preLoad == false) { + freeAnimDataTable(); + resetMessageHead(); + resetSeqList(); + resetglobalScriptsHead(); + resetObjectScriptHead(); + resetBgIncrustList(); - errorVar = 0; + setTextWindow(0, 0, 20, 200); - addScriptToList0(bootScriptIdx); + errorVar = 0; - menuVar = 0; + addScriptToList0(bootScriptIdx); - gfxFuncGen1(page0c, page0, page0c, page0, -1); + menuVar = 0; - ptrGfxFunc13(); + gfxFuncGen1(page0c, page0, page0c, page0, -1); - gfxFuncGen2(); + ptrGfxFunc13(); - quitFlag = 0; - inMenu = false; - allowPlayerInput = 0; - checkForPendingDataLoadSwitch = 0; + gfxFuncGen2(); - fadeRequired = 0; - isDrawCommandEnabled = 0; - waitForPlayerClick = 0; - menuCommandLen = 0; + inMenu = false; + allowPlayerInput = 0; + checkForPendingDataLoadSwitch = 0; - playerCommand = -1; - strcpy(commandBuffer, ""); + fadeRequired = 0; + isDrawCommandEnabled = 0; + waitForPlayerClick = 0; + menuCommandLen = 0; - globalVars[0x1F2] = 0; - globalVars[0x1F4] = 0; + playerCommand = -1; + strcpy(commandBuffer, ""); - for (i = 0; i < 16; i++) { - c_palette[i] = 0; - } + globalVars[0x1F2] = 0; + globalVars[0x1F4] = 0; - var17 = 1; + for (i = 0; i < 16; i++) { + c_palette[i] = 0; + } - strcpy(newPrcName, ""); - strcpy(newRelName, ""); - strcpy(newObjectName, ""); - strcpy(newMsgName, ""); - strcpy(currentBgName[0], ""); - strcpy(currentCtName, ""); - strcpy(currentPartName, ""); + var17 = 1; - g_sfxPlayer->stop(); + strcpy(newPrcName, ""); + strcpy(newRelName, ""); + strcpy(newObjectName, ""); + strcpy(newMsgName, ""); + strcpy(currentBgName[0], ""); + strcpy(currentCtName, ""); + strcpy(currentPartName, ""); + + g_sfxPlayer->stop(); + } do { mainLoopSub3(); diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index 700330ff05..d75a2e0f4a 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -438,7 +438,7 @@ void setupObjectScriptList(void) { } } -int16 makeLoad(char *saveName) { +bool CineEngine::makeLoad(char *saveName) { int16 i; int16 size; Common::InSaveFile *fHandle; @@ -450,7 +450,7 @@ int16 makeLoad(char *saveName) { waitPlayerInput(); // restoreScreen(); checkDataDisk(-1); - return -1; + return false; } g_sfxPlayer->stop(); @@ -683,7 +683,7 @@ int16 makeLoad(char *saveName) { }*/ } - return 0; + return true; } void makeSave(char *saveFileName) { -- cgit v1.2.3