diff options
author | Martin Kiewitz | 2015-06-09 12:14:41 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-06-10 07:14:13 +0200 |
commit | 866d7a27d8b0ea28a533f75774dd9ee16c288d38 (patch) | |
tree | 9b589b642736bb375af0fbf220799f59a1a926c7 /engines/sherlock/screen.cpp | |
parent | 15b9d61f6e5c49f5fab43fe0ff038a27853fb95c (diff) | |
download | scummvm-rg350-866d7a27d8b0ea28a533f75774dd9ee16c288d38.tar.gz scummvm-rg350-866d7a27d8b0ea28a533f75774dd9ee16c288d38.tar.bz2 scummvm-rg350-866d7a27d8b0ea28a533f75774dd9ee16c288d38.zip |
SHERLOCK: 3DO intro: implement fade in/out/merge
Diffstat (limited to 'engines/sherlock/screen.cpp')
-rw-r--r-- | engines/sherlock/screen.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index de93d0aec3..de9bf51f46 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -231,6 +231,90 @@ void Screen::verticalTransition() { } } +void Screen::fadeIntoScreen3DO(int speed) { + Events &events = *_vm->_events; + Common::Rect changedRect; + uint16 *currentScreenBasePtr = (uint16 *)getPixels(); + uint16 *targetScreenBasePtr = (uint16 *)_backBuffer->getPixels(); + uint16 *currentScreenPtr = NULL; + uint16 *targetScreenPtr = NULL; + uint16 currentScreenPixel = 0; + uint16 targetScreenPixel = 0; + + uint16 currentScreenPixelRed = 0; + uint16 currentScreenPixelGreen = 0; + uint16 currentScreenPixelBlue = 0; + + uint16 targetScreenPixelRed = 0; + uint16 targetScreenPixelGreen = 0; + uint16 targetScreenPixelBlue = 0; + + uint16 screenWidth = this->w(); + uint16 screenHeight = this->h(); + uint16 screenX = 0; + uint16 screenY = 0; + uint16 pixelsChanged = 0; + + _dirtyRects.clear(); + + do { + pixelsChanged = 0; + currentScreenPtr = currentScreenBasePtr; + targetScreenPtr = targetScreenBasePtr; + + for (screenY = 0; screenY < screenHeight; screenY++) { + for (screenX = 0; screenX < screenWidth; screenX++) { + currentScreenPixel = *currentScreenPtr; + targetScreenPixel = *targetScreenPtr; + + if (currentScreenPixel != targetScreenPixel) { + // pixel doesn't match, adjust accordingly + currentScreenPixelRed = currentScreenPixel & 0xF800; + currentScreenPixelGreen = currentScreenPixel & 0x07E0; + currentScreenPixelBlue = currentScreenPixel & 0x001F; + targetScreenPixelRed = targetScreenPixel & 0xF800; + targetScreenPixelGreen = targetScreenPixel & 0x07E0; + targetScreenPixelBlue = targetScreenPixel & 0x001F; + + if (currentScreenPixelRed != targetScreenPixelRed) { + if (currentScreenPixelRed < targetScreenPixelRed) { + currentScreenPixelRed += 0x0800; + } else { + currentScreenPixelRed -= 0x0800; + } + } + if (currentScreenPixelGreen != targetScreenPixelGreen) { + // Adjust +2/-2 because we are running RGB555 at RGB565 + if (currentScreenPixelGreen < targetScreenPixelGreen) { + currentScreenPixelGreen += 0x0040; + } else { + currentScreenPixelGreen -= 0x0040; + } + } + if (currentScreenPixelBlue != targetScreenPixelBlue) { + if (currentScreenPixelBlue < targetScreenPixelBlue) { + currentScreenPixelBlue += 0x0001; + } else { + currentScreenPixelBlue -= 0x0001; + } + } + *currentScreenPtr = currentScreenPixelRed | currentScreenPixelGreen | currentScreenPixelBlue; + pixelsChanged++; + } + + currentScreenPtr++; + targetScreenPtr++; + } + } + + // Too much considered dirty at the moment + addDirtyRect(Common::Rect(0, 0, screenWidth, screenHeight)); + + events.pollEvents(); + events.delay(10 * speed); + } while ((pixelsChanged) && (!_vm->shouldQuit())); +} + void Screen::restoreBackground(const Common::Rect &r) { if (r.width() > 0 && r.height() > 0) { Common::Rect tempRect = r; |