diff options
Diffstat (limited to 'engines/mads/scene_data.cpp')
-rw-r--r-- | engines/mads/scene_data.cpp | 172 |
1 files changed, 5 insertions, 167 deletions
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index c37f0b1f74..8980bd4428 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -136,173 +136,11 @@ void ScreenObjects::proc1() { /*------------------------------------------------------------------------*/ -MADSEngine *DirtyArea::_vm = nullptr; - -DirtyArea::DirtyArea() { - _active = false; - _textActive = false; -} - -void DirtyArea::setArea(int width, int height, int maxWidth, int maxHeight) { - if (_bounds.left % 2) { - --_bounds.left; - ++width; - } - - if (_bounds.left < 0) - _bounds.left = 0; - else if (_bounds.left > maxWidth) - _bounds.left = maxWidth; - int right = _bounds.left + width; - if (right < 0) - right = 0; - if (right > maxWidth) - right = maxWidth; - - _bounds.right = right; - _bounds2.left = _bounds.width() / 2; - _bounds2.right = _bounds.left + (_bounds.width() + 1) / 2 - 1; - - if (_bounds.top < 0) - _bounds.top = 0; - else if (_bounds.top > maxHeight) - _bounds.top = maxHeight; - int bottom = _bounds.top + height; - if (bottom < 0) - bottom = 0; - if (bottom > maxHeight) - bottom = maxHeight; - - _bounds.bottom = bottom; - _bounds2.top = _bounds.height() / 2; - _bounds2.bottom = _bounds.top + (_bounds.height() + 1) / 2 - 1; - - _active = true; -} - - -void DirtyArea::setSpriteSlot(const SpriteSlot *spriteSlot) { - int width, height; - Scene &scene = _vm->_game->_scene; - - if (spriteSlot->_spriteType == ST_FULL_SCREEN_REFRESH) { - // Special entry to refresh the entire screen - _bounds.left = 0; - _bounds.top = 0; - width = MADS_SCREEN_WIDTH; - height = MADS_SCENE_HEIGHT; - } else { - // Standard sprite slots - _bounds.left = spriteSlot->_position.x - scene._posAdjust.x; - _bounds.top = spriteSlot->_position.y - scene._posAdjust.y; - - SpriteAsset &spriteSet = *scene._sprites[spriteSlot->_spritesIndex]; - MSprite *frame = spriteSet.getFrame(((spriteSlot->_frameNumber & 0x7fff) - 1) & 0x7f); - - if (spriteSlot->_scale == -1) { - width = frame->w; - height = frame->h; - } else { - width = frame->w * spriteSlot->_scale / 100; - height = frame->h * spriteSlot->_scale / 100; - - _bounds.left -= width / 2; - _bounds.top += -(height - 1); - } - } - - setArea(width, height, MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT); -} - -void DirtyArea::setTextDisplay(const TextDisplay *textDisplay) { - _bounds.left = textDisplay->_bounds.left; - _bounds.top = textDisplay->_bounds.top; - - setArea(textDisplay->_bounds.width(), textDisplay->_bounds.height(), - MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT); -} - -/*------------------------------------------------------------------------*/ - -DirtyAreas::DirtyAreas(MADSEngine *vm) : _vm(vm) { - DirtyArea::_vm = vm; - - for (int i = 0; i < DIRTY_AREAS_SIZE; ++i) { - DirtyArea rec; - rec._active = false; - push_back(rec); - } -} - -void DirtyAreas::merge(int startIndex, int count) { - if (startIndex >= count) - return; - - for (int outerCtr = startIndex - 1, idx = 0; idx < count; ++outerCtr, ++idx) { - if (!(*this)[outerCtr]._active) - continue; - - for (int innerCtr = outerCtr + 1; innerCtr < count; ++innerCtr) { - if (!(*this)[innerCtr]._active || !intersects(outerCtr, innerCtr)) - continue; - - if ((*this)[outerCtr]._textActive && (*this)[innerCtr]._textActive) - mergeAreas(outerCtr, innerCtr); - } - } -} - -/** -* Returns true if two dirty areas intersect -*/ -bool DirtyAreas::intersects(int idx1, int idx2) { - return (*this)[idx1]._bounds2.intersects((*this)[idx2]._bounds2); -} - -void DirtyAreas::mergeAreas(int idx1, int idx2) { - DirtyArea &da1 = (*this)[idx1]; - DirtyArea &da2 = (*this)[idx2]; - - da1._bounds.extend(da2._bounds); - - da1._bounds2.left = da1._bounds.width() / 2; - da1._bounds2.right = da1._bounds.left + (da1._bounds.width() + 1) / 2 - 1; - da1._bounds2.top = da1._bounds.height() / 2; - da1._bounds2.bottom = da1._bounds.top + (da1._bounds.height() + 1) / 2 - 1; - - da2._active = false; - da1._textActive = true; -} - -void DirtyAreas::copy(MSurface *srcSurface, MSurface *destSurface, const Common::Point &posAdjust) { - for (uint i = 0; i < size(); ++i) { - const Common::Rect &srcBounds = (*this)[i]._bounds; - - Common::Rect bounds(srcBounds.left + posAdjust.x, srcBounds.top + posAdjust.y, - srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y); - - if ((*this)[i]._active && bounds.isValidRect()) { - srcSurface->copyTo(destSurface, bounds, Common::Point(bounds.left, bounds.top)); - } - } -} - -void DirtyAreas::copyToScreen(const Common::Point &posAdjust) { - for (uint i = 0; i < size(); ++i) { - const Common::Rect &srcBounds = (*this)[i]._bounds; - - Common::Rect bounds(srcBounds.left + posAdjust.x, srcBounds.top + posAdjust.y, - srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y); - - if ((*this)[i]._active && (*this)[i]._bounds.isValidRect()) { - _vm->_screen.copyRectToScreen(bounds); - } - } -} - -void DirtyAreas::reset() { - for (uint i = 0; i < size(); ++i) - (*this)[i]._active = false; +void SceneNode::load(Common::SeekableReadStream *f) { + _walkPos.x = f->readSint16LE(); + _walkPos.y = f->readSint16LE(); + for (int i = 0; i < MAX_ROUTE_NODES; ++i) + _indexes[i] = f->readUint16LE(); } /*------------------------------------------------------------------------*/ |