diff options
Diffstat (limited to 'engines/titanic/star_control/base_star.cpp')
-rw-r--r-- | engines/titanic/star_control/base_star.cpp | 99 |
1 files changed, 68 insertions, 31 deletions
diff --git a/engines/titanic/star_control/base_star.cpp b/engines/titanic/star_control/base_star.cpp index fc61eb71ea..cfadedd8e7 100644 --- a/engines/titanic/star_control/base_star.cpp +++ b/engines/titanic/star_control/base_star.cpp @@ -159,7 +159,7 @@ void CBaseStar::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarC } void CBaseStar::draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5) { - CStarControlSub6 sub6 = sub12->proc23(); + FPose pose = sub12->proc23(); sub12->proc36(&_value1, &_value2, &_value3, &_value4); const double MAX_VAL = 1.0e9 * 1.0e9; @@ -174,17 +174,17 @@ void CBaseStar::draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar for (uint idx = 0; idx < _data.size(); ++idx) { CBaseStarEntry &entry = _data[idx]; const FVector &vector = entry._position; - tempZ = vector._x * sub6._row1._z + vector._y * sub6._row2._z - + vector._z * sub6._row3._z + sub6._vector._z; + tempZ = vector._x * pose._row1._z + vector._y * pose._row2._z + + vector._z * pose._row3._z + pose._vector._z; if (tempZ <= minVal) continue; - tempY = vector._x * sub6._row1._y + vector._y * sub6._row2._y + vector._z * sub6._row3._y + sub6._vector._y; - tempX = vector._x * sub6._row1._x + vector._y * sub6._row2._x + vector._z * sub6._row3._x + sub6._vector._x; + tempY = vector._x * pose._row1._y + vector._y * pose._row2._y + vector._z * pose._row3._y + pose._vector._y; + tempX = vector._x * pose._row1._x + vector._y * pose._row2._x + vector._z * pose._row3._x + pose._vector._x; total2 = tempY * tempY + tempX * tempX + tempZ * tempZ; if (total2 < 1.0e12) { - sub5->proc2(&sub6, vector, centroid._x, centroid._y, total2, + sub5->proc2(pose, vector, centroid._x, centroid._y, total2, surfaceArea, sub12); continue; } @@ -244,7 +244,7 @@ void CBaseStar::draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar } void CBaseStar::draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5) { - CStarControlSub6 sub6 = sub12->proc23(); + FPose pose = sub12->proc23(); sub12->proc36(&_value1, &_value2, &_value3, &_value4); const double MAX_VAL = 1.0e9 * 1.0e9; @@ -259,17 +259,17 @@ void CBaseStar::draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar for (uint idx = 0; idx < _data.size(); ++idx) { CBaseStarEntry &entry = _data[idx]; const FVector &vector = entry._position; - tempZ = vector._x * sub6._row1._z + vector._y * sub6._row2._z - + vector._z * sub6._row3._z + sub6._vector._z; + tempZ = vector._x * pose._row1._z + vector._y * pose._row2._z + + vector._z * pose._row3._z + pose._vector._z; if (tempZ <= minVal) continue; - tempY = vector._x * sub6._row1._y + vector._y * sub6._row2._y + vector._z * sub6._row3._y + vector._y; - tempX = vector._x * sub6._row1._x + vector._y * sub6._row2._x + vector._z * sub6._row3._x + vector._x; + tempY = vector._x * pose._row1._y + vector._y * pose._row2._y + vector._z * pose._row3._y + vector._y; + tempX = vector._x * pose._row1._x + vector._y * pose._row2._x + vector._z * pose._row3._x + vector._x; total2 = tempY * tempY + tempX * tempX + tempZ * tempZ; if (total2 < 1.0e12) { - sub5->proc2(&sub6, vector, centroid._x, centroid._y, total2, + sub5->proc2(pose, vector, centroid._x, centroid._y, total2, surfaceArea, sub12); continue; } @@ -330,7 +330,7 @@ void CBaseStar::draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar } void CBaseStar::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5) { - CStarControlSub6 sub6 = sub12->proc23(); + FPose pose = sub12->proc23(); sub12->proc36(&_value1, &_value2, &_value3, &_value4); const double MAX_VAL = 1.0e9 * 1.0e9; @@ -339,23 +339,26 @@ void CBaseStar::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar double minVal = threshold - 9216.0; int width1 = surfaceArea->_width - 1; int height1 = surfaceArea->_height - 1; - double *v1Ptr = &_value1, *v2Ptr = &_value2, *v3Ptr = &_value3; - double tempX, tempY, tempZ, total2; + double *v1Ptr = &_value1, *v2Ptr = &_value2; + double *v3Ptr = &_value3, *v4Ptr = &_value4; + double tempX, tempY, tempZ, total2, sVal; + int xStart, yStart, rgb; + uint16 *pixelP; for (uint idx = 0; idx < _data.size(); ++idx) { CBaseStarEntry &entry = _data[idx]; const FVector &vector = entry._position; - tempZ = vector._x * sub6._row1._z + vector._y * sub6._row2._z - + vector._z * sub6._row3._z + sub6._vector._z; + tempZ = vector._x * pose._row1._z + vector._y * pose._row2._z + + vector._z * pose._row3._z + pose._vector._z; if (tempZ <= minVal) continue; - tempY = vector._x * sub6._row1._y + vector._y * sub6._row2._y + vector._z * sub6._row3._y + sub6._vector._y; - tempX = vector._x * sub6._row1._x + vector._y * sub6._row2._x + vector._z * sub6._row3._x + sub6._vector._x; + tempY = vector._x * pose._row1._y + vector._y * pose._row2._y + vector._z * pose._row3._y + pose._vector._y; + tempX = vector._x * pose._row1._x + vector._y * pose._row2._x + vector._z * pose._row3._x + pose._vector._x; total2 = tempY * tempY + tempX * tempX + tempZ * tempZ; if (total2 < 1.0e12) { - sub5->proc2(&sub6, vector, centroid._x, centroid._y, total2, + sub5->proc2(pose, vector, centroid._x, centroid._y, total2, surfaceArea, sub12); continue; } @@ -363,13 +366,47 @@ void CBaseStar::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar if (tempZ <= threshold || total2 >= MAX_VAL) continue; - int xStart = (int)((tempX + *v3Ptr) * *v1Ptr / tempZ + centroid._x); - int yStart = (int)(tempY * *v2Ptr / tempZ + centroid._y); + // First pixel + xStart = (int)((tempX + *v3Ptr) * *v1Ptr / tempZ + centroid._x); + yStart = (int)(tempY * *v2Ptr / tempZ + centroid._y); + if (xStart < 0 || xStart >= width1 || yStart < 0 || yStart >= height1) + continue; + + sVal = sqrt(total2); + sVal = (sVal < 100000.0) ? 1.0 : 1.0 - ((sVal - 100000.0) / 1.0e9); + sVal *= 255.0; + + if (sVal > 255.0) + sVal = 255.0; + if (sVal > 2.0) { + pixelP = (uint16 *)(surfaceArea->_pixelsPtr + surfaceArea->_pitch * yStart + xStart * 2); + rgb = ((int)(sVal - 0.5) & 0xf8) << 7; + + switch (entry._thickness) { + case 0: + *pixelP = rgb; + break; + + case 1: + *pixelP = rgb; + *(pixelP + 1) = rgb; + *(pixelP + surfaceArea->_pitch / 2) = rgb; + *(pixelP + surfaceArea->_pitch / 2 + 1) = rgb; + break; + + default: + break; + } + } + + // Second pixel + xStart = (int)((tempX + *v4Ptr) * *v1Ptr / tempZ + centroid._x); + yStart = (int)(tempY * *v2Ptr / tempZ + centroid._y); if (xStart < 0 || xStart >= width1 || yStart < 0 || yStart >= height1) continue; - double sVal = sqrt(total2); + sVal = sqrt(total2); sVal = (sVal < 100000.0) ? 1.0 : 1.0 - ((sVal - 100000.0) / 1.0e9); sVal *= 255.0; @@ -377,8 +414,8 @@ void CBaseStar::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar sVal = 255.0; if (sVal > 2.0) { - uint16 *pixelP = (uint16 *)(surfaceArea->_pixelsPtr + surfaceArea->_pitch * yStart + xStart * 2); - int rgb = ((int)(sVal - 0.5) & 0xf8) << 7; + pixelP = (uint16 *)(surfaceArea->_pixelsPtr + surfaceArea->_pitch * yStart + xStart * 2); + rgb = ((int)(sVal - 0.5) & 0xf8) << 7; switch (entry._thickness) { case 0: @@ -400,7 +437,7 @@ void CBaseStar::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar } void CBaseStar::draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5) { - CStarControlSub6 sub6 = sub12->proc23(); + FPose pose = sub12->proc23(); sub12->proc36(&_value1, &_value2, &_value3, &_value4); const double MAX_VAL = 1.0e9 * 1.0e9; @@ -418,17 +455,17 @@ void CBaseStar::draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar const CBaseStarEntry &entry = _data[idx]; const FVector &vector = entry._position; - tempZ = vector._x * sub6._row1._z + vector._y * sub6._row2._z - + vector._z * sub6._row3._z + sub6._vector._z; + tempZ = vector._x * pose._row1._z + vector._y * pose._row2._z + + vector._z * pose._row3._z + pose._vector._z; if (tempZ <= minVal) continue; - tempY = vector._x * sub6._row1._y + vector._y * sub6._row2._y + vector._z * sub6._row3._y + sub6._vector._y; - tempX = vector._x * sub6._row1._x + vector._y * sub6._row2._x + vector._z * sub6._row3._x + sub6._vector._x; + tempY = vector._x * pose._row1._y + vector._y * pose._row2._y + vector._z * pose._row3._y + pose._vector._y; + tempX = vector._x * pose._row1._x + vector._y * pose._row2._x + vector._z * pose._row3._x + pose._vector._x; total2 = tempY * tempY + tempX * tempX + tempZ * tempZ; if (total2 < 1.0e12) { - sub5->proc2(&sub6, vector, centroid._x, centroid._y, total2, + sub5->proc2(pose, vector, centroid._x, centroid._y, total2, surfaceArea, sub12); continue; } |