aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2012-04-04 00:03:41 +0200
committerEugene Sandulenko2018-03-28 17:36:57 +0200
commit6ab621dbd7fb573a7f5b7a0ee6e50ec9f72508f2 (patch)
treee03c55a10b9d858488522bb8d3e2e90b3bd36af3 /engines
parent38b7961bcb2ba472d7d119816dcb7cae29617e07 (diff)
downloadscummvm-rg350-6ab621dbd7fb573a7f5b7a0ee6e50ec9f72508f2.tar.gz
scummvm-rg350-6ab621dbd7fb573a7f5b7a0ee6e50ec9f72508f2.tar.bz2
scummvm-rg350-6ab621dbd7fb573a7f5b7a0ee6e50ec9f72508f2.zip
LILLIPUT: Add a script handler skeletton. All opcodes are stubbed
Diffstat (limited to 'engines')
-rw-r--r--engines/lilliput/lilliput.cpp251
-rw-r--r--engines/lilliput/lilliput.h6
-rw-r--r--engines/lilliput/module.mk3
-rw-r--r--engines/lilliput/script.cpp1051
-rw-r--r--engines/lilliput/script.h205
5 files changed, 1512 insertions, 4 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp
index befec749b7..285f03c3a0 100644
--- a/engines/lilliput/lilliput.cpp
+++ b/engines/lilliput/lilliput.cpp
@@ -27,10 +27,11 @@
#include "common/debug-channels.h"
#include "common/config-manager.h"
#include "common/textconsole.h"
+#include "common/memstream.h"
#include "lilliput/lilliput.h"
-
#include "engines/util.h"
+#include "lilliput/script.h"
namespace Lilliput {
@@ -52,6 +53,9 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_console = new LilliputConsole(this);
_rnd = 0;
+ _scriptHandler = new LilliputScript(this);
+
+ _vm_byte1714E = 0;
}
LilliputEngine::~LilliputEngine() {
@@ -70,7 +74,7 @@ bool LilliputEngine::hasFeature(EngineFeature f) const {
}
const char *LilliputEngine::getCopyrightString() const {
- return "Copyright 1989-1997 David P Gray, All Rights Reserved.";
+ return "copyright S.L.Grand, Brainware, 1991";
}
GameType LilliputEngine::getGameType() const {
@@ -81,6 +85,232 @@ Common::Platform LilliputEngine::getPlatform() const {
return _platform;
}
+byte *LilliputEngine::loadVGA(Common::String filename, bool loadPal) {
+ Common::File f;
+
+ if (!f.open(filename))
+ error("Missing game file %s", filename.c_str());
+
+ int remainingSize = f.size();
+ if (loadPal) {
+ for (int i = 0; i < 768; ++i)
+ _palette[i] = f.readByte();
+ remainingSize -= 768;
+ }
+
+ uint8 curByte;
+ byte decodeBuffer[100000];
+ int size = 0;
+
+ for (;remainingSize > 0;) {
+ curByte = f.readByte();
+ --remainingSize;
+
+ if (curByte == 0xFF)
+ break;
+
+ if (curByte & 0x80) {
+ // Compressed
+ int compSize = (curByte & 0x7F);
+ curByte = f.readByte();
+ --remainingSize;
+
+ for (int i = 0; i < compSize; ++i) {
+ decodeBuffer[size] = curByte;
+ ++size;
+ }
+ } else {
+ // Not compressed
+ int rawSize = (curByte & 0xF);
+ for (int i = 0; i < rawSize; ++i) {
+ decodeBuffer[size] = f.readByte();
+ --remainingSize;
+ ++size;
+ }
+ }
+ }
+
+ f.close();
+
+ byte *res = (byte *)malloc(sizeof(byte) * size);
+ memcpy(res, decodeBuffer, size);
+ return res;
+}
+
+byte *LilliputEngine::loadRaw(Common::String filename) {
+ Common::File f;
+
+ if (!f.open(filename))
+ error("Missing game file %s", filename.c_str());
+
+ int size = f.size();
+ byte *res = (byte *)malloc(sizeof(byte) * size);
+ for (int i = 0; i < size; ++i)
+ res[i] = f.readByte();
+
+ f.close();
+ return res;
+}
+
+void LilliputEngine::loadRules() {
+ static const byte _rulesXlatArray[26] = {30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44};
+ Common::File f;
+ uint16 curWord;
+
+ if (!f.open("ERULES.PRG"))
+ error("Missing game file ERULES.PRG");
+
+ _word10800_ERULES = f.readUint16LE();
+
+ // Chunk 1
+ int size = f.readUint16LE();
+ _rulesChunk1 = (byte *)malloc(sizeof(byte) * size);
+ for (int i = 0; i < size; ++i)
+ _rulesChunk1[i] = f.readByte();
+
+ // Chunk 2
+ _word10807_ERULES = f.readSint16LE();
+ assert(_word10807_ERULES <= 40);
+
+ for (int i = _word10807_ERULES, j = 0; i != 0; i--, j++) {
+ curWord = f.readUint16LE();
+ if (curWord != 0xFFFF)
+ curWord = (curWord << 3) + 4;
+ _rulesBuffer2_1[j] = curWord;
+
+ curWord = f.readUint16LE();
+ if (curWord != 0xFFFF)
+ curWord = (curWord << 3) + 4;
+ _rulesBuffer2_2[j] = curWord;
+
+ _rulesBuffer2_3[j] = (f.readUint16LE() & 0xFF);
+ _rulesBuffer2_4[j] = f.readUint16LE();
+ _rulesBuffer2_5[j] = f.readByte();
+ _rulesBuffer2_6[j] = f.readByte();
+ _rulesBuffer2_7[j] = f.readByte();
+ _rulesBuffer2_8[j] = f.readByte();
+ _rulesBuffer2_9[j] = f.readByte();
+ _rulesBuffer2_10[j] = f.readByte();
+ _rulesBuffer2_11[j] = f.readByte();
+ _rulesBuffer2_12[j] = f.readByte();
+ _rulesBuffer2_13[j] = f.readByte();
+ _rulesBuffer2_14[j] = f.readByte();
+
+ for (int k = 0; k < 32; k++)
+ _rulesBuffer2_15[(j * 32) + k] = f.readByte();
+
+ for (int k = 0; k < 32; k++)
+ _rulesBuffer2_16[(j * 32) + k] = f.readByte();
+ }
+
+ // Chunk 3 & 4
+ warning("Chunk 3 & 4 Pos: %d", f.pos());
+ _rulesChunk3_size = f.readSint16LE();
+ curWord = f.readSint16LE();
+
+ warning("Pos %d", f.pos());
+ _rulesChunk3 = (int *)malloc(sizeof(int) * _rulesChunk3_size);
+ for (int i = 0; i < _rulesChunk3_size; ++i)
+ _rulesChunk3[i] = f.readUint16LE();
+
+ warning("Pos %d", f.pos());
+ _rulesChunk4 = (byte *)malloc(sizeof(byte) * curWord);
+ for (int i = 0; i < curWord; ++i)
+ _rulesChunk4[i] = f.readByte();
+
+ // Chunk 5: Scripts
+ warning("Chunk 5 Pos: %d", f.pos());
+ // Use byte instead of int, therefore multiply by two the size.
+ // This is for changing that into a memory read stream
+ _rulesScript_size = f.readUint16LE() * 2;
+ _rulesScript = (byte *)malloc(sizeof(byte) * _rulesScript_size);
+ for (int i = 0; i < _rulesScript_size; ++i)
+ _rulesScript[i] = f.readByte();
+
+ // Chunk 6
+ _rulesChunk6_size = f.readUint16LE();
+ _rulesChunk6 = (int *)malloc(sizeof(int) * _rulesChunk6_size);
+ for (int i = 0; i < _rulesChunk6_size; ++i)
+ _rulesChunk6[i] = f.readUint16LE();
+
+ // Chunk 7 & 8
+ _rulesChunk7_size = f.readUint16LE();
+ _rulesChunk7 = (int *)malloc(sizeof(int) * _rulesChunk7_size);
+ for (int i = 0; i < _rulesChunk7_size; ++i)
+ _rulesChunk7[i] = f.readUint16LE();
+
+ curWord = f.readUint16LE();
+ _rulesChunk8 = (byte *)malloc(sizeof(byte) * curWord);
+ for (int i = 0; i < curWord; ++i)
+ _rulesChunk8[i] = f.readByte();
+
+ // Chunk 9
+ for (int i = 0; i < 60; i++)
+ _rulesChunk9[i] = f.readByte();
+
+ // Chunk 10 & 11
+ _rulesChunk10_size = f.readByte();
+ assert(_rulesChunk10_size <= 20);
+
+ if (_rulesChunk10_size != 0) {
+ _rulesChunk10 = (int *)malloc(sizeof(int) * _rulesChunk10_size);
+ int totalSize = 0;
+ for (int i = 0; i < _rulesChunk10_size; ++i) {
+ _rulesChunk10[i] = totalSize;
+ totalSize += f.readByte();
+ }
+ if (totalSize != 0) {
+ _rulesChunk11 = (byte *)malloc(sizeof(byte) * totalSize);
+ for (int i = 0; i < totalSize; i++)
+ _rulesChunk11[i] = f.readByte();
+ }
+ }
+
+ // Chunk 12
+ _rulesChunk12_size = f.readUint16LE();
+ assert(_rulesChunk12_size <= 40);
+
+ for (int i = 0; i < _rulesChunk12_size; i++) {
+ _rulesBuffer12_1[i] = f.readUint16LE();
+ _rulesBuffer12_2[i] = f.readUint16LE();
+ _rulesBuffer12_3[i] = f.readUint16LE();
+ _rulesBuffer12_4[i] = f.readUint16LE();
+ }
+
+ // Chunk 13
+ _word12F68_ERULES = f.readUint16LE();
+ for (int i = 0 ; i < 20; i++)
+ _rulesBuffer13_1[i] = f.readByte();
+
+ for (int i = 0 ; i < 20; i++)
+ _rulesBuffer13_2[i] = f.readUint16LE();
+
+ for (int i = 0 ; i < 20; i++)
+ _rulesBuffer13_3[i] = f.readUint16LE();
+
+ for (int i = 0; i < 20; i++) {
+ byte curByte = f.readByte();
+
+ if (curByte == 0x20)
+ _rulesBuffer13_4[i] = 0x39;
+ else if (curByte == 0xD)
+ _rulesBuffer13_4[i] = 0x1C;
+ // Hack to avoid xlat out of bounds
+ else if (curByte == 0xFF)
+ _rulesBuffer13_4[i] = 0x21;
+ // Hack to avoid xlat out of bounds
+ else if (curByte == 0x00)
+ _rulesBuffer13_4[i] = 0xB4;
+ else {
+ assert((curByte > 0x40) && (curByte <= 0x41 + 26));
+ _rulesBuffer13_4[i] = _rulesXlatArray[curByte - 0x41];
+ }
+ }
+ f.close();
+
+ // Skipped: Load Savegame
+}
+
Common::Error LilliputEngine::run() {
s_Engine = this;
initGraphics(320, 200);
@@ -88,6 +318,23 @@ Common::Error LilliputEngine::run() {
// Setup mixer
syncSoundSettings();
+ // TODO: Init Palette
+
+ // Load files. In the original, the size was hardcoded
+ _bufferIdeogram = loadVGA("IDEOGRAM.VGA", false);
+ _bufferMen = loadVGA("MEN.VGA", false);
+ _bufferMen2 = loadVGA("MEN2.VGA", false);
+ _bufferIsoChars = loadVGA("ISOCHARS.VGA", false);
+ _bufferIsoMap = loadRaw("ISOMAP.DTA");
+
+ //TODO: Init mouse handler
+
+ loadRules();
+
+ //TODO: Init sound/music player
+ _scriptHandler->runScript(Common::MemoryReadStream(_rulesScript, _rulesScript_size));
+
+ //TODO: Main loop
return Common::kNoError;
}
diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h
index 68dffd3839..7080868215 100644
--- a/engines/lilliput/lilliput.h
+++ b/engines/lilliput/lilliput.h
@@ -26,6 +26,7 @@
#include "engines/engine.h"
#include "common/file.h"
#include "lilliput/console.h"
+#include "lilliput/script.h"
namespace Common {
class RandomSource;
@@ -75,6 +76,9 @@ public:
GUI::Debugger *getDebugger();
Common::RandomSource *_rnd;
+ LilliputScript *_scriptHandler;
+
+ byte _vm_byte1714E;
byte _buffer1[45056];
byte _buffer2[45056];
@@ -110,7 +114,7 @@ public:
int *_rulesChunk3;
int _rulesChunk3_size;
byte *_rulesChunk4;
- int *_rulesScript;
+ byte *_rulesScript;
int _rulesScript_size;
int *_rulesChunk6;
int _rulesChunk6_size;
diff --git a/engines/lilliput/module.mk b/engines/lilliput/module.mk
index 0ec4403921..6f701a3e43 100644
--- a/engines/lilliput/module.mk
+++ b/engines/lilliput/module.mk
@@ -2,8 +2,9 @@ MODULE := engines/lilliput
MODULE_OBJS = \
console.o \
+ detection.o \
lilliput.o \
- detection.o
+ script.o
MODULE_DIRS += \
engines/lilliput
diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp
new file mode 100644
index 0000000000..b8f1cc97ff
--- /dev/null
+++ b/engines/lilliput/script.cpp
@@ -0,0 +1,1051 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "lilliput/lilliput.h"
+#include "lilliput/script.h"
+
+namespace Lilliput {
+
+LilliputScript::LilliputScript(LilliputEngine *vm) : _vm(vm) {
+}
+
+LilliputScript::~LilliputScript() {
+}
+
+byte LilliputScript::handleOpcodeType1(int curWord) {
+ warning("handleOpcodeType1: %d", curWord);
+ switch (curWord) {
+ case 0x0:
+ return OC_sub173DF();
+ break;
+ case 0x1:
+ return OC_sub173F0();
+ break;
+ case 0x2:
+ return OC_sub1740A();
+ break;
+ case 0x3:
+ return OC_sub17434();
+ break;
+ case 0x4:
+ return OC_sub17468();
+ break;
+ case 0x5:
+ return OC_getRandom();
+ break;
+ case 0x6:
+ return OC_sub1748C();
+ break;
+ case 0x7:
+ return OC_compWord18776();
+ break;
+ case 0x8:
+ return OC_checkSaveFlag();
+ break;
+ case 0x9:
+ return OC_sub174C8();
+ break;
+ case 0xA:
+ return OC_sub174D8();
+ break;
+ case 0xB:
+ return OC_sub1750E();
+ break;
+ case 0xC:
+ return OC_compareCoords_1();
+ break;
+ case 0xD:
+ return OC_compareCoords_2();
+ break;
+ case 0xE:
+ return OC_sub1757C();
+ break;
+ case 0xF:
+ return OC_sub1759E();
+ break;
+ case 0x10:
+ return OC_compWord16EF8();
+ break;
+ case 0x11:
+ return OC_sub175C8();
+ break;
+ case 0x12:
+ return OC_sub17640();
+ break;
+ case 0x13:
+ return OC_sub176C4();
+ break;
+ case 0x14:
+ return OC_compWord10804();
+ break;
+ case 0x15:
+ return OC_sub17766();
+ break;
+ case 0x16:
+ return OC_sub17782();
+ break;
+ case 0x17:
+ return OC_sub1779E();
+ break;
+ case 0x18:
+ return OC_sub177C6();
+ break;
+ case 0x19:
+ return OC_compWord16EFE();
+ break;
+ case 0x1A:
+ return OC_sub177F5();
+ break;
+ case 0x1B:
+ return OC_sub17812();
+ break;
+ case 0x1C:
+ return OC_sub17825();
+ break;
+ case 0x1D:
+ return OC_sub17844();
+ break;
+ case 0x1E:
+ return OC_sub1785C();
+ break;
+ case 0x1F:
+ return OC_sub17886();
+ break;
+ case 0x20:
+ return OC_sub178A8();
+ break;
+ case 0x21:
+ return OC_sub178BA();
+ break;
+ case 0x22:
+ return OC_sub178C2();
+ break;
+ case 0x23:
+ return OC_sub178D2();
+ break;
+ case 0x24:
+ return OC_sub178E8();
+ break;
+ case 0x25:
+ return OC_sub178FC();
+ break;
+ case 0x26:
+ return OC_sub1790F();
+ break;
+ case 0x27:
+ return OC_sub1792A();
+ break;
+ case 0x28:
+ return OC_sub1793E();
+ break;
+ case 0x29:
+ return OC_sub1795E();
+ break;
+ case 0x2A:
+ return OC_sub1796E();
+ break;
+ case 0x2B:
+ return OC_sub17984();
+ break;
+ case 0x2C:
+ return OC_checkSavedMousePos();
+ break;
+ case 0x2D:
+ return OC_sub179AE();
+ break;
+ case 0x2E:
+ return OC_sub179C2();
+ break;
+ case 0x2F:
+ return OC_sub179E5();
+ break;
+ case 0x30:
+ return OC_sub17A07();
+ break;
+ case 0x31:
+ return OC_sub17757();
+ break;
+ default:
+ error("Unexpected opcode %d", curWord);
+ break;
+ }
+}
+
+void LilliputScript::handleOpcodeType2(int curWord) {
+ warning("handleOpcodeType1: %d", curWord);
+ switch (curWord) {
+ case 0x0:
+ OC_setWord18821();
+ break;
+ case 0x1:
+ OC_sub17A3E();
+ break;
+ case 0x2:
+ OC_sub17D57();
+ break;
+ case 0x3:
+ OC_sub17D7F();
+ break;
+ case 0x4:
+ OC_sub17DB9();
+ break;
+ case 0x5:
+ OC_sub17DF9();
+ break;
+ case 0x6:
+ OC_sub17E07();
+ break;
+ case 0x7:
+ OC_sub17E15();
+ break;
+ case 0x8:
+ OC_sub17B03();
+ break;
+ case 0x9:
+ OC_getRandom_type2();
+ break;
+ case 0xA:
+ OC_sub17A66();
+ break;
+ case 0xB:
+ OC_sub17A8D();
+ break;
+ case 0xC:
+ OC_saveAndQuit();
+ break;
+ case 0xD:
+ OC_sub17B93();
+ break;
+ case 0xE:
+ OC_sub17E37();
+ break;
+ case 0xF:
+ OC_resetByte1714E();
+ break;
+ case 0x10:
+ OC_deleteSavegameAndQuit();
+ break;
+ case 0x11:
+ OC_incByte16F04();
+ break;
+ case 0x12:
+ OC_sub17BA5();
+ break;
+ case 0x13:
+ OC_setByte18823();
+ break;
+ case 0x14:
+ OC_sub17BB7();
+ break;
+ case 0x15:
+ OC_sub17BF2();
+ break;
+ case 0x16:
+ OC_sub17ACC();
+ break;
+ case 0x17:
+ OC_resetByte16F04();
+ break;
+ case 0x18:
+ OC_sub17AE1();
+ break;
+ case 0x19:
+ OC_sub17AEE();
+ break;
+ case 0x1A:
+ OC_setWord10804();
+ break;
+ case 0x1B:
+ OC_sub17C0E();
+ break;
+ case 0x1C:
+ OC_sub17C55();
+ break;
+ case 0x1D:
+ OC_sub17C76();
+ break;
+ case 0x1E:
+ OC_sub17AFC();
+ break;
+ case 0x1F:
+ OC_sub17C8B();
+ break;
+ case 0x20:
+ OC_sub17CA2();
+ break;
+ case 0x21:
+ OC_sub17CB9();
+ break;
+ case 0x22:
+ OC_sub17CD1();
+ break;
+ case 0x23:
+ OC_resetWord16EFE();
+ break;
+ case 0x24:
+ OC_sub17CEF();
+ break;
+ case 0x25:
+ OC_sub17D1B();
+ break;
+ case 0x26:
+ OC_sub17D23();
+ break;
+ case 0x27:
+ OC_sub17E6D();
+ break;
+ case 0x28:
+ OC_sub17E7E();
+ break;
+ case 0x29:
+ OC_sub17E99();
+ break;
+ case 0x2A:
+ OC_sub17EC5();
+ break;
+ case 0x2B:
+ OC_sub17EF4();
+ break;
+ case 0x2C:
+ OC_sub17F08();
+ break;
+ case 0x2D:
+ OC_sub17F4F();
+ break;
+ case 0x2E:
+ OC_sub17F68();
+ break;
+ case 0x2F:
+ OC_getNextVal();
+ break;
+ case 0x30:
+ OC_sub17FD2();
+ break;
+ case 0x31:
+ OC_sub17FDD();
+ break;
+ case 0x32:
+ OC_setByte10B29();
+ break;
+ case 0x33:
+ OC_sub18007();
+ break;
+ case 0x34:
+ OC_sub18014();
+ break;
+ case 0x35:
+ OC_sub1801D();
+ break;
+ case 0x36:
+ OC_sub1805D();
+ break;
+ case 0x37:
+ OC_sub18074();
+ break;
+ case 0x38:
+ OC_sub1808B();
+ break;
+ case 0x39:
+ OC_sub18099();
+ break;
+ case 0x3A:
+ OC_sub180C3();
+ break;
+ case 0x3B:
+ OC_sub1810A();
+ break;
+ case 0x3C:
+ OC_sub1812D();
+ break;
+ case 0x3D:
+ OC_sub1817F();
+ break;
+ case 0x3E:
+ OC_sub181BB();
+ break;
+ case 0x3F:
+ OC_sub18213();
+ break;
+ case 0x40:
+ OC_sub18252();
+ break;
+ case 0x41:
+ OC_sub18260();
+ break;
+ case 0x42:
+ OC_sub182EC();
+ break;
+ case 0x43:
+ OC_unkPaletteFunction_1();
+ break;
+ case 0x44:
+ OC_unkPaletteFunction_2();
+ break;
+ case 0x45:
+ OC_loadAndDisplayCUBESx_GFX();
+ break;
+ case 0x46:
+ OC_sub1834C();
+ break;
+ case 0x47:
+ OC_sub18359();
+ break;
+ case 0x48:
+ OC_sub18367();
+ break;
+ case 0x49:
+ OC_sub17D04();
+ break;
+ case 0x4A:
+ OC_sub18387();
+ break;
+ case 0x4B:
+ OC_setByte14835();
+ break;
+ case 0x4C:
+ OC_setByte14837();
+ break;
+ case 0x4D:
+ OC_sub183A2();
+ break;
+ case 0x4E:
+ OC_sub183C6();
+ break;
+ case 0x4F:
+ OC_loadFile_AERIAL_GFX();
+ break;
+ case 0x50:
+ OC_sub17E22();
+ break;
+ case 0x51:
+ OC_sub1844A();
+ break;
+ case 0x52:
+ OC_sub1847F();
+ break;
+ case 0x53:
+ OC_sub184AA();
+ break;
+ case 0x54:
+ OC_sub184D7();
+ break;
+ case 0x55:
+ OC_sub184F5();
+ break;
+ case 0x56:
+ OC_sub1853B();
+ break;
+ case 0x57:
+ OC_sub1864D();
+ break;
+ case 0x58:
+ OC_sub18608();
+ break;
+ case 0x59:
+ OC_sub18678();
+ break;
+ case 0x5A:
+ OC_sub18690();
+ break;
+ case 0x5B:
+ OC_setWord10802();
+ break;
+ case 0x5C:
+ OC_sub186A1();
+ break;
+ case 0x5D:
+ OC_sub186E5_snd();
+ break;
+ case 0x5E:
+ OC_sub1870A_snd();
+ break;
+ case 0x5F:
+ OC_sub18725_snd();
+ break;
+ case 0x60:
+ OC_sub18733_snd();
+ break;
+ case 0x61:
+ OC_sub1873F_snd();
+ break;
+ case 0x62:
+ OC_sub18746_snd();
+ break;
+ case 0x63:
+ OC_sub1875D_snd();
+ break;
+ case 0x64:
+ OC_sub18764();
+ break;
+ case 0x65:
+ OC_sub1853B();
+ break;
+ default:
+ error("Unknown opcode %d", curWord);
+ break;
+ }
+}
+
+int LilliputScript::handleOpcode(Common::MemoryReadStream script) {
+ uint16 curWord = script.readUint16LE();
+ if (curWord == 0xFFF6)
+ return -1;
+
+ while (curWord != 0xFFF8) {
+ byte mask = 0;
+ if (curWord > 1000) {
+ curWord -= 1000;
+ mask = 1;
+ }
+ byte result = handleOpcodeType1(curWord);
+ if ((result ^ mask) == 0) {
+ do {
+ curWord = script.readUint16LE();
+ } while (curWord != 0xFFF7);
+ return 0;
+ }
+ }
+
+ _vm->_vm_byte1714E = 1;
+
+ for (;;) {
+ curWord = script.readUint16LE();
+ if (curWord == 0xFFF7)
+ return _vm->_vm_byte1714E;
+
+ handleOpcodeType2(curWord);
+ }
+}
+
+void LilliputScript::runScript(Common::MemoryReadStream script) {
+ _byte16F05_ScriptHandler = 1;
+
+ while (handleOpcode(script) != 0xFF)
+ ;
+
+}
+
+byte LilliputScript::OC_sub173DF() {
+ warning("OC_sub173DF");
+ return 0;
+}
+byte LilliputScript::OC_sub173F0() {
+ warning("OC_sub173F0");
+ return 0;
+}
+byte LilliputScript::OC_sub1740A() {
+ warning("OC_sub1740A");
+ return 0;
+}
+byte LilliputScript::OC_sub17434() {
+ warning("OC_sub17434");
+ return 0;
+}
+byte LilliputScript::OC_sub17468() {
+ warning("OC_sub17468");
+ return 0;
+}
+byte LilliputScript::OC_getRandom() {
+ warning("OC_getRandom");
+ return 0;
+}
+byte LilliputScript::OC_sub1748C() {
+ warning("OC_sub1748C");
+ return 0;
+}
+byte LilliputScript::OC_compWord18776() {
+ warning("OC_compWord18776");
+ return 0;
+}
+byte LilliputScript::OC_checkSaveFlag() {
+ warning("OC_checkSaveFlag");
+ return 0;
+}
+byte LilliputScript::OC_sub174C8() {
+ warning("OC_sub174C8");
+ return 0;
+}
+byte LilliputScript::OC_sub174D8() {
+ warning("OC_sub174D8");
+ return 0;
+}
+byte LilliputScript::OC_sub1750E() {
+ warning("OC_sub1750E");
+ return 0;
+}
+byte LilliputScript::OC_compareCoords_1() {
+ warning("compareCoords_1");
+ return 0;
+}
+byte LilliputScript::OC_compareCoords_2() {
+ warning("compareCoords_2");
+ return 0;
+}
+byte LilliputScript::OC_sub1757C() {
+ warning("OC_sub1757C");
+ return 0;
+}
+byte LilliputScript::OC_sub1759E() {
+ warning("OC_sub1759E");
+ return 0;
+}
+byte LilliputScript::OC_compWord16EF8() {
+ warning("OC_compWord16EF8");
+ return 0;
+}
+byte LilliputScript::OC_sub175C8() {
+ warning("OC_sub175C8");
+ return 0;
+}
+byte LilliputScript::OC_sub17640() {
+ warning("OC_sub17640");
+ return 0;
+}
+byte LilliputScript::OC_sub176C4() {
+ warning("OC_sub176C4");
+ return 0;
+}
+byte LilliputScript::OC_compWord10804() {
+ warning("OC_compWord10804");
+ return 0;
+}
+byte LilliputScript::OC_sub17766() {
+ warning("OC_sub17766");
+ return 0;
+}
+byte LilliputScript::OC_sub17782() {
+ warning("OC_sub17782");
+ return 0;
+}
+byte LilliputScript::OC_sub1779E() {
+ warning("OC_sub1779E");
+ return 0;
+}
+byte LilliputScript::OC_sub177C6() {
+ warning("OC_sub177C6");
+ return 0;
+}
+byte LilliputScript::OC_compWord16EFE() {
+ warning("OC_compWord16EFE");
+ return 0;
+}
+byte LilliputScript::OC_sub177F5() {
+ warning("OC_sub177F5");
+ return 0;
+}
+byte LilliputScript::OC_sub17812() {
+ warning("OC_sub17812");
+ return 0;
+}
+byte LilliputScript::OC_sub17825() {
+ warning("OC_sub17825");
+ return 0;
+}
+byte LilliputScript::OC_sub17844() {
+ warning("OC_sub17844");
+ return 0;
+}
+byte LilliputScript::OC_sub1785C() {
+ warning("OC_sub1785C");
+ return 0;
+}
+byte LilliputScript::OC_sub17886() {
+ warning("OC_sub17886");
+ return 0;
+}
+byte LilliputScript::OC_sub178A8() {
+ warning("OC_sub178A8");
+ return 0;
+}
+byte LilliputScript::OC_sub178BA() {
+ warning("OC_sub178BA");
+ return 0;
+}
+byte LilliputScript::OC_sub178C2() {
+ warning("OC_sub178C2");
+ return 0;
+}
+byte LilliputScript::OC_sub178D2() {
+ warning("OC_sub178D2");
+ return 0;
+}
+byte LilliputScript::OC_sub178E8() {
+ warning("OC_sub178E8");
+ return 0;
+}
+byte LilliputScript::OC_sub178FC() {
+ warning("OC_sub178FC");
+ return 0;
+}
+byte LilliputScript::OC_sub1790F() {
+ warning("OC_sub1790F");
+ return 0;
+}
+byte LilliputScript::OC_sub1792A() {
+ warning("OC_sub1792A");
+ return 0;
+}
+byte LilliputScript::OC_sub1793E() {
+ warning("OC_sub1793E");
+ return 0;
+}
+byte LilliputScript::OC_sub1795E() {
+ warning("OC_sub1795E");
+ return 0;
+}
+byte LilliputScript::OC_sub1796E() {
+ warning("OC_sub1796E");
+ return 0;
+}
+byte LilliputScript::OC_sub17984() {
+ warning("OC_sub17984");
+ return 0;
+}
+byte LilliputScript::OC_checkSavedMousePos() {
+ warning("OC_checkSavedMousePos");
+ return 0;
+}
+byte LilliputScript::OC_sub179AE() {
+ warning("OC_sub179AE");
+ return 0;
+}
+byte LilliputScript::OC_sub179C2() {
+ warning("OC_sub179C2");
+ return 0;
+}
+byte LilliputScript::OC_sub179E5() {
+ warning("OC_sub179E5");
+ return 0;
+}
+byte LilliputScript::OC_sub17A07() {
+ warning("OC_sub17A07");
+ return 0;
+}
+byte LilliputScript::OC_sub17757() {
+ warning("OC_sub17757");
+ return 0;
+}
+
+void LilliputScript::OC_setWord18821() {
+ warning("OC_setWord18821");
+}
+void LilliputScript::OC_sub17A3E() {
+ warning("OC_sub17A3E");
+}
+void LilliputScript::OC_sub17D57() {
+ warning("OC_sub17D57");
+}
+void LilliputScript::OC_sub17D7F() {
+ warning("OC_sub17D7F");
+}
+void LilliputScript::OC_sub17DB9() {
+ warning("OC_sub17DB9");
+}
+void LilliputScript::OC_sub17DF9() {
+ warning("OC_sub17DF9");
+}
+void LilliputScript::OC_sub17E07() {
+ warning("OC_sub17E07");
+}
+void LilliputScript::OC_sub17E15() {
+ warning("OC_sub17E15");
+}
+void LilliputScript::OC_sub17B03() {
+ warning("OC_sub17B03");
+}
+void LilliputScript::OC_getRandom_type2() {
+ warning("OC_getRandom_type2");
+}
+void LilliputScript::OC_sub17A66() {
+ warning("OC_sub17A66");
+}
+void LilliputScript::OC_sub17A8D() {
+ warning("OC_sub17A8D");
+}
+void LilliputScript::OC_saveAndQuit() {
+ warning("OC_saveAndQuit");
+}
+void LilliputScript::OC_sub17B93() {
+ warning("OC_sub17B93");
+}
+void LilliputScript::OC_sub17E37() {
+ warning("OC_sub17E37");
+}
+void LilliputScript::OC_resetByte1714E() {
+ warning("OC_resetByte1714E");
+}
+void LilliputScript::OC_deleteSavegameAndQuit() {
+ warning("OC_deleteSavegameAndQuit");
+}
+void LilliputScript::OC_incByte16F04() {
+ warning("OC_incByte16F04");
+}
+void LilliputScript::OC_sub17BA5() {
+ warning("OC_sub17BA5");
+}
+void LilliputScript::OC_setByte18823() {
+ warning("OC_setByte18823");
+}
+void LilliputScript::OC_sub17BB7() {
+ warning("OC_sub17BB7");
+}
+void LilliputScript::OC_sub17BF2() {
+ warning("OC_sub17BF2");
+}
+void LilliputScript::OC_sub17ACC() {
+ warning("OC_sub17ACC");
+}
+void LilliputScript::OC_resetByte16F04() {
+ warning("OC_resetByte16F04");
+}
+void LilliputScript::OC_sub17AE1() {
+ warning("OC_sub17AE1");
+}
+void LilliputScript::OC_sub17AEE() {
+ warning("OC_sub17AEE");
+}
+void LilliputScript::OC_setWord10804() {
+ warning("OC_setWord10804");
+}
+void LilliputScript::OC_sub17C0E() {
+ warning("OC_sub17C0E");
+}
+void LilliputScript::OC_sub17C55() {
+ warning("OC_sub17C55");
+}
+void LilliputScript::OC_sub17C76() {
+ warning("OC_sub17C76");
+}
+void LilliputScript::OC_sub17AFC() {
+ warning("OC_sub17AFC");
+}
+void LilliputScript::OC_sub17C8B() {
+ warning("OC_sub17C8B");
+}
+void LilliputScript::OC_sub17CA2() {
+ warning("OC_sub17CA2");
+}
+void LilliputScript::OC_sub17CB9() {
+ warning("OC_sub17CB9");
+}
+void LilliputScript::OC_sub17CD1() {
+ warning("OC_sub17CD1");
+}
+void LilliputScript::OC_resetWord16EFE() {
+ warning("OC_resetWord16EFE");
+}
+void LilliputScript::OC_sub17CEF() {
+ warning("OC_sub17CEF");
+}
+void LilliputScript::OC_sub17D1B() {
+ warning("OC_sub17D1B");
+}
+void LilliputScript::OC_sub17D23() {
+ warning("OC_sub17D23");
+}
+void LilliputScript::OC_sub17E6D() {
+ warning("OC_sub17E6D");
+}
+void LilliputScript::OC_sub17E7E() {
+ warning("OC_sub17E7E");
+}
+void LilliputScript::OC_sub17E99() {
+ warning("OC_sub17E99");
+}
+void LilliputScript::OC_sub17EC5() {
+ warning("OC_sub17EC5");
+}
+void LilliputScript::OC_sub17EF4() {
+ warning("OC_sub17EF4");
+}
+void LilliputScript::OC_sub17F08() {
+ warning("OC_sub17F08");
+}
+void LilliputScript::OC_sub17F4F() {
+ warning("OC_sub17F4F");
+}
+void LilliputScript::OC_sub17F68() {
+ warning("OC_sub17F68");
+}
+void LilliputScript::OC_getNextVal() {
+ warning("OC_getNextVal");
+}
+void LilliputScript::OC_sub17FD2() {
+ warning("OC_sub17FD2");
+}
+void LilliputScript::OC_sub17FDD() {
+ warning("OC_sub17FDD");
+}
+void LilliputScript::OC_setByte10B29() {
+ warning("OC_setByte10B29");
+}
+void LilliputScript::OC_sub18007() {
+ warning("OC_sub18007");
+}
+void LilliputScript::OC_sub18014() {
+ warning("OC_sub18014");
+}
+void LilliputScript::OC_sub1801D() {
+ warning("OC_sub1801D");
+}
+void LilliputScript::OC_sub1805D() {
+ warning("OC_sub1805D");
+}
+void LilliputScript::OC_sub18074() {
+ warning("OC_sub18074");
+}
+void LilliputScript::OC_sub1808B() {
+ warning("OC_sub1808B");
+}
+void LilliputScript::OC_sub18099() {
+ warning("OC_sub18099");
+}
+void LilliputScript::OC_sub180C3() {
+ warning("OC_sub180C3");
+}
+void LilliputScript::OC_sub1810A() {
+ warning("OC_sub1810A");
+}
+void LilliputScript::OC_sub1812D() {
+ warning("OC_sub1812D");
+}
+void LilliputScript::OC_sub1817F() {
+ warning("OC_sub1817F");
+}
+void LilliputScript::OC_sub181BB() {
+ warning("OC_sub181BB");
+}
+void LilliputScript::OC_sub18213() {
+ warning("OC_sub18213");
+}
+void LilliputScript::OC_sub18252() {
+ warning("OC_sub18252");
+}
+void LilliputScript::OC_sub18260() {
+ warning("OC_sub18260");
+}
+void LilliputScript::OC_sub182EC() {
+ warning("OC_sub182EC");
+}
+void LilliputScript::OC_unkPaletteFunction_1() {
+ warning("OC_unkPaletteFunction_1");
+}
+void LilliputScript::OC_unkPaletteFunction_2() {
+ warning("OC_unkPaletteFunction_2");
+}
+void LilliputScript::OC_loadAndDisplayCUBESx_GFX() {
+ warning("OC_loadAndDisplayCUBESx_GFX");
+}
+void LilliputScript::OC_sub1834C() {
+ warning("OC_sub1834C");
+}
+void LilliputScript::OC_sub18359() {
+ warning("OC_sub18359");
+}
+void LilliputScript::OC_sub18367() {
+ warning("OC_sub18367");
+}
+void LilliputScript::OC_sub17D04() {
+ warning("OC_sub17D04");
+}
+void LilliputScript::OC_sub18387() {
+ warning("OC_sub18387");
+}
+void LilliputScript::OC_setByte14835() {
+ warning("OC_setByte14835");
+}
+void LilliputScript::OC_setByte14837() {
+ warning("OC_setByte14837");
+}
+void LilliputScript::OC_sub183A2() {
+ warning("OC_sub183A2");
+}
+void LilliputScript::OC_sub183C6() {
+ warning("OC_sub183C6");
+}
+void LilliputScript::OC_loadFile_AERIAL_GFX() {
+ warning("OC_loadFile_AERIAL_GFX");
+}
+void LilliputScript::OC_sub17E22() {
+ warning("OC_sub17E22");
+}
+void LilliputScript::OC_sub1844A() {
+ warning("OC_sub1844A");
+}
+void LilliputScript::OC_sub1847F() {
+ warning("OC_sub1847F");
+}
+void LilliputScript::OC_sub184AA() {
+ warning("OC_sub184AA");
+}
+void LilliputScript::OC_sub184D7() {
+ warning("OC_sub184D7");
+}
+void LilliputScript::OC_sub184F5() {
+ warning("OC_sub184F5");
+}
+void LilliputScript::OC_sub1853B() {
+ warning("OC_sub1853B");
+}
+void LilliputScript::OC_sub1864D() {
+ warning("OC_sub1864D");
+}
+void LilliputScript::OC_sub18608() {
+ warning("OC_sub18608");
+}
+void LilliputScript::OC_sub18678() {
+ warning("OC_sub18678");
+}
+void LilliputScript::OC_sub18690() {
+ warning("OC_sub18690");
+}
+void LilliputScript::OC_setWord10802() {
+ warning("OC_setWord10802");
+}
+void LilliputScript::OC_sub186A1() {
+ warning("OC_sub186A1");
+}
+void LilliputScript::OC_sub186E5_snd() {
+ warning("OC_sub186E5_snd");
+}
+void LilliputScript::OC_sub1870A_snd() {
+ warning("OC_sub1870A_snd");
+}
+void LilliputScript::OC_sub18725_snd() {
+ warning("OC_sub18725_snd");
+}
+void LilliputScript::OC_sub18733_snd() {
+ warning("OC_sub18733_snd");
+}
+void LilliputScript::OC_sub1873F_snd() {
+ warning("OC_sub1873F_snd");
+}
+void LilliputScript::OC_sub18746_snd() {
+ warning("OC_sub18746_snd");
+}
+void LilliputScript::OC_sub1875D_snd() {
+ warning("OC_sub1875D_snd");
+}
+void LilliputScript::OC_sub18764() {
+ warning("OC_sub18764");
+}
+} // End of namespace
diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h
new file mode 100644
index 0000000000..4ad9919e59
--- /dev/null
+++ b/engines/lilliput/script.h
@@ -0,0 +1,205 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef LILLIPUT_SCRIPT_H
+#define LILLIPUT_SCRIPT_H
+
+#include "common/memstream.h"
+
+namespace Lilliput {
+
+class LilliputEngine;
+class LilliputScript {
+public:
+ LilliputScript(LilliputEngine *vm);
+ ~LilliputScript();
+
+ void runScript(Common::MemoryReadStream script);
+private:
+ LilliputEngine *_vm;
+
+ byte _byte16F05_ScriptHandler;
+
+ int handleOpcode(Common::MemoryReadStream script);
+ byte handleOpcodeType1(int curWord);
+ void handleOpcodeType2(int curWord);
+
+ //Opcodes Type 1
+ byte OC_sub173DF();
+ byte OC_sub173F0();
+ byte OC_sub1740A();
+ byte OC_sub17434();
+ byte OC_sub17468();
+ byte OC_getRandom();
+ byte OC_sub1748C();
+ byte OC_compWord18776();
+ byte OC_checkSaveFlag();
+ byte OC_sub174C8();
+ byte OC_sub174D8();
+ byte OC_sub1750E();
+ byte OC_compareCoords_1();
+ byte OC_compareCoords_2();
+ byte OC_sub1757C();
+ byte OC_sub1759E();
+ byte OC_compWord16EF8();
+ byte OC_sub175C8();
+ byte OC_sub17640();
+ byte OC_sub176C4();
+ byte OC_compWord10804();
+ byte OC_sub17766();
+ byte OC_sub17782();
+ byte OC_sub1779E();
+ byte OC_sub177C6();
+ byte OC_compWord16EFE();
+ byte OC_sub177F5();
+ byte OC_sub17812();
+ byte OC_sub17825();
+ byte OC_sub17844();
+ byte OC_sub1785C();
+ byte OC_sub17886();
+ byte OC_sub178A8();
+ byte OC_sub178BA();
+ byte OC_sub178C2();
+ byte OC_sub178D2();
+ byte OC_sub178E8();
+ byte OC_sub178FC();
+ byte OC_sub1790F();
+ byte OC_sub1792A();
+ byte OC_sub1793E();
+ byte OC_sub1795E();
+ byte OC_sub1796E();
+ byte OC_sub17984();
+ byte OC_checkSavedMousePos();
+ byte OC_sub179AE();
+ byte OC_sub179C2();
+ byte OC_sub179E5();
+ byte OC_sub17A07();
+ byte OC_sub17757();
+
+ // Opcodes Type 2
+ void OC_setWord18821();
+ void OC_sub17A3E();
+ void OC_sub17D57();
+ void OC_sub17D7F();
+ void OC_sub17DB9();
+ void OC_sub17DF9();
+ void OC_sub17E07();
+ void OC_sub17E15();
+ void OC_sub17B03();
+ void OC_getRandom_type2();
+ void OC_sub17A66();
+ void OC_sub17A8D();
+ void OC_saveAndQuit();
+ void OC_sub17B93();
+ void OC_sub17E37();
+ void OC_resetByte1714E();
+ void OC_deleteSavegameAndQuit();
+ void OC_incByte16F04();
+ void OC_sub17BA5();
+ void OC_setByte18823();
+ void OC_sub17BB7();
+ void OC_sub17BF2();
+ void OC_sub17ACC();
+ void OC_resetByte16F04();
+ void OC_sub17AE1();
+ void OC_sub17AEE();
+ void OC_setWord10804();
+ void OC_sub17C0E();
+ void OC_sub17C55();
+ void OC_sub17C76();
+ void OC_sub17AFC();
+ void OC_sub17C8B();
+ void OC_sub17CA2();
+ void OC_sub17CB9();
+ void OC_sub17CD1();
+ void OC_resetWord16EFE();
+ void OC_sub17CEF();
+ void OC_sub17D1B();
+ void OC_sub17D23();
+ void OC_sub17E6D();
+ void OC_sub17E7E();
+ void OC_sub17E99();
+ void OC_sub17EC5();
+ void OC_sub17EF4();
+ void OC_sub17F08();
+ void OC_sub17F4F();
+ void OC_sub17F68();
+ void OC_getNextVal();
+ void OC_sub17FD2();
+ void OC_sub17FDD();
+ void OC_setByte10B29();
+ void OC_sub18007();
+ void OC_sub18014();
+ void OC_sub1801D();
+ void OC_sub1805D();
+ void OC_sub18074();
+ void OC_sub1808B();
+ void OC_sub18099();
+ void OC_sub180C3();
+ void OC_sub1810A();
+ void OC_sub1812D();
+ void OC_sub1817F();
+ void OC_sub181BB();
+ void OC_sub18213();
+ void OC_sub18252();
+ void OC_sub18260();
+ void OC_sub182EC();
+ void OC_unkPaletteFunction_1();
+ void OC_unkPaletteFunction_2();
+ void OC_loadAndDisplayCUBESx_GFX();
+ void OC_sub1834C();
+ void OC_sub18359();
+ void OC_sub18367();
+ void OC_sub17D04();
+ void OC_sub18387();
+ void OC_setByte14835();
+ void OC_setByte14837();
+ void OC_sub183A2();
+ void OC_sub183C6();
+ void OC_loadFile_AERIAL_GFX();
+ void OC_sub17E22();
+ void OC_sub1844A();
+ void OC_sub1847F();
+ void OC_sub184AA();
+ void OC_sub184D7();
+ void OC_sub184F5();
+ void OC_sub1853B();
+ void OC_sub1864D();
+ void OC_sub18608();
+ void OC_sub18678();
+ void OC_sub18690();
+ void OC_setWord10802();
+ void OC_sub186A1();
+ void OC_sub186E5_snd();
+ void OC_sub1870A_snd();
+ void OC_sub18725_snd();
+ void OC_sub18733_snd();
+ void OC_sub1873F_snd();
+ void OC_sub18746_snd();
+ void OC_sub1875D_snd();
+ void OC_sub18764();
+};
+
+} // End of namespace Lilliput
+
+#endif
+