From 69af4ce9f4dff2631c794da140f24466460288a8 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 4 Oct 2009 19:49:47 +0000 Subject: SCI/newgui: implemented kPalette / set intensity svn-id: r44631 --- engines/sci/engine/kgraphics.cpp | 27 ++++++++++----------------- engines/sci/gui/gui.cpp | 7 +++++++ engines/sci/gui/gui.h | 1 + engines/sci/gui/gui_gfx.cpp | 4 ++++ engines/sci/gui/gui_gfx.h | 1 + engines/sci/gui32/gui32.cpp | 6 ++++++ engines/sci/gui32/gui32.h | 3 ++- 7 files changed, 31 insertions(+), 18 deletions(-) diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 64896d7d92..b97d312e5d 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -1099,25 +1099,18 @@ reg_t kPalette(EngineState *s, int argc, reg_t *argv) { case 3: debug(5, "STUB: kPalette() effect 3, clear flag to colors"); break; - case 4: { // Set palette intensity -#if 0 - // Colors 0 (black) and 255 (white) cannot be changed - int16 from = CLIP(1, 255, argv[2].toUint16()); - int16 to = CLIP(1, 255, argv[3].toUint16()); - int16 intensity = argv[4].toUint16(); - - if (argc < 5 || argv[5].toUint16() == 0) { - s->gfx_state->gfxResMan->setPaletteIntensity(from, to, intensity); - } else { - warning("kPalette: argv[5] != 0"); + case 4: { // Set palette intensity + if (argc >= 4) { + int fromColor = CLIP(1, 255, argv[1].toUint16()); + int toColor = CLIP(1, 255, argv[2].toUint16()); + int intensity = argv[3].toUint16(); + bool setPalette = (argc < 5) ? true : (argv[5].isNull()) ? true : false; + + s->gui->paletteSetIntensity(fromColor, toColor, intensity, setPalette); } - - return s->r_acc; -#endif - debug(5, "STUB: kPalette() effect 4, set color intensity"); break; - } - case 5: { // Find closest color + } + case 5: { // Find closest color int r = argv[1].toUint16(); int g = argv[2].toUint16(); int b = argv[3].toUint16(); diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index e50af6a155..af10df59b6 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -312,6 +312,13 @@ int16 SciGUI::paletteFind(int r, int g, int b) { return _gfx->MatchColor(&_gfx->_sysPalette, r, g, b) & 0xFF; } +void SciGUI::paletteSetIntensity(int fromColor, int toColor, int intensity, bool setPalette) { + _gfx->PaletteSetIntensity(fromColor, toColor, intensity, &_gfx->_sysPalette); + if (setPalette) { + _gfx->SetCLUT(&_gfx->_sysPalette); + } +} + void SciGUI::paletteAnimate(int fromColor, int toColor, int speed) { _gfx->PaletteAnimate(fromColor, toColor, speed); } diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h index 59050b8e4a..f88df8b11e 100644 --- a/engines/sci/gui/gui.h +++ b/engines/sci/gui/gui.h @@ -72,6 +72,7 @@ public: virtual void paletteSet(int resourceNo, int flags); virtual int16 paletteFind(int r, int g, int b); + virtual void paletteSetIntensity(int fromColor, int toColor, int intensity, bool setPalette); virtual void paletteAnimate(int fromColor, int toColor, int speed); virtual int16 onControl(byte screenMask, Common::Rect rect); diff --git a/engines/sci/gui/gui_gfx.cpp b/engines/sci/gui/gui_gfx.cpp index 6644517c0c..a1a8df786a 100644 --- a/engines/sci/gui/gui_gfx.cpp +++ b/engines/sci/gui/gui_gfx.cpp @@ -1224,6 +1224,10 @@ void SciGUIgfx::drawCell(GUIResourceId viewId, GUIViewLoopNo loopNo, GUIViewCell } } +void SciGUIgfx::PaletteSetIntensity(int fromColor, int toColor, int intensity, GUIPalette *destPalette) { + memset(destPalette->intensity + fromColor, intensity, toColor - fromColor); +} + void SciGUIgfx::PaletteAnimate(byte fromColor, byte toColor, int speed) { GUIColor col; int len = toColor - fromColor - 1; diff --git a/engines/sci/gui/gui_gfx.h b/engines/sci/gui/gui_gfx.h index cd9a12358f..3d02ee017f 100644 --- a/engines/sci/gui/gui_gfx.h +++ b/engines/sci/gui/gui_gfx.h @@ -110,6 +110,7 @@ public: void drawPicture(GUIResourceId pictureId, uint16 style, bool addToFlag, GUIResourceId paletteId); void drawCell(GUIResourceId viewId, GUIViewLoopNo loopNo, GUIViewCellNo cellNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo); + void PaletteSetIntensity(int fromColor, int toColor, int intensity, GUIPalette *destPalette); void PaletteAnimate(byte fromColor, byte toColor, int speed); int16 onControl(uint16 screenMask, Common::Rect rect); diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp index 36c0ec2600..c1c317a41f 100644 --- a/engines/sci/gui32/gui32.cpp +++ b/engines/sci/gui32/gui32.cpp @@ -708,6 +708,12 @@ int16 SciGUI32::paletteFind(int r, int g, int b) { return bestindex; } +void SciGUI32::paletteSetIntensity(int fromColor, int toColor, int intensity, bool setPalette) { +#if 0 + s->gfx_state->gfxResMan->setPaletteIntensity(fromColor, toColor, intensity); +#endif +} + void SciGUI32::paletteAnimate(int fromColor, int toColor, int speed) { warning("STUB"); } diff --git a/engines/sci/gui32/gui32.h b/engines/sci/gui32/gui32.h index c760bff1a9..0670c9afa9 100644 --- a/engines/sci/gui32/gui32.h +++ b/engines/sci/gui32/gui32.h @@ -64,7 +64,8 @@ public: void graphRestoreBox(reg_t handle); void paletteSet(int resourceNo, int flags); - virtual int16 paletteFind(int r, int g, int b); + int16 paletteFind(int r, int g, int b); + void paletteSetIntensity(int fromColor, int toColor, int intensity, bool setPalette); void paletteAnimate(int fromColor, int toColor, int speed); int16 onControl(byte screenMask, Common::Rect rect); -- cgit v1.2.3