From a03119c5f5c51203a7ca0c7ca84d928b47ae8aa6 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 11 Aug 2007 08:05:03 +0000 Subject: Changed OSystem (A)RGBToColor and colorTo(A)RGB methods to use ColorMasks templates; clarified some OSystem comments svn-id: r28517 --- common/system.cpp | 21 +++++++++++++++++++-- common/system.h | 44 +++++++++++++++++--------------------------- 2 files changed, 36 insertions(+), 29 deletions(-) (limited to 'common') diff --git a/common/system.cpp b/common/system.cpp index f8068d41f5..a1bdb4cdcc 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -28,13 +28,13 @@ #include "backends/intern.h" #include "backends/events/default/default-events.h" -#include "gui/message.h" - #include "common/config-manager.h" #include "common/system.h" #include "common/timer.h" #include "common/util.h" +#include "graphics/colormasks.h" +#include "gui/message.h" #include "sound/mixer.h" OSystem *g_system = 0; @@ -66,6 +66,23 @@ bool OSystem::setGraphicsMode(const char *name) { return false; } +OverlayColor OSystem::RGBToColor(uint8 r, uint8 g, uint8 b) { + return ::RGBToColor >(r, g, b); +} + +void OSystem::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { + ::colorToRGB >(color, r, g, b); +} + +OverlayColor OSystem::ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b) { + return RGBToColor(r, g, b); +} + +void OSystem::colorToARGB(OverlayColor color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) { + colorToRGB(color, r, g, b); + a = 255; +} + void OSystem::displayMessageOnOSD(const char *msg) { // Display the message for 1.5 seconds GUI::TimedMessageDialog dialog(msg, 1500); diff --git a/common/system.h b/common/system.h index 79680c4655..a1df855449 100644 --- a/common/system.h +++ b/common/system.h @@ -495,17 +495,16 @@ public: virtual void updateScreen() = 0; /** - * Set current shake position, a feature needed for some SCUMM screen effects. - * The effect causes the displayed graphics to be shifted upwards by the specified - * (always positive) offset. The area at the bottom of the screen which is moved - * into view by this is filled by black. This does not cause any graphic data to - * be lost - that is, to restore the original view, the game engine only has to - * call this method again with a 0 offset. No calls to copyRectToScreen are necessary. + * Set current shake position, a feature needed for some SCUMM screen + * effects. The effect causes the displayed graphics to be shifted upwards + * by the specified (always positive) offset. The area at the bottom of the + * screen which is moved into view by this is filled with black. This does + * not cause any graphic data to be lost - that is, to restore the original + * view, the game engine only has to call this method again with offset + * equal to zero. No calls to copyRectToScreen are necessary. * @param shakeOffset the shake offset * - * @todo This is a rather special screen effect, only used by the SCUMM - * frontend - we should consider removing it from the backend API - * and instead implement the functionality in the frontend. + * @note This is currently used in the SCUMM, QUEEN and KYRA engines. */ virtual void setShakePos(int shakeOffset) = 0; @@ -549,8 +548,10 @@ public: * 8bpp), this needs some trickery. * * Essentially, we fake (alpha) blending on these systems by copying the - * game graphics into the overlay buffer, then manually compose whatever - * graphics we want to show in the overlay. + * current game graphics into the overlay buffer when activating the overlay, + * then manually compose whatever graphics we want to show in the overlay. + * This works because we assume the game to be "paused" whenever an overlay + * is active. */ //@{ @@ -607,9 +608,7 @@ public: * @see colorToRGB * @see ARGBToColor */ - virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b) { - return ((((r >> 3) & 0x1F) << 11) | (((g >> 2) & 0x3F) << 5) | ((b >> 3) & 0x1F)); - } + virtual OverlayColor RGBToColor(uint8 r, uint8 g, uint8 b); /** * Convert the given OverlayColor into a RGB triplet. An OverlayColor can @@ -619,14 +618,10 @@ public: * @see RGBToColor * @see colorToARGB */ - virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) { - r = (((color >> 11) & 0x1F) << 3); - g = (((color >> 5) & 0x3F) << 2); - b = ((color&0x1F) << 3); - } + virtual void colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b); /** - * Convert the given ARGB quadruplet into an OverlayColor. A OverlayColor can + * Convert the given ARGB quadruplet into an OverlayColor. A OverlayColor can * be 8bit, 16bit or 32bit, depending on the target system. The default * implementation generates a 16 bit color value, in the 565 format * (that is, 5 bits red, 6 bits green, 5 bits blue). @@ -634,9 +629,7 @@ public: * @see colorToRGB * @see RGBToColor */ - virtual OverlayColor ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b) { - return RGBToColor(r, g, b); - } + virtual OverlayColor ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b); /** * Convert the given OverlayColor into an ARGB quadruplet. An OverlayColor can @@ -647,10 +640,7 @@ public: * @see ARGBToColor * @see colorToRGB */ - virtual void colorToARGB(OverlayColor color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) { - colorToRGB(color, r, g, b); - a = 255; - } + virtual void colorToARGB(OverlayColor color, uint8 &a, uint8 &r, uint8 &g, uint8 &b); //@} -- cgit v1.2.3