[Scummvm-cvs-logs] SF.net SVN: scummvm: [30697] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Tue Jan 29 11:04:49 CET 2008


Revision: 30697
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30697&view=rev
Author:   peres001
Date:     2008-01-29 02:04:49 -0800 (Tue, 29 Jan 2008)

Log Message:
-----------
More cleanup: kBit2 is now replaced by the BackgroundInfo structure.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/graphics.h

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2008-01-29 09:58:21 UTC (rev 30696)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2008-01-29 10:04:49 UTC (rev 30697)
@@ -346,7 +346,7 @@
 
 void Gfx::updateScreen() {
 
-	g_system->copyRectToScreen((const byte*)_buffers[kBit2]->pixels, _buffers[kBit2]->pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight);
+	g_system->copyRectToScreen((const byte*)_backgroundInfo->bg.pixels, _backgroundInfo->bg.pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight);
 
 	Graphics::Surface *surf = g_system->lockScreen();
 	drawGfxObjects(*surf);
@@ -354,7 +354,7 @@
 	if (_halfbrite) {
 		// FIXME: the implementation of halfbrite is now largely sub-optimal in that a full screen
 		// rewrite is needed to apply the effect.
-		byte *src = (byte*)_buffers[kBit2]->pixels;
+		byte *src = (byte*)_backgroundInfo->bg.pixels;
 		byte *dst = (byte*)surf->pixels;
 		for (int i = 0; i < surf->w*surf->h; i++) {
 			*dst++ = *src++ | 0x20;
@@ -383,7 +383,7 @@
 //	graphic primitives
 //
 void Gfx::clearBackground() {
-	memset(_buffers[kBit2]->pixels, 0, _vm->_screenSize);
+	memset(_backgroundInfo->bg.pixels, 0, _vm->_screenSize);
 }
 
 
@@ -393,16 +393,16 @@
 	r.moveTo(x, y);
 
 	uint16 z = (mask) ? queryMask(y) : BUFFER_FOREGROUND;
-	blt(r, (byte*)surf.pixels, _buffers[kBit2], z, 0);
+	blt(r, (byte*)surf.pixels, &_backgroundInfo->bg, z, 0);
 }
 
 void Gfx::fillBackground(const Common::Rect& r, byte color) {
-	_buffers[kBit2]->fillRect(r, color);
+	_backgroundInfo->bg.fillRect(r, color);
 }
 
 void Gfx::invertBackground(const Common::Rect& r) {
 
-	byte *d = (byte*)_buffers[kBit2]->getBasePtr(r.left, r.top);
+	byte *d = (byte*)_backgroundInfo->bg.getBasePtr(r.left, r.top);
 
 	for (int i = 0; i < r.height(); i++) {
 		for (int j = 0; j < r.width(); j++) {
@@ -410,7 +410,7 @@
 			d++;
 		}
 
-		d += (_buffers[kBit2]->pitch - r.width());
+		d += (_backgroundInfo->bg.pitch - r.width());
 	}
 
 }
@@ -436,13 +436,13 @@
 	uint sPitch = r.width() - q.width();
 	uint dPitch = surf->w - q.width();
 
-    if (_depthMask && (z < BUFFER_FOREGROUND)) {
+    if (_backgroundInfo->mask.data && (z < BUFFER_FOREGROUND)) {
 
         for (uint16 i = 0; i < q.height(); i++) {
 
             for (uint16 j = 0; j < q.width(); j++) {
                 if (*s != transparentColor) {
-                    byte v = _depthMask->getValue(dp.x + j, dp.y + i);
+                    byte v = _backgroundInfo->mask.getValue(dp.x + j, dp.y + i);
                     if (z >= v) *d = *s;
                 }
 
@@ -709,33 +709,24 @@
 }
 
 
-void Gfx::setBackground(Graphics::Surface *surface) {
-	_buffers[kBit2] = surface;
 
-	_backgroundWidth = surface->w;
-	_backgroundHeight = surface->h;
-}
+void Gfx::copyRect(const Common::Rect &r, Graphics::Surface &src, Graphics::Surface &dst) {
 
-void Gfx::setMask(MaskBuffer *buffer) {
-	_depthMask = buffer;
-}
+	byte *s = (byte*)src.getBasePtr(r.left, r.top);
+	byte *d = (byte*)dst.getBasePtr(0, 0);
 
-void Gfx::copyRect(uint width, uint height, byte *dst, uint dstPitch, byte *src, uint srcPitch) {
+	for (uint16 i = 0; i < r.height(); i++) {
+		memcpy(d, s, r.width());
 
-	for (uint16 _si = 0; _si < height; _si++) {
-		memcpy(dst, src, width);
-
-		src += srcPitch;
-		dst += dstPitch;
+		s += src.pitch;
+		d += dst.pitch;
 	}
 
 	return;
 }
 
 void Gfx::grabBackground(const Common::Rect& r, Graphics::Surface &dst) {
-	byte *s = (byte*)_buffers[kBit2]->getBasePtr(r.left, r.top);
-	copyRect(r.width(), r.height(), (byte*)dst.pixels, dst.pitch, s, _backgroundWidth);
-	return;
+	copyRect(r, _backgroundInfo->bg, dst);
 }
 
 
@@ -756,13 +747,6 @@
 	_vm->initCommonGFX(_vm->getGameType() == GType_BRA);
 	g_system->endGFXTransaction();
 
-	_buffers[kBit2] = 0;
-	_depthMask = 0;
-
-	// FIXME: screen size must be decoupled from background size
-	_backgroundWidth = _vm->_screenWidth;
-	_backgroundHeight = _vm->_screenHeight;
-
 	setPalette(_palette);
 
 	_numBalloons = 0;
@@ -1032,26 +1016,14 @@
 void Gfx::setBackground(uint type, const char* name, const char* mask, const char* path) {
 
 	if (type == kBackgroundLocation) {
-
 		_disk->loadScenery(*_backgroundInfo, name, mask, path);
-
 		setPalette(_backgroundInfo->palette);
 		_palette.clone(_backgroundInfo->palette);
-		setBackground(&_backgroundInfo->bg);
-
-		if (_backgroundInfo->mask.data)
-			setMask(&_backgroundInfo->mask);
-
 	} else {
-
 		_disk->loadSlide(*_backgroundInfo, name);
-
 		setPalette(_backgroundInfo->palette);
-		setBackground(&_backgroundInfo->bg);
-
 	}
 
-	return;
 }
 
 

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2008-01-29 09:58:21 UTC (rev 30696)
+++ scummvm/trunk/engines/parallaction/graphics.h	2008-01-29 10:04:49 UTC (rev 30697)
@@ -274,7 +274,6 @@
 
 
 
-#define NUM_BUFFERS 4
 #define MAX_BALLOON_WIDTH 130
 
 class Parallaction;
@@ -347,11 +346,6 @@
 class Gfx {
 
 public:
-	enum Buffers {
-		// bit buffers
-		kBit2
-	};
-
 	Disk *_disk;
 
 	GfxObj* loadAnim(const char *name);
@@ -415,7 +409,6 @@
 	// misc
 	uint16 queryMask(uint16 v);
 	void updateScreen();
-	void setBackground(Graphics::Surface *surf);
 	void setMask(MaskBuffer *buffer);
 
 	// init
@@ -428,16 +421,11 @@
 	PaletteFxRange		_palettefx[6];
 	Palette				_palette;
 
-	int					_backgroundWidth;
-	int					_backgroundHeight;
-
 	uint				_screenX;		// scrolling position
 	uint				_screenY;
 
 protected:
 	Parallaction*		_vm;
-	Graphics::Surface	*_buffers[NUM_BUFFERS];
-	MaskBuffer			*_depthMask;
 	Font				*_font;
 	bool				_halfbrite;
 
@@ -481,7 +469,7 @@
 	void drawItems();
 	void drawBalloons();
 
-	void copyRect(uint width, uint height, byte *dst, uint dstPitch, byte *src, uint srcPitch);
+	void copyRect(const Common::Rect &r, Graphics::Surface &src, Graphics::Surface &dst);
 
 	int createBalloon(int16 w, int16 h, int16 winding, uint16 borderThickness);
 	Balloon *getBalloon(uint id);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list