From 5681ae1e82ba2c125928ecbfbd937cb187c06aa4 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 7 May 2008 02:56:18 +0000 Subject: Draw order related fixes. This also (finally) fixes the Gob3 draw order glitch (for real, this time) svn-id: r31915 --- engines/gob/inter_v2.cpp | 2 +- engines/gob/mult.h | 4 +- engines/gob/mult_v2.cpp | 100 +++++++++++++++++++++++------------------------ engines/gob/scenery.cpp | 14 ++++--- engines/gob/scenery.h | 6 +-- 5 files changed, 64 insertions(+), 62 deletions(-) diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index be510df08a..2442e4dcf2 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -899,7 +899,7 @@ void Inter_v2::o2_initMult() { if (_terminate) return; - _vm->_mult->_orderArray = new uint8[_vm->_mult->_objCount]; + _vm->_mult->_orderArray = new int8[_vm->_mult->_objCount]; memset(_vm->_mult->_orderArray, 0, _vm->_mult->_objCount * sizeof(int8)); _vm->_mult->_objects = new Mult::Mult_Object[_vm->_mult->_objCount]; memset(_vm->_mult->_objects, 0, diff --git a/engines/gob/mult.h b/engines/gob/mult.h index c283191ec8..aaf2e2826c 100644 --- a/engines/gob/mult.h +++ b/engines/gob/mult.h @@ -40,7 +40,7 @@ public: uint8 layer; uint8 frame; int8 animType; - uint8 order; + int8 order; int8 isPaused; int8 isStatic; int8 maxTick; @@ -229,7 +229,7 @@ public: int16 *_renderData; Mult_Object **_renderObjs; - uint8 *_orderArray; + int8 *_orderArray; SurfaceDesc::Ptr _animSurf; int16 _animLeft; diff --git a/engines/gob/mult_v2.cpp b/engines/gob/mult_v2.cpp index 02211880ba..9045089632 100644 --- a/engines/gob/mult_v2.cpp +++ b/engines/gob/mult_v2.cpp @@ -526,14 +526,14 @@ void Mult_v2::playMultInit() { delete[] _animArrayData; _objects = new Mult_Object[_objCount]; - _orderArray = new uint8[_objCount]; + _orderArray = new int8[_objCount]; _renderObjs = new Mult_Object*[_objCount]; _animArrayX = new int32[_objCount]; _animArrayY = new int32[_objCount]; _animArrayData = new Mult_AnimData[_objCount]; memset(_objects, 0, _objCount * sizeof(Mult_Object)); - memset(_orderArray, 0, _objCount * sizeof(uint8)); + memset(_orderArray, 0, _objCount * sizeof(int8)); memset(_renderObjs, 0, _objCount * sizeof(Mult_Object *)); memset(_animArrayX, 0, _objCount * sizeof(int32)); memset(_animArrayY, 0, _objCount * sizeof(int32)); @@ -768,9 +768,9 @@ void Mult_v2::newCycleAnim(Mult_Object &animObj) { } void Mult_v2::animate() { - uint8 minOrder = 100; - uint8 maxOrder = 0; - uint8 *orderArray; + int8 minOrder = 100; + int8 maxOrder = 0; + int8 *orderArray; int orderArrayPos = 0; int8 animIndices[150]; int numAnims = 0; @@ -952,60 +952,58 @@ void Mult_v2::animate() { Mult_Object &animObj1 = *_renderObjs[orderArray[i]]; Mult_AnimData &animData1 = *(animObj1.pAnimData); - if (!animObj1.needRedraw && !animData1.isStatic) { - for (int j = 0; j < orderArrayPos; j++) { - Mult_Object &animObj2 = *_renderObjs[orderArray[j]]; + if (!animObj1.needRedraw) { - if (!animObj2.needRedraw) - continue; + if (!animData1.isStatic) { + for (int j = 0; j < orderArrayPos; j++) { + Mult_Object &animObj2 = *_renderObjs[orderArray[j]]; - if ((animObj1.newRight >= animObj2.newLeft) && - (animObj2.newRight >= animObj1.newLeft) && - (animObj1.newBottom >= animObj2.newTop) && - (animObj2.newBottom >= animObj1.newTop)) { + if (!animObj2.needRedraw) + continue; - _vm->_scenery->_toRedrawLeft = animObj2.newLeft; - _vm->_scenery->_toRedrawRight = animObj2.newRight; - _vm->_scenery->_toRedrawTop = animObj2.newTop; - _vm->_scenery->_toRedrawBottom = animObj2.newBottom; + if ((animObj1.newRight >= animObj2.newLeft) && + (animObj2.newRight >= animObj1.newLeft) && + (animObj1.newBottom >= animObj2.newTop) && + (animObj2.newBottom >= animObj1.newTop)) { - _vm->_scenery->updateAnim(animData1.layer, animData1.frame, - animData1.animation, 12, *animObj1.pPosX, *animObj1.pPosY, 1); - _vm->_scenery->updateStatic(animData1.order + 1); + _vm->_scenery->_toRedrawLeft = animObj2.newLeft; + _vm->_scenery->_toRedrawRight = animObj2.newRight; + _vm->_scenery->_toRedrawTop = animObj2.newTop; + _vm->_scenery->_toRedrawBottom = animObj2.newBottom; + + _vm->_scenery->updateAnim(animData1.layer, animData1.frame, + animData1.animation, 12, *animObj1.pPosX, *animObj1.pPosY, 1); + _vm->_scenery->updateStatic(animData1.order + 1); + } } } - } else if (!animData1.isStatic) { - _vm->_scenery->updateAnim(animData1.layer, animData1.frame, - animData1.animation, 10, *animObj1.pPosX, *animObj1.pPosY, 1); - - if (_vm->_scenery->_toRedrawLeft != -12345) { - if (_vm->_global->_pressedKeys[0x36]) { - _vm->_video->drawLine(_vm->_draw->_frontSurface, - _vm->_scenery->_toRedrawLeft, _vm->_scenery->_toRedrawTop, - _vm->_scenery->_toRedrawRight, _vm->_scenery->_toRedrawTop, 15); - _vm->_video->drawLine(_vm->_draw->_frontSurface, - _vm->_scenery->_toRedrawLeft, _vm->_scenery->_toRedrawBottom, - _vm->_scenery->_toRedrawRight, _vm->_scenery->_toRedrawBottom, 15); - _vm->_video->drawLine(_vm->_draw->_frontSurface, - _vm->_scenery->_toRedrawLeft, _vm->_scenery->_toRedrawTop, - _vm->_scenery->_toRedrawLeft, _vm->_scenery->_toRedrawBottom, 15); - _vm->_video->drawLine(_vm->_draw->_frontSurface, - _vm->_scenery->_toRedrawRight, _vm->_scenery->_toRedrawTop, - _vm->_scenery->_toRedrawRight, _vm->_scenery->_toRedrawBottom, 15); - } - animObj1.lastLeft = _vm->_scenery->_toRedrawLeft; - animObj1.lastRight = _vm->_scenery->_toRedrawRight; - animObj1.lastTop = _vm->_scenery->_toRedrawTop; - animObj1.lastBottom = _vm->_scenery->_toRedrawBottom; - } else - animObj1.lastLeft = -1; + } else { - _vm->_scenery->_toRedrawLeft = animObj1.newLeft; - _vm->_scenery->_toRedrawRight = animObj1.newRight; - _vm->_scenery->_toRedrawTop = animObj1.newTop; - _vm->_scenery->_toRedrawBottom = animObj1.newBottom; + + if (animData1.isStatic != 0) { + _vm->_scenery->_toRedrawLeft = animObj1.newLeft; + _vm->_scenery->_toRedrawRight = animObj1.newRight; + _vm->_scenery->_toRedrawTop = animObj1.newTop; + _vm->_scenery->_toRedrawBottom = animObj1.newBottom; + } else { + _vm->_scenery->updateAnim(animData1.layer, animData1.frame, + animData1.animation, 10, *animObj1.pPosX, *animObj1.pPosY, 1); + + if (_vm->_scenery->_toRedrawLeft != -12345) { + animObj1.lastLeft = _vm->_scenery->_toRedrawLeft; + animObj1.lastRight = _vm->_scenery->_toRedrawRight; + animObj1.lastTop = _vm->_scenery->_toRedrawTop; + animObj1.lastBottom = _vm->_scenery->_toRedrawBottom; + } else { + animObj1.lastLeft = -1; + } + + } + + _vm->_scenery->updateStatic(animData1.order + 1); + } - _vm->_scenery->updateStatic(animData1.order + 1); + } // Advance animations diff --git a/engines/gob/scenery.cpp b/engines/gob/scenery.cpp index 3f9ec9e6f2..62a4dbad2f 100644 --- a/engines/gob/scenery.cpp +++ b/engines/gob/scenery.cpp @@ -155,9 +155,9 @@ int16 Scenery::loadStatic(char search) { ptr->layers[i].planes = new StaticPlane[ptr->layers[i].planeCount]; for (int j = 0; j < ptr->layers[i].planeCount; ++j) { - ptr->layers[i].planes[j].pictIndex = layerData.readSByte(); - ptr->layers[i].planes[j].pieceIndex = layerData.readSByte(); - ptr->layers[i].planes[j].drawOrder = layerData.readSByte(); + ptr->layers[i].planes[j].pictIndex = layerData.readByte(); + ptr->layers[i].planes[j].pieceIndex = layerData.readByte(); + ptr->layers[i].planes[j].drawOrder = layerData.readByte(); ptr->layers[i].planes[j].destX = layerData.readSint16LE(); ptr->layers[i].planes[j].destY = layerData.readSint16LE(); ptr->layers[i].planes[j].transp = layerData.readSByte(); @@ -278,7 +278,7 @@ void Scenery::renderStatic(int16 scenery, int16 layer) { } planeCount = layerPtr->planeCount; - for (order = 0; order < 40; order++) { + for (order = 0; order < 100; order++) { for (plane = 0, planePtr = layerPtr->planes; plane < planeCount; plane++, planePtr++) { if (planePtr->drawOrder != order) @@ -330,7 +330,7 @@ void Scenery::updateStatic(int16 orderFrom, byte index, byte layer) { planeCount = layerPtr->planeCount; - for (order = orderFrom; order < 40; order++) { + for (order = orderFrom; order < 100; order++) { for (planePtr = layerPtr->planes, plane = 0; plane < planeCount; plane++, planePtr++) { if (planePtr->drawOrder != order) @@ -338,6 +338,10 @@ void Scenery::updateStatic(int16 orderFrom, byte index, byte layer) { pieceIndex = planePtr->pieceIndex; pictIndex = planePtr->pictIndex - 1; + + if ((pictIndex >= _staticPictCount[index]) || (!pictPtr[pictIndex])) + continue; + _vm->_draw->_destSpriteX = planePtr->destX; _vm->_draw->_destSpriteY = planePtr->destY; diff --git a/engines/gob/scenery.h b/engines/gob/scenery.h index a1a1304d4d..03ef84e16d 100644 --- a/engines/gob/scenery.h +++ b/engines/gob/scenery.h @@ -41,9 +41,9 @@ public: } PACKED_STRUCT; struct StaticPlane { - int8 pictIndex; - int8 pieceIndex; - int8 drawOrder; + uint8 pictIndex; + uint8 pieceIndex; + uint8 drawOrder; int16 destX; int16 destY; int8 transp; -- cgit v1.2.3