Skip to content

Commit

Permalink
TITANIC: Added star keyboard handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Mar 3, 2017
1 parent 297cb6b commit 51f2420
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 40 deletions.
4 changes: 2 additions & 2 deletions engines/titanic/star_control/base_star.cpp
Expand Up @@ -165,8 +165,8 @@ void CBaseStar::draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar
vector._x = entry._val._v1;
vector._y = entry._val._v2;
vector._z = entry._val._v3;
v4 = vector._x * sub6._matrix._row1._z + vector._y * sub6._matrix._row2._z
+ vector._z * sub6._matrix._row3._z + sub6._field2C;
v4 = vector._x * sub6._row1._z + vector._y * sub6._row2._z
+ vector._z * sub6._row3._z + sub6._field2C;
if (v4 <= minVal)
continue;

Expand Down
5 changes: 2 additions & 3 deletions engines/titanic/star_control/star_control_sub12.cpp
Expand Up @@ -122,7 +122,7 @@ void CStarControlSub12::proc14(int v) {
_handlerP->proc9(&vector, v, &matrix);
}

void CStarControlSub12::proc15(int v) {
void CStarControlSub12::proc15(CErrorCode *errorCode) {
if (!_matrix1)
_matrix1 = new FMatrix();
if (!_matrix2)
Expand All @@ -133,8 +133,7 @@ void CStarControlSub12::proc15(int v) {

FVector v1 = _sub13._position;
FVector v2 = _sub13._position;
CErrorCode errorCode;
_handlerP->proc11(errorCode, v2, _matrix2);
_handlerP->proc11(*errorCode, v2, _matrix2);

if (v1 != v2) {
_sub13.setPosition(v2);
Expand Down
3 changes: 2 additions & 1 deletion engines/titanic/star_control/star_control_sub12.h
Expand Up @@ -28,6 +28,7 @@
#include "titanic/star_control/fpoint.h"
#include "titanic/star_control/star_control_sub13.h"
#include "titanic/star_control/star_control_sub20.h"
#include "titanic/star_control/error_code.h"

namespace Titanic {

Expand Down Expand Up @@ -77,7 +78,7 @@ class CStarControlSub12 {
virtual void proc12(double v1, double v2);
virtual void proc13(CStarControlSub13 *dest);
virtual void proc14(int v);
virtual void proc15(int v);
virtual void proc15(CErrorCode *errorCode);
virtual void proc16();
virtual void proc17();
virtual void proc18();
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/star_control/star_control_sub13.cpp
Expand Up @@ -129,7 +129,7 @@ void CStarControlSub13::setPosition(const FVector &v) {
void CStarControlSub13::setPosition(const CStarControlSub6 &sub6) {
FVector vector;
_position.fn5(&vector, &sub6);
_position = sub6._matrix._row1;
_position = sub6._row1;
_fieldD4 = 0;
}

Expand Down
60 changes: 31 additions & 29 deletions engines/titanic/star_control/star_control_sub6.cpp
Expand Up @@ -48,7 +48,7 @@ void CStarControlSub6::deinit() {
}

void CStarControlSub6::clear() {
_matrix.clear();
FMatrix::clear();
_field24 = 0;
_field28 = 0;
_field2C = 0;
Expand All @@ -61,39 +61,39 @@ void CStarControlSub6::set(int mode, double amount) {

switch (mode) {
case 0:
_matrix._row1._x = 1.0;
_matrix._row1._y = 0.0;
_matrix._row1._z = 0.0;
_matrix._row2._x = 0.0;
_matrix._row2._y = cosVal;
_matrix._row2._z = sinVal;
_matrix._row3._x = 0.0;
_matrix._row3._y = -sinVal;
_matrix._row3._z = cosVal;
_row1._x = 1.0;
_row1._y = 0.0;
_row1._z = 0.0;
_row2._x = 0.0;
_row2._y = cosVal;
_row2._z = sinVal;
_row3._x = 0.0;
_row3._y = -sinVal;
_row3._z = cosVal;
break;

case 1:
_matrix._row1._x = cosVal;
_matrix._row1._y = 0.0;
_matrix._row1._z = sinVal;
_matrix._row2._x = 0.0;
_matrix._row2._y = 1.0;
_matrix._row2._z = 0.0;
_matrix._row3._x = -sinVal;
_matrix._row3._y = 0.0;
_matrix._row3._z = sinVal;
_row1._x = cosVal;
_row1._y = 0.0;
_row1._z = sinVal;
_row2._x = 0.0;
_row2._y = 1.0;
_row2._z = 0.0;
_row3._x = -sinVal;
_row3._y = 0.0;
_row3._z = sinVal;
break;

case 2:
_matrix._row1._x = cosVal;
_matrix._row1._y = sinVal;
_matrix._row1._z = 0.0;
_matrix._row2._x = -sinVal;
_matrix._row2._y = cosVal;
_matrix._row2._z = 0.0;
_matrix._row3._x = 0.0;
_matrix._row3._y = 0.0;
_matrix._row3._z = 1.0;
_row1._x = cosVal;
_row1._y = sinVal;
_row1._z = 0.0;
_row2._x = -sinVal;
_row2._y = cosVal;
_row2._z = 0.0;
_row3._x = 0.0;
_row3._y = 0.0;
_row3._z = 1.0;
break;

default:
Expand All @@ -106,7 +106,9 @@ void CStarControlSub6::set(int mode, double amount) {
}

void CStarControlSub6::copyFrom(const CStarControlSub6 *src) {
_matrix = src->_matrix;
_row1 = src->_row1;
_row2 = src->_row2;
_row3 = src->_row3;
_field24 = src->_field24;
_field28 = src->_field28;
_field2C = src->_field2C;
Expand Down
3 changes: 1 addition & 2 deletions engines/titanic/star_control/star_control_sub6.h
Expand Up @@ -27,14 +27,13 @@

namespace Titanic {

class CStarControlSub6 {
class CStarControlSub6 : public FMatrix {
private:
static CStarControlSub6 *_static;
public:
static void init();
static void deinit();
public:
FMatrix _matrix;
int _field24;
int _field28;
int _field2C;
Expand Down
76 changes: 74 additions & 2 deletions engines/titanic/star_control/star_view.cpp
Expand Up @@ -25,6 +25,7 @@
#include "titanic/star_control/star_control.h"
#include "titanic/star_control/star_field.h"
#include "titanic/core/game_object.h"
#include "titanic/messages/pet_messages.h"
#include "titanic/titanic.h"

namespace Titanic {
Expand Down Expand Up @@ -145,7 +146,7 @@ bool CStarView::MouseMoveMsg(int unused, const Point &pt) {

bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
CStarControlSub6 sub6;
// int v = _starField ? _starField->get88() : -1;
int v = _starField ? _starField->get88() : -1;

switch (key) {
case Common::KEYCODE_TAB:
Expand All @@ -155,7 +156,78 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) {
}
break;

// TODO: More switch cases
case Common::KEYCODE_l: {
CPetControl *pet = _owner->getPetControl();
if (pet && pet->_remoteTarget) {
CPETStarFieldLockMsg lockMsg(1);
lockMsg.execute(pet->_remoteTarget);
}
return true;
}

case Common::KEYCODE_d: {
CPetControl *pet = _owner->getPetControl();
if (pet && pet->_remoteTarget) {
CPETStarFieldLockMsg lockMsg(0);
lockMsg.execute(pet->_remoteTarget);
}
return true;
}

case Common::KEYCODE_z:
case Common::KEYCODE_c:
if (v == -1) {
sub6.set(key == Common::KEYCODE_z ? MODE_PHOTO : MODE_STARFIELD, 1.0);
_sub12.proc22(sub6);
_sub12.proc15(errorCode);
return true;
}
break;

case Common::KEYCODE_SEMICOLON:
if (v == -1) {
_sub12.proc16();
errorCode->set();
return true;
}
break;

case Common::KEYCODE_PERIOD:
if (v == -1) {
_sub12.proc17();
errorCode->set();
return true;
}
break;

case Common::KEYCODE_SPACE:
if (v == -1) {
_sub12.proc19();
errorCode->set();
return true;
}
break;

case Common::KEYCODE_x:
if (v == -1) {
sub6.set(MODE_PHOTO, -1.0);
_sub12.proc22(sub6);
_sub12.proc15(errorCode);
return true;
}
break;

case Common::KEYCODE_QUOTE:
if (v == -1) {
sub6.set(MODE_STARFIELD, -1.0);
_sub12.proc22(sub6);
_sub12.proc15(errorCode);
return true;
}
break;

default:
break;
}

return false;
Expand Down

0 comments on commit 51f2420

Please sign in to comment.