aboutsummaryrefslogtreecommitdiff
path: root/engines/pegasus
diff options
context:
space:
mode:
authorMatthew Hoops2011-09-29 01:13:38 -0400
committerMatthew Hoops2011-09-29 01:15:54 -0400
commit6440d4d5f6b4183cd857ee685cebd08937137cf8 (patch)
tree5578ea4926052244d5832b9a60613421c902465a /engines/pegasus
parent091df1815e5fc4d5054f9005e6a80bd305588118 (diff)
downloadscummvm-rg350-6440d4d5f6b4183cd857ee685cebd08937137cf8.tar.gz
scummvm-rg350-6440d4d5f6b4183cd857ee685cebd08937137cf8.tar.bz2
scummvm-rg350-6440d4d5f6b4183cd857ee685cebd08937137cf8.zip
PEGASUS: Implement the ScreenDimmer class
Diffstat (limited to 'engines/pegasus')
-rw-r--r--engines/pegasus/elements.cpp46
-rw-r--r--engines/pegasus/elements.h8
-rw-r--r--engines/pegasus/pegasus.cpp3
-rw-r--r--engines/pegasus/pegasus.h1
4 files changed, 58 insertions, 0 deletions
diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index 4fe449d69e..bd3b4db2cb 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -478,4 +478,50 @@ void SpriteSequence::newFrame(const uint16 frame) {
_sprite.setCurrentFrameIndex(frame);
}
+#define DRAW_PIXEL() \
+ if (bytesPerPixel == 2) \
+ *((uint16 *)dst) = black; \
+ else \
+ *((uint32 *)dst) = black; \
+ dst += bytesPerPixel
+
+#define SKIP_PIXEL() \
+ dst += bytesPerPixel
+
+void ScreenDimmer::draw(const Common::Rect &r) {
+ // We're going to emulate QuickDraw's srcOr+gray mode here
+ // In this mode, every other y column is all black (odd-columns).
+ // Basically, every row does three black and then one transparent
+ // repeatedly.
+
+ // The output is identical to the original
+
+ uint32 black = g_system->getScreenFormat().RGBToColor(0, 0, 0);
+ Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
+ byte bytesPerPixel = g_system->getScreenFormat().bytesPerPixel;
+
+ // We're currently doing it to the whole screen to simplify the code
+
+ for (int y = 0; y < 480; y++) {
+ byte *dst = (byte *)screen->getBasePtr(0, y);
+
+ for (int x = 0; x < 640; x += 4) {
+ if (y & 1) {
+ DRAW_PIXEL();
+ DRAW_PIXEL();
+ SKIP_PIXEL();
+ DRAW_PIXEL();
+ } else {
+ SKIP_PIXEL();
+ DRAW_PIXEL();
+ DRAW_PIXEL();
+ DRAW_PIXEL();
+ }
+ }
+ }
+}
+
+#undef DRAW_PIXEL
+#undef SKIP_PIXEL
+
} // End of namespace Pegasus
diff --git a/engines/pegasus/elements.h b/engines/pegasus/elements.h
index f806f26a17..84c390aa02 100644
--- a/engines/pegasus/elements.h
+++ b/engines/pegasus/elements.h
@@ -224,6 +224,14 @@ protected:
Sprite _sprite;
};
+class ScreenDimmer : public DisplayElement {
+public:
+ ScreenDimmer() : DisplayElement(kScreenDimmerID) {}
+ virtual ~ScreenDimmer() {}
+
+ virtual void draw(const Common::Rect &);
+};
+
} // End of namespace Pegasus
#endif
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index ddc13d7a34..6af7f083af 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -142,6 +142,9 @@ Common::Error PegasusEngine::run() {
_returnHotspot.setHotspotFlags(kInfoReturnSpotFlag);
g_allHotspots.push_back(&_returnHotspot);
+ _screenDimmer.setBounds(Common::Rect(0, 0, 640, 480));
+ _screenDimmer.setDisplayOrder(kScreenDimmerOrder);
+
while (!shouldQuit())
processShell();
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 8405a51dc1..c0a7d02631 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -232,6 +232,7 @@ private:
GameMenu *_gameMenu;
void doGameMenuCommand(const tGameMenuCommand);
void doInterfaceOverview();
+ ScreenDimmer _screenDimmer;
// Energy
int32 _savedEnergyValue;