TWINE: renamed variables and initialize members

This commit is contained in:
Martin Gerhardy 2020-10-20 21:21:48 +02:00 committed by Eugene Sandulenko
parent 37bbfc168b
commit 77f29ada5f
9 changed files with 167 additions and 235 deletions

View File

@ -240,7 +240,7 @@ public:
HeroBehaviourType heroBehaviour = kNormal;
/** Hero auto agressive mode */
int16 autoAgressive = 0;
int16 autoAgressive = 1;
/** Previous Hero behaviour */
HeroBehaviourType previousHeroBehaviour = kNormal;
/** Previous Hero angle */

View File

@ -80,8 +80,8 @@ private:
public:
Menu(TwinEEngine *engine);
int32 currMenuTextIndex = 0;
int32 currMenuTextBank = 0;
int32 currMenuTextIndex = -1;
int32 currMenuTextBank = -1;
char currMenuTextBuffer[256] = "";
int16 itemAngle[255]{0}; // objectRotation

View File

@ -155,13 +155,10 @@ void Redraw::blitBackgroundAreas() {
}
void Redraw::sortDrawingList(DrawListStruct *list, int32 listSize) {
int32 i;
int32 j;
DrawListStruct tempStruct;
for (i = 0; i < listSize - 1; i++) {
for (j = 0; j < listSize - 1 - i; j++) {
for (int32 i = 0; i < listSize - 1; i++) {
for (int32 j = 0; j < listSize - 1 - i; j++) {
if (list[j + 1].posValue < list[j].posValue) {
memcpy(&tempStruct, &list[j + 1], sizeof(DrawListStruct));
memcpy(&list[j + 1], &list[j], sizeof(DrawListStruct));
@ -171,14 +168,14 @@ void Redraw::sortDrawingList(DrawListStruct *list, int32 listSize) {
}
}
void Redraw::addOverlay(int16 type, int16 info0, int16 X, int16 Y, int16 info1, int16 posType, int16 lifeTime) {
void Redraw::addOverlay(int16 type, int16 info0, int16 x, int16 y, int16 info1, int16 posType, int16 lifeTime) {
for (int32 i = 0; i < OVERLAY_MAX_ENTRIES; i++) {
OverlayListStruct *overlay = &overlayList[i];
if (overlay->info0 == -1) {
overlay->type = type;
overlay->info0 = info0;
overlay->X = X;
overlay->Y = Y;
overlay->x = x;
overlay->y = y;
overlay->info1 = info1;
overlay->posType = posType;
overlay->lifeTime = _engine->lbaTime + lifeTime * 50;
@ -194,8 +191,8 @@ void Redraw::updateOverlayTypePosition(int16 X1, int16 Y1, int16 X2, int16 Y2) {
for (int32 i = 0; i < OVERLAY_MAX_ENTRIES; i++) {
OverlayListStruct *overlay = &overlayList[i];
if (overlay->type == koFollowActor) {
overlay->X = newX;
overlay->Y = newY;
overlay->x = newX;
overlay->y = newY;
}
}
}
@ -203,12 +200,6 @@ void Redraw::updateOverlayTypePosition(int16 X1, int16 Y1, int16 X2, int16 Y2) {
void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
int16 tmp_projPosX;
int16 tmp_projPosY;
int32 i;
int32 tmpVal;
int32 modelActorPos; // arg_1A
int32 spriteActorPos; // top6
int32 shadowActorPos; // top2
int32 drawListPos; // a12
ActorStruct *actor;
tmp_projPosX = _engine->_renderer->projPosXScreen;
@ -235,10 +226,10 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
// first loop
modelActorPos = 0;
drawListPos = 0;
spriteActorPos = 0x1000;
shadowActorPos = 0x0C00;
int32 modelActorPos = 0;
int32 drawListPos = 0;
int32 spriteActorPos = 0x1000;
int32 shadowActorPos = 0x0C00;
// Process actors drawing list
for (modelActorPos = 0; modelActorPos < _engine->_scene->sceneNumActors; modelActorPos++, spriteActorPos++, shadowActorPos++) {
@ -264,7 +255,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
if ((actor->staticFlags.bUsesClipping && _engine->_renderer->projPosX > -112 && _engine->_renderer->projPosX < 752 && _engine->_renderer->projPosY > -50 && _engine->_renderer->projPosY < 651) ||
((!actor->staticFlags.bUsesClipping) && _engine->_renderer->projPosX > -50 && _engine->_renderer->projPosX < 680 && _engine->_renderer->projPosY > -30 && _engine->_renderer->projPosY < 580)) {
tmpVal = actor->z + actor->x - _engine->_grid->cameraX - _engine->_grid->cameraZ;
int32 tmpVal = actor->z + actor->x - _engine->_grid->cameraX - _engine->_grid->cameraZ;
// if actor is above another actor
if (actor->standOn != -1) {
@ -297,9 +288,9 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
tmpVal--;
drawList[drawListPos].posValue = tmpVal; // save the shadow entry in the drawList
drawList[drawListPos].index = 0xC00; // shadowActorPos
drawList[drawListPos].X = _engine->_actor->shadowX;
drawList[drawListPos].Y = _engine->_actor->shadowY;
drawList[drawListPos].Z = _engine->_actor->shadowZ;
drawList[drawListPos].x = _engine->_actor->shadowX;
drawList[drawListPos].y = _engine->_actor->shadowY;
drawList[drawListPos].z = _engine->_actor->shadowZ;
drawList[drawListPos].field_A = 2;
drawListPos++;
}
@ -310,7 +301,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
}
// second loop
for (i = 0; i < EXTRA_MAX_ENTRIES; i++) {
for (int32 i = 0; i < EXTRA_MAX_ENTRIES; i++) {
ExtraListStruct *extra = &_engine->_extra->extraList[i];
if (extra->info0 != -1) {
if (extra->type & 0x400) {
@ -334,9 +325,9 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
drawList[drawListPos].posValue = extra->x - _engine->_grid->cameraX + extra->z - _engine->_grid->cameraZ - 1;
drawList[drawListPos].index = 0xC00;
drawList[drawListPos].X = _engine->_actor->shadowX;
drawList[drawListPos].Y = _engine->_actor->shadowY;
drawList[drawListPos].Z = _engine->_actor->shadowZ;
drawList[drawListPos].x = _engine->_actor->shadowX;
drawList[drawListPos].y = _engine->_actor->shadowY;
drawList[drawListPos].z = _engine->_actor->shadowZ;
drawList[drawListPos].field_A = 0;
drawListPos++;
}
@ -414,7 +405,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
DrawListStruct shadow = drawList[pos];
// get actor position on screen
_engine->_renderer->projectPositionOnScreen(shadow.X - _engine->_grid->cameraX, shadow.Y - _engine->_grid->cameraY, shadow.Z - _engine->_grid->cameraZ);
_engine->_renderer->projectPositionOnScreen(shadow.x - _engine->_grid->cameraX, shadow.y - _engine->_grid->cameraY, shadow.z - _engine->_grid->cameraZ);
_engine->_grid->getSpriteSize(shadow.field_A, &spriteWidth, &spriteHeight, _engine->_scene->spriteShadowPtr);
@ -430,9 +421,9 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
_engine->_grid->drawSprite(shadow.field_A, renderLeft, renderTop, _engine->_scene->spriteShadowPtr);
}
tmpX = (shadow.X + 0x100) >> 9;
tmpY = shadow.Y >> 8;
tmpZ = (shadow.Z + 0x100) >> 9;
tmpX = (shadow.x + 0x100) >> 9;
tmpY = shadow.y >> 8;
tmpZ = (shadow.z + 0x100) >> 9;
_engine->_grid->drawOverModelActor(tmpX, tmpY, tmpZ);
@ -524,9 +515,9 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
if (_engine->_interface->textWindowLeft <= _engine->_interface->textWindowRight && _engine->_interface->textWindowTop <= _engine->_interface->textWindowBottom) {
int32 tmpX, tmpY, tmpZ;
tmpX = (drawList[pos].X + 0x100) >> 9;
tmpY = drawList[pos].Y >> 8;
tmpZ = (drawList[pos].Z + 0x100) >> 9;
tmpX = (drawList[pos].x + 0x100) >> 9;
tmpY = drawList[pos].y >> 8;
tmpZ = (drawList[pos].z + 0x100) >> 9;
_engine->_grid->drawOverModelActor(tmpX, tmpY, tmpZ);
addRedrawArea(_engine->_interface->textWindowLeft, _engine->_interface->textWindowTop, renderRight, renderBottom);
@ -545,7 +536,7 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
_engine->_debugScene->displayZones(_engine->_keyboard.skipIntro);
}
for (i = 0; i < OVERLAY_MAX_ENTRIES; i++) {
for (int32 i = 0; i < OVERLAY_MAX_ENTRIES; i++) {
OverlayListStruct *overlay = &overlayList[i];
if (overlay->info0 != -1) {
// process position overlay
@ -561,8 +552,8 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
_engine->_renderer->projectPositionOnScreen(actor2->x - _engine->_grid->cameraX, actor2->y + actor2->boudingBox.y.topRight - _engine->_grid->cameraY, actor2->z - _engine->_grid->cameraZ);
overlay->X = _engine->_renderer->projPosX;
overlay->Y = _engine->_renderer->projPosY;
overlay->x = _engine->_renderer->projPosX;
overlay->y = _engine->_renderer->projPosY;
if (_engine->lbaTime >= overlay->lifeTime) {
overlay->info0 = -1;
@ -583,8 +574,8 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
offsetX = *((int16 *)(_engine->_scene->spriteBoundingBoxPtr + (overlay->info0 * 16)));
offsetY = *((int16 *)(_engine->_scene->spriteBoundingBoxPtr + (overlay->info0 * 16) + 2));
renderLeft = offsetX + overlay->X;
renderTop = offsetY + overlay->Y;
renderLeft = offsetX + overlay->x;
renderTop = offsetY + overlay->y;
renderRight = renderLeft + spriteWidth;
renderBottom = renderTop + spriteHeight;
@ -598,15 +589,15 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
case koNumber: {
int32 textLength, textHeight;
char text[10];
sprintf(text, "%d", overlay->info0);
snprintf(text, sizeof(text), "%d", overlay->info0);
textLength = _engine->_text->getTextSize(text);
textHeight = 48;
renderLeft = overlay->X - (textLength / 2);
renderTop = overlay->Y - 24;
renderRight = overlay->X + (textLength / 2);
renderBottom = overlay->Y + textHeight;
renderLeft = overlay->x - (textLength / 2);
renderTop = overlay->y - 24;
renderRight = overlay->x + (textLength / 2);
renderBottom = overlay->y + textHeight;
_engine->_interface->setClip(renderLeft, renderTop, renderRight, renderBottom);
@ -629,10 +620,10 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
textLength = _engine->_text->getTextSize(text);
textHeight = 48;
renderLeft = overlay->X - (textLength / 2);
renderTop = overlay->Y - 24;
renderRight = overlay->X + (textLength / 2);
renderBottom = overlay->Y + textHeight;
renderLeft = overlay->x - (textLength / 2);
renderTop = overlay->y - 24;
renderRight = overlay->x + (textLength / 2);
renderBottom = overlay->y + textHeight;
_engine->_interface->setClip(renderLeft, renderTop, renderRight, renderBottom);
@ -669,10 +660,10 @@ void Redraw::redrawEngineActions(int32 bgRedraw) { // fullRedraw
int32 textLength = _engine->_text->getTextSize(text);
int32 textHeight = 48;
renderLeft = overlay->X - (textLength / 2);
renderTop = overlay->Y - 24;
renderRight = overlay->X + (textLength / 2);
renderBottom = overlay->Y + textHeight;
renderLeft = overlay->x - (textLength / 2);
renderTop = overlay->y - 24;
renderRight = overlay->x + (textLength / 2);
renderBottom = overlay->y + textHeight;
if (renderLeft < 0) {
renderLeft = 0;

View File

@ -46,8 +46,8 @@ enum OverlayPosType {
typedef struct OverlayListStruct {
int16 type = 0;
int16 info0 = 0; // sprite/3d model entry | number | number range
int16 X = 0;
int16 Y = 0;
int16 x = 0;
int16 y = 0;
int16 info1 = 0; // followed actor | total coins
int16 posType = 0;
int16 lifeTime = 0;
@ -60,9 +60,9 @@ private:
typedef struct DrawListStruct {
int16 posValue = 0;
uint16 index = 0; // field_2
uint16 X = 0;
uint16 Y = 0;
uint16 Z = 0;
uint16 x = 0;
uint16 y = 0;
uint16 z = 0;
uint16 field_A = 0;
uint16 field_C = 0;
uint16 field_E = 0;
@ -124,7 +124,7 @@ public:
int32 numOfRedrawBox = 0;
/** Save last actor that bubble dialog icon */
int32 bubbleActor = 0;
int32 bubbleActor = -1;
int32 bubbleSpriteIndex = 0;
OverlayListStruct overlayList[OVERLAY_MAX_ENTRIES];

View File

@ -20,13 +20,13 @@
*
*/
#include "twine/renderer.h"
#include "common/textconsole.h"
#include "common/util.h"
#include "twine/interface.h"
#include "twine/menu.h"
#include "twine/movements.h"
#include "twine/redraw.h"
#include "twine/renderer.h"
#include "twine/shadeangletab.h"
#include "twine/twine.h"
@ -64,24 +64,23 @@ int32 Renderer::projectPositionOnScreen(int32 cX, int32 cY, int32 cZ) {
projPosY = (-cY * cameraPosZ) / posZ + orthoProjY;
projPosZ = posZ;
return -1;
} else {
projPosX = 0;
projPosY = 0;
projPosZ = 0;
return 0;
}
} else {
projPosX = ((cX - cZ) * 24) / 512 + orthoProjX;
projPosY = (((cX + cZ) * 12) - cY * 30) / 512 + orthoProjY;
projPosZ = cZ - cY - cX;
projPosX = 0;
projPosY = 0;
projPosZ = 0;
return 0;
}
projPosX = ((cX - cZ) * 24) / 512 + orthoProjX;
projPosY = (((cX + cZ) * 12) - cY * 30) / 512 + orthoProjY;
projPosZ = cZ - cY - cX;
return 1;
}
void Renderer::setCameraPosition(int32 X, int32 Y, int32 cX, int32 cY, int32 cZ) {
orthoProjX = X;
orthoProjY = Y;
void Renderer::setCameraPosition(int32 x, int32 y, int32 cX, int32 cY, int32 cZ) {
orthoProjX = x;
orthoProjY = y;
cameraPosX = cX;
cameraPosY = cY;
@ -90,10 +89,10 @@ void Renderer::setCameraPosition(int32 X, int32 Y, int32 cX, int32 cY, int32 cZ)
isUsingOrhoProjection = 0;
}
void Renderer::setBaseTranslation(int32 X, int32 Y, int32 Z) {
baseTransPosX = X;
baseTransPosY = Y;
baseTransPosZ = Z;
void Renderer::setBaseTranslation(int32 x, int32 y, int32 z) {
baseTransPosX = x;
baseTransPosY = y;
baseTransPosZ = z;
}
void Renderer::setOrthoProjection(int32 X, int32 Y, int32 Z) {
@ -104,25 +103,22 @@ void Renderer::setOrthoProjection(int32 X, int32 Y, int32 Z) {
isUsingOrhoProjection = 1;
}
void Renderer::getBaseRotationPosition(int32 X, int32 Y, int32 Z) {
destX = (baseMatrix[0] * X + baseMatrix[1] * Y + baseMatrix[2] * Z) >> 14;
destY = (baseMatrix[3] * X + baseMatrix[4] * Y + baseMatrix[5] * Z) >> 14;
destZ = (baseMatrix[6] * X + baseMatrix[7] * Y + baseMatrix[8] * Z) >> 14;
void Renderer::getBaseRotationPosition(int32 x, int32 y, int32 z) {
destX = (baseMatrix[0] * x + baseMatrix[1] * y + baseMatrix[2] * z) >> 14;
destY = (baseMatrix[3] * x + baseMatrix[4] * y + baseMatrix[5] * z) >> 14;
destZ = (baseMatrix[6] * x + baseMatrix[7] * y + baseMatrix[8] * z) >> 14;
}
void Renderer::setBaseRotation(int32 X, int32 Y, int32 Z) {
int32 matrixElem;
double Xradians, Yradians, Zradians;
void Renderer::setBaseRotation(int32 x, int32 y, int32 z) {
shadeAngleTab3 = &shadeAngleTable[384];
baseMatrixRotationX = X & 0x3FF;
baseMatrixRotationY = Y & 0x3FF;
baseMatrixRotationZ = Z & 0x3FF;
baseMatrixRotationX = x & 0x3FF;
baseMatrixRotationY = y & 0x3FF;
baseMatrixRotationZ = z & 0x3FF;
Xradians = (double)((256 - X) % 1024) * 2 * M_PI / 1024;
Yradians = (double)((256 - Y) % 1024) * 2 * M_PI / 1024;
Zradians = (double)((256 - Z) % 1024) * 2 * M_PI / 1024;
double Xradians = (double)((256 - x) % 1024) * 2 * M_PI / 1024;
double Yradians = (double)((256 - y) % 1024) * 2 * M_PI / 1024;
double Zradians = (double)((256 - z) % 1024) * 2 * M_PI / 1024;
baseMatrix[0] = (int32)(sin(Zradians) * sin(Yradians) * 16384);
baseMatrix[1] = (int32)(-cos(Zradians) * 16384);
@ -132,7 +128,7 @@ void Renderer::setBaseRotation(int32 X, int32 Y, int32 Z) {
baseMatrix[6] = (int32)(cos(Zradians) * cos(Xradians) * 16384);
baseMatrix[7] = (int32)(sin(Zradians) * cos(Xradians) * 16384);
matrixElem = baseMatrix[3];
int32 matrixElem = baseMatrix[3];
baseMatrix[3] = (int32)(sin(Yradians) * matrixElem + 16384 * cos(Yradians) * cos(Xradians));
baseMatrix[5] = (int32)(cos(Yradians) * matrixElem - 16384 * sin(Yradians) * cos(Xradians));
@ -149,10 +145,10 @@ void Renderer::setBaseRotation(int32 X, int32 Y, int32 Z) {
baseRotPosZ = destZ;
}
void Renderer::getCameraAnglePositions(int32 X, int32 Y, int32 Z) {
destX = (baseMatrix[0] * X + baseMatrix[3] * Y + baseMatrix[6] * Z) >> 14;
destY = (baseMatrix[1] * X + baseMatrix[4] * Y + baseMatrix[7] * Z) >> 14;
destZ = (baseMatrix[2] * X + baseMatrix[5] * Y + baseMatrix[8] * Z) >> 14;
void Renderer::getCameraAnglePositions(int32 x, int32 y, int32 z) {
destX = (baseMatrix[0] * x + baseMatrix[3] * y + baseMatrix[6] * z) >> 14;
destY = (baseMatrix[1] * x + baseMatrix[4] * y + baseMatrix[7] * z) >> 14;
destZ = (baseMatrix[2] * x + baseMatrix[5] * y + baseMatrix[8] * z) >> 14;
}
void Renderer::setCameraAngle(int32 transPosX, int32 transPosY, int32 transPosZ, int32 rotPosX, int32 rotPosY, int32 rotPosZ, int32 param6) {
@ -172,19 +168,14 @@ void Renderer::setCameraAngle(int32 transPosX, int32 transPosY, int32 transPosZ,
}
void Renderer::applyRotation(int32 *tempMatrix, int32 *currentMatrix) {
int32 i;
int32 angle;
int32 angleVar1; // esi
int32 angleVar2; // ecx
int32 matrix1[9];
int32 matrix2[9];
if (renderAngleX) {
angle = renderAngleX;
angleVar2 = shadeAngleTable[angle & 0x3FF];
int32 angle = renderAngleX;
int32 angleVar2 = shadeAngleTable[angle & 0x3FF];
angle += 0x100;
angleVar1 = shadeAngleTable[angle & 0x3FF];
int32 angleVar1 = shadeAngleTable[angle & 0x3FF];
matrix1[0] = currentMatrix[0];
matrix1[3] = currentMatrix[3];
@ -197,15 +188,15 @@ void Renderer::applyRotation(int32 *tempMatrix, int32 *currentMatrix) {
matrix1[7] = (currentMatrix[8] * angleVar2 + currentMatrix[7] * angleVar1) >> 14;
matrix1[8] = (currentMatrix[8] * angleVar1 - currentMatrix[7] * angleVar2) >> 14;
} else {
for (i = 0; i < 9; i++)
for (int32 i = 0; i < 9; i++)
matrix1[i] = currentMatrix[i];
}
if (renderAngleZ) {
angle = renderAngleZ;
angleVar2 = shadeAngleTable[angle & 0x3FF];
int32 angle = renderAngleZ;
int32 angleVar2 = shadeAngleTable[angle & 0x3FF];
angle += 0x100;
angleVar1 = shadeAngleTable[angle & 0x3FF];
int32 angleVar1 = shadeAngleTable[angle & 0x3FF];
matrix2[2] = matrix1[2];
matrix2[5] = matrix1[5];
@ -218,15 +209,15 @@ void Renderer::applyRotation(int32 *tempMatrix, int32 *currentMatrix) {
matrix2[6] = (matrix1[7] * angleVar2 + matrix1[6] * angleVar1) >> 14;
matrix2[7] = (matrix1[7] * angleVar1 - matrix1[6] * angleVar2) >> 14;
} else {
for (i = 0; i < 9; i++)
for (int32 i = 0; i < 9; i++)
matrix2[i] = matrix1[i];
}
if (renderAngleY) {
angle = renderAngleY;
angleVar2 = shadeAngleTable[angle & 0x3FF]; // esi
int32 angle = renderAngleY;
int32 angleVar2 = shadeAngleTable[angle & 0x3FF]; // esi
angle += 0x100;
angleVar1 = shadeAngleTable[angle & 0x3FF]; // ecx
int32 angleVar1 = shadeAngleTable[angle & 0x3FF]; // ecx
tempMatrix[1] = matrix2[1];
tempMatrix[4] = matrix2[4];
@ -240,28 +231,21 @@ void Renderer::applyRotation(int32 *tempMatrix, int32 *currentMatrix) {
tempMatrix[6] = (matrix2[6] * angleVar1 - matrix2[8] * angleVar2) >> 14;
tempMatrix[8] = (matrix2[6] * angleVar2 + matrix2[8] * angleVar1) >> 14;
} else {
for (i = 0; i < 9; i++)
for (int32 i = 0; i < 9; i++)
tempMatrix[i] = matrix2[i];
}
}
void Renderer::applyPointsRotation(uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, int32 *rotationMatrix) {
int16 tmpX;
int16 tmpY;
int16 tmpZ;
int16 *tempPtr;
int32 numOfPoints2 = numPoints;
uint8 *pointsPtr2;
do {
pointsPtr2 = firstPointsPtr;
tempPtr = (int16 *)(firstPointsPtr);
uint8 *pointsPtr2 = firstPointsPtr;
const int16 *tempPtr = (int16 *)(firstPointsPtr);
tmpX = tempPtr[0];
tmpY = tempPtr[1];
tmpZ = tempPtr[2];
const int16 tmpX = tempPtr[0];
const int16 tmpY = tempPtr[1];
const int16 tmpZ = tempPtr[2];
destPoints->X = ((rotationMatrix[0] * tmpX + rotationMatrix[1] * tmpY + rotationMatrix[2] * tmpZ) >> 14) + destX;
destPoints->Y = ((rotationMatrix[3] * tmpX + rotationMatrix[4] * tmpY + rotationMatrix[5] * tmpZ) >> 14) + destY;
@ -273,9 +257,6 @@ void Renderer::applyPointsRotation(uint8 *firstPointsPtr, int32 numPoints, point
}
void Renderer::processRotatedElement(int32 rotZ, int32 rotY, int32 rotX, elementEntry *elemPtr) { // unsigned char * elemPtr) // loadPart
int32 *currentMatrix;
int16 baseElement;
int32 firstPoint = elemPtr->firstPoint;
int32 numOfPoints2 = elemPtr->numOfPoints;
@ -288,8 +269,9 @@ void Renderer::processRotatedElement(int32 rotZ, int32 rotY, int32 rotX, element
}
//baseElement = *((unsigned short int*)elemPtr+6);
baseElement = elemPtr->baseElement;
const int16 baseElement = elemPtr->baseElement;
int32 *currentMatrix;
// if its the first point
if (baseElement == -1) {
currentMatrix = baseMatrix;
@ -316,22 +298,15 @@ void Renderer::processRotatedElement(int32 rotZ, int32 rotY, int32 rotX, element
}
void Renderer::applyPointsTranslation(uint8 *firstPointsPtr, int32 numPoints, pointTab *destPoints, int32 *translationMatrix) {
int16 tmpX;
int16 tmpY;
int16 tmpZ;
int16 *tempPtr;
int32 numOfPoints2 = numPoints;
uint8 *pointsPtr2;
do {
pointsPtr2 = firstPointsPtr;
tempPtr = (int16 *)(firstPointsPtr);
uint8 *pointsPtr2 = firstPointsPtr;
int16 *tempPtr = (int16 *)(firstPointsPtr);
tmpX = tempPtr[0] + renderAngleZ;
tmpY = tempPtr[1] + renderAngleY;
tmpZ = tempPtr[2] + renderAngleX;
const int16 tmpX = tempPtr[0] + renderAngleZ;
const int16 tmpY = tempPtr[1] + renderAngleY;
const int16 tmpZ = tempPtr[2] + renderAngleX;
destPoints->X = ((translationMatrix[0] * tmpX + translationMatrix[1] * tmpY + translationMatrix[2] * tmpZ) >> 14) + destX;
destPoints->Y = ((translationMatrix[3] * tmpX + translationMatrix[4] * tmpY + translationMatrix[5] * tmpZ) >> 14) + destY;
@ -343,35 +318,28 @@ void Renderer::applyPointsTranslation(uint8 *firstPointsPtr, int32 numPoints, po
}
void Renderer::processTranslatedElement(int32 rotX, int32 rotY, int32 rotZ, elementEntry *elemPtr) {
int32 *dest;
int32 *source;
renderAngleX = rotX;
renderAngleY = rotY;
renderAngleZ = rotZ;
if (elemPtr->baseElement == -1) { // base point
int32 i;
destX = 0;
destY = 0;
destZ = 0;
dest = (int32 *)currentMatrixTableEntry;
int32 *dest = (int32 *)currentMatrixTableEntry;
for (i = 0; i < 9; i++)
for (int32 i = 0; i < 9; i++)
dest[i] = baseMatrix[i];
} else { // dependent
int32 i;
destX = computedPoints[(elemPtr->basePoint) / 6].X;
destY = computedPoints[(elemPtr->basePoint) / 6].Y;
destZ = computedPoints[(elemPtr->basePoint) / 6].Z;
source = (int32 *)((uint8 *)matricesTable + elemPtr->baseElement);
dest = (int32 *)currentMatrixTableEntry;
const int32 *source = (const int32 *)((const uint8 *)matricesTable + elemPtr->baseElement);
int32 *dest = (int32 *)currentMatrixTableEntry;
for (i = 0; i < 9; i++)
for (int32 i = 0; i < 9; i++)
dest[i] = source[i];
}
@ -379,18 +347,12 @@ void Renderer::processTranslatedElement(int32 rotX, int32 rotY, int32 rotZ, elem
}
void Renderer::translateGroup(int16 ax, int16 bx, int16 cx) {
int32 ebp;
int32 ebx;
int32 ecx;
int32 eax;
int32 edi;
int32 ebp = ax;
int32 ebx = bx;
int32 ecx = cx;
ebp = ax;
ebx = bx;
ecx = cx;
edi = shadeMatrix[0];
eax = shadeMatrix[1];
int32 edi = shadeMatrix[0];
int32 eax = shadeMatrix[1];
edi *= ebp;
eax *= ebx;
edi += eax;
@ -439,21 +401,15 @@ void Renderer::setLightVector(int32 angleX, int32 angleY, int32 angleZ) {
lightZ = destZ;
}
// TODO: remove me - use scummvm function
FORCEINLINE int16 clamp(int16 x, int16 a, int16 b) {
return x < a ? a : (x > b ? b : x);
}
int Renderer::computePolygons() {
int16 vertexX, vertexY;
int16 *outPtr;
int32 i, nVertex;
int8 direction, up;
int16 oldVertexX, oldVertexY;
int16 currentVertexX, currentVertexY;
int16 vsize, hsize, ypos;
int16 cvalue, cdelta;
int64 slope, xpos;
int64 slope;
vertexData *vertices;
pRenderV1 = vertexCoordinates;
@ -466,7 +422,7 @@ int Renderer::computePolygons() {
for (i = 0; i < numOfVertex; i++) {
vertices[i].x = clamp(vertices[i].x, 0, SCREEN_WIDTH - 1);
vertexX = vertices[i].x;
int16 vertexX = vertices[i].x;
if (vertexX < vleft)
vleft = vertexX;
@ -474,7 +430,7 @@ int Renderer::computePolygons() {
vright = vertexX;
vertices[i].y = clamp(vertices[i].y, 0, SCREEN_HEIGHT - 1);
vertexY = vertices[i].y;
int16 vertexY = vertices[i].y;
if (vertexY < vtop)
vtop = vertexY;
if (vertexY > vbottom)
@ -482,12 +438,12 @@ int Renderer::computePolygons() {
}
vertexParam1 = vertexParam2 = vertices[numOfVertex - 1].param;
currentVertexX = vertices[numOfVertex - 1].x;
currentVertexY = vertices[numOfVertex - 1].y;
int16 currentVertexX = vertices[numOfVertex - 1].x;
int16 currentVertexY = vertices[numOfVertex - 1].y;
for (nVertex = 0; nVertex < numOfVertex; nVertex++) {
oldVertexY = currentVertexY;
oldVertexX = currentVertexX;
int16 oldVertexY = currentVertexY;
int16 oldVertexX = currentVertexX;
oldVertexParam = vertexParam1;
vertexParam1 = vertexParam2 = vertices[nVertex].param;
@ -502,9 +458,13 @@ int Renderer::computePolygons() {
up = currentVertexY < oldVertexY;
direction = up ? -1 : 1;
vsize = ABS(currentVertexY - oldVertexY);
hsize = ABS(currentVertexX - oldVertexX);
int16 vsize = ABS(currentVertexY - oldVertexY);
int16 hsize = ABS(currentVertexX - oldVertexX);
int16 cvalue;
int16 cdelta;
int16 ypos;
int16 xpos;
if (direction * oldVertexX > direction * currentVertexX) { // if we are going up right
xpos = currentVertexX;
ypos = currentVertexY;
@ -525,7 +485,7 @@ int Renderer::computePolygons() {
for (i = 0; i < vsize + 2; i++) {
if ((outPtr - polyTab) < 960)
if ((outPtr - polyTab) > 0)
*(outPtr) = (int16)xpos;
*(outPtr) = xpos;
outPtr += direction;
xpos += slope;
}
@ -1659,11 +1619,10 @@ void Renderer::prepareIsoModel(uint8 *bodyPtr) { // loadGfxSub
// 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->bodyFlag & 0x80)) {
bodyHeader->bodyFlag |= 0x80;
} else {
if ((bodyHeader->bodyFlag & 0x80)) {
return;
}
bodyHeader->bodyFlag |= 0x80;
if (!(bodyHeader->bodyFlag & 2)) { // no animation applicable
return;
@ -1732,10 +1691,6 @@ int Renderer::renderIsoModel(int32 X, int32 Y, int32 Z, int32 angleX, int32 angl
}
void Renderer::copyActorInternAnim(uint8 *bodyPtrSrc, uint8 *bodyPtrDest) {
int16 cx;
int16 ax;
int32 i;
// check if both characters allow animation
if (!(*((int16 *)bodyPtrSrc) & 2))
return;
@ -1752,11 +1707,11 @@ void Renderer::copyActorInternAnim(uint8 *bodyPtrSrc, uint8 *bodyPtrDest) {
bodyPtrSrc = bodyPtrSrc + *((int16 *)(bodyPtrSrc - 2));
bodyPtrSrc = bodyPtrSrc + (*((int16 *)bodyPtrSrc)) * 6 + 2;
cx = *((int16 *)bodyPtrSrc);
int16 cx = *((int16 *)bodyPtrSrc);
bodyPtrDest = bodyPtrDest + *((int16 *)(bodyPtrDest - 2));
bodyPtrDest = bodyPtrDest + (*((int16 *)bodyPtrDest)) * 6 + 2;
ax = *((int16 *)bodyPtrDest);
int16 ax = *((int16 *)bodyPtrDest);
if (cx > ax)
cx = ax;
@ -1764,7 +1719,7 @@ void Renderer::copyActorInternAnim(uint8 *bodyPtrSrc, uint8 *bodyPtrDest) {
bodyPtrSrc += 10;
bodyPtrDest += 10;
for (i = 0; i < cx; i++) {
for (int32 i = 0; i < cx; i++) {
*((uint32 *)bodyPtrDest) = *((uint32 *)bodyPtrSrc);
*((uint32 *)(bodyPtrDest + 4)) = *((uint32 *)(bodyPtrSrc + 4));

View File

@ -55,7 +55,7 @@ private:
int32 numOfShades = 0; // field_10
int32 field_14 = 0;
int32 field_18 = 0;
int32 Y = 0;
int32 y = 0;
int32 field_20 = 0;
int16 field_24 = 0;
} elementEntry;

View File

@ -104,7 +104,7 @@ public:
Text(TwinEEngine *engine) : _engine(engine) {}
/** Current text bank */
int32 currentTextBank = 0;
int32 currentTextBank = -1;
/** Current dialogue text size */
int32 currDialTextSize = 0;
/** Current dialogue text pointer */
@ -151,7 +151,7 @@ public:
int32 nextDialTextEntry = 0; // ordered entry
Common::String currentVoxBankFile;
int32 showDialogueBubble = 0;
int32 showDialogueBubble = 1;
/**
* Initialize dialogue

View File

@ -278,26 +278,14 @@ void TwinEEngine::initAll() {
memset(_menu->itemAngle, 256, sizeof(_menu->itemAngle)); // reset inventory items angles
_redraw->bubbleSpriteIndex = SPRITEHQR_DIAG_BUBBLE_LEFT;
_redraw->bubbleActor = -1;
_text->showDialogueBubble = 1;
_text->currentTextBank = -1;
_menu->currMenuTextIndex = -1;
_menu->currMenuTextBank = -1;
_actor->autoAgressive = 1;
_scene->sceneHero = &_scene->sceneActors[0];
_redraw->renderLeft = 0;
_redraw->renderTop = 0;
_redraw->renderRight = SCREEN_TEXTLIMIT_RIGHT;
_redraw->renderBottom = SCREEN_TEXTLIMIT_BOTTOM;
// Set clip to fullscreen by default, allows main menu to render properly after load
_interface->resetClip();
rightMouse = 0;
leftMouse = 0;
_resources->initResources();
initSVGA();
@ -308,21 +296,22 @@ int TwinEEngine::getRandomNumber(uint max) {
}
void TwinEEngine::freezeTime() {
if (!isTimeFreezed)
if (!isTimeFreezed) {
saveFreezedTime = lbaTime;
}
isTimeFreezed++;
}
void TwinEEngine::unfreezeTime() {
--isTimeFreezed;
if (isTimeFreezed == 0)
if (isTimeFreezed == 0) {
lbaTime = saveFreezedTime;
}
}
void TwinEEngine::processActorSamplePosition(int32 actorIdx) {
int32 channelIdx;
ActorStruct *actor = &_scene->sceneActors[actorIdx];
channelIdx = _sound->getActorChannel(actorIdx);
const ActorStruct *actor = &_scene->sceneActors[actorIdx];
const int32 channelIdx = _sound->getActorChannel(actorIdx);
_sound->setSamplePosition(channelIdx, actor->x, actor->y, actor->z);
}

View File

@ -60,13 +60,12 @@ static const struct TwinELanguage {
const char *name;
const char *id;
} LanguageTypes[] = {
{"English", "EN_"},
{"Francais", "FR_"},
{"Deutsch", "DE_"},
{"Espanol", "SP_"},
{"Italiano", "IT_"},
{"Portugues", ""}
};
{"English", "EN_"},
{"Francais", "FR_"},
{"Deutsch", "DE_"},
{"Espanol", "SP_"},
{"Italiano", "IT_"},
{"Portugues", ""}};
/** Configuration file structure
@ -153,6 +152,7 @@ class TwinEEngine : public Engine {
private:
int32 isTimeFreezed = 0;
int32 saveFreezedTime = 0;
ActorMoveStruct loopMovePtr; // mainLoopVar1
public:
TwinEEngine(OSystem *system, Common::Language language, uint32 flags);
@ -194,7 +194,7 @@ public:
ConfigFile cfgfile;
/** CD Game directory */
const char *cdDir;
const char *cdDir = "";
/** Initialize LBA engine */
void initEngine();
@ -211,11 +211,11 @@ public:
/** Allocate video memory, both front and back buffers */
void allocVideoMemory();
int getRandomNumber(uint max = 0x7FFF);
int32 quitGame;
int32 lbaTime;
int32 quitGame = 0;
int32 lbaTime = 0;
int16 leftMouse;
int16 rightMouse;
int16 leftMouse = 0;
int16 rightMouse = 0;
/** Work video buffer */
uint8 *workVideoBuffer = nullptr;
@ -223,21 +223,18 @@ public:
uint8 *frontVideoBuffer = nullptr;
/** temporary screen table */
int32 screenLookupTable[2000];
int32 screenLookupTable[2000]{0};
ActorMoveStruct loopMovePtr; // mainLoopVar1
int32 loopPressedKey; // mainLoopVar5
int32 previousLoopPressedKey; // mainLoopVar6
int32 loopCurrentKey; // mainLoopVar7
int32 loopInventoryItem; // mainLoopVar9
int32 loopActorStep; // mainLoopVar17
int32 loopPressedKey = 0; // mainLoopVar5
int32 previousLoopPressedKey = 0; // mainLoopVar6
int32 loopCurrentKey = 0; // mainLoopVar7
int32 loopInventoryItem = 0; // mainLoopVar9
int32 loopActorStep = 0; // mainLoopVar17
/** Disable screen recenter */
int16 disableScreenRecenter;
int16 disableScreenRecenter = 0;
int32 zoomScreen;
int32 zoomScreen = 0;
void freezeTime();
void unfreezeTime();