From d810e626ae70554bbc994393811b5b8a13cfeeb0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 28 Mar 2016 22:48:44 -0400 Subject: TITANIC: Implemented CGameObject::checkPoint --- engines/titanic/core/game_object.cpp | 26 +++++++++++++++++++++++--- engines/titanic/core/game_object.h | 6 +++++- engines/titanic/video_surface.cpp | 19 +++++++++++++++++++ engines/titanic/video_surface.h | 15 +++++++++++++++ 4 files changed, 62 insertions(+), 4 deletions(-) diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 834364591d..ac02f62fb5 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -129,9 +129,29 @@ void CGameObject::stopMovie() { _surface->stopMovie(); } -bool CGameObject::checkPoint(const Point &pt, int v0, int v1) { - warning("TODO: CGameObject::checkPoint"); - return false; +bool CGameObject::checkPoint(const Point &pt, bool ignore40, bool visibleOnly) { + if ((!_visible && visibleOnly) || !_bounds.contains(pt)) + return false; + + if (ignore40 || _field40) + return true; + + if (!_surface) { + if (_frameNumber == -1) + return true; + loadFrame(_frameNumber); + if (!_surface) + return true; + } + + Common::Point pixelPos = pt - _bounds; + if (_surface->_blitStyleFlag) { + pixelPos.y = ((_bounds.height() - _bounds.top) / 2) * 2 - pixelPos.y; + } + + uint transColor = _surface->getTransparencyColor(); + uint pixel = _surface->getPixel(pixelPos); + return pixel != transColor; } void CGameObject::draw(CScreenManager *screenManager) { diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index ced8663ed3..dccef71cfe 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -142,7 +142,11 @@ public: */ void stopMovie(); - bool checkPoint(const Point &pt, int v0, int v1); + /** + * Checks the passed point is validly in the object, + * with extra checking of object flags status + */ + bool checkPoint(const Point &pt, bool ignore40 = false, bool visibleOnly = false); void fn1(int val1, int val2, int val3); diff --git a/engines/titanic/video_surface.cpp b/engines/titanic/video_surface.cpp index e8f0e03136..1708504a80 100644 --- a/engines/titanic/video_surface.cpp +++ b/engines/titanic/video_surface.cpp @@ -143,6 +143,11 @@ void CVideoSurface::blitRect2(const Rect &srcRect, const Rect &destRect, CVideoS blitRect1(srcRect, destRect, src); } +uint16 CVideoSurface::getTransparencyColor() const { + // TODO: Do like the original + return 0xF81F; +} + /*------------------------------------------------------------------------*/ OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, DirectDrawSurface *surface) : @@ -276,6 +281,20 @@ bool OSVideoSurface::load() { } } +uint16 OSVideoSurface::getPixel(const Common::Point &pt) { + if (!loadIfReady()) + return 0; + + if (pt.x >= 0 && pt.y >= 0 && pt.x < getWidth() && pt.y < getHeight()) { + lock(); + uint16 pixel = *(uint16 *)_rawSurface->getBasePtr(pt.x, pt.y); + unlock(); + return pixel; + } else { + return getTransparencyColor(); + } +} + void OSVideoSurface::shiftColors() { if (!loadIfReady()) return; diff --git a/engines/titanic/video_surface.h b/engines/titanic/video_surface.h index b2390fb358..6090861404 100644 --- a/engines/titanic/video_surface.h +++ b/engines/titanic/video_surface.h @@ -134,6 +134,11 @@ public: virtual int proc26() = 0; + /** + * Gets the pixel at the specified position within the surface + */ + virtual uint16 getPixel(const Common::Point &pt) = 0; + /** * Shifts the colors of the surface.. maybe greys it out? */ @@ -181,6 +186,11 @@ public: void set40(void *v) { _field40 = v; } uint16 *getPixels() { return (uint16 *)_rawSurface->getPixels(); } + + /** + * Returns the transparent color + */ + uint16 getTransparencyColor() const; }; class OSVideoSurface : public CVideoSurface { @@ -245,6 +255,11 @@ public: virtual int proc26(); + /** + * Gets the pixel at the specified position within the surface + */ + virtual uint16 getPixel(const Common::Point &pt); + /** * Shifts the colors of the surface.. maybe greys it out? */ -- cgit v1.2.3