[Scummvm-git-logs] scummvm master -> fda21bb74958b30bafc805c8fab04260cfdbb772
dreammaster
dreammaster at scummvm.org
Mon Apr 10 03:08:54 CEST 2017
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
fda21bb749 TITANIC: Rename CBaseStar to CBaseStars
Commit: fda21bb74958b30bafc805c8fab04260cfdbb772
https://github.com/scummvm/scummvm/commit/fda21bb74958b30bafc805c8fab04260cfdbb772
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-04-09T21:08:38-04:00
Commit Message:
TITANIC: Rename CBaseStar to CBaseStars
Changed paths:
A engines/titanic/star_control/base_stars.cpp
A engines/titanic/star_control/base_stars.h
R engines/titanic/star_control/base_star.cpp
R engines/titanic/star_control/base_star.h
engines/titanic/module.mk
engines/titanic/star_control/star_control_sub12.h
engines/titanic/star_control/star_control_sub13.h
engines/titanic/star_control/star_control_sub2.h
engines/titanic/star_control/star_control_sub20.h
engines/titanic/star_control/star_control_sub7.h
engines/titanic/star_control/star_control_sub8.h
engines/titanic/star_control/star_ref.cpp
engines/titanic/star_control/star_ref.h
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 0b32265..aa165d3 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -431,7 +431,7 @@ MODULE_OBJS := \
sound/water_lapping_sounds.o \
sound/wave_file.o \
star_control/star_control.o \
- star_control/base_star.o \
+ star_control/base_stars.o \
star_control/dmatrix.o \
star_control/dvector.o \
star_control/fmatrix.o \
diff --git a/engines/titanic/star_control/base_star.cpp b/engines/titanic/star_control/base_star.cpp
deleted file mode 100644
index e6a7b48..0000000
--- a/engines/titanic/star_control/base_star.cpp
+++ /dev/null
@@ -1,565 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "titanic/star_control/base_star.h"
-#include "titanic/star_control/star_control_sub12.h"
-#include "titanic/star_control/star_ref.h"
-#include "titanic/titanic.h"
-
-namespace Titanic {
-
-CBaseStarEntry::CBaseStarEntry() : _red(0), _value(0.0) {
- Common::fill(&_data[0], &_data[5], 0);
-}
-
-void CBaseStarEntry::load(Common::SeekableReadStream &s) {
- _red = s.readByte();
- _green = s.readByte();
- _blue = s.readByte();
- _thickness = s.readByte();
- _value = s.readFloatLE();
- _position._x = s.readFloatLE();
- _position._y = s.readFloatLE();
- _position._z = s.readFloatLE();
-
- for (int idx = 0; idx < 5; ++idx)
- _data[idx] = s.readUint32LE();
-}
-
-bool CBaseStarEntry::operator==(const CBaseStarEntry &s) const {
- return _red == s._red && _green == s._green
- && _blue == s._blue && _thickness == s._thickness
- && _value == s._value && _position == s._position
- && _data[0] == s._data[0] && _data[1] == s._data[1]
- && _data[2] == s._data[2] && _data[3] == s._data[3]
- && _data[4] == s._data[4];
-}
-
-/*------------------------------------------------------------------------*/
-
-CBaseStar::CBaseStar() : _minVal(0.0), _maxVal(1.0), _range(0.0),
- _value1(0.0), _value2(0.0), _value3(0.0), _value4(0.0) {
-}
-
-void CBaseStar::clear() {
- _data.clear();
-}
-
-void CBaseStar::initialize() {
- _minVal = 9.9999998e10;
- _maxVal = -9.9999998e10;
- _minMax.reset();
-
- for (uint idx = 0; idx < _data.size(); ++idx) {
- const CBaseStarEntry *entry = getDataPtr(idx);
- _minMax.expand(entry->_position);
-
- if (entry->_value < _minVal)
- _minVal = entry->_value;
- if (entry->_value > _maxVal)
- _maxVal = entry->_value;
- }
-
- _range = (_maxVal - _minVal) / 1.0;
-}
-
-const CBaseStarEntry *CBaseStar::getDataPtr(int index) const {
- return (index >= 0 && index < (int)_data.size()) ? &_data[index] : nullptr;
-}
-
-void CBaseStar::loadData(Common::SeekableReadStream &s) {
- uint headerId = s.readUint32LE();
- uint count = s.readUint32LE();
- if (headerId != 100 || count == 0)
- error("Invalid star data");
-
- // Initialize the data array
- clear();
- _data.resize(count);
-
- // Iterate through reading the data for each entry
- for (uint idx = 0; idx < count; ++idx)
- _data[idx].load(s);
-}
-
-void CBaseStar::loadData(const CString &resName) {
- // Get a stream to read the data from the DAT file
- Common::SeekableReadStream *stream = g_vm->_filesManager->getResource(resName);
- assert(stream);
-
- // Load the stream
- loadData(*stream);
- delete stream;
-}
-
-void CBaseStar::resetEntry(CBaseStarEntry &entry) {
- entry._red = 0xFF;
- entry._green = 0xFF;
- entry._blue = 0xFF;
- entry._thickness = 0;
- entry._position._x = 0;
- entry._position._y = 0;
- entry._position._z = 0;
- for (int idx = 0; idx < 5; ++idx)
- entry._data[idx] = 0;
-}
-
-void CBaseStar::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) {
- if (!_data.empty()) {
- switch (sub12->proc27()) {
- case 0:
- switch (surfaceArea->_bpp) {
- case 1:
- draw1(surfaceArea, sub12, closeup);
- break;
- case 2:
- draw2(surfaceArea, sub12, closeup);
- break;
- default:
- break;
- }
- break;
-
- case 2:
- switch (surfaceArea->_bpp) {
- case 1:
- draw3(surfaceArea, sub12, closeup);
- break;
- case 2:
- draw4(surfaceArea, sub12, closeup);
- break;
- default:
- break;
- }
- break;
-
- default:
- break;
- }
- }
-}
-
-void CBaseStar::draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) {
- FPose pose = sub12->proc23();
- sub12->proc36(&_value1, &_value2, &_value3, &_value4);
-
- const double MAX_VAL = 1.0e9 * 1.0e9;
- FPoint centroid = surfaceArea->_centroid - FPoint(0.5, 0.5);
- double threshold = sub12->proc25();
- double minVal = threshold - 9216.0;
- int width1 = surfaceArea->_width - 1;
- int height1 = surfaceArea->_height - 1;
- double *v1Ptr = &_value1, *v2Ptr = &_value2;
- double tempX, tempY, tempZ, total2;
-
- for (uint idx = 0; idx < _data.size(); ++idx) {
- CBaseStarEntry &entry = _data[idx];
- const FVector &vector = entry._position;
- 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 * 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) {
- closeup->draw(pose, vector, FVector(centroid._x, centroid._y, total2),
- surfaceArea, sub12);
- continue;
- }
-
- if (tempZ <= threshold || total2 >= MAX_VAL)
- continue;
-
- int xStart = (int)(*v1Ptr * tempX / tempZ + centroid._x);
- int yStart = (int)(*v2Ptr * tempY / tempZ + centroid._y);
- if (xStart < 0 || xStart >= width1 || yStart < 0 || yStart >= height1)
- continue;
-
- double sVal = sqrt(total2);
- sVal = (sVal < 100000.0) ? 1.0 : 1.0 - ((sVal - 100000.0) / 1.0e9);
- double red = MIN((double)entry._red * sVal, (double)255.0);
- double green = MIN((double)entry._green * sVal, (double)255.0);
- double blue = MIN((double)entry._green * sVal, (double)255.0);
-
- int skipCtr = 0;
- if (red < 0.0) {
- red = 0.0;
- ++skipCtr;
- }
- if (green < 0.0) {
- green = 0.0;
- ++skipCtr;
- }
- if (blue < 0.0) {
- blue = 0.0;
- ++skipCtr;
- }
- if (skipCtr == 3)
- continue;
-
- int r = (int)(red - 0.5) & 0xfff8;
- int g = (int)(green - 0.5) & 0xfff8;
- int b = (int)(blue - 0.5) & 0xfff8;
- int rgb = ((g | (r << 5)) << 2) | ((b >> 3) & 0xfff8);
- uint16 *pixelP = (uint16 *)(surfaceArea->_pixelsPtr + surfaceArea->_pitch * yStart + xStart * 2);
-
- 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;
- }
- }
-}
-
-void CBaseStar::draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) {
- FPose pose = sub12->proc23();
- sub12->proc36(&_value1, &_value2, &_value3, &_value4);
-
- const double MAX_VAL = 1.0e9 * 1.0e9;
- FPoint centroid = surfaceArea->_centroid - FPoint(0.5, 0.5);
- double threshold = sub12->proc25();
- double minVal = threshold - 9216.0;
- int width1 = surfaceArea->_width - 1;
- int height1 = surfaceArea->_height - 1;
- double *v1Ptr = &_value1, *v2Ptr = &_value2;
- double tempX, tempY, tempZ, total2;
-
- for (uint idx = 0; idx < _data.size(); ++idx) {
- CBaseStarEntry &entry = _data[idx];
- const FVector &vector = entry._position;
- 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 * 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) {
- closeup->draw(pose, vector, FVector(centroid._x, centroid._y, total2),
- surfaceArea, sub12);
- continue;
- }
-
- if (tempZ <= threshold || total2 >= MAX_VAL)
- continue;
-
- int xStart = (int)(*v1Ptr * tempX / tempZ + centroid._x);
- int yStart = (int)(*v2Ptr * tempY / tempZ + centroid._y);
- if (xStart < 0 || xStart >= width1 || yStart < 0 || yStart >= height1)
- continue;
-
- double sVal = sqrt(total2);
- sVal = (sVal < 100000.0) ? 1.0 : 1.0 - ((sVal - 100000.0) / 1.0e9);
- double red = MIN((double)entry._red * sVal, (double)255.0);
- double green = MIN((double)entry._green * sVal, (double)255.0);
- double blue = MIN((double)entry._green * sVal, (double)255.0);
-
- int skipCtr = 0;
- if (red < 0.0) {
- red = 0.0;
- ++skipCtr;
- }
- if (green < 0.0) {
- green = 0.0;
- ++skipCtr;
- }
- if (blue < 0.0) {
- blue = 0.0;
- ++skipCtr;
- }
- if (skipCtr == 3)
- continue;
-
- int r = (int)(red - 0.5) & 0xf8;
- int g = (int)(green - 0.5) & 0xfc;
- int b = (int)(blue - 0.5) & 0xfff8;
-
- int rgb = ((g | (r << 5)) << 3) | (b >> 3);
- uint16 *pixelP = (uint16 *)(surfaceArea->_pixelsPtr + surfaceArea->_pitch * yStart + xStart * 2);
-
- 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;
- }
- }
-}
-
-void CBaseStar::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) {
- FPose pose = sub12->proc23();
- sub12->proc36(&_value1, &_value2, &_value3, &_value4);
-
- const double MAX_VAL = 1.0e9 * 1.0e9;
- FPoint centroid = surfaceArea->_centroid - FPoint(0.5, 0.5);
- double threshold = sub12->proc25();
- double minVal = threshold - 9216.0;
- int width1 = surfaceArea->_width - 1;
- int height1 = surfaceArea->_height - 1;
- 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 * pose._row1._z + vector._y * pose._row2._z
- + vector._z * pose._row3._z + pose._vector._z;
- if (tempZ <= minVal)
- continue;
-
- 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) {
- closeup->draw(pose, vector, FVector(centroid._x, centroid._y, total2),
- surfaceArea, sub12);
- continue;
- }
-
- if (tempZ <= threshold || total2 >= MAX_VAL)
- continue;
-
- // 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;
-
- 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;
- }
- }
- }
-}
-
-void CBaseStar::draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) {
- FPose pose = sub12->proc23();
- sub12->proc36(&_value1, &_value2, &_value3, &_value4);
-
- const double MAX_VAL = 1.0e9 * 1.0e9;
- FPoint centroid = surfaceArea->_centroid - FPoint(0.5, 0.5);
- double threshold = sub12->proc25();
- double minVal = threshold - 9216.0;
- int width1 = surfaceArea->_width - 1;
- int height1 = surfaceArea->_height - 1;
- double *v1Ptr = &_value1, *v2Ptr = &_value2, *v3Ptr = &_value3, *v4Ptr = &_value4;
- double tempX, tempY, tempZ, total2, sVal;
- int xStart, yStart, rgb;
- uint16 *pixelP;
-
- for (uint idx = 0; idx < _data.size(); ++idx) {
- const CBaseStarEntry &entry = _data[idx];
- const FVector &vector = entry._position;
-
- 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 * 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) {
- closeup->draw(pose, vector, FVector(centroid._x, centroid._y, total2),
- surfaceArea, sub12);
- continue;
- }
-
- if (tempZ <= threshold || total2 >= MAX_VAL)
- continue;
-
- // 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) << 8;
-
- 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;
-
- 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) >> 3) & 0xff;
-
- 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;
- }
- }
- }
-}
-
-int CBaseStar::baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
- const Common::Point &pt) {
- CStarRef1 ref(this, pt);
- ref.process(surfaceArea, sub12);
- return ref._index;
-}
-
-int CBaseStar::baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) {
- CStarRef3 ref(this);
- ref.process(surfaceArea, sub12);
- return ref._index;
-}
-
-/*------------------------------------------------------------------------*/
-
-void CStarVector::apply() {
- _owner->addMatrixRow(_vector);
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/star_control/base_star.h b/engines/titanic/star_control/base_star.h
deleted file mode 100644
index 81bdb4d..0000000
--- a/engines/titanic/star_control/base_star.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef TITANIC_STAR_CONTROL_SUB3_H
-#define TITANIC_STAR_CONTROL_SUB3_H
-
-#include "titanic/support/simple_file.h"
-#include "titanic/star_control/frange.h"
-#include "titanic/star_control/star_closeup.h"
-#include "titanic/star_control/surface_area.h"
-
-namespace Titanic {
-
-enum StarMode { MODE_STARFIELD = 0, MODE_PHOTO = 1 };
-
-class CStarControlSub12;
-
-struct CBaseStarEntry {
- byte _red;
- byte _green;
- byte _blue;
- byte _thickness;
- double _value;
- FVector _position;
- uint _data[5];
-
- CBaseStarEntry();
-
- /**
- * Loads the data for a star
- */
- void load(Common::SeekableReadStream &s);
-
- bool operator==(const CBaseStarEntry &s) const;
-};
-
-struct CStarPosition : public Common::Point {
- int _index1;
- int _index2;
- CStarPosition() : _index1(0), _index2(0) {}
-
- bool operator==(const CStarPosition &sp) const {
- return x == sp.x && y == sp.y && _index1 == sp._index1 && _index2 == sp._index2;
- }
-};
-
-class CBaseStar {
-private:
- void draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup);
- void draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup);
- void draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup);
- void draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup);
-protected:
- FRange _minMax;
- double _minVal;
- double _maxVal;
- double _range;
- double _value1, _value2;
- double _value3, _value4;
-protected:
- /**
- * Load entry data from a passed stream
- */
- void loadData(Common::SeekableReadStream &s);
-
- /**
- * Load entry data from a specified resource
- */
- void loadData(const CString &resName);
-
- /**
- * Reset the data for an entry
- */
- void resetEntry(CBaseStarEntry &entry);
-public:
- Common::Array<CBaseStarEntry> _data;
-public:
- CBaseStar();
- virtual ~CBaseStar() {}
-
- /**
- * Draw the item
- */
- virtual void draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup);
-
- virtual bool loadYale(int v1) { return true; }
-
- /**
- * Selects a star
- */
- virtual bool selectStar(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
- const Common::Point &pt, void *handler = nullptr) { return false; }
-
- /**
- * Adds a new star, or removes one if already present at the given co-ordinates
- */
- virtual bool addStar(const CBaseStarEntry *entry) { return false; }
-
- virtual bool loadStar() { return false; }
-
- /**
- * Load the item's data
- */
- virtual void load(SimpleFile *file) {}
-
- /**
- * Save the item's data
- */
- virtual void save(SimpleFile *file, int indent) {}
-
- /**
- * Clear allocated data
- */
- void clear();
-
- void initialize();
-
- int size() const { return _data.size(); }
-
- /**
- * Get a pointer to a data entry
- */
- const CBaseStarEntry *getDataPtr(int index) const;
-
- int baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
- const Common::Point &pt);
-
- int baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12);
-};
-
-class CStarVector {
-private:
- CStarControlSub12 *_owner;
- FVector _vector;
-public:
- CStarVector(CStarControlSub12 *owner, const FVector &v) : _owner(owner), _vector(v) {}
-
- /**
- * Applies the saved vector
- */
- void apply();
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_STAR_CONTROL_SUB3_H */
diff --git a/engines/titanic/star_control/base_stars.cpp b/engines/titanic/star_control/base_stars.cpp
new file mode 100644
index 0000000..a5c6143
--- /dev/null
+++ b/engines/titanic/star_control/base_stars.cpp
@@ -0,0 +1,565 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/star_control/base_stars.h"
+#include "titanic/star_control/star_control_sub12.h"
+#include "titanic/star_control/star_ref.h"
+#include "titanic/titanic.h"
+
+namespace Titanic {
+
+CBaseStarEntry::CBaseStarEntry() : _red(0), _value(0.0) {
+ Common::fill(&_data[0], &_data[5], 0);
+}
+
+void CBaseStarEntry::load(Common::SeekableReadStream &s) {
+ _red = s.readByte();
+ _green = s.readByte();
+ _blue = s.readByte();
+ _thickness = s.readByte();
+ _value = s.readFloatLE();
+ _position._x = s.readFloatLE();
+ _position._y = s.readFloatLE();
+ _position._z = s.readFloatLE();
+
+ for (int idx = 0; idx < 5; ++idx)
+ _data[idx] = s.readUint32LE();
+}
+
+bool CBaseStarEntry::operator==(const CBaseStarEntry &s) const {
+ return _red == s._red && _green == s._green
+ && _blue == s._blue && _thickness == s._thickness
+ && _value == s._value && _position == s._position
+ && _data[0] == s._data[0] && _data[1] == s._data[1]
+ && _data[2] == s._data[2] && _data[3] == s._data[3]
+ && _data[4] == s._data[4];
+}
+
+/*------------------------------------------------------------------------*/
+
+CBaseStars::CBaseStars() : _minVal(0.0), _maxVal(1.0), _range(0.0),
+ _value1(0.0), _value2(0.0), _value3(0.0), _value4(0.0) {
+}
+
+void CBaseStars::clear() {
+ _data.clear();
+}
+
+void CBaseStars::initialize() {
+ _minVal = 9.9999998e10;
+ _maxVal = -9.9999998e10;
+ _minMax.reset();
+
+ for (uint idx = 0; idx < _data.size(); ++idx) {
+ const CBaseStarEntry *entry = getDataPtr(idx);
+ _minMax.expand(entry->_position);
+
+ if (entry->_value < _minVal)
+ _minVal = entry->_value;
+ if (entry->_value > _maxVal)
+ _maxVal = entry->_value;
+ }
+
+ _range = (_maxVal - _minVal) / 1.0;
+}
+
+const CBaseStarEntry *CBaseStars::getDataPtr(int index) const {
+ return (index >= 0 && index < (int)_data.size()) ? &_data[index] : nullptr;
+}
+
+void CBaseStars::loadData(Common::SeekableReadStream &s) {
+ uint headerId = s.readUint32LE();
+ uint count = s.readUint32LE();
+ if (headerId != 100 || count == 0)
+ error("Invalid star data");
+
+ // Initialize the data array
+ clear();
+ _data.resize(count);
+
+ // Iterate through reading the data for each entry
+ for (uint idx = 0; idx < count; ++idx)
+ _data[idx].load(s);
+}
+
+void CBaseStars::loadData(const CString &resName) {
+ // Get a stream to read the data from the DAT file
+ Common::SeekableReadStream *stream = g_vm->_filesManager->getResource(resName);
+ assert(stream);
+
+ // Load the stream
+ loadData(*stream);
+ delete stream;
+}
+
+void CBaseStars::resetEntry(CBaseStarEntry &entry) {
+ entry._red = 0xFF;
+ entry._green = 0xFF;
+ entry._blue = 0xFF;
+ entry._thickness = 0;
+ entry._position._x = 0;
+ entry._position._y = 0;
+ entry._position._z = 0;
+ for (int idx = 0; idx < 5; ++idx)
+ entry._data[idx] = 0;
+}
+
+void CBaseStars::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) {
+ if (!_data.empty()) {
+ switch (sub12->proc27()) {
+ case 0:
+ switch (surfaceArea->_bpp) {
+ case 1:
+ draw1(surfaceArea, sub12, closeup);
+ break;
+ case 2:
+ draw2(surfaceArea, sub12, closeup);
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case 2:
+ switch (surfaceArea->_bpp) {
+ case 1:
+ draw3(surfaceArea, sub12, closeup);
+ break;
+ case 2:
+ draw4(surfaceArea, sub12, closeup);
+ break;
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+void CBaseStars::draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) {
+ FPose pose = sub12->proc23();
+ sub12->proc36(&_value1, &_value2, &_value3, &_value4);
+
+ const double MAX_VAL = 1.0e9 * 1.0e9;
+ FPoint centroid = surfaceArea->_centroid - FPoint(0.5, 0.5);
+ double threshold = sub12->proc25();
+ double minVal = threshold - 9216.0;
+ int width1 = surfaceArea->_width - 1;
+ int height1 = surfaceArea->_height - 1;
+ double *v1Ptr = &_value1, *v2Ptr = &_value2;
+ double tempX, tempY, tempZ, total2;
+
+ for (uint idx = 0; idx < _data.size(); ++idx) {
+ CBaseStarEntry &entry = _data[idx];
+ const FVector &vector = entry._position;
+ 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 * 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) {
+ closeup->draw(pose, vector, FVector(centroid._x, centroid._y, total2),
+ surfaceArea, sub12);
+ continue;
+ }
+
+ if (tempZ <= threshold || total2 >= MAX_VAL)
+ continue;
+
+ int xStart = (int)(*v1Ptr * tempX / tempZ + centroid._x);
+ int yStart = (int)(*v2Ptr * tempY / tempZ + centroid._y);
+ if (xStart < 0 || xStart >= width1 || yStart < 0 || yStart >= height1)
+ continue;
+
+ double sVal = sqrt(total2);
+ sVal = (sVal < 100000.0) ? 1.0 : 1.0 - ((sVal - 100000.0) / 1.0e9);
+ double red = MIN((double)entry._red * sVal, (double)255.0);
+ double green = MIN((double)entry._green * sVal, (double)255.0);
+ double blue = MIN((double)entry._green * sVal, (double)255.0);
+
+ int skipCtr = 0;
+ if (red < 0.0) {
+ red = 0.0;
+ ++skipCtr;
+ }
+ if (green < 0.0) {
+ green = 0.0;
+ ++skipCtr;
+ }
+ if (blue < 0.0) {
+ blue = 0.0;
+ ++skipCtr;
+ }
+ if (skipCtr == 3)
+ continue;
+
+ int r = (int)(red - 0.5) & 0xfff8;
+ int g = (int)(green - 0.5) & 0xfff8;
+ int b = (int)(blue - 0.5) & 0xfff8;
+ int rgb = ((g | (r << 5)) << 2) | ((b >> 3) & 0xfff8);
+ uint16 *pixelP = (uint16 *)(surfaceArea->_pixelsPtr + surfaceArea->_pitch * yStart + xStart * 2);
+
+ 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;
+ }
+ }
+}
+
+void CBaseStars::draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) {
+ FPose pose = sub12->proc23();
+ sub12->proc36(&_value1, &_value2, &_value3, &_value4);
+
+ const double MAX_VAL = 1.0e9 * 1.0e9;
+ FPoint centroid = surfaceArea->_centroid - FPoint(0.5, 0.5);
+ double threshold = sub12->proc25();
+ double minVal = threshold - 9216.0;
+ int width1 = surfaceArea->_width - 1;
+ int height1 = surfaceArea->_height - 1;
+ double *v1Ptr = &_value1, *v2Ptr = &_value2;
+ double tempX, tempY, tempZ, total2;
+
+ for (uint idx = 0; idx < _data.size(); ++idx) {
+ CBaseStarEntry &entry = _data[idx];
+ const FVector &vector = entry._position;
+ 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 * 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) {
+ closeup->draw(pose, vector, FVector(centroid._x, centroid._y, total2),
+ surfaceArea, sub12);
+ continue;
+ }
+
+ if (tempZ <= threshold || total2 >= MAX_VAL)
+ continue;
+
+ int xStart = (int)(*v1Ptr * tempX / tempZ + centroid._x);
+ int yStart = (int)(*v2Ptr * tempY / tempZ + centroid._y);
+ if (xStart < 0 || xStart >= width1 || yStart < 0 || yStart >= height1)
+ continue;
+
+ double sVal = sqrt(total2);
+ sVal = (sVal < 100000.0) ? 1.0 : 1.0 - ((sVal - 100000.0) / 1.0e9);
+ double red = MIN((double)entry._red * sVal, (double)255.0);
+ double green = MIN((double)entry._green * sVal, (double)255.0);
+ double blue = MIN((double)entry._green * sVal, (double)255.0);
+
+ int skipCtr = 0;
+ if (red < 0.0) {
+ red = 0.0;
+ ++skipCtr;
+ }
+ if (green < 0.0) {
+ green = 0.0;
+ ++skipCtr;
+ }
+ if (blue < 0.0) {
+ blue = 0.0;
+ ++skipCtr;
+ }
+ if (skipCtr == 3)
+ continue;
+
+ int r = (int)(red - 0.5) & 0xf8;
+ int g = (int)(green - 0.5) & 0xfc;
+ int b = (int)(blue - 0.5) & 0xfff8;
+
+ int rgb = ((g | (r << 5)) << 3) | (b >> 3);
+ uint16 *pixelP = (uint16 *)(surfaceArea->_pixelsPtr + surfaceArea->_pitch * yStart + xStart * 2);
+
+ 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;
+ }
+ }
+}
+
+void CBaseStars::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) {
+ FPose pose = sub12->proc23();
+ sub12->proc36(&_value1, &_value2, &_value3, &_value4);
+
+ const double MAX_VAL = 1.0e9 * 1.0e9;
+ FPoint centroid = surfaceArea->_centroid - FPoint(0.5, 0.5);
+ double threshold = sub12->proc25();
+ double minVal = threshold - 9216.0;
+ int width1 = surfaceArea->_width - 1;
+ int height1 = surfaceArea->_height - 1;
+ 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 * pose._row1._z + vector._y * pose._row2._z
+ + vector._z * pose._row3._z + pose._vector._z;
+ if (tempZ <= minVal)
+ continue;
+
+ 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) {
+ closeup->draw(pose, vector, FVector(centroid._x, centroid._y, total2),
+ surfaceArea, sub12);
+ continue;
+ }
+
+ if (tempZ <= threshold || total2 >= MAX_VAL)
+ continue;
+
+ // 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;
+
+ 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;
+ }
+ }
+ }
+}
+
+void CBaseStars::draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) {
+ FPose pose = sub12->proc23();
+ sub12->proc36(&_value1, &_value2, &_value3, &_value4);
+
+ const double MAX_VAL = 1.0e9 * 1.0e9;
+ FPoint centroid = surfaceArea->_centroid - FPoint(0.5, 0.5);
+ double threshold = sub12->proc25();
+ double minVal = threshold - 9216.0;
+ int width1 = surfaceArea->_width - 1;
+ int height1 = surfaceArea->_height - 1;
+ double *v1Ptr = &_value1, *v2Ptr = &_value2, *v3Ptr = &_value3, *v4Ptr = &_value4;
+ double tempX, tempY, tempZ, total2, sVal;
+ int xStart, yStart, rgb;
+ uint16 *pixelP;
+
+ for (uint idx = 0; idx < _data.size(); ++idx) {
+ const CBaseStarEntry &entry = _data[idx];
+ const FVector &vector = entry._position;
+
+ 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 * 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) {
+ closeup->draw(pose, vector, FVector(centroid._x, centroid._y, total2),
+ surfaceArea, sub12);
+ continue;
+ }
+
+ if (tempZ <= threshold || total2 >= MAX_VAL)
+ continue;
+
+ // 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) << 8;
+
+ 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;
+
+ 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) >> 3) & 0xff;
+
+ 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;
+ }
+ }
+ }
+}
+
+int CBaseStars::baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
+ const Common::Point &pt) {
+ CStarRef1 ref(this, pt);
+ ref.process(surfaceArea, sub12);
+ return ref._index;
+}
+
+int CBaseStars::baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) {
+ CStarRef3 ref(this);
+ ref.process(surfaceArea, sub12);
+ return ref._index;
+}
+
+/*------------------------------------------------------------------------*/
+
+void CStarVector::apply() {
+ _owner->addMatrixRow(_vector);
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/base_stars.h b/engines/titanic/star_control/base_stars.h
new file mode 100644
index 0000000..0394bfe
--- /dev/null
+++ b/engines/titanic/star_control/base_stars.h
@@ -0,0 +1,168 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_STAR_CONTROL_SUB3_H
+#define TITANIC_STAR_CONTROL_SUB3_H
+
+#include "titanic/support/simple_file.h"
+#include "titanic/star_control/frange.h"
+#include "titanic/star_control/star_closeup.h"
+#include "titanic/star_control/surface_area.h"
+
+namespace Titanic {
+
+enum StarMode { MODE_STARFIELD = 0, MODE_PHOTO = 1 };
+
+class CStarControlSub12;
+
+struct CBaseStarEntry {
+ byte _red;
+ byte _green;
+ byte _blue;
+ byte _thickness;
+ double _value;
+ FVector _position;
+ uint _data[5];
+
+ CBaseStarEntry();
+
+ /**
+ * Loads the data for a star
+ */
+ void load(Common::SeekableReadStream &s);
+
+ bool operator==(const CBaseStarEntry &s) const;
+};
+
+struct CStarPosition : public Common::Point {
+ int _index1;
+ int _index2;
+ CStarPosition() : _index1(0), _index2(0) {}
+
+ bool operator==(const CStarPosition &sp) const {
+ return x == sp.x && y == sp.y && _index1 == sp._index1 && _index2 == sp._index2;
+ }
+};
+
+/**
+ * Base class for views that draw a set of stars in simulated 3D space
+ */
+class CBaseStars {
+private:
+ void draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup);
+ void draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup);
+ void draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup);
+ void draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup);
+protected:
+ FRange _minMax;
+ double _minVal;
+ double _maxVal;
+ double _range;
+ double _value1, _value2;
+ double _value3, _value4;
+protected:
+ /**
+ * Load entry data from a passed stream
+ */
+ void loadData(Common::SeekableReadStream &s);
+
+ /**
+ * Load entry data from a specified resource
+ */
+ void loadData(const CString &resName);
+
+ /**
+ * Reset the data for an entry
+ */
+ void resetEntry(CBaseStarEntry &entry);
+public:
+ Common::Array<CBaseStarEntry> _data;
+public:
+ CBaseStars();
+ virtual ~CBaseStars() {}
+
+ /**
+ * Draw the item
+ */
+ virtual void draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup);
+
+ virtual bool loadYale(int v1) { return true; }
+
+ /**
+ * Selects a star
+ */
+ virtual bool selectStar(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
+ const Common::Point &pt, void *handler = nullptr) { return false; }
+
+ /**
+ * Adds a new star, or removes one if already present at the given co-ordinates
+ */
+ virtual bool addStar(const CBaseStarEntry *entry) { return false; }
+
+ virtual bool loadStar() { return false; }
+
+ /**
+ * Load the item's data
+ */
+ virtual void load(SimpleFile *file) {}
+
+ /**
+ * Save the item's data
+ */
+ virtual void save(SimpleFile *file, int indent) {}
+
+ /**
+ * Clear allocated data
+ */
+ void clear();
+
+ void initialize();
+
+ int size() const { return _data.size(); }
+
+ /**
+ * Get a pointer to a data entry
+ */
+ const CBaseStarEntry *getDataPtr(int index) const;
+
+ int baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
+ const Common::Point &pt);
+
+ int baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12);
+};
+
+class CStarVector {
+private:
+ CStarControlSub12 *_owner;
+ FVector _vector;
+public:
+ CStarVector(CStarControlSub12 *owner, const FVector &v) : _owner(owner), _vector(v) {}
+
+ /**
+ * Applies the saved vector
+ */
+ void apply();
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_STAR_CONTROL_SUB3_H */
diff --git a/engines/titanic/star_control/star_control_sub12.h b/engines/titanic/star_control/star_control_sub12.h
index f54ba11..06edd96 100644
--- a/engines/titanic/star_control/star_control_sub12.h
+++ b/engines/titanic/star_control/star_control_sub12.h
@@ -26,7 +26,7 @@
#include "titanic/support/simple_file.h"
#include "titanic/star_control/fmatrix.h"
#include "titanic/star_control/fpoint.h"
-#include "titanic/star_control/base_star.h"
+#include "titanic/star_control/base_stars.h"
#include "titanic/star_control/star_control_sub13.h"
#include "titanic/star_control/star_control_sub20.h"
#include "titanic/star_control/error_code.h"
diff --git a/engines/titanic/star_control/star_control_sub13.h b/engines/titanic/star_control/star_control_sub13.h
index 123ca09..ccf2cb8 100644
--- a/engines/titanic/star_control/star_control_sub13.h
+++ b/engines/titanic/star_control/star_control_sub13.h
@@ -24,7 +24,7 @@
#define TITANIC_STAR_CONTROL_SUB13_H
#include "titanic/support/simple_file.h"
-#include "titanic/star_control/base_star.h"
+#include "titanic/star_control/base_stars.h"
#include "titanic/star_control/fpose.h"
#include "titanic/star_control/fmatrix.h"
diff --git a/engines/titanic/star_control/star_control_sub2.h b/engines/titanic/star_control/star_control_sub2.h
index bcf7397..39f1de6 100644
--- a/engines/titanic/star_control/star_control_sub2.h
+++ b/engines/titanic/star_control/star_control_sub2.h
@@ -23,11 +23,11 @@
#ifndef TITANIC_STAR_CONTROL_SUB2_H
#define TITANIC_STAR_CONTROL_SUB2_H
-#include "titanic/star_control/base_star.h"
+#include "titanic/star_control/base_stars.h"
namespace Titanic {
-class CStarControlSub2: public CBaseStar {
+class CStarControlSub2: public CBaseStars {
public:
virtual ~CStarControlSub2() {}
diff --git a/engines/titanic/star_control/star_control_sub20.h b/engines/titanic/star_control/star_control_sub20.h
index eed5e94..ce31499 100644
--- a/engines/titanic/star_control/star_control_sub20.h
+++ b/engines/titanic/star_control/star_control_sub20.h
@@ -24,7 +24,7 @@
#define TITANIC_STAR_CONTROL_SUB20_H
#include "titanic/support/simple_file.h"
-#include "titanic/star_control/base_star.h"
+#include "titanic/star_control/base_stars.h"
#include "titanic/star_control/error_code.h"
#include "titanic/star_control/fmatrix.h"
diff --git a/engines/titanic/star_control/star_control_sub7.h b/engines/titanic/star_control/star_control_sub7.h
index b884400..be5a51f 100644
--- a/engines/titanic/star_control/star_control_sub7.h
+++ b/engines/titanic/star_control/star_control_sub7.h
@@ -23,10 +23,10 @@
#ifndef TITANIC_STAR_CONTROL_SUB7_H
#define TITANIC_STAR_CONTROL_SUB7_H
-#include "titanic/star_control/base_star.h"
+#include "titanic/star_control/base_stars.h"
namespace Titanic {
-class CStarControlSub7 : public CBaseStar {
+class CStarControlSub7 : public CBaseStars {
public:
virtual ~CStarControlSub7() { clear(); }
diff --git a/engines/titanic/star_control/star_control_sub8.h b/engines/titanic/star_control/star_control_sub8.h
index 4939179..992420f 100644
--- a/engines/titanic/star_control/star_control_sub8.h
+++ b/engines/titanic/star_control/star_control_sub8.h
@@ -25,7 +25,7 @@
#include "common/array.h"
#include "common/rect.h"
-#include "titanic/star_control/base_star.h"
+#include "titanic/star_control/base_stars.h"
#include "titanic/star_control/surface_area.h"
#include "titanic/star_control/fpoint.h"
#include "titanic/support/simple_file.h"
diff --git a/engines/titanic/star_control/star_ref.cpp b/engines/titanic/star_control/star_ref.cpp
index dfea8aa..fe3f233 100644
--- a/engines/titanic/star_control/star_ref.cpp
+++ b/engines/titanic/star_control/star_ref.cpp
@@ -25,7 +25,7 @@
namespace Titanic {
void CBaseStarRef::process(CSurfaceArea *surface, CStarControlSub12 *sub12) {
- if (_star->_data.empty())
+ if (_stars->_data.empty())
return;
const double MAX_VAL = 1.0e9 * 1.0e9;
@@ -36,8 +36,8 @@ void CBaseStarRef::process(CSurfaceArea *surface, CStarControlSub12 *sub12) {
FVector vTemp, vector1, vector2;
double val1, green, blue, red;
- for (int idx = 0; idx < _star->size(); ++idx) {
- const CBaseStarEntry &se = _star->_data[idx];
+ for (int idx = 0; idx < _stars->size(); ++idx) {
+ const CBaseStarEntry &se = _stars->_data[idx];
vTemp = se._position;
vector1._x = vTemp._x * pose._row1._x + vTemp._y * pose._row2._x + vTemp._z * pose._row3._x + pose._vector._x;
vector1._y = vTemp._x * pose._row1._y + vTemp._y * pose._row2._y + vTemp._z * pose._row3._y + pose._vector._y;
diff --git a/engines/titanic/star_control/star_ref.h b/engines/titanic/star_control/star_ref.h
index 3cd016e..1ed2213 100644
--- a/engines/titanic/star_control/star_ref.h
+++ b/engines/titanic/star_control/star_ref.h
@@ -21,7 +21,7 @@
*/
#include "common/rect.h"
-#include "titanic/star_control/base_star.h"
+#include "titanic/star_control/base_stars.h"
#include "titanic/star_control/star_control_sub12.h"
#include "titanic/star_control/surface_area.h"
@@ -32,10 +32,10 @@ namespace Titanic {
class CBaseStarRef {
protected:
- CBaseStar *_star;
+ CBaseStars *_stars;
public:
- CBaseStarRef(CBaseStar *star) : _star(star) {}
- CBaseStarRef() : _star(nullptr) {}
+ CBaseStarRef(CBaseStars *stars) : _stars(stars) {}
+ CBaseStarRef() : _stars(nullptr) {}
virtual ~CBaseStarRef() {}
void process(CSurfaceArea *surface, CStarControlSub12 *sub12);
@@ -49,8 +49,8 @@ private:
public:
int _index;
public:
- CStarRef1(CBaseStar *star, const Common::Point &pt) :
- CBaseStarRef(star), _position(pt), _index(-1) {}
+ CStarRef1(CBaseStars *stars, const Common::Point &pt) :
+ CBaseStarRef(stars), _position(pt), _index(-1) {}
virtual ~CStarRef1() {}
virtual bool check(const Common::Point &pt, int index);
@@ -62,8 +62,8 @@ private:
public:
int _index;
public:
- CStarRef2(CBaseStar *star, Common::Array<CStarPosition> *positions) :
- CBaseStarRef(star), _positions(positions), _index(0) {}
+ CStarRef2(CBaseStars *stars, Common::Array<CStarPosition> *positions) :
+ CBaseStarRef(stars), _positions(positions), _index(0) {}
virtual ~CStarRef2() {}
virtual bool check(const Common::Point &pt, int index);
@@ -73,7 +73,7 @@ class CStarRef3 : public CBaseStarRef {
public:
int _index;
public:
- CStarRef3(CBaseStar *star) :CBaseStarRef(star), _index(0) {}
+ CStarRef3(CBaseStars *stars) :CBaseStarRef(stars), _index(0) {}
virtual ~CStarRef3() {}
virtual bool check(const Common::Point &pt, int index);
More information about the Scummvm-git-logs
mailing list