TITANIC: Work on CBaseStar and CStarControlSub4 classes

This commit is contained in:
Paul Gilbert 2016-06-30 23:40:58 -04:00
parent d436ce5dae
commit eebb42be89
12 changed files with 142 additions and 39 deletions

View File

@ -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 \

View File

@ -20,16 +20,44 @@
*
*/
#include "titanic/star_control/star_control_sub3.h"
#include "titanic/star_control/base_star.h"
namespace Titanic {
CStarControlSub3::CStarControlSub3() : _field4(0), _field8(0),
_fieldC(1), _field28(0), _field2C(0x3F800000) {
CBaseStar::CBaseStar() : _fieldC(1), _minVal(0.0), _maxVal(1.0), _range(0.0) {
}
void CStarControlSub3::proc2() {
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

View File

@ -28,29 +28,52 @@
namespace Titanic {
class CStarControlSub3 {
struct CBaseStarEntry {
int _field0;
double _value;
CBaseStarVal _val;
};
class CBaseStar {
protected:
int _field4;
int _field8;
Common::Array<CBaseStarEntry> _data;
int _fieldC;
CStarControlSub4 _sub4;
int _field28;
int _field2C;
double _minVal;
double _maxVal;
double _range;
public:
CStarControlSub3();
virtual ~CStarControlSub3() {}
CBaseStar();
virtual ~CBaseStar() {}
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 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) {}
virtual void proc9() {}
/**
* 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

View File

@ -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) {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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