aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2012-04-19 08:03:19 +0200
committerEugene Sandulenko2018-03-28 17:36:57 +0200
commit4fd850776872ad2715f054f3e3cc24684e499297 (patch)
treef2afbf6eade0c57a16b88d24e76f4d85f46c6991 /engines
parenteeb69f46bcdbb088fb63c06647683fbebdaec9dc (diff)
downloadscummvm-rg350-4fd850776872ad2715f054f3e3cc24684e499297.tar.gz
scummvm-rg350-4fd850776872ad2715f054f3e3cc24684e499297.tar.bz2
scummvm-rg350-4fd850776872ad2715f054f3e3cc24684e499297.zip
LILLIPUT: Start implementing engine update (int 8 replacement in the original)
The screen now moves to the point expected in intro
Diffstat (limited to 'engines')
-rw-r--r--engines/lilliput/lilliput.cpp158
-rw-r--r--engines/lilliput/lilliput.h16
-rw-r--r--engines/lilliput/script.cpp6
-rw-r--r--engines/lilliput/script.h2
4 files changed, 176 insertions, 6 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp
index bf899eae71..986b6c7055 100644
--- a/engines/lilliput/lilliput.cpp
+++ b/engines/lilliput/lilliput.cpp
@@ -112,6 +112,7 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_console = new LilliputConsole(this);
_rnd = 0;
+ _int8installed = false;
_mouseX = 0;
_mouseY = 0;
_oldMouseX = 0;
@@ -131,6 +132,12 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_byte160FA = 0;
_byte16529 = 0;
_byte1652A = 0;
+ _byte12A04 = 0;
+ _byte12A05 = 10;
+ _byte12A06 = 2;
+ _byte12A07 = 0;
+ _byte12A08 = 0;
+ _byte12A09 = 0;
_rulesBuffer2PrevIndx = 0;
_word16EFA = 0;
@@ -196,6 +203,42 @@ GUI::Debugger *LilliputEngine::getDebugger() {
return _console;
}
+void LilliputEngine::update() {
+ newInt8();
+ pollEvent();
+}
+
+void LilliputEngine::newInt8() {
+ if (!_int8installed)
+ return;
+
+ if (_byte12A06 == 0) {
+ _byte12A06 = 2;
+ _byte12A07 ^= 1;
+ }
+ --_byte12A06;
+ // TODO: check 'out 20h, 20h'
+
+ // if (_soundEnabled)
+ warning("TODO: call sound function #1");
+
+ if (_byte12A08 != 1) {
+ _byte12A08 = 1;
+ if (_byte12A05 != 0)
+ --_byte12A05;
+ else {
+ _byte12A05 = 10;
+ if (_sound_byte16F06 != 0)
+ --_sound_byte16F06;
+
+ _byte12A04 ^= 1;
+ if (_byte12A09 != 1)
+ displayFunction16();
+ }
+ _byte12A08 = 0;
+ }
+}
+
bool LilliputEngine::hasFeature(EngineFeature f) const {
return (f == kSupportsRTL) || (f == kSupportsLoadingDuringRuntime) || (f == kSupportsSavingDuringRuntime);
}
@@ -285,6 +328,7 @@ void LilliputEngine::displayFunction2(byte *buf, int var2, int var4) {
}
}
+// Fill 16x16 rect
void LilliputEngine::displayFunction3(int var1, int var2, int var4) {
debugC(2, kDebugEngine, "displayFunction3(%d, %d, %d)", var1, var2, var4);
@@ -399,6 +443,7 @@ void LilliputEngine::displayFunction9() {
}
+// Display dialog bubble
void LilliputEngine::displayFunction10() {
debugC(2, kDebugEngine, "displayFunction10()");
static const byte _array15976[16] = {244, 248, 250, 250, 252, 252, 252, 252, 252, 252, 252, 252, 250, 250, 248, 244};
@@ -412,7 +457,8 @@ void LilliputEngine::displayFunction10() {
for (int i = 0; i < 16; i++) {
var3 = _array15976[i];
tmpIndex = index - (var3 / 2);
- for (int j = 0; j < 16; j++) {
+ var3 &= 0xFE;
+ for (int j = 0; j < var3; j++) {
((byte *)_mainSurface->getPixels())[tmpIndex + j] = 17;
}
index += 320;
@@ -593,6 +639,113 @@ void LilliputEngine::displayFunction15() {
}
}
+void LilliputEngine::displayFunction16() {
+ debugC(2, kDebugEngine, "displayFunction16()");
+
+ if (_scriptHandler->_byte16F08 == 1) {
+ warning("sub_15F31");
+ warning("sub_15F0C");
+ warning("sub_16626");
+ warning("sub_12F37");
+ warning("sub_16CA0");
+ warning("sub_16EBC");
+ warning("sub_171CF");
+ warning("sub_15EAE");
+ } else {
+ sub1638C();
+ warning("sub_189DE");
+ displayFunction15();
+ displayFunction14();
+ warning("sub_16626");
+ warning("sub_12F37");
+ warning("sub_16CA0");
+ warning("sub_16EBC");
+ warning("sub_171CF");
+ warning("sub_130EE");
+ warning("sub_12FE5");
+ warning("sub_15FFF");
+ }
+}
+
+// Move "window" to x/y
+void LilliputEngine::sub1638C() {
+ debugC(2, kDebugEngine, "sub1638C()");
+
+ if (_scriptHandler->_word10802 == 0xFFFF)
+ return;
+
+ int var2 = (_rulesBuffer2_1[_scriptHandler->_word10802] >> 3) - _scriptHandler->_word12A00;
+ int var4 = (_rulesBuffer2_2[_scriptHandler->_word10802] >> 3) - _scriptHandler->_word12A02;
+ int var1 = _scriptHandler->_word12A00;
+
+ if (var2 >= 1) {
+ if (var2 >= 6) {
+ var1 += 4;
+ if (var1 > 56)
+ var1 = 56;
+ }
+ } else {
+ var1 -= 4;
+ if (var1 < 0)
+ var1 = 0;
+ }
+
+ int var3 = _scriptHandler->_word12A02;
+ if (var4 >= 1) {
+ if (var4 > 6) {
+ var3 += 4;
+ if (var3 >= 56)
+ var3 = 56;
+ }
+ } else {
+ var3 -= 4;
+ if (var3 < 0)
+ var3 = 0;
+ }
+
+ sub163F0(var1, var3);
+}
+
+void LilliputEngine::sub163F0(int var1, int var3) {
+ debugC(2, kDebugEngine, "sub163F0(%d, %d)", var1, var3);
+
+ if ((var1 == _scriptHandler->_word12A00) && (var3 = _scriptHandler->_word12A02))
+ return;
+
+ int var2 = 0;
+ if (var1 != _scriptHandler->_word12A00) {
+ if (var1 < _scriptHandler->_word12A00)
+ --var2;
+ else
+ ++var2;
+ }
+
+ int var4 = 0;
+ if (var3!= _scriptHandler->_word12A02) {
+ if (var3 < _scriptHandler->_word12A02)
+ --var4;
+ else
+ ++var4;
+ }
+
+ do {
+ _scriptHandler->_word12A00 += var2;
+ _scriptHandler->_word12A02 += var4;
+
+ displayFunction9();
+ displayFunction15();
+ displayFunction14();
+
+ if (var1 == _scriptHandler->_word12A00)
+ var2 = 0;
+
+ if (var3 == _scriptHandler->_word12A02)
+ var4 = 0;
+ } while ((var2 != 0) && (var4 !=0));
+
+ warning("Sound function #5");
+}
+
void LilliputEngine::pollEvent() {
debugC(2, kDebugEngine, "pollEvent()");
@@ -1002,10 +1155,13 @@ Common::Error LilliputEngine::run() {
//TODO: Init sound/music player
_scriptHandler->runScript(Common::MemoryReadStream(_initScript, _initScript_size));
+ _int8installed = true;
+
while(!_shouldQuit) {
handleMenu();
handleGameScripts();
// To be removed when handled in the previous fonctions
+ update();
pollEvent();
}
diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h
index 11784393e6..c1d8f55b1b 100644
--- a/engines/lilliput/lilliput.h
+++ b/engines/lilliput/lilliput.h
@@ -90,6 +90,12 @@ public:
byte _byte16F09;
byte _keyboard_nextIndex;
byte _keyboard_oldIndex;
+ byte _byte12A04;
+ byte _byte12A05;
+ byte _byte12A06;
+ byte _byte12A07;
+ byte _byte12A08;
+ byte _byte12A09;
byte _buffer1[45056];
byte _buffer2[45056];
@@ -104,7 +110,8 @@ public:
byte _curPalette[768];
bool _saveFlag;
-
+ bool _int8installed;
+
int _word10800_ERULES;
int _word10807_ERULES;
int _word16EFA;
@@ -179,6 +186,9 @@ public:
uint32 getFeatures() const;
const char *getGameId() const;
+ void newInt8();
+ void update();
+
void displayFunction1(byte *buf, int var1, int var2, int var4);
void displayFunction1a(byte *buf, int var2, int var4);
void displayFunction2(byte *buf, int var2, int var4);
@@ -194,6 +204,10 @@ public:
void displayFunction13(byte *buf, int var1, int var2, int var3);
void displayFunction14();
void displayFunction15();
+ void displayFunction16();
+
+ void sub1638C();
+ void sub163F0(int var1, int var3);
void initGame(const LilliputGameDescription *gd);
byte *loadVGA(Common::String filename, bool loadPal);
diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp
index c9e7607867..4aab2f6b4b 100644
--- a/engines/lilliput/script.cpp
+++ b/engines/lilliput/script.cpp
@@ -585,7 +585,7 @@ void LilliputScript::runScript(Common::MemoryReadStream script) {
_byte16F05_ScriptHandler = 1;
while (handleOpcode(&script) != 0xFF)
- ;
+ _vm->update();
}
void LilliputScript::runMenuScript(Common::MemoryReadStream script) {
@@ -594,7 +594,7 @@ void LilliputScript::runMenuScript(Common::MemoryReadStream script) {
_byte16F05_ScriptHandler = 0;
while (handleOpcode(&script) == 0)
- ;
+ _vm->update();
}
void LilliputScript::sub185ED(byte index, byte subIndex) {
@@ -1789,7 +1789,7 @@ void LilliputScript::OC_displayTitleScreen() {
for (;;) {
sub185B4_display();
- _vm->pollEvent();
+ _vm->update();
if (_vm->_keyboard_nextIndex != _vm->_keyboard_oldIndex) {
_vm->_byte16F09 = _vm->_keyboard_getch();
_vm->_keyboard_getch();
diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h
index 2d605f3fa4..6113fd8808 100644
--- a/engines/lilliput/script.h
+++ b/engines/lilliput/script.h
@@ -42,6 +42,7 @@ public:
int _word12A00;
int _word12A02;
+ int _word10802;
byte _byte12A04;
LilliputScript(LilliputEngine *vm);
@@ -76,7 +77,6 @@ private:
int _word1881B;
int _word16F00;
- int _word10802;
int _word10804;
int _word15FFB;
int _word15FFD;