aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2012-04-29 10:04:15 +0200
committerEugene Sandulenko2018-03-28 17:36:57 +0200
commit974c223a43bb490ee7602ee1cfbd36d3e11b13a8 (patch)
treed9ede51cada9a9a28734c8241601feb6ebf7c285 /engines
parentdd8131652822c78d9ce62b63a7ce00c8d5ef455f (diff)
downloadscummvm-rg350-974c223a43bb490ee7602ee1cfbd36d3e11b13a8.tar.gz
scummvm-rg350-974c223a43bb490ee7602ee1cfbd36d3e11b13a8.tar.bz2
scummvm-rg350-974c223a43bb490ee7602ee1cfbd36d3e11b13a8.zip
LILLIPUT: Split palette functions, implement some core functions
Diffstat (limited to 'engines')
-rw-r--r--engines/lilliput/lilliput.cpp106
-rw-r--r--engines/lilliput/lilliput.h7
-rw-r--r--engines/lilliput/script.cpp40
-rw-r--r--engines/lilliput/script.h4
4 files changed, 117 insertions, 40 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp
index 50b19c299a..834eeb787a 100644
--- a/engines/lilliput/lilliput.cpp
+++ b/engines/lilliput/lilliput.cpp
@@ -125,6 +125,7 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_savedMousePosDivided = 0xFFFF;
_skipDisplayFlag1 = 1;
_skipDisplayFlag2 = 0;
+ _displayMap = 0;
_scriptHandler = new LilliputScript(this);
_soundHandler = new LilliputSound(this);
@@ -450,7 +451,7 @@ void LilliputEngine::displayFunction7() {
void LilliputEngine::displayFunction8() {
debugC(2, kDebugEngine, "displayFunction8()");
- if (_scriptHandler->displayMap == 1)
+ if (_displayMap == 1)
return;
displayFunction5();
@@ -617,7 +618,7 @@ void LilliputEngine::displayFunction13(byte *buf, int var1, int var2, int var3)
void LilliputEngine::displayFunction14() {
debugC(2, kDebugEngine, "displayFunction14()");
- if (_scriptHandler->displayMap == 1)
+ if (_displayMap == 1)
return;
if (_mouseDisplayX > 48)
@@ -778,8 +779,12 @@ void LilliputEngine::displayFunction15() {
void LilliputEngine::displayFunction16() {
debugC(2, kDebugEngine, "displayFunction16()");
- if (_scriptHandler->displayMap == 1) {
- warning("sub_15F31");
+ if (_displayMap == 1) {
+ bool forceReturnFl = false;
+ sub15F31(forceReturnFl);
+ if (forceReturnFl)
+ return;
+
restoreMapPoints();
sub16626();
sub12F37();
@@ -803,8 +808,46 @@ void LilliputEngine::displayFunction16() {
}
}
-int LilliputEngine::sub16DD5(int x1, int y1, int x2, int y2)
-{
+void LilliputEngine::sub1863B() {
+ _arr18560[0]._field0 = 0;
+ _arr18560[1]._field0 = 0;
+ _arr18560[2]._field0 = 0;
+ _arr18560[3]._field0 = 0;
+ _scriptHandler->_word1855E = 0;
+}
+
+void LilliputEngine::paletteFadeOut() {
+ debugC(2, kDebugEngine, "paletteFadeOut()");
+
+ sub1863B();
+ byte palette[768];
+ for (int fade = 256; fade >= 0; fade -= 8) {
+ for (int i = 0; i < 768; i++) {
+ palette[i] = (_curPalette[i] * fade) >> 8;
+ }
+ _system->getPaletteManager()->setPalette(palette, 0, 256);
+ _system->updateScreen();
+ _system->delayMillis(20);
+ }
+}
+
+void LilliputEngine::paletteFadeIn() {
+ debugC(2, kDebugEngine, "paletteFadeIn()");
+
+ byte palette[768];
+ for (int fade = 8; fade <= 256; fade += 8) {
+ for (int i = 0; i < 768; i++) {
+ palette[i] = (_curPalette[i] * fade) >> 8;
+ }
+ _system->getPaletteManager()->setPalette(palette, 0, 256);
+ _system->updateScreen();
+ _system->delayMillis(20);
+ }
+}
+
+int LilliputEngine::sub16DD5(int x1, int y1, int x2, int y2) {
+ debugC(2, kDebugEngine, "sub16DD5(%d, %d, %d, %d)", x1, y1, x2, y2);
+
byte *isoMap = _bufferIsoMap + (x1 << 8) + (y1 << 2) + 1;
int dx = x2 - x1;
@@ -868,6 +911,57 @@ int LilliputEngine::sub16DD5(int x1, int y1, int x2, int y2)
return 1;
}
+void LilliputEngine::sub15F75() {
+ debugC(2, kDebugEngine, "sub15F75()");
+
+ _byte129A0 = 0xFF;
+ _savedMousePosDivided = 0xFFFF;
+ byte newX = _mouseX >> 2;
+ byte newY = _mouseY / 3;
+
+ if ((newX >= 64) || (newY >= 64))
+ return;
+
+ _savedMousePosDivided = (newX << 8) + newY;
+ _byte16F07_menuId = 5;
+}
+
+void LilliputEngine::sub130B6() {
+ debugC(2, kDebugEngine, "sub130B6()");
+
+ for (int index = 0; index < _word12F68_ERULES; index++) {
+ if (_scriptHandler->_array122E9[index] == 3)
+ _scriptHandler->_array122E9[index] = 2;
+ }
+}
+
+void LilliputEngine::sub15F31(bool &forceReturnFl) {
+ debugC(2, kDebugEngine, "sub15F31()");
+
+ forceReturnFl = false;
+ if (_displayMap != 1)
+ return;
+
+ pollEvent();
+ warning("sub15F31- TODO: Check keyboard");
+
+ if ((_mouseButton & 1) == 0)
+ return;
+
+ _mouseButton = 0;
+ sub15F75();
+
+ _displayMap = 0;
+ paletteFadeOut();
+ _word15AC2 = 0;
+ sub130B6();
+ displayFunction12();
+ _scriptHandler->_heroismLevel = 0;
+ sub16217();
+ paletteFadeIn();
+ forceReturnFl = true;
+}
+
void LilliputEngine::sub16CA0() {
debugC(2, kDebugEngine, "sub16CA0()");
diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h
index 756cc11604..e9b46953d0 100644
--- a/engines/lilliput/lilliput.h
+++ b/engines/lilliput/lilliput.h
@@ -123,6 +123,7 @@ public:
bool _saveFlag;
bool _int8installed;
+ byte _displayMap;
int _word10800_ERULES;
int _numCharacters;
@@ -232,6 +233,11 @@ public:
void displayFunction18(int index, int x, int y, int flags);
void displayString(byte *buf, int var2, int var4);
void displayChar(int index, int var1);
+ void sub130B6();
+ void sub15F75();
+ void sub1863B();
+ void paletteFadeOut();
+ void paletteFadeIn();
void sortCharacters();
void scrollToViewportCharacterTarget();
@@ -265,6 +271,7 @@ public:
void sub1546F(byte displayX, byte displayY);
void sub15498(byte x, byte y, int var2);
void sub15A4C(int &vgaIndex, byte *srcBuf, int &bufIndex);
+ void sub15F31(bool &forceReturnFl);
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 9bcc8adf67..6b576930da 100644
--- a/engines/lilliput/script.cpp
+++ b/engines/lilliput/script.cpp
@@ -30,7 +30,6 @@ namespace Lilliput {
LilliputScript::LilliputScript(LilliputEngine *vm) : _vm(vm), _currScript(NULL) {
_byte129A0 = 0xFF;
- displayMap = 0;
_byte1855D = 0;
_byte12A04 = 0;
_byte10806 = 0;
@@ -764,14 +763,6 @@ void LilliputScript::runMenuScript(ScriptStream script) {
_vm->update();
}
-void LilliputScript::sub1863B() {
- _vm->_arr18560[0]._field0 = 0;
- _vm->_arr18560[1]._field0 = 0;
- _vm->_arr18560[2]._field0 = 0;
- _vm->_arr18560[3]._field0 = 0;
- _word1855E = 0;
-}
-
void LilliputScript::sub185ED(byte index, byte subIndex) {
debugC(2, kDebugScript, "sub185ED");
if (_vm->_arr18560[index]._field0 != 1)
@@ -929,7 +920,7 @@ void LilliputScript::sub17D40(bool &forceReturnFl) {
debugC(1, kDebugScript, "sub17D40()");
forceReturnFl = false;
- if ((displayMap != 1) && (_vm->_characterRelativePositionX[_vm->_rulesBuffer2PrevIndx] != 0xFF))
+ if ((_vm->_displayMap != 1) && (_vm->_characterRelativePositionX[_vm->_rulesBuffer2PrevIndx] != 0xFF))
return;
forceReturnFl = true;
@@ -2472,30 +2463,17 @@ void LilliputScript::OC_sub182EC() {
void LilliputScript::OC_PaletteFadeOut() {
debugC(1, kDebugScript, "OC_PaletteFadeOut()");
- sub1863B();
- byte palette[768];
- for (int fade = 256; fade >= 0; fade -= 8) {
- for (int i = 0; i < 768; i++) {
- palette[i] = (_vm->_curPalette[i] * fade) >> 8;
- }
- _vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
- _vm->_system->updateScreen();
- _vm->_system->delayMillis(20);
- }
+ _byte12A09 = 1;
+ _vm->paletteFadeOut();
+ _byte12A09 = 0;
}
void LilliputScript::OC_PaletteFadeIn() {
debugC(1, kDebugScript, "OC_PaletteFadeIn()");
- byte palette[768];
- for (int fade = 8; fade <= 256; fade += 8) {
- for (int i = 0; i < 768; i++) {
- palette[i] = (_vm->_curPalette[i] * fade) >> 8;
- }
- _vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
- _vm->_system->updateScreen();
- _vm->_system->delayMillis(20);
- }
+ _byte12A09 = 1;
+ _vm->paletteFadeIn();
+ _byte12A09 = 0;
}
void LilliputScript::OC_loadAndDisplayCUBESx_GFX() {
@@ -2594,7 +2572,7 @@ void LilliputScript::OC_sub1847F() {
int var2 = _currScript->readUint16LE();
int var4 = _currScript->readUint16LE();
- if (displayMap != 1) {
+ if (_vm->_displayMap != 1) {
_vm->displayFunction5();
sub18BE6(var1 & 0xFF, var2, var4);
_vm->displayFunction4();
@@ -2667,7 +2645,7 @@ void LilliputScript::OC_sub1853B() {
debugC(1, kDebugScript, "OC_sub1853B()");
OC_PaletteFadeOut();
- displayMap = 0;
+ _vm->_displayMap = 0;
_heroismLevel = 0;
sub130B6();
diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h
index 8356f92b1d..9cd0899be2 100644
--- a/engines/lilliput/script.h
+++ b/engines/lilliput/script.h
@@ -35,7 +35,6 @@ class LilliputEngine;
class LilliputScript {
public:
- byte displayMap;
byte _byte12A04;
byte _heroismLevel;
@@ -57,6 +56,7 @@ public:
int _word1881B;
int _heroismBarX;
int _heroismBarBottomY;
+ int _word1855E;
short _array12311[640];
byte _array128EF[40];
@@ -92,14 +92,12 @@ private:
int _word16F00;
int _word10804;
- int _word1855E;
int _word18776;
int handleOpcode(ScriptStream *script);
byte handleOpcodeType1(int curWord);
void handleOpcodeType2(int curWord);
- void sub1863B();
void sub185ED(byte index, byte subIndex);
void sub185B4_display();
void sub1823E(byte var1, byte var2, byte *curBufPtr);