diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/m4/m4.cpp | 10 | ||||
-rw-r--r-- | engines/m4/mads_logic.cpp | 38 | ||||
-rw-r--r-- | engines/m4/mads_logic.h | 6 | ||||
-rw-r--r-- | engines/m4/mads_views.cpp | 47 | ||||
-rw-r--r-- | engines/m4/mads_views.h | 8 |
5 files changed, 57 insertions, 52 deletions
diff --git a/engines/m4/m4.cpp b/engines/m4/m4.cpp index 33a2fe6b68..897fb468cd 100644 --- a/engines/m4/m4.cpp +++ b/engines/m4/m4.cpp @@ -583,13 +583,15 @@ Common::Error MadsEngine::run() { _animation->updateAnim(); - // Call the updateState method of all views - _viewManager->updateState(); - if (g_system->getMillis() >= nextFrame) { - _viewManager->refreshAll(); nextFrame = g_system->getMillis() + GAME_FRAME_DELAY; ++_currentTimer; + + // Call the updateState method of all views + _viewManager->updateState(); + + // Refresh the display + _viewManager->refreshAll(); } g_system->delayMillis(10); diff --git a/engines/m4/mads_logic.cpp b/engines/m4/mads_logic.cpp index 7c70b780f1..d0b7021f38 100644 --- a/engines/m4/mads_logic.cpp +++ b/engines/m4/mads_logic.cpp @@ -77,31 +77,32 @@ uint16 MadsSceneLogic::loadSpriteSet(uint16 suffixNum, uint16 sepChar) { return _madsVm->scene()->loadSceneSpriteSet(resName); } -uint16 MadsSceneLogic::startSpriteSequence(uint16 srcSpriteIdx, int v0, int numTicks, int fld24, int timeoutTicks, int extraTicks) { +uint16 MadsSceneLogic::startReversibleSpriteSequence(uint16 srcSpriteIdx, int v0, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks) { M4Sprite *spriteFrame = _madsVm->scene()->_spriteSlots.getSprite(srcSpriteIdx).getFrame(1); uint8 depth = _madsVm->_rails->getDepth(Common::Point(spriteFrame->x + (spriteFrame->width() / 2), spriteFrame->y + (spriteFrame->height() / 2))); - return _madsVm->scene()->_sequenceList.add(srcSpriteIdx, v0, 1, fld24, timeoutTicks, extraTicks, numTicks, 0, 0, - -1, 100, depth - 1, 1, ANIMTYPE_SINGLE_DIRECTION, 0, 0); + return _madsVm->scene()->_sequenceList.add(srcSpriteIdx, v0, 1, triggerCountdown, timeoutTicks, extraTicks, numTicks, 0, 0, + -1, 100, depth - 1, 1, ANIMTYPE_REVERSIBLE, 0, 0); } -uint16 MadsSceneLogic::startCycledSpriteSequence(uint16 srcSpriteIdx, int v0, int numTicks, int fld24, int timeoutTicks, int extraTicks) { +uint16 MadsSceneLogic::startCycledSpriteSequence(uint16 srcSpriteIdx, int v0, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks) { M4Sprite *spriteFrame = _madsVm->scene()->_spriteSlots.getSprite(srcSpriteIdx).getFrame(1); +warning("%d %dx%d %d/%d", srcSpriteIdx, spriteFrame->x, spriteFrame->y, spriteFrame->width(), spriteFrame->height()); uint8 depth = _madsVm->_rails->getDepth(Common::Point(spriteFrame->x + (spriteFrame->width() / 2), spriteFrame->y + (spriteFrame->height() / 2))); - return _madsVm->scene()->_sequenceList.add(srcSpriteIdx, v0, 1, fld24, timeoutTicks, extraTicks, numTicks, 0, 0, + return _madsVm->scene()->_sequenceList.add(srcSpriteIdx, v0, 1, triggerCountdown, timeoutTicks, extraTicks, numTicks, 0, 0, -1, 100, depth - 1, 1, ANIMTYPE_CYCLED, 0, 0); } -uint16 MadsSceneLogic::startSpriteSequence3(uint16 srcSpriteIdx, int v0, int numTicks, int fld24, int timeoutTicks, int extraTicks) { +uint16 MadsSceneLogic::startSpriteSequence3(uint16 srcSpriteIdx, int v0, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks) { M4Sprite *spriteFrame = _madsVm->scene()->_spriteSlots.getSprite(srcSpriteIdx).getFrame(1); uint8 depth = _madsVm->_rails->getDepth(Common::Point(spriteFrame->x + (spriteFrame->width() / 2), spriteFrame->y + (spriteFrame->height() / 2))); - return _madsVm->scene()->_sequenceList.add(srcSpriteIdx, v0, 1, fld24, timeoutTicks, extraTicks, numTicks, 0, 0, - -1, 100, depth - 1, -1, ANIMTYPE_SINGLE_DIRECTION, 0, 0); + return _madsVm->scene()->_sequenceList.add(srcSpriteIdx, v0, 1, triggerCountdown, timeoutTicks, extraTicks, numTicks, 0, 0, + -1, 100, depth - 1, -1, ANIMTYPE_CYCLED, 0, 0); } void MadsSceneLogic::activateHotspot(int idx, bool active) { @@ -184,19 +185,20 @@ void MadsSceneLogic::enterScene() { _spriteIndexes[12] = loadSpriteSet(8, 'x'); _spriteIndexes[13] = loadSpriteSet(0, 'x'); - _spriteIndexes[15] = startSpriteSequence(_spriteIndexes[0], 0, 5, 0, 0, 25); - _spriteIndexes[16] = startSpriteSequence(_spriteIndexes[1], 0, 4, 0, 1, 0); - _spriteIndexes[17] = startSpriteSequence(_spriteIndexes[2], 0, 4, 0, 1, 0); + _spriteIndexes[15] = startCycledSpriteSequence(_spriteIndexes[0], 0, 5, 0, 0, 25); - _madsVm->scene()->_sequenceList.addSubEntry(0, SM_FRAME_INDEX, 7, 70); + _spriteIndexes[16] = startCycledSpriteSequence(_spriteIndexes[1], 0, 4, 0, 1, 0); + _spriteIndexes[17] = startCycledSpriteSequence(_spriteIndexes[2], 0, 4, 0, 1, 0); - _spriteIndexes[18] = startCycledSpriteSequence(_spriteIndexes[3], 0, 10, 0, 0, 60); - _spriteIndexes[19] = startSpriteSequence(_spriteIndexes[4], 0, 5, 0, 1, 0); - _spriteIndexes[20] = startSpriteSequence(_spriteIndexes[5], 0, 10, 0, 2, 0); - _spriteIndexes[21] = startSpriteSequence(_spriteIndexes[6], 0, 6, 0, 0, 0); +// _madsVm->scene()->_sequenceList.addSubEntry(_spriteIndexes[17], SM_FRAME_INDEX, 7, 70); - _spriteIndexes[23] = startSpriteSequence(_spriteIndexes[8], 0, 6, 0, 10, 4); - _spriteIndexes[24] = startSpriteSequence(_spriteIndexes[9], 0, 6, 0, 32, 47); + _spriteIndexes[18] = startReversibleSpriteSequence(_spriteIndexes[3], 0, 10, 0, 0, 60); + _spriteIndexes[19] = startCycledSpriteSequence(_spriteIndexes[4], 0, 5, 0, 1, 0); + _spriteIndexes[20] = startCycledSpriteSequence(_spriteIndexes[5], 0, 10, 0, 2, 0); + _spriteIndexes[21] = startCycledSpriteSequence(_spriteIndexes[6], 0, 6, 0, 0, 0); + + _spriteIndexes[23] = startCycledSpriteSequence(_spriteIndexes[8], 0, 6, 0, 10, 4); + _spriteIndexes[24] = startCycledSpriteSequence(_spriteIndexes[9], 0, 6, 0, 32, 47); activateHotspot(0x137, false); // SHIELD MODULATOR // shield_panel_opened = 0; diff --git a/engines/m4/mads_logic.h b/engines/m4/mads_logic.h index 5c66da48fd..a589556a21 100644 --- a/engines/m4/mads_logic.h +++ b/engines/m4/mads_logic.h @@ -35,9 +35,9 @@ class MadsSceneLogic { private: // Library interface methods uint16 loadSpriteSet(uint16 suffixNum, uint16 sepChar); - uint16 startSpriteSequence(uint16 srcSpriteIdx, int v0, int numTicks, int fld24, int timeoutTicks, int extraTicks); - uint16 startCycledSpriteSequence(uint16 srcSpriteIdx, int v0, int numTicks, int fld24, int timeoutTicks, int extraTicks); - uint16 startSpriteSequence3(uint16 srcSpriteIdx, int v0, int numTicks, int fld24, int timeoutTicks, int extraTicks); + uint16 startReversibleSpriteSequence(uint16 srcSpriteIdx, int v0, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks); + uint16 startCycledSpriteSequence(uint16 srcSpriteIdx, int v0, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks); + uint16 startSpriteSequence3(uint16 srcSpriteIdx, int v0, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks); void activateHotspot(int idx, bool active); void lowRoomsEntrySound(); private: diff --git a/engines/m4/mads_views.cpp b/engines/m4/mads_views.cpp index 04e8afd21a..e50c35bc04 100644 --- a/engines/m4/mads_views.cpp +++ b/engines/m4/mads_views.cpp @@ -121,7 +121,7 @@ void MadsSpriteSlots::draw(View *view) { // Minimalised drawing assert(slot.spriteListIndex < (int)_sprites.size()); M4Sprite *spr = spriteSet.getFrame(slot.frameNumber - 1); - spr->draw1(view, slot.scale, slot.depth, slot.xp, MADS_Y_OFFSET + slot.yp); + spr->draw1(view, slot.scale, slot.depth, slot.xp, slot.yp); } else { int xp, yp; M4Sprite *spr = spriteSet.getFrame(slot.frameNumber - 1); @@ -135,9 +135,9 @@ void MadsSpriteSlots::draw(View *view) { } if (slot.depth > 1) { - spr->draw2(view, slot.depth, xp, MADS_Y_OFFSET + yp); + spr->draw2(view, slot.depth, xp, yp); } else { - spr->draw3(view, xp, MADS_Y_OFFSET + yp); + spr->draw3(view, xp, yp); } } } @@ -501,7 +501,7 @@ bool MadsSequenceList::addSubEntry(int index, SequenceSubEntryMode mode, int fra return false; } -int MadsSequenceList::add(int spriteListIndex, int v0, int frameIndex, char field_24, int timeoutTicks, int extraTicks, int numTicks, +int MadsSequenceList::add(int spriteListIndex, int v0, int frameIndex, int triggerCountdown, int delayTicks, int extraTicks, int numTicks, int height, int width, char field_12, char scale, uint8 depth, int frameInc, SpriteAnimType animType, int numSprites, int frameStart) { @@ -536,10 +536,10 @@ int MadsSequenceList::add(int spriteListIndex, int v0, int frameIndex, char fiel _entries[timerIndex].numTicks = numTicks; _entries[timerIndex].extraTicks = extraTicks; - _entries[timerIndex].timeout = _madsVm->_currentTimer + timeoutTicks; + _entries[timerIndex].timeout = _madsVm->_currentTimer + delayTicks; - _entries[timerIndex].field_24 = field_24; - _entries[timerIndex].field_25 = 0; + _entries[timerIndex].triggerCountdown = triggerCountdown; + _entries[timerIndex].doneFlag = false; _entries[timerIndex].field_13 = 0; _entries[timerIndex].dynamicHotspotIndex = -1; _entries[timerIndex].entries.count = 0; @@ -589,13 +589,14 @@ bool MadsSequenceList::loadSprites(int timerIndex) { int idx = -1; _owner._spriteSlots.deleteTimer(timerIndex); - if (seqEntry.field_25 != 0) { + if (seqEntry.doneFlag) { remove(timerIndex); return false; } if (seqEntry.spriteListIndex == -1) { - seqEntry.field_25 = -1; + // Doesn't have an associated sprite anymore, so mark as done + seqEntry.doneFlag = true; } else if ((slotIndex = _owner._spriteSlots.getIndex()) >= 0) { MadsSpriteSlot &spriteSlot = _owner._spriteSlots[slotIndex]; setSpriteSlot(timerIndex, spriteSlot); @@ -631,17 +632,17 @@ bool MadsSequenceList::loadSprites(int timerIndex) { if (seqEntry.frameIndex >= seqEntry.frameStart) { if (seqEntry.frameIndex > seqEntry.numSprites) { result = true; - if (seqEntry.animType != ANIMTYPE_CYCLED) { - // Keep index from exceeding maximum allowed + if (seqEntry.animType == ANIMTYPE_CYCLED) { + // Reset back to the starting frame (cyclic) seqEntry.frameIndex = seqEntry.frameStart; } else { - // Switch into reverse + // Switch into reverse mode seqEntry.frameIndex = seqEntry.numSprites - 1; seqEntry.frameInc = -1; } } } else { - // Currently in reverse mode + // Currently in reverse mode and moved past starting frame result = true; if (seqEntry.animType == ANIMTYPE_CYCLED) @@ -655,13 +656,13 @@ bool MadsSequenceList::loadSprites(int timerIndex) { } } - if (result && (seqEntry.field_24 != 0)) { - if (--seqEntry.field_24 != 0) - seqEntry.field_25 = -1; + if (result && (seqEntry.triggerCountdown != 0)) { + if (--seqEntry.triggerCountdown == 0) + seqEntry.doneFlag = true; } } else { - // Out of sprite slots - seqEntry.field_25 = -1; + // Out of sprite display slots, so mark entry as done + seqEntry.doneFlag = true; } if (seqEntry.entries.count > 0) { @@ -669,7 +670,7 @@ bool MadsSequenceList::loadSprites(int timerIndex) { switch (seqEntry.entries.mode[i]) { case SM_0: case SM_1: - if (((seqEntry.entries.mode[i] == SM_0) && (seqEntry.field_25 != 0)) || + if (((seqEntry.entries.mode[i] == SM_0) && seqEntry.doneFlag) || ((seqEntry.entries.mode[i] == SM_1) && result)) idx = i; break; @@ -702,18 +703,18 @@ void MadsSequenceList::tick() { if ((_owner._abortTimers2 == 0) && (_owner._abortTimers != 0)) break; - MadsSequenceEntry &timerEntry = _entries[idx]; + MadsSequenceEntry &seqEntry = _entries[idx]; uint32 currentTimer = _madsVm->_currentTimer; - if (!timerEntry.active || (currentTimer < timerEntry.timeout)) + if (!seqEntry.active || (currentTimer < seqEntry.timeout)) continue; // Set the next timeout for the timer entry - timerEntry.timeout = currentTimer + timerEntry.numTicks; + seqEntry.timeout = currentTimer + seqEntry.numTicks; // Action the sprite if (loadSprites(idx)) { - timerEntry.timeout += timerEntry.extraTicks; + seqEntry.timeout += seqEntry.extraTicks; } } } diff --git a/engines/m4/mads_views.h b/engines/m4/mads_views.h index 224acdfb51..926702a80b 100644 --- a/engines/m4/mads_views.h +++ b/engines/m4/mads_views.h @@ -236,7 +236,7 @@ public: void reset(); }; -enum SpriteAnimType {ANIMTYPE_SINGLE_DIRECTION = 1, ANIMTYPE_CYCLED = 2}; +enum SpriteAnimType {ANIMTYPE_CYCLED = 1, ANIMTYPE_REVERSIBLE = 2}; enum SequenceSubEntryMode {SM_0 = 0, SM_1 = 1, SM_FRAME_INDEX = 2}; @@ -272,8 +272,8 @@ struct MadsSequenceEntry { int width; int height; - int field_24; - int field_25; + int triggerCountdown; + bool doneFlag; MadsSequenceSubEntries entries; AbortTimerMode abortMode; @@ -295,7 +295,7 @@ public: MadsSequenceEntry &operator[](int index) { return _entries[index]; } void clear(); bool addSubEntry(int index, SequenceSubEntryMode mode, int frameIndex, int abortVal); - int add(int spriteListIndex, int v0, int v1, char field_24, int timeoutTicks, int extraTicks, int numTicks, + int add(int spriteListIndex, int v0, int v1, int triggerCountdown, int delayTicks, int extraTicks, int numTicks, int height, int width, char field_12, char scale, uint8 depth, int frameInc, SpriteAnimType animType, int numSprites, int frameStart); void remove(int timerIndex); |