aboutsummaryrefslogtreecommitdiff
path: root/scumm/gfx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scumm/gfx.cpp')
-rw-r--r--scumm/gfx.cpp148
1 files changed, 147 insertions, 1 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp
index cda2598c70..7866c2dfd8 100644
--- a/scumm/gfx.cpp
+++ b/scumm/gfx.cpp
@@ -2370,6 +2370,88 @@ void Scumm::setCameraAtEx(int at)
}
}
+void Scumm::palManipulateInit(int start, int end, int d, int time, int e)
+{
+ // TODO - correctly implement this function (see also bug #558245)
+ //
+ // There are two known places (both in FOA) where this function is being
+ // called. The fist is during the FOA extro, to change the color to match
+ // the sinking sun. The following three calls (with some pauses between them)
+ // are issued:
+ //
+ // palManipulateInit(16, 190, 32, 180, 1)
+ // palManipulateInit(16, 190, 32, 1, 1)
+ // palManipulateInit(16, 190, 32, 800, 1)
+ //
+ // The second place is in the Inner Sanctum after you used the stone discs,
+ // here it is used to give the scene a "lava glow".
+ //
+ // palManipulateInit(32, 65, 46, 20, 1): not implemented!
+ //
+ // The first two parameters seem to specify a palette range (as the colors
+ // from 16 to 190 are the ones that make up water & sky).
+ //
+ // Maybe the change has to be done over a period of time, possibly specified
+ // by the second last parameter - between call 1 and 2, about 17-18 seconds
+ // seem to pass (well using get_msecs, I measured 17155 ms, 17613 ms, 17815 ms).
+ //
+ // No clue about the third and fifth parameter right now, they just always
+ // are 32 and 1 - possibly finding another example of this function being
+ // used would help a lot. Also, I can't currently compare it with the original,
+ // doing that (and possibly, taking screenshots of it for analysis!) would
+ // help a lot.
+
+ warning("palManipulateInit(%d, %d, %d, %d, %d): not implemented", start, end, d, time, e);
+
+ // FIXME - is this right?
+ // It seems we already have had this "palManipulate" and "moveMemInPalRes"
+ // functions, only they were never used (somebody disassembled them and
+ // didn't disassmble the functions using them?).
+ //
+ // I
+ _palManipStart = start;
+ _palManipEnd = end;
+ //_palManipCounter = ?
+
+ {
+ int redScale = 0xFF;
+ int greenScale = 0xFF - d;
+ int blueScale = 0xFF - d;
+ byte *cptr;
+ byte *cur;
+ int num;
+ int color;
+
+ cptr = _currentPalette + start * 3;
+ cur = _currentPalette + start * 3;
+ num = end - start + 1;
+
+ do {
+ color = *cptr++;
+ if (redScale != 0xFF)
+ color = color * redScale / 0xFF;
+ if (color > 255)
+ color = 255;
+ *cur++ = color;
+
+ color = *cptr++;
+ if (greenScale != 0xFF)
+ color = color * greenScale / 0xFF;
+ if (color > 255)
+ color = 255;
+ *cur++ = color;
+
+ color = *cptr++;
+ if (blueScale != 0xFF)
+ color = color * blueScale / 0xFF;
+ if (color > 255)
+ color = 255;
+ *cur++ = color;
+ } while (--num);
+ setDirtyColors(start, end);
+ }
+}
+
void Scumm::palManipulate()
{
byte *srcptr, *destptr;
@@ -2378,8 +2460,12 @@ void Scumm::palManipulate()
if (!_palManipCounter)
return;
+
srcptr = getResourceAddress(rtTemp, 4) + _palManipStart * 6;
destptr = getResourceAddress(rtTemp, 5) + _palManipStart * 6;
+ if (!srcptr || !destptr)
+ return;
+
pal = _currentPalette + _palManipStart * 3;
i = _palManipStart;
@@ -2402,12 +2488,72 @@ void Scumm::palManipulate()
i++;
}
setDirtyColors(_palManipStart, _palManipEnd);
- if (!--_palManipCounter) {
+ _palManipCounter--;
+ if (!_palManipCounter) {
nukeResource(rtTemp, 4);
nukeResource(rtTemp, 5);
}
}
+void Scumm::unkRoomFunc3(int unk1, int unk2, int rfact, int gfact, int bfact)
+{
+ byte *pal = _currentPalette;
+ byte *table = _shadowPalette;
+ int i;
+
+ warning("unkRoomFunc3(%d,%d,%d,%d,%d): not fully implemented", unk1, unk2, rfact, gfact, bfact);
+
+ // TODO - correctly implement this function (see also patch #588501)
+ //
+ // Some "typical" examples of how this function is being invoked in real life:
+ //
+ // 1)
+ // unkRoomFunc3(16, 255, 200, 200, 200)
+ //
+ // FOA: Sets up the colors for the boat and submarine shadows in the
+ // diving scene. Are the shadows too light? Maybe unk1 is used to
+ // darken the colors?
+ //
+ // 2)
+ // unkRoomFunc3(0, 255, 700, 700, 700)
+ //
+ // FOA: Sets up the colors for the subway car headlight when it first
+ // goes on. This seems to work ok.
+ //
+ // 3)
+ // unkRoomFunc3(160, 191, 300, 300, 300)
+ // unkRoomFunc3(160, 191, 289, 289, 289)
+ // ...
+ // unkRoomFunc3(160, 191, 14, 14, 14)
+ // unkRoomFunc3(160, 191, 3, 3, 3)
+ //
+ // 4)
+ // FOA: Sets up the colors for the subway car headlight for the later
+ // half of the trip, where it fades out. This currently doesn't work
+ // at all. The colors are too dark to be brightened. At first I thought
+ // unk1 and unk2 were used to tell which color interval to manipulate,
+ // but as far as I can tell the colors 160-191 aren't used at all to
+ // draw the light, that can't be it. Apparently unk1 and/or unk2 are
+ // used to brighten the colors.
+ //
+ // 5)
+ // unkRoomFunc3(16,255,500,500,500)
+ //
+ // FOA: Used in the Inner Sanctum after you activated the machine using the
+ // stone discs (briefly before the Nazis arrive). No idea at all if it is
+ // right here; also note that palManipulateInit() is called at the same time.
+ //
+ //
+
+ for (i = 0; i <= 255; i++) {
+ int r = (int) (*pal++ * rfact) >> 8;
+ int g = (int) (*pal++ * gfact) >> 8;
+ int b = (int) (*pal++ * bfact) >> 8;
+
+ *table++ = remapPaletteColor(r, g, b, (uint) -1);
+ }
+}
+
void Scumm::swapPalColors(int a, int b)
{
byte *ap, *bp;