diff options
author | Martin Kiewitz | 2016-02-20 05:38:22 +0100 |
---|---|---|
committer | Martin Kiewitz | 2016-02-20 05:38:22 +0100 |
commit | 19283b94a975d778f4882dedabe07be68cf1822e (patch) | |
tree | fe75f74e4d1e809ce09f21add1dfc0b58d7892dc /engines/sci | |
parent | 8706f8c28836b171886e5f0092a773863a2fedd3 (diff) | |
download | scummvm-rg350-19283b94a975d778f4882dedabe07be68cf1822e.tar.gz scummvm-rg350-19283b94a975d778f4882dedabe07be68cf1822e.tar.bz2 scummvm-rg350-19283b94a975d778f4882dedabe07be68cf1822e.zip |
SCI32: Some work on kIsOnMe
Plenty of hotspots seem to work now
Not fully done yet
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/kgraphics32.cpp | 28 | ||||
-rw-r--r-- | engines/sci/graphics/celobj32.h | 2 | ||||
-rw-r--r-- | engines/sci/graphics/frameout.cpp | 67 | ||||
-rw-r--r-- | engines/sci/graphics/frameout.h | 2 |
4 files changed, 73 insertions, 26 deletions
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp index 85518bae99..c3eb0b520f 100644 --- a/engines/sci/engine/kgraphics32.cpp +++ b/engines/sci/engine/kgraphics32.cpp @@ -148,31 +148,9 @@ reg_t kIsOnMe(EngineState *s, int argc, reg_t *argv) { uint16 x = argv[0].toUint16(); uint16 y = argv[1].toUint16(); reg_t targetObject = argv[2]; - uint16 illegalBits = argv[3].getOffset(); - Common::Rect nsRect = g_sci->_gfxCompare->getNSRect(targetObject); - - uint16 itemX = readSelectorValue(s->_segMan, targetObject, SELECTOR(x)); - uint16 itemY = readSelectorValue(s->_segMan, targetObject, SELECTOR(y)); - // If top and left are negative, we need to adjust coordinates by the item's x and y - if (nsRect.left < 0) - nsRect.translate(itemX, 0); - if (nsRect.top < 0) - nsRect.translate(0, itemY); - - // we assume that x, y are local coordinates - - bool contained = nsRect.contains(x, y); - if (contained && illegalBits) { - // If illegalbits are set, we check the color of the pixel that got clicked on - // for now, we return false if the pixel is transparent - // although illegalBits may get differently set, don't know yet how this really works out - uint16 viewId = readSelectorValue(s->_segMan, targetObject, SELECTOR(view)); - int16 loopNo = readSelectorValue(s->_segMan, targetObject, SELECTOR(loop)); - int16 celNo = readSelectorValue(s->_segMan, targetObject, SELECTOR(cel)); - if (g_sci->_gfxCompare->kernelIsItSkip(viewId, loopNo, celNo, Common::Point(x - nsRect.left, y - nsRect.top))) - contained = false; - } - return make_reg(0, contained); + uint16 checkPixels = argv[3].getOffset(); + + return make_reg(0, g_sci->_gfxFrameout->kernelIsOnMe(x, y, checkPixels, targetObject)); } reg_t kCreateTextBitmap(EngineState *s, int argc, reg_t *argv) { diff --git a/engines/sci/graphics/celobj32.h b/engines/sci/graphics/celobj32.h index 897615d590..1422b76a57 100644 --- a/engines/sci/graphics/celobj32.h +++ b/engines/sci/graphics/celobj32.h @@ -367,7 +367,7 @@ public: * Reads the pixel at the given coordinates. This method * is valid only for CelObjView and CelObjPic. */ - inline uint8 readPixel(uint16 x, uint16 y, bool mirrorX) const; + virtual uint8 readPixel(uint16 x, uint16 y, bool mirrorX) const; /** * Submits the palette from this cel to the palette diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index 5380db174b..fcf5fcf49d 100644 --- a/engines/sci/graphics/frameout.cpp +++ b/engines/sci/graphics/frameout.cpp @@ -1867,6 +1867,73 @@ void GfxFrameout::kernelFrameout(const bool shouldShowBits) { } } +uint16 GfxFrameout::kernelIsOnMe(int16 x, int16 y, uint16 checkPixels, reg_t screenObject) { + reg_t planeObject = readSelector(_segMan, screenObject, SELECTOR(plane)); + Plane *screenObjPlane = _planes.findByObject(planeObject); + ScreenItem *screenItem = nullptr; + + if (!screenObjPlane) { + // Specified plane not found + return 0; + } + + screenItem = screenObjPlane->_screenItemList.findByObject(screenObject); + if (!screenItem) { + // Specified screen object not in item list + return 0; + } + + // adjust coordinate according to resolution + int32 adjustedX = x * getCurrentBuffer().screenWidth / getCurrentBuffer().scriptWidth; + int32 adjustedY = y * getCurrentBuffer().screenHeight / getCurrentBuffer().scriptHeight; + + adjustedX += screenObjPlane->_planeRect.left; + adjustedY += screenObjPlane->_planeRect.top; + + //warning("kIsOnMe %s %d (%d, %d -> %d, %d) mouse %d, %d", _segMan->getObjectName(screenObject), checkPixels, screenItem->_screenRect.left, screenItem->_screenRect.top, screenItem->_screenRect.right, screenItem->_screenRect.bottom, adjustedX, adjustedY); + + if (!screenItem->_screenRect.contains(adjustedX, adjustedY)) { + // Specified coordinates are not within screen item + return 0; + } + + //warning("HIT!"); + if (checkPixels) { + //warning("Check Pixels"); + CelObj &screenItemCelObject = screenItem->getCelObj(); + + int32 celAdjustedX = adjustedX; + int32 celAdjustedY = adjustedY; + bool celMirrored = screenItem->_mirrorX ^ screenItemCelObject._mirrorX; + + celAdjustedX -= screenItem->_scaledPosition.x; + celAdjustedY -= screenItem->_scaledPosition.y; + + celAdjustedX = celAdjustedX * screenItemCelObject._scaledWidth / getCurrentBuffer().screenWidth; + celAdjustedY = celAdjustedY * screenItemCelObject._scaledHeight / getCurrentBuffer().screenHeight; + + // if adjustedX/Y larger than width/height divide again?? + // + if >0 afterwards increase by 1 + +#if 0 + if ((screenItem->_scale.signal) && (screenItem->_scale.x) && (screenItem->_scale.y)) { + celAdjustedX = celAdjustedX * 128 / screenItem->_scale.x; + celAdjustedY = celAdjustedY * 128 / screenItem->_scale.y; + } +#endif + + byte coordinateColor = screenItemCelObject.readPixel(celAdjustedX, celAdjustedY, celMirrored); + byte transparentColor = screenItemCelObject._transparentColor; + + if (coordinateColor == transparentColor) { + // Coordinate is transparent + //warning("TRANSPARENT!"); + return 0; + } + } + return 1; +} + #pragma mark - #pragma mark Debugging diff --git a/engines/sci/graphics/frameout.h b/engines/sci/graphics/frameout.h index 27fce71393..0239b2d7b4 100644 --- a/engines/sci/graphics/frameout.h +++ b/engines/sci/graphics/frameout.h @@ -490,6 +490,8 @@ public: return 1; }; + uint16 kernelIsOnMe(int16 x, int16 y, uint16 checkPixels, reg_t screenObject); + #pragma mark - #pragma mark Debugging public: |