aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/engine/kgraphics.cpp36
-rw-r--r--engines/sci/gui/gui.cpp8
-rw-r--r--engines/sci/gui/gui.h2
-rw-r--r--engines/sci/gui/gui_palette.cpp16
-rw-r--r--engines/sci/gui/gui_palette.h4
-rw-r--r--engines/sci/gui32/gui32.cpp6
-rw-r--r--engines/sci/gui32/gui32.h2
7 files changed, 55 insertions, 19 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index af84cbbbcf..dc4cb3079e 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -567,18 +567,26 @@ reg_t kPalette(EngineState *s, int argc, reg_t *argv) {
s->_gui->paletteSet(resourceId, flags);
}
break;
- case 2: // Set flag to colors
- warning("kPalette(2), set flag to colors");
+ case 2: { // Set palette-flag(s)
+ uint16 fromColor = CLIP<uint16>(argv[1].toUint16(), 1, 255);
+ uint16 toColor = CLIP<uint16>(argv[2].toUint16(), 1, 255);
+ uint16 flags = argv[3].toUint16();
+ s->_gui->paletteSetFlag(fromColor, toColor, flags);
break;
- case 3: // Clear flag to colors
- warning("kPalette(3), clear flag to colors");
+ }
+ case 3: { // Remove palette-flag(s)
+ uint16 fromColor = CLIP<uint16>(argv[1].toUint16(), 1, 255);
+ uint16 toColor = CLIP<uint16>(argv[2].toUint16(), 1, 255);
+ uint16 flags = argv[3].toUint16();
+ s->_gui->paletteUnsetFlag(fromColor, toColor, flags);
break;
+ }
case 4: { // Set palette intensity
switch (argc) {
case 4:
case 5: {
- uint16 fromColor = CLIP<int>(argv[1].toUint16(), 1, 255);
- uint16 toColor = CLIP<int>(argv[2].toUint16(), 1, 255);
+ uint16 fromColor = CLIP<uint16>(argv[1].toUint16(), 1, 255);
+ uint16 toColor = CLIP<uint16>(argv[2].toUint16(), 1, 255);
uint16 intensity = argv[3].toUint16();
bool setPalette = (argc < 5) ? true : (argv[4].isNull()) ? true : false;
@@ -598,18 +606,12 @@ reg_t kPalette(EngineState *s, int argc, reg_t *argv) {
return make_reg(0, s->_gui->paletteFind(r, g, b));
}
case 6: { // Animate
- switch (argc) {
- case 4: {
- uint16 fromColor = argv[1].toUint16();
- uint16 toColor = argv[2].toUint16();
- int16 speed = argv[3].toSint16();
+ int16 argNr;
+ for (argNr = 1; argNr < argc; argNr += 3) {
+ uint16 fromColor = argv[argNr].toUint16();
+ uint16 toColor = argv[argNr + 1].toUint16();
+ int16 speed = argv[argNr + 2].toSint16();
s->_gui->paletteAnimate(fromColor, toColor, speed);
- break;
- }
- case 22:
-
- default:
- warning("kPalette(6) called with %d parameters", argc);
}
break;
}
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp
index c2e7a17f06..707c8af7c5 100644
--- a/engines/sci/gui/gui.cpp
+++ b/engines/sci/gui/gui.cpp
@@ -461,6 +461,14 @@ void SciGui::paletteSet(GuiResourceId resourceId, uint16 flags) {
_palette->setFromResource(resourceId, flags);
}
+void SciGui::paletteSetFlag(uint16 fromColor, uint16 toColor, uint16 flag) {
+ _palette->setFlag(fromColor, toColor, flag);
+}
+
+void SciGui::paletteUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag) {
+ _palette->unsetFlag(fromColor, toColor, flag);
+}
+
int16 SciGui::paletteFind(uint16 r, uint16 g, uint16 b) {
return _palette->matchColor(&_palette->_sysPalette, r, g, b) & 0xFF;
}
diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h
index ba6d8b7ff9..697ad539f7 100644
--- a/engines/sci/gui/gui.h
+++ b/engines/sci/gui/gui.h
@@ -101,6 +101,8 @@ public:
virtual int16 picNotValid(int16 newPicNotValid);
virtual void paletteSet(GuiResourceId resourceNo, uint16 flags);
+ virtual void paletteSetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
+ virtual void paletteUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
virtual int16 paletteFind(uint16 r, uint16 g, uint16 b);
virtual void paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette);
virtual void paletteAnimate(uint16 fromColor, uint16 toColor, int16 speed);
diff --git a/engines/sci/gui/gui_palette.cpp b/engines/sci/gui/gui_palette.cpp
index 83b94e2085..8f9558f7e5 100644
--- a/engines/sci/gui/gui_palette.cpp
+++ b/engines/sci/gui/gui_palette.cpp
@@ -269,7 +269,21 @@ void SciGuiPalette::setOnScreen() {
_screen->setPalette(&_sysPalette);
}
-void SciGuiPalette::setIntensity(int fromColor, int toColor, int intensity, bool setPalette) {
+void SciGuiPalette::setFlag(uint16 fromColor, uint16 toColor, uint16 flag) {
+ uint16 colorNr;
+ for (colorNr = fromColor; colorNr < toColor; colorNr++) {
+ _sysPalette.colors[colorNr].used |= flag;
+ }
+}
+
+void SciGuiPalette::unsetFlag(uint16 fromColor, uint16 toColor, uint16 flag) {
+ uint16 colorNr;
+ for (colorNr = fromColor; colorNr < toColor; colorNr++) {
+ _sysPalette.colors[colorNr].used &= ~flag;
+ }
+}
+
+void SciGuiPalette::setIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette) {
memset(&_sysPalette.intensity[0] + fromColor, intensity, toColor - fromColor);
if (setPalette)
setOnScreen();
diff --git a/engines/sci/gui/gui_palette.h b/engines/sci/gui/gui_palette.h
index 9313d7e169..ea63f7fe0f 100644
--- a/engines/sci/gui/gui_palette.h
+++ b/engines/sci/gui/gui_palette.h
@@ -47,7 +47,9 @@ public:
void setOnScreen();
- void setIntensity(int fromColor, int toColor, int intensity, bool setPalette);
+ void setFlag(uint16 fromColor, uint16 toColor, uint16 flag);
+ void unsetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
+ void setIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette);
void animate(byte fromColor, byte toColor, int speed);
GuiPalette _sysPalette;
diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp
index a5a7987d8b..cc590dc4b9 100644
--- a/engines/sci/gui32/gui32.cpp
+++ b/engines/sci/gui32/gui32.cpp
@@ -1346,6 +1346,12 @@ void SciGui32::paletteSet(GuiResourceId resourceNo, uint16 flags) {
//warning("STUB");
}
+void SciGui32::paletteSetFlag(uint16 fromColor, uint16 toColor, uint16 flag) {
+}
+
+void SciGui32::paletteUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag) {
+}
+
int16 SciGui32::paletteFind(uint16 r, uint16 g, uint16 b) {
int i, delta, bestindex = -1, bestdelta = 200000;
diff --git a/engines/sci/gui32/gui32.h b/engines/sci/gui32/gui32.h
index 3f7d12e80c..99ab6df889 100644
--- a/engines/sci/gui32/gui32.h
+++ b/engines/sci/gui32/gui32.h
@@ -79,6 +79,8 @@ public:
int16 picNotValid(int16 newPicNotValid);
void paletteSet(GuiResourceId resourceNo, uint16 flags);
+ void paletteSetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
+ void paletteUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
int16 paletteFind(uint16 r, uint16 g, uint16 b);
void paletteSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity);
void paletteAnimate(uint16 fromColor, uint16 toColor, uint16 speed);