diff options
author | Matthew Stewart | 2018-07-23 05:36:32 -0400 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-09 08:37:30 +0200 |
commit | eff87179da0554446837a732bb6855f6c7f8a890 (patch) | |
tree | 87ace1e7847dcf6d589f60a33fb5acfcdc1d91e7 /engines/startrek/math.cpp | |
parent | 565bf0e96750588e8a7f6816e79683e97896f8de (diff) | |
download | scummvm-rg350-eff87179da0554446837a732bb6855f6c7f8a890.tar.gz scummvm-rg350-eff87179da0554446837a732bb6855f6c7f8a890.tar.bz2 scummvm-rg350-eff87179da0554446837a732bb6855f6c7f8a890.zip |
STARTREK: Half-done implementation of drawR3Shape
Handles drawing, scaling, probably rotating objects in space.
Diffstat (limited to 'engines/startrek/math.cpp')
-rw-r--r-- | engines/startrek/math.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/engines/startrek/math.cpp b/engines/startrek/math.cpp index 80aa39ee6a..da81b1fa85 100644 --- a/engines/startrek/math.cpp +++ b/engines/startrek/math.cpp @@ -24,7 +24,7 @@ namespace StarTrek { -Fixed14 StarTrekEngine::sin(Fixed8 angle) { +Fixed14 StarTrekEngine::sin(Angle angle) { int16 i = angle.raw(); if (angle < 0) { i %= 0x400; @@ -46,14 +46,14 @@ Fixed14 StarTrekEngine::sin(Fixed8 angle) { f = -_sineTable.getTable()[i & 0xff]; else if (i < 0x400) f = -_sineTable.getTable()[256 - (i & 0xff)]; - return Fixed16(f); + return Fixed14(f); } -Fixed14 StarTrekEngine::cos(Fixed8 angle) { +Fixed14 StarTrekEngine::cos(Angle angle) { return sin(angle + 1.0); } -Fixed8 StarTrekEngine::atan2(int32 deltaX, int32 deltaY) { +Angle StarTrekEngine::atan2(int32 deltaX, int32 deltaY) { const int16 atanTable[] = { 0x0000, 0x0064, 0x00c9, 0x012d, 0x0192, 0x01f6, 0x025b, 0x02c0, 0x0324, 0x0389, 0x03ee, 0x0453, 0x04b8, 0x051d, 0x0582, 0x05e8, @@ -85,9 +85,9 @@ Fixed8 StarTrekEngine::atan2(int32 deltaX, int32 deltaY) { Fixed14 ratio; if (deltaY > deltaX) - ratio = Fixed14::fromRaw(((deltaX & 0xffff0000) >> 2) / (deltaY >> 16)); + ratio = Fixed14::fromRaw(((deltaX & 0xffff0000) >> 2) / deltaY); else - ratio = Fixed14::fromRaw(((deltaY & 0xffff0000) >> 2) / (deltaX >> 16)); + ratio = Fixed14::fromRaw(((deltaY & 0xffff0000) >> 2) / deltaX); int16 endIndex = 128; int16 index = 0; @@ -123,7 +123,7 @@ Fixed8 StarTrekEngine::atan2(int32 deltaX, int32 deltaY) { angle = -256 + angle; } - return Fixed8::fromRaw(angle); + return Angle::fromRaw(angle); } } |