[Scummvm-git-logs] scummvm master -> 7c988dbca859074079e1a02b24406127fc9f2429
mgerhardy
martin.gerhardy at gmail.com
Fri Mar 19 15:00:04 UTC 2021
This automated email contains information about 23 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
81ffafcd3f TWINE: renamed variables
1092f28549 TWINE: use angle constant
5a557cfd83 TWINE: replaced magic number
9588323abf TWINE: removed unused function
d1a13f4127 TWINE: reduced visibility of Model functions
cdb52c4680 TWINE: return pointer to BonesBaseData in Model class functions
c93360da16 TWINE: cleanup in Model functions
ae68a82917 TWINE: removed Renderer::prepareIsoModel
87cd84b703 TWINE: fixed invalid numOfShades for body parser
ac5424fa4c TWINE: moved bodyTable into Resourced class
107d356ab8 TWINE: validate body loading
d4282fca9d TWINE: reduce visibility
c458c8d955 TWINE: converted to IVec3
4dee4ffddd TWINE: removed member var
b19f6deb26 TWINE: removed member renderPos
5f94f6ed94 TWINE: renamed members
1a06a98bc5 TWINE: removed method declaraction without implementation
827ffeb7fe TWINE: removed comment
db23bbfbfc TWINE: minor cleanup
c98ceb9762 TWINE: don't mis-use the animType for the sprite actor angle for rotations
5fa6a23d8a TWINE: converted to enum class
bee2acfd2b TWINE: reduced visibility
7c988dbca8 TWINE: renamed members
Commit: 81ffafcd3fe3c8af60eb4557ac50245f06855118
https://github.com/scummvm/scummvm/commit/81ffafcd3fe3c8af60eb4557ac50245f06855118
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:06+01:00
Commit Message:
TWINE: renamed variables
Changed paths:
engines/twine/scene/extra.cpp
diff --git a/engines/twine/scene/extra.cpp b/engines/twine/scene/extra.cpp
index c6147ccf59..0733a89f55 100644
--- a/engines/twine/scene/extra.cpp
+++ b/engines/twine/scene/extra.cpp
@@ -404,8 +404,8 @@ void Extra::addExtraThrowMagicball(int32 x, int32 y, int32 z, int32 xAngle, int3
void Extra::drawSpecialShape(const ExtraShape &shapeTable, int32 x, int32 y, int32 color, int32 angle, int32 size) {
int shapeDataIndex = 0;
- int16 var_x = shapeTable.data[shapeDataIndex].x * size / 16;
- int16 var_z = shapeTable.data[shapeDataIndex].z * size / 16;
+ int16 shapeX = shapeTable.data[shapeDataIndex].x * size / 16;
+ int16 shapeZ = shapeTable.data[shapeDataIndex].z * size / 16;
++shapeDataIndex;
@@ -414,7 +414,7 @@ void Extra::drawSpecialShape(const ExtraShape &shapeTable, int32 x, int32 y, int
_engine->_redraw->renderRect.top = 0x7D00;
_engine->_redraw->renderRect.bottom = -0x7D00;
- _engine->_movements->rotateActor(var_x, var_z, angle);
+ _engine->_movements->rotateActor(shapeX, shapeZ, angle);
const int32 computedX = _engine->_renderer->destPos.x + x;
const int32 computedY = _engine->_renderer->destPos.z + y;
@@ -439,8 +439,8 @@ void Extra::drawSpecialShape(const ExtraShape &shapeTable, int32 x, int32 y, int
int32 currentY = computedY;
for (int32 numEntries = 1; numEntries < shapeTable.n; ++numEntries) {
- var_x = shapeTable.data[shapeDataIndex].x * size / 16;
- var_z = shapeTable.data[shapeDataIndex].z * size / 16;
+ shapeX = shapeTable.data[shapeDataIndex].x * size / 16;
+ shapeZ = shapeTable.data[shapeDataIndex].z * size / 16;
++shapeDataIndex;
const int32 oldComputedX = currentX;
@@ -449,7 +449,7 @@ void Extra::drawSpecialShape(const ExtraShape &shapeTable, int32 x, int32 y, int
_engine->_renderer->projPos.x = currentX;
_engine->_renderer->projPos.y = currentY;
- _engine->_movements->rotateActor(var_x, var_z, angle);
+ _engine->_movements->rotateActor(shapeX, shapeZ, angle);
currentX = _engine->_renderer->destPos.x + x;
currentY = _engine->_renderer->destPos.z + y;
Commit: 1092f285490d71c5be109d30d9f694ccd5b6a7a2
https://github.com/scummvm/scummvm/commit/1092f285490d71c5be109d30d9f694ccd5b6a7a2
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:06+01:00
Commit Message:
TWINE: use angle constant
Changed paths:
engines/twine/scene/extra.cpp
diff --git a/engines/twine/scene/extra.cpp b/engines/twine/scene/extra.cpp
index 0733a89f55..d4034294e5 100644
--- a/engines/twine/scene/extra.cpp
+++ b/engines/twine/scene/extra.cpp
@@ -499,7 +499,7 @@ void Extra::drawExtraSpecial(int32 extraIdx, int32 x, int32 y) {
cloudTime = 32;
}
- drawSpecialShape(explodeCloudShape, x, y, COLOR_WHITE, 0, cloudTime);
+ drawSpecialShape(explodeCloudShape, x, y, COLOR_WHITE, ANGLE_0, cloudTime);
break;
}
}
Commit: 5a557cfd83414e2dd45c024adc4df4b4149eed93
https://github.com/scummvm/scummvm/commit/5a557cfd83414e2dd45c024adc4df4b4149eed93
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:06+01:00
Commit Message:
TWINE: replaced magic number
Changed paths:
engines/twine/scene/extra.cpp
diff --git a/engines/twine/scene/extra.cpp b/engines/twine/scene/extra.cpp
index d4034294e5..d4028ad16a 100644
--- a/engines/twine/scene/extra.cpp
+++ b/engines/twine/scene/extra.cpp
@@ -486,7 +486,7 @@ void Extra::drawSpecialShape(const ExtraShape &shapeTable, int32 x, int32 y, int
void Extra::drawExtraSpecial(int32 extraIdx, int32 x, int32 y) {
ExtraListStruct *extra = &extraList[extraIdx];
- ExtraSpecialType specialType = (ExtraSpecialType)(extra->info0 & 0x7FFF);
+ ExtraSpecialType specialType = (ExtraSpecialType)(extra->info0 & (EXTRA_SPECIAL_MASK - 1));
switch (specialType) {
case ExtraSpecialType::kHitStars:
Commit: 9588323abf3107e4ee6f2a23ac6b1d56d8fa996a
https://github.com/scummvm/scummvm/commit/9588323abf3107e4ee6f2a23ac6b1d56d8fa996a
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:06+01:00
Commit Message:
TWINE: removed unused function
Changed paths:
engines/twine/renderer/renderer.h
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index f5d7fd4bb7..c65da0b532 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -159,12 +159,6 @@ struct Model {
return READ_LE_INT16(verticesBase);
}
- static uint8 *getShadesData(uint8 *bodyPtr) {
- uint8 *bonesBase = getBonesBaseData(bodyPtr);
- const int16 numBones = getNumBones(bodyPtr);
- return bonesBase + numBones * 38;
- }
-
static const uint8 *getShadesBaseData(const uint8 *bodyPtr, int16 shadeIdx = 0) {
return getShadesData(bodyPtr) + 2 + (shadeIdx * 8);
}
Commit: d1a13f41270271a28e3a81938a0db56ff5d6c971
https://github.com/scummvm/scummvm/commit/d1a13f41270271a28e3a81938a0db56ff5d6c971
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:06+01:00
Commit Message:
TWINE: reduced visibility of Model functions
Changed paths:
engines/twine/renderer/renderer.h
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index c65da0b532..a66084552e 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -101,7 +101,20 @@ struct BodyFlags {
uint16 unk16 : 1; // 1 << 15
};
-struct Model {
+class Model {
+private:
+ static uint8 *getBonesData(uint8 *bodyPtr) {
+ uint8 *verticesBase = getData(bodyPtr);
+ const int16 numVertices = READ_LE_INT16(verticesBase);
+ return verticesBase + 2 + numVertices * 6;
+ }
+
+ static const uint8 *getBonesData(const uint8 *bodyPtr) {
+ const uint8 *verticesBase = getData(bodyPtr);
+ const int16 numVertices = READ_LE_INT16(verticesBase);
+ return verticesBase + 2 + numVertices * 6;
+ }
+public:
static inline bool isAnimated(const uint8 *bodyPtr) {
const int16 bodyHeader = READ_LE_INT16(bodyPtr);
return (bodyHeader & 2) != 0;
@@ -119,18 +132,6 @@ struct Model {
return getData(bodyPtr) + 2;
}
- static uint8 *getBonesData(uint8 *bodyPtr) {
- uint8 *verticesBase = getData(bodyPtr);
- const int16 numVertices = READ_LE_INT16(verticesBase);
- return verticesBase + 2 + numVertices * 6;
- }
-
- static const uint8 *getBonesData(const uint8 *bodyPtr) {
- const uint8 *verticesBase = getData(bodyPtr);
- const int16 numVertices = READ_LE_INT16(verticesBase);
- return verticesBase + 2 + numVertices * 6;
- }
-
static const BoneFrame *getBonesStateData(const uint8 *bodyPtr, int boneIdx) {
return (const BoneFrame*)(getBonesBaseData(bodyPtr) + 8 + (boneIdx * 38));
}
Commit: cdb52c468007506e1e1c96fbc8a775fcff48cee2
https://github.com/scummvm/scummvm/commit/cdb52c468007506e1e1c96fbc8a775fcff48cee2
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: return pointer to BonesBaseData in Model class functions
Changed paths:
engines/twine/renderer/renderer.cpp
engines/twine/renderer/renderer.h
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index cfb7453461..e3dba1de63 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -328,7 +328,7 @@ void Renderer::applyPointsRotation(const pointTab *pointsPtr, int32 numPoints, p
} while (--numOfPoints2);
}
-void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const elementEntry *elemPtr, ModelData *modelData) {
+void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const BonesBaseData *elemPtr, ModelData *modelData) {
int32 firstPoint = elemPtr->firstPoint / sizeof(pointTab);
int32 numOfPoints2 = elemPtr->numOfPoints;
@@ -381,7 +381,7 @@ void Renderer::applyPointsTranslation(const pointTab *pointsPtr, int32 numPoints
} while (--numOfPoints2);
}
-void Renderer::processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const elementEntry *elemPtr, ModelData *modelData) {
+void Renderer::processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const BonesBaseData *elemPtr, ModelData *modelData) {
renderAngleX = rotX;
renderAngleY = rotY;
renderAngleZ = rotZ;
@@ -1308,7 +1308,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
IMatrix3x3 *modelMatrix = &matricesTable[0];
- const elementEntry *bonesPtr0 = (const elementEntry *)Model::getBonesBaseData(bodyPtr, 0);
+ const BonesBaseData *bonesPtr0 = Model::getBonesBaseData(bodyPtr, 0);
processRotatedElement(modelMatrix, pointsPtr, renderAngleX, renderAngleY, renderAngleZ, bonesPtr0, modelData);
int32 numOfPrimitives = 0;
@@ -1319,7 +1319,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
int boneIdx = 1;
do {
- const elementEntry *bonesPtr = (const elementEntry *)Model::getBonesBaseData(bodyPtr, boneIdx);
+ const BonesBaseData *bonesPtr = Model::getBonesBaseData(bodyPtr, boneIdx);
int16 boneType = bonesPtr->flag;
if (boneType == 0) {
@@ -1496,14 +1496,12 @@ void Renderer::prepareIsoModel(uint8 *bodyPtr) { // loadGfxSub
return;
}
- uint8 *bonesBase = Model::getBonesBaseData(bodyPtr);
const int16 numBones = Model::getNumBones(bodyPtr);
// set up bone indices
for (int32 i = 0; i < numBones; i++) {
- bonesBase += sizeof(elementEntry);
- elementEntry *ee = (elementEntry *)bonesBase;
- ee->baseElement = ee->baseElement / sizeof(elementEntry);
+ BonesBaseData *bonesBase = Model::getBonesBaseData(bodyPtr, i + 1);
+ bonesBase->baseElement /= sizeof(BonesBaseData);
}
}
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index a66084552e..8e689f1be4 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -101,6 +101,26 @@ struct BodyFlags {
uint16 unk16 : 1; // 1 << 15
};
+#include "common/pack-start.h"
+struct BonesBaseData {
+ int16 firstPoint = 0; // data1
+ int16 numOfPoints = 0; // data2
+ int16 basePoint = 0; // data3
+ int16 baseElement = 0; // param
+ int16 flag = 0;
+ int16 rotateZ = 0;
+ int16 rotateY = 0;
+ int16 rotateX = 0;
+ int32 numOfShades = 0; // field_10
+ int32 field_14 = 0;
+ int32 field_18 = 0;
+ int32 y = 0;
+ int32 field_20 = 0;
+ int16 field_24 = 0;
+};
+#include "common/pack-end.h"
+static_assert(sizeof(BonesBaseData) == 38, "Unexpected elementEntry size");
+
class Model {
private:
static uint8 *getBonesData(uint8 *bodyPtr) {
@@ -133,19 +153,23 @@ public:
}
static const BoneFrame *getBonesStateData(const uint8 *bodyPtr, int boneIdx) {
- return (const BoneFrame*)(getBonesBaseData(bodyPtr) + 8 + (boneIdx * 38));
+ assert(boneIdx <= getNumBones(bodyPtr));
+ return (const BoneFrame*)((const uint8*)getBonesBaseData(bodyPtr) + 8 + (boneIdx * sizeof(BonesBaseData)));
}
static BoneFrame *getBonesStateData(uint8 *bodyPtr, int boneIdx) {
- return (BoneFrame*)(getBonesBaseData(bodyPtr) + 8 + (boneIdx * 38));
+ assert(boneIdx <= getNumBones(bodyPtr));
+ return (BoneFrame*)((uint8*)getBonesBaseData(bodyPtr) + 8 + (boneIdx * sizeof(BonesBaseData)));
}
- static uint8 *getBonesBaseData(uint8 *bodyPtr) {
- return getBonesData(bodyPtr) + 2;
+ static BonesBaseData *getBonesBaseData(uint8 *bodyPtr, int boneIdx = 0) {
+ assert(boneIdx <= getNumBones(bodyPtr));
+ return (BonesBaseData *)(getBonesData(bodyPtr) + 2 + (boneIdx * sizeof(BonesBaseData)));
}
- static const uint8 *getBonesBaseData(const uint8 *bodyPtr, int boneIdx = 0) {
- return getBonesData(bodyPtr) + 2 + (boneIdx * 38);
+ static const BonesBaseData *getBonesBaseData(const uint8 *bodyPtr, int boneIdx = 0) {
+ assert(boneIdx <= getNumBones(bodyPtr));
+ return (const BonesBaseData *)(getBonesData(bodyPtr) + 2 + (boneIdx * sizeof(BonesBaseData)));
}
static int16 getNumBones(const uint8 *bodyPtr) {
@@ -161,13 +185,14 @@ public:
}
static const uint8 *getShadesBaseData(const uint8 *bodyPtr, int16 shadeIdx = 0) {
+ assert(shadeIdx <= getNumShades(bodyPtr));
return getShadesData(bodyPtr) + 2 + (shadeIdx * 8);
}
static const uint8 *getShadesData(const uint8 *bodyPtr) {
- const uint8 *bonesBase = getBonesBaseData(bodyPtr);
+ const uint8 *bonesBase = (const uint8 *)getBonesBaseData(bodyPtr);
const int16 numBones = getNumBones(bodyPtr);
- return bonesBase + numBones * 38;
+ return bonesBase + numBones * sizeof(BonesBaseData);
}
static int16 getNumShades(const uint8 *bodyPtr) {
@@ -176,8 +201,8 @@ public:
}
static int16 getNumShadesBone(const uint8 *bodyPtr, int boneIdx) {
- const uint8 *bonesBase = getBonesBaseData(bodyPtr);
- return READ_LE_INT16(bonesBase + (boneIdx * 38) + 18);
+ const uint8 *bonesBase = (const uint8 *)getBonesBaseData(bodyPtr, boneIdx);
+ return READ_LE_INT16(bonesBase + 18);
}
static const uint8 *getPolygonData(const uint8 *bodyPtr) {
@@ -195,26 +220,6 @@ public:
}
};
-#include "common/pack-start.h"
-struct elementEntry {
- int16 firstPoint = 0; // data1
- int16 numOfPoints = 0; // data2
- int16 basePoint = 0; // data3
- int16 baseElement = 0; // param
- int16 flag = 0;
- int16 rotateZ = 0;
- int16 rotateY = 0;
- int16 rotateX = 0;
- int32 numOfShades = 0; // field_10
- int32 field_14 = 0;
- int32 field_18 = 0;
- int32 y = 0;
- int32 field_20 = 0;
- int16 field_24 = 0;
-};
-#include "common/pack-end.h"
-static_assert(sizeof(elementEntry) == 38, "Unexpected elementEntry size");
-
class Renderer {
private:
TwinEEngine *_engine;
@@ -285,9 +290,9 @@ private:
void getCameraAnglePositions(int32 x, int32 y, int32 z);
void applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *currentMatrix);
void applyPointsRotation(const pointTab *pointsPtr, int32 numPoints, pointTab *destPoints, const IMatrix3x3 *rotationMatrix);
- void processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const elementEntry *elemPtr, ModelData *modelData);
+ void processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const BonesBaseData *elemPtr, ModelData *modelData);
void applyPointsTranslation(const pointTab *pointsPtr, int32 numPoints, pointTab *destPoints, const IMatrix3x3 *translationMatrix);
- void processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const elementEntry *elemPtr, ModelData *modelData);
+ void processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const BonesBaseData *elemPtr, ModelData *modelData);
void translateGroup(int32 x, int32 y, int32 z);
// ---- variables ----
Commit: c93360da16082a7126ef37a8d8ef823d7d3391d0
https://github.com/scummvm/scummvm/commit/c93360da16082a7126ef37a8d8ef823d7d3391d0
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: cleanup in Model functions
Changed paths:
engines/twine/renderer/renderer.h
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 8e689f1be4..88053a69c6 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -111,12 +111,13 @@ struct BonesBaseData {
int16 rotateZ = 0;
int16 rotateY = 0;
int16 rotateX = 0;
- int32 numOfShades = 0; // field_10
- int32 field_14 = 0;
+ int16 unk1 = 0; // field_10
+ int16 numOfShades = 0;
+ int16 unk2 = 0;
int32 field_18 = 0;
int32 y = 0;
int32 field_20 = 0;
- int16 field_24 = 0;
+ int32 field_24 = 0;
};
#include "common/pack-end.h"
static_assert(sizeof(BonesBaseData) == 38, "Unexpected elementEntry size");
@@ -173,9 +174,7 @@ public:
}
static int16 getNumBones(const uint8 *bodyPtr) {
- const uint8 *verticesBase = getData(bodyPtr);
- const int16 numVertices = READ_LE_INT16(verticesBase);
- const uint8 *bonesBase = verticesBase + 2 + numVertices * 6;
+ const uint8 *bonesBase = getBonesData(bodyPtr);
return READ_LE_INT16(bonesBase);
}
@@ -190,9 +189,8 @@ public:
}
static const uint8 *getShadesData(const uint8 *bodyPtr) {
- const uint8 *bonesBase = (const uint8 *)getBonesBaseData(bodyPtr);
const int16 numBones = getNumBones(bodyPtr);
- return bonesBase + numBones * sizeof(BonesBaseData);
+ return (const uint8 *)getBonesBaseData(bodyPtr, numBones);
}
static int16 getNumShades(const uint8 *bodyPtr) {
@@ -201,8 +199,7 @@ public:
}
static int16 getNumShadesBone(const uint8 *bodyPtr, int boneIdx) {
- const uint8 *bonesBase = (const uint8 *)getBonesBaseData(bodyPtr, boneIdx);
- return READ_LE_INT16(bonesBase + 18);
+ return getBonesBaseData(bodyPtr, boneIdx)->numOfShades;
}
static const uint8 *getPolygonData(const uint8 *bodyPtr) {
Commit: ae68a82917312e3a299138a55d8e47dd1f5a9edf
https://github.com/scummvm/scummvm/commit/ae68a82917312e3a299138a55d8e47dd1f5a9edf
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: removed Renderer::prepareIsoModel
Changed paths:
engines/twine/holomap.cpp
engines/twine/renderer/renderer.cpp
engines/twine/renderer/renderer.h
engines/twine/resources/resources.cpp
engines/twine/scene/actor.cpp
engines/twine/scene/gamestate.cpp
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 3431734a0a..1df401addc 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -324,7 +324,6 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
animData.loadFromHQR(Resources::HQR_RESS_FILE, data.getAnimation());
uint8 *modelPtr = nullptr;
HQR::getAllocEntry(&modelPtr, Resources::HQR_RESS_FILE, data.getModel());
- Renderer::prepareIsoModel(modelPtr);
uint frameNumber = 0;
int32 frameTime = _engine->lbaTime;
int16 trajAnimFrameIdx = 0;
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index e3dba1de63..0445c8e5c7 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -328,9 +328,9 @@ void Renderer::applyPointsRotation(const pointTab *pointsPtr, int32 numPoints, p
} while (--numOfPoints2);
}
-void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const BonesBaseData *elemPtr, ModelData *modelData) {
- int32 firstPoint = elemPtr->firstPoint / sizeof(pointTab);
- int32 numOfPoints2 = elemPtr->numOfPoints;
+void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const BonesBaseData *boneData, ModelData *modelData) {
+ int32 firstPoint = boneData->firstPoint / sizeof(pointTab);
+ int32 numOfPoints2 = boneData->numOfPoints;
renderAngleX = rotX;
renderAngleY = rotY;
@@ -338,15 +338,15 @@ void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *p
const IMatrix3x3 *currentMatrix;
// if its the first point
- if (elemPtr->baseElement == -1) {
+ if (boneData->baseElement == -1) {
currentMatrix = &baseMatrix;
destPos.x = 0;
destPos.y = 0;
destPos.z = 0;
} else {
- const int32 pointIdx = elemPtr->basePoint / sizeof(pointTab);
- const int32 matrixIndex = elemPtr->baseElement;
+ const int32 pointIdx = boneData->basePoint / sizeof(pointTab);
+ const int32 matrixIndex = boneData->baseElement / sizeof(BonesBaseData);
assert(matrixIndex >= 0 && matrixIndex < ARRAYSIZE(matricesTable));
currentMatrix = &matricesTable[matrixIndex];
@@ -381,29 +381,29 @@ void Renderer::applyPointsTranslation(const pointTab *pointsPtr, int32 numPoints
} while (--numOfPoints2);
}
-void Renderer::processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const BonesBaseData *elemPtr, ModelData *modelData) {
+void Renderer::processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const BonesBaseData *boneData, ModelData *modelData) {
renderAngleX = rotX;
renderAngleY = rotY;
renderAngleZ = rotZ;
- if (elemPtr->baseElement == -1) { // base point
+ if (boneData->baseElement == -1) { // base point
destPos.x = 0;
destPos.y = 0;
destPos.z = 0;
*targetMatrix = baseMatrix;
} else { // dependent
- const int pointsIdx = elemPtr->basePoint / 6;
+ const int32 pointsIdx = boneData->basePoint / sizeof(pointTab);
destPos.x = modelData->computedPoints[pointsIdx].x;
destPos.y = modelData->computedPoints[pointsIdx].y;
destPos.z = modelData->computedPoints[pointsIdx].z;
- const int32 matrixIndex = elemPtr->baseElement;
+ const int32 matrixIndex = boneData->baseElement / sizeof(BonesBaseData);
assert(matrixIndex >= 0 && matrixIndex < ARRAYSIZE(matricesTable));
*targetMatrix = matricesTable[matrixIndex];
}
- applyPointsTranslation(&pointsPtr[elemPtr->firstPoint / sizeof(pointTab)], elemPtr->numOfPoints, &modelData->computedPoints[elemPtr->firstPoint / sizeof(pointTab)], targetMatrix);
+ applyPointsTranslation(&pointsPtr[boneData->firstPoint / sizeof(pointTab)], boneData->numOfPoints, &modelData->computedPoints[boneData->firstPoint / sizeof(pointTab)], targetMatrix);
}
void Renderer::setLightVector(int32 angleX, int32 angleY, int32 angleZ) {
@@ -1308,8 +1308,8 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
IMatrix3x3 *modelMatrix = &matricesTable[0];
- const BonesBaseData *bonesPtr0 = Model::getBonesBaseData(bodyPtr, 0);
- processRotatedElement(modelMatrix, pointsPtr, renderAngleX, renderAngleY, renderAngleZ, bonesPtr0, modelData);
+ const BonesBaseData *boneData = Model::getBonesBaseData(bodyPtr, 0);
+ processRotatedElement(modelMatrix, pointsPtr, renderAngleX, renderAngleY, renderAngleZ, boneData, modelData);
int32 numOfPrimitives = 0;
@@ -1319,13 +1319,13 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
int boneIdx = 1;
do {
- const BonesBaseData *bonesPtr = Model::getBonesBaseData(bodyPtr, boneIdx);
- int16 boneType = bonesPtr->flag;
+ boneData = Model::getBonesBaseData(bodyPtr, boneIdx);
+ int16 boneType = boneData->flag;
if (boneType == 0) {
- processRotatedElement(modelMatrix, pointsPtr, bonesPtr->rotateX, bonesPtr->rotateY, bonesPtr->rotateZ, bonesPtr, modelData);
+ processRotatedElement(modelMatrix, pointsPtr, boneData->rotateX, boneData->rotateY, boneData->rotateZ, boneData, modelData);
} else if (boneType == 1) {
- processTranslatedElement(modelMatrix, pointsPtr, bonesPtr->rotateX, bonesPtr->rotateY, bonesPtr->rotateZ, bonesPtr, modelData);
+ processTranslatedElement(modelMatrix, pointsPtr, boneData->rotateX, boneData->rotateY, boneData->rotateZ, boneData, modelData);
}
++modelMatrix;
@@ -1481,30 +1481,6 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
return renderModelElements(numOfPrimitives, Model::getPolygonData(bodyPtr), &renderCmds, modelData);
}
-void Renderer::prepareIsoModel(uint8 *bodyPtr) { // loadGfxSub
- BodyFlags *bodyHeader = (BodyFlags *)bodyPtr;
-
- // This function should only be called ONCE, otherwise it corrupts the model data.
- // The following code implements an unused flag to indicate that a model was already processed.
- if (bodyHeader->alreadyPrepared) {
- return;
- }
- bodyHeader->alreadyPrepared = 1;
-
- // no animation applicable
- if (!Model::isAnimated(bodyPtr)) {
- return;
- }
-
- const int16 numBones = Model::getNumBones(bodyPtr);
-
- // set up bone indices
- for (int32 i = 0; i < numBones; i++) {
- BonesBaseData *bonesBase = Model::getBonesBaseData(bodyPtr, i + 1);
- bonesBase->baseElement /= sizeof(BonesBaseData);
- }
-}
-
bool Renderer::renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 angleY, int32 angleZ, const uint8 *bodyPtr) {
renderAngleX = angleX;
renderAngleY = angleY;
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 88053a69c6..cbba2acac4 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -82,25 +82,6 @@ inline IMatrix3x3 operator*(const IMatrix3x3 &matrix, const IVec3 &vec) {
return out;
}
-struct BodyFlags {
- uint16 unk1 : 1; // 1 << 0
- uint16 animated : 1; // 1 << 1
- uint16 unk3 : 1; // 1 << 2
- uint16 unk4 : 1; // 1 << 3
- uint16 unk5 : 1; // 1 << 4
- uint16 unk6 : 1; // 1 << 5
- uint16 unk7 : 1; // 1 << 6
- uint16 alreadyPrepared : 1; // 1 << 7
- uint16 unk9 : 1; // 1 << 8
- uint16 unk10 : 1; // 1 << 9
- uint16 unk11 : 1; // 1 << 10
- uint16 unk12 : 1; // 1 << 11
- uint16 unk13 : 1; // 1 << 12
- uint16 unk14 : 1; // 1 << 13
- uint16 unk15 : 1; // 1 << 14
- uint16 unk16 : 1; // 1 << 15
-};
-
#include "common/pack-start.h"
struct BonesBaseData {
int16 firstPoint = 0; // data1
@@ -210,7 +191,7 @@ public:
}
const int16 bones = getNumBones(bodyPtr);
for (int16 boneIdx = 0; boneIdx < bones; ++boneIdx) {
- int16 numOfShades = Model::getNumShadesBone(bodyPtr, boneIdx);
+ int16 numOfShades = getNumShadesBone(bodyPtr, boneIdx);
shades += numOfShades * 8;
}
return shades;
@@ -287,9 +268,9 @@ private:
void getCameraAnglePositions(int32 x, int32 y, int32 z);
void applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *currentMatrix);
void applyPointsRotation(const pointTab *pointsPtr, int32 numPoints, pointTab *destPoints, const IMatrix3x3 *rotationMatrix);
- void processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const BonesBaseData *elemPtr, ModelData *modelData);
+ void processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const BonesBaseData *boneData, ModelData *modelData);
void applyPointsTranslation(const pointTab *pointsPtr, int32 numPoints, pointTab *destPoints, const IMatrix3x3 *translationMatrix);
- void processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const BonesBaseData *elemPtr, ModelData *modelData);
+ void processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const BonesBaseData *boneData, ModelData *modelData);
void translateGroup(int32 x, int32 y, int32 z);
// ---- variables ----
@@ -376,7 +357,6 @@ public:
void setLightVector(int32 angleX, int32 angleY, int32 angleZ);
void getBaseRotationPosition(int32 x, int32 y, int32 z);
- static void prepareIsoModel(uint8 *bodyPtr);
void renderPolygons(const CmdRenderPolygon &polygon, Vertex *vertices);
inline int32 projectPositionOnScreen(const IVec3& pos) {
diff --git a/engines/twine/resources/resources.cpp b/engines/twine/resources/resources.cpp
index 5d5e6fece0..8e07a5393e 100644
--- a/engines/twine/resources/resources.cpp
+++ b/engines/twine/resources/resources.cpp
@@ -139,7 +139,6 @@ void Resources::preloadInventoryItems() {
debug("preload %i inventory items", numEntries);
for (int32 i = 0; i < numEntries; i++) {
inventorySizeTable[i] = HQR::getAllocEntry(&inventoryTable[i], Resources::HQR_INVOBJ_FILE, i);
- Renderer::prepareIsoModel(_engine->_resources->inventoryTable[i]);
}
}
@@ -180,25 +179,21 @@ void Resources::initResources() {
if (holomapTwinsenModelSize == 0) {
error("Failed to load holomap twinsen model");
}
- Renderer::prepareIsoModel(holomapTwinsenModelPtr);
holomapPointModelSize = HQR::getAllocEntry(&holomapPointModelPtr, Resources::HQR_RESS_FILE, RESSHQR_HOLOPOINTMDL);
if (holomapPointModelSize == 0) {
error("Failed to load holomap point model");
}
- Renderer::prepareIsoModel(holomapPointModelPtr);
holomapArrowSize = HQR::getAllocEntry(&holomapArrowPtr, Resources::HQR_RESS_FILE, RESSHQR_HOLOARROWMDL);
if (holomapArrowSize == 0) {
error("Failed to load holomap arrow model");
}
- Renderer::prepareIsoModel(holomapArrowPtr);
holomapTwinsenArrowSize = HQR::getAllocEntry(&holomapTwinsenArrowPtr, Resources::HQR_RESS_FILE, RESSHQR_HOLOTWINARROWMDL);
if (holomapTwinsenArrowSize == 0) {
error("Failed to load holomap twinsen arrow model");
}
- Renderer::prepareIsoModel(holomapTwinsenArrowPtr);
holomapPointAnimSize = HQR::getAllocEntry(&holomapPointAnimPtr, Resources::HQR_RESS_FILE, RESSHQR_HOLOPOINTANIM);
if (holomapPointAnimSize == 0) {
diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index 578fc64477..82a01a3321 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -197,7 +197,6 @@ int32 Actor::initBody(BodyType bodyIdx, int32 actorIdx, ActorBoundingBox &actorB
error("HQR ERROR: Loading body entities");
}
bodyData[index].loadFromBuffer(bodyTable[index], bodyTableSize[index]);
- Renderer::prepareIsoModel(bodyTable[index]);
stream.seek(stream.pos() - sizeof(uint16));
stream.writeUint16LE(index + 0x8000);
} else {
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index 70c0db437c..c7bc19f9d1 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -500,7 +500,6 @@ void GameState::processGameoverAnimation() {
return;
}
- Renderer::prepareIsoModel(gameOverPtr);
_engine->_sound->stopSamples();
_engine->_music->stopMidiMusic(); // stop fade music
_engine->_renderer->setCameraPosition(_engine->width() / 2, _engine->height() / 2, 128, 200, 200);
Commit: 87cd84b703a234bc2e006a1c2c2e4bd1653c8117
https://github.com/scummvm/scummvm/commit/87cd84b703a234bc2e006a1c2c2e4bd1653c8117
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: fixed invalid numOfShades for body parser
Changed paths:
engines/twine/parser/body.cpp
diff --git a/engines/twine/parser/body.cpp b/engines/twine/parser/body.cpp
index 2a5f51c299..4ff8b83b28 100644
--- a/engines/twine/parser/body.cpp
+++ b/engines/twine/parser/body.cpp
@@ -53,12 +53,13 @@ void BodyData::loadBones(Common::SeekableReadStream &stream) {
boneframe.x = stream.readSint16LE();
boneframe.y = stream.readSint16LE();
boneframe.z = stream.readSint16LE();
- const int32 numOfShades = stream.readSint32LE();
- /*int32 field_14 =*/ stream.readSint32LE();
+ /*int16 unk1 =*/ stream.readSint16LE();
+ const int16 numOfShades = stream.readSint16LE();
+ /*int16 unk2 =*/ stream.readSint16LE();
/*int32 field_18 =*/ stream.readSint32LE();
/*int32 y =*/ stream.readSint32LE();
/*int32 field_20 =*/ stream.readSint32LE();
- /*int16 field_24 =*/ stream.readSint16LE();
+ /*int32 field_24 =*/ stream.readSint32LE();
BodyBone bone;
bone.parent = baseElementOffset == -1 ? 0xffff : baseElementOffset / 38;
Commit: ac5424fa4c81a9ec012f7a0d2daabd33c1b71628
https://github.com/scummvm/scummvm/commit/ac5424fa4c81a9ec012f7a0d2daabd33c1b71628
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: moved bodyTable into Resourced class
Changed paths:
engines/twine/menu/menu.cpp
engines/twine/renderer/redraw.cpp
engines/twine/resources/resources.cpp
engines/twine/resources/resources.h
engines/twine/scene/actor.cpp
engines/twine/scene/actor.h
engines/twine/scene/animations.cpp
engines/twine/scene/gamestate.cpp
diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp
index 18c006badf..7192c77ba9 100644
--- a/engines/twine/menu/menu.cpp
+++ b/engines/twine/menu/menu.cpp
@@ -1011,7 +1011,7 @@ void Menu::processBehaviourMenu() {
_engine->_actor->setBehaviour(HeroBehaviourType::kNormal);
}
- behaviourEntity = _engine->_actor->bodyTable[_engine->_scene->sceneHero->entity];
+ behaviourEntity = _engine->_resources->bodyTable[_engine->_scene->sceneHero->entity];
_engine->_actor->heroAnimIdx[(byte)HeroBehaviourType::kNormal] = _engine->_actor->heroAnimIdxNORMAL;
_engine->_actor->heroAnimIdx[(byte)HeroBehaviourType::kAthletic] = _engine->_actor->heroAnimIdxATHLETIC;
diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index b200eb7965..ccb910b95c 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -343,13 +343,13 @@ void Redraw::processDrawListActors(const DrawListStruct &drawCmd, bool bgRedraw)
ActorStruct *actor = _engine->_scene->getActor(actorIdx);
if (actor->previousAnimIdx >= 0) {
const AnimData &animData = _engine->_resources->animData[actor->previousAnimIdx];
- _engine->_animations->setModelAnimation(actor->animPosition, animData, _engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
+ _engine->_animations->setModelAnimation(actor->animPosition, animData, _engine->_resources->bodyTable[actor->entity], &actor->animTimerData);
}
const int32 x = actor->pos.x - _engine->_grid->camera.x;
const int32 y = actor->pos.y - _engine->_grid->camera.y;
const int32 z = actor->pos.z - _engine->_grid->camera.z;
- if (!_engine->_renderer->renderIsoModel(x, y, z, ANGLE_0, actor->angle, ANGLE_0, _engine->_actor->bodyTable[actor->entity])) {
+ if (!_engine->_renderer->renderIsoModel(x, y, z, ANGLE_0, actor->angle, ANGLE_0, _engine->_resources->bodyTable[actor->entity])) {
return;
}
diff --git a/engines/twine/resources/resources.cpp b/engines/twine/resources/resources.cpp
index 8e07a5393e..1931c0397b 100644
--- a/engines/twine/resources/resources.cpp
+++ b/engines/twine/resources/resources.cpp
@@ -43,6 +43,9 @@ Resources::~Resources() {
for (size_t i = 0; i < ARRAYSIZE(samplesTable); ++i) {
free(samplesTable[i]);
}
+ for (size_t i = 0; i < ARRAYSIZE(bodyTable); ++i) {
+ free(bodyTable[i]);
+ }
free(fontPtr);
free(spriteShadowPtr);
free(holomapSurfacePtr);
diff --git a/engines/twine/resources/resources.h b/engines/twine/resources/resources.h
index 27a7237aba..bad5cfa3ff 100644
--- a/engines/twine/resources/resources.h
+++ b/engines/twine/resources/resources.h
@@ -169,6 +169,11 @@ public:
AnimData animData[NUM_ANIMS];
+ /** Actors 3D body table - size of NUM_BODIES */
+ uint8 *bodyTable[NUM_BODIES]{nullptr};
+ int32 bodyTableSize[NUM_BODIES]{0};
+ BodyData bodyData[NUM_BODIES];
+
/** Table with all loaded samples */
uint8 *samplesTable[NUM_SAMPLES]{nullptr};
/** Table with all loaded samples sizes */
diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index 82a01a3321..92c1448a59 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -50,10 +50,6 @@ Actor::~Actor() {
free(heroEntityAGGRESSIVE);
free(heroEntityDISCRETE);
free(heroEntityPROTOPACK);
-
- for (size_t i = 0; i < ARRAYSIZE(bodyTable); ++i) {
- free(bodyTable[i]);
- }
}
void Actor::restartHeroScene() {
@@ -192,11 +188,11 @@ int32 Actor::initBody(BodyType bodyIdx, int32 actorIdx, ActorBoundingBox &actorB
if (!(bodyIndex & 0x8000)) {
index = currentPositionInBodyPtrTab;
currentPositionInBodyPtrTab++;
- bodyTableSize[index] = HQR::getAllocEntry(&bodyTable[index], Resources::HQR_BODY_FILE, bodyIndex & 0xFFFF);
- if (bodyTableSize[index] == 0) {
+ _engine->_resources->bodyTableSize[index] = HQR::getAllocEntry(&_engine->_resources->bodyTable[index], Resources::HQR_BODY_FILE, bodyIndex & 0xFFFF);
+ if (_engine->_resources->bodyTableSize[index] == 0) {
error("HQR ERROR: Loading body entities");
}
- bodyData[index].loadFromBuffer(bodyTable[index], bodyTableSize[index]);
+ _engine->_resources->bodyData[index].loadFromBuffer(_engine->_resources->bodyTable[index], _engine->_resources->bodyTableSize[index]);
stream.seek(stream.pos() - sizeof(uint16));
stream.writeUint16LE(index + 0x8000);
} else {
@@ -268,7 +264,7 @@ void Actor::initModelActor(BodyType bodyIdx, int16 actorIdx) {
bbox.maxs.z = actorBoundingBox.bbox.maxs.z;
} else {
BoundingBox &bbox = localActor->boudingBox;
- const BodyData &bd = bodyData[localActor->entity];
+ const BodyData &bd = _engine->_resources->bodyData[localActor->entity];
bbox.mins.y = bd.bbox.mins.y;
bbox.maxs.y = bd.bbox.maxs.y;
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 4c19fc0079..e2dce0cfd3 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -319,11 +319,6 @@ public:
/** Hero anim for behaviour menu */
int16 heroAnimIdx[4];
- /** Actors 3D body table - size of NUM_BODIES */
- uint8 *bodyTable[NUM_BODIES]{nullptr};
- int32 bodyTableSize[NUM_BODIES]{0};
- BodyData bodyData[NUM_BODIES];
-
/** Current position in body table */
int32 currentPositionInBodyPtrTab;
void clearBodyTable();
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index f5be03d4e7..44ff927b97 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -433,10 +433,10 @@ bool Animations::initAnim(AnimationTypes newAnim, int16 animType, AnimationTypes
if (actor->previousAnimIdx == -1) {
// if no previous animation
- setAnimAtKeyframe(0, _engine->_resources->animData[animIndex], _engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
+ setAnimAtKeyframe(0, _engine->_resources->animData[animIndex], _engine->_resources->bodyTable[actor->entity], &actor->animTimerData);
} else {
// interpolation between animations
- stockAnimation(_engine->_actor->bodyTable[actor->entity], &actor->animTimerData);
+ stockAnimation(_engine->_resources->bodyTable[actor->entity], &actor->animTimerData);
}
actor->previousAnimIdx = animIndex;
@@ -565,7 +565,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
const AnimData &animData = _engine->_resources->animData[actor->previousAnimIdx];
bool keyFramePassed = false;
- if (Model::isAnimated(_engine->_actor->bodyTable[actor->entity])) {
+ if (Model::isAnimated(_engine->_resources->bodyTable[actor->entity])) {
keyFramePassed = verifyAnimAtKeyframe(actor->animPosition, animData, &actor->animTimerData);
}
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index c7bc19f9d1..fb91ac4651 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -321,7 +321,7 @@ void GameState::processFoundItem(int32 item) {
const int32 itemCameraY = _engine->_grid->newCamera.y * BRICK_HEIGHT;
const int32 itemCameraZ = _engine->_grid->newCamera.z * BRICK_SIZE;
- uint8 *bodyPtr = _engine->_actor->bodyTable[_engine->_scene->sceneHero->entity];
+ uint8 *bodyPtr = _engine->_resources->bodyTable[_engine->_scene->sceneHero->entity];
const int32 bodyX = _engine->_scene->sceneHero->pos.x - itemCameraX;
const int32 bodyY = _engine->_scene->sceneHero->pos.y - itemCameraY;
const int32 bodyZ = _engine->_scene->sceneHero->pos.z - itemCameraZ;
Commit: 107d356ab881f319b7b9a790534a80d35ffc3692
https://github.com/scummvm/scummvm/commit/107d356ab881f319b7b9a790534a80d35ffc3692
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: validate body loading
Changed paths:
engines/twine/parser/body.cpp
engines/twine/renderer/renderer.h
engines/twine/scene/actor.cpp
diff --git a/engines/twine/parser/body.cpp b/engines/twine/parser/body.cpp
index 4ff8b83b28..1abf4c07eb 100644
--- a/engines/twine/parser/body.cpp
+++ b/engines/twine/parser/body.cpp
@@ -101,14 +101,14 @@ void BodyData::loadPolygons(Common::SeekableReadStream &stream) {
poly.color = stream.readUint16LE();
int16 intensity = -1;
- if (poly.renderType >= 7 && poly.renderType < 9) {
+ if (poly.renderType == POLYGONTYPE_GOURAUD || poly.renderType == POLYGONTYPE_DITHER) {
intensity = stream.readSint16LE();
}
poly.indices.reserve(numVertex);
poly.intensities.reserve(numVertex);
for (int k = 0; k < numVertex; ++k) {
- if (poly.renderType >= 9) {
+ if (poly.renderType >= POLYGONTYPE_UNKNOWN) {
intensity = stream.readSint16LE();
}
const uint16 vertexIndex = stream.readUint16LE() / 6;
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index cbba2acac4..d434f11712 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -38,6 +38,7 @@
#define POLYGONTYPE_TRAME 6
#define POLYGONTYPE_GOURAUD 7
#define POLYGONTYPE_DITHER 8
+#define POLYGONTYPE_UNKNOWN 9
namespace Common {
class MemoryReadStream;
diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index 92c1448a59..ea34665926 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -190,9 +190,11 @@ int32 Actor::initBody(BodyType bodyIdx, int32 actorIdx, ActorBoundingBox &actorB
currentPositionInBodyPtrTab++;
_engine->_resources->bodyTableSize[index] = HQR::getAllocEntry(&_engine->_resources->bodyTable[index], Resources::HQR_BODY_FILE, bodyIndex & 0xFFFF);
if (_engine->_resources->bodyTableSize[index] == 0) {
- error("HQR ERROR: Loading body entities");
+ error("HQR ERROR: Loading body entity for actor %i: %i", actorIdx, (int)bodyIdx);
+ }
+ if (!_engine->_resources->bodyData[index].loadFromBuffer(_engine->_resources->bodyTable[index], _engine->_resources->bodyTableSize[index])) {
+ error("HQR ERROR: Parsing body entity for actor %i: %i", actorIdx, (int)bodyIdx);
}
- _engine->_resources->bodyData[index].loadFromBuffer(_engine->_resources->bodyTable[index], _engine->_resources->bodyTableSize[index]);
stream.seek(stream.pos() - sizeof(uint16));
stream.writeUint16LE(index + 0x8000);
} else {
Commit: d4282fca9d8d4bc355409727c1da54e66318460d
https://github.com/scummvm/scummvm/commit/d4282fca9d8d4bc355409727c1da54e66318460d
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: reduce visibility
Changed paths:
engines/twine/renderer/renderer.h
engines/twine/scene/animations.cpp
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index d434f11712..870f5adb14 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -117,11 +117,6 @@ private:
const int16 numVertices = READ_LE_INT16(verticesBase);
return verticesBase + 2 + numVertices * 6;
}
-public:
- static inline bool isAnimated(const uint8 *bodyPtr) {
- const int16 bodyHeader = READ_LE_INT16(bodyPtr);
- return (bodyHeader & 2) != 0;
- }
static uint8 *getData(uint8 *bodyPtr) {
return bodyPtr + 0x1A;
@@ -130,6 +125,11 @@ public:
static const uint8 *getData(const uint8 *bodyPtr) {
return bodyPtr + 0x1A;
}
+public:
+ static inline bool isAnimated(const uint8 *bodyPtr) {
+ const int16 bodyHeader = READ_LE_INT16(bodyPtr);
+ return (bodyHeader & 2) != 0;
+ }
static const uint8 *getVerticesBaseData(const uint8 *bodyPtr) {
return getData(bodyPtr) + 2;
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index 44ff927b97..97bfc35a43 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -56,6 +56,7 @@ Animations::Animations(TwinEEngine *engine) : _engine(engine) {
int32 Animations::getBodyAnimIndex(AnimationTypes animIdx, int32 actorIdx) {
ActorStruct *actor = _engine->_scene->getActor(actorIdx);
+ // TODO: cache this
EntityData entityData;
entityData.loadFromBuffer(actor->entityDataPtr, actor->entityDataSize);
const int32 bodyAnimIndex = entityData.getAnimIndex(animIdx);
@@ -272,6 +273,7 @@ void Animations::processAnimActions(int32 actorIdx) {
return;
}
+ // TODO: cache this
EntityData entityData;
entityData.loadFromBuffer(actor->entityDataPtr, actor->entityDataSize);
const Common::Array<EntityAnim::Action> *actions = entityData.getActions(actor->animExtraPtr);
Commit: c458c8d95582a4208b155a92c1606020522b8412
https://github.com/scummvm/scummvm/commit/c458c8d95582a4208b155a92c1606020522b8412
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: converted to IVec3
Changed paths:
engines/twine/renderer/renderer.cpp
engines/twine/renderer/renderer.h
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 0445c8e5c7..b3b4de599f 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -249,8 +249,8 @@ void Renderer::applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *current
IMatrix3x3 matrix1;
IMatrix3x3 matrix2;
- if (renderAngleX) {
- int32 angle = renderAngleX;
+ if (renderAngle.x) {
+ int32 angle = renderAngle.x;
int32 angleVar2 = shadeAngleTable[ClampAngle(angle)];
angle += ANGLE_90;
int32 angleVar1 = shadeAngleTable[ClampAngle(angle)];
@@ -269,8 +269,8 @@ void Renderer::applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *current
matrix1 = *currentMatrix;
}
- if (renderAngleZ) {
- int32 angle = renderAngleZ;
+ if (renderAngle.z) {
+ int32 angle = renderAngle.z;
int32 angleVar2 = shadeAngleTable[ClampAngle(angle)];
angle += ANGLE_90;
int32 angleVar1 = shadeAngleTable[ClampAngle(angle)];
@@ -289,8 +289,8 @@ void Renderer::applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *current
matrix2 = matrix1;
}
- if (renderAngleY) {
- int32 angle = renderAngleY;
+ if (renderAngle.y) {
+ int32 angle = renderAngle.y;
int32 angleVar2 = shadeAngleTable[ClampAngle(angle)];
angle += ANGLE_90;
int32 angleVar1 = shadeAngleTable[ClampAngle(angle)];
@@ -332,9 +332,9 @@ void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *p
int32 firstPoint = boneData->firstPoint / sizeof(pointTab);
int32 numOfPoints2 = boneData->numOfPoints;
- renderAngleX = rotX;
- renderAngleY = rotY;
- renderAngleZ = rotZ;
+ renderAngle.x = rotX;
+ renderAngle.y = rotY;
+ renderAngle.z = rotZ;
const IMatrix3x3 *currentMatrix;
// if its the first point
@@ -368,9 +368,9 @@ void Renderer::applyPointsTranslation(const pointTab *pointsPtr, int32 numPoints
int32 numOfPoints2 = numPoints;
do {
- const int32 tmpX = pointsPtr->x + renderAngleZ;
- const int32 tmpY = pointsPtr->y + renderAngleY;
- const int32 tmpZ = pointsPtr->z + renderAngleX;
+ const int32 tmpX = pointsPtr->x + renderAngle.z;
+ const int32 tmpY = pointsPtr->y + renderAngle.y;
+ const int32 tmpZ = pointsPtr->z + renderAngle.x;
destPoints->x = ((translationMatrix->row1[0] * tmpX + translationMatrix->row1[1] * tmpY + translationMatrix->row1[2] * tmpZ) / SCENE_SIZE_HALF) + destPos.x;
destPoints->y = ((translationMatrix->row2[0] * tmpX + translationMatrix->row2[1] * tmpY + translationMatrix->row2[2] * tmpZ) / SCENE_SIZE_HALF) + destPos.y;
@@ -382,9 +382,9 @@ void Renderer::applyPointsTranslation(const pointTab *pointsPtr, int32 numPoints
}
void Renderer::processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const BonesBaseData *boneData, ModelData *modelData) {
- renderAngleX = rotX;
- renderAngleY = rotY;
- renderAngleZ = rotZ;
+ renderAngle.x = rotX;
+ renderAngle.y = rotY;
+ renderAngle.z = rotZ;
if (boneData->baseElement == -1) { // base point
destPos.x = 0;
@@ -412,9 +412,9 @@ void Renderer::setLightVector(int32 angleX, int32 angleY, int32 angleZ) {
_cameraAngleY = angleY;
_cameraAngleZ = angleZ;*/
- renderAngleX = angleX;
- renderAngleY = angleY;
- renderAngleZ = angleZ;
+ renderAngle.x = angleX;
+ renderAngle.y = angleY;
+ renderAngle.z = angleZ;
applyRotation(&shadeMatrix, &baseMatrix);
translateGroup(0, 0, 59);
@@ -1309,7 +1309,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
IMatrix3x3 *modelMatrix = &matricesTable[0];
const BonesBaseData *boneData = Model::getBonesBaseData(bodyPtr, 0);
- processRotatedElement(modelMatrix, pointsPtr, renderAngleX, renderAngleY, renderAngleZ, boneData, modelData);
+ processRotatedElement(modelMatrix, pointsPtr, renderAngle.x, renderAngle.y, renderAngle.z, boneData, modelData);
int32 numOfPrimitives = 0;
@@ -1482,9 +1482,9 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
}
bool Renderer::renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 angleY, int32 angleZ, const uint8 *bodyPtr) {
- renderAngleX = angleX;
- renderAngleY = angleY;
- renderAngleZ = angleZ;
+ renderAngle.x = angleX;
+ renderAngle.y = angleY;
+ renderAngle.z = angleZ;
// model render size reset
_engine->_redraw->renderRect.left = SCENE_SIZE_MAX;
@@ -1499,9 +1499,7 @@ bool Renderer::renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 ang
} else {
getBaseRotationPosition(x, y, z);
- renderPos.x = destPos.x - baseRotPos.x;
- renderPos.y = destPos.y - baseRotPos.y; // RECHECK
- renderPos.z = destPos.z - baseRotPos.z;
+ renderPos = destPos - baseRotPos; // RECHECK y
}
if (!Model::isAnimated(bodyPtr)) {
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 870f5adb14..4957f26048 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -284,9 +284,7 @@ private:
// ---
- int32 renderAngleX = 0; // _angleX
- int32 renderAngleY = 0; // _angleY
- int32 renderAngleZ = 0; // _angleZ
+ IVec3 renderAngle;
IVec3 renderPos;
Commit: 4dee4ffddd88e1741b754f196c6d2c83b4315946
https://github.com/scummvm/scummvm/commit/4dee4ffddd88e1741b754f196c6d2c83b4315946
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: removed member var
Changed paths:
engines/twine/renderer/renderer.cpp
engines/twine/renderer/renderer.h
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index b3b4de599f..1a18970148 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -245,12 +245,12 @@ IVec3 Renderer::getHolomapRotation(const int32 angleX, const int32 angleY, const
return vec;
}
-void Renderer::applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *currentMatrix) {
+void Renderer::applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *currentMatrix, const IVec3 &angleVec) {
IMatrix3x3 matrix1;
IMatrix3x3 matrix2;
- if (renderAngle.x) {
- int32 angle = renderAngle.x;
+ if (angleVec.x) {
+ int32 angle = angleVec.x;
int32 angleVar2 = shadeAngleTable[ClampAngle(angle)];
angle += ANGLE_90;
int32 angleVar1 = shadeAngleTable[ClampAngle(angle)];
@@ -269,8 +269,8 @@ void Renderer::applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *current
matrix1 = *currentMatrix;
}
- if (renderAngle.z) {
- int32 angle = renderAngle.z;
+ if (angleVec.z) {
+ int32 angle = angleVec.z;
int32 angleVar2 = shadeAngleTable[ClampAngle(angle)];
angle += ANGLE_90;
int32 angleVar1 = shadeAngleTable[ClampAngle(angle)];
@@ -289,8 +289,8 @@ void Renderer::applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *current
matrix2 = matrix1;
}
- if (renderAngle.y) {
- int32 angle = renderAngle.y;
+ if (angleVec.y) {
+ int32 angle = angleVec.y;
int32 angleVar2 = shadeAngleTable[ClampAngle(angle)];
angle += ANGLE_90;
int32 angleVar1 = shadeAngleTable[ClampAngle(angle)];
@@ -332,6 +332,7 @@ void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *p
int32 firstPoint = boneData->firstPoint / sizeof(pointTab);
int32 numOfPoints2 = boneData->numOfPoints;
+ IVec3 renderAngle;
renderAngle.x = rotX;
renderAngle.y = rotY;
renderAngle.z = rotZ;
@@ -355,7 +356,7 @@ void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *p
destPos.z = modelData->computedPoints[pointIdx].z;
}
- applyRotation(targetMatrix, currentMatrix);
+ applyRotation(targetMatrix, currentMatrix, renderAngle);
if (!numOfPoints2) {
warning("RENDER WARNING: No points in this model!");
@@ -364,13 +365,13 @@ void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *p
applyPointsRotation(&pointsPtr[firstPoint], numOfPoints2, &modelData->computedPoints[firstPoint], targetMatrix);
}
-void Renderer::applyPointsTranslation(const pointTab *pointsPtr, int32 numPoints, pointTab *destPoints, const IMatrix3x3 *translationMatrix) {
+void Renderer::applyPointsTranslation(const pointTab *pointsPtr, int32 numPoints, pointTab *destPoints, const IMatrix3x3 *translationMatrix, const IVec3 &angleVec) {
int32 numOfPoints2 = numPoints;
do {
- const int32 tmpX = pointsPtr->x + renderAngle.z;
- const int32 tmpY = pointsPtr->y + renderAngle.y;
- const int32 tmpZ = pointsPtr->z + renderAngle.x;
+ const int32 tmpX = pointsPtr->x + angleVec.z;
+ const int32 tmpY = pointsPtr->y + angleVec.y;
+ const int32 tmpZ = pointsPtr->z + angleVec.x;
destPoints->x = ((translationMatrix->row1[0] * tmpX + translationMatrix->row1[1] * tmpY + translationMatrix->row1[2] * tmpZ) / SCENE_SIZE_HALF) + destPos.x;
destPoints->y = ((translationMatrix->row2[0] * tmpX + translationMatrix->row2[1] * tmpY + translationMatrix->row2[2] * tmpZ) / SCENE_SIZE_HALF) + destPos.y;
@@ -382,6 +383,7 @@ void Renderer::applyPointsTranslation(const pointTab *pointsPtr, int32 numPoints
}
void Renderer::processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const BonesBaseData *boneData, ModelData *modelData) {
+ IVec3 renderAngle;
renderAngle.x = rotX;
renderAngle.y = rotY;
renderAngle.z = rotZ;
@@ -403,7 +405,7 @@ void Renderer::processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab
*targetMatrix = matricesTable[matrixIndex];
}
- applyPointsTranslation(&pointsPtr[boneData->firstPoint / sizeof(pointTab)], boneData->numOfPoints, &modelData->computedPoints[boneData->firstPoint / sizeof(pointTab)], targetMatrix);
+ applyPointsTranslation(&pointsPtr[boneData->firstPoint / sizeof(pointTab)], boneData->numOfPoints, &modelData->computedPoints[boneData->firstPoint / sizeof(pointTab)], targetMatrix, renderAngle);
}
void Renderer::setLightVector(int32 angleX, int32 angleY, int32 angleZ) {
@@ -412,11 +414,12 @@ void Renderer::setLightVector(int32 angleX, int32 angleY, int32 angleZ) {
_cameraAngleY = angleY;
_cameraAngleZ = angleZ;*/
+ IVec3 renderAngle;
renderAngle.x = angleX;
renderAngle.y = angleY;
renderAngle.z = angleZ;
- applyRotation(&shadeMatrix, &baseMatrix);
+ applyRotation(&shadeMatrix, &baseMatrix, renderAngle);
translateGroup(0, 0, 59);
lightPos = destPos;
@@ -1300,7 +1303,7 @@ bool Renderer::renderModelElements(int32 numOfPrimitives, const uint8 *polygonPt
return true;
}
-bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, RenderCommand *renderCmds) {
+bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, RenderCommand *renderCmds, const IVec3 &angleVec) {
const int32 numVertices = Model::getNumVertices(bodyPtr);
const int32 numBones = Model::getNumBones(bodyPtr);
@@ -1309,7 +1312,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
IMatrix3x3 *modelMatrix = &matricesTable[0];
const BonesBaseData *boneData = Model::getBonesBaseData(bodyPtr, 0);
- processRotatedElement(modelMatrix, pointsPtr, renderAngle.x, renderAngle.y, renderAngle.z, boneData, modelData);
+ processRotatedElement(modelMatrix, pointsPtr, angleVec.x, angleVec.y, angleVec.z, boneData, modelData);
int32 numOfPrimitives = 0;
@@ -1482,6 +1485,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
}
bool Renderer::renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 angleY, int32 angleZ, const uint8 *bodyPtr) {
+ IVec3 renderAngle;
renderAngle.x = angleX;
renderAngle.y = angleY;
renderAngle.z = angleZ;
@@ -1506,7 +1510,7 @@ bool Renderer::renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 ang
error("Unsupported unanimated model render!");
}
// restart at the beginning of the renderTable
- return renderAnimatedModel(&_modelData, bodyPtr, _renderCmds);
+ return renderAnimatedModel(&_modelData, bodyPtr, _renderCmds, renderAngle);
}
void Renderer::renderBehaviourModel(const Common::Rect &rect, int32 y, int32 angle, const uint8 *bodyPtr) {
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 4957f26048..2c45c74c39 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -263,14 +263,14 @@ private:
ModelData _modelData;
- bool renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, RenderCommand *renderCmds);
+ bool renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, RenderCommand *renderCmds, const IVec3 &angleVec);
void circleFill(int32 x, int32 y, int32 radius, uint8 color);
bool renderModelElements(int32 numOfPrimitives, const uint8 *polygonPtr, RenderCommand **renderCmds, ModelData *modelData);
void getCameraAnglePositions(int32 x, int32 y, int32 z);
- void applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *currentMatrix);
+ void applyRotation(IMatrix3x3 *targetMatrix, const IMatrix3x3 *currentMatrix, const IVec3 &angleVec);
void applyPointsRotation(const pointTab *pointsPtr, int32 numPoints, pointTab *destPoints, const IMatrix3x3 *rotationMatrix);
void processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotZ, int32 rotY, int32 rotX, const BonesBaseData *boneData, ModelData *modelData);
- void applyPointsTranslation(const pointTab *pointsPtr, int32 numPoints, pointTab *destPoints, const IMatrix3x3 *translationMatrix);
+ void applyPointsTranslation(const pointTab *pointsPtr, int32 numPoints, pointTab *destPoints, const IMatrix3x3 *translationMatrix, const IVec3 &angleVec);
void processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const BonesBaseData *boneData, ModelData *modelData);
void translateGroup(int32 x, int32 y, int32 z);
@@ -282,14 +282,8 @@ private:
int32 cameraScaleY = 0; // cameraVar2
int32 cameraScaleZ = 0; // cameraVar3
- // ---
-
- IVec3 renderAngle;
-
IVec3 renderPos;
- // ---
-
IMatrix3x3 baseMatrix;
IMatrix3x3 matricesTable[30 + 1];
IMatrix3x3 shadeMatrix;
Commit: b19f6deb26b85859f68855aa6082570dcdb92d2a
https://github.com/scummvm/scummvm/commit/b19f6deb26b85859f68855aa6082570dcdb92d2a
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: removed member renderPos
Changed paths:
engines/twine/renderer/renderer.cpp
engines/twine/renderer/renderer.h
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 1a18970148..002de9e03e 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -1303,7 +1303,7 @@ bool Renderer::renderModelElements(int32 numOfPrimitives, const uint8 *polygonPt
return true;
}
-bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, RenderCommand *renderCmds, const IVec3 &angleVec) {
+bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, RenderCommand *renderCmds, const IVec3 &angleVec, const IVec3 &renderPos) {
const int32 numVertices = Model::getNumVertices(bodyPtr);
const int32 numBones = Model::getNumBones(bodyPtr);
@@ -1496,6 +1496,7 @@ bool Renderer::renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 ang
_engine->_redraw->renderRect.right = SCENE_SIZE_MIN;
_engine->_redraw->renderRect.bottom = SCENE_SIZE_MIN;
+ IVec3 renderPos;
if (isUsingOrthoProjection) {
renderPos.x = x;
renderPos.y = y;
@@ -1510,7 +1511,7 @@ bool Renderer::renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 ang
error("Unsupported unanimated model render!");
}
// restart at the beginning of the renderTable
- return renderAnimatedModel(&_modelData, bodyPtr, _renderCmds, renderAngle);
+ return renderAnimatedModel(&_modelData, bodyPtr, _renderCmds, renderAngle, renderPos);
}
void Renderer::renderBehaviourModel(const Common::Rect &rect, int32 y, int32 angle, const uint8 *bodyPtr) {
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 2c45c74c39..02c7e2a246 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -263,7 +263,7 @@ private:
ModelData _modelData;
- bool renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, RenderCommand *renderCmds, const IVec3 &angleVec);
+ bool renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, RenderCommand *renderCmds, const IVec3 &angleVec, const IVec3 &renderPos);
void circleFill(int32 x, int32 y, int32 radius, uint8 color);
bool renderModelElements(int32 numOfPrimitives, const uint8 *polygonPtr, RenderCommand **renderCmds, ModelData *modelData);
void getCameraAnglePositions(int32 x, int32 y, int32 z);
@@ -274,15 +274,11 @@ private:
void processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const BonesBaseData *boneData, ModelData *modelData);
void translateGroup(int32 x, int32 y, int32 z);
- // ---- variables ----
-
IVec3 baseTransPos;
- int32 cameraDepthOffset = 0; // cameraVar1
- int32 cameraScaleY = 0; // cameraVar2
- int32 cameraScaleZ = 0; // cameraVar3
-
- IVec3 renderPos;
+ int32 cameraDepthOffset = 0;
+ int32 cameraScaleY = 0;
+ int32 cameraScaleZ = 0;
IMatrix3x3 baseMatrix;
IMatrix3x3 matricesTable[30 + 1];
Commit: 5f94f6ed94842343dea7d5f8fe53c3f4acfca9e9
https://github.com/scummvm/scummvm/commit/5f94f6ed94842343dea7d5f8fe53c3f4acfca9e9
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: renamed members
Changed paths:
engines/twine/renderer/redraw.cpp
engines/twine/renderer/redraw.h
engines/twine/renderer/renderer.cpp
engines/twine/renderer/renderer.h
engines/twine/scene/actor.cpp
engines/twine/scene/actor.h
engines/twine/scene/movements.cpp
diff --git a/engines/twine/renderer/redraw.cpp b/engines/twine/renderer/redraw.cpp
index ccb910b95c..d294163aec 100644
--- a/engines/twine/renderer/redraw.cpp
+++ b/engines/twine/renderer/redraw.cpp
@@ -50,7 +50,7 @@ void Redraw::addRedrawCurrentArea(const Common::Rect &redrawArea) {
const int32 area = (redrawArea.right - redrawArea.left) * (redrawArea.bottom - redrawArea.top);
for (int32 i = 0; i < numOfRedrawBox; ++i) {
- Common::Rect &rect = currentRedrawList[i];
+ Common::Rect &rect = _currentRedrawList[i];
const int32 leftValue = MIN<int32>(redrawArea.left, rect.left);
const int32 rightValue = MAX<int32>(redrawArea.right, rect.right);
const int32 topValue = MIN<int32>(redrawArea.top, rect.top);
@@ -70,7 +70,7 @@ void Redraw::addRedrawCurrentArea(const Common::Rect &redrawArea) {
}
}
- Common::Rect &rect = currentRedrawList[numOfRedrawBox];
+ Common::Rect &rect = _currentRedrawList[numOfRedrawBox];
rect.left = redrawArea.left;
rect.top = redrawArea.top;
rect.right = redrawArea.right;
@@ -107,7 +107,7 @@ void Redraw::addRedrawArea(int32 left, int32 top, int32 right, int32 bottom) {
return;
}
- Common::Rect &rect = nextRedrawList[currNumOfRedrawBox];
+ Common::Rect &rect = _nextRedrawList[currNumOfRedrawBox];
rect.left = left;
rect.top = top;
rect.right = right;
@@ -122,25 +122,25 @@ void Redraw::moveNextAreas() {
numOfRedrawBox = 0;
for (int32 i = 0; i < currNumOfRedrawBox; i++) {
- addRedrawCurrentArea(nextRedrawList[i]);
+ addRedrawCurrentArea(_nextRedrawList[i]);
}
}
void Redraw::flipRedrawAreas() {
for (int32 i = 0; i < numOfRedrawBox; i++) { // redraw areas on screen
- _engine->copyBlockPhys(currentRedrawList[i].left, currentRedrawList[i].top, currentRedrawList[i].right, currentRedrawList[i].bottom);
+ _engine->copyBlockPhys(_currentRedrawList[i].left, _currentRedrawList[i].top, _currentRedrawList[i].right, _currentRedrawList[i].bottom);
}
numOfRedrawBox = 0;
for (int32 i = 0; i < currNumOfRedrawBox; i++) { //setup the redraw areas for next display
- addRedrawCurrentArea(nextRedrawList[i]);
+ addRedrawCurrentArea(_nextRedrawList[i]);
}
}
void Redraw::blitBackgroundAreas() {
for (int32 i = 0; i < numOfRedrawBox; i++) {
- _engine->_interface->blitBox(currentRedrawList[i], _engine->workVideoBuffer, _engine->frontVideoBuffer);
+ _engine->_interface->blitBox(_currentRedrawList[i], _engine->workVideoBuffer, _engine->frontVideoBuffer);
}
}
@@ -624,8 +624,8 @@ void Redraw::renderOverlays() {
_engine->_interface->setClip(rect);
const uint8* bodyPtr = _engine->_resources->inventoryTable[item];
- overlayRotation += 1; // overlayRotation += 8;
- _engine->_renderer->renderInventoryItem(40, 40, bodyPtr, overlayRotation, 16000);
+ _overlayRotation += 1; // overlayRotation += 8;
+ _engine->_renderer->renderInventoryItem(40, 40, bodyPtr, _overlayRotation, 16000);
_engine->_menu->drawBox(rect);
addRedrawArea(rect);
_engine->_gameState->initEngineProjections();
diff --git a/engines/twine/renderer/redraw.h b/engines/twine/renderer/redraw.h
index 3187e95b44..90aae374b9 100644
--- a/engines/twine/renderer/redraw.h
+++ b/engines/twine/renderer/redraw.h
@@ -85,10 +85,10 @@ private:
DrawShadows = 0xC00
};
- Common::Rect currentRedrawList[300];
- Common::Rect nextRedrawList[300];
+ Common::Rect _currentRedrawList[300];
+ Common::Rect _nextRedrawList[300];
- int16 overlayRotation = 0;
+ int16 _overlayRotation = 0;
/**
* Add a certain region to the current redraw list array
* @param redrawArea redraw the region
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 002de9e03e..7a319dd14d 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -65,18 +65,18 @@ void Renderer::init(int32 w, int32 h) {
}
void Renderer::projectXYPositionOnScreen(int32 x, int32 y, int32 z) {
- if (isUsingOrthoProjection == 1) {
+ if (_isUsingOrthoProjection == 1) {
projPos.x = ((x - z) * 24) / BRICK_SIZE + orthoProjPos.x;
projPos.y = y;
return;
}
int32 cz = baseRotPos.z - z;
if (-1 < cz) {
- int32 posZ = cz + cameraDepthOffset;
+ int32 posZ = cz + _cameraDepthOffset;
if (posZ < 0) {
posZ = 0x7FFF;
}
- projPos.x = (cz * cameraScaleY) / posZ + orthoProjPos.x;
+ projPos.x = (cz * _cameraScaleY) / posZ + orthoProjPos.x;
projPos.y = y - baseRotPos.y;
return;
}
@@ -86,7 +86,7 @@ void Renderer::projectXYPositionOnScreen(int32 x, int32 y, int32 z) {
}
int32 Renderer::projectPositionOnScreen(int32 cX, int32 cY, int32 cZ) {
- if (isUsingOrthoProjection) {
+ if (_isUsingOrthoProjection) {
projPos.x = ((cX - cZ) * 24) / BRICK_SIZE + orthoProjPos.x;
projPos.y = (((cX + cZ) * 12) - cY * 30) / BRICK_SIZE + orthoProjPos.y;
projPos.z = cZ - cY - cX;
@@ -104,13 +104,13 @@ int32 Renderer::projectPositionOnScreen(int32 cX, int32 cY, int32 cZ) {
return 0;
}
- int32 posZ = cZ + cameraDepthOffset;
+ int32 posZ = cZ + _cameraDepthOffset;
if (posZ < 0) {
posZ = 0x7FFF;
}
- projPos.x = (cX * cameraScaleY) / posZ + orthoProjPos.x;
- projPos.y = (-cY * cameraScaleZ) / posZ + orthoProjPos.y;
+ projPos.x = (cX * _cameraScaleY) / posZ + orthoProjPos.x;
+ projPos.y = (-cY * _cameraScaleZ) / posZ + orthoProjPos.y;
projPos.z = posZ;
return -1;
}
@@ -119,17 +119,17 @@ void Renderer::setCameraPosition(int32 x, int32 y, int32 depthOffset, int32 scal
orthoProjPos.x = x;
orthoProjPos.y = y;
- cameraDepthOffset = depthOffset;
- cameraScaleY = scaleY;
- cameraScaleZ = scaleZ;
+ _cameraDepthOffset = depthOffset;
+ _cameraScaleY = scaleY;
+ _cameraScaleZ = scaleZ;
- isUsingOrthoProjection = false;
+ _isUsingOrthoProjection = false;
}
void Renderer::setBaseTranslation(int32 x, int32 y, int32 z) {
- baseTransPos.x = x;
- baseTransPos.y = y;
- baseTransPos.z = z;
+ _baseTransPos.x = x;
+ _baseTransPos.y = y;
+ _baseTransPos.z = z;
}
void Renderer::setOrthoProjection(int32 x, int32 y, int32 z) {
@@ -137,13 +137,13 @@ void Renderer::setOrthoProjection(int32 x, int32 y, int32 z) {
orthoProjPos.y = y;
orthoProjPos.z = z;
- isUsingOrthoProjection = true;
+ _isUsingOrthoProjection = true;
}
void Renderer::baseMatrixTranspose() {
- SWAP(baseMatrix.row1[1], baseMatrix.row2[0]);
- SWAP(baseMatrix.row1[2], baseMatrix.row3[0]);
- SWAP(baseMatrix.row2[2], baseMatrix.row3[1]);
+ SWAP(_baseMatrix.row1[1], _baseMatrix.row2[0]);
+ SWAP(_baseMatrix.row1[2], _baseMatrix.row3[0]);
+ SWAP(_baseMatrix.row2[2], _baseMatrix.row3[1]);
}
void Renderer::setBaseRotation(int32 x, int32 y, int32 z, bool transpose) {
@@ -151,28 +151,28 @@ void Renderer::setBaseRotation(int32 x, int32 y, int32 z, bool transpose) {
const double Yradians = (double)((ANGLE_90 - y) % ANGLE_360) * 2 * M_PI / ANGLE_360;
const double Zradians = (double)((ANGLE_90 - z) % ANGLE_360) * 2 * M_PI / ANGLE_360;
- baseMatrix.row1[0] = (int32)(sin(Zradians) * sin(Yradians) * SCENE_SIZE_HALFF);
- baseMatrix.row1[1] = (int32)(-cos(Zradians) * SCENE_SIZE_HALFF);
- baseMatrix.row1[2] = (int32)(sin(Zradians) * cos(Yradians) * SCENE_SIZE_HALFF);
- baseMatrix.row2[0] = (int32)(cos(Zradians) * sin(Xradians) * SCENE_SIZE_HALFF);
- baseMatrix.row2[1] = (int32)(sin(Zradians) * sin(Xradians) * SCENE_SIZE_HALFF);
- baseMatrix.row3[0] = (int32)(cos(Zradians) * cos(Xradians) * SCENE_SIZE_HALFF);
- baseMatrix.row3[1] = (int32)(sin(Zradians) * cos(Xradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row1[0] = (int32)(sin(Zradians) * sin(Yradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row1[1] = (int32)(-cos(Zradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row1[2] = (int32)(sin(Zradians) * cos(Yradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row2[0] = (int32)(cos(Zradians) * sin(Xradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row2[1] = (int32)(sin(Zradians) * sin(Xradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row3[0] = (int32)(cos(Zradians) * cos(Xradians) * SCENE_SIZE_HALFF);
+ _baseMatrix.row3[1] = (int32)(sin(Zradians) * cos(Xradians) * SCENE_SIZE_HALFF);
- int32 matrixElem = baseMatrix.row2[0];
+ int32 matrixElem = _baseMatrix.row2[0];
- baseMatrix.row2[0] = (int32)(sin(Yradians) * matrixElem + SCENE_SIZE_HALFF * cos(Yradians) * cos(Xradians));
- baseMatrix.row2[2] = (int32)(cos(Yradians) * matrixElem - SCENE_SIZE_HALFF * sin(Yradians) * cos(Xradians));
+ _baseMatrix.row2[0] = (int32)(sin(Yradians) * matrixElem + SCENE_SIZE_HALFF * cos(Yradians) * cos(Xradians));
+ _baseMatrix.row2[2] = (int32)(cos(Yradians) * matrixElem - SCENE_SIZE_HALFF * sin(Yradians) * cos(Xradians));
- matrixElem = baseMatrix.row3[0];
+ matrixElem = _baseMatrix.row3[0];
- baseMatrix.row3[0] = (int32)(sin(Yradians) * matrixElem - SCENE_SIZE_HALFF * sin(Xradians) * cos(Yradians));
- baseMatrix.row3[2] = (int32)(cos(Yradians) * matrixElem + SCENE_SIZE_HALFF * sin(Xradians) * sin(Yradians));
+ _baseMatrix.row3[0] = (int32)(sin(Yradians) * matrixElem - SCENE_SIZE_HALFF * sin(Xradians) * cos(Yradians));
+ _baseMatrix.row3[2] = (int32)(cos(Yradians) * matrixElem + SCENE_SIZE_HALFF * sin(Xradians) * sin(Yradians));
if (transpose) {
baseMatrixTranspose();
}
- getBaseRotationPosition(baseTransPos.x, baseTransPos.y, baseTransPos.z);
+ getBaseRotationPosition(_baseTransPos.x, _baseTransPos.y, _baseTransPos.z);
baseRotPos.x = destPos.x;
baseRotPos.y = destPos.y;
@@ -180,27 +180,27 @@ void Renderer::setBaseRotation(int32 x, int32 y, int32 z, bool transpose) {
}
void Renderer::getBaseRotationPosition(int32 x, int32 y, int32 z) {
- destPos.x = (baseMatrix.row1[0] * x + baseMatrix.row1[1] * y + baseMatrix.row1[2] * z) / SCENE_SIZE_HALF;
- destPos.y = (baseMatrix.row2[0] * x + baseMatrix.row2[1] * y + baseMatrix.row2[2] * z) / SCENE_SIZE_HALF;
- destPos.z = (baseMatrix.row3[0] * x + baseMatrix.row3[1] * y + baseMatrix.row3[2] * z) / SCENE_SIZE_HALF;
+ destPos.x = (_baseMatrix.row1[0] * x + _baseMatrix.row1[1] * y + _baseMatrix.row1[2] * z) / SCENE_SIZE_HALF;
+ destPos.y = (_baseMatrix.row2[0] * x + _baseMatrix.row2[1] * y + _baseMatrix.row2[2] * z) / SCENE_SIZE_HALF;
+ destPos.z = (_baseMatrix.row3[0] * x + _baseMatrix.row3[1] * y + _baseMatrix.row3[2] * z) / SCENE_SIZE_HALF;
}
void Renderer::getCameraAnglePositions(int32 x, int32 y, int32 z) {
- destPos.x = (baseMatrix.row1[0] * x + baseMatrix.row2[0] * y + baseMatrix.row3[0] * z) / SCENE_SIZE_HALF;
- destPos.y = (baseMatrix.row1[1] * x + baseMatrix.row2[1] * y + baseMatrix.row3[1] * z) / SCENE_SIZE_HALF;
- destPos.z = (baseMatrix.row1[2] * x + baseMatrix.row2[2] * y + baseMatrix.row3[2] * z) / SCENE_SIZE_HALF;
+ destPos.x = (_baseMatrix.row1[0] * x + _baseMatrix.row2[0] * y + _baseMatrix.row3[0] * z) / SCENE_SIZE_HALF;
+ destPos.y = (_baseMatrix.row1[1] * x + _baseMatrix.row2[1] * y + _baseMatrix.row3[1] * z) / SCENE_SIZE_HALF;
+ destPos.z = (_baseMatrix.row1[2] * x + _baseMatrix.row2[2] * y + _baseMatrix.row3[2] * z) / SCENE_SIZE_HALF;
}
void Renderer::translateGroup(int32 x, int32 y, int32 z) {
- destPos.x = (shadeMatrix.row1[0] * x + shadeMatrix.row1[1] * y + shadeMatrix.row1[2] * z) / SCENE_SIZE_HALF;
- destPos.y = (shadeMatrix.row2[0] * x + shadeMatrix.row2[1] * y + shadeMatrix.row2[2] * z) / SCENE_SIZE_HALF;
+ destPos.x = (_shadeMatrix.row1[0] * x + _shadeMatrix.row1[1] * y + _shadeMatrix.row1[2] * z) / SCENE_SIZE_HALF;
+ destPos.y = (_shadeMatrix.row2[0] * x + _shadeMatrix.row2[1] * y + _shadeMatrix.row2[2] * z) / SCENE_SIZE_HALF;
destPos.z = destPos.y;
}
void Renderer::setCameraAngle(int32 transPosX, int32 transPosY, int32 transPosZ, int32 rotPosX, int32 rotPosY, int32 rotPosZ, int32 param6) {
- baseTransPos.x = transPosX;
- baseTransPos.y = transPosY;
- baseTransPos.z = transPosZ;
+ _baseTransPos.x = transPosX;
+ _baseTransPos.y = transPosY;
+ _baseTransPos.z = transPosZ;
setBaseRotation(rotPosX, rotPosY, rotPosZ);
@@ -208,7 +208,7 @@ void Renderer::setCameraAngle(int32 transPosX, int32 transPosY, int32 transPosZ,
getCameraAnglePositions(baseRotPos.x, baseRotPos.y, baseRotPos.z);
- baseTransPos = destPos;
+ _baseTransPos = destPos;
}
IVec3 Renderer::getHolomapRotation(const int32 angleX, const int32 angleY, const int32 angleZ) const {
@@ -229,15 +229,15 @@ IVec3 Renderer::getHolomapRotation(const int32 angleX, const int32 angleY, const
rotZ = -shadeAngleTable[ClampAngle(angleZ)] * rotX / SCENE_SIZE_HALF;
rotX = shadeAngleTable[ClampAngle(angleZ + ANGLE_90)] * rotX / SCENE_SIZE_HALF;
}
- const int32 row1X = baseMatrix.row1[0] * rotX;
- const int32 row1Y = baseMatrix.row1[1] * rotY;
- const int32 row1Z = baseMatrix.row1[2] * rotZ;
- const int32 row2X = baseMatrix.row2[0] * rotX;
- const int32 row2Y = baseMatrix.row2[1] * rotY;
- const int32 row2Z = baseMatrix.row2[2] * rotZ;
- const int32 row3X = baseMatrix.row3[0] * rotX;
- const int32 row3Y = baseMatrix.row3[1] * rotY;
- const int32 row3Z = baseMatrix.row3[2] * rotZ;
+ const int32 row1X = _baseMatrix.row1[0] * rotX;
+ const int32 row1Y = _baseMatrix.row1[1] * rotY;
+ const int32 row1Z = _baseMatrix.row1[2] * rotZ;
+ const int32 row2X = _baseMatrix.row2[0] * rotX;
+ const int32 row2Y = _baseMatrix.row2[1] * rotY;
+ const int32 row2Z = _baseMatrix.row2[2] * rotZ;
+ const int32 row3X = _baseMatrix.row3[0] * rotX;
+ const int32 row3Y = _baseMatrix.row3[1] * rotY;
+ const int32 row3Z = _baseMatrix.row3[2] * rotZ;
IVec3 vec;
vec.x = (row1X + row1Y + row1Z) / SCENE_SIZE_HALF;
vec.y = (row2X + row2Y + row2Z) / SCENE_SIZE_HALF;
@@ -340,7 +340,7 @@ void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *p
const IMatrix3x3 *currentMatrix;
// if its the first point
if (boneData->baseElement == -1) {
- currentMatrix = &baseMatrix;
+ currentMatrix = &_baseMatrix;
destPos.x = 0;
destPos.y = 0;
@@ -348,8 +348,8 @@ void Renderer::processRotatedElement(IMatrix3x3 *targetMatrix, const pointTab *p
} else {
const int32 pointIdx = boneData->basePoint / sizeof(pointTab);
const int32 matrixIndex = boneData->baseElement / sizeof(BonesBaseData);
- assert(matrixIndex >= 0 && matrixIndex < ARRAYSIZE(matricesTable));
- currentMatrix = &matricesTable[matrixIndex];
+ assert(matrixIndex >= 0 && matrixIndex < ARRAYSIZE(_matricesTable));
+ currentMatrix = &_matricesTable[matrixIndex];
destPos.x = modelData->computedPoints[pointIdx].x;
destPos.y = modelData->computedPoints[pointIdx].y;
@@ -393,7 +393,7 @@ void Renderer::processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab
destPos.y = 0;
destPos.z = 0;
- *targetMatrix = baseMatrix;
+ *targetMatrix = _baseMatrix;
} else { // dependent
const int32 pointsIdx = boneData->basePoint / sizeof(pointTab);
destPos.x = modelData->computedPoints[pointsIdx].x;
@@ -401,8 +401,8 @@ void Renderer::processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab
destPos.z = modelData->computedPoints[pointsIdx].z;
const int32 matrixIndex = boneData->baseElement / sizeof(BonesBaseData);
- assert(matrixIndex >= 0 && matrixIndex < ARRAYSIZE(matricesTable));
- *targetMatrix = matricesTable[matrixIndex];
+ assert(matrixIndex >= 0 && matrixIndex < ARRAYSIZE(_matricesTable));
+ *targetMatrix = _matricesTable[matrixIndex];
}
applyPointsTranslation(&pointsPtr[boneData->firstPoint / sizeof(pointTab)], boneData->numOfPoints, &modelData->computedPoints[boneData->firstPoint / sizeof(pointTab)], targetMatrix, renderAngle);
@@ -419,10 +419,10 @@ void Renderer::setLightVector(int32 angleX, int32 angleY, int32 angleZ) {
renderAngle.y = angleY;
renderAngle.z = angleZ;
- applyRotation(&shadeMatrix, &baseMatrix, renderAngle);
+ applyRotation(&_shadeMatrix, &_baseMatrix, renderAngle);
translateGroup(0, 0, 59);
- lightPos = destPos;
+ _lightPos = destPos;
}
FORCEINLINE int16 clamp(int16 x, int16 a, int16 b) {
@@ -1225,7 +1225,7 @@ bool Renderer::renderModelElements(int32 numOfPrimitives, const uint8 *polygonPt
// TODO: proper size
Common::MemoryReadStream stream(polygonPtr, 100000);
- uint8 *renderBufferPtr = renderCoordinatesBuffer;
+ uint8 *renderBufferPtr = _renderCoordinatesBuffer;
renderBufferPtr = preparePolygons(stream, numOfPrimitives, renderCmds, renderBufferPtr, modelData);
renderBufferPtr = prepareLines(stream, numOfPrimitives, renderCmds, renderBufferPtr, modelData);
renderBufferPtr = prepareSpheres(stream, numOfPrimitives, renderCmds, renderBufferPtr, modelData);
@@ -1309,7 +1309,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
const pointTab *pointsPtr = (const pointTab *)Model::getVerticesBaseData(bodyPtr);
- IMatrix3x3 *modelMatrix = &matricesTable[0];
+ IMatrix3x3 *modelMatrix = &_matricesTable[0];
const BonesBaseData *boneData = Model::getBonesBaseData(bodyPtr, 0);
processRotatedElement(modelMatrix, pointsPtr, angleVec.x, angleVec.y, angleVec.z, boneData, modelData);
@@ -1318,7 +1318,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
if (numBones - 1 != 0) {
numOfPrimitives = numBones - 1;
- modelMatrix = &matricesTable[1];
+ modelMatrix = &_matricesTable[1];
int boneIdx = 1;
do {
@@ -1341,7 +1341,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
const pointTab *pointPtr = &modelData->computedPoints[0];
pointTab *pointPtrDest = &modelData->flattenPoints[0];
- if (isUsingOrthoProjection) { // use standard projection
+ if (_isUsingOrthoProjection) { // use standard projection
do {
const int32 coX = pointPtr->x + renderPos.x;
const int32 coY = pointPtr->y + renderPos.y;
@@ -1374,7 +1374,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
int32 coY = pointPtr->y + renderPos.y;
int32 coZ = -(pointPtr->z + renderPos.z);
- coZ += cameraDepthOffset;
+ coZ += _cameraDepthOffset;
if (coZ <= 0) {
coZ = 0x7FFFFFFF;
@@ -1382,7 +1382,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
// X projection
{
- coX = orthoProjPos.x + ((coX * cameraScaleY) / coZ);
+ coX = orthoProjPos.x + ((coX * _cameraScaleY) / coZ);
if (coX > 0xFFFF) {
coX = 0x7FFF;
@@ -1401,7 +1401,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
// Y projection
{
- coY = orthoProjPos.y + ((-coY * cameraScaleZ) / coZ);
+ coY = orthoProjPos.y + ((-coY * _cameraScaleZ) / coZ);
if (coY > 0xFFFF) {
coY = 0x7FFF;
@@ -1434,7 +1434,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
if (numOfShades) { // process normal data
uint16 *currentShadeDestination = (uint16 *)modelData->shadeTable;
- IMatrix3x3 *lightMatrix = &matricesTable[0];
+ IMatrix3x3 *lightMatrix = &_matricesTable[0];
numOfPrimitives = numBones;
@@ -1446,7 +1446,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
if (numOfShades) {
int32 numShades = numOfShades;
- shadeMatrix = *lightMatrix * lightPos;
+ _shadeMatrix = *lightMatrix * _lightPos;
do { // for each normal
const uint8 *shadePtr = Model::getShadesBaseData(bodyPtr, shadeIndex);
@@ -1457,9 +1457,9 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
const int16 col3 = *((const int16 *)colPtr++);
int32 color = 0;
- color += shadeMatrix.row1[0] * col1 + shadeMatrix.row1[1] * col2 + shadeMatrix.row1[2] * col3;
- color += shadeMatrix.row2[0] * col1 + shadeMatrix.row2[1] * col2 + shadeMatrix.row2[2] * col3;
- color += shadeMatrix.row3[0] * col1 + shadeMatrix.row3[1] * col2 + shadeMatrix.row3[2] * col3;
+ color += _shadeMatrix.row1[0] * col1 + _shadeMatrix.row1[1] * col2 + _shadeMatrix.row1[2] * col3;
+ color += _shadeMatrix.row2[0] * col1 + _shadeMatrix.row2[1] * col2 + _shadeMatrix.row2[2] * col3;
+ color += _shadeMatrix.row3[0] * col1 + _shadeMatrix.row3[1] * col2 + _shadeMatrix.row3[2] * col3;
int32 shade = 0;
@@ -1497,7 +1497,7 @@ bool Renderer::renderIsoModel(int32 x, int32 y, int32 z, int32 angleX, int32 ang
_engine->_redraw->renderRect.bottom = SCENE_SIZE_MIN;
IVec3 renderPos;
- if (isUsingOrthoProjection) {
+ if (_isUsingOrthoProjection) {
renderPos.x = x;
renderPos.y = y;
renderPos.z = z;
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index 02c7e2a246..b26983f7eb 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -274,23 +274,23 @@ private:
void processTranslatedElement(IMatrix3x3 *targetMatrix, const pointTab *pointsPtr, int32 rotX, int32 rotY, int32 rotZ, const BonesBaseData *boneData, ModelData *modelData);
void translateGroup(int32 x, int32 y, int32 z);
- IVec3 baseTransPos;
+ IVec3 _baseTransPos;
- int32 cameraDepthOffset = 0;
- int32 cameraScaleY = 0;
- int32 cameraScaleZ = 0;
+ int32 _cameraDepthOffset = 0;
+ int32 _cameraScaleY = 0;
+ int32 _cameraScaleZ = 0;
- IMatrix3x3 baseMatrix;
- IMatrix3x3 matricesTable[30 + 1];
- IMatrix3x3 shadeMatrix;
- IVec3 lightPos;
+ IMatrix3x3 _baseMatrix;
+ IMatrix3x3 _matricesTable[30 + 1];
+ IMatrix3x3 _shadeMatrix;
+ IVec3 _lightPos;
RenderCommand _renderCmds[1000];
/**
* @brief Raw buffer for holding the render commands. This is a type followed by the command data
* that is needed to render the primitive.
*/
- uint8 renderCoordinatesBuffer[10000]{0};
+ uint8 _renderCoordinatesBuffer[10000]{0};
int32 _polyTabSize = 0;
int16 *_polyTab = nullptr;
@@ -304,7 +304,7 @@ private:
int16* _holomap_polytab_1_2_ptr = nullptr;
int16* _holomap_polytab_1_3_ptr = nullptr;
- bool isUsingOrthoProjection = false;
+ bool _isUsingOrthoProjection = false;
void renderPolygonsCopper(uint8 *out, int vtop, int32 vsize, uint8 color) const;
void renderPolygonsBopper(uint8 *out, int vtop, int32 vsize, uint8 color) const;
diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index ea34665926..d1d1c7a1e2 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -45,11 +45,11 @@ Actor::Actor(TwinEEngine *engine) : _engine(engine) {
Actor::~Actor() {
_engine->_scene->getActor(OWN_ACTOR_SCENE_INDEX)->entityDataPtr = nullptr;
- free(heroEntityNORMAL);
- free(heroEntityATHLETIC);
- free(heroEntityAGGRESSIVE);
- free(heroEntityDISCRETE);
- free(heroEntityPROTOPACK);
+ free(_heroEntityNORMAL);
+ free(_heroEntityATHLETIC);
+ free(_heroEntityAGGRESSIVE);
+ free(_heroEntityDISCRETE);
+ free(_heroEntityPROTOPACK);
}
void Actor::restartHeroScene() {
@@ -93,11 +93,11 @@ int32 Actor::loadBehaviourEntity(ActorStruct *sceneHero, uint8 **ptr, int16 &bod
void Actor::loadHeroEntities() {
ActorStruct *sceneHero = _engine->_scene->sceneHero;
- heroEntityATHLETICSize = loadBehaviourEntity(sceneHero, &heroEntityATHLETIC, heroAnimIdxATHLETIC, FILE3DHQR_HEROATHLETIC);
- heroEntityAGGRESSIVESize = loadBehaviourEntity(sceneHero, &heroEntityAGGRESSIVE, heroAnimIdxAGGRESSIVE, FILE3DHQR_HEROAGGRESSIVE);
- heroEntityDISCRETESize = loadBehaviourEntity(sceneHero, &heroEntityDISCRETE, heroAnimIdxDISCRETE, FILE3DHQR_HERODISCRETE);
- heroEntityPROTOPACKSize = loadBehaviourEntity(sceneHero, &heroEntityPROTOPACK, heroAnimIdxPROTOPACK, FILE3DHQR_HEROPROTOPACK);
- heroEntityNORMALSize = loadBehaviourEntity(sceneHero, &heroEntityNORMAL, heroAnimIdxNORMAL, FILE3DHQR_HERONORMAL);
+ _heroEntityATHLETICSize = loadBehaviourEntity(sceneHero, &_heroEntityATHLETIC, heroAnimIdxATHLETIC, FILE3DHQR_HEROATHLETIC);
+ _heroEntityAGGRESSIVESize = loadBehaviourEntity(sceneHero, &_heroEntityAGGRESSIVE, heroAnimIdxAGGRESSIVE, FILE3DHQR_HEROAGGRESSIVE);
+ _heroEntityDISCRETESize = loadBehaviourEntity(sceneHero, &_heroEntityDISCRETE, heroAnimIdxDISCRETE, FILE3DHQR_HERODISCRETE);
+ _heroEntityPROTOPACKSize = loadBehaviourEntity(sceneHero, &_heroEntityPROTOPACK, heroAnimIdxPROTOPACK, FILE3DHQR_HEROPROTOPACK);
+ _heroEntityNORMALSize = loadBehaviourEntity(sceneHero, &_heroEntityNORMAL, heroAnimIdxNORMAL, FILE3DHQR_HERONORMAL);
sceneHero->animExtraPtr = _engine->_animations->currentActorAnimExtraPtr;
}
@@ -107,28 +107,28 @@ void Actor::setBehaviour(HeroBehaviourType behaviour) {
switch (behaviour) {
case HeroBehaviourType::kNormal:
heroBehaviour = behaviour;
- sceneHero->entityDataPtr = heroEntityNORMAL;
- sceneHero->entityDataSize = heroEntityNORMALSize;
+ sceneHero->entityDataPtr = _heroEntityNORMAL;
+ sceneHero->entityDataSize = _heroEntityNORMALSize;
break;
case HeroBehaviourType::kAthletic:
heroBehaviour = behaviour;
- sceneHero->entityDataPtr = heroEntityATHLETIC;
- sceneHero->entityDataSize = heroEntityATHLETICSize;
+ sceneHero->entityDataPtr = _heroEntityATHLETIC;
+ sceneHero->entityDataSize = _heroEntityATHLETICSize;
break;
case HeroBehaviourType::kAggressive:
heroBehaviour = behaviour;
- sceneHero->entityDataPtr = heroEntityAGGRESSIVE;
- sceneHero->entityDataSize = heroEntityAGGRESSIVESize;
+ sceneHero->entityDataPtr = _heroEntityAGGRESSIVE;
+ sceneHero->entityDataSize = _heroEntityAGGRESSIVESize;
break;
case HeroBehaviourType::kDiscrete:
heroBehaviour = behaviour;
- sceneHero->entityDataPtr = heroEntityDISCRETE;
- sceneHero->entityDataSize = heroEntityDISCRETESize;
+ sceneHero->entityDataPtr = _heroEntityDISCRETE;
+ sceneHero->entityDataSize = _heroEntityDISCRETESize;
break;
case HeroBehaviourType::kProtoPack:
heroBehaviour = behaviour;
- sceneHero->entityDataPtr = heroEntityPROTOPACK;
- sceneHero->entityDataSize = heroEntityPROTOPACKSize;
+ sceneHero->entityDataPtr = _heroEntityPROTOPACK;
+ sceneHero->entityDataSize = _heroEntityPROTOPACKSize;
break;
};
@@ -156,11 +156,11 @@ void Actor::initSpriteActor(int32 actorIdx) {
}
int32 Actor::getTextIdForBehaviour() const {
- if (_engine->_actor->heroBehaviour == HeroBehaviourType::kAggressive && _engine->_actor->autoAggressive) {
+ if (heroBehaviour == HeroBehaviourType::kAggressive && autoAggressive) {
return TextId::kBehaviourAggressiveAuto;
}
// the other values are matching the text ids
- return (int32)_engine->_actor->heroBehaviour;
+ return (int32)heroBehaviour;
}
// see Animations::getBodyAnimIndex
@@ -186,8 +186,8 @@ int32 Actor::initBody(BodyType bodyIdx, int32 actorIdx, ActorBoundingBox &actorB
// TODO: move into resources class
int32 index;
if (!(bodyIndex & 0x8000)) {
- index = currentPositionInBodyPtrTab;
- currentPositionInBodyPtrTab++;
+ index = _currentPositionInBodyPtrTab;
+ _currentPositionInBodyPtrTab++;
_engine->_resources->bodyTableSize[index] = HQR::getAllocEntry(&_engine->_resources->bodyTable[index], Resources::HQR_BODY_FILE, bodyIndex & 0xFFFF);
if (_engine->_resources->bodyTableSize[index] == 0) {
error("HQR ERROR: Loading body entity for actor %i: %i", actorIdx, (int)bodyIdx);
@@ -455,7 +455,7 @@ void Actor::processActorExtraBonus(int32 actorIdx) { // GiveExtraBonus
}
void Actor::clearBodyTable() {
- currentPositionInBodyPtrTab = 0;
+ _currentPositionInBodyPtrTab = 0;
}
ActorStruct::~ActorStruct() {
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index e2dce0cfd3..33848ff2c3 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -258,20 +258,23 @@ private:
TwinEEngine *_engine;
/** Hero 3D entity for normal behaviour */
- uint8 *heroEntityNORMAL = nullptr;
- int32 heroEntityNORMALSize = 0;
+ uint8 *_heroEntityNORMAL = nullptr;
+ int32 _heroEntityNORMALSize = 0;
/** Hero 3D entity for athletic behaviour */
- uint8 *heroEntityATHLETIC = nullptr;
- int32 heroEntityATHLETICSize = 0;
+ uint8 *_heroEntityATHLETIC = nullptr;
+ int32 _heroEntityATHLETICSize = 0;
/** Hero 3D entity for aggressive behaviour */
- uint8 *heroEntityAGGRESSIVE = nullptr;
- int32 heroEntityAGGRESSIVESize = 0;
+ uint8 *_heroEntityAGGRESSIVE = nullptr;
+ int32 _heroEntityAGGRESSIVESize = 0;
/** Hero 3D entity for discrete behaviour */
- uint8 *heroEntityDISCRETE = nullptr;
- int32 heroEntityDISCRETESize = 0;
+ uint8 *_heroEntityDISCRETE = nullptr;
+ int32 _heroEntityDISCRETESize = 0;
/** Hero 3D entity for protopack behaviour */
- uint8 *heroEntityPROTOPACK = nullptr;
- int32 heroEntityPROTOPACKSize = 0;
+ uint8 *_heroEntityPROTOPACK = nullptr;
+ int32 _heroEntityPROTOPACKSize = 0;
+
+ /** Current position in body table */
+ int32 _currentPositionInBodyPtrTab;
void initSpriteActor(int32 actorIdx);
@@ -292,8 +295,6 @@ public:
/** Actor shadow coordinate */
IVec3 shadowCoord;
- /** Actor shadow collition type - brick shape */
- ShapeType shadowCollisionType = ShapeType::kNone;
HeroBehaviourType heroBehaviour = HeroBehaviourType::kNormal;
/** Hero auto aggressive mode */
@@ -319,8 +320,6 @@ public:
/** Hero anim for behaviour menu */
int16 heroAnimIdx[4];
- /** Current position in body table */
- int32 currentPositionInBodyPtrTab;
void clearBodyTable();
/** Restart hero variables while opening new scenes */
diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index b790e15c0b..8541a6edc5 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -43,14 +43,15 @@ void Movements::getShadowPosition(int32 x, int32 y, int32 z) {
processActor.x = x;
processActor.z = z;
+ ShapeType shadowCollisionType;
if (*ptr) {
const uint8 *blockPtr = _engine->_grid->getBlockLibrary(*ptr - 1) + 3 + *(ptr + 1) * 4;
const ShapeType brickShape = (ShapeType) * ((const uint8 *)(blockPtr));
- _engine->_actor->shadowCollisionType = brickShape;
+ shadowCollisionType = brickShape;
} else {
- _engine->_actor->shadowCollisionType = ShapeType::kNone;
+ shadowCollisionType = ShapeType::kNone;
}
- _engine->_collision->reajustActorPosition(_engine->_actor->shadowCollisionType);
+ _engine->_collision->reajustActorPosition(shadowCollisionType);
_engine->_actor->shadowCoord = processActor;
}
Commit: 1a06a98bc5ae76e0a0cd62dcd5334bd552aa4989
https://github.com/scummvm/scummvm/commit/1a06a98bc5ae76e0a0cd62dcd5334bd552aa4989
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: removed method declaraction without implementation
Changed paths:
engines/twine/scene/actor.h
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index 33848ff2c3..bde465b3f4 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -336,9 +336,6 @@ public:
*/
void setBehaviour(HeroBehaviourType behaviour);
- /** Preload all sprites */
- void preloadSprites();
-
/**
* Initialize 3D actor
* @param bodyIdx 3D actor body index
Commit: 827ffeb7feb747bd6437d95a275f871d12bddeb1
https://github.com/scummvm/scummvm/commit/827ffeb7feb747bd6437d95a275f871d12bddeb1
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: removed comment
Changed paths:
engines/twine/scene/animations.cpp
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index 97bfc35a43..1fb081b3f4 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -473,7 +473,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
_engine->_movements->previousActor = actor->collisionPos;
- if (actor->staticFlags.bIsSpriteActor) { // is sprite actor
+ if (actor->staticFlags.bIsSpriteActor) {
if (actor->strengthOfHit) {
actor->dynamicFlags.bIsHitting = 1;
}
Commit: db23bbfbfc498d1526223c9398a7e6739779ea15
https://github.com/scummvm/scummvm/commit/db23bbfbfc498d1526223c9398a7e6739779ea15
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: minor cleanup
Changed paths:
engines/twine/scene/collision.cpp
engines/twine/scene/movements.h
diff --git a/engines/twine/scene/collision.cpp b/engines/twine/scene/collision.cpp
index dfa89a6acf..495bd67a2f 100644
--- a/engines/twine/scene/collision.cpp
+++ b/engines/twine/scene/collision.cpp
@@ -325,9 +325,7 @@ int32 Collision::checkCollisionWithActors(int32 actorIdx) {
}
} else {
if (!actor->dynamicFlags.bIsFalling) {
- _engine->_movements->processActor.x = _engine->_movements->previousActor.x;
- _engine->_movements->processActor.y = _engine->_movements->previousActor.y;
- _engine->_movements->processActor.z = _engine->_movements->previousActor.z;
+ _engine->_movements->processActor = _engine->_movements->previousActor;
}
}
}
diff --git a/engines/twine/scene/movements.h b/engines/twine/scene/movements.h
index 0f6c6d7c40..925410c478 100644
--- a/engines/twine/scene/movements.h
+++ b/engines/twine/scene/movements.h
@@ -124,8 +124,7 @@ public:
*/
bool shouldTriggerZoneAction() const;
- /** Hero moved */
- bool heroMoved = false; // twinsenMove
+ bool heroMoved = false;
/** Process actor coordinate */
IVec3 processActor;
@@ -133,7 +132,7 @@ public:
/** Previous process actor coordinate */
IVec3 previousActor;
- int32 targetActorDistance = 0; // DoTrackVar1
+ int32 targetActorDistance = 0;
/**
* Get shadow position
Commit: c98ceb97621a83dfc85daee7a5b0a9bc0bd4dd62
https://github.com/scummvm/scummvm/commit/c98ceb97621a83dfc85daee7a5b0a9bc0bd4dd62
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: don't mis-use the animType for the sprite actor angle for rotations
introduced a new member var to be able to use an enum for the animType at some point
Changed paths:
engines/twine/scene/actor.h
engines/twine/scene/animations.cpp
engines/twine/script/script_move_v1.cpp
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index bde465b3f4..c0093b9a05 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -233,6 +233,7 @@ public:
int32 doorStatus = 0;
int32 animPosition = 0;
int32 animType = kAnimationTypeLoop; // field_78
+ int32 spriteActorRotation = 0;
int32 brickSound = 0; // field_7A
BoundingBox boudingBox;
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index 1fb081b3f4..b9242f74ee 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -491,7 +491,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
}
}
- _engine->_movements->rotateActor(xAxisRotation, 0, actor->animType);
+ _engine->_movements->rotateActor(xAxisRotation, 0, actor->spriteActorRotation);
_engine->_movements->processActor.y = actor->pos.y - _engine->_renderer->destPos.z;
diff --git a/engines/twine/script/script_move_v1.cpp b/engines/twine/script/script_move_v1.cpp
index 32197a8290..ea8c6ae4f4 100644
--- a/engines/twine/script/script_move_v1.cpp
+++ b/engines/twine/script/script_move_v1.cpp
@@ -327,8 +327,7 @@ static int32 mGOTO_POINT_3D(TwinEEngine *engine, MoveScriptContext &ctx) {
engine->_renderer->destPos.z = sp.z;
ctx.actor->angle = engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->pos.x, ctx.actor->pos.z, sp.x, sp.z);
- // TODO: this adds an angle to the animType value
- ctx.actor->animType = engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->pos.y, 0, sp.y, engine->_movements->targetActorDistance);
+ ctx.actor->spriteActorRotation = engine->_movements->getAngleAndSetTargetActorDistance(ctx.actor->pos.y, 0, sp.y, engine->_movements->targetActorDistance);
if (engine->_movements->targetActorDistance > 100) {
ctx.undo(1);
Commit: 5fa6a23d8a8e9415c076e147bbfc4704f342f177
https://github.com/scummvm/scummvm/commit/5fa6a23d8a8e9415c076e147bbfc4704f342f177
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: converted to enum class
Changed paths:
engines/twine/scene/actor.cpp
engines/twine/scene/actor.h
engines/twine/scene/animations.cpp
engines/twine/scene/animations.h
engines/twine/scene/collision.cpp
engines/twine/scene/movements.cpp
engines/twine/scene/scene.cpp
engines/twine/script/script_life_v1.cpp
engines/twine/script/script_move_v1.cpp
engines/twine/twine.cpp
diff --git a/engines/twine/scene/actor.cpp b/engines/twine/scene/actor.cpp
index d1d1c7a1e2..b5dd57f227 100644
--- a/engines/twine/scene/actor.cpp
+++ b/engines/twine/scene/actor.cpp
@@ -140,9 +140,9 @@ void Actor::setBehaviour(HeroBehaviourType behaviour) {
initModelActor(bodyIdx, OWN_ACTOR_SCENE_INDEX);
sceneHero->anim = AnimationTypes::kAnimNone;
- sceneHero->animType = kAnimationTypeLoop;
+ sceneHero->animType = AnimType::kAnimationTypeLoop;
- _engine->_animations->initAnim(AnimationTypes::kStanding, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, 0);
+ _engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, 0);
}
void Actor::initSpriteActor(int32 actorIdx) {
@@ -317,10 +317,10 @@ void Actor::initActor(int16 actorIdx) {
initModelActor(actor->body, actorIdx);
actor->previousAnimIdx = -1;
- actor->animType = kAnimationTypeLoop;
+ actor->animType = AnimType::kAnimationTypeLoop;
if (actor->entity != -1) {
- _engine->_animations->initAnim(actor->anim, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+ _engine->_animations->initAnim(actor->anim, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
}
_engine->_movements->setActorAngleSafe(actor->angle, actor->angle, ANGLE_0, &actor->move);
@@ -372,7 +372,7 @@ void Actor::resetActor(int16 actorIdx) {
actor->lastPos.z = 0;
actor->entity = -1;
actor->previousAnimIdx = -1;
- actor->animType = kAnimationTypeLoop;
+ actor->animType = AnimType::kAnimationTypeLoop;
actor->animPosition = 0;
_engine->_movements->setActorAngleSafe(ANGLE_0, ANGLE_0, ANGLE_0, &actor->move);
@@ -403,9 +403,9 @@ void Actor::hitActor(int32 actorIdx, int32 actorIdxAttacked, int32 strengthOfHit
}
if (_engine->getRandomNumber() & 1) {
- _engine->_animations->initAnim(AnimationTypes::kHit2, kAnimationType_3, AnimationTypes::kAnimInvalid, actorIdxAttacked);
+ _engine->_animations->initAnim(AnimationTypes::kHit2, AnimType::kAnimationType_3, AnimationTypes::kAnimInvalid, actorIdxAttacked);
} else {
- _engine->_animations->initAnim(AnimationTypes::kBigHit, kAnimationType_3, AnimationTypes::kAnimInvalid, actorIdxAttacked);
+ _engine->_animations->initAnim(AnimationTypes::kBigHit, AnimType::kAnimationType_3, AnimationTypes::kAnimInvalid, actorIdxAttacked);
}
}
@@ -420,7 +420,7 @@ void Actor::hitActor(int32 actorIdx, int32 actorIdxAttacked, int32 strengthOfHit
actor->life = 0;
}
} else {
- _engine->_animations->initAnim(AnimationTypes::kHit, kAnimationType_3, AnimationTypes::kAnimInvalid, actorIdxAttacked);
+ _engine->_animations->initAnim(AnimationTypes::kHit, AnimType::kAnimationType_3, AnimationTypes::kAnimInvalid, actorIdxAttacked);
}
}
diff --git a/engines/twine/scene/actor.h b/engines/twine/scene/actor.h
index c0093b9a05..412eabda2a 100644
--- a/engines/twine/scene/actor.h
+++ b/engines/twine/scene/actor.h
@@ -134,16 +134,18 @@ struct BonusParameter {
uint16 unused : 7;
};
-#define kAnimationTypeLoop 0
-#define kAnimationType_1 1
-// play animation and let animExtra follow as next animation
-// if there is already a next animation set - replace the value
-#define kAnimationType_2 2
-// replace animation and let the current animation follow
-#define kAnimationType_3 3
-// play animation and let animExtra follow as next animation
-// but don't take the current state in account
-#define kAnimationType_4 4
+enum class AnimType {
+ kAnimationTypeLoop = 0,
+ kAnimationType_1 = 1,
+ // play animation and let animExtra follow as next animation
+ // if there is already a next animation set - replace the value
+ kAnimationType_2 = 2,
+ // replace animation and let the current animation follow
+ kAnimationType_3 = 3,
+ // play animation and let animExtra follow as next animation
+ // but don't take the current state in account
+ kAnimationType_4 = 4
+};
#define kActorMaxLife 50
@@ -232,7 +234,7 @@ public:
int32 previousAnimIdx = 0;
int32 doorStatus = 0;
int32 animPosition = 0;
- int32 animType = kAnimationTypeLoop; // field_78
+ AnimType animType = AnimType::kAnimationTypeLoop; // field_78
int32 spriteActorRotation = 0;
int32 brickSound = 0; // field_7A
diff --git a/engines/twine/scene/animations.cpp b/engines/twine/scene/animations.cpp
index b9242f74ee..070d31a279 100644
--- a/engines/twine/scene/animations.cpp
+++ b/engines/twine/scene/animations.cpp
@@ -390,7 +390,7 @@ void Animations::processAnimActions(int32 actorIdx) {
}
}
-bool Animations::initAnim(AnimationTypes newAnim, int16 animType, AnimationTypes animExtra, int32 actorIdx) {
+bool Animations::initAnim(AnimationTypes newAnim, AnimType animType, AnimationTypes animExtra, int32 actorIdx) {
ActorStruct *actor = _engine->_scene->getActor(actorIdx);
if (actor->entity == -1) {
return false;
@@ -404,7 +404,7 @@ bool Animations::initAnim(AnimationTypes newAnim, int16 animType, AnimationTypes
return true;
}
- if (animExtra == AnimationTypes::kAnimInvalid && actor->animType != kAnimationType_2) {
+ if (animExtra == AnimationTypes::kAnimInvalid && actor->animType != AnimType::kAnimationType_2) {
animExtra = actor->anim;
}
@@ -414,13 +414,13 @@ bool Animations::initAnim(AnimationTypes newAnim, int16 animType, AnimationTypes
animIndex = getBodyAnimIndex(AnimationTypes::kStanding, actorIdx);
}
- if (animType != kAnimationType_4 && actor->animType == kAnimationType_2) {
+ if (animType != AnimType::kAnimationType_4 && actor->animType == AnimType::kAnimationType_2) {
actor->animExtra = newAnim;
return false;
}
- if (animType == kAnimationType_3) {
- animType = kAnimationType_2;
+ if (animType == AnimType::kAnimationType_3) {
+ animType = AnimType::kAnimationType_2;
animExtra = actor->anim;
@@ -429,8 +429,8 @@ bool Animations::initAnim(AnimationTypes newAnim, int16 animType, AnimationTypes
}
}
- if (animType == kAnimationType_4) {
- animType = kAnimationType_2;
+ if (animType == AnimType::kAnimationType_4) {
+ animType = AnimType::kAnimationType_2;
}
if (actor->previousAnimIdx == -1) {
@@ -606,7 +606,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
if (numKeyframe == (int16)animData.getNumKeyframes()) {
actor->dynamicFlags.bIsHitting = 0;
- if (actor->animType == kAnimationTypeLoop) {
+ if (actor->animType == AnimType::kAnimationTypeLoop) {
actor->animPosition = animData.getLoopFrame();
} else {
actor->anim = (AnimationTypes)actor->animExtra;
@@ -619,7 +619,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
actor->animExtraPtr = currentActorAnimExtraPtr;
- actor->animType = kAnimationTypeLoop;
+ actor->animType = AnimType::kAnimationTypeLoop;
actor->animPosition = 0;
actor->strengthOfHit = 0;
}
@@ -706,7 +706,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
if (_engine->_renderer->destPos.x >= 0 && _engine->_renderer->destPos.z >= 0 && _engine->_renderer->destPos.x <= 0x7E00 && _engine->_renderer->destPos.z <= 0x7E00) {
if (_engine->_grid->getBrickShape(_engine->_renderer->destPos.x, _engine->_movements->processActor.y + BRICK_HEIGHT, _engine->_renderer->destPos.z) != ShapeType::kNone && _engine->cfgfile.WallCollision) { // avoid wall hit damage
_engine->_extra->addExtraSpecial(actor->pos.x, actor->pos.y + 1000, actor->pos.z, ExtraSpecialType::kHitStars);
- initAnim(AnimationTypes::kBigHit, kAnimationType_2, AnimationTypes::kStanding, currentlyProcessedActorIdx);
+ initAnim(AnimationTypes::kBigHit, AnimType::kAnimationType_2, AnimationTypes::kStanding, currentlyProcessedActorIdx);
if (IS_HERO(currentlyProcessedActorIdx)) {
_engine->_movements->heroMoved = true;
@@ -728,7 +728,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
} else {
if (IS_HERO(actorIdx) && _engine->_actor->heroBehaviour == HeroBehaviourType::kAthletic && actor->anim == AnimationTypes::kForward && _engine->cfgfile.WallCollision) { // avoid wall hit damage
_engine->_extra->addExtraSpecial(actor->pos.x, actor->pos.y + 1000, actor->pos.z, ExtraSpecialType::kHitStars);
- initAnim(AnimationTypes::kBigHit, kAnimationType_2, AnimationTypes::kStanding, currentlyProcessedActorIdx);
+ initAnim(AnimationTypes::kBigHit, AnimType::kAnimationType_2, AnimationTypes::kStanding, currentlyProcessedActorIdx);
_engine->_movements->heroMoved = true;
actor->addLife(-1);
}
@@ -776,7 +776,7 @@ void Animations::processActorAnimations(int32 actorIdx) { // DoAnim
_engine->_scene->heroYBeforeFall = _engine->_movements->processActor.y;
}
- initAnim(AnimationTypes::kFall, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+ initAnim(AnimationTypes::kFall, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
}
}
}
diff --git a/engines/twine/scene/animations.h b/engines/twine/scene/animations.h
index 33c9bd7c1b..677e622b0b 100644
--- a/engines/twine/scene/animations.h
+++ b/engines/twine/scene/animations.h
@@ -107,7 +107,7 @@ public:
* @param animExtra animation actions extra data
* @param actorIdx actor index
*/
- bool initAnim(AnimationTypes newAnim, int16 animType, AnimationTypes animExtra, int32 actorIdx);
+ bool initAnim(AnimationTypes newAnim, AnimType animType, AnimationTypes animExtra, int32 actorIdx);
/**
* Process acotr animation actions
diff --git a/engines/twine/scene/collision.cpp b/engines/twine/scene/collision.cpp
index 495bd67a2f..4c6c5adf8e 100644
--- a/engines/twine/scene/collision.cpp
+++ b/engines/twine/scene/collision.cpp
@@ -439,16 +439,16 @@ void Collision::stopFalling() { // ReceptionObj()
} else {
_engine->_actor->processActorPtr->addLife(-1);
}
- _engine->_animations->initAnim(AnimationTypes::kLandingHit, kAnimationType_2, AnimationTypes::kStanding, _engine->_animations->currentlyProcessedActorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kLandingHit, AnimType::kAnimationType_2, AnimationTypes::kStanding, _engine->_animations->currentlyProcessedActorIdx);
} else if (fall > 10) {
- _engine->_animations->initAnim(AnimationTypes::kLanding, kAnimationType_2, AnimationTypes::kStanding, _engine->_animations->currentlyProcessedActorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kLanding, AnimType::kAnimationType_2, AnimationTypes::kStanding, _engine->_animations->currentlyProcessedActorIdx);
} else {
- _engine->_animations->initAnim(AnimationTypes::kStanding, kAnimationTypeLoop, AnimationTypes::kStanding, _engine->_animations->currentlyProcessedActorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kStanding, _engine->_animations->currentlyProcessedActorIdx);
}
_engine->_scene->heroYBeforeFall = 0;
} else {
- _engine->_animations->initAnim(AnimationTypes::kLanding, kAnimationType_2, _engine->_actor->processActorPtr->animExtra, _engine->_animations->currentlyProcessedActorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kLanding, AnimType::kAnimationType_2, _engine->_actor->processActorPtr->animExtra, _engine->_animations->currentlyProcessedActorIdx);
}
_engine->_actor->processActorPtr->dynamicFlags.bIsFalling = 0;
diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index 8541a6edc5..bbfeaf7e0e 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -232,7 +232,7 @@ bool Movements::processBehaviourExecution(int actorIdx) {
executeAction = true;
break;
case HeroBehaviourType::kAthletic:
- _engine->_animations->initAnim(AnimationTypes::kJump, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kJump, AnimType::kAnimationType_1, AnimationTypes::kStanding, actorIdx);
break;
case HeroBehaviourType::kAggressive:
if (_engine->_actor->autoAggressive) {
@@ -245,31 +245,31 @@ bool Movements::processBehaviourExecution(int actorIdx) {
switch (aggresiveMode) {
case 0:
- _engine->_animations->initAnim(AnimationTypes::kKick, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kKick, AnimType::kAnimationType_1, AnimationTypes::kStanding, actorIdx);
break;
case 1:
- _engine->_animations->initAnim(AnimationTypes::kRightPunch, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kRightPunch, AnimType::kAnimationType_1, AnimationTypes::kStanding, actorIdx);
break;
case 2:
- _engine->_animations->initAnim(AnimationTypes::kLeftPunch, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kLeftPunch, AnimType::kAnimationType_1, AnimationTypes::kStanding, actorIdx);
break;
}
}
} else {
if (_engine->_input->isActionActive(TwinEActionType::TurnLeft)) {
- _engine->_animations->initAnim(AnimationTypes::kLeftPunch, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kLeftPunch, AnimType::kAnimationType_1, AnimationTypes::kStanding, actorIdx);
heroMoved = true;
} else if (_engine->_input->isActionActive(TwinEActionType::TurnRight)) {
- _engine->_animations->initAnim(AnimationTypes::kRightPunch, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kRightPunch, AnimType::kAnimationType_1, AnimationTypes::kStanding, actorIdx);
heroMoved = true;
} else if (_engine->_input->isActionActive(TwinEActionType::MoveForward)) {
- _engine->_animations->initAnim(AnimationTypes::kKick, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kKick, AnimType::kAnimationType_1, AnimationTypes::kStanding, actorIdx);
heroMoved = true;
}
}
break;
case HeroBehaviourType::kDiscrete:
- _engine->_animations->initAnim(AnimationTypes::kHide, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kHide, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
break;
case HeroBehaviourType::kProtoPack:
break;
@@ -283,7 +283,7 @@ bool Movements::processAttackExecution(int actorIdx) {
// Use Magic Ball
if (_engine->_gameState->hasItem(InventoryItems::kiMagicBall)) {
if (_engine->_gameState->magicBallIdx == -1) {
- _engine->_animations->initAnim(AnimationTypes::kThrowBall, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kThrowBall, AnimType::kAnimationType_1, AnimationTypes::kStanding, actorIdx);
}
actor->angle = actor->move.getRealAngle(_engine->lbaTime);
@@ -294,7 +294,7 @@ bool Movements::processAttackExecution(int actorIdx) {
_engine->_actor->initModelActor(BodyType::btSabre, actorIdx);
}
- _engine->_animations->initAnim(AnimationTypes::kSabreAttack, kAnimationType_1, AnimationTypes::kStanding, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kSabreAttack, AnimType::kAnimationType_1, AnimationTypes::kStanding, actorIdx);
actor->angle = actor->move.getRealAngle(_engine->lbaTime);
return true;
@@ -317,7 +317,7 @@ void Movements::processManualMovementExecution(int actorIdx) {
// if walking should get stopped
if (!_engine->_input->isActionActive(TwinEActionType::MoveForward) && !_engine->_input->isActionActive(TwinEActionType::MoveBackward)) {
if (heroMoved && (heroActionKey != previousLoopActionKey || changedCursorKeys != previousChangedCursorKeys)) {
- _engine->_animations->initAnim(AnimationTypes::kStanding, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
}
}
@@ -325,17 +325,17 @@ void Movements::processManualMovementExecution(int actorIdx) {
if (_engine->_input->isActionActive(TwinEActionType::MoveForward)) {
if (!_engine->_scene->currentActorInZone) {
- _engine->_animations->initAnim(AnimationTypes::kForward, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kForward, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
}
heroMoved = true;
} else if (_engine->_input->isActionActive(TwinEActionType::MoveBackward)) {
- _engine->_animations->initAnim(AnimationTypes::kBackward, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kBackward, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
heroMoved = true;
}
if (_engine->_input->isActionActive(TwinEActionType::TurnLeft)) {
if (actor->anim == AnimationTypes::kStanding) {
- _engine->_animations->initAnim(AnimationTypes::kTurnLeft, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kTurnLeft, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
} else {
if (!actor->dynamicFlags.bIsRotationByAnim) {
actor->angle = actor->move.getRealAngle(_engine->lbaTime);
@@ -344,7 +344,7 @@ void Movements::processManualMovementExecution(int actorIdx) {
heroMoved = true;
} else if (_engine->_input->isActionActive(TwinEActionType::TurnRight)) {
if (actor->anim == AnimationTypes::kStanding) {
- _engine->_animations->initAnim(AnimationTypes::kTurnRight, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kTurnRight, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
} else {
if (!actor->dynamicFlags.bIsRotationByAnim) {
actor->angle = actor->move.getRealAngle(_engine->lbaTime);
@@ -414,11 +414,11 @@ void Movements::processRandomAction(int actorIdx) {
if (actor->brickCausesDamage()) {
moveActor(actor->angle, ClampAngle((_engine->getRandomNumber() & ANGLE_90) + (actor->angle - ANGLE_90)), actor->speed, &actor->move);
actor->delayInMillis = _engine->getRandomNumber(300) + _engine->lbaTime + 300;
- _engine->_animations->initAnim(AnimationTypes::kStanding, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
}
if (!actor->move.numOfStep) {
- _engine->_animations->initAnim(AnimationTypes::kForward, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
+ _engine->_animations->initAnim(AnimationTypes::kForward, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
if (_engine->lbaTime > actor->delayInMillis) {
moveActor(actor->angle, ClampAngle((_engine->getRandomNumber() & ANGLE_90) + (actor->angle - ANGLE_90)), actor->speed, &actor->move);
actor->delayInMillis = _engine->getRandomNumber(300) + _engine->lbaTime + 300;
diff --git a/engines/twine/scene/scene.cpp b/engines/twine/scene/scene.cpp
index 2174590c15..9ae9f561ec 100644
--- a/engines/twine/scene/scene.cpp
+++ b/engines/twine/scene/scene.cpp
@@ -722,7 +722,7 @@ void Scene::processActorZones(int32 actorIdx) {
break;
case ZoneType::kObject:
if (IS_HERO(actorIdx) && _engine->_movements->shouldTriggerZoneAction()) {
- _engine->_animations->initAnim(AnimationTypes::kAction, kAnimationType_1, AnimationTypes::kStanding, 0);
+ _engine->_animations->initAnim(AnimationTypes::kAction, AnimType::kAnimationType_1, AnimationTypes::kStanding, 0);
processZoneExtraBonus(zone);
}
break;
@@ -746,9 +746,9 @@ void Scene::processActorZones(int32 actorIdx) {
if (_engine->_grid->getBrickShape(_engine->_renderer->destPos.x, actor->pos.y + ANGLE_90, _engine->_renderer->destPos.z) != ShapeType::kNone) {
currentActorInZone = true;
if (actor->pos.y >= ABS(zone->mins.y + zone->maxs.y) / 2) {
- _engine->_animations->initAnim(AnimationTypes::kTopLadder, kAnimationType_2, AnimationTypes::kStanding, actorIdx); // reached end of ladder
+ _engine->_animations->initAnim(AnimationTypes::kTopLadder, AnimType::kAnimationType_2, AnimationTypes::kStanding, actorIdx); // reached end of ladder
} else {
- _engine->_animations->initAnim(AnimationTypes::kClimbLadder, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx); // go up in ladder
+ _engine->_animations->initAnim(AnimationTypes::kClimbLadder, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx); // go up in ladder
}
}
}
diff --git a/engines/twine/script/script_life_v1.cpp b/engines/twine/script/script_life_v1.cpp
index b6b0cc9038..0ecd1630e1 100644
--- a/engines/twine/script/script_life_v1.cpp
+++ b/engines/twine/script/script_life_v1.cpp
@@ -588,7 +588,7 @@ static int32 lBODY_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
*/
static int32 lANIM(TwinEEngine *engine, LifeScriptContext &ctx) {
AnimationTypes animIdx = (AnimationTypes)ctx.stream.readByte();
- engine->_animations->initAnim(animIdx, kAnimationTypeLoop, AnimationTypes::kStanding, ctx.actorIdx);
+ engine->_animations->initAnim(animIdx, AnimType::kAnimationTypeLoop, AnimationTypes::kStanding, ctx.actorIdx);
return 0;
}
@@ -599,7 +599,7 @@ static int32 lANIM(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 lANIM_OBJ(TwinEEngine *engine, LifeScriptContext &ctx) {
int32 otherActorIdx = ctx.stream.readByte();
AnimationTypes otherAnimIdx = (AnimationTypes)ctx.stream.readByte();
- engine->_animations->initAnim(otherAnimIdx, kAnimationTypeLoop, AnimationTypes::kStanding, otherActorIdx);
+ engine->_animations->initAnim(otherAnimIdx, AnimType::kAnimationTypeLoop, AnimationTypes::kStanding, otherActorIdx);
return 0;
}
@@ -729,7 +729,7 @@ static int32 lCAM_FOLLOW(TwinEEngine *engine, LifeScriptContext &ctx) {
static int32 lSET_BEHAVIOUR(TwinEEngine *engine, LifeScriptContext &ctx) {
const HeroBehaviourType behavior = (HeroBehaviourType)ctx.stream.readByte();
- engine->_animations->initAnim(AnimationTypes::kStanding, kAnimationTypeLoop, AnimationTypes::kAnimInvalid, 0);
+ engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, 0);
engine->_actor->setBehaviour(behavior);
return 0;
@@ -1614,7 +1614,7 @@ static int32 lANIM_SET(TwinEEngine *engine, LifeScriptContext &ctx) {
ctx.actor->anim = AnimationTypes::kAnimNone;
ctx.actor->previousAnimIdx = -1;
- engine->_animations->initAnim(animIdx, kAnimationTypeLoop, AnimationTypes::kStanding, ctx.actorIdx);
+ engine->_animations->initAnim(animIdx, AnimType::kAnimationTypeLoop, AnimationTypes::kStanding, ctx.actorIdx);
return 0;
}
diff --git a/engines/twine/script/script_move_v1.cpp b/engines/twine/script/script_move_v1.cpp
index ea8c6ae4f4..80b3fa6dfc 100644
--- a/engines/twine/script/script_move_v1.cpp
+++ b/engines/twine/script/script_move_v1.cpp
@@ -102,7 +102,7 @@ static int32 mBODY(TwinEEngine *engine, MoveScriptContext &ctx) {
*/
static int32 mANIM(TwinEEngine *engine, MoveScriptContext &ctx) {
AnimationTypes animIdx = (AnimationTypes)ctx.stream.readByte();
- if (engine->_animations->initAnim(animIdx, kAnimationTypeLoop, AnimationTypes::kStanding, ctx.actorIdx)) {
+ if (engine->_animations->initAnim(animIdx, AnimType::kAnimationTypeLoop, AnimationTypes::kStanding, ctx.actorIdx)) {
return 0;
}
ctx.undo(1);
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index b1225a6c8b..8ee81dfe5a 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -611,7 +611,7 @@ void TwinEEngine::processInventoryAction() {
_actor->setBehaviour(HeroBehaviourType::kNormal);
}
_actor->initModelActor(BodyType::btSabre, OWN_ACTOR_SCENE_INDEX);
- _animations->initAnim(AnimationTypes::kSabreUnknown, kAnimationType_1, AnimationTypes::kStanding, OWN_ACTOR_SCENE_INDEX);
+ _animations->initAnim(AnimationTypes::kSabreUnknown, AnimType::kAnimationType_1, AnimationTypes::kStanding, OWN_ACTOR_SCENE_INDEX);
_gameState->usingSabre = true;
}
@@ -861,7 +861,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
if (actor->life == 0) {
if (IS_HERO(a)) {
- _animations->initAnim(AnimationTypes::kLandDeath, kAnimationType_4, AnimationTypes::kStanding, 0);
+ _animations->initAnim(AnimationTypes::kLandDeath, AnimType::kAnimationType_4, AnimationTypes::kStanding, 0);
actor->controlMode = ControlMode::kNoMove;
} else {
_sound->playSample(Samples::Explode, 1, actor->pos, a);
@@ -909,7 +909,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
if (IS_HERO(a)) {
if (_actor->heroBehaviour != HeroBehaviourType::kProtoPack || actor->anim != AnimationTypes::kForward) {
if (!_actor->cropBottomScreen) {
- _animations->initAnim(AnimationTypes::kDrawn, kAnimationType_4, AnimationTypes::kStanding, 0);
+ _animations->initAnim(AnimationTypes::kDrawn, AnimType::kAnimationType_4, AnimationTypes::kStanding, 0);
_renderer->projectPositionOnScreen(actor->pos - _grid->camera);
_actor->cropBottomScreen = _renderer->projPos.y;
}
Commit: bee2acfd2b9f571189a603d2c410ffd37b384f3b
https://github.com/scummvm/scummvm/commit/bee2acfd2b9f571189a603d2c410ffd37b384f3b
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: reduced visibility
Changed paths:
engines/twine/renderer/renderer.cpp
engines/twine/renderer/renderer.h
diff --git a/engines/twine/renderer/renderer.cpp b/engines/twine/renderer/renderer.cpp
index 7a319dd14d..69ac8da24c 100644
--- a/engines/twine/renderer/renderer.cpp
+++ b/engines/twine/renderer/renderer.cpp
@@ -66,7 +66,7 @@ void Renderer::init(int32 w, int32 h) {
void Renderer::projectXYPositionOnScreen(int32 x, int32 y, int32 z) {
if (_isUsingOrthoProjection == 1) {
- projPos.x = ((x - z) * 24) / BRICK_SIZE + orthoProjPos.x;
+ projPos.x = ((x - z) * 24) / BRICK_SIZE + _orthoProjPos.x;
projPos.y = y;
return;
}
@@ -76,7 +76,7 @@ void Renderer::projectXYPositionOnScreen(int32 x, int32 y, int32 z) {
if (posZ < 0) {
posZ = 0x7FFF;
}
- projPos.x = (cz * _cameraScaleY) / posZ + orthoProjPos.x;
+ projPos.x = (cz * _cameraScaleY) / posZ + _orthoProjPos.x;
projPos.y = y - baseRotPos.y;
return;
}
@@ -87,8 +87,8 @@ void Renderer::projectXYPositionOnScreen(int32 x, int32 y, int32 z) {
int32 Renderer::projectPositionOnScreen(int32 cX, int32 cY, int32 cZ) {
if (_isUsingOrthoProjection) {
- projPos.x = ((cX - cZ) * 24) / BRICK_SIZE + orthoProjPos.x;
- projPos.y = (((cX + cZ) * 12) - cY * 30) / BRICK_SIZE + orthoProjPos.y;
+ projPos.x = ((cX - cZ) * 24) / BRICK_SIZE + _orthoProjPos.x;
+ projPos.y = (((cX + cZ) * 12) - cY * 30) / BRICK_SIZE + _orthoProjPos.y;
projPos.z = cZ - cY - cX;
return 1;
}
@@ -109,15 +109,15 @@ int32 Renderer::projectPositionOnScreen(int32 cX, int32 cY, int32 cZ) {
posZ = 0x7FFF;
}
- projPos.x = (cX * _cameraScaleY) / posZ + orthoProjPos.x;
- projPos.y = (-cY * _cameraScaleZ) / posZ + orthoProjPos.y;
+ projPos.x = (cX * _cameraScaleY) / posZ + _orthoProjPos.x;
+ projPos.y = (-cY * _cameraScaleZ) / posZ + _orthoProjPos.y;
projPos.z = posZ;
return -1;
}
void Renderer::setCameraPosition(int32 x, int32 y, int32 depthOffset, int32 scaleY, int32 scaleZ) {
- orthoProjPos.x = x;
- orthoProjPos.y = y;
+ _orthoProjPos.x = x;
+ _orthoProjPos.y = y;
_cameraDepthOffset = depthOffset;
_cameraScaleY = scaleY;
@@ -133,9 +133,9 @@ void Renderer::setBaseTranslation(int32 x, int32 y, int32 z) {
}
void Renderer::setOrthoProjection(int32 x, int32 y, int32 z) {
- orthoProjPos.x = x;
- orthoProjPos.y = y;
- orthoProjPos.z = z;
+ _orthoProjPos.x = x;
+ _orthoProjPos.y = y;
+ _orthoProjPos.z = z;
_isUsingOrthoProjection = true;
}
@@ -1347,8 +1347,8 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
const int32 coY = pointPtr->y + renderPos.y;
const int32 coZ = -(pointPtr->z + renderPos.z);
- pointPtrDest->x = (coX + coZ) * 24 / BRICK_SIZE + orthoProjPos.x;
- pointPtrDest->y = (((coX - coZ) * 12) - coY * 30) / BRICK_SIZE + orthoProjPos.y;
+ pointPtrDest->x = (coX + coZ) * 24 / BRICK_SIZE + _orthoProjPos.x;
+ pointPtrDest->y = (((coX - coZ) * 12) - coY * 30) / BRICK_SIZE + _orthoProjPos.y;
pointPtrDest->z = coZ - coX - coY;
if (pointPtrDest->x < _engine->_redraw->renderRect.left) {
@@ -1382,7 +1382,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
// X projection
{
- coX = orthoProjPos.x + ((coX * _cameraScaleY) / coZ);
+ coX = _orthoProjPos.x + ((coX * _cameraScaleY) / coZ);
if (coX > 0xFFFF) {
coX = 0x7FFF;
@@ -1401,7 +1401,7 @@ bool Renderer::renderAnimatedModel(ModelData *modelData, const uint8 *bodyPtr, R
// Y projection
{
- coY = orthoProjPos.y + ((-coY * _cameraScaleZ) / coZ);
+ coY = _orthoProjPos.y + ((-coY * _cameraScaleZ) / coZ);
if (coY > 0xFFFF) {
coY = 0x7FFF;
diff --git a/engines/twine/renderer/renderer.h b/engines/twine/renderer/renderer.h
index b26983f7eb..aa48065d68 100644
--- a/engines/twine/renderer/renderer.h
+++ b/engines/twine/renderer/renderer.h
@@ -275,6 +275,7 @@ private:
void translateGroup(int32 x, int32 y, int32 z);
IVec3 _baseTransPos;
+ IVec3 _orthoProjPos;
int32 _cameraDepthOffset = 0;
int32 _cameraScaleY = 0;
@@ -339,7 +340,6 @@ public:
IVec3 projPosScreen;
IVec3 projPos;
IVec3 baseRotPos;
- IVec3 orthoProjPos;
IVec3 destPos;
IVec3 getHolomapRotation(const int32 angleX, const int32 angleY, const int32 angleZ) const;
Commit: 7c988dbca859074079e1a02b24406127fc9f2429
https://github.com/scummvm/scummvm/commit/7c988dbca859074079e1a02b24406127fc9f2429
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-19T15:49:07+01:00
Commit Message:
TWINE: renamed members
Changed paths:
engines/twine/flamovies.cpp
engines/twine/flamovies.h
engines/twine/holomap.cpp
engines/twine/holomap.h
engines/twine/scene/collision.cpp
engines/twine/scene/collision.h
engines/twine/scene/extra.cpp
engines/twine/scene/extra.h
engines/twine/scene/gamestate.cpp
engines/twine/scene/gamestate.h
engines/twine/scene/grid.cpp
engines/twine/scene/grid.h
engines/twine/scene/movements.cpp
engines/twine/scene/movements.h
engines/twine/text.cpp
engines/twine/text.h
engines/twine/twine.cpp
engines/twine/twine.h
diff --git a/engines/twine/flamovies.cpp b/engines/twine/flamovies.cpp
index a8e3c75b36..a1a867c305 100644
--- a/engines/twine/flamovies.cpp
+++ b/engines/twine/flamovies.cpp
@@ -68,7 +68,7 @@ struct FLASampleStruct {
#define FLA_EXT ".fla"
void FlaMovies::drawKeyFrame(Common::MemoryReadStream &stream, int32 width, int32 height) {
- uint8 *destPtr = (uint8 *)flaBuffer;
+ uint8 *destPtr = (uint8 *)_flaBuffer;
uint8 *startOfLine = destPtr;
for (int32 y = 0; y < height; ++y) {
@@ -97,7 +97,7 @@ void FlaMovies::drawDeltaFrame(Common::MemoryReadStream &stream, int32 width) {
const uint16 skip = stream.readUint16LE() * width;
const int32 height = stream.readSint16LE();
- uint8 *destPtr = (uint8 *)flaBuffer + skip;
+ uint8 *destPtr = (uint8 *)_flaBuffer + skip;
uint8 *startOfLine = destPtr;
for (int32 y = 0; y < height; ++y) {
const int8 lineEntryCount = stream.readByte();
@@ -123,7 +123,7 @@ void FlaMovies::drawDeltaFrame(Common::MemoryReadStream &stream, int32 width) {
}
void FlaMovies::scaleFla2x() {
- uint8 *source = (uint8 *)flaBuffer;
+ uint8 *source = (uint8 *)_flaBuffer;
uint8 *dest = (uint8 *)_engine->imageBuffer.getPixels();
if (_engine->cfgfile.Movie == CONF_MOVIE_FLAWIDE) {
@@ -159,23 +159,23 @@ void FlaMovies::scaleFla2x() {
void FlaMovies::processFrame() {
FLASampleStruct sample;
- file.read(&frameData.videoSize, 1);
- file.read(&frameData.dummy, 1);
- file.read(&frameData.frameVar0, 4);
- if (frameData.frameVar0 > _engine->imageBuffer.w * _engine->imageBuffer.h) {
- warning("Skipping video frame - it would exceed the screen buffer: %i", frameData.frameVar0);
+ _file.read(&_frameData.videoSize, 1);
+ _file.read(&_frameData.dummy, 1);
+ _file.read(&_frameData.frameVar0, 4);
+ if (_frameData.frameVar0 > _engine->imageBuffer.w * _engine->imageBuffer.h) {
+ warning("Skipping video frame - it would exceed the screen buffer: %i", _frameData.frameVar0);
return;
}
uint8 *outBuf = (uint8 *)_engine->imageBuffer.getPixels();
- file.read(outBuf, frameData.frameVar0);
+ _file.read(outBuf, _frameData.frameVar0);
- if ((int32)frameData.videoSize <= 0) {
+ if ((int32)_frameData.videoSize <= 0) {
return;
}
- Common::MemoryReadStream stream(outBuf, frameData.frameVar0);
- for (int32 frame = 0; frame < frameData.videoSize; ++frame) {
+ Common::MemoryReadStream stream(outBuf, _frameData.frameVar0);
+ for (int32 frame = 0; frame < _frameData.videoSize; ++frame) {
const uint16 opcode = stream.readUint16LE();
const uint16 opcodeBlockSize = stream.readUint16LE();
const int32 pos = stream.pos();
@@ -229,7 +229,7 @@ void FlaMovies::processFrame() {
case kDeltaFrame: {
drawDeltaFrame(stream, FLASCREEN_WIDTH);
if (_fadeOut == 1) {
- ++fadeOutFrames;
+ ++_fadeOutFrames;
}
break;
}
@@ -358,29 +358,29 @@ void FlaMovies::playFlaMovie(const char *flaName) {
fileNamePath += FLA_EXT;
_fadeOut = -1;
- fadeOutFrames = 0;
+ _fadeOutFrames = 0;
- file.close();
- if (!file.open(fileNamePath)) {
+ _file.close();
+ if (!_file.open(fileNamePath)) {
warning("Failed to open fla movie '%s'", fileNamePath.c_str());
return;
}
- file.read(&flaHeaderData.version, 6);
- flaHeaderData.numOfFrames = file.readUint32LE();
- flaHeaderData.speed = file.readByte();
- flaHeaderData.var1 = file.readByte();
- debug(2, "Unknown byte in fla file: %i", flaHeaderData.var1);
- flaHeaderData.xsize = file.readUint16LE();
- flaHeaderData.ysize = file.readUint16LE();
+ _file.read(&_flaHeaderData.version, 6);
+ _flaHeaderData.numOfFrames = _file.readUint32LE();
+ _flaHeaderData.speed = _file.readByte();
+ _flaHeaderData.var1 = _file.readByte();
+ debug(2, "Unknown byte in fla file: %i", _flaHeaderData.var1);
+ _flaHeaderData.xsize = _file.readUint16LE();
+ _flaHeaderData.ysize = _file.readUint16LE();
- samplesInFla = file.readUint16LE();
- const uint16 unk2 = file.readUint16LE();
+ _samplesInFla = _file.readUint16LE();
+ const uint16 unk2 = _file.readUint16LE();
debug(2, "Unknown uint16 in fla file: %i", unk2);
- file.skip(4 * samplesInFla);
+ _file.skip(4 * _samplesInFla);
- if (!strcmp((const char *)flaHeaderData.version, "V1.3")) {
+ if (!strcmp((const char *)_flaHeaderData.version, "V1.3")) {
int32 currentFrame = 0;
debug("Play fla: %s", flaName);
@@ -390,12 +390,12 @@ void FlaMovies::playFlaMovie(const char *flaName) {
_flaPaletteVar = true;
do {
FrameMarker frame;
- ScopedFPS scopedFps(flaHeaderData.speed);
+ ScopedFPS scopedFps(_flaHeaderData.speed);
_engine->readKeys();
if (_engine->shouldQuit()) {
break;
}
- if (currentFrame == flaHeaderData.numOfFrames) {
+ if (currentFrame == _flaHeaderData.numOfFrames) {
break;
}
processFrame();
@@ -415,12 +415,12 @@ void FlaMovies::playFlaMovie(const char *flaName) {
}
// TRICKY: fade in tricky
- if (fadeOutFrames >= 2) {
+ if (_fadeOutFrames >= 2) {
_engine->flip();
_engine->_screens->convertPalToRGBA(_engine->_screens->palette, _engine->_screens->paletteRGBACustom);
_engine->_screens->fadeToPal(_engine->_screens->paletteRGBACustom);
_fadeOut = -1;
- fadeOutFrames = 0;
+ _fadeOutFrames = 0;
}
currentFrame++;
diff --git a/engines/twine/flamovies.h b/engines/twine/flamovies.h
index be76a8f27d..f45dd7b29b 100644
--- a/engines/twine/flamovies.h
+++ b/engines/twine/flamovies.h
@@ -66,23 +66,23 @@ class FlaMovies {
private:
TwinEEngine *_engine;
- Common::File file;
+ Common::File _file;
/** Auxiliar FLA fade out variable */
int32 _fadeOut = 0;
/** Auxiliar FLA fade out variable to count frames between the fade */
- int32 fadeOutFrames = 0;
+ int32 _fadeOutFrames = 0;
bool _flaPaletteVar = false;
/** FLA movie file buffer */
- uint8 flaBuffer[FLASCREEN_WIDTH * FLASCREEN_HEIGHT] {0};
+ uint8 _flaBuffer[FLASCREEN_WIDTH * FLASCREEN_HEIGHT] {0};
/** Number of samples in FLA movie */
- int32 samplesInFla = 0;
+ int32 _samplesInFla = 0;
/** FLA movie header data */
- FLAHeaderStruct flaHeaderData;
+ FLAHeaderStruct _flaHeaderData;
/** FLA movie header data */
- FLAFrameDataStruct frameData;
+ FLAFrameDataStruct _frameData;
void drawKeyFrame(Common::MemoryReadStream &stream, int32 width, int32 height);
void drawDeltaFrame(Common::MemoryReadStream &stream, int32 width);
diff --git a/engines/twine/holomap.cpp b/engines/twine/holomap.cpp
index 1df401addc..a6790a5ccc 100644
--- a/engines/twine/holomap.cpp
+++ b/engines/twine/holomap.cpp
@@ -96,21 +96,21 @@ void Holomap::loadHolomapGFX() {
int32 j = 576;
for (int32 i = 0; i < 96; i += 3, j += 3) {
- paletteHolomap[i + 0] = _engine->_screens->palette[j + 0];
- paletteHolomap[i + 1] = _engine->_screens->palette[j + 1];
- paletteHolomap[i + 2] = _engine->_screens->palette[j + 2];
+ _paletteHolomap[i + 0] = _engine->_screens->palette[j + 0];
+ _paletteHolomap[i + 1] = _engine->_screens->palette[j + 1];
+ _paletteHolomap[i + 2] = _engine->_screens->palette[j + 2];
}
j = 576;
for (int32 i = 96; i < 189; i += 3, j += 3) {
- paletteHolomap[i + 0] = _engine->_screens->palette[j + 0];
- paletteHolomap[i + 1] = _engine->_screens->palette[j + 1];
- paletteHolomap[i + 2] = _engine->_screens->palette[j + 2];
+ _paletteHolomap[i + 0] = _engine->_screens->palette[j + 0];
+ _paletteHolomap[i + 1] = _engine->_screens->palette[j + 1];
+ _paletteHolomap[i + 2] = _engine->_screens->palette[j + 2];
}
prepareHolomapProjectedPositions();
prepareHolomapSurface();
- holomapPaletteIndex = 0;
+ _holomapPaletteIndex = 0;
}
static int sortHolomapSurfaceCoordsByDepth(const void *a1, const void *a2) {
@@ -341,11 +341,11 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
if (!fadeInPalette && local18 < _engine->lbaTime) {
//const Common::Rect rect(170, 50, 470, 330);
//_engine->_interface->setClip(rect);
- _engine->setPalette(192, 32, &paletteHolomap[3 * holomapPaletteIndex++]);
+ _engine->setPalette(192, 32, &_paletteHolomap[3 * _holomapPaletteIndex++]);
//_engine->copyBlockPhys(rect);
//_engine->_interface->resetClip();
- if (holomapPaletteIndex == 32) {
- holomapPaletteIndex = 0;
+ if (_holomapPaletteIndex == 32) {
+ _holomapPaletteIndex = 0;
}
local18 = _engine->lbaTime + 3;
}
@@ -576,11 +576,11 @@ void Holomap::processHolomap() {
if (!fadeInPalette && local18 < _engine->lbaTime) {
//const Common::Rect rect(170, 50, 470, 330);
//_engine->_interface->setClip(rect);
- _engine->setPalette(192, 32, &paletteHolomap[3 * holomapPaletteIndex++]);
+ _engine->setPalette(192, 32, &_paletteHolomap[3 * _holomapPaletteIndex++]);
//_engine->copyBlockPhys(rect);
//_engine->_interface->resetClip();
- if (holomapPaletteIndex == 32) {
- holomapPaletteIndex = 0;
+ if (_holomapPaletteIndex == 32) {
+ _holomapPaletteIndex = 0;
}
local18 = _engine->lbaTime + 3;
redraw = true;
diff --git a/engines/twine/holomap.h b/engines/twine/holomap.h
index 3abbb37390..dae01cf949 100644
--- a/engines/twine/holomap.h
+++ b/engines/twine/holomap.h
@@ -112,8 +112,8 @@ private:
int32 _numLocations = 0;
Location _locations[NUM_LOCATIONS];
- int32 holomapPaletteIndex = 0;
- uint8 paletteHolomap[NUMOFCOLORS * 3]{0};
+ int32 _holomapPaletteIndex = 0;
+ uint8 _paletteHolomap[NUMOFCOLORS * 3]{0};
void drawHolomapText(int32 centerx, int32 top, const char *title);
int32 getNextHolomapLocation(int32 currentLocation, int32 dir) const;
diff --git a/engines/twine/scene/collision.cpp b/engines/twine/scene/collision.cpp
index 4c6c5adf8e..01932fd343 100644
--- a/engines/twine/scene/collision.cpp
+++ b/engines/twine/scene/collision.cpp
@@ -40,7 +40,7 @@ namespace TwinE {
Collision::Collision(TwinEEngine *engine) : _engine(engine) {
}
-bool Collision::standingOnActor(int32 actorIdx1, int32 actorIdx2) {
+bool Collision::standingOnActor(int32 actorIdx1, int32 actorIdx2) const {
const ActorStruct *actor1 = _engine->_scene->getActor(actorIdx1);
const ActorStruct *actor2 = _engine->_scene->getActor(actorIdx2);
@@ -91,7 +91,7 @@ bool Collision::standingOnActor(int32 actorIdx1, int32 actorIdx2) {
return true; // standing
}
-int32 Collision::getAverageValue(int32 start, int32 end, int32 maxDelay, int32 delay) {
+int32 Collision::getAverageValue(int32 start, int32 end, int32 maxDelay, int32 delay) const {
if (delay <= 0) {
return start;
}
diff --git a/engines/twine/scene/collision.h b/engines/twine/scene/collision.h
index 87004e28bc..09ab8b36cb 100644
--- a/engines/twine/scene/collision.h
+++ b/engines/twine/scene/collision.h
@@ -50,9 +50,9 @@ public:
* @param actorIdx1 Actor 1 index
* @param actorIdx2 Actor 2 index
*/
- bool standingOnActor(int32 actorIdx1, int32 actorIdx2);
+ bool standingOnActor(int32 actorIdx1, int32 actorIdx2) const;
- int32 getAverageValue(int32 start, int32 end, int32 maxDelay, int32 delay);
+ int32 getAverageValue(int32 start, int32 end, int32 maxDelay, int32 delay) const;
/**
* Reajust actor position in scene according with brick shape bellow actor
diff --git a/engines/twine/scene/extra.cpp b/engines/twine/scene/extra.cpp
index d4028ad16a..9d6219c3a3 100644
--- a/engines/twine/scene/extra.cpp
+++ b/engines/twine/scene/extra.cpp
@@ -305,9 +305,9 @@ int32 Extra::addExtraAiming(int32 actorIdx, int32 x, int32 y, int32 z, int32 spr
}
// cseg01:00018168
-int32 Extra::findExtraKey() {
+int32 Extra::findExtraKey() const {
for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
- ExtraListStruct *extra = &extraList[i];
+ const ExtraListStruct *extra = &extraList[i];
if (extra->info0 == SPRITEHQR_KEY) {
return i;
}
diff --git a/engines/twine/scene/extra.h b/engines/twine/scene/extra.h
index 859805985d..e2d7ccab9b 100644
--- a/engines/twine/scene/extra.h
+++ b/engines/twine/scene/extra.h
@@ -90,7 +90,7 @@ private:
void throwExtra(ExtraListStruct *extra, int32 xAngle, int32 yAngle, int32 x, int32 extraAngle);
void processMagicballBounce(ExtraListStruct *extra, int32 x, int32 y, int32 z);
- int32 findExtraKey();
+ int32 findExtraKey() const;
int32 addExtraAimingAtKey(int32 actorIdx, int32 x, int32 y, int32 z, int32 spriteIdx, int32 extraIdx);
void drawSpecialShape(const ExtraShape &shapeTable, int32 x, int32 y, int32 color, int32 angle, int32 size);
diff --git a/engines/twine/scene/gamestate.cpp b/engines/twine/scene/gamestate.cpp
index fb91ac4651..bc46587b87 100644
--- a/engines/twine/scene/gamestate.cpp
+++ b/engines/twine/scene/gamestate.cpp
@@ -452,18 +452,18 @@ void GameState::processFoundItem(int32 item) {
void GameState::processGameChoices(int32 choiceIdx) {
_engine->_screens->copyScreen(_engine->frontVideoBuffer, _engine->workVideoBuffer);
- gameChoicesSettings.reset();
- gameChoicesSettings.setTextBankId(_engine->_scene->sceneTextBank + TextBankId::Citadel_Island);
+ _gameChoicesSettings.reset();
+ _gameChoicesSettings.setTextBankId(_engine->_scene->sceneTextBank + TextBankId::Citadel_Island);
// filled via script
for (int32 i = 0; i < numChoices; i++) {
- gameChoicesSettings.addButton(gameChoices[i], 0);
+ _gameChoicesSettings.addButton(gameChoices[i], 0);
}
_engine->_text->drawAskQuestion(choiceIdx);
- _engine->_menu->processMenu(&gameChoicesSettings, false);
- const int16 activeButton = gameChoicesSettings.getActiveButton();
+ _engine->_menu->processMenu(&_gameChoicesSettings, false);
+ const int16 activeButton = _gameChoicesSettings.getActiveButton();
choiceAnswer = gameChoices[activeButton];
// get right VOX entry index
diff --git a/engines/twine/scene/gamestate.h b/engines/twine/scene/gamestate.h
index 193abc9835..64451f3f55 100644
--- a/engines/twine/scene/gamestate.h
+++ b/engines/twine/scene/gamestate.h
@@ -82,7 +82,7 @@ private:
void initGameStateVars();
void initHeroVars();
- MenuSettings gameChoicesSettings;
+ MenuSettings _gameChoicesSettings;
/**
* LBA engine game flags to save quest states
diff --git a/engines/twine/scene/grid.cpp b/engines/twine/scene/grid.cpp
index ecdd5d1f2a..05f975f19d 100644
--- a/engines/twine/scene/grid.cpp
+++ b/engines/twine/scene/grid.cpp
@@ -38,34 +38,34 @@
namespace TwinE {
Grid::Grid(TwinEEngine *engine) : _engine(engine) {
- blockBufferSize = GRID_SIZE_X * GRID_SIZE_Z * GRID_SIZE_Y * 2 * sizeof(uint8);
- blockBuffer = (uint8 *)malloc(blockBufferSize);
+ _blockBufferSize = GRID_SIZE_X * GRID_SIZE_Z * GRID_SIZE_Y * 2 * sizeof(uint8);
+ _blockBuffer = (uint8 *)malloc(_blockBufferSize);
}
Grid::~Grid() {
- free(blockBuffer);
- for (int32 i = 0; i < ARRAYSIZE(brickMaskTable); i++) {
- free(brickMaskTable[i]);
+ free(_blockBuffer);
+ for (int32 i = 0; i < ARRAYSIZE(_brickMaskTable); i++) {
+ free(_brickMaskTable[i]);
}
- for (int32 i = 0; i < ARRAYSIZE(brickTable); i++) {
- free(brickTable[i]);
+ for (int32 i = 0; i < ARRAYSIZE(_brickTable); i++) {
+ free(_brickTable[i]);
}
- free(currentGrid);
- free(currentBll);
- free(brickInfoBuffer);
- free(bricksDataBuffer);
+ free(_currentGrid);
+ free(_currentBll);
+ free(_brickInfoBuffer);
+ free(_bricksDataBuffer);
}
void Grid::init(int32 w, int32 h) {
const int32 numbrickentries = (1 + (w + 24) / 24);
const size_t brickDataBufferSize = numbrickentries * MAXBRICKS * sizeof(BrickEntry);
- bricksDataBuffer = (BrickEntry *)malloc(brickDataBufferSize);
+ _bricksDataBuffer = (BrickEntry *)malloc(brickDataBufferSize);
_brickInfoBufferSize = numbrickentries * sizeof(int16);
- brickInfoBuffer = (int16 *)malloc(_brickInfoBufferSize);
+ _brickInfoBuffer = (int16 *)malloc(_brickInfoBufferSize);
}
void Grid::copyGridMask(int32 index, int32 x, int32 y, const Graphics::ManagedSurface &buffer) {
- uint8 *ptr = brickMaskTable[index];
+ uint8 *ptr = _brickMaskTable[index];
int32 left = x + *(ptr + 2);
int32 top = y + *(ptr + 3);
@@ -158,7 +158,7 @@ void Grid::copyGridMask(int32 index, int32 x, int32 y, const Graphics::ManagedSu
}
const BrickEntry* Grid::getBrickEntry(int32 j, int32 i) const {
- return &bricksDataBuffer[j * MAXBRICKS + i];
+ return &_bricksDataBuffer[j * MAXBRICKS + i];
}
void Grid::drawOverModelActor(int32 x, int32 y, int32 z) {
@@ -166,7 +166,7 @@ void Grid::drawOverModelActor(int32 x, int32 y, int32 z) {
const int32 copyBlockPhysRight = ((_engine->_interface->textWindow.right + 24) / 24);
for (int32 j = copyBlockPhysLeft; j <= copyBlockPhysRight; j++) {
- for (int32 i = 0; i < brickInfoBuffer[j]; i++) {
+ for (int32 i = 0; i < _brickInfoBuffer[j]; i++) {
const BrickEntry *currBrickEntry = getBrickEntry(j, i);
if (currBrickEntry->posY + 38 > _engine->_interface->textWindow.top && currBrickEntry->posY <= _engine->_interface->textWindow.bottom && currBrickEntry->y >= y) {
@@ -183,7 +183,7 @@ void Grid::drawOverSpriteActor(int32 x, int32 y, int32 z) {
const int32 copyBlockPhysRight = (_engine->_interface->textWindow.right + 24) / 24;
for (int32 j = copyBlockPhysLeft; j <= copyBlockPhysRight; j++) {
- for (int32 i = 0; i < brickInfoBuffer[j]; i++) {
+ for (int32 i = 0; i < _brickInfoBuffer[j]; i++) {
const BrickEntry *currBrickEntry = getBrickEntry(j, i);
if (currBrickEntry->posY + 38 > _engine->_interface->textWindow.top && currBrickEntry->posY <= _engine->_interface->textWindow.bottom && currBrickEntry->y >= y) {
@@ -262,14 +262,14 @@ void Grid::processGridMask(const uint8 *buffer, uint8 *ptr) {
void Grid::createGridMask() {
for (int32 b = 0; b < NUM_BRICKS; b++) {
- if (!brickUsageTable[b]) {
+ if (!_brickUsageTable[b]) {
continue;
}
- if (brickMaskTable[b]) {
- free(brickMaskTable[b]);
+ if (_brickMaskTable[b]) {
+ free(_brickMaskTable[b]);
}
- brickMaskTable[b] = (uint8 *)malloc(brickSizeTable[b]);
- processGridMask(brickTable[b], brickMaskTable[b]);
+ _brickMaskTable[b] = (uint8 *)malloc(_brickSizeTable[b]);
+ processGridMask(_brickTable[b], _brickMaskTable[b]);
}
}
@@ -285,11 +285,11 @@ void Grid::loadGridBricks() {
uint32 lastBrick = 0;
uint32 currentBllEntryIdx = 0;
- memset(brickSizeTable, 0, sizeof(brickSizeTable));
- memset(brickUsageTable, 0, sizeof(brickUsageTable));
+ memset(_brickSizeTable, 0, sizeof(_brickSizeTable));
+ memset(_brickUsageTable, 0, sizeof(_brickUsageTable));
// get block libraries usage bits
- const uint8 *ptrToBllBits = currentGrid + (currentGridSize - 32);
+ const uint8 *ptrToBllBits = _currentGrid + (_currentGridSize - 32);
// for all bits under the 32bytes (256bits)
for (uint32 i = 1; i < 256; i++) {
@@ -297,8 +297,8 @@ void Grid::loadGridBricks() {
const uint8 currentBitMask = 1 << (7 - (i & 7));
if (currentBitByte & currentBitMask) {
- uint32 currentBllOffset = READ_LE_UINT32(currentBll + currentBllEntryIdx);
- const uint8 *currentBllPtr = currentBll + currentBllOffset;
+ uint32 currentBllOffset = READ_LE_UINT32(_currentBll + currentBllEntryIdx);
+ const uint8 *currentBllPtr = _currentBll + currentBllOffset;
const uint32 bllSizeX = *currentBllPtr++;
const uint32 bllSizeY = *currentBllPtr++;
@@ -323,7 +323,7 @@ void Grid::loadGridBricks() {
lastBrick = brickIdx;
}
- brickUsageTable[brickIdx] = 1;
+ _brickUsageTable[brickIdx] = 1;
}
}
}
@@ -331,13 +331,13 @@ void Grid::loadGridBricks() {
}
for (uint32 i = firstBrick; i <= lastBrick; i++) {
- if (!brickUsageTable[i]) {
- free(brickTable[i]);
- brickTable[i] = nullptr;
+ if (!_brickUsageTable[i]) {
+ free(_brickTable[i]);
+ _brickTable[i] = nullptr;
continue;
}
- brickSizeTable[i] = HQR::getAllocEntry(&brickTable[i], Resources::HQR_LBA_BRK_FILE, i);
- if (brickSizeTable[i] == 0) {
+ _brickSizeTable[i] = HQR::getAllocEntry(&_brickTable[i], Resources::HQR_LBA_BRK_FILE, i);
+ if (_brickSizeTable[i] == 0) {
warning("Failed to load isometric brick index %i", i);
}
}
@@ -408,8 +408,8 @@ void Grid::createGridMap() {
const int32 gridIdx = z * GRID_SIZE_X;
for (int32 x = 0; x < GRID_SIZE_X; x++) {
- const int32 gridOffset = READ_LE_UINT16(currentGrid + 2 * (x + gridIdx));
- createGridColumn(currentGrid + gridOffset, currentGridSize - gridOffset, blockBuffer + blockOffset, blockBufferSize - blockOffset);
+ const int32 gridOffset = READ_LE_UINT16(_currentGrid + 2 * (x + gridIdx));
+ createGridColumn(_currentGrid + gridOffset, _currentGridSize - gridOffset, _blockBuffer + blockOffset, _blockBufferSize - blockOffset);
blockOffset += 2 * GRID_SIZE_Y;
}
currOffset += GRID_SIZE_X * (2 * GRID_SIZE_Y);
@@ -427,7 +427,7 @@ void Grid::createCellingGridMap(const uint8 *gridPtr, int32 gridPtrSize) {
for (int32 x = 0; x < GRID_SIZE_X; x++) {
const int gridOffset = READ_LE_UINT16(tempGridPtr);
tempGridPtr += 2;
- createCellingGridColumn(gridPtr + gridOffset, gridPtrSize - gridOffset, blockBuffer + blockOffset, blockBufferSize - blockOffset);
+ createCellingGridColumn(gridPtr + gridOffset, gridPtrSize - gridOffset, _blockBuffer + blockOffset, _blockBufferSize - blockOffset);
blockOffset += 2 * GRID_SIZE_Y;
}
currGridOffset += GRID_SIZE_X+ GRID_SIZE_Z;
@@ -437,14 +437,14 @@ void Grid::createCellingGridMap(const uint8 *gridPtr, int32 gridPtrSize) {
bool Grid::initGrid(int32 index) {
// load grids from file
- currentGridSize = HQR::getAllocEntry(¤tGrid, Resources::HQR_LBA_GRI_FILE, index);
- if (currentGridSize == 0) {
+ _currentGridSize = HQR::getAllocEntry(&_currentGrid, Resources::HQR_LBA_GRI_FILE, index);
+ if (_currentGridSize == 0) {
warning("Failed to load grid index: %i", index);
return false;
}
// load layouts from file
- if (HQR::getAllocEntry(¤tBll, Resources::HQR_LBA_BLL_FILE, index) == 0) {
+ if (HQR::getAllocEntry(&_currentBll, Resources::HQR_LBA_BLL_FILE, index) == 0) {
warning("Failed to load block library index: %i", index);
return false;
}
@@ -453,7 +453,7 @@ bool Grid::initGrid(int32 index) {
createGridMask();
- numberOfBll = READ_LE_INT32(currentBll) >> 2;
+ _numberOfBll = READ_LE_INT32(_currentBll) >> 2;
createGridMap();
@@ -478,7 +478,7 @@ bool Grid::initCellingGrid(int32 index) {
}
bool Grid::drawBrick(int32 index, int32 posX, int32 posY) {
- return drawBrickSprite(index, posX, posY, brickTable[index], false);
+ return drawBrickSprite(index, posX, posY, _brickTable[index], false);
}
bool Grid::drawSprite(int32 index, int32 posX, int32 posY, const uint8 *ptr) {
@@ -591,7 +591,7 @@ uint8 *Grid::getBlockBuffer(int32 x, int32 y, int32 z) {
const int32 tempX = (x + BRICK_HEIGHT) / BRICK_SIZE;
const int32 tempY = y / BRICK_HEIGHT;
const int32 tempZ = (z + BRICK_HEIGHT) / BRICK_SIZE;
- return blockBuffer + tempY * 2 + tempX * GRID_SIZE_Y * 2 + (tempZ * GRID_SIZE_X) * GRID_SIZE_Y * 2;
+ return _blockBuffer + tempY * 2 + tempX * GRID_SIZE_Y * 2 + (tempZ * GRID_SIZE_X) * GRID_SIZE_Y * 2;
}
const uint8 *Grid::getBlockBufferGround(int32 x, int32 y, int32 z, int32 &ground) {
@@ -599,7 +599,7 @@ const uint8 *Grid::getBlockBufferGround(int32 x, int32 y, int32 z, int32 &ground
const int32 tempX = _engine->_collision->collision.x;
int32 tempY = _engine->_collision->collision.y;
const int32 tempZ = _engine->_collision->collision.z;
- const uint8 *ptr = blockBuffer + tempY * 2 + tempX * GRID_SIZE_Y * 2 + (tempZ * GRID_SIZE_X) * GRID_SIZE_Y * 2;
+ const uint8 *ptr = _blockBuffer + tempY * 2 + tempX * GRID_SIZE_Y * 2 + (tempZ * GRID_SIZE_X) * GRID_SIZE_Y * 2;
while (tempY) {
if (READ_LE_INT16(ptr)) { // found the ground
@@ -615,14 +615,14 @@ const uint8 *Grid::getBlockBufferGround(int32 x, int32 y, int32 z, int32 &ground
return ptr;
}
-const uint8 *Grid::getBlockLibrary(int32 index) {
- const int32 offset = READ_LE_UINT32(currentBll + 4 * index);
- return (const uint8 *)(currentBll + offset);
+const uint8 *Grid::getBlockLibrary(int32 index) const {
+ const int32 offset = READ_LE_UINT32(_currentBll + 4 * index);
+ return (const uint8 *)(_currentBll + offset);
}
void Grid::getBrickPos(int32 x, int32 y, int32 z) {
- brickPixelPosX = (x - z) * 24 + 288; // x pos
- brickPixelPosY = ((x + z) * 12) - (y * 15) + 215; // y pos
+ _brickPixelPosX = (x - z) * 24 + 288; // x pos
+ _brickPixelPosY = ((x + z) * 12) - (y * 15) + 215; // y pos
}
void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y, int32 z) {
@@ -637,45 +637,45 @@ void Grid::drawColumnGrid(int32 blockIdx, int32 brickBlockIdx, int32 x, int32 y,
getBrickPos(x - newCamera.x, y - newCamera.y, z - newCamera.z);
- if (brickPixelPosX < -24) {
+ if (_brickPixelPosX < -24) {
return;
}
- if (brickPixelPosX >= _engine->width()) {
+ if (_brickPixelPosX >= _engine->width()) {
return;
}
- if (brickPixelPosY < -38) {
+ if (_brickPixelPosY < -38) {
return;
}
- if (brickPixelPosY >= _engine->height()) {
+ if (_brickPixelPosY >= _engine->height()) {
return;
}
// draw the background brick
- drawBrick(brickIdx - 1, brickPixelPosX, brickPixelPosY);
+ drawBrick(brickIdx - 1, _brickPixelPosX, _brickPixelPosY);
- int32 brickBuffIdx = (brickPixelPosX + 24) / 24;
+ int32 brickBuffIdx = (_brickPixelPosX + 24) / 24;
- if (brickInfoBuffer[brickBuffIdx] >= MAXBRICKS) {
+ if (_brickInfoBuffer[brickBuffIdx] >= MAXBRICKS) {
warning("GRID: brick buffer exceeded");
return;
}
- BrickEntry *currBrickEntry = &bricksDataBuffer[brickBuffIdx * MAXBRICKS + brickInfoBuffer[brickBuffIdx]];
+ BrickEntry *currBrickEntry = &_bricksDataBuffer[brickBuffIdx * MAXBRICKS + _brickInfoBuffer[brickBuffIdx]];
currBrickEntry->x = x;
currBrickEntry->y = y;
currBrickEntry->z = z;
- currBrickEntry->posX = brickPixelPosX;
- currBrickEntry->posY = brickPixelPosY;
+ currBrickEntry->posX = _brickPixelPosX;
+ currBrickEntry->posY = _brickPixelPosY;
currBrickEntry->index = brickIdx - 1;
currBrickEntry->shape = brickShape;
currBrickEntry->sound = brickSound;
- brickInfoBuffer[brickBuffIdx]++;
+ _brickInfoBuffer[brickBuffIdx]++;
}
void Grid::redrawGrid() {
- blockMap *map = (blockMap *)blockBuffer;
+ blockMap *map = (blockMap *)_blockBuffer;
camera.x = newCamera.x * BRICK_SIZE;
camera.y = newCamera.y * BRICK_HEIGHT;
@@ -686,7 +686,7 @@ void Grid::redrawGrid() {
_engine->_renderer->projPosScreen.x = _engine->_renderer->projPos.x;
_engine->_renderer->projPosScreen.y = _engine->_renderer->projPos.y;
- memset(brickInfoBuffer, 0, _brickInfoBufferSize);
+ memset(_brickInfoBuffer, 0, _brickInfoBufferSize);
if (!_engine->_scene->enableGridTileRendering) {
return;
@@ -719,7 +719,7 @@ ShapeType Grid::getBrickShape(int32 x, int32 y, int32 z) {
return ShapeType::kNone;
}
- uint8 *blockBufferPtr = blockBuffer;
+ uint8 *blockBufferPtr = _blockBuffer;
blockBufferPtr += _engine->_collision->collision.x * GRID_SIZE_Y * 2;
blockBufferPtr += _engine->_collision->collision.y * 2;
blockBufferPtr += (_engine->_collision->collision.z * GRID_SIZE_X * 2) * GRID_SIZE_Y;
@@ -727,7 +727,7 @@ ShapeType Grid::getBrickShape(int32 x, int32 y, int32 z) {
uint8 blockIdx = *blockBufferPtr;
if (blockIdx) {
- const uint8 *blockPtr = currentBll;
+ const uint8 *blockPtr = _currentBll;
blockPtr += READ_LE_UINT32(blockPtr + blockIdx * 4 - 4);
blockPtr += 3;
@@ -761,7 +761,7 @@ ShapeType Grid::getBrickShapeFull(int32 x, int32 y, int32 z, int32 y2) {
return ShapeType::kNone;
}
- uint8 *blockBufferPtr = blockBuffer;
+ uint8 *blockBufferPtr = _blockBuffer;
blockBufferPtr += _engine->_collision->collision.x * GRID_SIZE_Y * 2;
blockBufferPtr += _engine->_collision->collision.y * 2;
blockBufferPtr += (_engine->_collision->collision.z * GRID_SIZE_X * 2) * GRID_SIZE_Y;
@@ -769,7 +769,7 @@ ShapeType Grid::getBrickShapeFull(int32 x, int32 y, int32 z, int32 y2) {
uint8 blockIdx = *blockBufferPtr;
if (blockIdx) {
- const uint8 *blockPtr = currentBll;
+ const uint8 *blockPtr = _currentBll;
blockPtr += READ_LE_UINT32(blockPtr + blockIdx * 4 - 4);
blockPtr += 3;
@@ -833,7 +833,7 @@ int32 Grid::getBrickSoundType(int32 x, int32 y, int32 z) { // getPos2
return 0; // none
}
- const uint8 *blockBufferPtr = blockBuffer;
+ const uint8 *blockBufferPtr = _blockBuffer;
blockBufferPtr += _engine->_collision->collision.x * GRID_SIZE_Y * 2;
blockBufferPtr += _engine->_collision->collision.y * 2;
blockBufferPtr += (_engine->_collision->collision.z * GRID_SIZE_X * 2) * GRID_SIZE_Y;
@@ -841,7 +841,7 @@ int32 Grid::getBrickSoundType(int32 x, int32 y, int32 z) { // getPos2
uint8 blockIdx = *blockBufferPtr;
if (blockIdx) {
- const uint8 *blockPtr = currentBll;
+ const uint8 *blockPtr = _currentBll;
blockPtr += READ_LE_UINT32(blockPtr + blockIdx * 4 - 4);
blockPtr += 3;
diff --git a/engines/twine/scene/grid.h b/engines/twine/scene/grid.h
index e2e544f65d..527d9052dd 100644
--- a/engines/twine/scene/grid.h
+++ b/engines/twine/scene/grid.h
@@ -147,36 +147,36 @@ private:
void copyGridMask(int32 index, int32 x, int32 y, const Graphics::ManagedSurface &buffer);
/** Table with all loaded bricks */
- uint8 *brickTable[NUM_BRICKS]{nullptr};
+ uint8 *_brickTable[NUM_BRICKS]{nullptr};
/** Table with all loaded bricks masks */
- uint8 *brickMaskTable[NUM_BRICKS]{nullptr};
+ uint8 *_brickMaskTable[NUM_BRICKS]{nullptr};
/** Table with all loaded bricks sizes */
- uint32 brickSizeTable[NUM_BRICKS]{0};
+ uint32 _brickSizeTable[NUM_BRICKS]{0};
/** Table with all loaded bricks usage */
- uint8 brickUsageTable[NUM_BRICKS]{0};
+ uint8 _brickUsageTable[NUM_BRICKS]{0};
/** Current grid pointer */
- int32 currentGridSize = 0;
- uint8 *currentGrid = nullptr;
+ int32 _currentGridSize = 0;
+ uint8 *_currentGrid = nullptr;
/** Current block library pointer */
- uint8 *currentBll = nullptr;
+ uint8 *_currentBll = nullptr;
/** Number of block libraries */
- int32 numberOfBll = 0;
+ int32 _numberOfBll = 0;
/** Brick data buffer */
- BrickEntry *bricksDataBuffer = nullptr;
+ BrickEntry *_bricksDataBuffer = nullptr;
/** Brick info buffer */
- int16 *brickInfoBuffer = nullptr;
+ int16 *_brickInfoBuffer = nullptr;
int32 _brickInfoBufferSize = 0;
/** Current brick pixel X position */
- int32 brickPixelPosX = 0;
+ int32 _brickPixelPosX = 0;
/** Current brick pixel Y position */
- int32 brickPixelPosY = 0;
+ int32 _brickPixelPosY = 0;
/** Celling grid brick block buffer */
- int32 blockBufferSize = 0;
- uint8 *blockBuffer = nullptr;
+ int32 _blockBufferSize = 0;
+ uint8 *_blockBuffer = nullptr;
uint8 *getBlockBuffer(int32 x, int32 y, int32 z);
const BrickEntry* getBrickEntry(int32 j, int32 i) const;
@@ -269,7 +269,7 @@ public:
* @param index block library index
* @return pointer to the current block index
*/
- const uint8 *getBlockLibrary(int32 index);
+ const uint8 *getBlockLibrary(int32 index) const;
/** Create grid map from current grid to block library buffer */
void createGridMap();
diff --git a/engines/twine/scene/movements.cpp b/engines/twine/scene/movements.cpp
index bbfeaf7e0e..9c0f55df18 100644
--- a/engines/twine/scene/movements.cpp
+++ b/engines/twine/scene/movements.cpp
@@ -215,11 +215,11 @@ void Movements::ChangedCursorKeys::update(TwinEEngine *engine) {
}
void Movements::update() {
- previousChangedCursorKeys = changedCursorKeys;
- previousLoopActionKey = heroActionKey;
+ _previousChangedCursorKeys = _changedCursorKeys;
+ _previousLoopActionKey = _heroActionKey;
- heroActionKey = _engine->_input->isHeroActionActive();
- changedCursorKeys.update(_engine);
+ _heroActionKey = _engine->_input->isHeroActionActive();
+ _changedCursorKeys.update(_engine);
}
bool Movements::processBehaviourExecution(int actorIdx) {
@@ -240,7 +240,7 @@ bool Movements::processBehaviourExecution(int actorIdx) {
heroMoved = true;
actor->angle = actor->move.getRealAngle(_engine->lbaTime);
// TODO: previousLoopActionKey must be handled properly
- if (!previousLoopActionKey || actor->anim == AnimationTypes::kStanding) {
+ if (!_previousLoopActionKey || actor->anim == AnimationTypes::kStanding) {
const int32 aggresiveMode = _engine->getRandomNumber(3);
switch (aggresiveMode) {
@@ -313,10 +313,10 @@ void Movements::processManualMovementExecution(int actorIdx) {
if (actor->isAttackWeaponAnimationActive()) {
return;
}
- if (!changedCursorKeys || heroAction) {
+ if (!_changedCursorKeys || heroAction) {
// if walking should get stopped
if (!_engine->_input->isActionActive(TwinEActionType::MoveForward) && !_engine->_input->isActionActive(TwinEActionType::MoveBackward)) {
- if (heroMoved && (heroActionKey != previousLoopActionKey || changedCursorKeys != previousChangedCursorKeys)) {
+ if (heroMoved && (_heroActionKey != _previousLoopActionKey || _changedCursorKeys != _previousChangedCursorKeys)) {
_engine->_animations->initAnim(AnimationTypes::kStanding, AnimType::kAnimationTypeLoop, AnimationTypes::kAnimInvalid, actorIdx);
}
}
diff --git a/engines/twine/scene/movements.h b/engines/twine/scene/movements.h
index 925410c478..8c10b58b07 100644
--- a/engines/twine/scene/movements.h
+++ b/engines/twine/scene/movements.h
@@ -60,11 +60,11 @@ private:
};
// enter, space, ...
- int16 heroActionKey = 0;
- int32 previousLoopActionKey = 0;
+ int16 _heroActionKey = 0;
+ int32 _previousLoopActionKey = 0;
// cursor keys
- ChangedCursorKeys changedCursorKeys;
- ChangedCursorKeys previousChangedCursorKeys;
+ ChangedCursorKeys _changedCursorKeys;
+ ChangedCursorKeys _previousChangedCursorKeys;
/**
* The Actor is controlled by the player. This works well only for the Hero Actor in general.
diff --git a/engines/twine/text.cpp b/engines/twine/text.cpp
index ac0917d183..9c5664c16e 100644
--- a/engines/twine/text.cpp
+++ b/engines/twine/text.cpp
@@ -50,12 +50,12 @@ namespace TwinE {
static const int32 PADDING = 8;
Text::Text(TwinEEngine *engine) : _engine(engine) {
- Common::fill(&currMenuTextBuffer[0], &currMenuTextBuffer[256], 0);
+ Common::fill(&_currMenuTextBuffer[0], &_currMenuTextBuffer[256], 0);
}
Text::~Text() {
- free(dialTextPtr);
- free(dialOrderPtr);
+ free(_dialTextPtr);
+ free(_dialOrderPtr);
}
void Text::initVoxBank(int32 bankIdx) {
@@ -95,9 +95,9 @@ bool Text::initVoxToPlay(int32 index) { // setVoxFileAtDigit
return false;
}
- Common::MemoryReadStream stream((const byte *)dialOrderPtr, dialOrderSize);
+ Common::MemoryReadStream stream((const byte *)_dialOrderPtr, _dialOrderSize);
// choose right text from order index
- for (int32 i = 0; i < numDialTextEntries; i++) {
+ for (int32 i = 0; i < _numDialTextEntries; i++) {
const int32 orderIdx = stream.readSint16LE();
if (orderIdx == index) {
currDialTextEntry = i;
@@ -140,26 +140,26 @@ bool Text::stopVox(int32 index) {
void Text::initTextBank(int32 bankIdx) {
// don't load if we already have the dialogue text bank loaded
- if (bankIdx == currentBankIdx) {
+ if (bankIdx == _currentBankIdx) {
return;
}
- currentBankIdx = bankIdx;
+ _currentBankIdx = bankIdx;
// get index according with language
const int32 size = _engine->isLBA1() ? 28 : 30;
// the text banks indices are split into index and dialogs - each entry thus consists of two entries in the hqr
// every 28 entries starts a new language
const int32 languageIndex = _engine->cfgfile.LanguageId * size + (int)bankIdx * 2;
- dialOrderSize = HQR::getAllocEntry((uint8 **)&dialOrderPtr, Resources::HQR_TEXT_FILE, languageIndex + INDEXOFFSET);
- if (dialOrderSize == 0) {
+ _dialOrderSize = HQR::getAllocEntry((uint8 **)&_dialOrderPtr, Resources::HQR_TEXT_FILE, languageIndex + INDEXOFFSET);
+ if (_dialOrderSize == 0) {
warning("Failed to initialize text bank %i from file %s", languageIndex, Resources::HQR_TEXT_FILE);
return;
}
- numDialTextEntries = dialOrderSize / 2;
+ _numDialTextEntries = _dialOrderSize / 2;
- if (HQR::getAllocEntry((uint8 **)&dialTextPtr, Resources::HQR_TEXT_FILE, languageIndex + DIALOGSOFFSET) == 0) {
+ if (HQR::getAllocEntry((uint8 **)&_dialTextPtr, Resources::HQR_TEXT_FILE, languageIndex + DIALOGSOFFSET) == 0) {
warning("Failed to initialize additional text bank %i from file %s", languageIndex + 1, Resources::HQR_TEXT_FILE);
return;
}
@@ -694,10 +694,10 @@ void Text::setTextCrossColor(int32 stopColor, int32 startColor, int32 stepSize)
}
bool Text::getText(int32 index) {
- const int16 *localTextBuf = (const int16 *)dialTextPtr;
- const int16 *localOrderBuf = (const int16 *)dialOrderPtr;
+ const int16 *localTextBuf = (const int16 *)_dialTextPtr;
+ const int16 *localOrderBuf = (const int16 *)_dialOrderPtr;
- const int32 numEntries = numDialTextEntries;
+ const int32 numEntries = _numDialTextEntries;
int32 currIdx = 0;
// choose right text from order index
do {
@@ -716,7 +716,7 @@ bool Text::getText(int32 index) {
const int32 ptrCurrentEntry = READ_LE_INT16(&localTextBuf[currIdx]);
const int32 ptrNextEntry = READ_LE_INT16(&localTextBuf[currIdx + 1]);
- _currDialTextPtr = dialTextPtr + ptrCurrentEntry;
+ _currDialTextPtr = _dialTextPtr + ptrCurrentEntry;
_currDialTextSize = ptrNextEntry - ptrCurrentEntry;
// RECHECK: this was added for vox playback
@@ -726,9 +726,9 @@ bool Text::getText(int32 index) {
}
bool Text::getMenuText(int32 index, char *text, uint32 textSize) {
- if (index == currMenuTextIndex) {
- if (currMenuTextBank == _engine->_scene->sceneTextBank) {
- Common::strlcpy(text, currMenuTextBuffer, textSize);
+ if (index == _currMenuTextIndex) {
+ if (_currMenuTextBank == _engine->_scene->sceneTextBank) {
+ Common::strlcpy(text, _currMenuTextBuffer, textSize);
return true;
}
}
@@ -744,10 +744,10 @@ bool Text::getMenuText(int32 index, char *text, uint32 textSize) {
Common::strlcpy(text, _currDialTextPtr, MIN<int32>(textSize, _currDialTextSize + 1));
_currDialTextSize++;
- Common::strlcpy(currMenuTextBuffer, text, MIN<int32>(sizeof(currMenuTextBuffer), _currDialTextSize));
+ Common::strlcpy(_currMenuTextBuffer, text, MIN<int32>(sizeof(_currMenuTextBuffer), _currDialTextSize));
- currMenuTextIndex = index;
- currMenuTextBank = _engine->_scene->sceneTextBank;
+ _currMenuTextIndex = index;
+ _currMenuTextBank = _engine->_scene->sceneTextBank;
return true;
}
diff --git a/engines/twine/text.h b/engines/twine/text.h
index 957c69d057..c7f6bcfe8e 100644
--- a/engines/twine/text.h
+++ b/engines/twine/text.h
@@ -170,15 +170,15 @@ private:
void fadeInCharacters(int32 counter, int32 fontColor);
// RECHECK THIS LATER
- int32 currentBankIdx = TextBankId::None; // textVar1
+ int32 _currentBankIdx = TextBankId::None; // textVar1
/** Dialogue text pointer */
- char *dialTextPtr = nullptr; // bufText
+ char *_dialTextPtr = nullptr; // bufText
/** Dialogue entry order pointer */
- int32 dialOrderSize = 0;
- char *dialOrderPtr = nullptr; // bufOrder
+ int32 _dialOrderSize = 0;
+ char *_dialOrderPtr = nullptr; // bufOrder
/** Number of dialogues text entries */
- int16 numDialTextEntries = 0;
+ int16 _numDialTextEntries = 0;
// TODO: refactor all this variables and related functions
char _progressiveTextBuffer[256] {'\0'};
@@ -204,9 +204,9 @@ private:
/** Current dialogue text size */
int32 _currDialTextSize = 0;
- char currMenuTextBuffer[256];
- int32 currMenuTextBank = TextBankId::None;
- int32 currMenuTextIndex = -1;
+ char _currMenuTextBuffer[256];
+ int32 _currMenuTextBank = TextBankId::None;
+ int32 _currMenuTextIndex = -1;
/** Pixel size between dialogue text */
int32 _dialSpaceBetween = 0;
diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 8ee81dfe5a..5ae1a45705 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -535,17 +535,17 @@ int TwinEEngine::getRandomNumber(uint max) {
}
void TwinEEngine::freezeTime() {
- if (!isTimeFreezed) {
- saveFreezedTime = lbaTime;
+ if (!_isTimeFreezed) {
+ _saveFreezedTime = lbaTime;
_pauseToken = pauseEngine();
}
- isTimeFreezed++;
+ _isTimeFreezed++;
}
void TwinEEngine::unfreezeTime() {
- --isTimeFreezed;
- if (isTimeFreezed == 0) {
- lbaTime = saveFreezedTime;
+ --_isTimeFreezed;
+ if (_isTimeFreezed == 0) {
+ lbaTime = _saveFreezedTime;
_pauseToken.clear();
}
}
@@ -835,12 +835,12 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
}
}
- loopActorStep = loopMovePtr.getRealValue(lbaTime);
+ loopActorStep = _loopMovePtr.getRealValue(lbaTime);
if (!loopActorStep) {
loopActorStep = 1;
}
- _movements->setActorAngle(ANGLE_0, -ANGLE_90, ANGLE_1, &loopMovePtr);
+ _movements->setActorAngle(ANGLE_0, -ANGLE_90, ANGLE_1, &_loopMovePtr);
disableScreenRecenter = false;
_scene->processEnvironmentSound();
@@ -1005,7 +1005,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
bool TwinEEngine::gameEngineLoop() {
_redraw->reqBgRedraw = true;
_screens->lockPalette = true;
- _movements->setActorAngle(ANGLE_0, -ANGLE_90, ANGLE_1, &loopMovePtr);
+ _movements->setActorAngle(ANGLE_0, -ANGLE_90, ANGLE_1, &_loopMovePtr);
while (quitGame == -1) {
uint32 start = g_system->getMillis();
diff --git a/engines/twine/twine.h b/engines/twine/twine.h
index 0c075f0a72..fbe9506aee 100644
--- a/engines/twine/twine.h
+++ b/engines/twine/twine.h
@@ -182,13 +182,14 @@ public:
class TwinEEngine : public Engine {
private:
- int32 isTimeFreezed = 0;
- int32 saveFreezedTime = 0;
+ int32 _isTimeFreezed = 0;
+ int32 _saveFreezedTime = 0;
int32 _mouseCursorState = 0;
- ActorMoveStruct loopMovePtr; // mainLoopVar1
+ ActorMoveStruct _loopMovePtr; // mainLoopVar1
PauseToken _pauseToken;
TwineGameType _gameType;
EngineState _state = EngineState::Menu;
+ Common::String _queuedFlaMovie;
void processBookOfBu();
void processBonusList();
@@ -202,9 +203,6 @@ private:
void processActorSamplePosition(int32 actorIdx);
/** Allocate video memory, both front and back buffers */
void allocVideoMemory(int32 w, int32 h);
-
- Common::String _queuedFlaMovie;
-
public:
TwinEEngine(OSystem *system, Common::Language language, uint32 flagsTwineGameType, TwineGameType gameType);
~TwinEEngine() override;
More information about the Scummvm-git-logs
mailing list