[Scummvm-cvs-logs] scummvm master -> a37bb1dabbe586df65ceb311af349343ebd2b973

sev- sev at scummvm.org
Tue Jun 17 14:35:44 CEST 2014


This automated email contains information about 8 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
8738d55b04 FULLPIPE: Switch engine to 32 bit
343910d3ce FULLPIPE: Switch graphics to TransparentSurface
5847240234 GRAPHICS: Rename BS_ to TS_ (for TransparentSurface)
f404c842a1 FULLPIPE: Skip internal 565 rpresentation for sprites and directly render them in 32bit
e6af6328c7 FULLPIPE: Implement horizontal flipping
7c444319cb FULLPIPE: cleanup
6c8d48c5a5 FULLPIPE: Cleanup gfx code
a37bb1dabb FULLPIPE: Fix crash in scene34. Now it is rendered properly


Commit: 8738d55b049c996578749010bfca33985e4da4aa
    https://github.com/scummvm/scummvm/commit/8738d55b049c996578749010bfca33985e4da4aa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2014-06-17T14:00:47+03:00

Commit Message:
FULLPIPE: Switch engine to 32 bit

Changed paths:
    engines/fullpipe/fullpipe.cpp
    engines/fullpipe/gfx.cpp



diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp
index f79564e..0c74c75 100644
--- a/engines/fullpipe/fullpipe.cpp
+++ b/engines/fullpipe/fullpipe.cpp
@@ -243,7 +243,7 @@ void FullpipeEngine::restartGame() {
 }
 
 Common::Error FullpipeEngine::run() {
-	const Graphics::PixelFormat format(2, 5, 6, 5, 0, 11, 5, 0, 0);
+	const Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0);
 	// Initialize backend
 	initGraphics(800, 600, true, &format);
 
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp
index 519b39f..220892d 100644
--- a/engines/fullpipe/gfx.cpp
+++ b/engines/fullpipe/gfx.cpp
@@ -847,6 +847,8 @@ void Bitmap::decode(int32 *palette) {
 		putDibRB(palette);
 	else
 		putDibCB(palette);
+
+	_surface->convertToInPlace(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
 }
 
 void Bitmap::putDib(int x, int y, int32 *palette) {


Commit: 343910d3ce604149fa885dd562a113da7bbd05c8
    https://github.com/scummvm/scummvm/commit/343910d3ce604149fa885dd562a113da7bbd05c8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2014-06-17T14:07:19+03:00

Commit Message:
FULLPIPE: Switch graphics to TransparentSurface

Changed paths:
    engines/fullpipe/fullpipe.h
    engines/fullpipe/gfx.cpp
    engines/fullpipe/gfx.h



diff --git a/engines/fullpipe/fullpipe.h b/engines/fullpipe/fullpipe.h
index afdc493..181e82c 100644
--- a/engines/fullpipe/fullpipe.h
+++ b/engines/fullpipe/fullpipe.h
@@ -32,7 +32,7 @@
 
 #include "audio/mixer.h"
 
-#include "graphics/surface.h"
+#include "graphics/transparent_surface.h"
 
 #include "engines/engine.h"
 
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp
index 220892d..5f8177c 100644
--- a/engines/fullpipe/gfx.cpp
+++ b/engines/fullpipe/gfx.cpp
@@ -54,7 +54,7 @@ Bitmap::Bitmap(Bitmap *src) {
 	_width = src->_width;
 	_height = src->_height;
 	_pixels = src->_pixels;
-	_surface = new Graphics::Surface(*src->_surface);
+	_surface = new Graphics::TransparentSurface(*src->_surface);
 }
 
 Bitmap::~Bitmap() {
@@ -839,7 +839,7 @@ bool Bitmap::isPixelAtHitPosRB(int x, int y) {
 }
 
 void Bitmap::decode(int32 *palette) {
-	_surface = new Graphics::Surface;
+	_surface = new Graphics::TransparentSurface;
 
 	_surface->create(_width, _height, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
 
@@ -881,7 +881,7 @@ void Bitmap::putDib(int x, int y, int32 *palette) {
 	if (sub.width() <= 0 || sub.height() <= 0)
 		return;
 
-	g_fp->_backgroundSurface.copyRectToSurface(*_surface, x1, y1, sub);
+	_surface->blit(g_fp->_backgroundSurface, x1, y1, Graphics::FLIP_NONE, &sub);
 	g_fp->_system->copyRectToScreen(g_fp->_backgroundSurface.getBasePtr(x1, y1), g_fp->_backgroundSurface.pitch, x1, y1, sub.width(), sub.height());
 }
 
diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h
index ddf153e..48c90a6 100644
--- a/engines/fullpipe/gfx.h
+++ b/engines/fullpipe/gfx.h
@@ -38,7 +38,7 @@ struct Bitmap {
 	int _type;
 	int _dataSize;
 	int _flags;
-	Graphics::Surface *_surface;
+	Graphics::TransparentSurface *_surface;
 
 	Bitmap();
 	Bitmap(Bitmap *src);


Commit: 58472402341a6445245e8fccccf041a17d362983
    https://github.com/scummvm/scummvm/commit/58472402341a6445245e8fccccf041a17d362983
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2014-06-17T14:54:53+03:00

Commit Message:
GRAPHICS: Rename BS_ to TS_ (for TransparentSurface)

Changed paths:
    graphics/transparent_surface.h



diff --git a/graphics/transparent_surface.h b/graphics/transparent_surface.h
index cc35f8e..ca26b26 100644
--- a/graphics/transparent_surface.h
+++ b/graphics/transparent_surface.h
@@ -36,8 +36,8 @@
  */
 
 // TODO: Find a better solution for this.
-#define BS_RGB(R,G,B)       (0xFF000000 | ((R) << 16) | ((G) << 8) | (B))
-#define BS_ARGB(A,R,G,B)    (((A) << 24) | ((R) << 16) | ((G) << 8) | (B))
+#define TS_RGB(R,G,B)       (((R) << 24) | ((G) << 16) | (B << 8) | (A)
+#define TS_ARGB(A,R,G,B)    (((R) << 24) | ((G) << 16) | ((B) << 8) | (A))
 
 namespace Graphics {
 
@@ -82,15 +82,15 @@ struct TransparentSurface : public Graphics::Surface {
 	 @param posY the position on the Y-axis in the target image in pixels where the image is supposed to be rendered.<br>
 	 The default value is 0.
 	 @param flipping how the the image should be flipped.<br>
-	 The default value is BS_Image::FLIP_NONE (no flipping)
+	 The default value is Graphics::FLIP_NONE (no flipping)
 	 @param pPartRect Pointer on Common::Rect which specifies the section to be rendered. If the whole image has to be rendered the Pointer is NULL.<br>
 	 This referes to the unflipped and unscaled image.<br>
 	 The default value is NULL.
 	 @param color an ARGB color value, which determines the parameters for the color modulation und alpha blending.<br>
 	 The alpha component of the color determines the alpha blending parameter (0 = no covering, 255 = full covering).<br>
 	 The color components determines the color for color modulation.<br>
-	 The default value is BS_ARGB(255, 255, 255, 255) (full covering, no color modulation).
-	 The macros BS_RGB and BS_ARGB can be used for the creation of the color value.
+	 The default value is TS_ARGB(255, 255, 255, 255) (full covering, no color modulation).
+	 The macros TS_RGB and TS_ARGB can be used for the creation of the color value.
 	 @param width the output width of the screen section.
 	 The images will be scaled if the output width of the screen section differs from the image section.<br>
 	 The value -1 determines that the image should not be scaled.<br>
@@ -104,7 +104,7 @@ struct TransparentSurface : public Graphics::Surface {
 	Common::Rect blit(Graphics::Surface &target, int posX = 0, int posY = 0,
 	                  int flipping = FLIP_NONE,
 	                  Common::Rect *pPartRect = nullptr,
-	                  uint color = BS_ARGB(255, 255, 255, 255),
+	                  uint color = TS_ARGB(255, 255, 255, 255),
 	                  int width = -1, int height = -1,
 	                  TSpriteBlendMode blend = BLEND_NORMAL);
 	void applyColorKey(uint8 r, uint8 g, uint8 b, bool overwriteAlpha = false);


Commit: f404c842a11c17802209cde5773c66020f97838b
    https://github.com/scummvm/scummvm/commit/f404c842a11c17802209cde5773c66020f97838b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2014-06-17T14:55:26+03:00

Commit Message:
FULLPIPE: Skip internal 565 rpresentation for sprites and directly render them in 32bit

Changed paths:
    engines/fullpipe/fullpipe.cpp
    engines/fullpipe/fullpipe.h
    engines/fullpipe/gfx.cpp
    engines/fullpipe/gfx.h



diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp
index 0c74c75..0a176ca 100644
--- a/engines/fullpipe/fullpipe.cpp
+++ b/engines/fullpipe/fullpipe.cpp
@@ -249,6 +249,8 @@ Common::Error FullpipeEngine::run() {
 
 	_backgroundSurface.create(800, 600, format);
 
+	_origFormat = new Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
+
 	_console = new Console(this);
 
 	initialize();
@@ -440,6 +442,8 @@ void FullpipeEngine::cleanup() {
 		delete (*_globalMessageQueueList)[i];
 
 	stopAllSoundStreams();
+
+	delete _origFormat;
 }
 
 void FullpipeEngine::updateScreen() {
diff --git a/engines/fullpipe/fullpipe.h b/engines/fullpipe/fullpipe.h
index 181e82c..394f6a0 100644
--- a/engines/fullpipe/fullpipe.h
+++ b/engines/fullpipe/fullpipe.h
@@ -108,6 +108,7 @@ public:
 	void updateEvents();
 
 	Graphics::Surface _backgroundSurface;
+	Graphics::PixelFormat *_origFormat;
 
 	GameLoader *_gameLoader;
 	GameProject *_gameProject;
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp
index 5f8177c..86eaf89 100644
--- a/engines/fullpipe/gfx.cpp
+++ b/engines/fullpipe/gfx.cpp
@@ -826,29 +826,21 @@ bool Bitmap::isPixelHitAtPos(int x, int y) {
 }
 
 bool Bitmap::isPixelAtHitPosRB(int x, int y) {
-	int ox = _x;
-	int oy = _y;
-
-	_x = _y = 0;
-
-	bool res = putDibRB(0, x, y);
-	_x = ox;
-	_y = oy;
+	if (!_surface)
+		return false;
 
-	return res;
+	return ((*((int32 *)_surface->getBasePtr(x, y)) & 0xff000000) != 0);
 }
 
 void Bitmap::decode(int32 *palette) {
 	_surface = new Graphics::TransparentSurface;
 
-	_surface->create(_width, _height, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
+	_surface->create(_width, _height, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
 
 	if (_type == MKTAG('R', 'B', '\0', '\0'))
 		putDibRB(palette);
 	else
 		putDibCB(palette);
-
-	_surface->convertToInPlace(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
 }
 
 void Bitmap::putDib(int x, int y, int32 *palette) {
@@ -885,8 +877,8 @@ void Bitmap::putDib(int x, int y, int32 *palette) {
 	g_fp->_system->copyRectToScreen(g_fp->_backgroundSurface.getBasePtr(x1, y1), g_fp->_backgroundSurface.pitch, x1, y1, sub.width(), sub.height());
 }
 
-bool Bitmap::putDibRB(int32 *palette, int pX, int pY) {
-	uint16 *curDestPtr;
+bool Bitmap::putDibRB(int32 *palette) {
+	uint32 *curDestPtr;
 	int endy;
 	int x;
 	int start1;
@@ -897,36 +889,18 @@ bool Bitmap::putDibRB(int32 *palette, int pX, int pY) {
 	uint16 *srcPtr2;
 	uint16 *srcPtr;
 
-	_x = _y = 0;
-
-	if (!palette && pX == -1) {
+	if (!palette) {
 		debug(2, "Bitmap::putDibRB(): Both global and local palettes are empty");
 		return false;
 	}
 
 	debug(8, "Bitmap::putDibRB()");
 
-	endx = _width + _x - 1;
-	endy = _height + _y - 1;
-
-	if (_x > 799 || endx < 0 || _y > 599 || endy < 0)
-		return false;
-
-	if (pX == -1) {
-		if (endy > 599)
-			endy = 599;
-
-		if (endx > 799)
-			endx = 799;
-	}
-
-	int startx = _x;
-	if (startx < 0)
-		startx = 0;
+	endx = _width - 1;
+	endy = _height - 1;
 
-	int starty = _y;
-	if (starty < 0)
-		starty = 0;
+	int startx = 0;
+	int starty = 0;
 
 	y = endy;
 
@@ -970,14 +944,9 @@ bool Bitmap::putDibRB(int32 *palette, int pX, int pY) {
 				if (fillLen > 0 || start1 >= 0) {
 					if (x <= 799 + 1 || (fillLen += 799 - x + 1, fillLen > 0)) {
 						if (y <= endy) {
-							if (pX == -1) {
-								int bgcolor = palette[(pixel >> 8) & 0xff];
-								curDestPtr = (uint16 *)_surface->getBasePtr(start1, y);
-								colorFill(curDestPtr, fillLen, bgcolor);
-							} else {
-								if (y == pY && pX >= start1 && pX < start1 + fillLen)
-									return true;
-							}
+							int bgcolor = palette[(pixel >> 8) & 0xff];
+							curDestPtr = (uint32 *)_surface->getBasePtr(start1, y);
+							colorFill(curDestPtr, fillLen, bgcolor);
 						}
 					}
 				}
@@ -1002,26 +971,18 @@ bool Bitmap::putDibRB(int32 *palette, int pX, int pY) {
 				}
 
 				if (y <= endy) {
-					if (pX == -1) {
-						curDestPtr = (uint16 *)_surface->getBasePtr(start1, y);
-						paletteFill(curDestPtr, (byte *)srcPtr2, fillLen, (int32 *)palette);
-					} else {
-						if (y == pY && pX >= start1 && pX < start1 + fillLen)
-							return true;
-					}
+					curDestPtr = (uint32 *)_surface->getBasePtr(start1, y);
+					paletteFill(curDestPtr, (byte *)srcPtr2, fillLen, (int32 *)palette);
 				}
 			}
 		}
 	}
 
-	//if (pX == -1)
-	//	g_fp->_system->copyRectToScreen(g_fp->_backgroundSurface.getBasePtr(startx, starty), g_fp->_backgroundSurface.pitch, startx, starty, endx + 1 - startx, endy + 1 - starty);
-
 	return false;
 }
 
 void Bitmap::putDibCB(int32 *palette) {
-	uint16 *curDestPtr;
+	uint32 *curDestPtr;
 	int endx;
 	int endy;
 	int bpp;
@@ -1071,12 +1032,12 @@ void Bitmap::putDibCB(int32 *palette) {
 
 	if (_flags & 0x1000000) {
 		for (int y = starty; y <= endy; srcPtr -= pitch, y++) {
-			curDestPtr = (uint16 *)_surface->getBasePtr(startx, y);
+			curDestPtr = (uint32 *)_surface->getBasePtr(startx, y);
 			copierKeyColor(curDestPtr, srcPtr, endx - startx + 1, _flags & 0xff, (int32 *)palette, cb05_format);
 		}
 	} else {
 		for (int y = starty; y <= endy; srcPtr -= pitch, y++) {
-			curDestPtr = (uint16 *)_surface->getBasePtr(startx, y);
+			curDestPtr = (uint32 *)_surface->getBasePtr(startx, y);
 			copier(curDestPtr, srcPtr, endx - startx + 1, (int32 *)palette, cb05_format);
 		}
 	}
@@ -1084,7 +1045,7 @@ void Bitmap::putDibCB(int32 *palette) {
 	//g_fp->_system->copyRectToScreen(g_fp->_backgroundSurface.getBasePtr(startx, starty), g_fp->_backgroundSurface.pitch, startx, starty, endx + 1 - startx, endy + 1 - starty);
 }
 
-void Bitmap::colorFill(uint16 *dest, int len, int32 color) {
+void Bitmap::colorFill(uint32 *dest, int len, int32 color) {
 #if 0
 	if (blendMode) {
 		if (blendMode != 1)
@@ -1095,12 +1056,17 @@ void Bitmap::colorFill(uint16 *dest, int len, int32 color) {
 		colorFill = ptrfillColor16bit;
 	}
 #endif
+	byte r, g, b;
+
+	g_fp->_origFormat->colorToRGB(color, r, g, b);
+
+	uint32 c = TS_ARGB(0xff, r, g, b);
 
 	for (int i = 0; i < len; i++)
-		*dest++ = (int16)(color & 0xffff);
+		*dest++ = c;
 }
 
-void Bitmap::paletteFill(uint16 *dest, byte *src, int len, int32 *palette) {
+void Bitmap::paletteFill(uint32 *dest, byte *src, int len, int32 *palette) {
 #if 0
 	if (blendMode) {
 		if (blendMode != 1)
@@ -1112,11 +1078,16 @@ void Bitmap::paletteFill(uint16 *dest, byte *src, int len, int32 *palette) {
 	}
 #endif
 
-	for (int i = 0; i < len; i++)
-		*dest++ = READ_LE_UINT32(&palette[*src++]) & 0xffff;
+	byte r, g, b;
+
+	for (int i = 0; i < len; i++) {
+		g_fp->_origFormat->colorToRGB(READ_LE_UINT32(&palette[*src++]) & 0xffff, r, g, b);
+
+		*dest++ = TS_ARGB(0xff, r, g, b);
+	}
 }
 
-void Bitmap::copierKeyColor(uint16 *dest, byte *src, int len, int keyColor, int32 *palette, bool cb05_format) {
+void Bitmap::copierKeyColor(uint32 *dest, byte *src, int len, int keyColor, int32 *palette, bool cb05_format) {
 #if 0
 	if (blendMode) {
 		if (blendMode == 1) {
@@ -1134,10 +1105,14 @@ void Bitmap::copierKeyColor(uint16 *dest, byte *src, int len, int keyColor, int3
 	}
 #endif
 
+	byte r, g, b;
+
 	if (!cb05_format) {
 		for (int i = 0; i < len; i++) {
-			if (*src != keyColor)
-				*dest = READ_LE_UINT32(&palette[*src]) & 0xffff;
+			if (*src != keyColor) {
+				g_fp->_origFormat->colorToRGB(READ_LE_UINT32(&palette[*src]) & 0xffff, r, g, b);
+				*dest = TS_ARGB(0xff, r, g, b);
+			}
 
 			dest++;
 			src++;
@@ -1146,8 +1121,10 @@ void Bitmap::copierKeyColor(uint16 *dest, byte *src, int len, int keyColor, int3
 		int16 *src16 = (int16 *)src;
 
 		for (int i = 0; i < len; i++) {
-			if (*src16 != 0)
-				*dest = *src16;
+			if (*src16 != 0) {
+				g_fp->_origFormat->colorToRGB(READ_LE_UINT16(src16) & 0xffff, r, g, b);
+				*dest = TS_ARGB(0xff, r, g, b);
+			}
 
 			dest++;
 			src16++;
@@ -1155,7 +1132,7 @@ void Bitmap::copierKeyColor(uint16 *dest, byte *src, int len, int keyColor, int3
 	}
 }
 
-void Bitmap::copier(uint16 *dest, byte *src, int len, int32 *palette, bool cb05_format) {
+void Bitmap::copier(uint32 *dest, byte *src, int len, int32 *palette, bool cb05_format) {
 #if 0
 	if (blendMode) {
 		if (blendMode == 1) {
@@ -1173,14 +1150,21 @@ void Bitmap::copier(uint16 *dest, byte *src, int len, int32 *palette, bool cb05_
 	}
 #endif
 
+	byte r, g, b;
+
 	if (!cb05_format) {
-		for (int i = 0; i < len; i++)
-			*dest++ = READ_LE_UINT32(&palette[*src++]) & 0xffff;
+		for (int i = 0; i < len; i++) {
+			g_fp->_origFormat->colorToRGB(READ_LE_UINT32(&palette[*src++]) & 0xffff, r, g, b);
+
+			*dest++ = TS_ARGB(0xff, r, g, b);
+		}
 	} else {
 		int16 *src16 = (int16 *)src;
 
-		for (int i = 0; i < len; i++)
-			*dest++ = *src16++;
+		for (int i = 0; i < len; i++) {
+			g_fp->_origFormat->colorToRGB(READ_LE_UINT32(src16++) & 0xffff, r, g, b);
+			*dest++ = TS_ARGB(0xff, r, g, b);
+		}
 	}
 }
 
diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h
index 48c90a6..0ad81af 100644
--- a/engines/fullpipe/gfx.h
+++ b/engines/fullpipe/gfx.h
@@ -47,13 +47,13 @@ struct Bitmap {
 	void load(Common::ReadStream *s);
 	void decode(int32 *palette);
 	void putDib(int x, int y, int32 *palette);
-	bool putDibRB(int32 *palette, int x = -1, int y = -1);
+	bool putDibRB(int32 *palette);
 	void putDibCB(int32 *palette);
 
-	void colorFill(uint16 *dest, int len, int32 color);
-	void paletteFill(uint16 *dest, byte *src, int len, int32 *palette);
-	void copierKeyColor(uint16 *dest, byte *src, int len, int keyColor, int32 *palette, bool cb05_format);
-	void copier(uint16 *dest, byte *src, int len, int32 *palette, bool cb05_format);
+	void colorFill(uint32 *dest, int len, int32 color);
+	void paletteFill(uint32 *dest, byte *src, int len, int32 *palette);
+	void copierKeyColor(uint32 *dest, byte *src, int len, int keyColor, int32 *palette, bool cb05_format);
+	void copier(uint32 *dest, byte *src, int len, int32 *palette, bool cb05_format);
 
 	Bitmap *reverseImage();
 	Bitmap *reverseImageRB();


Commit: e6af6328c7dab0d84ea5fe9f7317399f47a4381e
    https://github.com/scummvm/scummvm/commit/e6af6328c7dab0d84ea5fe9f7317399f47a4381e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2014-06-17T15:05:10+03:00

Commit Message:
FULLPIPE: Implement horizontal flipping

Changed paths:
    engines/fullpipe/gfx.cpp
    engines/fullpipe/gfx.h



diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp
index 86eaf89..dd2a026 100644
--- a/engines/fullpipe/gfx.cpp
+++ b/engines/fullpipe/gfx.cpp
@@ -33,55 +33,6 @@
 
 namespace Fullpipe {
 
-Bitmap::Bitmap() {
-	_x = 0;
-	_y = 0;
-	_width = 0;
-	_height = 0;
-	_pixels = 0;
-	_type = 0;
-	_dataSize = 0;
-	_flags = 0;
-	_surface = 0;
-}
-
-Bitmap::Bitmap(Bitmap *src) {
-	_x = src->_x;
-	_y = src->_y;
-	_flags = src->_flags;
-	_dataSize = src->_dataSize;
-	_type = src->_type;
-	_width = src->_width;
-	_height = src->_height;
-	_pixels = src->_pixels;
-	_surface = new Graphics::TransparentSurface(*src->_surface);
-}
-
-Bitmap::~Bitmap() {
-	if (_pixels)
-		free(_pixels);
-
-	delete _surface;
-
-	_pixels = 0;
-}
-
-void Bitmap::load(Common::ReadStream *s) {
-	debug(5, "Bitmap::load()");
-
-	_x = s->readUint32LE();
-	_y = s->readUint32LE();
-	_width = s->readUint32LE();
-	_height = s->readUint32LE();
-	s->readUint32LE(); // pixels
-	_type = s->readUint32LE();
-	_dataSize = s->readUint32LE();
-	_flags = s->readUint32LE();
-
-	debug(8, "Bitmap: x: %d y: %d w: %d h: %d dataSize: 0x%x", _x, _y, _width, _height, _dataSize);
-	debug(8, "Bitmap: type: %s (0x%04x) flags: 0x%x", Common::tag2string(_type).c_str(), _type, _flags);
-}
-
 Background::Background() {
 	_x = 0;
 	_y = 0;
@@ -795,6 +746,57 @@ int Picture::getPixelAtPosEx(int x, int y) {
 	return 0;
 }
 
+Bitmap::Bitmap() {
+	_x = 0;
+	_y = 0;
+	_width = 0;
+	_height = 0;
+	_pixels = 0;
+	_type = 0;
+	_dataSize = 0;
+	_flags = 0;
+	_surface = 0;
+	_flipping = Graphics::FLIP_NONE;
+}
+
+Bitmap::Bitmap(Bitmap *src) {
+	_x = src->_x;
+	_y = src->_y;
+	_flags = src->_flags;
+	_dataSize = src->_dataSize;
+	_type = src->_type;
+	_width = src->_width;
+	_height = src->_height;
+	_pixels = src->_pixels;
+	_surface = new Graphics::TransparentSurface(*src->_surface);
+	_flipping = src->_flipping;
+}
+
+Bitmap::~Bitmap() {
+	if (_pixels)
+		free(_pixels);
+
+	delete _surface;
+
+	_pixels = 0;
+}
+
+void Bitmap::load(Common::ReadStream *s) {
+	debug(5, "Bitmap::load()");
+
+	_x = s->readUint32LE();
+	_y = s->readUint32LE();
+	_width = s->readUint32LE();
+	_height = s->readUint32LE();
+	s->readUint32LE(); // pixels
+	_type = s->readUint32LE();
+	_dataSize = s->readUint32LE();
+	_flags = s->readUint32LE();
+
+	debug(8, "Bitmap: x: %d y: %d w: %d h: %d dataSize: 0x%x", _x, _y, _width, _height, _dataSize);
+	debug(8, "Bitmap: type: %s (0x%04x) flags: 0x%x", Common::tag2string(_type).c_str(), _type, _flags);
+}
+
 bool Bitmap::isPixelHitAtPos(int x, int y) {
 	if (x < _x || x >= _width + _x || y < _y || y >= _y + _height)
 		return false;
@@ -873,7 +875,7 @@ void Bitmap::putDib(int x, int y, int32 *palette) {
 	if (sub.width() <= 0 || sub.height() <= 0)
 		return;
 
-	_surface->blit(g_fp->_backgroundSurface, x1, y1, Graphics::FLIP_NONE, &sub);
+	_surface->blit(g_fp->_backgroundSurface, x1, y1, _flipping, &sub);
 	g_fp->_system->copyRectToScreen(g_fp->_backgroundSurface.getBasePtr(x1, y1), g_fp->_backgroundSurface.pitch, x1, y1, sub.width(), sub.height());
 }
 
@@ -989,21 +991,8 @@ void Bitmap::putDibCB(int32 *palette) {
 	uint pitch;
 	bool cb05_format;
 
-	_x = _y = 0;
-
-	endx = _width + _x - 1;
-	endy = _height + _y - 1;
-
-	debug(8, "Bitmap::putDibCB(): %d, %d, %d, %d [%d, %d]", _x, _y, endx, endy, _width, _height);
-
-	if (_x > 799 || endx < 0 || _y > 599 || endy < 0)
-		return;
-
-	if (endy > 599)
-		endy = 599;
-
-	if (endx > 799)
-		endx = 799;
+	endx = _width - 1;
+	endy = _height - 1;
 
 	cb05_format = (_type == MKTAG('C', 'B', '\05', 'e'));
 
@@ -1013,22 +1002,13 @@ void Bitmap::putDibCB(int32 *palette) {
 	bpp = cb05_format ? 2 : 1;
 	pitch = (bpp * _width + 3) & 0xFFFFFFFC;
 
-	byte *srcPtr = &_pixels[pitch * (endy - _y)];
+	byte *srcPtr = &_pixels[pitch * endy];
 
-	if (endy - _y < _height)
+	if (endy < _height)
 		srcPtr = &_pixels[pitch * (_height - 1)];
 
-	int starty = _y;
-	if (starty < 0) {
-		starty = 0;
-		srcPtr = &_pixels[pitch * (_height + _y)];
-	}
-
-	int startx = _x;
-	if (startx < 0) {
-		srcPtr += bpp * -_x;
-		startx = 0;
-	}
+	int starty = 0;
+	int startx = 0;
 
 	if (_flags & 0x1000000) {
 		for (int y = starty; y <= endy; srcPtr -= pitch, y++) {
@@ -1041,8 +1021,6 @@ void Bitmap::putDibCB(int32 *palette) {
 			copier(curDestPtr, srcPtr, endx - startx + 1, (int32 *)palette, cb05_format);
 		}
 	}
-
-	//g_fp->_system->copyRectToScreen(g_fp->_backgroundSurface.getBasePtr(startx, starty), g_fp->_backgroundSurface.pitch, startx, starty, endx + 1 - startx, endy + 1 - starty);
 }
 
 void Bitmap::colorFill(uint32 *dest, int len, int32 color) {
@@ -1169,18 +1147,12 @@ void Bitmap::copier(uint32 *dest, byte *src, int len, int32 *palette, bool cb05_
 }
 
 Bitmap *Bitmap::reverseImage() {
-	switch (_type) {
-	case MKTAG('R', 'B', '\0', '\0'):
-		return reverseImageRB();
-	case MKTAG('C', 'B', '\0', '\0'):
-		return reverseImageCB();
-	case MKTAG('C', 'B', '\05', 'e'):
-		return reverseImageCB05();
-	default:
-		error("Bitmap::reverseImage: Unknown image type: %x", _type);
-	}
+	Bitmap *res = new Bitmap(this);
 
-	return 0;
+	res->_flipping = Graphics::FLIP_H;
+	res->_pixels = 0;
+
+	return res;
 }
 
 Bitmap *Bitmap::reverseImageRB() {
diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h
index 0ad81af..3606a1a 100644
--- a/engines/fullpipe/gfx.h
+++ b/engines/fullpipe/gfx.h
@@ -39,6 +39,7 @@ struct Bitmap {
 	int _dataSize;
 	int _flags;
 	Graphics::TransparentSurface *_surface;
+	int _flipping;
 
 	Bitmap();
 	Bitmap(Bitmap *src);


Commit: 7c444319cbb14b95a5fe2c7cf2c5471ab065c961
    https://github.com/scummvm/scummvm/commit/7c444319cbb14b95a5fe2c7cf2c5471ab065c961
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2014-06-17T15:06:11+03:00

Commit Message:
FULLPIPE: cleanup

Changed paths:
    engines/fullpipe/gfx.cpp
    engines/fullpipe/gfx.h



diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp
index dd2a026..718a3a3 100644
--- a/engines/fullpipe/gfx.cpp
+++ b/engines/fullpipe/gfx.cpp
@@ -1155,58 +1155,6 @@ Bitmap *Bitmap::reverseImage() {
 	return res;
 }
 
-Bitmap *Bitmap::reverseImageRB() {
-	uint16 *newpixels = (uint16 *)calloc(((_dataSize + 15) & 0xfffffff0) + sizeof(Bitmap), 1);
-	uint16 *srcPtr = (uint16 *)_pixels;
-
-	int idx = 0;
-	while (srcPtr[idx] != 0x100) {
-		uint16 *srcPtr2 = &srcPtr[idx];
-
-		int prevIdx = idx;
-		int i = idx;
-
-		while (*srcPtr2) {
-			++srcPtr2;
-			++idx;
-		}
-
-		int idx2 = idx;
-
-		newpixels[idx] = srcPtr[idx];
-
-		while (i != idx) {
-			int fillLen = 2 - ((srcPtr[prevIdx] & 0xff) != 0 ? 1 : 0);
-			idx2 -= fillLen;
-			memcpy(&newpixels[idx2], &srcPtr[prevIdx], 2 * fillLen);
-			prevIdx = fillLen + i;
-			i += fillLen;
-		}
-		++idx;
-	}
-	newpixels[idx] = 256;
-
-	int oldBmp = ((_dataSize + 15) >> 1) & 0x7FFFFFF8;
-	memcpy(&newpixels[oldBmp], &srcPtr[oldBmp], sizeof(Bitmap));
-
-	Bitmap *res = new Bitmap(this);
-	res->_pixels = (byte *)newpixels;
-
-	return res;
-}
-
-Bitmap *Bitmap::reverseImageCB() {
-	warning("STUB: Bitmap::reverseImageCB()");
-
-	return this;
-}
-
-Bitmap *Bitmap::reverseImageCB05() {
-	warning("STUB: Bitmap::reverseImageCB05()");
-
-	return this;
-}
-
 Bitmap *Bitmap::flipVertical() {
 	warning("STUB: Bitmap::flipVertical()");
 
diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h
index 3606a1a..576ff7e 100644
--- a/engines/fullpipe/gfx.h
+++ b/engines/fullpipe/gfx.h
@@ -57,9 +57,6 @@ struct Bitmap {
 	void copier(uint32 *dest, byte *src, int len, int32 *palette, bool cb05_format);
 
 	Bitmap *reverseImage();
-	Bitmap *reverseImageRB();
-	Bitmap *reverseImageCB();
-	Bitmap *reverseImageCB05();
 	Bitmap *flipVertical();
 
 	void drawShaded(int type, int x, int y, byte *palette);


Commit: 6c8d48c5a533eac4494c231b9f488080e09e15b3
    https://github.com/scummvm/scummvm/commit/6c8d48c5a533eac4494c231b9f488080e09e15b3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2014-06-17T15:24:42+03:00

Commit Message:
FULLPIPE: Cleanup gfx code

Changed paths:
    engines/fullpipe/gfx.cpp
    engines/fullpipe/gfx.h
    engines/fullpipe/statics.cpp



diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp
index 718a3a3..2bed8a8 100644
--- a/engines/fullpipe/gfx.cpp
+++ b/engines/fullpipe/gfx.cpp
@@ -469,7 +469,7 @@ void Picture::freePicture() {
 	if (_bitmap) {
 		if (testFlags() && !_field_54) {
 			freeData();
-			free(_bitmap);
+			//free(_bitmap);
 			_bitmap = 0;
 		}
 	}
@@ -590,6 +590,8 @@ void Picture::getDibInfo() {
 	_bitmap->_pixels = _data;
 
 	_bitmap->decode((int32 *)(_paletteData ? _paletteData : g_fp->_globalPalette));
+
+	_bitmap->_pixels = 0;
 }
 
 Bitmap *Picture::getPixelData() {
@@ -801,33 +803,6 @@ bool Bitmap::isPixelHitAtPos(int x, int y) {
 	if (x < _x || x >= _width + _x || y < _y || y >= _y + _height)
 		return false;
 
-	int off;
-
-	if (_type == 'CB\x05e')
-		off = 2 * ((_width + 1) / 2);
-	else
-		off = 4 * ((_width + 3) / 4);
-
-	off = x + off * (_y + _height - y - 1) - _x;
-
-	if (_flags & 0x1000000) {
-		switch (_type) {
-		case 'CB\0\0':
-			if (_pixels[off] == (_flags & 0xff))
-				return false;
-			break;
-		case 'CB\x05e':
-			if (!*(int16 *)&_pixels[2 * off])
-				return false;
-			break;
-		case 'RB\0\0':
-			return isPixelAtHitPosRB(x, y);
-		}
-	}
-	return true;
-}
-
-bool Bitmap::isPixelAtHitPosRB(int x, int y) {
 	if (!_surface)
 		return false;
 
@@ -1146,13 +1121,13 @@ void Bitmap::copier(uint32 *dest, byte *src, int len, int32 *palette, bool cb05_
 	}
 }
 
-Bitmap *Bitmap::reverseImage() {
-	Bitmap *res = new Bitmap(this);
-
-	res->_flipping = Graphics::FLIP_H;
-	res->_pixels = 0;
+Bitmap *Bitmap::reverseImage(bool flip) {
+	if (flip)
+		_flipping = Graphics::FLIP_H;
+	else
+		_flipping = Graphics::FLIP_NONE;
 
-	return res;
+	return this;
 }
 
 Bitmap *Bitmap::flipVertical() {
diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h
index 576ff7e..d4d70fc 100644
--- a/engines/fullpipe/gfx.h
+++ b/engines/fullpipe/gfx.h
@@ -56,14 +56,13 @@ struct Bitmap {
 	void copierKeyColor(uint32 *dest, byte *src, int len, int keyColor, int32 *palette, bool cb05_format);
 	void copier(uint32 *dest, byte *src, int len, int32 *palette, bool cb05_format);
 
-	Bitmap *reverseImage();
+	Bitmap *reverseImage(bool flip = true);
 	Bitmap *flipVertical();
 
 	void drawShaded(int type, int x, int y, byte *palette);
 	void drawRotated(int x, int y, int angle, byte *palette);
 
 	bool isPixelHitAtPos(int x, int y);
-	bool isPixelAtHitPosRB(int x, int y);
 };
 
 class Picture : public MemoryObject {
diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp
index 292ef08..f757a51 100644
--- a/engines/fullpipe/statics.cpp
+++ b/engines/fullpipe/statics.cpp
@@ -528,7 +528,7 @@ void Movement::draw(bool flipFlag, int angle) {
 	if (_currMovement) {
 		bmp = _currDynamicPhase->getPixelData()->reverseImage();
 	} else {
-		bmp = _currDynamicPhase->getPixelData();
+		bmp = _currDynamicPhase->getPixelData()->reverseImage(false);
 	}
 
 	if (flipFlag) {
@@ -553,7 +553,7 @@ void Movement::draw(bool flipFlag, int angle) {
 				//vrtSetAlphaBlendMode(g_vrtDrawHandle, 0, 255);
 			} else {
 				//vrtSetAlphaBlendMode(g_vrtDrawHandle, 1, LOBYTE(_currDynamicPhase->rect.top));
-				_currDynamicPhase->_convertedBitmap->putDib(x, y, (int32 *)_currDynamicPhase->_paletteData);
+				_currDynamicPhase->_convertedBitmap->reverseImage(false)->putDib(x, y, (int32 *)_currDynamicPhase->_paletteData);
 				//vrtSetAlphaBlendMode(g_vrtDrawHandle, 0, 255);
 			}
 		}
@@ -1454,14 +1454,8 @@ bool Statics::load(MfcArchive &file) {
 void Statics::init() {
 	Picture::init();
 
-	if (_staticsId & 0x4000) {
-		Bitmap *bmp = _bitmap->reverseImage();
-
-		freePixelData();
-
-		_bitmap = bmp;
-		_data = bmp->_pixels;
-	}
+	if (_staticsId & 0x4000)
+		_bitmap->reverseImage();
 }
 
 Common::Point *Statics::getSomeXY(Common::Point &p) {
@@ -2211,7 +2205,7 @@ DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) {
 		_mfield_10 = src->_mfield_10;
 		_libHandle = src->_libHandle;
 
-		_bitmap = src->_bitmap;
+		_bitmap = src->_bitmap->reverseImage(false);
 		if (_bitmap)
 			_field_54 = 1;
 


Commit: a37bb1dabbe586df65ceb311af349343ebd2b973
    https://github.com/scummvm/scummvm/commit/a37bb1dabbe586df65ceb311af349343ebd2b973
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2014-06-17T15:34:24+03:00

Commit Message:
FULLPIPE: Fix crash in scene34. Now it is rendered properly

Changed paths:
    engines/fullpipe/statics.cpp



diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp
index f757a51..322ef54 100644
--- a/engines/fullpipe/statics.cpp
+++ b/engines/fullpipe/statics.cpp
@@ -2205,10 +2205,13 @@ DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) {
 		_mfield_10 = src->_mfield_10;
 		_libHandle = src->_libHandle;
 
-		_bitmap = src->_bitmap->reverseImage(false);
-		if (_bitmap)
+		_bitmap = src->_bitmap;
+		if (_bitmap) {
 			_field_54 = 1;
 
+			_bitmap = src->_bitmap->reverseImage(false);
+		}
+
 		_someX = src->_someX;
 		_someY = src->_someY;
 	}






More information about the Scummvm-git-logs mailing list