diff options
Diffstat (limited to 'engines/mads')
-rw-r--r-- | engines/mads/animation.cpp | 8 | ||||
-rw-r--r-- | engines/mads/player.cpp | 8 | ||||
-rw-r--r-- | engines/mads/screen.cpp | 23 | ||||
-rw-r--r-- | engines/mads/sequence.cpp | 2 | ||||
-rw-r--r-- | engines/mads/sprites.cpp | 24 | ||||
-rw-r--r-- | engines/mads/sprites.h | 16 | ||||
-rw-r--r-- | engines/mads/user_interface.cpp | 48 | ||||
-rw-r--r-- | engines/mads/user_interface.h | 6 |
8 files changed, 71 insertions, 64 deletions
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index a8adfe3105..f4fee20de7 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -403,7 +403,7 @@ void Animation::update() { for (uint idx = 0; idx < scene._spriteSlots.size(); ++idx) { if (scene._spriteSlots[idx]._seqIndex >= 0x80) - scene._spriteSlots[idx]._SlotType = ST_EXPIRED; + scene._spriteSlots[idx]._flags = IMG_ERASE; } // Validate the current frame @@ -445,7 +445,7 @@ void Animation::update() { if (paChanged) { newIndex = scene._spriteSlots.add(); scene._spriteSlots[newIndex]._seqIndex = -1; - scene._spriteSlots[newIndex]._SlotType = ST_FULL_SCREEN_REFRESH; + scene._spriteSlots[newIndex]._flags = IMG_REFRESH; } // Main frame animation loop - frames get animated by being placed, as necessary, into the @@ -463,7 +463,7 @@ void Animation::update() { int seqIndex = _frameEntries[_oldFrameEntry]._seqIndex - scene._spriteSlots[index]._seqIndex; if (seqIndex == 0x80) { if (scene._spriteSlots[index] == _frameEntries[_oldFrameEntry]._spriteSlot) { - scene._spriteSlots[index]._SlotType = ST_NONE; + scene._spriteSlots[index]._flags = IMG_STATIC; spriteSlotIndex = -1; } } @@ -479,7 +479,7 @@ void Animation::update() { SpriteAsset &spriteSet = *scene._sprites[ scene._spriteSlots[slotIndex]._spritesIndex]; - slot._SlotType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND; + slot._flags = spriteSet.isBackground() ? IMG_DELTA : IMG_UPDATE; } break; } diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp index 5546784083..a98fdb1b15 100644 --- a/engines/mads/player.cpp +++ b/engines/mads/player.cpp @@ -260,7 +260,7 @@ void Player::update() { if (_forceRefresh || (_visible != _priorVisible)) { int slotIndex = getSpriteSlot(); if (slotIndex >= 0) - scene._spriteSlots[slotIndex]._SlotType = ST_EXPIRED; + scene._spriteSlots[slotIndex]._flags = IMG_ERASE; int newDepth = 1; int yp = MAX(_playerPos.y, (int16)(MADS_SCENE_HEIGHT - 1)); @@ -278,7 +278,7 @@ void Player::update() { if (_visible) { // Player sprite needs to be rendered SpriteSlot slot; - slot._SlotType = ST_FOREGROUND; + slot._flags = IMG_UPDATE; slot._seqIndex = PLAYER_SEQ_INDEX; slot._spritesIndex = _spritesStart + _spritesIdx; slot._frameNumber = _mirror ? -_frameNumber : _frameNumber; @@ -299,7 +299,7 @@ void Player::update() { if (equal) // Undo the prior expiry of the player sprite - s2._SlotType = ST_NONE; + s2._flags = IMG_STATIC; else slotIndex = -1; } @@ -532,7 +532,7 @@ int Player::getSpriteSlot() { for (uint idx = 0; idx < spriteSlots.size(); ++idx) { if (spriteSlots[idx]._seqIndex == PLAYER_SEQ_INDEX && - spriteSlots[idx]._SlotType >= ST_NONE) + spriteSlots[idx]._flags >= IMG_STATIC) return idx; } diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp index 391ba71eeb..ca7235a14c 100644 --- a/engines/mads/screen.cpp +++ b/engines/mads/screen.cpp @@ -78,7 +78,7 @@ void DirtyArea::setSpriteSlot(const SpriteSlot *spriteSlot) { int width, height; Scene &scene = _vm->_game->_scene; - if (spriteSlot->_SlotType == ST_FULL_SCREEN_REFRESH) { + if (spriteSlot->_flags == IMG_REFRESH) { // Special entry to refresh the entire screen _bounds.left = 0; _bounds.top = 0; @@ -117,24 +117,24 @@ void DirtyArea::setTextDisplay(const TextDisplay *textDisplay) { } void DirtyArea::setUISlot(const UISlot *slot) { - int type = slot->_slotType; - if (type <= -20) - type += 20; + int type = slot->_flags; + if (type <= IMG_UPDATE_ONLY) + type += -IMG_UPDATE_ONLY; if (type >= 0x40) type &= ~0x40; MSurface &intSurface = _vm->_game->_scene._userInterface; switch (type) { - case ST_FULL_SCREEN_REFRESH: + case IMG_REFRESH: _bounds.left = 0; _bounds.top = 0; setArea(intSurface.w, intSurface.h, intSurface.w, intSurface.h); break; - case ST_MINUS3: + case IMG_OVERPRINT: _bounds.left = slot->_position.x; _bounds.top = slot->_position.y; // TODO: spritesIndex & frameNumber used as w & h??! - error("TODO: Figure out ST_MINUS3. Maybe need a union?"); + error("TODO: Figure out IMG_OVERPRINT. Maybe need a union?"); break; default: { @@ -143,7 +143,7 @@ void DirtyArea::setUISlot(const UISlot *slot) { int w = frame->w; int h = frame->h; - if (slot->_field2 == 200) { + if (slot->_segmentId == IMG_SPINNING_OBJECT) { _bounds.left = slot->_position.x; _bounds.top = slot->_position.y; } else { @@ -350,12 +350,11 @@ void ScreenObjects::check(bool scanFlag) { for (uint idx = 0; idx < uiSlots.size(); ++idx) { UISlot &slot = uiSlots[idx]; - if (slot._slotType != ST_FULL_SCREEN_REFRESH && slot._slotType > -20 - && slot._field2 != 200) - slot._slotType = ST_EXPIRED; + if (slot._flags != IMG_REFRESH && slot._flags > -20 + && slot._segmentId != IMG_SPINNING_OBJECT) + slot._flags = IMG_ERASE; } - // TODO: The stuff here could probably be moved to Scene::doFrame // Any background animation scene.backgroundAnimation(); diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp index 6b9bd9e017..01ca69615f 100644 --- a/engines/mads/sequence.cpp +++ b/engines/mads/sequence.cpp @@ -184,7 +184,7 @@ void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) { SequenceEntry &timerEntry = _entries[seqIndex]; SpriteAsset &spriteSet = *scene._sprites[timerEntry._spritesIndex]; - spriteSlot._SlotType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND; + spriteSlot._flags = spriteSet.isBackground() ? IMG_DELTA : IMG_UPDATE; spriteSlot._seqIndex = seqIndex; spriteSlot._spritesIndex = timerEntry._spritesIndex; spriteSlot._frameNumber = timerEntry._flipped ? -timerEntry._frameIndex : timerEntry._frameIndex; diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp index 226835bb23..442125e929 100644 --- a/engines/mads/sprites.cpp +++ b/engines/mads/sprites.cpp @@ -139,7 +139,7 @@ byte MSprite::getTransparencyIndex() const { MADSEngine *SpriteSlot::_vm = nullptr; SpriteSlot::SpriteSlot() { - _SlotType = ST_NONE; + _flags = IMG_STATIC; _seqIndex = 0; _spritesIndex = 0; _frameNumber = 0; @@ -147,8 +147,8 @@ SpriteSlot::SpriteSlot() { _scale = 0; } -SpriteSlot::SpriteSlot(SlotType type, int seqIndex) { - _SlotType = type; +SpriteSlot::SpriteSlot(SpriteFlags type, int seqIndex) { + _flags = type; _seqIndex = seqIndex; _spritesIndex = 0; _frameNumber = 0; @@ -183,7 +183,7 @@ void SpriteSlots::reset(bool flag) { _vm->_game->_scene._sprites.clear(); Common::Array<SpriteSlot>::clear(); - push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1)); + push_back(SpriteSlot(IMG_REFRESH, -1)); } void SpriteSlots::deleteEntry(int index) { @@ -194,11 +194,11 @@ void SpriteSlots::setDirtyAreas() { Scene &scene = _vm->_game->_scene; for (uint i = 0; i < size(); ++i) { - if ((*this)[i]._SlotType >= ST_NONE) { + if ((*this)[i]._flags >= IMG_STATIC) { scene._dirtyAreas[i].setSpriteSlot(&(*this)[i]); - scene._dirtyAreas[i]._textActive = ((*this)[i]._SlotType <= ST_NONE) ? 0 : 1; - (*this)[i]._SlotType = ST_NONE; + scene._dirtyAreas[i]._textActive = ((*this)[i]._flags <= IMG_STATIC) ? 0 : 1; + (*this)[i]._flags = IMG_STATIC; } } } @@ -207,7 +207,7 @@ void SpriteSlots::fullRefresh(bool clearAll) { if (clearAll) Common::Array<SpriteSlot>::clear(); - push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1)); + push_back(SpriteSlot(IMG_REFRESH, -1)); } void SpriteSlots::deleteTimer(int seqIndex) { @@ -233,14 +233,14 @@ void SpriteSlots::drawBackground() { SpriteSlot &spriteSlot = (*this)[i]; DirtyArea &dirtyArea = scene._dirtyAreas[i]; - if (spriteSlot._SlotType >= ST_NONE) { + if (spriteSlot._flags >= IMG_STATIC) { // Foreground sprite, so we can ignore it dirtyArea._active = false; } else { dirtyArea._active = true; dirtyArea.setSpriteSlot(&spriteSlot); - if (spriteSlot._SlotType == ST_BACKGROUND) { + if (spriteSlot._flags == IMG_DELTA) { // Background object, so need to draw it assert(spriteSlot._frameNumber > 0); SpriteAsset *asset = scene._sprites[spriteSlot._spritesIndex]; @@ -290,7 +290,7 @@ void SpriteSlots::drawForeground(MSurface *s) { // Get a list of sprite object depths for active objects for (uint i = 0; i < size(); ++i) { SpriteSlot &spriteSlot = (*this)[i]; - if (spriteSlot._SlotType >= ST_NONE) { + if (spriteSlot._flags >= IMG_STATIC) { DepthEntry rec(16 - spriteSlot._depth, i); depthList.push_back(rec); } @@ -353,7 +353,7 @@ void SpriteSlots::drawForeground(MSurface *s) { void SpriteSlots::cleanUp() { for (int i = (int)size() - 1; i >= 0; --i) { - if ((*this)[i]._SlotType < ST_NONE) + if ((*this)[i]._flags < IMG_STATIC) remove_at(i); } } diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h index a9b4e97d40..962d8c9e75 100644 --- a/engines/mads/sprites.h +++ b/engines/mads/sprites.h @@ -30,9 +30,15 @@ namespace MADS { -enum SlotType { - ST_NONE = 0, ST_FOREGROUND = 1, ST_MINUS5 = -5, ST_BACKGROUND = -4, - ST_MINUS3 = -3, ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1 +enum SpriteFlags { + IMG_STATIC = 0, // Item should remain fixed on the screen + IMG_UPDATE = 1, // Item needs to be redrawn + IMG_ERASE = -1, // Erase image and remove it + IMG_REFRESH = -2, // Full refresh + IMG_OVERPRINT = -3, // Interface overprint + IMG_DELTA = -4, // Delta change + IMG_FULL_UPDATE = -5, // Interface refresh + IMG_UPDATE_ONLY = -20 // Update the active screen area only }; class MADSEngine; @@ -129,11 +135,11 @@ private: static MADSEngine *_vm; friend class SpriteSlots; public: - SlotType _SlotType; + SpriteFlags _flags; int _seqIndex; public: SpriteSlot(); - SpriteSlot(SlotType type, int seqIndex); + SpriteSlot(SpriteFlags type, int seqIndex); void setup(int dirtyAreaIndex); bool operator==(const SpriteSlotSubset &other) const; diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp index 2cd1662077..7ed1884e88 100644 --- a/engines/mads/user_interface.cpp +++ b/engines/mads/user_interface.cpp @@ -28,8 +28,8 @@ namespace MADS { UISlot::UISlot() { - _slotType = ST_NONE; - _field2 = 0; + _flags = IMG_STATIC; + _segmentId = 0; _spritesIndex = 0; _frameNumber = 0; } @@ -38,8 +38,8 @@ UISlot::UISlot() { void UISlots::fullRefresh() { UISlot slot; - slot._slotType = ST_FULL_SCREEN_REFRESH; - slot._field2 = -1; + slot._flags = IMG_REFRESH; + slot._segmentId = -1; push_back(slot); } @@ -48,8 +48,8 @@ void UISlots::add(const Common::Point &pt, int frameNumber, int spritesIndex) { assert(size() < 50); UISlot ie; - ie._slotType = -3; - ie._field2 = 201; + ie._flags = -3; + ie._segmentId = IMG_TEXT_UPDATE; ie._position = pt; ie._frameNumber = frameNumber; ie._spritesIndex = spritesIndex; @@ -67,12 +67,12 @@ void UISlots::draw(bool updateFlag, bool delFlag) { DirtyArea &dirtyArea = userInterface._dirtyAreas[idx]; UISlot &slot = (*this)[idx]; - if (slot._slotType >= ST_NONE) { + if (slot._flags >= IMG_STATIC) { dirtyArea._active = false; } else { dirtyArea.setUISlot(&slot); dirtyArea._textActive = true; - if (slot._field2 == 200 && slot._slotType == ST_MINUS5) { + if (slot._segmentId == IMG_SPINNING_OBJECT && slot._flags == IMG_FULL_UPDATE) { dirtyArea._active = false; dirtyAreaPtr = &dirtyArea; } @@ -89,10 +89,10 @@ void UISlots::draw(bool updateFlag, bool delFlag) { UISlot &slot = (*this)[idx]; if (dirtyArea._active && dirtyArea._bounds.width() > 0 - && dirtyArea._bounds.height() > 0 && slot._slotType >= -20) { + && dirtyArea._bounds.height() > 0 && slot._flags >= -20) { // TODO: Figure out the difference between two copy methods used - if (slot._slotType >= ST_EXPIRED) { + if (slot._flags >= IMG_ERASE) { userInterface._surface.copyTo(&userInterface, dirtyArea._bounds, Common::Point(dirtyArea._bounds.left, dirtyArea._bounds.top)); } else { @@ -106,14 +106,14 @@ void UISlots::draw(bool updateFlag, bool delFlag) { DirtyArea &dirtyArea = userInterface._dirtyAreas[idx]; UISlot &slot = (*this)[idx]; - int slotType = slot._slotType; - if (slotType >= ST_NONE) { + int slotType = slot._flags; + if (slotType >= IMG_STATIC) { dirtyArea.setUISlot(&slot); if (!updateFlag) slotType &= ~0x40; dirtyArea._textActive = slotType > 0; - slot._slotType &= 0x40; + slot._flags &= 0x40; } } @@ -123,7 +123,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) { DirtyArea &dirtyArea = userInterface._dirtyAreas[idx]; UISlot &slot = (*this)[idx]; - if (slot._slotType >= ST_NONE && !(slot._slotType & 0x40)) { + if (slot._flags >= IMG_STATIC && !(slot._flags & 0x40)) { if (!dirtyArea._active) { error("Should never reach this point, even in original"); } @@ -131,7 +131,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) { if (dirtyArea._textActive) { SpriteAsset *asset = scene._sprites[slot._spritesIndex]; - if (slot._field2 == 200) { + if (slot._segmentId == IMG_SPINNING_OBJECT) { MSprite *sprite = asset->getFrame(slot._frameNumber & 0x7F); sprite->copyTo(&userInterface, slot._position, sprite->getTransparencyIndex()); @@ -170,16 +170,16 @@ void UISlots::draw(bool updateFlag, bool delFlag) { for (int idx = (int)size() - 1; idx >= 0; --idx) { UISlot &slot = (*this)[idx]; - if (slot._slotType < ST_NONE) { + if (slot._flags < IMG_STATIC) { if (delFlag || updateFlag) remove_at(idx); - else if (slot._slotType >= -20) - slot._slotType -= 20; + else if (slot._flags >= -20) + slot._flags -= 20; } else { if (updateFlag) - slot._slotType &= ~0x40; + slot._flags &= ~0x40; else - slot._slotType |= 0x40; + slot._flags |= 0x40; } } } @@ -619,14 +619,14 @@ void UserInterface::inventoryAnim() { // Loop through the slots list for inventory animation entry for (uint i = 0; i < _uiSlots.size(); ++i) { - if (_uiSlots[i]._field2 == 200) - _uiSlots[i]._slotType = -5; + if (_uiSlots[i]._segmentId == IMG_SPINNING_OBJECT) + _uiSlots[i]._flags = -5; } // Add a new slot entry for the inventory animation UISlot slot; - slot._slotType = ST_FOREGROUND; - slot._field2 = 200; + slot._flags = IMG_UPDATE; + slot._segmentId = IMG_SPINNING_OBJECT; slot._frameNumber = _invFrameNumber; slot._spritesIndex = _invSpritesIndex; slot._position = Common::Point(160, 3); diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h index 740ea66c4e..53c1e10466 100644 --- a/engines/mads/user_interface.h +++ b/engines/mads/user_interface.h @@ -31,10 +31,12 @@ namespace MADS { +enum { IMG_SPINNING_OBJECT = 200, IMG_TEXT_UPDATE = 201 }; + class UISlot { public: - int _slotType; - int _field2; + int _flags; + int _segmentId; int _spritesIndex; int _frameNumber; Common::Point _position; |