diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/avalanche/graphics.cpp | 18 | ||||
-rw-r--r-- | engines/avalanche/graphics.h | 4 | ||||
-rw-r--r-- | engines/avalanche/lucerna2.cpp | 69 | ||||
-rw-r--r-- | engines/avalanche/lucerna2.h | 8 |
4 files changed, 82 insertions, 17 deletions
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index 7870f1d20f..9e772d393c 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -119,7 +119,8 @@ void Graphics::drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16 } } -void Graphics::drawArc(const ::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, byte color) { +Common::Point Graphics::drawArc(const ::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, byte color) { + Common::Point endPoint; const double pi = 3.14; const double convfac = pi / 180.0; @@ -134,8 +135,10 @@ void Graphics::drawArc(const ::Graphics::Surface &surface, int16 x, int16 y, int /* check for an ellipse with negligable x and y radius */ if ((xRadius <= 1) && (yRadius <= 1)) { - *(byte *)_scrolls.getBasePtr(x,y) = color; - return; + *(byte *)_scrolls.getBasePtr(x, y) = color; + endPoint.x = x; + endPoint.y = y; + return endPoint; } /* check if valid angles */ @@ -152,7 +155,7 @@ void Graphics::drawArc(const ::Graphics::Surface &surface, int16 x, int16 y, int /* approximate the number of pixels required by using the circumference */ /* equation of an ellipse. */ - uint16 numOfPixels=floor(sqrt(3.0)*sqrt(pow(float(xRadius), 2)+pow(float(yRadius), 2)) + 0.5); + uint16 numOfPixels=floor(sqrt(3.0)*sqrt(pow(double(xRadius), 2)+pow(double(yRadius), 2)) + 0.5); /* Calculate the angle precision required */ double delta = 90.0 / numOfPixels; @@ -166,6 +169,11 @@ void Graphics::drawArc(const ::Graphics::Surface &surface, int16 x, int16 y, int /* 1 pixel is sometimes not drawn (JM) */ uint16 deltaEnd = 91; + // Set the end point. + double tempTerm = endAngle * convfac; + endPoint.x = floor(xRadius * cos(tempTerm) + 0.5) + x; + endPoint.y = floor(yRadius * sin(tempTerm + pi) + 0.5) + y; + /* Calculate points */ int16 xNext = xRadius; int16 yNext = 0; @@ -196,6 +204,8 @@ void Graphics::drawArc(const ::Graphics::Surface &surface, int16 x, int16 y, int j += delta; } while (j <= deltaEnd); + + return endPoint; } void Graphics::drawPieSlice(const ::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, byte color) { diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index c3049327e8..ce4218e19d 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -31,6 +31,7 @@ #include "common/file.h" #include "graphics/surface.h" +#include "common/rect.h" namespace Avalanche { class AvalancheEngine; @@ -87,8 +88,9 @@ public: void drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16 y); - void drawArc(const ::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, byte color); + Common::Point drawArc(const ::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, byte color); // Taken from Free Pascal's Procedure InternalEllipseDefault. Used to replace Pascal's procedure arc. + // Returns the end point of the arc. (Needed in Lucerna::lucerna_clock().) void drawPieSlice(const ::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, byte color); diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp index b78c8ce51d..740fa8c8e0 100644 --- a/engines/avalanche/lucerna2.cpp +++ b/engines/avalanche/lucerna2.cpp @@ -1082,24 +1082,77 @@ void Lucerna::showrw() { // It's data is loaded in load_digits(). -void Lucerna::calchand(uint16 ang, uint16 length, /*arccoordstype &a,*/ byte c) { - warning("STUB: Lucerna::calchand()"); +void Lucerna::calchand(uint16 ang, uint16 length, Common::Point &a, byte c) { + if (ang > 900) { + a.x = 177; + return; + } + + a = _vm->_graphics->drawArc(_vm->_graphics->_surface, xm, ym, 449 - ang, 450 - ang, length, c); } -void Lucerna::hand(/*arccoordstype a,*/ byte c) { - warning("STUB: Lucerna::hand()"); +void Lucerna::hand(const Common::Point &a, byte c) { + if (a.x == 177) + return; + + _vm->_graphics->_surface.drawLine(xm, ym, a.x, a.y, c); } -void Lucerna::chime() { - warning("STUB: Lucerna::chime()"); +void Lucerna::refresh_hands() { + const bytefield clockspace = {61, 166, 66, 200}; + + for (byte page_ = 0; page_ < 2; page_++) + _vm->_trip->getset[page_].remember(clockspace); } void Lucerna::plothands() { - warning("STUB: Lucerna::plothands()"); + /* off;*/ + //setactivepage(3); + calchand(_vm->_gyro->onh, 14, ah, yellow); + calchand(_vm->_gyro->om * 6, 17, am, yellow); + hand(ah, brown); + hand(am, brown); + + calchand(nh, 14, ah, brown); + calchand(_vm->_gyro->m * 6, 17, am, brown); + hand(ah, yellow); + hand(am, yellow); + + //setactivepage(1 - cp); + + refresh_hands(); + + /* on;*/ +} + +void Lucerna::chime() { + warning("STUB: Lucerna::chime()"); } void Lucerna::clock_lucerna() { - warning("STUB: Lucerna::clock_lucerna()"); + /* ...Clock. */ + TimeDate t; + _vm->_system->getTimeAndDate(t); + _vm->_gyro->h = t.tm_hour; + _vm->_gyro->m = t.tm_min; + _vm->_gyro->s = t.tm_sec; + + nh = (_vm->_gyro->h % 12) * 30 + _vm->_gyro->m / 2; + + if (_vm->_gyro->oh != _vm->_gyro->h) { + plothands(); + chime(); + } + + if (_vm->_gyro->om != _vm->_gyro->m) + plothands(); + + if ((_vm->_gyro->h == 0) && (_vm->_gyro->oh != 0) && (_vm->_gyro->oh != 17717)) + _vm->_scrolls->display(Common::String("Good morning!") + 13 + 13 + "Yes, it's just past midnight. Are you having an all-night Avvy session? Glad you like the game that much!"); + + _vm->_gyro->oh = _vm->_gyro->h; + _vm->_gyro->onh = nh; + _vm->_gyro->om = _vm->_gyro->m; } diff --git a/engines/avalanche/lucerna2.h b/engines/avalanche/lucerna2.h index efb45e2878..f0ecf2bad7 100644 --- a/engines/avalanche/lucerna2.h +++ b/engines/avalanche/lucerna2.h @@ -125,7 +125,7 @@ private: //Clock static const int16 xm = 510; static const int16 ym = 183; - //arccoordstype ah, am; http://www.freepascal.org/docs-html/rtl/graph/arccoordstype.html + Common::Point ah, am; uint16 nh; @@ -159,11 +159,11 @@ private: void fadein(byte n); // clock_lucerna - void calchand(uint16 ang, uint16 length,/* arccoordstype &a,*/ byte c); - void hand(/*arccoordstype a,*/ byte c); - void chime(); + void calchand(uint16 ang, uint16 length, Common::Point &a, byte c); + void hand(const Common::Point &a, byte c); void refresh_hands(); void plothands(); + void chime(); }; |