diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/animator_hof.cpp | 50 | ||||
-rw-r--r-- | engines/kyra/animator_mr.cpp | 48 | ||||
-rw-r--r-- | engines/kyra/animator_v1.cpp | 114 | ||||
-rw-r--r-- | engines/kyra/animator_v1.h | 52 | ||||
-rw-r--r-- | engines/kyra/animator_v2.cpp | 64 | ||||
-rw-r--r-- | engines/kyra/kyra_hof.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/kyra_hof.h | 6 | ||||
-rw-r--r-- | engines/kyra/kyra_mr.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/kyra_mr.h | 7 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.h | 8 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.h | 19 | ||||
-rw-r--r-- | engines/kyra/scene_v1.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/script_v1.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/sprites.cpp | 2 |
16 files changed, 183 insertions, 207 deletions
diff --git a/engines/kyra/animator_hof.cpp b/engines/kyra/animator_hof.cpp index 0d234e8987..b4ab4383d0 100644 --- a/engines/kyra/animator_hof.cpp +++ b/engines/kyra/animator_hof.cpp @@ -318,56 +318,6 @@ void KyraEngine_HoF::drawCharacterAnimObject(AnimObj *obj, int x, int y, int lay _screen->drawShape(2, getShapePtr(obj->shapeIndex1), x, y, 2, obj->flags | 4, layer, _charScale, _charScale); } -void KyraEngine_HoF::addItemToAnimList(int item) { - debugC(9, kDebugLevelAnimator, "KyraEngine_HoF::addItemToAnimList(%d)", item); - restorePage3(); - - AnimObj *animObj = &_animObjects[11+item]; - - animObj->enabled = 1; - animObj->needRefresh = 1; - animObj->specialRefresh = 1; - - int itemId = _itemList[item].id; - - animObj->xPos2 = animObj->xPos1 = _itemList[item].x; - animObj->yPos2 = animObj->yPos1 = _itemList[item].y; - - animObj->shapePtr = getShapePtr(64+itemId); - animObj->shapeIndex2 = animObj->shapeIndex1 = 64+itemId; - - int scaleY, scaleX; - scaleY = scaleX = getScale(animObj->xPos1, animObj->yPos1); - - uint8 *shapePtr = getShapePtr(64+itemId); - animObj->xPos3 = (animObj->xPos2 -= (_screen->getShapeScaledWidth(shapePtr, scaleX) >> 1)); - animObj->yPos3 = (animObj->yPos2 -= _screen->getShapeScaledHeight(shapePtr, scaleY)); - - animObj->width2 = animObj->height2 = 0; - - _animList = addToAnimListSorted(_animList, animObj); - animObj->needRefresh = 1; - animObj->specialRefresh = 1; -} - -void KyraEngine_HoF::deleteItemAnimEntry(int item) { - debugC(9, kDebugLevelAnimator, "KyraEngine_HoF::deleteItemAnimEntry(%d)", item); - AnimObj *animObj = &_animObjects[11+item]; - - restorePage3(); - - animObj->shapePtr = 0; - animObj->shapeIndex1 = 0xFFFF; - animObj->shapeIndex2 = 0xFFFF; - animObj->needRefresh = 1; - animObj->specialRefresh = 1; - - refreshAnimObjectsIfNeed(); - - animObj->enabled = 0; - _animList = deleteAnimListEntry(_animList, animObj); -} - void KyraEngine_HoF::setCharacterAnimDim(int w, int h) { debugC(9, kDebugLevelAnimator, "KyraEngine_HoF::setCharacterAnimDim(%d, %d)", w, h); restorePage3(); diff --git a/engines/kyra/animator_mr.cpp b/engines/kyra/animator_mr.cpp index 18ed258276..c51989ae67 100644 --- a/engines/kyra/animator_mr.cpp +++ b/engines/kyra/animator_mr.cpp @@ -431,53 +431,5 @@ void KyraEngine_MR::showIdleAnim() { _nextIdleType = !_nextIdleType; } -void KyraEngine_MR::addItemToAnimList(int item) { - debugC(9, kDebugLevelAnimator, "KyraEngine_MR::addItemToAnimList(%d)", item); - restorePage3(); - - AnimObj *animObj = &_animObjects[17+item]; - - animObj->enabled = 1; - animObj->needRefresh = 1; - - int itemId = _itemList[item].id; - - animObj->xPos2 = animObj->xPos1 = _itemList[item].x; - animObj->yPos2 = animObj->yPos1 = _itemList[item].y; - - animObj->shapePtr = getShapePtr(248+itemId); - animSetupPaletteEntry(animObj); - animObj->shapeIndex2 = animObj->shapeIndex1 = 248+itemId; - - int scaleY, scaleX; - scaleY = scaleX = getScale(animObj->xPos1, animObj->yPos1); - - uint8 *shapePtr = getShapePtr(248+itemId); - animObj->xPos3 = (animObj->xPos2 -= (_screen->getShapeScaledWidth(shapePtr, scaleX) >> 1)); - animObj->yPos3 = (animObj->yPos2 -= _screen->getShapeScaledHeight(shapePtr, scaleY)); - - animObj->width2 = animObj->height2 = 0; - - _animList = addToAnimListSorted(_animList, animObj); - animObj->needRefresh = 1; -} - -void KyraEngine_MR::deleteItemAnimEntry(int item) { - debugC(9, kDebugLevelAnimator, "KyraEngine_MR::deleteItemAnimEntry(%d)", item); - AnimObj *animObj = &_animObjects[17+item]; - - restorePage3(); - - animObj->shapePtr = 0; - animObj->shapeIndex1 = 0xFFFF; - animObj->shapeIndex2 = 0xFFFF; - animObj->needRefresh = 1; - - refreshAnimObjectsIfNeed(); - - animObj->enabled = 0; - _animList = deleteAnimListEntry(_animList, animObj); -} - } // end of namespace Kyra diff --git a/engines/kyra/animator_v1.cpp b/engines/kyra/animator_v1.cpp index 69dc473d32..ea56efd9fb 100644 --- a/engines/kyra/animator_v1.cpp +++ b/engines/kyra/animator_v1.cpp @@ -33,7 +33,7 @@ #include "common/system.h" namespace Kyra { -ScreenAnimator::ScreenAnimator(KyraEngine_v1 *vm, OSystem *system) { +Animator_v1::Animator_v1(KyraEngine_v1 *vm, OSystem *system) { _vm = vm; _screen = vm->screen(); _initOk = false; @@ -48,14 +48,14 @@ ScreenAnimator::ScreenAnimator(KyraEngine_v1 *vm, OSystem *system) { memset(_actorBkgBackUp[1], 0, _screen->getRectSize(8, 69)); } -ScreenAnimator::~ScreenAnimator() { +Animator_v1::~Animator_v1() { close(); delete [] _actorBkgBackUp[0]; delete [] _actorBkgBackUp[1]; } -void ScreenAnimator::init(int actors_, int items_, int sprites_) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::init(%d, %d, %d)", actors_, items_, sprites_); +void Animator_v1::init(int actors_, int items_, int sprites_) { + debugC(9, kDebugLevelAnimator, "Animator_v1::init(%d, %d, %d)", actors_, items_, sprites_); _screenObjects = new AnimObject[actors_ + items_ + sprites_]; assert(_screenObjects); memset(_screenObjects, 0, sizeof(AnimObject) * (actors_ + items_ + sprites_)); @@ -67,8 +67,8 @@ void ScreenAnimator::init(int actors_, int items_, int sprites_) { _initOk = true; } -void ScreenAnimator::close() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::close()"); +void Animator_v1::close() { + debugC(9, kDebugLevelAnimator, "Animator_v1::close()"); if (_initOk) { _initOk = false; delete [] _screenObjects; @@ -76,7 +76,7 @@ void ScreenAnimator::close() { } } -void ScreenAnimator::initAnimStateList() { +void Animator_v1::initAnimStateList() { AnimObject *animStates = _screenObjects; animStates[0].index = 0; animStates[0].active = 1; @@ -118,8 +118,8 @@ void ScreenAnimator::initAnimStateList() { } } -void ScreenAnimator::preserveAllBackgrounds() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::preserveAllBackgrounds()"); +void Animator_v1::preserveAllBackgrounds() { + debugC(9, kDebugLevelAnimator, "Animator_v1::preserveAllBackgrounds()"); uint8 curPage = _screen->_curPage; _screen->_curPage = 2; @@ -134,8 +134,8 @@ void ScreenAnimator::preserveAllBackgrounds() { _screen->_curPage = curPage; } -void ScreenAnimator::flagAllObjectsForBkgdChange() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::flagAllObjectsForBkgdChange()"); +void Animator_v1::flagAllObjectsForBkgdChange() { + debugC(9, kDebugLevelAnimator, "Animator_v1::flagAllObjectsForBkgdChange()"); AnimObject *curObject = _objectQueue; while (curObject) { curObject->bkgdChangeFlag = 1; @@ -143,8 +143,8 @@ void ScreenAnimator::flagAllObjectsForBkgdChange() { } } -void ScreenAnimator::flagAllObjectsForRefresh() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::flagAllObjectsForRefresh()"); +void Animator_v1::flagAllObjectsForRefresh() { + debugC(9, kDebugLevelAnimator, "Animator_v1::flagAllObjectsForRefresh()"); AnimObject *curObject = _objectQueue; while (curObject) { curObject->refreshFlag = 1; @@ -152,8 +152,8 @@ void ScreenAnimator::flagAllObjectsForRefresh() { } } -void ScreenAnimator::restoreAllObjectBackgrounds() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::restoreAllObjectBackground()"); +void Animator_v1::restoreAllObjectBackgrounds() { + debugC(9, kDebugLevelAnimator, "Animator_v1::restoreAllObjectBackground()"); AnimObject *curObject = _objectQueue; _screen->_curPage = 2; @@ -169,8 +169,8 @@ void ScreenAnimator::restoreAllObjectBackgrounds() { _screen->_curPage = 0; } -void ScreenAnimator::preserveAnyChangedBackgrounds() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::preserveAnyChangedBackgrounds()"); +void Animator_v1::preserveAnyChangedBackgrounds() { + debugC(9, kDebugLevelAnimator, "Animator_v1::preserveAnyChangedBackgrounds()"); AnimObject *curObject = _objectQueue; _screen->_curPage = 2; @@ -185,8 +185,8 @@ void ScreenAnimator::preserveAnyChangedBackgrounds() { _screen->_curPage = 0; } -void ScreenAnimator::preserveOrRestoreBackground(AnimObject *obj, bool restore) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::preserveOrRestoreBackground(%p, %d)", (const void *)obj, restore); +void Animator_v1::preserveOrRestoreBackground(AnimObject *obj, bool restore) { + debugC(9, kDebugLevelAnimator, "Animator_v1::preserveOrRestoreBackground(%p, %d)", (const void *)obj, restore); int x = 0, y = 0, width = obj->width, height = obj->height; if (restore) { @@ -217,8 +217,8 @@ void ScreenAnimator::preserveOrRestoreBackground(AnimObject *obj, bool restore) _screen->copyRegionToBuffer(_screen->_curPage, x << 3, y, width << 3, height, obj->background); } -void ScreenAnimator::prepDrawAllObjects() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::prepDrawAllObjects()"); +void Animator_v1::prepDrawAllObjects() { + debugC(9, kDebugLevelAnimator, "Animator_v1::prepDrawAllObjects()"); AnimObject *curObject = _objectQueue; int drawPage = 2; int flagUnk1 = 0, flagUnk2 = 0, flagUnk3 = 0; @@ -363,8 +363,8 @@ void ScreenAnimator::prepDrawAllObjects() { } } -void ScreenAnimator::copyChangedObjectsForward(int refreshFlag) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::copyChangedObjectsForward(%d)", refreshFlag); +void Animator_v1::copyChangedObjectsForward(int refreshFlag) { + debugC(9, kDebugLevelAnimator, "Animator_v1::copyChangedObjectsForward(%d)", refreshFlag); for (AnimObject *curObject = _objectQueue; curObject; curObject = curObject->nextAnimObject) { if (curObject->active) { @@ -404,16 +404,16 @@ void ScreenAnimator::copyChangedObjectsForward(int refreshFlag) { } } -void ScreenAnimator::updateAllObjectShapes() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::updateAllObjectShapes()"); +void Animator_v1::updateAllObjectShapes() { + debugC(9, kDebugLevelAnimator, "Animator_v1::updateAllObjectShapes()"); restoreAllObjectBackgrounds(); preserveAnyChangedBackgrounds(); prepDrawAllObjects(); copyChangedObjectsForward(0); } -void ScreenAnimator::animRemoveGameItem(int index) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::animRemoveGameItem(%d)", index); +void Animator_v1::animRemoveGameItem(int index) { + debugC(9, kDebugLevelAnimator, "Animator_v1::animRemoveGameItem(%d)", index); restoreAllObjectBackgrounds(); AnimObject *animObj = &_items[index]; @@ -427,8 +427,8 @@ void ScreenAnimator::animRemoveGameItem(int index) { objectRemoveQueue(_objectQueue, animObj); } -void ScreenAnimator::animAddGameItem(int index, uint16 sceneId) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::animRemoveGameItem(%d, %d)", index, sceneId); +void Animator_v1::animAddGameItem(int index, uint16 sceneId) { + debugC(9, kDebugLevelAnimator, "Animator_v1::animRemoveGameItem(%d, %d)", index, sceneId); restoreAllObjectBackgrounds(); assert(sceneId < _vm->_roomTableSize); Room *currentRoom = &_vm->_roomTable[sceneId]; @@ -453,8 +453,8 @@ void ScreenAnimator::animAddGameItem(int index, uint16 sceneId) { animObj->bkgdChangeFlag = 1; } -void ScreenAnimator::animAddNPC(int character) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::animAddNPC(%d)", character); +void Animator_v1::animAddNPC(int character) { + debugC(9, kDebugLevelAnimator, "Animator_v1::animAddNPC(%d)", character); restoreAllObjectBackgrounds(); AnimObject *animObj = &_actors[character]; const Character *ch = &_vm->_characterList[character]; @@ -478,8 +478,8 @@ void ScreenAnimator::animAddNPC(int character) { animObj->bkgdChangeFlag = 1; } -AnimObject *ScreenAnimator::objectRemoveQueue(AnimObject *queue, AnimObject *rem) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::objectRemoveQueue(%p, %p)", (const void *)queue, (const void *)rem); +Animator_v1::AnimObject *Animator_v1::objectRemoveQueue(AnimObject *queue, AnimObject *rem) { + debugC(9, kDebugLevelAnimator, "Animator_v1::objectRemoveQueue(%p, %p)", (const void *)queue, (const void *)rem); AnimObject *cur = queue; AnimObject *prev = queue; @@ -512,14 +512,14 @@ AnimObject *ScreenAnimator::objectRemoveQueue(AnimObject *queue, AnimObject *rem return queue; } -AnimObject *ScreenAnimator::objectAddHead(AnimObject *queue, AnimObject *head) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::objectAddHead(%p, %p)", (const void *)queue, (const void *)head); +Animator_v1::AnimObject *Animator_v1::objectAddHead(AnimObject *queue, AnimObject *head) { + debugC(9, kDebugLevelAnimator, "Animator_v1::objectAddHead(%p, %p)", (const void *)queue, (const void *)head); head->nextAnimObject = queue; return head; } -AnimObject *ScreenAnimator::objectQueue(AnimObject *queue, AnimObject *add) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::objectQueue(%p, %p)", (const void *)queue, (const void *)add); +Animator_v1::AnimObject *Animator_v1::objectQueue(AnimObject *queue, AnimObject *add) { + debugC(9, kDebugLevelAnimator, "Animator_v1::objectQueue(%p, %p)", (const void *)queue, (const void *)add); if (add->drawY <= queue->drawY || !queue) { add->nextAnimObject = queue; return add; @@ -544,16 +544,16 @@ AnimObject *ScreenAnimator::objectQueue(AnimObject *queue, AnimObject *add) { return queue; } -void ScreenAnimator::addObjectToQueue(AnimObject *object) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::addObjectToQueue(%p)", (const void *)object); +void Animator_v1::addObjectToQueue(AnimObject *object) { + debugC(9, kDebugLevelAnimator, "Animator_v1::addObjectToQueue(%p)", (const void *)object); if (!_objectQueue) _objectQueue = objectAddHead(0, object); else _objectQueue = objectQueue(_objectQueue, object); } -void ScreenAnimator::refreshObject(AnimObject *object) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::refreshObject(%p)", (const void *)object); +void Animator_v1::refreshObject(AnimObject *object) { + debugC(9, kDebugLevelAnimator, "Animator_v1::refreshObject(%p)", (const void *)object); _objectQueue = objectRemoveQueue(_objectQueue, object); if (_objectQueue) _objectQueue = objectQueue(_objectQueue, object); @@ -561,8 +561,8 @@ void ScreenAnimator::refreshObject(AnimObject *object) { _objectQueue = objectAddHead(0, object); } -void ScreenAnimator::makeBrandonFaceMouse() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::makeBrandonFaceMouse()"); +void Animator_v1::makeBrandonFaceMouse() { + debugC(9, kDebugLevelAnimator, "Animator_v1::makeBrandonFaceMouse()"); Common::Point mouse = _vm->getMousePos(); if (mouse.x >= _vm->_currentCharacter->x1) _vm->_currentCharacter->facing = 3; @@ -572,22 +572,22 @@ void ScreenAnimator::makeBrandonFaceMouse() { updateAllObjectShapes(); } -int16 ScreenAnimator::fetchAnimWidth(const uint8 *shape, int16 mult) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::fetchAnimWidth(%p, %d)", (const void *)shape, mult); +int16 Animator_v1::fetchAnimWidth(const uint8 *shape, int16 mult) { + debugC(9, kDebugLevelAnimator, "Animator_v1::fetchAnimWidth(%p, %d)", (const void *)shape, mult); if (_vm->gameFlags().useAltShapeHeader) shape += 2; return (((int16)READ_LE_UINT16((shape+3))) * mult) >> 8; } -int16 ScreenAnimator::fetchAnimHeight(const uint8 *shape, int16 mult) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::fetchAnimHeight(%p, %d)", (const void *)shape, mult); +int16 Animator_v1::fetchAnimHeight(const uint8 *shape, int16 mult) { + debugC(9, kDebugLevelAnimator, "Animator_v1::fetchAnimHeight(%p, %d)", (const void *)shape, mult); if (_vm->gameFlags().useAltShapeHeader) shape += 2; return (int16)(((int8)*(shape+2)) * mult) >> 8; } -void ScreenAnimator::setBrandonAnimSeqSize(int width, int height) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::setBrandonAnimSeqSize(%d, %d)", width, height); +void Animator_v1::setBrandonAnimSeqSize(int width, int height) { + debugC(9, kDebugLevelAnimator, "Animator_v1::setBrandonAnimSeqSize(%d, %d)", width, height); restoreAllObjectBackgrounds(); _brandonAnimSeqSizeWidth = _actors[0].width; _brandonAnimSeqSizeHeight = _actors[0].height; @@ -596,16 +596,16 @@ void ScreenAnimator::setBrandonAnimSeqSize(int width, int height) { preserveAllBackgrounds(); } -void ScreenAnimator::resetBrandonAnimSeqSize() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::resetBrandonAnimSeqSize()"); +void Animator_v1::resetBrandonAnimSeqSize() { + debugC(9, kDebugLevelAnimator, "Animator_v1::resetBrandonAnimSeqSize()"); restoreAllObjectBackgrounds(); _actors[0].width = _brandonAnimSeqSizeWidth; _actors[0].height = _brandonAnimSeqSizeHeight; preserveAllBackgrounds(); } -void ScreenAnimator::animRefreshNPC(int character) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::animRefreshNPC(%d)", character); +void Animator_v1::animRefreshNPC(int character) { + debugC(9, kDebugLevelAnimator, "Animator_v1::animRefreshNPC(%d)", character); AnimObject *animObj = &_actors[character]; Character *ch = &_vm->characterList()[character]; @@ -663,8 +663,8 @@ void ScreenAnimator::animRefreshNPC(int character) { refreshObject(animObj); } -void ScreenAnimator::setCharacterDefaultFrame(int character) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::setCharacterDefaultFrame()"); +void Animator_v1::setCharacterDefaultFrame(int character) { + debugC(9, kDebugLevelAnimator, "Animator_v1::setCharacterDefaultFrame()"); static uint16 initFrameTable[] = { 7, 41, 77, 0, 0 }; @@ -676,8 +676,8 @@ void ScreenAnimator::setCharacterDefaultFrame(int character) { // edit->unk6 = 1; } -void ScreenAnimator::setCharactersHeight() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::setCharactersHeight()"); +void Animator_v1::setCharactersHeight() { + debugC(9, kDebugLevelAnimator, "Animator_v1::setCharactersHeight()"); static int8 initHeightTable[] = { 48, 40, 48, 47, 56, 44, 42, 47, 38, 35, diff --git a/engines/kyra/animator_v1.h b/engines/kyra/animator_v1.h index 7bfb872651..3ae0b23da4 100644 --- a/engines/kyra/animator_v1.h +++ b/engines/kyra/animator_v1.h @@ -23,38 +23,38 @@ * */ -#ifndef KYRA_ANIMATOR_H -#define KYRA_ANIMATOR_H +#ifndef KYRA_ANIMATOR_V1_H +#define KYRA_ANIMATOR_V1_H namespace Kyra { class KyraEngine_v1; class Screen; -struct AnimObject { - uint8 index; - uint32 active; - uint32 refreshFlag; - uint32 bkgdChangeFlag; - bool disable; - uint32 flags; - int16 drawY; - uint8 *sceneAnimPtr; - int16 animFrameNumber; - uint8 *background; - uint16 rectSize; - int16 x1, y1; - int16 x2, y2; - uint16 width; - uint16 height; - uint16 width2; - uint16 height2; - AnimObject *nextAnimObject; -}; - -class ScreenAnimator { +class Animator_v1 { public: - ScreenAnimator(KyraEngine_v1 *vm, OSystem *system); - virtual ~ScreenAnimator(); + struct AnimObject { + uint8 index; + uint32 active; + uint32 refreshFlag; + uint32 bkgdChangeFlag; + bool disable; + uint32 flags; + int16 drawY; + uint8 *sceneAnimPtr; + int16 animFrameNumber; + uint8 *background; + uint16 rectSize; + int16 x1, y1; + int16 x2, y2; + uint16 width; + uint16 height; + uint16 width2; + uint16 height2; + AnimObject *nextAnimObject; + }; + + Animator_v1(KyraEngine_v1 *vm, OSystem *system); + virtual ~Animator_v1(); operator bool() const { return _initOk; } diff --git a/engines/kyra/animator_v2.cpp b/engines/kyra/animator_v2.cpp index ed2c37dae2..10f7b02579 100644 --- a/engines/kyra/animator_v2.cpp +++ b/engines/kyra/animator_v2.cpp @@ -24,13 +24,23 @@ */ #include "kyra/kyra_v2.h" -#include "kyra/screen.h" +#include "kyra/screen_v2.h" #include "kyra/wsamovie.h" #include "common/endian.h" namespace Kyra { +void KyraEngine_v2::allocAnimObjects(int actors, int anims, int items) { + debugC(9, kDebugLevelAnimator, "KyraEngine_v2::allocAnimObjects(%d, %d, %d)", actors, anims, items); + _animObjects = new AnimObj[actors+anims+items]; + assert(_animObjects); + + _animActor = _animObjects; + _animAnims = _animObjects + actors; + _animItems = _animObjects + actors + anims; +} + KyraEngine_v2::AnimObj *KyraEngine_v2::initAnimList(AnimObj *list, AnimObj *entry) { debugC(9, kDebugLevelAnimator, "KyraEngine_v2::initAnimList(%p, %p)", (const void*)list, (const void*)entry); entry->nextObject = list; @@ -135,5 +145,57 @@ void KyraEngine_v2::flagAnimObjsSpecialRefresh() { curEntry->specialRefresh = 1; } +void KyraEngine_v2::addItemToAnimList(int item) { + debugC(9, kDebugLevelAnimator, "KyraEngine_v2::addItemToAnimList(%d)", item); + assert(item < _itemListSize); + + restorePage3(); + + AnimObj *animObj = _animItems + item; + + animObj->enabled = 1; + animObj->needRefresh = 1; + + int itemId = _itemList[item].id; + + animObj->xPos2 = animObj->xPos1 = _itemList[item].x; + animObj->yPos2 = animObj->yPos1 = _itemList[item].y; + + animObj->shapePtr = getShapePtr(getItemShape(itemId)); + animSetupPaletteEntry(animObj); + animObj->shapeIndex2 = animObj->shapeIndex1 = getItemShape(itemId); + + int scaleY, scaleX; + scaleY = scaleX = getScale(animObj->xPos1, animObj->yPos1); + + uint8 *shapePtr = getShapePtr(getItemShape(itemId)); + animObj->xPos3 = (animObj->xPos2 -= (screen_v2()->getShapeScaledWidth(shapePtr, scaleX) >> 1)); + animObj->yPos3 = (animObj->yPos2 -= screen_v2()->getShapeScaledHeight(shapePtr, scaleY)); + + animObj->width2 = animObj->height2 = 0; + + _animList = addToAnimListSorted(_animList, animObj); + animObj->needRefresh = 1; +} + +void KyraEngine_v2::deleteItemAnimEntry(int item) { + debugC(9, kDebugLevelAnimator, "KyraEngine_v2::deleteItemAnimEntry(%d)", item); + assert(item < _itemListSize); + + AnimObj *animObj = _animItems + item; + + restorePage3(); + + animObj->shapePtr = 0; + animObj->shapeIndex1 = 0xFFFF; + animObj->shapeIndex2 = 0xFFFF; + animObj->needRefresh = 1; + + refreshAnimObjectsIfNeed(); + + animObj->enabled = 0; + _animList = deleteAnimListEntry(_animList, animObj); +} + } // end of namespace Kyra diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp index cb56913e72..347e5f35a4 100644 --- a/engines/kyra/kyra_hof.cpp +++ b/engines/kyra/kyra_hof.cpp @@ -71,7 +71,6 @@ KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEn _currentTalkFile = 0; _lastSfxTrack = -1; _handItemSet = -1; - memset(_animObjects, 0, sizeof(_animObjects)); _unkHandleSceneChangeFlag = false; _pathfinderFlag = 0; _mouseX = _mouseY = 0; @@ -282,10 +281,13 @@ void KyraEngine_HoF::startup() { _trackMap = _dosTrackMap; _trackMapSize = _dosTrackMapSize; + allocAnimObjects(1, 10, 30); + _screen->_curPage = 0; delete [] _mouseSHPBuf; _mouseSHPBuf = 0; + _gameShapes.clear(); memset(_sceneShapeTable, 0, sizeof(_sceneShapeTable)); _gamePlayBuffer = new uint8[46080]; _unkBuf500Bytes = new uint8[500]; diff --git a/engines/kyra/kyra_hof.h b/engines/kyra/kyra_hof.h index 73257920a0..f05ab77455 100644 --- a/engines/kyra/kyra_hof.h +++ b/engines/kyra/kyra_hof.h @@ -369,6 +369,8 @@ protected: ShapeDesc *_shapeDescTable; + int getItemShape(int item) const { return 64+item; } + void loadCharacterShapes(int shapes); void loadInventoryShapes(); @@ -401,7 +403,6 @@ protected: uint8 *_gamePlayBuffer; void restorePage3(); - AnimObj _animObjects[42]; void clearAnimObjects(); void refreshAnimObjects(int force); @@ -416,9 +417,6 @@ protected: void updateCharacterAnim(int); void updateSceneAnim(int anim, int newFrame); - void addItemToAnimList(int item); - void deleteItemAnimEntry(int item); - int _animObj0Width, _animObj0Height; void setCharacterAnimDim(int w, int h); void resetCharacterAnimDim(); diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp index 71f9c8aa86..3fe27fe86d 100644 --- a/engines/kyra/kyra_mr.cpp +++ b/engines/kyra/kyra_mr.cpp @@ -53,7 +53,6 @@ KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngi _gamePlayBuffer = 0; _interface = _interfaceCommandLine = 0; _costPalBuffer = 0; - _animObjects = 0; memset(_sceneShapes, 0, sizeof(_sceneShapes)); memset(_sceneAnimMovie, 0, sizeof(_sceneAnimMovie)); _gfxBackUpRect = 0; @@ -148,7 +147,6 @@ KyraEngine_MR::~KyraEngine_MR() { delete [] _interface; delete [] _interfaceCommandLine; delete [] _costPalBuffer; - delete [] _animObjects; for (uint i = 0; i < ARRAYSIZE(_sceneShapes); ++i) delete [] _sceneShapes[i]; @@ -532,7 +530,7 @@ void KyraEngine_MR::startup() { musicUpdate(0); _costPalBuffer = new uint8[864]; //XXX - _animObjects = new AnimObj[67]; + allocAnimObjects(1, 16, 50); musicUpdate(0); diff --git a/engines/kyra/kyra_mr.h b/engines/kyra/kyra_mr.h index ea2c58883e..9b330394e6 100644 --- a/engines/kyra/kyra_mr.h +++ b/engines/kyra/kyra_mr.h @@ -173,8 +173,6 @@ private: uint8 *_gamePlayBuffer; void restorePage3(); - AnimObj *_animObjects; - void clearAnimObjects(); void animSetupPaletteEntry(AnimObj *anim); @@ -201,9 +199,6 @@ private: bool _nextIdleType; void showIdleAnim(); - void addItemToAnimList(int item); - void deleteItemAnimEntry(int item); - // interface uint8 *_interface; uint8 *_interfaceCommandLine; @@ -296,6 +291,8 @@ private: void setMouseCursor(uint16 item); // shapes + int getItemShape(int item) const { return 248+item; } + void initMouseShapes(); void loadCharacterShapes(int newShapes); diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 182f52fa3c..e9bb25fe5f 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -164,7 +164,7 @@ int KyraEngine_v1::init() { assert(_sprites); _seq = new SeqPlayer(this, _system); assert(_seq); - _animator = new ScreenAnimator(this, _system); + _animator = new Animator_v1(this, _system); assert(_animator); _animator->init(5, 11, 12); assert(*_animator); diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h index 1805efc127..50791c3ade 100644 --- a/engines/kyra/kyra_v1.h +++ b/engines/kyra/kyra_v1.h @@ -38,7 +38,7 @@ class SoundDigital; class SeqPlayer; class Sprites; class Debugger; -class ScreenAnimator; +class Animator_v1; class TextDisplayer; class KyraEngine_v1; @@ -108,14 +108,14 @@ struct BeadState { class KyraEngine_v1 : public KyraEngine { friend class MusicPlayer; friend class Debugger_v1; - friend class ScreenAnimator; + friend class Animator_v1; friend class GUI_v1; public: KyraEngine_v1(OSystem *system, const GameFlags &flags); ~KyraEngine_v1(); Screen *screen() { return _screen; } - ScreenAnimator *animator() { return _animator; } + Animator_v1 *animator() { return _animator; } virtual Movie *createWSAMovie(); uint8 **shapes() { return _shapes; } @@ -476,7 +476,7 @@ protected: uint8 _configTextspeed; - ScreenAnimator *_animator; + Animator_v1 *_animator; SeqPlayer *_seq; Sprites *_sprites; Screen_v1 *_screen; diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index 0868f1d16e..0f4a78146b 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -44,6 +44,8 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi memset(&_sceneScriptState, 0, sizeof(_sceneScriptState)); memset(&_sceneScriptData, 0, sizeof(_sceneScriptData)); + + _animObjects = 0; } KyraEngine_v2::~KyraEngine_v2() { @@ -56,6 +58,8 @@ KyraEngine_v2::~KyraEngine_v2() { delete [] _itemList; _emc->unload(&_sceneScriptData); + + delete [] _animObjects; } void KyraEngine_v2::updateInput() { diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index 44647e331e..6a426f3761 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -80,7 +80,7 @@ protected: struct AnimObj { uint16 index; uint16 type; - uint16 enabled; + bool enabled; uint16 needRefresh; uint16 specialRefresh; uint16 animFlags; @@ -99,6 +99,13 @@ protected: AnimObj *nextObject; }; + void allocAnimObjects(int actors, int anims, int items); + AnimObj *_animObjects; + + AnimObj *_animActor; + AnimObj *_animAnims; + AnimObj *_animItems; + bool _drawNoShapeFlag; AnimObj *_animList; @@ -121,12 +128,16 @@ protected: virtual void updateCharacterAnim(int) = 0; virtual void updateSceneAnim(int anim, int newFrame) = 0; - virtual void addItemToAnimList(int item) = 0; - virtual void deleteItemAnimEntry(int item) = 0; + void addItemToAnimList(int item); + void deleteItemAnimEntry(int item); + + virtual void animSetupPaletteEntry(AnimObj *) {} virtual void setCharacterAnimDim(int w, int h) = 0; virtual void resetCharacterAnimDim() = 0; + virtual int getScale(int x, int y) = 0; + // Scene struct SceneDesc { char filename1[10]; @@ -197,6 +208,8 @@ protected: void addShapeToPool(uint8 *shpData, int index); void remShapeFromPool(int idx); + virtual int getItemShape(int item) const = 0; + int _characterShapeFile; virtual void loadCharacterShapes(int shapes) = 0; diff --git a/engines/kyra/scene_v1.cpp b/engines/kyra/scene_v1.cpp index e3af434a5b..c5d1de82a9 100644 --- a/engines/kyra/scene_v1.cpp +++ b/engines/kyra/scene_v1.cpp @@ -615,7 +615,7 @@ void KyraEngine_v1::initSceneObjectList(int brandonAlive) { int startAnimFrame = 0; - AnimObject *curAnimState = _animator->actors(); + Animator_v1::AnimObject *curAnimState = _animator->actors(); curAnimState->active = 1; curAnimState->drawY = _currentCharacter->y1; curAnimState->sceneAnimPtr = _shapes[_currentCharacter->currentAnimFrame]; diff --git a/engines/kyra/script_v1.cpp b/engines/kyra/script_v1.cpp index 6f39e843e9..a258482802 100644 --- a/engines/kyra/script_v1.cpp +++ b/engines/kyra/script_v1.cpp @@ -576,7 +576,7 @@ int KyraEngine_v1::o1_popBrandonIntoScene(EMCState *script) { int yOffset = _defaultShapeTable[0].yOffset; int width = _defaultShapeTable[0].w << 3; int height = _defaultShapeTable[0].h; - AnimObject *curAnim = _animator->actors(); + Animator_v1::AnimObject *curAnim = _animator->actors(); if (changeScaleMode) { curAnim->x1 = _currentCharacter->x1; @@ -994,7 +994,7 @@ int KyraEngine_v1::o1_unhideMobileCharacter(EMCState *script) { int KyraEngine_v1::o1_setCharactersLocation(EMCState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1_setCharactersLocation(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); Character *ch = &_characterList[stackPos(0)]; - AnimObject *animObj = &_animator->actors()[stackPos(0)]; + Animator_v1::AnimObject *animObj = &_animator->actors()[stackPos(0)]; int newScene = stackPos(1); if (_currentCharacter->sceneId == ch->sceneId) { if (_currentCharacter->sceneId != newScene) diff --git a/engines/kyra/sprites.cpp b/engines/kyra/sprites.cpp index 531033f5c4..b54192abae 100644 --- a/engines/kyra/sprites.cpp +++ b/engines/kyra/sprites.cpp @@ -554,7 +554,7 @@ void Sprites::loadSceneShapes() { void Sprites::refreshSceneAnimObject(uint8 animNum, uint8 shapeNum, uint16 x, uint16 y, bool flipX, bool unkFlag) { debugC(9, kDebugLevelSprites, "Sprites::refreshSceneAnimObject(%i, %i, %i, %i, %i, %i", animNum, shapeNum, x, y, flipX, unkFlag); - AnimObject &anim = _vm->animator()->sprites()[animNum]; + Animator_v1::AnimObject &anim = _vm->animator()->sprites()[animNum]; anim.refreshFlag = 1; anim.bkgdChangeFlag = 1; |