From 919db23841c24475257182f6daddea59cefb408a Mon Sep 17 00:00:00 2001 From: Matthew Stewart Date: Thu, 26 Jul 2018 00:18:32 -0400 Subject: STARTREK: Implement "BAN" files. These are background animations in various rooms, purely visual. --- engines/startrek/graphics.cpp | 65 ++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 19 deletions(-) (limited to 'engines/startrek/graphics.cpp') diff --git a/engines/startrek/graphics.cpp b/engines/startrek/graphics.cpp index 6e8c97f902..43358f8c1c 100644 --- a/engines/startrek/graphics.cpp +++ b/engines/startrek/graphics.cpp @@ -109,6 +109,14 @@ byte *Graphics::getBackgroundPixels() { return _backgroundImage->pixels; } +byte *Graphics::lockScreenPixels() { + return (byte *)_vm->_system->lockScreen()->getPixels(); +} + +void Graphics::unlockScreenPixels() { + _vm->_system->unlockScreen(); +} + void Graphics::clearScreenAndPriBuffer() { Common::fill(_priData, _priData + sizeof(_priData), 0); @@ -571,28 +579,24 @@ void Graphics::drawAllSprites(bool updateScreen) { surface.free(); - if (updateScreen) { - // Check if there are any pending updates to the mouse. - if (_mouseBitmap != _mouseBitmapLastFrame) { - _mouseBitmapLastFrame = _mouseBitmap; - _vm->_system->setMouseCursor(_mouseBitmap->pixels, _mouseBitmap->width, _mouseBitmap->height, _mouseBitmap->xoffset, _mouseBitmap->yoffset, 0); - } - if (_mouseToBeShown) { - CursorMan.showMouse(true); - _mouseToBeShown = false; - } else if (_mouseToBeHidden) { - CursorMan.showMouse(false); - _mouseToBeHidden = false; - } + if (updateScreen) + this->updateScreen(); +} - if (_mouseWarpX != -1) { - _vm->_system->warpMouse(_mouseWarpX, _mouseWarpY); - _mouseWarpX = -1; - _mouseWarpY = -1; - } +void Graphics::drawAllSpritesInRect(const Common::Rect &rect) { + ::Graphics::Surface *surface = _vm->_system->lockScreen(); + + for (int i = 0; i < _numSprites; i++) { + Sprite *sprite = _sprites[i]; + if (!sprite->isOnScreen) + continue; - _vm->_system->updateScreen(); + Common::Rect intersect = rect.findIntersectingRect(sprite->drawRect); + if (!intersect.isEmpty()) + drawSprite(*sprite, surface, intersect); } + + _vm->_system->unlockScreen(); } void Graphics::forceDrawAllSprites(bool updateScreen) { @@ -601,6 +605,29 @@ void Graphics::forceDrawAllSprites(bool updateScreen) { drawAllSprites(updateScreen); } +void Graphics::updateScreen() { + // Check if there are any pending updates to the mouse. + if (_mouseBitmap != _mouseBitmapLastFrame) { + _mouseBitmapLastFrame = _mouseBitmap; + _vm->_system->setMouseCursor(_mouseBitmap->pixels, _mouseBitmap->width, _mouseBitmap->height, _mouseBitmap->xoffset, _mouseBitmap->yoffset, 0); + } + if (_mouseToBeShown) { + CursorMan.showMouse(true); + _mouseToBeShown = false; + } else if (_mouseToBeHidden) { + CursorMan.showMouse(false); + _mouseToBeHidden = false; + } + + if (_mouseWarpX != -1) { + _vm->_system->warpMouse(_mouseWarpX, _mouseWarpY); + _mouseWarpX = -1; + _mouseWarpY = -1; + } + + _vm->_system->updateScreen(); +} + Sprite *Graphics::getSpriteAt(int16 x, int16 y) { for (int i = _numSprites - 1; i >= 0; i--) { Sprite *sprite = _sprites[i]; -- cgit v1.2.3