[Scummvm-git-logs] scummvm master -> 03e0dcdd9cf5ee9d4cf8801dab45619d1eb8ed5b
mgerhardy
martin.gerhardy at gmail.com
Sun Nov 8 12:11:50 UTC 2020
This automated email contains information about 11 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
fa19374e58 CREATE_PROJECT: added .gitignore to create_project cmake part
fde132ea03 TWINE: converted to boolean
0f97c56560 TWINE: reduced scope
12f9ba1bea TWINE: const
62f1335826 TWINE: remove member variables and use them as local vars
ca540d5e6b TWINE: const and converted to boolean
b6750b454e TWINE: const
6f3c9a5e69 TWINE: converted return value to boolean
f4f67faee0 TWINE: fixed a few endian issues in the animation code
60935e83ed TWINE: const and reduced scope in renderer code
03e0dcdd9c TWINE: removed yet another member from renderer class and made it a local var
Commit: fa19374e583489b4ddb177cde74169bbfda0f4e6
https://github.com/scummvm/scummvm/commit/fa19374e583489b4ddb177cde74169bbfda0f4e6
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-08T11:32:59+01:00
Commit Message:
CREATE_PROJECT: added .gitignore to create_project cmake part
Changed paths:
A devtools/create_project/cmake/.gitignore
diff --git a/devtools/create_project/cmake/.gitignore b/devtools/create_project/cmake/.gitignore
new file mode 100644
index 0000000000..eeb1efe45c
--- /dev/null
+++ b/devtools/create_project/cmake/.gitignore
@@ -0,0 +1,3 @@
+/Makefile
+/build
+/create_project*
Commit: fde132ea03c529bf25c61039b4b495f16c374f6c
https://github.com/scummvm/scummvm/commit/fde132ea03c529bf25c61039b4b495f16c374f6c
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-08T11:46:26+01:00
Commit Message:
TWINE: converted to boolean
Changed paths:
engines/twine/collision.cpp
engines/twine/collision.h
engines/twine/extra.cpp
diff --git a/engines/twine/collision.cpp b/engines/twine/collision.cpp
index b2fca42dac..aa436ad5b8 100644
--- a/engines/twine/collision.cpp
+++ b/engines/twine/collision.cpp
@@ -111,9 +111,9 @@ void Collision::reajustActorPosition(int32 brickShape) {
return;
}
- int32 brkX = (collisionX << 9) - 0x100;
- int32 brkY = collisionY << 8;
- int32 brkZ = (collisionZ << 9) - 0x100;
+ const int32 brkX = (collisionX << 9) - 0x100;
+ const int32 brkY = collisionY << 8;
+ const int32 brkZ = (collisionZ << 9) - 0x100;
// double-side stairs
if (brickShape >= kDoubleSideStairsTop1 && brickShape <= kDoubleSideStairsRight2) {
@@ -381,14 +381,12 @@ int32 Collision::checkCollisionWithActors(int32 actorIdx) {
return actor->collision;
}
-void Collision::checkHeroCollisionWithBricks(int32 X, int32 Y, int32 Z, int32 damageMask) {
- int32 brickShape;
+void Collision::checkHeroCollisionWithBricks(int32 x, int32 y, int32 z, int32 damageMask) {
+ int32 brickShape = _engine->_grid->getBrickShape(_engine->_movements->processActorX, _engine->_movements->processActorY, _engine->_movements->processActorZ);
- brickShape = _engine->_grid->getBrickShape(_engine->_movements->processActorX, _engine->_movements->processActorY, _engine->_movements->processActorZ);
-
- _engine->_movements->processActorX += X;
- _engine->_movements->processActorY += Y;
- _engine->_movements->processActorZ += Z;
+ _engine->_movements->processActorX += x;
+ _engine->_movements->processActorY += y;
+ _engine->_movements->processActorZ += z;
if (_engine->_movements->processActorX >= 0 && _engine->_movements->processActorZ >= 0 && _engine->_movements->processActorX <= 0x7E00 && _engine->_movements->processActorZ <= 0x7E00) {
reajustActorPosition(brickShape);
@@ -396,10 +394,10 @@ void Collision::checkHeroCollisionWithBricks(int32 X, int32 Y, int32 Z, int32 da
if (brickShape == kSolid) {
causeActorDamage |= damageMask;
- brickShape = _engine->_grid->getBrickShapeFull(_engine->_movements->processActorX, _engine->_movements->processActorY, _engine->_movements->previousActorZ + Z, _engine->_actor->processActorPtr->boudingBox.y.topRight);
+ brickShape = _engine->_grid->getBrickShapeFull(_engine->_movements->processActorX, _engine->_movements->processActorY, _engine->_movements->previousActorZ + z, _engine->_actor->processActorPtr->boudingBox.y.topRight);
if (brickShape == kSolid) {
- brickShape = _engine->_grid->getBrickShapeFull(X + _engine->_movements->previousActorX, _engine->_movements->processActorY, _engine->_movements->processActorZ, _engine->_actor->processActorPtr->boudingBox.y.topRight);
+ brickShape = _engine->_grid->getBrickShapeFull(x + _engine->_movements->previousActorX, _engine->_movements->processActorY, _engine->_movements->processActorZ, _engine->_actor->processActorPtr->boudingBox.y.topRight);
if (brickShape != kSolid) {
processCollisionX = _engine->_movements->previousActorX;
@@ -415,14 +413,12 @@ void Collision::checkHeroCollisionWithBricks(int32 X, int32 Y, int32 Z, int32 da
_engine->_movements->processActorZ = processCollisionZ;
}
-void Collision::checkActorCollisionWithBricks(int32 X, int32 Y, int32 Z, int32 damageMask) {
- int32 brickShape;
-
- brickShape = _engine->_grid->getBrickShape(_engine->_movements->processActorX, _engine->_movements->processActorY, _engine->_movements->processActorZ);
+void Collision::checkActorCollisionWithBricks(int32 x, int32 y, int32 z, int32 damageMask) {
+ int32 brickShape = _engine->_grid->getBrickShape(_engine->_movements->processActorX, _engine->_movements->processActorY, _engine->_movements->processActorZ);
- _engine->_movements->processActorX += X;
- _engine->_movements->processActorY += Y;
- _engine->_movements->processActorZ += Z;
+ _engine->_movements->processActorX += x;
+ _engine->_movements->processActorY += y;
+ _engine->_movements->processActorZ += z;
if (_engine->_movements->processActorX >= 0 && _engine->_movements->processActorZ >= 0 && _engine->_movements->processActorX <= 0x7E00 && _engine->_movements->processActorZ <= 0x7E00) {
reajustActorPosition(brickShape);
@@ -430,10 +426,10 @@ void Collision::checkActorCollisionWithBricks(int32 X, int32 Y, int32 Z, int32 d
if (brickShape == kSolid) {
causeActorDamage |= damageMask;
- brickShape = _engine->_grid->getBrickShape(_engine->_movements->processActorX, _engine->_movements->processActorY, _engine->_movements->previousActorZ + Z);
+ brickShape = _engine->_grid->getBrickShape(_engine->_movements->processActorX, _engine->_movements->processActorY, _engine->_movements->previousActorZ + z);
if (brickShape == kSolid) {
- brickShape = _engine->_grid->getBrickShape(X + _engine->_movements->previousActorX, _engine->_movements->processActorY, _engine->_movements->processActorZ);
+ brickShape = _engine->_grid->getBrickShape(x + _engine->_movements->previousActorX, _engine->_movements->processActorY, _engine->_movements->processActorZ);
if (brickShape != kSolid) {
processCollisionX = _engine->_movements->previousActorX;
@@ -507,28 +503,28 @@ int32 Collision::checkExtraCollisionWithActors(ExtraListStruct *extra, int32 act
return -1;
}
-int32 Collision::checkExtraCollisionWithBricks(int32 X, int32 Y, int32 Z, int32 oldX, int32 oldY, int32 oldZ) {
+bool Collision::checkExtraCollisionWithBricks(int32 x, int32 y, int32 z, int32 oldX, int32 oldY, int32 oldZ) {
if (_engine->_grid->getBrickShape(oldX, oldY, oldZ)) {
- return 1;
+ return true;
}
- const int32 averageX = ABS(X + oldX) / 2;
- const int32 averageY = ABS(Y + oldY) / 2;
- const int32 averageZ = ABS(Z + oldZ) / 2;
+ const int32 averageX = ABS(x + oldX) / 2;
+ const int32 averageY = ABS(y + oldY) / 2;
+ const int32 averageZ = ABS(z + oldZ) / 2;
if (_engine->_grid->getBrickShape(averageX, averageY, averageZ)) {
- return 1;
+ return true;
}
if (_engine->_grid->getBrickShape(ABS(oldX + averageX) / 2, ABS(oldY + averageY) / 2, ABS(oldZ + averageZ) / 2)) {
- return 1;
+ return true;
}
- if (_engine->_grid->getBrickShape(ABS(X + averageX) / 2, ABS(Y + averageY) / 2, ABS(Z + averageZ) / 2)) {
- return 1;
+ if (_engine->_grid->getBrickShape(ABS(x + averageX) / 2, ABS(y + averageY) / 2, ABS(z + averageZ) / 2)) {
+ return true;
}
- return 0;
+ return false;
}
int32 Collision::checkExtraCollisionWithExtra(ExtraListStruct *extra, int32 extraIdx) {
diff --git a/engines/twine/collision.h b/engines/twine/collision.h
index 71ddd5e752..e383ed17df 100644
--- a/engines/twine/collision.h
+++ b/engines/twine/collision.h
@@ -75,21 +75,21 @@ public:
/**
* Check Hero collision with bricks
- * @param X Hero X coordinate
- * @param Y Hero Y coordinate
- * @param Z Hero Z coordinate
+ * @param x Hero X coordinate
+ * @param y Hero Y coordinate
+ * @param z Hero Z coordinate
* @param damageMask Cause damage mask
*/
- void checkHeroCollisionWithBricks(int32 X, int32 Y, int32 Z, int32 damageMask);
+ void checkHeroCollisionWithBricks(int32 x, int32 y, int32 z, int32 damageMask);
/**
* Check other actor collision with bricks
- * @param X Actor X coordinate
- * @param Y Actor Y coordinate
- * @param Z Actor Z coordinate
+ * @param x Actor X coordinate
+ * @param y Actor Y coordinate
+ * @param z Actor Z coordinate
* @param damageMask Cause damage mask
*/
- void checkActorCollisionWithBricks(int32 X, int32 Y, int32 Z, int32 damageMask);
+ void checkActorCollisionWithBricks(int32 x, int32 y, int32 z, int32 damageMask);
/** Make actor to stop falling */
void stopFalling();
@@ -102,7 +102,7 @@ public:
int32 checkExtraCollisionWithActors(ExtraListStruct *extra, int32 actorIdx);
/** Check extra collision with bricks */
- int32 checkExtraCollisionWithBricks(int32 X, int32 Y, int32 Z, int32 oldX, int32 oldY, int32 oldZ);
+ bool checkExtraCollisionWithBricks(int32 x, int32 y, int32 z, int32 oldX, int32 oldY, int32 oldZ);
/**
* Check extra collision with another extra
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index bf8c1b6013..3247b486e8 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -352,6 +352,7 @@ void Extra::addExtraThrowMagicball(int32 x, int32 y, int32 z, int32 param1, int3
int32 ballStrength = 0;
int32 extraIdx = -1;
+ // TODO: check against MagicballStrengthType
switch (_engine->_gameState->magicLevelIdx) {
case 0:
case 1:
Commit: 0f97c56560394391aaa4c9f0389949e8ba13adab
https://github.com/scummvm/scummvm/commit/0f97c56560394391aaa4c9f0389949e8ba13adab
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-08T11:48:18+01:00
Commit Message:
TWINE: reduced scope
Changed paths:
engines/twine/extra.cpp
diff --git a/engines/twine/extra.cpp b/engines/twine/extra.cpp
index 3247b486e8..70df761754 100644
--- a/engines/twine/extra.cpp
+++ b/engines/twine/extra.cpp
@@ -540,8 +540,6 @@ void Extra::processExtras() {
int32 currentExtraX = 0;
int32 currentExtraY = 0;
int32 currentExtraZ = 0;
- int32 currentExtraSpeedX = 0;
- int32 currentExtraSpeedY = 0;
for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
ExtraListStruct *extra = &extraList[i];
@@ -571,10 +569,10 @@ void Extra::processExtras() {
currentExtraY = extra->y;
currentExtraZ = extra->z;
- currentExtraSpeedX = extra->destX * (_engine->lbaTime - extra->lifeTime);
+ int32 currentExtraSpeedX = extra->destX * (_engine->lbaTime - extra->lifeTime);
extra->x = currentExtraSpeedX + extra->lastX;
- currentExtraSpeedY = extra->destY * (_engine->lbaTime - extra->lifeTime);
+ int32 currentExtraSpeedY = extra->destY * (_engine->lbaTime - extra->lifeTime);
currentExtraSpeedY += extra->lastY;
extra->y = currentExtraSpeedY - ABS(((extra->angle * (_engine->lbaTime - extra->lifeTime)) * (_engine->lbaTime - extra->lifeTime)) >> 4);
Commit: 12f9ba1beae3d3174ec70930de3da7d06a032cf8
https://github.com/scummvm/scummvm/commit/12f9ba1beae3d3174ec70930de3da7d06a032cf8
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-08T12:00:39+01:00
Commit Message:
TWINE: const
Changed paths:
engines/twine/animations.cpp
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 2deaebade1..399cabd8f7 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -195,7 +195,7 @@ void Animations::applyAnimStep(uint8 **ptr, int32 bp, int32 bx) {
int32 Animations::getAnimMode(uint8 **ptr) {
int16 *lptr = (int16 *)*ptr;
- int16 opcode = *(int16 *)(keyFramePtr);
+ int16 opcode = *(const int16 *)(keyFramePtr);
*(int16 *)(lptr) = opcode;
keyFramePtr += 2;
@@ -206,13 +206,13 @@ int32 Animations::getAnimMode(uint8 **ptr) {
}
int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
- int32 numOfPointInAnim = *(int16 *)(animPtr + 2);
+ int32 numOfPointInAnim = *(const int16 *)(animPtr + 2);
keyFramePtr = ((numOfPointInAnim * 8 + 8) * animState) + animPtr + 8;
- int32 keyFrameLength = *(int16 *)(keyFramePtr);
+ int32 keyFrameLength = *(const int16 *)(keyFramePtr);
- int16 bodyHeader = *(int16 *)(bodyPtr);
+ int16 bodyHeader = *(const int16 *)(bodyPtr);
if (!(bodyHeader & 2)) {
return 0;
@@ -230,14 +230,14 @@ int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *body
lastKeyFramePtr = ebx;
- int32 eax = *(int16 *)(edi - 2);
+ int32 eax = *(const int16 *)(edi - 2);
edi += eax;
- eax = *(int16 *)(edi);
+ eax = *(const int16 *)(edi);
eax = eax + eax * 2;
edi = edi + eax * 2 + 12;
- int32 numOfPointInBody = *(int16 *)(edi - 10);
+ int32 numOfPointInBody = *(const int16 *)(edi - 10);
if (numOfPointInAnim > numOfPointInBody) {
numOfPointInAnim = numOfPointInBody;
@@ -247,9 +247,9 @@ int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *body
if (eax >= keyFrameLength) {
int32 *destPtr; // keyFrame
- int32 *sourcePtr;
+ const int32 *sourcePtr;
- sourcePtr = (int32 *)(keyFramePtr + 8);
+ sourcePtr = (const int32 *)(keyFramePtr + 8);
destPtr = (int32 *)edi;
do {
@@ -261,12 +261,12 @@ int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *body
animTimerDataPtr->ptr = keyFramePtr;
animTimerDataPtr->time = _engine->lbaTime;
- currentStepX = *(int16 *)(keyFramePtr + 2);
- currentStepY = *(int16 *)(keyFramePtr + 4);
- currentStepZ = *(int16 *)(keyFramePtr + 6);
+ currentStepX = *(const int16 *)(keyFramePtr + 2);
+ currentStepY = *(const int16 *)(keyFramePtr + 4);
+ currentStepZ = *(const int16 *)(keyFramePtr + 6);
- processRotationByAnim = *(int16 *)(keyFramePtr + 8);
- processLastRotationAngle = *(int16 *)(keyFramePtr + 12);
+ processRotationByAnim = *(const int16 *)(keyFramePtr + 8);
+ processLastRotationAngle = *(const int16 *)(keyFramePtr + 12);
return 1;
}
@@ -275,8 +275,8 @@ int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *body
lastKeyFramePtr += 8;
keyFramePtr += 8;
- processRotationByAnim = *(int16 *)(keyFramePtr);
- processLastRotationAngle = (*(int16 *)(keyFramePtr + 4) * eax) / keyFrameLength;
+ processRotationByAnim = *(const int16 *)(keyFramePtr);
+ processLastRotationAngle = (*(const int16 *)(keyFramePtr + 4) * eax) / keyFrameLength;
lastKeyFramePtr += 8;
keyFramePtr += 8;
@@ -309,9 +309,9 @@ int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *body
} while (--tmpNumOfPoints);
}
- currentStepX = (*(int16 *)(keyFramePtrOld + 2) * eax) / keyFrameLength;
- currentStepY = (*(int16 *)(keyFramePtrOld + 4) * eax) / keyFrameLength;
- currentStepZ = (*(int16 *)(keyFramePtrOld + 6) * eax) / keyFrameLength;
+ currentStepX = (*(const int16 *)(keyFramePtrOld + 2) * eax) / keyFrameLength;
+ currentStepY = (*(const int16 *)(keyFramePtrOld + 4) * eax) / keyFrameLength;
+ currentStepZ = (*(const int16 *)(keyFramePtrOld + 6) * eax) / keyFrameLength;
return 0;
}
Commit: 62f1335826bea2809ff929265826ff15643489d9
https://github.com/scummvm/scummvm/commit/62f1335826bea2809ff929265826ff15643489d9
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-08T12:08:53+01:00
Commit Message:
TWINE: remove member variables and use them as local vars
and a lot of const
Changed paths:
engines/twine/actor.h
engines/twine/animations.cpp
engines/twine/animations.h
diff --git a/engines/twine/actor.h b/engines/twine/actor.h
index d3f6d9c2df..cc95edfe48 100644
--- a/engines/twine/actor.h
+++ b/engines/twine/actor.h
@@ -76,7 +76,7 @@ struct ZVBox {
/** Actors animation timer structure */
struct AnimTimerDataStruct {
- uint8 *ptr = nullptr;
+ const uint8 *ptr = nullptr;
int32 time = 0;
};
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 399cabd8f7..8b069124ac 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -77,16 +77,16 @@ Animations::~Animations() {
}
int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
- const int16 numOfKeyframeInAnim = *(int16 *)(animPtr);
+ const int16 numOfKeyframeInAnim = *(const int16 *)(animPtr);
if (keyframeIdx >= numOfKeyframeInAnim) {
return numOfKeyframeInAnim;
}
- int16 numOfBonesInAnim = *(int16 *)(animPtr + 2);
+ int16 numOfBonesInAnim = *(const int16 *)(animPtr + 2);
uint8 *ptrToData = (uint8 *)((numOfBonesInAnim * 8 + 8) * keyframeIdx + animPtr + 8);
- const int16 bodyHeader = *(int16 *)(bodyPtr);
+ const int16 bodyHeader = *(const int16 *)(bodyPtr);
if (!(bodyHeader & 2)) {
return 0;
@@ -97,13 +97,13 @@ int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bo
animTimerDataPtr->ptr = ptrToData;
animTimerDataPtr->time = _engine->lbaTime;
- ptrToBodyData = ptrToBodyData + *(int16 *)(ptrToBodyData) + 2;
+ ptrToBodyData = ptrToBodyData + *(const int16 *)(ptrToBodyData) + 2;
- const int16 numOfElementInBody = *(int16 *)(ptrToBodyData);
+ const int16 numOfElementInBody = *(const int16 *)(ptrToBodyData);
ptrToBodyData = ptrToBodyData + numOfElementInBody * 6 + 12;
- const int16 numOfPointInBody = *(int16 *)(ptrToBodyData - 10); // num elements
+ const int16 numOfPointInBody = *(const int16 *)(ptrToBodyData - 10); // num elements
if (numOfBonesInAnim > numOfPointInBody) {
numOfBonesInAnim = numOfPointInBody;
@@ -124,12 +124,12 @@ int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bo
ptrToData = ptrToDataBackup + 2;
- currentStepX = *(int16 *)(ptrToData);
- currentStepY = *(int16 *)(ptrToData + 2);
- currentStepZ = *(int16 *)(ptrToData + 4);
+ currentStepX = *(const int16 *)(ptrToData);
+ currentStepY = *(const int16 *)(ptrToData + 2);
+ currentStepZ = *(const int16 *)(ptrToData + 4);
- processRotationByAnim = *(int16 *)(ptrToData + 6);
- processLastRotationAngle = *(int16 *)(ptrToData + 10);
+ processRotationByAnim = *(const int16 *)(ptrToData + 6);
+ processLastRotationAngle = *(const int16 *)(ptrToData + 10);
return 1;
}
@@ -142,12 +142,12 @@ int32 Animations::getStartKeyframe(const uint8 *animPtr) {
return READ_LE_INT16(animPtr + 4);
}
-void Animations::applyAnimStepRotation(uint8 **ptr, int32 bp, int32 bx) {
- int16 lastAngle = *(const int16 *)(lastKeyFramePtr);
- lastKeyFramePtr += 2;
+void Animations::applyAnimStepRotation(uint8 **ptr, int32 bp, int32 bx, const uint8 **keyFramePtr, const uint8 **lastKeyFramePtr) {
+ int16 lastAngle = *(const int16 *)(*lastKeyFramePtr);
+ *lastKeyFramePtr += 2;
- int16 newAngle = *(const int16 *)(keyFramePtr);
- keyFramePtr += 2;
+ int16 newAngle = *(const int16 *)(*keyFramePtr);
+ *keyFramePtr += 2;
lastAngle &= 0x3FF;
newAngle &= 0x3FF;
@@ -172,12 +172,12 @@ void Animations::applyAnimStepRotation(uint8 **ptr, int32 bp, int32 bx) {
*(ptr) = *(ptr) + 2;
}
-void Animations::applyAnimStep(uint8 **ptr, int32 bp, int32 bx) {
- int16 lastAngle = *(const int16 *)lastKeyFramePtr;
- lastKeyFramePtr += 2;
+void Animations::applyAnimStep(uint8 **ptr, int32 bp, int32 bx, const uint8 **keyFramePtr, const uint8 **lastKeyFramePtr) {
+ int16 lastAngle = *(const int16 *)*lastKeyFramePtr;
+ *lastKeyFramePtr += 2;
- int16 newAngle = *(const int16 *)keyFramePtr;
- keyFramePtr += 2;
+ int16 newAngle = *(const int16 *)*keyFramePtr;
+ *keyFramePtr += 2;
int16 angleDif = newAngle - lastAngle;
@@ -193,14 +193,14 @@ void Animations::applyAnimStep(uint8 **ptr, int32 bp, int32 bx) {
*(ptr) = *(ptr) + 2;
}
-int32 Animations::getAnimMode(uint8 **ptr) {
+int32 Animations::getAnimMode(uint8 **ptr, const uint8 **keyFramePtr, const uint8 **lastKeyFramePtr) {
int16 *lptr = (int16 *)*ptr;
- int16 opcode = *(const int16 *)(keyFramePtr);
+ int16 opcode = *(const int16 *)(*keyFramePtr);
*(int16 *)(lptr) = opcode;
- keyFramePtr += 2;
+ *keyFramePtr += 2;
*(ptr) = *(ptr) + 2;
- lastKeyFramePtr += 2;
+ *lastKeyFramePtr += 2;
return opcode;
}
@@ -208,7 +208,7 @@ int32 Animations::getAnimMode(uint8 **ptr) {
int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
int32 numOfPointInAnim = *(const int16 *)(animPtr + 2);
- keyFramePtr = ((numOfPointInAnim * 8 + 8) * animState) + animPtr + 8;
+ const uint8* keyFramePtr = ((numOfPointInAnim * 8 + 8) * animState) + animPtr + 8;
int32 keyFrameLength = *(const int16 *)(keyFramePtr);
@@ -220,7 +220,7 @@ int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *body
uint8 *edi = bodyPtr + 16;
- uint8 *ebx = animTimerDataPtr->ptr;
+ const uint8 *ebx = animTimerDataPtr->ptr;
int32 ebp = animTimerDataPtr->time;
if (!ebx) {
@@ -228,7 +228,7 @@ int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *body
ebp = keyFrameLength;
}
- lastKeyFramePtr = ebx;
+ const uint8* lastKeyFramePtr = ebx;
int32 eax = *(const int16 *)(edi - 2);
edi += eax;
@@ -270,7 +270,7 @@ int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *body
return 1;
}
- uint8 *keyFramePtrOld = keyFramePtr;
+ const uint8 *keyFramePtrOld = keyFramePtr;
lastKeyFramePtr += 8;
keyFramePtr += 8;
@@ -287,19 +287,19 @@ int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *body
int16 tmpNumOfPoints = numOfPointInAnim;
do {
- int16 animOpcode = getAnimMode(&edi);
+ int16 animOpcode = getAnimMode(&edi, &keyFramePtr, &lastKeyFramePtr);
switch (animOpcode) {
case 0: // allow global rotate
- applyAnimStepRotation(&edi, eax, keyFrameLength);
- applyAnimStepRotation(&edi, eax, keyFrameLength);
- applyAnimStepRotation(&edi, eax, keyFrameLength);
+ applyAnimStepRotation(&edi, eax, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
+ applyAnimStepRotation(&edi, eax, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
+ applyAnimStepRotation(&edi, eax, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
break;
case 1: // dissallow global rotate
case 2: // dissallow global rotate + hide
- applyAnimStep(&edi, eax, keyFrameLength);
- applyAnimStep(&edi, eax, keyFrameLength);
- applyAnimStep(&edi, eax, keyFrameLength);
+ applyAnimStep(&edi, eax, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
+ applyAnimStep(&edi, eax, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
+ applyAnimStep(&edi, eax, keyFrameLength, &keyFramePtr, &lastKeyFramePtr);
break;
default:
error("Unsupported animation rotation mode %d!\n", animOpcode);
@@ -356,7 +356,7 @@ int32 Animations::getBodyAnimIndex(AnimationTypes animIdx, int32 actorIdx) {
int32 Animations::stockAnimation(uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
uint8 *animPtr = animBuffer2;
- int32 playAnim = *(int16 *)(bodyPtr);
+ int32 playAnim = *(const int16 *)(bodyPtr);
if (!(playAnim & 2)) {
return 0;
@@ -366,15 +366,15 @@ int32 Animations::stockAnimation(uint8 *bodyPtr, AnimTimerDataStruct *animTimerD
animTimerDataPtr->time = _engine->lbaTime;
animTimerDataPtr->ptr = animPtr;
- int32 var0 = *(int16 *)(ptr - 2);
+ int32 var0 = *(const int16 *)(ptr - 2);
ptr = ptr + var0;
- int32 var1 = *(int16 *)(ptr);
+ int32 var1 = *(const int16 *)(ptr);
var1 = var1 + var1 * 2;
ptr = ptr + var1 * 2 + 2;
- int32 var2 = *(int16 *)(ptr);
+ int32 var2 = *(const int16 *)(ptr);
int32 counter = var2;
var2 = (var2 * 8) + 8;
@@ -399,7 +399,7 @@ int32 Animations::stockAnimation(uint8 *bodyPtr, AnimTimerDataStruct *animTimerD
int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
const int32 numOfPointInAnim = *(const int16 *)(animPtr + 2);
- keyFramePtr = ((numOfPointInAnim * 8 + 8) * animIdx) + animPtr + 8;
+ const uint8 *keyFramePtr = ((numOfPointInAnim * 8 + 8) * animIdx) + animPtr + 8;
const int32 keyFrameLength = *(const int16 *)(keyFramePtr);
const int16 bodyHeader = *(const int16 *)(bodyPtr);
if (!(bodyHeader & 2)) {
@@ -414,7 +414,7 @@ int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bod
ebp = keyFrameLength;
}
- lastKeyFramePtr = ebx;
+ const uint8* lastKeyFramePtr = ebx;
const int32 eax = _engine->lbaTime - ebp;
diff --git a/engines/twine/animations.h b/engines/twine/animations.h
index 9a15238bd8..4cf5718eeb 100644
--- a/engines/twine/animations.h
+++ b/engines/twine/animations.h
@@ -34,9 +34,9 @@ class TwinEEngine;
class Animations {
private:
TwinEEngine *_engine;
- void applyAnimStepRotation(uint8 **ptr, int32 bp, int32 bx);
- int32 getAnimMode(uint8 **ptr);
- void applyAnimStep(uint8 **ptr, int32 bp, int32 bx);
+ void applyAnimStepRotation(uint8 **ptr, int32 bp, int32 bx, const uint8 **keyFramePtr, const uint8 **lastKeyFramePtr);
+ int32 getAnimMode(uint8 **ptr, const uint8 **keyFramePtr, const uint8 **lastKeyFramePtr);
+ void applyAnimStep(uint8 **ptr, int32 bp, int32 bx, const uint8 **keyFramePtr, const uint8 **lastKeyFramePtr);
/**
* Verify animation at keyframe
@@ -62,11 +62,6 @@ private:
/** Current step Z coornidate */
int16 currentStepZ = 0;
- /** Pointer to current animation keyframe */
- uint8 *keyFramePtr = nullptr;
- /** Pointer to last animation keyframe */
- const uint8 *lastKeyFramePtr = nullptr;
-
public:
Animations(TwinEEngine *engine);
~Animations();
Commit: ca540d5e6b4a216716bd3df3976aa7cf4d389db4
https://github.com/scummvm/scummvm/commit/ca540d5e6b4a216716bd3df3976aa7cf4d389db4
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-08T12:13:14+01:00
Commit Message:
TWINE: const and converted to boolean
Changed paths:
engines/twine/animations.cpp
engines/twine/animations.h
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 8b069124ac..dad62b3c12 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -335,7 +335,7 @@ int32 Animations::getBodyAnimIndex(AnimationTypes animIdx, int32 actorIdx) {
if (type == 3) {
if (animIdx == *bodyPtr) {
ptr++;
- uint16 realAnimIdx = *(int16 *)(ptr);
+ uint16 realAnimIdx = *(const int16 *)(ptr);
ptr += 2;
uint8 *ptr2 = ptr;
ptr++;
@@ -361,7 +361,7 @@ int32 Animations::stockAnimation(uint8 *bodyPtr, AnimTimerDataStruct *animTimerD
if (!(playAnim & 2)) {
return 0;
}
- uint8 *ptr = (bodyPtr + 0x10);
+ const uint8 *ptr = (bodyPtr + 0x10);
animTimerDataPtr->time = _engine->lbaTime;
animTimerDataPtr->ptr = animPtr;
@@ -379,13 +379,13 @@ int32 Animations::stockAnimation(uint8 *bodyPtr, AnimTimerDataStruct *animTimerD
var2 = (var2 * 8) + 8;
int32 *edi = (int32 *)(animPtr + 8);
- int32 *esi = (int32 *)(ptr + 10);
+ const int32 *esi = (const int32 *)(ptr + 10);
do {
*(edi++) = *(esi++);
*(edi++) = *(esi++);
- esi = (int32 *)(((int8 *)esi) + 30);
+ esi = (const int32 *)(((const int8 *)esi) + 30);
} while (counter--);
animBuffer2 += var2;
@@ -671,19 +671,18 @@ void Animations::processAnimActions(int32 actorIdx) {
}
}
-// TODO: convert to boolean
-int32 Animations::initAnim(AnimationTypes newAnim, int16 animType, uint8 animExtra, int32 actorIdx) {
+bool Animations::initAnim(AnimationTypes newAnim, int16 animType, uint8 animExtra, int32 actorIdx) {
ActorStruct *actor = _engine->_scene->getActor(actorIdx);
if (actor->entity == -1) {
- return 0;
+ return false;
}
if (actor->staticFlags.bIsSpriteActor) {
- return 0;
+ return false;
}
if (newAnim == actor->anim && actor->previousAnimIdx != -1) {
- return 1;
+ return true;
}
if (animExtra == 255 && actor->animType != 2) {
@@ -698,7 +697,7 @@ int32 Animations::initAnim(AnimationTypes newAnim, int16 animType, uint8 animExt
if (animType != 4 && actor->animType == 2) {
actor->animExtra = newAnim;
- return 0;
+ return false;
}
if (animType == 3) {
@@ -743,7 +742,7 @@ int32 Animations::initAnim(AnimationTypes newAnim, int16 animType, uint8 animExt
actor->lastY = 0;
actor->lastZ = 0;
- return 1;
+ return true;
}
void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
diff --git a/engines/twine/animations.h b/engines/twine/animations.h
index 4cf5718eeb..dbceec3836 100644
--- a/engines/twine/animations.h
+++ b/engines/twine/animations.h
@@ -122,7 +122,7 @@ public:
* @param animExtra animation actions extra data
* @param actorIdx actor index
*/
- int32 initAnim(AnimationTypes newAnim, int16 animType, uint8 animExtra, int32 actorIdx);
+ bool initAnim(AnimationTypes newAnim, int16 animType, uint8 animExtra, int32 actorIdx);
/**
* Process acotr animation actions
Commit: b6750b454e28b1d0bb81ec78b37b14682e07d7b3
https://github.com/scummvm/scummvm/commit/b6750b454e28b1d0bb81ec78b37b14682e07d7b3
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-08T12:14:56+01:00
Commit Message:
TWINE: const
Changed paths:
engines/twine/animations.cpp
engines/twine/animations.h
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index dad62b3c12..7d906263b4 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -84,7 +84,7 @@ int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bo
int16 numOfBonesInAnim = *(const int16 *)(animPtr + 2);
- uint8 *ptrToData = (uint8 *)((numOfBonesInAnim * 8 + 8) * keyframeIdx + animPtr + 8);
+ const uint8 *ptrToData = (const uint8 *)((numOfBonesInAnim * 8 + 8) * keyframeIdx + animPtr + 8);
const int16 bodyHeader = *(const int16 *)(bodyPtr);
@@ -109,7 +109,7 @@ int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bo
numOfBonesInAnim = numOfPointInBody;
}
- uint8 *ptrToDataBackup = ptrToData;
+ const uint8 *ptrToDataBackup = ptrToData;
ptrToData += 8;
@@ -205,7 +205,7 @@ int32 Animations::getAnimMode(uint8 **ptr, const uint8 **keyFramePtr, const uint
return opcode;
}
-int32 Animations::setModelAnimation(int32 animState, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
+int32 Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
int32 numOfPointInAnim = *(const int16 *)(animPtr + 2);
const uint8* keyFramePtr = ((numOfPointInAnim * 8 + 8) * animState) + animPtr + 8;
diff --git a/engines/twine/animations.h b/engines/twine/animations.h
index dbceec3836..a19015a99d 100644
--- a/engines/twine/animations.h
+++ b/engines/twine/animations.h
@@ -99,7 +99,7 @@ public:
* @param bodyPtr Body model poitner
* @param animTimerDataPtr Animation time data
*/
- int32 setModelAnimation(int32 animIdx, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
+ int32 setModelAnimation(int32 animIdx, const uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
/**
* Get entity anim index (This is taken from File3D entities)
Commit: 6f3c9a5e69726b89edff1013f6779ce8aec1cf70
https://github.com/scummvm/scummvm/commit/6f3c9a5e69726b89edff1013f6779ce8aec1cf70
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-08T12:17:34+01:00
Commit Message:
TWINE: converted return value to boolean
Changed paths:
engines/twine/animations.cpp
engines/twine/animations.h
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 7d906263b4..3c0ea540d5 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -205,7 +205,7 @@ int32 Animations::getAnimMode(uint8 **ptr, const uint8 **keyFramePtr, const uint
return opcode;
}
-int32 Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
+bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
int32 numOfPointInAnim = *(const int16 *)(animPtr + 2);
const uint8* keyFramePtr = ((numOfPointInAnim * 8 + 8) * animState) + animPtr + 8;
@@ -215,7 +215,7 @@ int32 Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
int16 bodyHeader = *(const int16 *)(bodyPtr);
if (!(bodyHeader & 2)) {
- return 0;
+ return false;
}
uint8 *edi = bodyPtr + 16;
@@ -268,7 +268,7 @@ int32 Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
processRotationByAnim = *(const int16 *)(keyFramePtr + 8);
processLastRotationAngle = *(const int16 *)(keyFramePtr + 12);
- return 1;
+ return true;
}
const uint8 *keyFramePtrOld = keyFramePtr;
@@ -313,7 +313,7 @@ int32 Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
currentStepY = (*(const int16 *)(keyFramePtrOld + 4) * eax) / keyFrameLength;
currentStepZ = (*(const int16 *)(keyFramePtrOld + 6) * eax) / keyFrameLength;
- return 0;
+ return false;
}
int32 Animations::getBodyAnimIndex(AnimationTypes animIdx, int32 actorIdx) {
diff --git a/engines/twine/animations.h b/engines/twine/animations.h
index a19015a99d..de8a75eb01 100644
--- a/engines/twine/animations.h
+++ b/engines/twine/animations.h
@@ -99,7 +99,7 @@ public:
* @param bodyPtr Body model poitner
* @param animTimerDataPtr Animation time data
*/
- int32 setModelAnimation(int32 animIdx, const uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
+ bool setModelAnimation(int32 animIdx, const uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr);
/**
* Get entity anim index (This is taken from File3D entities)
Commit: f4f67faee04258d5af2453ff503fea1ee1dd15f1
https://github.com/scummvm/scummvm/commit/f4f67faee04258d5af2453ff503fea1ee1dd15f1
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-08T12:33:02+01:00
Commit Message:
TWINE: fixed a few endian issues in the animation code
the body and keyframe data is directly loaded from the hqrs
Changed paths:
engines/twine/animations.cpp
engines/twine/renderer.cpp
engines/twine/renderer.h
diff --git a/engines/twine/animations.cpp b/engines/twine/animations.cpp
index 3c0ea540d5..d9e45a7500 100644
--- a/engines/twine/animations.cpp
+++ b/engines/twine/animations.cpp
@@ -77,16 +77,16 @@ Animations::~Animations() {
}
int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
- const int16 numOfKeyframeInAnim = *(const int16 *)(animPtr);
+ const int16 numOfKeyframeInAnim = READ_LE_INT16(animPtr);
if (keyframeIdx >= numOfKeyframeInAnim) {
return numOfKeyframeInAnim;
}
- int16 numOfBonesInAnim = *(const int16 *)(animPtr + 2);
+ int16 numOfBonesInAnim = READ_LE_INT16(animPtr + 2);
const uint8 *ptrToData = (const uint8 *)((numOfBonesInAnim * 8 + 8) * keyframeIdx + animPtr + 8);
- const int16 bodyHeader = *(const int16 *)(bodyPtr);
+ const int16 bodyHeader = READ_LE_INT16(bodyPtr);
if (!(bodyHeader & 2)) {
return 0;
@@ -97,13 +97,13 @@ int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bo
animTimerDataPtr->ptr = ptrToData;
animTimerDataPtr->time = _engine->lbaTime;
- ptrToBodyData = ptrToBodyData + *(const int16 *)(ptrToBodyData) + 2;
+ ptrToBodyData = ptrToBodyData + READ_LE_INT16(ptrToBodyData) + 2;
- const int16 numOfElementInBody = *(const int16 *)(ptrToBodyData);
+ const int16 numOfElementInBody = READ_LE_INT16(ptrToBodyData);
ptrToBodyData = ptrToBodyData + numOfElementInBody * 6 + 12;
- const int16 numOfPointInBody = *(const int16 *)(ptrToBodyData - 10); // num elements
+ const int16 numOfPointInBody = READ_LE_INT16(ptrToBodyData - 10); // num elements
if (numOfBonesInAnim > numOfPointInBody) {
numOfBonesInAnim = numOfPointInBody;
@@ -124,12 +124,12 @@ int32 Animations::setAnimAtKeyframe(int32 keyframeIdx, uint8 *animPtr, uint8 *bo
ptrToData = ptrToDataBackup + 2;
- currentStepX = *(const int16 *)(ptrToData);
- currentStepY = *(const int16 *)(ptrToData + 2);
- currentStepZ = *(const int16 *)(ptrToData + 4);
+ currentStepX = READ_LE_INT16(ptrToData);
+ currentStepY = READ_LE_INT16(ptrToData + 2);
+ currentStepZ = READ_LE_INT16(ptrToData + 4);
- processRotationByAnim = *(const int16 *)(ptrToData + 6);
- processLastRotationAngle = *(const int16 *)(ptrToData + 10);
+ processRotationByAnim = READ_LE_INT16(ptrToData + 6);
+ processLastRotationAngle = READ_LE_INT16(ptrToData + 10);
return 1;
}
@@ -143,10 +143,10 @@ int32 Animations::getStartKeyframe(const uint8 *animPtr) {
}
void Animations::applyAnimStepRotation(uint8 **ptr, int32 bp, int32 bx, const uint8 **keyFramePtr, const uint8 **lastKeyFramePtr) {
- int16 lastAngle = *(const int16 *)(*lastKeyFramePtr);
+ int16 lastAngle = READ_LE_INT16(*lastKeyFramePtr);
*lastKeyFramePtr += 2;
- int16 newAngle = *(const int16 *)(*keyFramePtr);
+ int16 newAngle = READ_LE_INT16(*keyFramePtr);
*keyFramePtr += 2;
lastAngle &= 0x3FF;
@@ -173,10 +173,10 @@ void Animations::applyAnimStepRotation(uint8 **ptr, int32 bp, int32 bx, const ui
}
void Animations::applyAnimStep(uint8 **ptr, int32 bp, int32 bx, const uint8 **keyFramePtr, const uint8 **lastKeyFramePtr) {
- int16 lastAngle = *(const int16 *)*lastKeyFramePtr;
+ int16 lastAngle = READ_LE_INT16(*lastKeyFramePtr);
*lastKeyFramePtr += 2;
- int16 newAngle = *(const int16 *)*keyFramePtr;
+ int16 newAngle = READ_LE_INT16(*keyFramePtr);
*keyFramePtr += 2;
int16 angleDif = newAngle - lastAngle;
@@ -195,7 +195,7 @@ void Animations::applyAnimStep(uint8 **ptr, int32 bp, int32 bx, const uint8 **ke
int32 Animations::getAnimMode(uint8 **ptr, const uint8 **keyFramePtr, const uint8 **lastKeyFramePtr) {
int16 *lptr = (int16 *)*ptr;
- int16 opcode = *(const int16 *)(*keyFramePtr);
+ int16 opcode = READ_LE_INT16(*keyFramePtr);
*(int16 *)(lptr) = opcode;
*keyFramePtr += 2;
@@ -206,13 +206,13 @@ int32 Animations::getAnimMode(uint8 **ptr, const uint8 **keyFramePtr, const uint
}
bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
- int32 numOfPointInAnim = *(const int16 *)(animPtr + 2);
+ int32 numOfPointInAnim = READ_LE_INT16(animPtr + 2);
const uint8* keyFramePtr = ((numOfPointInAnim * 8 + 8) * animState) + animPtr + 8;
- int32 keyFrameLength = *(const int16 *)(keyFramePtr);
+ int32 keyFrameLength = READ_LE_INT16(keyFramePtr);
- int16 bodyHeader = *(const int16 *)(bodyPtr);
+ int16 bodyHeader = READ_LE_INT16(bodyPtr);
if (!(bodyHeader & 2)) {
return false;
@@ -230,14 +230,14 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
const uint8* lastKeyFramePtr = ebx;
- int32 eax = *(const int16 *)(edi - 2);
+ int32 eax = READ_LE_INT16(edi - 2);
edi += eax;
- eax = *(const int16 *)(edi);
+ eax = READ_LE_INT16(edi);
eax = eax + eax * 2;
edi = edi + eax * 2 + 12;
- int32 numOfPointInBody = *(const int16 *)(edi - 10);
+ int32 numOfPointInBody = READ_LE_INT16(edi - 10);
if (numOfPointInAnim > numOfPointInBody) {
numOfPointInAnim = numOfPointInBody;
@@ -246,11 +246,8 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
eax = _engine->lbaTime - ebp;
if (eax >= keyFrameLength) {
- int32 *destPtr; // keyFrame
- const int32 *sourcePtr;
-
- sourcePtr = (const int32 *)(keyFramePtr + 8);
- destPtr = (int32 *)edi;
+ const int32 *sourcePtr = (const int32 *)(keyFramePtr + 8);
+ int32 *destPtr = (int32 *)edi; // keyframe
do {
*(destPtr++) = *(sourcePtr++);
@@ -261,12 +258,12 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
animTimerDataPtr->ptr = keyFramePtr;
animTimerDataPtr->time = _engine->lbaTime;
- currentStepX = *(const int16 *)(keyFramePtr + 2);
- currentStepY = *(const int16 *)(keyFramePtr + 4);
- currentStepZ = *(const int16 *)(keyFramePtr + 6);
+ currentStepX = READ_LE_INT16(keyFramePtr + 2);
+ currentStepY = READ_LE_INT16(keyFramePtr + 4);
+ currentStepZ = READ_LE_INT16(keyFramePtr + 6);
- processRotationByAnim = *(const int16 *)(keyFramePtr + 8);
- processLastRotationAngle = *(const int16 *)(keyFramePtr + 12);
+ processRotationByAnim = READ_LE_INT16(keyFramePtr + 8);
+ processLastRotationAngle = READ_LE_INT16(keyFramePtr + 12);
return true;
}
@@ -275,8 +272,8 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
lastKeyFramePtr += 8;
keyFramePtr += 8;
- processRotationByAnim = *(const int16 *)(keyFramePtr);
- processLastRotationAngle = (*(const int16 *)(keyFramePtr + 4) * eax) / keyFrameLength;
+ processRotationByAnim = READ_LE_INT16(keyFramePtr);
+ processLastRotationAngle = (READ_LE_INT16(keyFramePtr + 4) * eax) / keyFrameLength;
lastKeyFramePtr += 8;
keyFramePtr += 8;
@@ -309,9 +306,9 @@ bool Animations::setModelAnimation(int32 animState, const uint8 *animPtr, uint8
} while (--tmpNumOfPoints);
}
- currentStepX = (*(const int16 *)(keyFramePtrOld + 2) * eax) / keyFrameLength;
- currentStepY = (*(const int16 *)(keyFramePtrOld + 4) * eax) / keyFrameLength;
- currentStepZ = (*(const int16 *)(keyFramePtrOld + 6) * eax) / keyFrameLength;
+ currentStepX = (READ_LE_INT16(keyFramePtrOld + 2) * eax) / keyFrameLength;
+ currentStepY = (READ_LE_INT16(keyFramePtrOld + 4) * eax) / keyFrameLength;
+ currentStepZ = (READ_LE_INT16(keyFramePtrOld + 6) * eax) / keyFrameLength;
return false;
}
@@ -335,7 +332,7 @@ int32 Animations::getBodyAnimIndex(AnimationTypes animIdx, int32 actorIdx) {
if (type == 3) {
if (animIdx == *bodyPtr) {
ptr++;
- uint16 realAnimIdx = *(const int16 *)(ptr);
+ uint16 realAnimIdx = READ_LE_INT16(ptr);
ptr += 2;
uint8 *ptr2 = ptr;
ptr++;
@@ -356,7 +353,7 @@ int32 Animations::getBodyAnimIndex(AnimationTypes animIdx, int32 actorIdx) {
int32 Animations::stockAnimation(uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
uint8 *animPtr = animBuffer2;
- int32 playAnim = *(const int16 *)(bodyPtr);
+ int32 playAnim = READ_LE_INT16(bodyPtr);
if (!(playAnim & 2)) {
return 0;
@@ -366,15 +363,15 @@ int32 Animations::stockAnimation(uint8 *bodyPtr, AnimTimerDataStruct *animTimerD
animTimerDataPtr->time = _engine->lbaTime;
animTimerDataPtr->ptr = animPtr;
- int32 var0 = *(const int16 *)(ptr - 2);
+ int32 var0 = READ_LE_INT16(ptr - 2);
ptr = ptr + var0;
- int32 var1 = *(const int16 *)(ptr);
+ int32 var1 = READ_LE_INT16(ptr);
var1 = var1 + var1 * 2;
ptr = ptr + var1 * 2 + 2;
- int32 var2 = *(const int16 *)(ptr);
+ int32 var2 = READ_LE_INT16(ptr);
int32 counter = var2;
var2 = (var2 * 8) + 8;
@@ -398,10 +395,10 @@ int32 Animations::stockAnimation(uint8 *bodyPtr, AnimTimerDataStruct *animTimerD
}
int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bodyPtr, AnimTimerDataStruct *animTimerDataPtr) {
- const int32 numOfPointInAnim = *(const int16 *)(animPtr + 2);
+ const int32 numOfPointInAnim = READ_LE_INT16(animPtr + 2);
const uint8 *keyFramePtr = ((numOfPointInAnim * 8 + 8) * animIdx) + animPtr + 8;
- const int32 keyFrameLength = *(const int16 *)(keyFramePtr);
- const int16 bodyHeader = *(const int16 *)(bodyPtr);
+ const int32 keyFrameLength = READ_LE_INT16(keyFramePtr);
+ const int16 bodyHeader = READ_LE_INT16(bodyPtr);
if (!(bodyHeader & 2)) {
return 0;
}
@@ -422,12 +419,12 @@ int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bod
animTimerDataPtr->ptr = keyFramePtr;
animTimerDataPtr->time = _engine->lbaTime;
- currentStepX = *(const int16 *)(keyFramePtr + 2);
- currentStepY = *(const int16 *)(keyFramePtr + 4);
- currentStepZ = *(const int16 *)(keyFramePtr + 6);
+ currentStepX = READ_LE_INT16(keyFramePtr + 2);
+ currentStepY = READ_LE_INT16(keyFramePtr + 4);
+ currentStepZ = READ_LE_INT16(keyFramePtr + 6);
- processRotationByAnim = *(const int16 *)(keyFramePtr + 8);
- processLastRotationAngle = *(const int16 *)(keyFramePtr + 12);
+ processRotationByAnim = READ_LE_INT16(keyFramePtr + 8);
+ processLastRotationAngle = READ_LE_INT16(keyFramePtr + 12);
return 1;
}
@@ -436,15 +433,15 @@ int32 Animations::verifyAnimAtKeyframe(int32 animIdx, uint8 *animPtr, uint8 *bod
lastKeyFramePtr += 8;
keyFramePtr += 8;
- processRotationByAnim = *(const int16 *)(keyFramePtr);
- processLastRotationAngle = (*(const int16 *)(keyFramePtr + 4) * eax) / keyFrameLength;
+ processRotationByAnim = READ_LE_INT16(keyFramePtr);
+ processLastRotationAngle = (READ_LE_INT16(keyFramePtr + 4) * eax) / keyFrameLength;
lastKeyFramePtr += 8;
keyFramePtr += 8;
- currentStepX = (*(const int16 *)(keyFramePtrOld + 2) * eax) / keyFrameLength;
- currentStepY = (*(const int16 *)(keyFramePtrOld + 4) * eax) / keyFrameLength;
- currentStepZ = (*(const int16 *)(keyFramePtrOld + 6) * eax) / keyFrameLength;
+ currentStepX = (READ_LE_INT16(keyFramePtrOld + 2) * eax) / keyFrameLength;
+ currentStepY = (READ_LE_INT16(keyFramePtrOld + 4) * eax) / keyFrameLength;
+ currentStepZ = (READ_LE_INT16(keyFramePtrOld + 6) * eax) / keyFrameLength;
return 0;
}
diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index 42954e4301..c9d6a9fb5e 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -1513,7 +1513,7 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
} while (--numOfPrimitives);
}
- shadePtr = (int32 *)elementsPtr;
+ int32 *shadePtr = (int32 *)elementsPtr;
int32 numOfShades = *((const uint16 *)shadePtr);
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index a5a98d595b..8ad0f351e2 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -161,7 +161,6 @@ private:
int32 matricesTable[271] {0};
uint8 *currentMatrixTableEntry = nullptr;
- int32 *shadePtr = nullptr;
int32 shadeMatrix[9] {0};
int32 lightX = 0;
int32 lightY = 0;
Commit: 60935e83ed95c27ee42a27e81d7717add2c181e7
https://github.com/scummvm/scummvm/commit/60935e83ed95c27ee42a27e81d7717add2c181e7
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-08T12:49:49+01:00
Commit Message:
TWINE: const and reduced scope in renderer code
Changed paths:
engines/twine/renderer.cpp
diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index c9d6a9fb5e..a5c46e87c6 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -987,11 +987,9 @@ void Renderer::renderPolygons(int32 renderType, int32 color) {
}
void Renderer::circleFill(int32 x, int32 y, int32 radius, int8 color) {
- int32 currentLine;
-
radius += 1;
- for (currentLine = -radius; currentLine <= radius; currentLine++) {
+ for (int32 currentLine = -radius; currentLine <= radius; currentLine++) {
double width;
if (ABS(currentLine) != radius) {
@@ -1024,7 +1022,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
// prepare polygons
uint8 *edi = renderTab7; // renderTab7 coordinates buffer
- int16 temp = *((int16 *)pointer); // we read the number of polygons
+ int16 temp = *((const int16 *)pointer); // we read the number of polygons
pointer += 2;
if (temp) {
@@ -1032,7 +1030,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
do { // loop that load all the polygons
uint8 *render23 = edi;
- polyHeader *currentPolyHeader = (polyHeader *)pointer;
+ const polyHeader *currentPolyHeader = (const polyHeader *)pointer;
//ecx = *((int32*) pointer);
pointer += 2;
int16 polyRenderType = currentPolyHeader->renderType;
@@ -1054,7 +1052,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
renderV19 = edi;
do {
- polyVertexHeader *currentPolyVertex = (polyVertexHeader *)pointer;
+ const polyVertexHeader *currentPolyVertex = (const polyVertexHeader *)pointer;
int16 shadeValue = currentPolyHeader->colorIndex + shadeTable[currentPolyVertex->shadeEntry];
@@ -1085,7 +1083,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
int16 color = currentPolyHeader->colorIndex;
- int16 shadeEntry = *((int16 *)(pointer + 2));
+ int16 shadeEntry = *((const int16 *)(pointer + 2));
pointer += 4;
@@ -1097,7 +1095,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
counter = destinationHeader->numOfVertex;
do {
- int32 eax = *((int16 *)pointer);
+ int32 eax = *((const int16 *)pointer);
pointer += 2;
currentVertex = &flattenPoints[eax / 6];
@@ -1131,7 +1129,7 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
counter = currentPolyHeader->numOfVertex;
do {
- eax = *((int16 *)pointer);
+ eax = *((const int16 *)pointer);
pointer += 2;
currentVertex = &flattenPoints[eax / 6];
@@ -1156,22 +1154,22 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
int32 render25 = bestDepth;
- int16 ax = *((int16 *)(edi + 4));
- int16 bx = *((int16 *)(edi + 8));
+ int16 ax = *((const int16 *)(edi + 4));
+ int16 bx = *((const int16 *)(edi + 8));
- ax -= *((int16 *)(edi + 16));
- bx -= *((int16 *)(edi + 2));
+ ax -= *((const int16 *)(edi + 16));
+ bx -= *((const int16 *)(edi + 2));
ax *= bx;
bestDepth = ax;
bx = currentDepth;
- ax = *((int16 *)(edi + 2));
- int16 cx = *((int16 *)(edi + 10));
+ ax = *((const int16 *)(edi + 2));
+ int16 cx = *((const int16 *)(edi + 10));
- ax -= *((int16 *)(edi + 14));
- cx -= *((int16 *)(edi + 4));
+ ax -= *((const int16 *)(edi + 14));
+ cx -= *((const int16 *)(edi + 4));
ax *= cx;
@@ -1234,14 +1232,14 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
// prepare spheres
- temp = *((int16 *)pointer);
+ temp = *((const int16 *)pointer);
pointer += 2;
if (temp) {
numOfPrimitives += temp;
do {
uint8 color2 = *(pointer + 1);
- int16 center = *((uint16 *)(pointer + 6));
- int16 size = *((uint16 *)(pointer + 4));
+ int16 center = *((const uint16 *)(pointer + 6));
+ int16 size = *((const uint16 *)(pointer + 4));
*(uint8 *)edi = color2;
*((int16 *)(edi + 1)) = flattenPoints[center / 6].x;
@@ -1299,8 +1297,8 @@ int32 Renderer::renderModelElements(int32 numOfPrimitives, uint8 *pointer) {
switch (type) {
case RENDERTYPE_DRAWLINE: { // draw a line
- lineCoordinates *lineCoordinatesPtr = (lineCoordinates *)pointer;
- int16 color = (*((int32 *)&lineCoordinatesPtr->data) & 0xFF00) >> 8;
+ const lineCoordinates *lineCoordinatesPtr = (const lineCoordinates *)pointer;
+ int16 color = (*((const int32 *)&lineCoordinatesPtr->data) & 0xFF00) >> 8;
const int32 x1 = *((const int16 *)&lineCoordinatesPtr->x1);
const int32 y1 = *((const int16 *)&lineCoordinatesPtr->y1);
@@ -1389,15 +1387,16 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
bodyPtr += 2;
uint8 *elementsPtr = bodyPtr;
- uint8 *elementsPtr2 = elementsPtr;
+ const uint8 *elementsPtr2 = elementsPtr;
+ // TODO: un-memberify this
currentMatrixTableEntry = (uint8 *)matricesTable;
processRotatedElement(pointsPtr, renderAngleX, renderAngleY, renderAngleZ, (const elementEntry *)elementsPtr);
elementsPtr += 38;
- elementEntry *elemEntryPtr = (elementEntry *)elementsPtr;
+ const elementEntry *elemEntryPtr = (const elementEntry *)elementsPtr;
int32 numOfPrimitives = 0;
@@ -1460,8 +1459,9 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
coZ += cameraPosX;
- if (coZ <= 0)
+ if (coZ <= 0) {
coZ = 0x7FFFFFFF;
+ }
// X projection
{
@@ -1520,8 +1520,6 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
shadePtr = (int32 *)(((uint8 *)shadePtr) + 2);
if (numOfShades) { // process normal data
- int32 color;
-
uint8 *currentShadeDestination = (uint8 *)shadeTable;
int32 *lightMatrix = matricesTable;
const uint8 *pri2Ptr3;
@@ -1555,7 +1553,7 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
int16 col2 = *((const int16 *)colPtr++);
int16 col3 = *((const int16 *)colPtr++);
- color = shadeMatrix[0] * col1 + shadeMatrix[1] * col2 + shadeMatrix[2] * col3;
+ int32 color = shadeMatrix[0] * col1 + shadeMatrix[1] * col2 + shadeMatrix[2] * col3;
color += shadeMatrix[3] * col1 + shadeMatrix[4] * col2 + shadeMatrix[5] * col3;
color += shadeMatrix[6] * col1 + shadeMatrix[7] * col2 + shadeMatrix[8] * col3;
@@ -1585,15 +1583,8 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
void Renderer::prepareIsoModel(uint8 *bodyPtr) { // loadGfxSub
bodyHeaderStruct *bodyHeader;
- int16 offsetToData;
- uint8 *bodyDataPtr;
- int16 numOfElement1;
- int16 numOfPoint;
- uint8 *ptrToKeyData;
- int32 i;
int32 bp = 36;
int32 bx = 38;
- uint8 *ptr2;
bodyHeader = (bodyHeaderStruct *)bodyPtr;
@@ -1608,20 +1599,20 @@ void Renderer::prepareIsoModel(uint8 *bodyPtr) { // loadGfxSub
return;
}
- offsetToData = bodyHeader->offsetToData;
+ int16 offsetToData = bodyHeader->offsetToData;
- bodyDataPtr = bodyPtr + offsetToData + 16;
+ uint8 *bodyDataPtr = bodyPtr + offsetToData + 16;
- numOfElement1 = *((int16 *)bodyDataPtr);
- ptr2 = bodyDataPtr + 2 + numOfElement1 * 6;
+ int16 numOfElement1 = *((const int16 *)bodyDataPtr);
+ uint8 *ptr2 = bodyDataPtr + 2 + numOfElement1 * 6;
- numOfPoint = *((int16 *)ptr2);
+ int16 numOfPoint = *((const int16 *)ptr2);
- ptrToKeyData = ptr2 + 2;
+ uint8 *ptrToKeyData = ptr2 + 2;
- for (i = 0; i < numOfPoint; i++) {
+ for (int32 i = 0; i < numOfPoint; i++) {
ptrToKeyData += 38;
- *((int16 *)(ptrToKeyData + 6)) = (*((int16 *)(ptrToKeyData + 6)) * bp) / bx;
+ *((int16 *)(ptrToKeyData + 6)) = (*((const int16 *)(ptrToKeyData + 6)) * bp) / bx;
}
}
@@ -1651,10 +1642,10 @@ int32 Renderer::renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 an
// restart at the beginning of the renderTable
renderTabEntryPtr = renderTab;
- int16 bodyHeader = *((uint16 *)bodyPtr);
+ int16 bodyHeader = *((const uint16 *)bodyPtr);
// jump after the header
- uint8 *ptr = bodyPtr + 16 + *((uint16 *)(bodyPtr + 14));
+ uint8 *ptr = bodyPtr + 16 + *((const uint16 *)(bodyPtr + 14));
if (bodyHeader & 2) { // if animated
// the mostly used renderer code
@@ -1706,24 +1697,19 @@ void Renderer::copyActorInternAnim(const uint8 *bodyPtrSrc, uint8 *bodyPtrDest)
}
void Renderer::renderBehaviourModel(int32 boxLeft, int32 boxTop, int32 boxRight, int32 boxBottom, int32 Y, int32 angle, uint8 *entityPtr) {
- int tmpBoxRight;
- int x;
- int y;
- short int newAngle;
-
- tmpBoxRight = boxRight;
+ int32 tmpBoxRight = boxRight;
- y = boxBottom + boxTop;
+ int32 y = boxBottom + boxTop;
y >>= 1;
- x = boxRight + boxLeft;
+ int32 x = boxRight + boxLeft;
x >>= 1;
setOrthoProjection(x, y, 0);
_engine->_interface->setClip(boxLeft, boxTop, tmpBoxRight, boxBottom);
if (angle == -1) {
- newAngle = _engine->_movements->getRealAngle(&_engine->_menu->moveMenu);
+ const int16 newAngle = _engine->_movements->getRealAngle(&_engine->_menu->moveMenu);
if (_engine->_menu->moveMenu.numOfStep == 0) {
_engine->_movements->setActorAngleSafe(newAngle, newAngle - 256, 50, &_engine->_menu->moveMenu);
}
Commit: 03e0dcdd9cf5ee9d4cf8801dab45619d1eb8ed5b
https://github.com/scummvm/scummvm/commit/03e0dcdd9cf5ee9d4cf8801dab45619d1eb8ed5b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2020-11-08T13:02:37+01:00
Commit Message:
TWINE: removed yet another member from renderer class and made it a local var
Changed paths:
engines/twine/renderer.cpp
engines/twine/renderer.h
diff --git a/engines/twine/renderer.cpp b/engines/twine/renderer.cpp
index a5c46e87c6..37379fdd39 100644
--- a/engines/twine/renderer.cpp
+++ b/engines/twine/renderer.cpp
@@ -163,7 +163,7 @@ void Renderer::setCameraAngle(int32 transPosX, int32 transPosY, int32 transPosZ,
baseTransPosZ = destZ;
}
-void Renderer::applyRotation(int32 *tempMatrix, const int32 *currentMatrix) {
+void Renderer::applyRotation(int32 *targetMatrix, const int32 *currentMatrix) {
int32 matrix1[9];
int32 matrix2[9];
@@ -217,20 +217,20 @@ void Renderer::applyRotation(int32 *tempMatrix, const int32 *currentMatrix) {
angle += 0x100;
int32 angleVar1 = shadeAngleTable[angle & 0x3FF]; // ecx
- tempMatrix[1] = matrix2[1];
- tempMatrix[4] = matrix2[4];
- tempMatrix[7] = matrix2[7];
+ targetMatrix[1] = matrix2[1];
+ targetMatrix[4] = matrix2[4];
+ targetMatrix[7] = matrix2[7];
- tempMatrix[0] = (matrix2[0] * angleVar1 - matrix2[2] * angleVar2) >> 14;
- tempMatrix[2] = (matrix2[0] * angleVar2 + matrix2[2] * angleVar1) >> 14;
- tempMatrix[3] = (matrix2[3] * angleVar1 - matrix2[5] * angleVar2) >> 14;
- tempMatrix[5] = (matrix2[3] * angleVar2 + matrix2[5] * angleVar1) >> 14;
+ targetMatrix[0] = (matrix2[0] * angleVar1 - matrix2[2] * angleVar2) >> 14;
+ targetMatrix[2] = (matrix2[0] * angleVar2 + matrix2[2] * angleVar1) >> 14;
+ targetMatrix[3] = (matrix2[3] * angleVar1 - matrix2[5] * angleVar2) >> 14;
+ targetMatrix[5] = (matrix2[3] * angleVar2 + matrix2[5] * angleVar1) >> 14;
- tempMatrix[6] = (matrix2[6] * angleVar1 - matrix2[8] * angleVar2) >> 14;
- tempMatrix[8] = (matrix2[6] * angleVar2 + matrix2[8] * angleVar1) >> 14;
+ targetMatrix[6] = (matrix2[6] * angleVar1 - matrix2[8] * angleVar2) >> 14;
+ targetMatrix[8] = (matrix2[6] * angleVar2 + matrix2[8] * angleVar1) >> 14;
} else {
for (int32 i = 0; i < 9; i++) {
- tempMatrix[i] = matrix2[i];
+ targetMatrix[i] = matrix2[i];
}
}
}
@@ -255,7 +255,7 @@ void Renderer::applyPointsRotation(const uint8 *firstPointsPtr, int32 numPoints,
} while (--numOfPoints2);
}
-void Renderer::processRotatedElement(const uint8 *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const elementEntry *elemPtr) { // unsigned char * elemPtr) // loadPart
+void Renderer::processRotatedElement(int32 *targetMatrix, const uint8 *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const elementEntry *elemPtr) { // unsigned char * elemPtr) // loadPart
int32 firstPoint = elemPtr->firstPoint;
int32 numOfPoints2 = elemPtr->numOfPoints;
@@ -287,13 +287,13 @@ void Renderer::processRotatedElement(const uint8 *pointsPtr, int32 rotZ, int32 r
destZ = computedPoints[pointIdx].z;
}
- applyRotation((int32 *)currentMatrixTableEntry, currentMatrix);
+ applyRotation(targetMatrix, currentMatrix);
if (!numOfPoints2) {
warning("RENDER WARNING: No points in this model!");
}
- applyPointsRotation(pointsPtr + firstPoint, numOfPoints2, &computedPoints[firstPoint / 6], (const int32 *)currentMatrixTableEntry);
+ applyPointsRotation(pointsPtr + firstPoint, numOfPoints2, &computedPoints[firstPoint / 6], targetMatrix);
}
void Renderer::applyPointsTranslation(const uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, const int32 *translationMatrix) {
@@ -316,7 +316,7 @@ void Renderer::applyPointsTranslation(const uint8 *firstPointsPtr, int32 numPoin
} while (--numOfPoints2);
}
-void Renderer::processTranslatedElement(const uint8 *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const elementEntry *elemPtr) {
+void Renderer::processTranslatedElement(int32 *targetMatrix, const uint8 *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const elementEntry *elemPtr) {
renderAngleX = rotX;
renderAngleY = rotY;
renderAngleZ = rotZ;
@@ -326,7 +326,7 @@ void Renderer::processTranslatedElement(const uint8 *pointsPtr, int32 rotX, int3
destY = 0;
destZ = 0;
- int32 *dest = (int32 *)currentMatrixTableEntry;
+ int32 *dest = targetMatrix;
for (int32 i = 0; i < 9; i++) {
dest[i] = baseMatrix[i];
@@ -336,15 +336,15 @@ void Renderer::processTranslatedElement(const uint8 *pointsPtr, int32 rotX, int3
destY = computedPoints[(elemPtr->basePoint) / 6].y;
destZ = computedPoints[(elemPtr->basePoint) / 6].z;
- const int32 *source = (const int32 *)((const uint8 *)matricesTable + elemPtr->baseElement);
- int32 *dest = (int32 *)currentMatrixTableEntry;
+ const int32 *source = &matricesTable[elemPtr->baseElement / sizeof(int32)];
+ int32 *dest = targetMatrix;
for (int32 i = 0; i < 9; i++) {
dest[i] = source[i];
}
}
- applyPointsTranslation(pointsPtr + elemPtr->firstPoint, elemPtr->numOfPoints, &computedPoints[elemPtr->firstPoint / 6], (int32 *)currentMatrixTableEntry);
+ applyPointsTranslation(pointsPtr + elemPtr->firstPoint, elemPtr->numOfPoints, &computedPoints[elemPtr->firstPoint / 6], targetMatrix);
}
void Renderer::translateGroup(int16 ax, int16 bx, int16 cx) {
@@ -1389,10 +1389,9 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
uint8 *elementsPtr = bodyPtr;
const uint8 *elementsPtr2 = elementsPtr;
- // TODO: un-memberify this
- currentMatrixTableEntry = (uint8 *)matricesTable;
+ int32 *modelMatrix = matricesTable;
- processRotatedElement(pointsPtr, renderAngleX, renderAngleY, renderAngleZ, (const elementEntry *)elementsPtr);
+ processRotatedElement(modelMatrix, pointsPtr, renderAngleX, renderAngleY, renderAngleZ, (const elementEntry *)elementsPtr);
elementsPtr += 38;
@@ -1402,18 +1401,18 @@ int32 Renderer::renderAnimatedModel(uint8 *bodyPtr) {
if (numOfElements - 1 != 0) {
numOfPrimitives = numOfElements - 1;
- currentMatrixTableEntry = (uint8 *)&matricesTable[9];
+ modelMatrix = &matricesTable[9];
do {
int16 boneType = elemEntryPtr->flag;
if (boneType == 0) {
- processRotatedElement(pointsPtr, elemEntryPtr->rotateX, elemEntryPtr->rotateY, elemEntryPtr->rotateZ, elemEntryPtr); // rotation
+ processRotatedElement(modelMatrix, pointsPtr, elemEntryPtr->rotateX, elemEntryPtr->rotateY, elemEntryPtr->rotateZ, elemEntryPtr); // rotation
} else if (boneType == 1) {
- processTranslatedElement(pointsPtr, elemEntryPtr->rotateX, elemEntryPtr->rotateY, elemEntryPtr->rotateZ, elemEntryPtr); // translation
+ processTranslatedElement(modelMatrix, pointsPtr, elemEntryPtr->rotateX, elemEntryPtr->rotateY, elemEntryPtr->rotateZ, elemEntryPtr); // translation
}
- currentMatrixTableEntry += 36;
+ modelMatrix += 9;
elementsPtr += 38;
elemEntryPtr = (elementEntry *)elementsPtr;
} while (--numOfPrimitives);
diff --git a/engines/twine/renderer.h b/engines/twine/renderer.h
index 8ad0f351e2..2218c8b19a 100644
--- a/engines/twine/renderer.h
+++ b/engines/twine/renderer.h
@@ -123,11 +123,11 @@ private:
int32 renderModelElements(int32 numOfPrimitives, uint8 *pointer);
void getBaseRotationPosition(int32 x, int32 y, int32 z);
void getCameraAnglePositions(int32 x, int32 y, int32 z);
- void applyRotation(int32 *tempMatrix, const int32 *currentMatrix);
+ void applyRotation(int32 *targetMatrix, const int32 *currentMatrix);
void applyPointsRotation(const uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, const int32 *rotationMatrix);
- void processRotatedElement(const uint8 *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const elementEntry *elemPtr);
+ void processRotatedElement(int32 *targetMatrix, const uint8 *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const elementEntry *elemPtr);
void applyPointsTranslation(const uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, const int32 *translationMatrix);
- void processTranslatedElement(const uint8 *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const elementEntry *elemPtr);
+ void processTranslatedElement(int32 *targetMatrix, const uint8 *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const elementEntry *elemPtr);
void translateGroup(int16 ax, int16 bx, int16 cx);
// ---- variables ----
@@ -158,10 +158,9 @@ private:
int32 baseMatrix[3 * 3] {0};
- int32 matricesTable[271] {0};
- uint8 *currentMatrixTableEntry = nullptr;
+ int32 matricesTable[30 * 3 * 3 + 1] {0};
- int32 shadeMatrix[9] {0};
+ int32 shadeMatrix[3 * 3] {0};
int32 lightX = 0;
int32 lightY = 0;
int32 lightZ = 0;
More information about the Scummvm-git-logs
mailing list