diff options
author | Willem Jan Palenstijn | 2011-11-27 18:56:37 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2011-11-27 18:56:37 +0100 |
commit | 3f30105fff58849dc24dadbf04d945bfb75916a4 (patch) | |
tree | 6e4cb4df1a95756a7d212738327300bc743f71b9 /engines/dreamweb | |
parent | d9e86715d6531304bc5a3826a3c151db0b56edba (diff) | |
download | scummvm-rg350-3f30105fff58849dc24dadbf04d945bfb75916a4.tar.gz scummvm-rg350-3f30105fff58849dc24dadbf04d945bfb75916a4.tar.bz2 scummvm-rg350-3f30105fff58849dc24dadbf04d945bfb75916a4.zip |
DREAMWEB: Add utility function ObjPos::contains
Diffstat (limited to 'engines/dreamweb')
-rw-r--r-- | engines/dreamweb/structs.h | 3 | ||||
-rw-r--r-- | engines/dreamweb/stubs.cpp | 30 |
2 files changed, 6 insertions, 27 deletions
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 50736120c8..c9ec703ded 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -134,6 +134,9 @@ struct ObjPos { uint8 xMax; uint8 yMax; uint8 index; + bool contains(uint8 x, uint8 y) const { + return (x >= xMin) && (x < xMax) && (y >= yMin) && (y < yMax); + } }; struct Frame { diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index c336a62307..e8a5624323 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1064,15 +1064,7 @@ bool DreamGenContext::checkiffree(uint8 x, uint8 y) { const ObjPos *freeList = (const ObjPos *)segRef(data.word(kBuffers)).ptr(kFreelist, 80 * sizeof(ObjPos)); for (size_t i = 0; i < 80; ++i) { const ObjPos *objPos = freeList + 79 - i; - if (objPos->index == 0xff) - continue; - if (x < objPos->xMin) - continue; - if (x >= objPos->xMax) - continue; - if (y < objPos->yMin) - continue; - if (y >= objPos->yMax) + if (objPos->index == 0xff || !objPos->contains(x,y)) continue; obname(objPos->index, 2); return true; @@ -1088,15 +1080,7 @@ bool DreamGenContext::checkifex(uint8 x, uint8 y) { const ObjPos *exList = (const ObjPos *)segRef(data.word(kBuffers)).ptr(kExlist, 100 * sizeof(ObjPos)); for (size_t i = 0; i < 100; ++i) { const ObjPos *objPos = exList + 99 - i; - if (objPos->index == 0xff) - continue; - if (x < objPos->xMin) - continue; - if (x >= objPos->xMax) - continue; - if (y < objPos->yMin) - continue; - if (y >= objPos->yMax) + if (objPos->index == 0xff || !objPos->contains(x,y)) continue; obname(objPos->index, 4); return true; @@ -1793,15 +1777,7 @@ bool DreamGenContext::checkifset(uint8 x, uint8 y) { const ObjPos *setList = (const ObjPos *)segRef(data.word(kBuffers)).ptr(kSetlist, sizeof(ObjPos) * 128); for (size_t i = 0; i < 128; ++i) { const ObjPos *pos = setList + 127 - i; - if (pos->index == 0xff) - continue; - if (x < pos->xMin) - continue; - if (x >= pos->xMax) - continue; - if (y < pos->yMin) - continue; - if (y >= pos->yMax) + if (pos->index == 0xff || !pos->contains(x,y)) continue; if (! pixelcheckset(pos, x, y)) continue; |