diff options
| author | Martin Kiewitz | 2010-02-05 20:44:03 +0000 | 
|---|---|---|
| committer | Martin Kiewitz | 2010-02-05 20:44:03 +0000 | 
| commit | 248bc560f32ee78a25e606b8ff54a449be6bf6e2 (patch) | |
| tree | efe49c14d8329942ea2f6e66e671d8ab55b8b2c6 /engines/sci/graphics/compare.cpp | |
| parent | 779fc7dc193d5ad360d02ccd33a86ea021f2e138 (diff) | |
| download | scummvm-rg350-248bc560f32ee78a25e606b8ff54a449be6bf6e2.tar.gz scummvm-rg350-248bc560f32ee78a25e606b8ff54a449be6bf6e2.tar.bz2 scummvm-rg350-248bc560f32ee78a25e606b8ff54a449be6bf6e2.zip | |
SCI: moved onControl etc. into GfxCompare, now getting called directly. also fixed loading saved games due Gfx* changes
svn-id: r47912
Diffstat (limited to 'engines/sci/graphics/compare.cpp')
| -rw-r--r-- | engines/sci/graphics/compare.cpp | 78 | 
1 files changed, 73 insertions, 5 deletions
| diff --git a/engines/sci/graphics/compare.cpp b/engines/sci/graphics/compare.cpp index 194dc7f374..82a5d04c44 100644 --- a/engines/sci/graphics/compare.cpp +++ b/engines/sci/graphics/compare.cpp @@ -31,6 +31,7 @@  #include "sci/engine/state.h"  #include "sci/engine/selector.h"  #include "sci/graphics/compare.h" +#include "sci/graphics/coordadjuster.h"  #include "sci/graphics/animate.h"  #include "sci/graphics/cache.h"  #include "sci/graphics/screen.h" @@ -38,14 +39,14 @@  namespace Sci { -GfxCompare::GfxCompare(SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxScreen *screen) -	: _segMan(segMan), _kernel(kernel), _cache(cache), _screen(screen) { +GfxCompare::GfxCompare(SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxScreen *screen, GfxCoordAdjuster *coordAdjuster) +	: _segMan(segMan), _kernel(kernel), _cache(cache), _screen(screen), _coordAdjuster(coordAdjuster) {  }  GfxCompare::~GfxCompare() {  } -uint16 GfxCompare::onControl(uint16 screenMask, Common::Rect rect) { +uint16 GfxCompare::isOnControl(uint16 screenMask, Common::Rect rect) {  	int16 x, y;  	uint16 result = 0; @@ -75,7 +76,7 @@ static inline int sign_extend_byte(int value) {  		return value;  } -bool GfxCompare::CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect, List *list) { +bool GfxCompare::canBeHereCheckRectList(reg_t checkObject, Common::Rect checkRect, List *list) {  	reg_t curAddress = list->first;  	Node *curNode = _segMan->lookupNode(curAddress);  	reg_t curObject; @@ -103,7 +104,14 @@ bool GfxCompare::CanBeHereCheckRectList(reg_t checkObject, Common::Rect checkRec  	return true;  } -void GfxCompare::SetNowSeen(reg_t objectReference) { +uint16 GfxCompare::kernelOnControl(byte screenMask, Common::Rect rect) { +	Common::Rect adjustedRect = _coordAdjuster->onControl(rect); + +	uint16 result = isOnControl(screenMask, adjustedRect); +	return result; +} + +void GfxCompare::kernelSetNowSeen(reg_t objectReference) {  	GfxView *view = NULL;  	Common::Rect celRect(0, 0);  	GuiResourceId viewId = (GuiResourceId)GET_SEL32V(_segMan, objectReference, view); @@ -128,4 +136,64 @@ void GfxCompare::SetNowSeen(reg_t objectReference) {  	}  } +bool GfxCompare::kernelCanBeHere(reg_t curObject, reg_t listReference) { +	Common::Rect checkRect; +	Common::Rect adjustedRect; +	uint16 signal, controlMask; +	bool result; + +	checkRect.left = GET_SEL32V(_segMan, curObject, brLeft); +	checkRect.top = GET_SEL32V(_segMan, curObject, brTop); +	checkRect.right = GET_SEL32V(_segMan, curObject, brRight); +	checkRect.bottom = GET_SEL32V(_segMan, curObject, brBottom); + +	adjustedRect = _coordAdjuster->onControl(checkRect); + +	signal = GET_SEL32V(_segMan, curObject, signal); +	controlMask = GET_SEL32V(_segMan, curObject, illegalBits); +	result = (isOnControl(SCI_SCREEN_MASK_CONTROL, adjustedRect) & controlMask) ? false : true; +	if ((result) && (signal & (kSignalIgnoreActor | kSignalRemoveView)) == 0) { +		List *list = _segMan->lookupList(listReference); +		if (!list) +			error("kCanBeHere called with non-list as parameter"); + +		result = canBeHereCheckRectList(curObject, checkRect, list); +	} +	return result; +} + +bool GfxCompare::kernelIsItSkip(GuiResourceId viewId, int16 loopNo, int16 celNo, Common::Point position) { +	GfxView *tmpView = _cache->getView(viewId); +	CelInfo *celInfo = tmpView->getCelInfo(loopNo, celNo); +	position.x = CLIP<int>(position.x, 0, celInfo->width - 1); +	position.y = CLIP<int>(position.y, 0, celInfo->height - 1); +	byte *celData = tmpView->getBitmap(loopNo, celNo); +	bool result = (celData[position.y * celInfo->width + position.x] == celInfo->clearKey); +	return result; +} + +void GfxCompare::kernelBaseSetter(reg_t object) { +	if (lookup_selector(_segMan, object, _kernel->_selectorCache.brLeft, NULL, NULL) == kSelectorVariable) { +		int16 x = GET_SEL32V(_segMan, object, x); +		int16 y = GET_SEL32V(_segMan, object, y); +		int16 z = (_kernel->_selectorCache.z > -1) ? GET_SEL32V(_segMan, object, z) : 0; +		int16 yStep = GET_SEL32V(_segMan, object, yStep); +		GuiResourceId viewId = GET_SEL32V(_segMan, object, view); +		int16 loopNo = GET_SEL32V(_segMan, object, loop); +		int16 celNo = GET_SEL32V(_segMan, object, cel); + +		GfxView *tmpView = _cache->getView(viewId); +		Common::Rect celRect; + +		tmpView->getCelRect(loopNo, celNo, x, y, z, &celRect); +		celRect.bottom = y + 1; +		celRect.top = celRect.bottom - yStep; + +		PUT_SEL32V(_segMan, object, brLeft, celRect.left); +		PUT_SEL32V(_segMan, object, brRight, celRect.right); +		PUT_SEL32V(_segMan, object, brTop, celRect.top); +		PUT_SEL32V(_segMan, object, brBottom, celRect.bottom); +	} +} +  } // End of namespace Sci | 
