Skip to content

Commit

Permalink
MOHAWK: Introduce the effects intermediary screen
Browse files Browse the repository at this point in the history
  • Loading branch information
bgK authored and sev- committed Jul 3, 2017
1 parent 8fcebc1 commit e9b6708
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions engines/mohawk/riven_graphics.cpp
Expand Up @@ -47,6 +47,9 @@ RivenGraphics::RivenGraphics(MohawkEngine_Riven* vm) : GraphicsManager(), _vm(vm
_mainScreen = new Graphics::Surface();
_mainScreen->create(608, 392, _pixelFormat);

_effectScreen = new Graphics::Surface();
_effectScreen->create(608, 392, _pixelFormat);

_screenUpdateNesting = 0;
_screenUpdateRunning = false;
_scheduledTransition = -1; // no transition
Expand All @@ -60,6 +63,8 @@ RivenGraphics::RivenGraphics(MohawkEngine_Riven* vm) : GraphicsManager(), _vm(vm
}

RivenGraphics::~RivenGraphics() {
_effectScreen->free();
delete _effectScreen;
_mainScreen->free();
delete _mainScreen;
delete _bitmapDecoder;
Expand Down Expand Up @@ -90,10 +95,13 @@ void RivenGraphics::copyImageToScreen(uint16 image, uint32 left, uint32 top, uin
void RivenGraphics::updateScreen(Common::Rect updateRect) {
if (_dirtyScreen) {
// Copy to screen if there's no transition. Otherwise transition. ;)
if (_scheduledTransition < 0)
_vm->_system->copyRectToScreen(_mainScreen->getBasePtr(updateRect.left, updateRect.top), _mainScreen->pitch, updateRect.left, updateRect.top, updateRect.width(), updateRect.height());
else
if (_scheduledTransition < 0) {
// mainScreen -> effectScreen -> systemScreen
_effectScreen->copyRectToSurface(*_mainScreen, updateRect.left, updateRect.top, updateRect);
_vm->_system->copyRectToScreen(_effectScreen->getBasePtr(updateRect.left, updateRect.top), _effectScreen->pitch, updateRect.left, updateRect.top, updateRect.width(), updateRect.height());
} else {
runScheduledTransition();
}

// Finally, update the screen.
_vm->_system->updateScreen();
Expand Down Expand Up @@ -230,7 +238,8 @@ void RivenGraphics::runScheduledTransition() {
}

// For now, just copy the image to screen without doing any transition.
_vm->_system->copyRectToScreen(_mainScreen->getPixels(), _mainScreen->pitch, 0, 0, _mainScreen->w, _mainScreen->h);
_effectScreen->copyRectToSurface(*_mainScreen, 0, 0, Common::Rect(_mainScreen->w, _mainScreen->h));
_vm->_system->copyRectToScreen(_effectScreen->getBasePtr(0, 0), _effectScreen->pitch, 0, 0, _effectScreen->w, _effectScreen->h);
_vm->_system->updateScreen();

_scheduledTransition = -1; // Clear scheduled transition
Expand Down
1 change: 1 addition & 0 deletions engines/mohawk/riven_graphics.h
Expand Up @@ -100,6 +100,7 @@ class RivenGraphics : public GraphicsManager {

// Screen Related
Graphics::Surface *_mainScreen;
Graphics::Surface *_effectScreen;
bool _dirtyScreen;
Graphics::PixelFormat _pixelFormat;
void clearMainScreen();
Expand Down

0 comments on commit e9b6708

Please sign in to comment.