aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/illusions/illusions_duckman.cpp2
-rw-r--r--engines/illusions/screen.cpp89
-rw-r--r--engines/illusions/screen.h3
-rw-r--r--engines/illusions/scriptopcodes_duckman.cpp17
-rw-r--r--engines/illusions/scriptopcodes_duckman.h2
-rw-r--r--engines/illusions/sequenceopcodes.cpp8
-rw-r--r--engines/illusions/sequenceopcodes.h1
7 files changed, 103 insertions, 19 deletions
diff --git a/engines/illusions/illusions_duckman.cpp b/engines/illusions/illusions_duckman.cpp
index e36cd354f6..135bd0b8c7 100644
--- a/engines/illusions/illusions_duckman.cpp
+++ b/engines/illusions/illusions_duckman.cpp
@@ -232,7 +232,7 @@ Common::Point IllusionsEngine_Duckman::getNamedPointPosition(uint32 namedPointId
}
} else {
// TODO
- //debug("getNamedPointPosition(%08X) UNKNOWN", namedPointId);
+ debug("getNamedPointPosition(%08X) UNKNOWN", namedPointId);
return Common::Point(0, 0);
}
}
diff --git a/engines/illusions/screen.cpp b/engines/illusions/screen.cpp
index 57989e738f..35e8b59271 100644
--- a/engines/illusions/screen.cpp
+++ b/engines/illusions/screen.cpp
@@ -312,7 +312,7 @@ void Screen::setPalette(byte *colors, uint start, uint count) {
*dstPal++ = *colors++;
++colors;
}
- // TODO Build colorTransTbl
+ buildColorTransTbl();
_needRefreshPalette = true;
}
@@ -334,6 +334,42 @@ void Screen::getPalette(byte *colors) {
}
}
+void Screen::shiftPalette(int16 fromIndex, int16 toIndex) {
+ //debug("shiftPalette(%d, %d)", fromIndex, toIndex);
+ byte r, g, b;
+ if (toIndex > fromIndex) {
+ r = _mainPalette[3 * toIndex + 0];
+ g = _mainPalette[3 * toIndex + 1];
+ b = _mainPalette[3 * toIndex + 2];
+ for (int16 i = toIndex; i > fromIndex; --i) {
+ byte *dst = &_mainPalette[3 * i];
+ byte *src = &_mainPalette[3 * (i - 1)];
+ dst[0] = src[0];
+ dst[1] = src[1];
+ dst[2] = src[2];
+ }
+ _mainPalette[3 * fromIndex + 0] = r;
+ _mainPalette[3 * fromIndex + 1] = g;
+ _mainPalette[3 * fromIndex + 2] = b;
+ } else {
+ r = _mainPalette[3 * toIndex + 0];
+ g = _mainPalette[3 * toIndex + 1];
+ b = _mainPalette[3 * toIndex + 2];
+ for (int16 i = toIndex + 1; i < fromIndex; +i) {
+ byte *dst = &_mainPalette[3 * i];
+ byte *src = &_mainPalette[3 * (i + 1)];
+ dst[0] = src[0];
+ dst[1] = src[1];
+ dst[2] = src[2];
+ }
+ _mainPalette[3 * fromIndex + 0] = r;
+ _mainPalette[3 * fromIndex + 1] = g;
+ _mainPalette[3 * fromIndex + 2] = b;
+ }
+ // TODO Refresh colorTransTbl
+ _needRefreshPalette = true;
+}
+
void Screen::updatePalette() {
if (_needRefreshPalette) {
// TODO Update fader palette
@@ -342,6 +378,30 @@ void Screen::updatePalette() {
}
}
+void Screen::buildColorTransTbl() {
+ const int cr = _mainPalette[3 * 1 + 0];
+ const int cg = _mainPalette[3 * 1 + 1];
+ const int cb = _mainPalette[3 * 1 + 2];
+ for (int index1 = 0; index1 < 256; ++index1) {
+ const int dr = (cr + _mainPalette[3 * index1 + 0]) / 2;
+ const int dg = (cg + _mainPalette[3 * index1 + 1]) / 2;
+ const int db = (cb + _mainPalette[3 * index1 + 2]) / 2;
+ int minDistance = 766;
+ int minIndex2 = 2;
+ for (int index2 = 2; index2 < 256; ++index2) {
+ int distance =
+ ABS(dr - _mainPalette[3 * index2 + 0]) +
+ ABS(dg - _mainPalette[3 * index2 + 1]) +
+ ABS(db - _mainPalette[3 * index2 + 2]);
+ if (distance < minDistance) {
+ minDistance = distance;
+ minIndex2 = index2;
+ }
+ }
+ _colorTransTbl[index1] = minIndex2;
+ }
+}
+
void Screen::drawText(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 *text, uint count) {
for (uint i = 0; i < count; ++i)
x += font->_widthC + drawChar(font, surface, x, y, *text++);
@@ -456,9 +516,13 @@ void Screen::drawSurface81(int16 destX, int16 destY, Graphics::Surface *surface,
byte *src = (byte*)surface->getBasePtr(srcRect.left, srcRect.top + yc);
byte *dst = (byte*)_backSurface->getBasePtr(destX, destY + yc);
for (int16 xc = 0; xc < w; ++xc) {
- byte pixel = *src++;
- if (pixel != 0)
- *dst = pixel;
+ const byte pixel = *src++;
+ if (pixel != 0) {
+ if (pixel == 1)
+ *dst = _colorTransTbl[*dst];
+ else
+ *dst = pixel;
+ }
++dst;
}
}
@@ -485,9 +549,12 @@ void Screen::drawSurface82(Common::Rect &dstRect, Graphics::Surface *surface, Co
byte *src = (byte*)surface->getBasePtr(srcRect.left, srcY);
byte *dstRow = dst;
while (w-- > 0) {
- byte pixel = *src;
+ const byte pixel = *src;
if (pixel != 0) {
- *dstRow = pixel;
+ if (pixel == 1)
+ *dstRow = _colorTransTbl[*dstRow];
+ else
+ *dstRow = pixel;
}
++dstRow;
src += errXStart;
@@ -498,9 +565,13 @@ void Screen::drawSurface82(Common::Rect &dstRect, Graphics::Surface *surface, Co
}
}
while (skipX-- > 0) {
- byte pixel = *src;
- if (pixel != 0)
- *dstRow = pixel;
+ const byte pixel = *src;
+ if (pixel != 0) {
+ if (pixel == 1)
+ *dstRow = _colorTransTbl[*dstRow];
+ else
+ *dstRow = pixel;
+ }
++src;
++dstRow;
}
diff --git a/engines/illusions/screen.h b/engines/illusions/screen.h
index 91750cfba5..bdecda48a5 100644
--- a/engines/illusions/screen.h
+++ b/engines/illusions/screen.h
@@ -114,6 +114,7 @@ public:
void setPalette(byte *colors, uint start, uint count);
void setPaletteEntry(int16 index, byte r, byte g, byte b);
void getPalette(byte *colors);
+ void shiftPalette(int16 fromIndex, int16 toIndex);
void updatePalette();
void drawText(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 *text, uint count);
int16 drawChar(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 c);
@@ -130,8 +131,10 @@ public:
bool _needRefreshPalette;
byte _mainPalette[768];
+ byte _colorTransTbl[256];
void setSystemPalette(byte *palette);
+ void buildColorTransTbl();
void decompressSprite8(SpriteDecompressQueueItem *item);
void drawSurface8(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect, int16 scale, uint32 flags);
diff --git a/engines/illusions/scriptopcodes_duckman.cpp b/engines/illusions/scriptopcodes_duckman.cpp
index 0312172c5f..b932037f00 100644
--- a/engines/illusions/scriptopcodes_duckman.cpp
+++ b/engines/illusions/scriptopcodes_duckman.cpp
@@ -71,6 +71,7 @@ void ScriptOpcodes_Duckman::initOpcodes() {
OPCODE(23, opExitModalScene);
OPCODE(24, opEnterScene24);
OPCODE(25, opLeaveScene24);
+ OPCODE(32, opPanCenterObject);
OPCODE(33, opPanTrackObject);
OPCODE(34, opPanToObject);
OPCODE(36, opPanToPoint);
@@ -133,7 +134,6 @@ void ScriptOpcodes_Duckman::initOpcodes() {
OPCODE(20, opEnterScene);
OPCODE(30, opEnterCloseUpScene);
OPCODE(31, opExitCloseUpScene);
- OPCODE(32, opPanCenterObject);
OPCODE(35, opPanToNamedPoint);
OPCODE(53, opSetActorToNamedPoint);
OPCODE(63, opSetSelectSfx);
@@ -252,7 +252,8 @@ void ScriptOpcodes_Duckman::opEnterScene18(ScriptThread *scriptThread, OpCall &o
//static uint dsceneId = 0x0001002D, dthreadId = 0x00020141;
//static uint dsceneId = 0x0001004B, dthreadId = 0x0002029B;
//static uint dsceneId = 0x00010021, dthreadId = 0x00020113;
-static uint dsceneId = 0x0001000A, dthreadId = 0x00020043;
+//static uint dsceneId = 0x0001000A, dthreadId = 0x00020043;//Home front
+static uint dsceneId = 0x0001000E, dthreadId = 0x0002007C;
void ScriptOpcodes_Duckman::opChangeScene(ScriptThread *scriptThread, OpCall &opCall) {
ARG_SKIP(2);
@@ -315,6 +316,12 @@ void ScriptOpcodes_Duckman::opLeaveScene24(ScriptThread *scriptThread, OpCall &o
_vm->leavePause(_vm->getCurrentScene(), opCall._callerThreadId);
}
+void ScriptOpcodes_Duckman::opPanCenterObject(ScriptThread *scriptThread, OpCall &opCall) {
+ ARG_INT16(speed);
+ ARG_UINT32(objectId);
+ _vm->_camera->panCenterObject(objectId, speed);
+}
+
void ScriptOpcodes_Duckman::opPanTrackObject(ScriptThread *scriptThread, OpCall &opCall) {
ARG_SKIP(2);
ARG_UINT32(objectId);
@@ -787,12 +794,6 @@ void ScriptOpcodes_Duckman::opExitCloseUpScene(ScriptThread *scriptThread, OpCal
opCall._result = kTSYield;
}
-void ScriptOpcodes_Duckman::opPanCenterObject(ScriptThread *scriptThread, OpCall &opCall) {
- ARG_INT16(speed);
- ARG_UINT32(objectId);
- _vm->_camera->panCenterObject(objectId, speed);
-}
-
void ScriptOpcodes_Duckman::opPanToNamedPoint(ScriptThread *scriptThread, OpCall &opCall) {
ARG_INT16(speed);
ARG_UINT32(namedPointId);
diff --git a/engines/illusions/scriptopcodes_duckman.h b/engines/illusions/scriptopcodes_duckman.h
index be093c488a..4c66d346d9 100644
--- a/engines/illusions/scriptopcodes_duckman.h
+++ b/engines/illusions/scriptopcodes_duckman.h
@@ -58,6 +58,7 @@ protected:
void opExitModalScene(ScriptThread *scriptThread, OpCall &opCall);
void opEnterScene24(ScriptThread *scriptThread, OpCall &opCall);
void opLeaveScene24(ScriptThread *scriptThread, OpCall &opCall);
+ void opPanCenterObject(ScriptThread *scriptThread, OpCall &opCall);
void opPanTrackObject(ScriptThread *scriptThread, OpCall &opCall);
void opPanToObject(ScriptThread *scriptThread, OpCall &opCall);
void opPanToPoint(ScriptThread *scriptThread, OpCall &opCall);
@@ -120,7 +121,6 @@ protected:
void opEnterScene(ScriptThread *scriptThread, OpCall &opCall);
void opEnterCloseUpScene(ScriptThread *scriptThread, OpCall &opCall);
void opExitCloseUpScene(ScriptThread *scriptThread, OpCall &opCall);
- void opPanCenterObject(ScriptThread *scriptThread, OpCall &opCall);
void opPanToNamedPoint(ScriptThread *scriptThread, OpCall &opCall);
void opSetActorToNamedPoint(ScriptThread *scriptThread, OpCall &opCall);
void opSetSelectSfx(ScriptThread *scriptThread, OpCall &opCall);
diff --git a/engines/illusions/sequenceopcodes.cpp b/engines/illusions/sequenceopcodes.cpp
index 868a565170..92b4e128d6 100644
--- a/engines/illusions/sequenceopcodes.cpp
+++ b/engines/illusions/sequenceopcodes.cpp
@@ -25,6 +25,7 @@
#include "illusions/actor.h"
#include "illusions/actorresource.h"
#include "illusions/dictionary.h"
+#include "illusions/screen.h"
#include "illusions/scriptman.h"
#include "illusions/scriptopcodes.h"
@@ -88,6 +89,7 @@ void SequenceOpcodes::initOpcodes() {
OPCODE(40, opSetPriorityLayer);
OPCODE(41, opDisableAutoRegionLayer);
OPCODE(42, opSetRegionLayer);
+ OPCODE(49, opShiftPalette);
OPCODE(50, opPlaySound);
OPCODE(51, opStopSound);
OPCODE(52, opStartScriptThread);
@@ -335,6 +337,12 @@ void SequenceOpcodes::opSetRegionLayer(Control *control, OpCall &opCall) {
control->_actor->_regionLayer = bgRes->getRegionLayer(regionLayerIndex - 1);
}
+void SequenceOpcodes::opShiftPalette(Control *control, OpCall &opCall) {
+ ARG_INT16(fromIndex);
+ ARG_INT16(toIndex);
+ _vm->_screen->shiftPalette(fromIndex, toIndex);
+}
+
void SequenceOpcodes::opPlaySound(Control *control, OpCall &opCall) {
ARG_INT16(flags);
ARG_INT16(volume);
diff --git a/engines/illusions/sequenceopcodes.h b/engines/illusions/sequenceopcodes.h
index f423d07b10..384507e0fa 100644
--- a/engines/illusions/sequenceopcodes.h
+++ b/engines/illusions/sequenceopcodes.h
@@ -77,6 +77,7 @@ protected:
void opSetPriorityLayer(Control *control, OpCall &opCall);
void opDisableAutoRegionLayer(Control *control, OpCall &opCall);
void opSetRegionLayer(Control *control, OpCall &opCall);
+ void opShiftPalette(Control *control, OpCall &opCall);
void opPlaySound(Control *control, OpCall &opCall);
void opStopSound(Control *control, OpCall &opCall);
void opStartScriptThread(Control *control, OpCall &opCall);