Ticket #9855: object_intersect.diff

File object_intersect.diff, 2.7 KB (added by bluegr, 3 years ago)

Proper implementation of kObjectIntersect

  • engines/sci/engine/kgraphics32.cpp

    diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
    index 76ed27a..74be3d8 100644
    a b reg_t kSetPalStyleRange(EngineState *s, int argc, reg_t *argv) {  
    245245}
    246246
    247247reg_t kObjectIntersect(EngineState *s, int argc, reg_t *argv) {
    248         Common::Rect objRect1 = g_sci->_gfxCompare->getNSRect(argv[0]);
    249         Common::Rect objRect2 = g_sci->_gfxCompare->getNSRect(argv[1]);
    250         return make_reg(0, objRect1.intersects(objRect2));
     248        uint16 intersectArea = g_sci->_gfxFrameout->kernelObjectIntersection(argv[0], argv[1]);
     249        return make_reg(0, intersectArea);
    251250}
    252251
    253252reg_t kIsOnMe(EngineState *s, int argc, reg_t *argv) {
  • engines/sci/graphics/frameout.cpp

    diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
    index c969f91..a640b11 100644
    a b bool GfxFrameout::kernelSetNowSeen(const reg_t screenItemObject) const {  
    12831283        return true;
    12841284}
    12851285
     1286const Common::Rect GfxFrameout::getObjectNSRect(const reg_t object) const {
     1287        const reg_t planeObject = readSelector(_segMan, object, SELECTOR(plane));
     1288        Plane *plane = _planes.findByObject(planeObject);
     1289        if (plane == nullptr)
     1290                error("getObjectNSRect: Plane %04x:%04x not found for screen item %04x:%04x", PRINT_REG(planeObject), PRINT_REG(object));
     1291
     1292        ScreenItem *screenItem = plane->_screenItemList.findByObject(object);
     1293        if (screenItem == nullptr)
     1294                error("getObjectNSRect: Screen item not found for object %04x:%04x", PRINT_REG(object));
     1295
     1296        return screenItem->getNowSeenRect(*plane);
     1297}
     1298
     1299uint16 GfxFrameout::kernelObjectIntersection(const reg_t object1, const reg_t object2) const {
     1300        const Common::Rect nowSeen1 = getObjectNSRect(object1);
     1301        const Common::Rect nowSeen2 = getObjectNSRect(object2);
     1302        Common::Rect intersection = nowSeen1;
     1303        intersection.clip(nowSeen2);
     1304        return intersection.width() * intersection.height();
     1305}
     1306
    12861307void GfxFrameout::remapMarkRedraw() {
    12871308        for (PlaneList::const_iterator it = _planes.begin(); it != _planes.end(); ++it) {
    12881309                Plane *p = *it;
  • engines/sci/graphics/frameout.h

    diff --git a/engines/sci/graphics/frameout.h b/engines/sci/graphics/frameout.h
    index e706f14..7bc06f3 100644
    a b public:  
    9696        void kernelUpdateScreenItem(const reg_t object);
    9797        void kernelDeleteScreenItem(const reg_t object);
    9898        bool kernelSetNowSeen(const reg_t screenItemObject) const;
     99        uint16 kernelObjectIntersection(const reg_t object1, const reg_t object2) const;
     100
     101private:
     102        const Common::Rect getObjectNSRect(const reg_t object) const;
    99103
    100104#pragma mark -
    101105#pragma mark Planes