aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/star_control
diff options
context:
space:
mode:
authorPaul Gilbert2017-04-02 17:04:51 -0400
committerPaul Gilbert2017-04-02 17:04:51 -0400
commit320cdbeac3da4ecad8464ed068921f0b9fce0844 (patch)
tree2e0f80c57143c852d2b8a9e4e3f9aed6e65cbae7 /engines/titanic/star_control
parent9145900924d5b8801ffcaf8a38ac9195f61cd606 (diff)
downloadscummvm-rg350-320cdbeac3da4ecad8464ed068921f0b9fce0844.tar.gz
scummvm-rg350-320cdbeac3da4ecad8464ed068921f0b9fce0844.tar.bz2
scummvm-rg350-320cdbeac3da4ecad8464ed068921f0b9fce0844.zip
TITANIC: Add missing code from CBaseStar draw3
Diffstat (limited to 'engines/titanic/star_control')
-rw-r--r--engines/titanic/star_control/base_star.cpp51
1 files changed, 44 insertions, 7 deletions
diff --git a/engines/titanic/star_control/base_star.cpp b/engines/titanic/star_control/base_star.cpp
index fc61eb71ea..dfd7343068 100644
--- a/engines/titanic/star_control/base_star.cpp
+++ b/engines/titanic/star_control/base_star.cpp
@@ -339,8 +339,11 @@ 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];
@@ -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: