aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/graphics.cpp
diff options
context:
space:
mode:
authorBastien Bouclet2011-08-15 08:52:11 +0200
committerBastien Bouclet2011-08-27 17:09:11 +0200
commit3ca0b304cf29f12d5fb3cadccb18689306d33ff8 (patch)
tree6bff6b40e1fe0782a38e656fefe4810c27b5ffc6 /engines/mohawk/graphics.cpp
parent5e174cbfe466dbbe8e5470b0a00de1481b986181 (diff)
downloadscummvm-rg350-3ca0b304cf29f12d5fb3cadccb18689306d33ff8.tar.gz
scummvm-rg350-3ca0b304cf29f12d5fb3cadccb18689306d33ff8.tar.bz2
scummvm-rg350-3ca0b304cf29f12d5fb3cadccb18689306d33ff8.zip
MOHAWK: Implement fading for Myst Demo
Diffstat (limited to 'engines/mohawk/graphics.cpp')
-rw-r--r--engines/mohawk/graphics.cpp42
1 files changed, 40 insertions, 2 deletions
diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp
index 35c9d478d8..c4326d175f 100644
--- a/engines/mohawk/graphics.cpp
+++ b/engines/mohawk/graphics.cpp
@@ -672,12 +672,50 @@ void MystGraphics::simulatePreviousDrawDelay(const Common::Rect &dest) {
_nextAllowedDrawTime = time + _constantDrawDelay + dest.height() * dest.width() / _proportionalDrawDelay;
}
+void MystGraphics::copyBackBufferToScreenWithSaturation(int16 saturation) {
+ Graphics::Surface *screen = _vm->_system->lockScreen();
+
+ for (uint16 y = 0; y < _viewport.height(); y++)
+ for (uint16 x = 0; x < _viewport.width(); x++) {
+ uint32 color;
+ uint8 r, g, b;
+
+ if (_pixelFormat.bytesPerPixel == 2)
+ color = *(const uint16 *)_backBuffer->getBasePtr(x, y);
+ else
+ color = *(const uint32 *)_backBuffer->getBasePtr(x, y);
+
+ _pixelFormat.colorToRGB(color, r, g, b);
+
+ r = CLIP<int16>((int16)r - saturation, 0, 255);
+ g = CLIP<int16>((int16)g - saturation, 0, 255);
+ b = CLIP<int16>((int16)b - saturation, 0, 255);
+
+ color = _pixelFormat.RGBToColor(r, g, b);
+
+ if (_pixelFormat.bytesPerPixel == 2) {
+ uint16 *dst = (uint16 *)screen->getBasePtr(x, y);
+ *dst = color;
+ } else {
+ uint32 *dst = (uint32 *)screen->getBasePtr(x, y);
+ *dst = color;
+ }
+ }
+
+ _vm->_system->unlockScreen();
+ _vm->_system->updateScreen();
+}
+
void MystGraphics::fadeToBlack() {
- // TODO: Implement
+ for (int16 i = 0; i < 256; i += 32) {
+ copyBackBufferToScreenWithSaturation(i);
+ }
}
void MystGraphics::fadeFromBlack() {
- // TODO: Implement
+ for (int16 i = 256; i >= 0; i -= 32) {
+ copyBackBufferToScreenWithSaturation(i);
+ }
}
#endif // ENABLE_MYST