diff options
| author | lukaslw | 2014-05-31 20:57:46 +0200 | 
|---|---|---|
| committer | lukaslw | 2014-06-22 20:08:27 +0200 | 
| commit | 7874a4e7820378c8ca260f646e0ee8ee84bf6b9c (patch) | |
| tree | 95b2a7c5243206badba08a7eca6f221acd1d715f | |
| parent | dab83cc3ebe13ec604ba117ad163bc8a005bc7b2 (diff) | |
| download | scummvm-rg350-7874a4e7820378c8ca260f646e0ee8ee84bf6b9c.tar.gz scummvm-rg350-7874a4e7820378c8ca260f646e0ee8ee84bf6b9c.tar.bz2 scummvm-rg350-7874a4e7820378c8ca260f646e0ee8ee84bf6b9c.zip | |
PRINCE: drawMask progress, changes in spriteCheck
| -rw-r--r-- | engines/prince/graphics.cpp | 17 | ||||
| -rw-r--r-- | engines/prince/hero.cpp | 2 | ||||
| -rw-r--r-- | engines/prince/prince.cpp | 41 | ||||
| -rw-r--r-- | engines/prince/prince.h | 3 | ||||
| -rw-r--r-- | engines/prince/script.cpp | 3 | 
5 files changed, 58 insertions, 8 deletions
| diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp index 93b558a03b..4f55b5a23e 100644 --- a/engines/prince/graphics.cpp +++ b/engines/prince/graphics.cpp @@ -90,15 +90,28 @@ void GraphicsMan::drawTransparent(int32 posX, int32 posY, const Graphics::Surfac  }  void GraphicsMan::drawMask(int32 posX, int32 posY, int32 width, int32 height, byte *maskData, const Graphics::Surface *originalRoomSurface) { +	int maskWidth = width >> 3; +	int maskPostion = 0; +	int maskCounter = 128;  	for (int y = 0; y < height; y++) { +		int tempMaskPostion = maskPostion;  		for (int x = 0; x < width; x++) {  			if (x + posX < _frontScreen->w && x + posX >= 0) {  				if (y + posY < _frontScreen->h && y + posY >= 0) { -					byte orgPixel = *((byte*)originalRoomSurface->getBasePtr(x + posX, y + posY)); -					*((byte*)_frontScreen->getBasePtr(x + posX, y + posY)) = orgPixel; +					if ((maskData[tempMaskPostion] & maskCounter) != 0) { +						byte orgPixel = *((byte*)originalRoomSurface->getBasePtr(x + posX, y + posY)); +						*((byte*)_frontScreen->getBasePtr(x + posX, y + posY)) = orgPixel; +					} +					maskCounter >>= 1; +					if (maskCounter == 0) { +						maskCounter = 128; +						tempMaskPostion++; +					}  				}  			}  		} +		maskPostion += maskWidth; +		maskCounter = 128;  	}  	change();  } diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp index 51ba4529fe..aeef68d4b2 100644 --- a/engines/prince/hero.cpp +++ b/engines/prince/hero.cpp @@ -203,7 +203,7 @@ void Hero::countDrawPosition() {  	_scaledFrameYSize = getScaledValue(_frameYSize);  	//TODO -	int tempHeroHeight = _scaledFrameYSize; // not used? global? +	//int tempHeroHeight = _scaledFrameYSize; // not used? global?  	int width = _frameXSize / 2;  	tempMiddleX = _middleX - width; //eax  	int z = _middleY; //ebp diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index e63986dc3c..5b8903b49c 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -718,6 +718,35 @@ void PrinceEngine::showTexts() {  	}  } +bool PrinceEngine::spriteCheck(int sprWidth, int sprHeight, int destX, int destY) { +	destX -= _picWindowX; +	destY -= _picWindowY; + +	 // if x1 is on visible part of screen +	if (destX < 0) { +		if (destX + sprWidth < 1) { +			//x2 is negative - out of window +			return false; +		} +	} +	 // if x1 is outside of screen on right side +	if (destX >= kNormalWidth) { +		return false; +	} + +	if (destY < 0) { +		if (destY + sprHeight < 1) { +			//y2 is negative - out of window +			return false; +		} +	} +	if (destY >= kNormalHeight) { +		return false; +	} + +	return true; +} +/*  bool PrinceEngine::spriteCheck(Graphics::Surface *backAnimSurface, int destX, int destY) {  	int sprWidth = backAnimSurface->w;  	int sprHeight = backAnimSurface->h; @@ -748,6 +777,7 @@ bool PrinceEngine::spriteCheck(Graphics::Surface *backAnimSurface, int destX, in  	return true;  } +*/  // CheckNak  void PrinceEngine::checkMasks(int x1, int y1, int sprWidth, int sprHeight, int z) { @@ -774,6 +804,7 @@ void PrinceEngine::insertMasks(const Graphics::Surface *originalRoomSurface) {  	for (uint i = 0; i < _maskList.size(); i++) {  		if (_maskList[i]._state == 1) {  			showMask(i, originalRoomSurface); +			_maskList[i]._state = 0; // here or somewhere else?  		}  	}  } @@ -781,12 +812,16 @@ void PrinceEngine::insertMasks(const Graphics::Surface *originalRoomSurface) {  // ShowNak  void PrinceEngine::showMask(int maskNr, const Graphics::Surface *originalRoomSurface) {  	if (_maskList[maskNr]._flags == 0) { -		_graph->drawMask(_maskList[maskNr]._x1, _maskList[maskNr]._y1, _maskList[maskNr]._width, _maskList[maskNr]._height, _maskList[maskNr].getMask(), originalRoomSurface); +		if (spriteCheck(_maskList[maskNr]._width, _maskList[maskNr]._height, _maskList[maskNr]._x1, _maskList[maskNr]._y1)) { +			int destX = _maskList[maskNr]._x1 - _picWindowX; +			int destY = _maskList[maskNr]._y1 - _picWindowY; +			_graph->drawMask(destX, destY, _maskList[maskNr]._width, _maskList[maskNr]._height, _maskList[maskNr].getMask(), originalRoomSurface); +		}  	}  }  void PrinceEngine::showSprite(Graphics::Surface *backAnimSurface, int destX, int destY) { -	if (spriteCheck(backAnimSurface, destX, destY)) { +	if (spriteCheck(backAnimSurface->w, backAnimSurface->h, destX, destY)) {  		destX -= _picWindowX;  		destY -= _picWindowY;  		_graph->drawTransparent(destX, destY, backAnimSurface); @@ -794,7 +829,7 @@ void PrinceEngine::showSprite(Graphics::Surface *backAnimSurface, int destX, int  }  void PrinceEngine::showSpriteShadow(Graphics::Surface *shadowSurface, int destX, int destY) { -	if (spriteCheck(shadowSurface, destX, destY)) { +	if (spriteCheck(shadowSurface->w, shadowSurface->h, destX, destY)) {  		destX -= _picWindowX;  		destY -= _picWindowY;  		_graph->drawAsShadow(destX, destY, shadowSurface, _graph->_shadowTable70); diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 1a6fa14e0d..6747f5cab9 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -30,6 +30,7 @@  #include "common/textconsole.h"  #include "common/rect.h"  #include "common/events.h" +#include "common/endian.h"  #include "image/bmp.h" @@ -262,7 +263,7 @@ private:  	void showLogo();  	void showBackAnims();  	void clearBackAnimList(); -	bool spriteCheck(Graphics::Surface *backAnimSurface, int destX, int destY); +	bool spriteCheck(int sprWidth, int sprHeight, int destX, int destY);  	void showSprite(Graphics::Surface *backAnimSurface, int destX, int destY);  	void showSpriteShadow(Graphics::Surface *shadowSurface, int destX, int destY);  	void makeShadowTable(int brightness); diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 13234971cd..91da9abdc5 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -332,9 +332,10 @@ bool Script::loadAllMasks(Common::Array<Mask> &maskList, int offset) {  			}  			delete msStream;  		} -		tempMask._width = tempMask.getHeight(); +		tempMask._width = tempMask.getWidth();  		tempMask._height = tempMask.getHeight();  		debug("width: %d, height: %d\n", tempMask._width, tempMask._height); +		debug("dataSize: %d", dataSize);  		maskList.push_back(tempMask);  		offset += 16; // size of Mask (Nak) struct | 
