From eebb42be89b3fe520bb4d175a0c0fac3c3291841 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 30 Jun 2016 23:40:58 -0400 Subject: TITANIC: Work on CBaseStar and CStarControlSub4 classes --- engines/titanic/module.mk | 2 +- engines/titanic/star_control/base_star.cpp | 63 +++++++++++++++++ engines/titanic/star_control/base_star.h | 81 ++++++++++++++++++++++ engines/titanic/star_control/star_control.cpp | 4 +- engines/titanic/star_control/star_control.h | 5 +- engines/titanic/star_control/star_control_sub2.cpp | 20 ++++++ engines/titanic/star_control/star_control_sub2.h | 9 ++- engines/titanic/star_control/star_control_sub3.cpp | 35 ---------- engines/titanic/star_control/star_control_sub3.h | 58 ---------------- engines/titanic/star_control/star_control_sub4.cpp | 18 ++++- engines/titanic/star_control/star_control_sub4.h | 16 +++-- engines/titanic/star_control/star_control_sub6.cpp | 4 +- engines/titanic/star_control/star_control_sub7.cpp | 8 +++ engines/titanic/star_control/star_control_sub7.h | 8 ++- 14 files changed, 217 insertions(+), 114 deletions(-) create mode 100644 engines/titanic/star_control/base_star.cpp create mode 100644 engines/titanic/star_control/base_star.h delete mode 100644 engines/titanic/star_control/star_control_sub3.cpp delete mode 100644 engines/titanic/star_control/star_control_sub3.h (limited to 'engines/titanic') diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index 3c752bf13a..7138f57464 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -419,7 +419,7 @@ MODULE_OBJS := \ star_control/star_control.o \ star_control/star_control_sub1.o \ star_control/star_control_sub2.o \ - star_control/star_control_sub3.o \ + star_control/base_star.o \ star_control/star_control_sub4.o \ star_control/star_control_sub5.o \ star_control/star_control_sub6.o \ diff --git a/engines/titanic/star_control/base_star.cpp b/engines/titanic/star_control/base_star.cpp new file mode 100644 index 0000000000..c8f55a7931 --- /dev/null +++ b/engines/titanic/star_control/base_star.cpp @@ -0,0 +1,63 @@ +/* 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" + +namespace Titanic { + +CBaseStar::CBaseStar() : _fieldC(1), _minVal(0.0), _maxVal(1.0), _range(0.0) { +} + +void CBaseStar::proc2(int v1, int v2, int v3) { + error("TODO"); +} + +void CBaseStar::clear() { + if (!_data.empty()) { + if (_fieldC) + _data.clear(); + } +} + +void CBaseStar::initialize() { + _minVal = 9.9999998e10; + _maxVal = -9.9999998e10; + _sub4.initialize(); + + for (uint idx = 0; idx < _data.size(); ++idx) { + const CBaseStarEntry *entry = getDataPtr(idx); + _sub4.checkEntry(entry->_val); + + if (entry->_value < _minVal) + _minVal = entry->_value; + if (entry->_value > _maxVal) + _maxVal = entry->_value; + } + + _range = (_maxVal - _minVal) / 1.0; +} + +CBaseStarEntry *CBaseStar::getDataPtr(int index) { + return (index >= 0 && index < (int)_data.size()) ? &_data[index] : nullptr; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/base_star.h b/engines/titanic/star_control/base_star.h new file mode 100644 index 0000000000..20dbacedb6 --- /dev/null +++ b/engines/titanic/star_control/base_star.h @@ -0,0 +1,81 @@ +/* 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/star_control_sub4.h" + +namespace Titanic { + +struct CBaseStarEntry { + int _field0; + double _value; + CBaseStarVal _val; +}; + +class CBaseStar { +protected: + Common::Array _data; + int _fieldC; + CStarControlSub4 _sub4; + double _minVal; + double _maxVal; + double _range; +public: + CBaseStar(); + virtual ~CBaseStar() {} + + virtual void proc2(int v1, int v2, int v3); + virtual bool loadYale(int v1) { return true; } + virtual bool proc4(int v1, int v2, int v3, int v4, int v5) { return false; } + virtual bool proc5(int v1) { return false; } + virtual bool loadStar() { return false; } + virtual bool proc7(int v1, int v2) { return true; } + + /** + * 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(); + + /** + * Get a pointer to a data entry + */ + CBaseStarEntry *getDataPtr(int index); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB3_H */ diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp index 9880e6f28c..d8b7d1206c 100644 --- a/engines/titanic/star_control/star_control.cpp +++ b/engines/titanic/star_control/star_control.cpp @@ -25,8 +25,8 @@ namespace Titanic { -CStarControl::CStarControl() : _fieldBC(0), _field80A0(0), - _field80A4(0), _field80A8(0), _field80AC(0), _field80B0(0) { +CStarControl::CStarControl() : _fieldBC(0), _field80B0(0), + _starRect(20, 10, 620, 350) { } void CStarControl::save(SimpleFile *file, int indent) { diff --git a/engines/titanic/star_control/star_control.h b/engines/titanic/star_control/star_control.h index 1bd2dec92b..be8ee752cf 100644 --- a/engines/titanic/star_control/star_control.h +++ b/engines/titanic/star_control/star_control.h @@ -34,10 +34,7 @@ private: int _fieldBC; CStarControlSub1 _sub1; CStarControlSub11 _sub11; - int _field80A0; - int _field80A4; - int _field80A8; - int _field80AC; + Rect _starRect; int _field80B0; public: CLASSDEF diff --git a/engines/titanic/star_control/star_control_sub2.cpp b/engines/titanic/star_control/star_control_sub2.cpp index 9b9a5f84ad..d221c9fb0e 100644 --- a/engines/titanic/star_control/star_control_sub2.cpp +++ b/engines/titanic/star_control/star_control_sub2.cpp @@ -24,5 +24,25 @@ namespace Titanic { +bool CStarControlSub2::proc3(int v1) { + clear(); + // TODO + return true; +} + +bool CStarControlSub2::proc4(int v1, int v2, int v3, int v4, int v5) { + // TODO + return true; +} + +bool CStarControlSub2::proc6() { + // TODO + return true; +} + +bool CStarControlSub2::proc7(int v1, int v2) { + // TODO + return true; +} } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub2.h b/engines/titanic/star_control/star_control_sub2.h index 2bae029c96..33fdb4259a 100644 --- a/engines/titanic/star_control/star_control_sub2.h +++ b/engines/titanic/star_control/star_control_sub2.h @@ -23,13 +23,18 @@ #ifndef TITANIC_STAR_CONTROL_SUB2_H #define TITANIC_STAR_CONTROL_SUB2_H -#include "titanic/star_control/star_control_sub3.h" +#include "titanic/star_control/base_star.h" namespace Titanic { -class CStarControlSub2: public CStarControlSub3 { +class CStarControlSub2: public CBaseStar { public: virtual ~CStarControlSub2() {} + + virtual bool proc3(int v1); + virtual bool proc4(int v1, int v2, int v3, int v4, int v5); + virtual bool proc6(); + virtual bool proc7(int v1, int v2); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub3.cpp b/engines/titanic/star_control/star_control_sub3.cpp deleted file mode 100644 index c65a308535..0000000000 --- a/engines/titanic/star_control/star_control_sub3.cpp +++ /dev/null @@ -1,35 +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/star_control_sub3.h" - -namespace Titanic { - -CStarControlSub3::CStarControlSub3() : _field4(0), _field8(0), - _fieldC(1), _field28(0), _field2C(0x3F800000) { -} - -void CStarControlSub3::proc2() { - error("TODO"); -} - -} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub3.h b/engines/titanic/star_control/star_control_sub3.h deleted file mode 100644 index 08d0835e1c..0000000000 --- a/engines/titanic/star_control/star_control_sub3.h +++ /dev/null @@ -1,58 +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/star_control_sub4.h" - -namespace Titanic { - -class CStarControlSub3 { -protected: - int _field4; - int _field8; - int _fieldC; - CStarControlSub4 _sub4; - int _field28; - int _field2C; -public: - CStarControlSub3(); - virtual ~CStarControlSub3() {} - - virtual void proc2(); - virtual int proc3() { return 1; } - virtual int proc4() { return 0; } - virtual int proc5() { return 0; } - virtual int proc6() { return 0; } - virtual int proc7() { return 1; } - - virtual void load(SimpleFile *file) {} - - virtual void proc9() {} - -}; - -} // End of namespace Titanic - -#endif /* TITANIC_STAR_CONTROL_SUB3_H */ diff --git a/engines/titanic/star_control/star_control_sub4.cpp b/engines/titanic/star_control/star_control_sub4.cpp index 27ef859f51..f765acbbc1 100644 --- a/engines/titanic/star_control/star_control_sub4.cpp +++ b/engines/titanic/star_control/star_control_sub4.cpp @@ -20,12 +20,26 @@ * */ +#include "common/algorithm.h" #include "titanic/star_control/star_control_sub4.h" namespace Titanic { -CStarControlSub4::CStarControlSub4() : _field0(0), - _field4(0), _fieldC(0), _field10(0), _field14(0) { +CStarControlSub4::CStarControlSub4() { +} + +void CStarControlSub4::initialize() { + _min._v1 = _min._v2 = _min._v3 = 9.9999994e27; + _max._v1 = _max._v2 = _max._v3 = -9.9999994e27; +} + +void CStarControlSub4::checkEntry(const CBaseStarVal &val) { + _min._v1 = MIN(_min._v1, val._v1); + _min._v2 = MIN(_min._v2, val._v2); + _min._v3 = MIN(_min._v3, val._v3); + _max._v1 = MAX(_max._v1, val._v1); + _max._v2 = MAX(_max._v2, val._v2); + _max._v3 = MAX(_max._v3, val._v3); } } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub4.h b/engines/titanic/star_control/star_control_sub4.h index 4aa75f8566..f0fcfaf7f4 100644 --- a/engines/titanic/star_control/star_control_sub4.h +++ b/engines/titanic/star_control/star_control_sub4.h @@ -25,17 +25,21 @@ namespace Titanic { +struct CBaseStarVal { + double _v1, _v2, _v3; + CBaseStarVal() : _v1(0), _v2(0), _v3(0) {} +}; + class CStarControlSub4 { private: - int _field0; - int _field4; - int _field8; - int _fieldC; - int _field10; - int _field14; + CBaseStarVal _min; + CBaseStarVal _max; public: CStarControlSub4(); + void initialize(); + + void checkEntry(const CBaseStarVal &val); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub6.cpp b/engines/titanic/star_control/star_control_sub6.cpp index 79937b7cab..c4161813f4 100644 --- a/engines/titanic/star_control/star_control_sub6.cpp +++ b/engines/titanic/star_control/star_control_sub6.cpp @@ -32,11 +32,11 @@ void CStarControlSub6::clear() { _field0 = 0x3F800000; _field4 = 0; _field8 = 0; - _fieldC = 0), + _fieldC = 0; _field10 = 0x3F800000; _field14 = 0; _field18 = 0; - _field1C = 0), + _field1C = 0; _field20 = 0x3F800000; _field24 = 0; _field28 = 0; diff --git a/engines/titanic/star_control/star_control_sub7.cpp b/engines/titanic/star_control/star_control_sub7.cpp index 0677e33558..b33f8be582 100644 --- a/engines/titanic/star_control/star_control_sub7.cpp +++ b/engines/titanic/star_control/star_control_sub7.cpp @@ -24,5 +24,13 @@ namespace Titanic { +void CStarControlSub7::proc2(int v1, int v2, int v3) { + // TODO +} + +bool CStarControlSub7::proc5(int v1) { + // TODO + return true; +} } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub7.h b/engines/titanic/star_control/star_control_sub7.h index 9999423d94..b73124ddd7 100644 --- a/engines/titanic/star_control/star_control_sub7.h +++ b/engines/titanic/star_control/star_control_sub7.h @@ -23,11 +23,15 @@ #ifndef TITANIC_STAR_CONTROL_SUB7_H #define TITANIC_STAR_CONTROL_SUB7_H -#include "titanic/star_control/star_control_sub3.h" +#include "titanic/star_control/base_star.h" namespace Titanic { -class CStarControlSub7 : public CStarControlSub3 { +class CStarControlSub7 : public CBaseStar { public: + virtual ~CStarControlSub7() { clear(); } + + virtual void proc2(int v1, int v2, int v3); + virtual bool proc5(int v1); }; } // End of namespace Titanic -- cgit v1.2.3