aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter van Niftrik2016-12-27 19:05:45 +0100
committerWalter van Niftrik2016-12-27 19:06:57 +0100
commit4f1a821e6602ff580992c73b00e9174bd46a9c14 (patch)
tree52a67e50591251dc35188e8532d56a1643737385
parente78abf4e061ca7c8a144c1123e54381580ae3f41 (diff)
downloadscummvm-rg350-4f1a821e6602ff580992c73b00e9174bd46a9c14.tar.gz
scummvm-rg350-4f1a821e6602ff580992c73b00e9174bd46a9c14.tar.bz2
scummvm-rg350-4f1a821e6602ff580992c73b00e9174bd46a9c14.zip
ADL: Implement hires5 save/restore/restart
-rw-r--r--engines/adl/adl_v2.h3
-rw-r--r--engines/adl/adl_v4.cpp63
-rw-r--r--engines/adl/adl_v4.h3
-rw-r--r--engines/adl/hires5.cpp12
4 files changed, 75 insertions, 6 deletions
diff --git a/engines/adl/adl_v2.h b/engines/adl/adl_v2.h
index fe0c781f44..f0af9eba22 100644
--- a/engines/adl/adl_v2.h
+++ b/engines/adl/adl_v2.h
@@ -59,6 +59,7 @@ protected:
void loadPictures(Common::ReadStream &stream);
void loadItemPictures(Common::ReadStream &stream, byte count);
virtual bool isInventoryFull() { return false; }
+ int askForSlot(const Common::String &question);
void checkTextOverflow(char c);
@@ -91,8 +92,6 @@ protected:
byte _roomOnScreen, _picOnScreen, _itemsOnScreen;
private:
- int askForSlot(const Common::String &question);
-
Common::RandomSource *_random;
};
diff --git a/engines/adl/adl_v4.cpp b/engines/adl/adl_v4.cpp
index 2ab784f3aa..c979f836aa 100644
--- a/engines/adl/adl_v4.cpp
+++ b/engines/adl/adl_v4.cpp
@@ -21,6 +21,7 @@
*/
#include "adl/adl_v4.h"
+#include "adl/display.h"
#include "adl/detection.h"
namespace Adl {
@@ -452,6 +453,68 @@ int AdlEngine_v4::o4_setRegion(ScriptEnv &e) {
return -1;
}
+int AdlEngine_v4::o4_save(ScriptEnv &e) {
+ OP_DEBUG_0("\tSAVE_GAME()");
+
+ _display->printString(_strings_v2.saveReplace);
+ const char key = inputKey();
+
+ if (shouldQuit())
+ return -1;
+
+ if (key != APPLECHAR('Y'))
+ return 0;
+
+ const int slot = askForSlot(_strings_v2.saveInsert);
+
+ if (slot < 0)
+ return -1;
+
+ saveGameState(slot, "");
+ return 0;
+}
+
+int AdlEngine_v4::o4_restore(ScriptEnv &e) {
+ OP_DEBUG_0("\tRESTORE_GAME()");
+
+ const int slot = askForSlot(_strings_v2.restoreInsert);
+
+ if (slot < 0)
+ return -1;
+
+ loadGameState(slot);
+ _isRestoring = false;
+
+ _picOnScreen = 0;
+ _roomOnScreen = 0;
+
+ // Long jump
+ _isRestarting = true;
+ return -1;
+}
+
+int AdlEngine_v4::o4_restart(ScriptEnv &e) {
+ OP_DEBUG_0("\tRESTART_GAME()");
+
+ while (true) {
+ _display->printString(_strings.playAgain);
+ const Common::String input(inputString());
+
+ if (shouldQuit())
+ return -1;
+
+ if (input.firstChar() == APPLECHAR('N')) {
+ return o1_quit(e);
+ } else if (input.firstChar() == APPLECHAR('Y')) {
+ // The original game loads a special save game from volume 3
+ initState();
+ // Long jump
+ _isRestarting = true;
+ return -1;
+ }
+ }
+}
+
int AdlEngine_v4::o4_setRegionRoom(ScriptEnv &e) {
OP_DEBUG_2("\tSET_REGION_ROOM(%d, %d)", e.arg(1), e.arg(2));
diff --git a/engines/adl/adl_v4.h b/engines/adl/adl_v4.h
index c1f9bfbd73..caf2b3f7f8 100644
--- a/engines/adl/adl_v4.h
+++ b/engines/adl/adl_v4.h
@@ -78,6 +78,9 @@ protected:
int o4_setRegionToPrev(ScriptEnv &e);
int o4_moveAllItems(ScriptEnv &e);
int o4_setRegion(ScriptEnv &e);
+ int o4_save(ScriptEnv &e);
+ int o4_restore(ScriptEnv &e);
+ int o4_restart(ScriptEnv &e);
int o4_setRegionRoom(ScriptEnv &e);
int o4_setRoomPic(ScriptEnv &e);
diff --git a/engines/adl/hires5.cpp b/engines/adl/hires5.cpp
index 299d1ec5dd..c1ada9e7d3 100644
--- a/engines/adl/hires5.cpp
+++ b/engines/adl/hires5.cpp
@@ -111,10 +111,10 @@ void HiRes5Engine::setupOpcodeTables() {
Opcode(o4_moveAllItems);
Opcode(o1_quit);
Opcode(o4_setRegion);
- Opcode(o2_save); // TODO
+ Opcode(o4_save);
// 0x10
- Opcode(o2_restore); // TODO
- Opcode(o1_restart); // TODO
+ Opcode(o4_restore);
+ Opcode(o4_restart);
Opcode(o4_setRegionRoom);
Opcode(o_startAnimation);
// 0x14
@@ -244,7 +244,11 @@ void HiRes5Engine::init() {
stream.reset(_disk->createReadStream(0x7, 0xc));
_strings.lineFeeds = readString(*stream);
- // TODO: opcode strings
+ stream.reset(_disk->createReadStream(0x8, 0x3, 0x00, 2));
+ _strings_v2.saveInsert = readStringAt(*stream, 0x66);
+ _strings_v2.saveReplace = readStringAt(*stream, 0x112);
+ _strings_v2.restoreInsert = readStringAt(*stream, 0x180);
+ _strings.playAgain = readStringAt(*stream, 0x247, 0xff);
_messageIds.cantGoThere = 110;
_messageIds.dontUnderstand = 112;