diff options
| author | Torbjörn Andersson | 2003-08-18 07:46:46 +0000 | 
|---|---|---|
| committer | Torbjörn Andersson | 2003-08-18 07:46:46 +0000 | 
| commit | c6118886062a46d04d4c7576e8daef7bc99b45a6 (patch) | |
| tree | 8e59f48773204e9bc68e6882f815296e5a375841 | |
| parent | 311eb2678fbcfbd57606331bd88ff2cb24edde64 (diff) | |
| download | scummvm-rg350-c6118886062a46d04d4c7576e8daef7bc99b45a6.tar.gz scummvm-rg350-c6118886062a46d04d4c7576e8daef7bc99b45a6.tar.bz2 scummvm-rg350-c6118886062a46d04d4c7576e8daef7bc99b45a6.zip | |
Added support for opaque surfaces (it's the default now, actually) since it
looks like the sprite renderer may need them.
svn-id: r9753
| -rw-r--r-- | sword2/driver/driver96.h | 5 | ||||
| -rw-r--r-- | sword2/driver/render.cpp | 21 | 
2 files changed, 20 insertions, 6 deletions
| diff --git a/sword2/driver/driver96.h b/sword2/driver/driver96.h index 476ed1245e..45ef77f239 100644 --- a/sword2/driver/driver96.h +++ b/sword2/driver/driver96.h @@ -1262,11 +1262,13 @@ public:  	uint16 _width, _height;  	uint16 _pitch;  	byte *_pixels; +	int _colorKey;  	Surface(uint width, uint height) {  		_width = width;  		_height = height;  		_pixels = (byte *) calloc(_width, _height); +		_colorKey = -1;  	};  	~Surface() { @@ -1276,6 +1278,9 @@ public:  	void clear();  	void blit(Surface *s, ScummVM::Rect *r);  	void blit(Surface *s, ScummVM::Rect *r, ScummVM::Rect *clip_rect); +	void setColorKey(int colorKey) { +		_colorKey = colorKey; +	};  };  // diff --git a/sword2/driver/render.cpp b/sword2/driver/render.cpp index 9e56a3bee0..63d3c84562 100644 --- a/sword2/driver/render.cpp +++ b/sword2/driver/render.cpp @@ -326,13 +326,21 @@ void Surface::blit(Surface *s, ScummVM::Rect *r, ScummVM::Rect *clip_rect) {  	// several times, as each new parallax layer is rendered, this may be  	// a bit inefficient. -	for (i = 0; i < r->bottom - r->top; i++) { -		for (j = 0; j < r->right - r->left; j++) { -			if (src[j]) -				dst[j] = src[j]; +	if (s->_colorKey >= 0) { +		for (i = 0; i < r->bottom - r->top; i++) { +			for (j = 0; j < r->right - r->left; j++) { +				if (src[j] != s->_colorKey) +					dst[j] = src[j]; +			} +			src += s->_width; +			dst += _width; +		} +	} else { +		for (i = 0; i < r->bottom - r->top; i++) { +			memcpy(dst, src, r->right - r->left); +			src += s->_width; +			dst += _width;  		} -		src += s->_width; -		dst += _width;  	}  	g_sword2->_system->copy_rect(_pixels + r->top * _width + r->left, _width, r->left, r->top, r->right - r->left, r->bottom - r->top); @@ -1292,6 +1300,7 @@ bailout:  		if (block_has_data) {  			blockSurfaces[layer][i] = new Surface(BLOCKWIDTH, BLOCKHEIGHT); +			blockSurfaces[layer][i]->setColorKey(0);  			//  Copy the data into the surfaces.  			dst = blockSurfaces[layer][i]->_pixels; | 
