aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2012-04-07 14:36:04 +0200
committerEugene Sandulenko2018-03-28 17:36:57 +0200
commit7865322c0a7d006e76935155ac9ac904e8c39c55 (patch)
tree6484470248c06c84104e4384580e0b8564e9c460
parent53518bc6770e1b09211b8e2846f8655890f70a2b (diff)
downloadscummvm-rg350-7865322c0a7d006e76935155ac9ac904e8c39c55.tar.gz
scummvm-rg350-7865322c0a7d006e76935155ac9ac904e8c39c55.tar.bz2
scummvm-rg350-7865322c0a7d006e76935155ac9ac904e8c39c55.zip
LILLIPUT: Implement a couple of other opcodes, add proper debugc
-rw-r--r--engines/lilliput/lilliput.cpp17
-rw-r--r--engines/lilliput/lilliput.h18
-rw-r--r--engines/lilliput/script.cpp79
-rw-r--r--engines/lilliput/script.h2
4 files changed, 90 insertions, 26 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp
index 7192628978..cb3af63712 100644
--- a/engines/lilliput/lilliput.cpp
+++ b/engines/lilliput/lilliput.cpp
@@ -40,16 +40,8 @@ LilliputEngine *LilliputEngine::s_Engine = 0;
LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd) : Engine(syst), _gameDescription(gd)
{
_system = syst;
- DebugMan.addDebugChannel(kDebugSchedule, "Schedule", "Script Schedule debug level");
DebugMan.addDebugChannel(kDebugEngine, "Engine", "Engine debug level");
- DebugMan.addDebugChannel(kDebugDisplay, "Display", "Display debug level");
- DebugMan.addDebugChannel(kDebugMouse, "Mouse", "Mouse debug level");
- DebugMan.addDebugChannel(kDebugParser, "Parser", "Parser debug level");
- DebugMan.addDebugChannel(kDebugFile, "File", "File IO debug level");
- DebugMan.addDebugChannel(kDebugRoute, "Route", "Route debug level");
- DebugMan.addDebugChannel(kDebugInventory, "Inventory", "Inventory debug level");
- DebugMan.addDebugChannel(kDebugObject, "Object", "Object debug level");
- DebugMan.addDebugChannel(kDebugMusic, "Music", "Music debug level");
+ DebugMan.addDebugChannel(kDebugScript, "Script", "Script debug level");
_console = new LilliputConsole(this);
_rnd = 0;
@@ -57,6 +49,13 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_byte1714E = 0;
_rulesBuffer2PrevIndx = 0;
+ _word16EFA = 0;
+
+ for (int i = 0; i < 40; i++) {
+ _byte10999[i] = 0;
+ _byte109C1[i] = 0;
+ }
+
}
LilliputEngine::~LilliputEngine() {
diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h
index 23f5ae0b09..a908dd02c7 100644
--- a/engines/lilliput/lilliput.h
+++ b/engines/lilliput/lilliput.h
@@ -52,16 +52,8 @@ enum GameType {
};
enum LilliputDebugChannels {
- kDebugSchedule = 1 << 0,
- kDebugEngine = 1 << 1,
- kDebugDisplay = 1 << 2,
- kDebugMouse = 1 << 3,
- kDebugParser = 1 << 4,
- kDebugFile = 1 << 5,
- kDebugRoute = 1 << 6,
- kDebugInventory = 1 << 7,
- kDebugObject = 1 << 8,
- kDebugMusic = 1 << 9
+ kDebugEngine = 1 << 0,
+ kDebugScript = 1 << 1
};
struct LilliputGameDescription;
@@ -109,6 +101,7 @@ public:
int _word10807_ERULES;
int _word12D3D;
int _word12D3F;
+ int _word16EFA;
byte *_rulesChunk1;
int _rulesBuffer2PrevIndx;
@@ -152,7 +145,8 @@ public:
int _rulesBuffer13_2[20];
int _rulesBuffer13_3[20];
byte _rulesBuffer13_4[20];
-
+ byte _byte10999[40];
+ byte _byte109C1[40];
const LilliputGameDescription *_gameDescription;
uint32 getFeatures() const;
@@ -174,7 +168,7 @@ public:
// Temporary stubs
byte _mouse_byte1299A;
-
+ byte _mouse_savedMousePosDivided;
byte _keyboard_getch();
protected:
diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp
index f89ca7ae60..5c1bdcf2ff 100644
--- a/engines/lilliput/script.cpp
+++ b/engines/lilliput/script.cpp
@@ -22,6 +22,7 @@
#include "lilliput/lilliput.h"
#include "lilliput/script.h"
+#include "common/debug.h"
namespace Lilliput {
@@ -35,6 +36,7 @@ LilliputScript::~LilliputScript() {
}
byte LilliputScript::handleOpcodeType1(int curWord) {
+ debugC(2, kDebugScript, "handleOpcodeType1(0x%x)", curWord);
switch (curWord) {
case 0x0:
return OC_sub173DF();
@@ -193,6 +195,7 @@ byte LilliputScript::handleOpcodeType1(int curWord) {
}
void LilliputScript::handleOpcodeType2(int curWord) {
+ debugC(2, kDebugScript, "handleOpcodeType2(0x%x)", curWord);
switch (curWord) {
case 0x0:
OC_setWord18821();
@@ -507,6 +510,7 @@ void LilliputScript::handleOpcodeType2(int curWord) {
}
int LilliputScript::handleOpcode(Common::MemoryReadStream *script) {
+ debugC(2, kDebugScript, "handleOpcode");
_currScript = script;
uint16 curWord = _currScript->readUint16LE();
if (curWord == 0xFFF6)
@@ -539,6 +543,7 @@ int LilliputScript::handleOpcode(Common::MemoryReadStream *script) {
}
void LilliputScript::runScript(Common::MemoryReadStream script) {
+ debugC(1, kDebugScript, "runScript");
_byte16F05_ScriptHandler = 1;
while (handleOpcode(&script) != 0xFF)
@@ -546,7 +551,7 @@ void LilliputScript::runScript(Common::MemoryReadStream script) {
}
byte LilliputScript::compValues(byte var1, int oper, int var2) {
- warning("compValues - %d %c %d", var1, oper & 0xFF, var2);
+ debugC(1, kDebugScript, "compValues(%d, %c, %d)", var1, oper, var2);
switch (oper & 0xFF) {
case '<':
return (var1 < var2);
@@ -558,7 +563,49 @@ byte LilliputScript::compValues(byte var1, int oper, int var2) {
}
}
+int LilliputScript::getValue2() {
+ debugC(1, kDebugScript, "getValue2()");
+ int curWord = _currScript->readUint16LE();
+ int tmpVal = curWord >> 8;
+ switch(tmpVal) {
+ case 0xFF:
+ assert((_vm->_rulesBuffer2PrevIndx >= 0) && (_vm->_rulesBuffer2PrevIndx < 40));
+ return ((_vm->_rulesBuffer2_13[_vm->_rulesBuffer2PrevIndx] << 8) + _vm->_rulesBuffer2_14[_vm->_rulesBuffer2PrevIndx]);
+ case 0xFE: {
+ int index = curWord & 0xFF;
+ assert((index >= 0) && (index < 40));
+ return ((_vm->_rulesBuffer2_13[index] << 8) + _vm->_rulesBuffer2_14[index]);
+ }
+ case 0xFD:
+ return _vm->_word16EFA;
+ case 0xFC:
+ warning("TODO: getValue2 - 0xFC");
+ return 0;
+ case 0xFB:
+ warning("TODO: getValue2 - 0xFB");
+ return 0;
+ case 0xFA:
+ return ((_vm->_byte10999[_vm->_rulesBuffer2PrevIndx] << 8) + _vm->_byte109C1[_vm->_rulesBuffer2PrevIndx]);
+ case 0xF9:
+ return ((_vm->_rulesBuffer2_15[4] << 8) + _vm->_rulesBuffer2_15[5]);
+ case 0xF8: {
+ int index = curWord & 0xFF;
+ assert((index >= 0) && (index < 40));
+ return _vm->_rulesBuffer12_3[index];
+ }
+ case 0xF7:
+ warning("TODO: getValue2 - 0xF7");
+ return 0;
+ case 0xF6:
+ return _vm->_mouse_savedMousePosDivided;
+ default:
+ warning("getValue2 - 0x%x - Unexpected high value %d", tmpVal, curWord);
+ return curWord;
+ }
+}
+
int LilliputScript::getValue1() {
+ debugC(1, kDebugScript, "getValue1()");
int curWord = _currScript->readUint16LE();
if (curWord < 1000)
return curWord;
@@ -581,6 +628,7 @@ int LilliputScript::getValue1() {
}
byte *LilliputScript::getBuffer215Ptr() {
+ debugC(1, kDebugScript, "getBuffer215Ptr()");
int tmpVal = getValue1();
tmpVal *= 32;
tmpVal += _currScript->readUint16LE();
@@ -603,6 +651,8 @@ byte LilliputScript::OC_sub1740A() {
}
byte LilliputScript::OC_sub17434() {
+ debugC(1, kDebugScript, "OC_sub17434()");
+
byte *tmpArr = getBuffer215Ptr();
byte var1 = tmpArr[0];
uint16 oper = _currScript->readUint16LE();
@@ -1004,9 +1054,16 @@ void LilliputScript::OC_unkPaletteFunction_1() {
void LilliputScript::OC_unkPaletteFunction_2() {
warning("OC_unkPaletteFunction_2");
}
+
void LilliputScript::OC_loadAndDisplayCUBESx_GFX() {
- warning("OC_loadAndDisplayCUBESx_GFX");
+ debugC(1, kDebugScript, "OC_loadAndDisplayCUBESx_GFX()");
+
+ int curWord = _currScript->readUint16LE();
+ assert((curWord >= 0) && (curWord <= 9));
+ Common::String fileName = Common::String::format("CUBES%d.GFX", curWord);
+ warning("TODO: load %s then display things", fileName.c_str());
}
+
void LilliputScript::OC_sub1834C() {
warning("OC_sub1834C");
}
@@ -1047,6 +1104,8 @@ void LilliputScript::OC_sub1847F() {
warning("OC_sub1847F");
}
void LilliputScript::OC_displayVGAFile() {
+ debugC(1, kDebugScript, "OC_displayVGAFile()");
+
_byte12A09 = 1;
warning("TODO: unkPaletteFunction_1");
int curWord = _currScript->readUint16LE();
@@ -1060,6 +1119,8 @@ void LilliputScript::OC_sub184D7() {
warning("OC_sub184D7");
}
void LilliputScript::OC_sub184F5() {
+ debugC(1, kDebugScript, "OC_sub184F5()");
+
_vm->_byte184F4 = (_currScript->readUint16LE() & 0xFF);
_vm->_sound_byte16F06 = _vm->_byte184F4;
// TODO: use a separated function when properly identified
@@ -1098,7 +1159,8 @@ void LilliputScript::OC_sub1864D() {
warning("OC_sub1864D");
}
void LilliputScript::OC_initArr18560() {
- warning("OC_initArr18560");
+ debugC(1, kDebugScript, "OC_initArr18560()");
+
int curWord = _currScript->readUint16LE();
assert (curWord < 4);
_vm->_arr18560[curWord]._field0 = 1;
@@ -1122,9 +1184,15 @@ void LilliputScript::OC_sub186A1() {
void LilliputScript::OC_sub186E5_snd() {
warning("OC_sub186E5_snd");
}
+
void LilliputScript::OC_sub1870A_snd() {
- warning("OC_sub1870A_snd");
+ debugC(1, kDebugScript, "OC_sub1870A_snd()");
+
+ int tmpVal = getValue2();
+ int curWord = _currScript->readUint16LE();
+ warning("TODO: call sound function #2");
}
+
void LilliputScript::OC_sub18725_snd() {
warning("OC_sub18725_snd");
}
@@ -1135,7 +1203,8 @@ void LilliputScript::OC_sub1873F_snd() {
warning("OC_sub1873F_snd");
}
void LilliputScript::OC_sub18746_snd() {
- warning("OC_sub18746_snd");
+ debugC(1, kDebugScript, "OC_sub18746_snd()");
+
int curWord = _currScript->readUint16LE();
curWord = (2 << 8) + (curWord & 0xFF);
warning("TODO: ovlContentOVL Function 2, init DX and BX");
diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h
index 8a0793ec72..d5610ba1da 100644
--- a/engines/lilliput/script.h
+++ b/engines/lilliput/script.h
@@ -52,6 +52,8 @@ private:
void handleOpcodeType2(int curWord);
int getValue1();
+ int getValue2();
+
byte *getBuffer215Ptr();
byte compValues(byte var1, int oper, int var2);