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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Mon Aug 6 15:22:22 CEST 2007


Revision: 28469
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28469&view=rev
Author:   peres001
Date:     2007-08-06 06:22:21 -0700 (Mon, 06 Aug 2007)

Log Message:
-----------
Changed internal graphics buffers to use Surface instead of vanilla arrays. ScummVM's stock surfaces are used for the moment.

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	2007-08-06 08:45:59 UTC (rev 28468)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2007-08-06 13:22:21 UTC (rev 28469)
@@ -32,8 +32,6 @@
 
 namespace Parallaction {
 
-byte *		Gfx::_buffers[];
-
 #define BALLOON_WIDTH	12
 #define BALLOON_HEIGHT	10
 
@@ -80,7 +78,7 @@
 
 	winding = (winding == 0 ? 1 : 0);
 	byte *s = _resBalloon[winding];
-	byte *d = _buffers[kBitFront] + (r.left + (r.width()+5)/2 - 5) + (r.bottom - 1) * _vm->_screenWidth;
+	byte *d = (byte*)_buffers[kBitFront]->getBasePtr(r.left + (r.width()+5)/2 - 5, r.bottom - 1);
 
 	for (uint16 i = 0; i < BALLOON_HEIGHT; i++) {
 		for (uint16 j = 0; j < BALLOON_WIDTH; j++) {
@@ -256,14 +254,14 @@
 
 void Gfx::updateScreen() {
 //	  printf("Gfx::updateScreen()\n");
-	g_system->copyRectToScreen(_buffers[kBitFront], _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
+	g_system->copyRectToScreen((const byte*)_buffers[kBitFront]->pixels, _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
 	g_system->updateScreen();
 	return;
 }
 
 
 void Gfx::swapBuffers() {
-	byte *temp = _buffers[kBitFront];
+	Graphics::Surface *temp = _buffers[kBitFront];
 	_buffers[kBitFront] = _buffers[kBitBack];
 	_buffers[kBitBack] = temp;
 	updateScreen();
@@ -275,7 +273,7 @@
 //	graphic primitives
 //
 void Gfx::clearScreen(Gfx::Buffers buffer) {
-	memset(_buffers[buffer], 0, _vm->_screenSize);
+	memset(_buffers[buffer]->pixels, 0, _vm->_screenSize);
 
 	if (buffer == kBitFront) updateScreen();
 
@@ -284,7 +282,7 @@
 
 
 void Gfx::copyScreen(Gfx::Buffers srcbuffer, Gfx::Buffers dstbuffer) {
-	memcpy(_buffers[dstbuffer], _buffers[srcbuffer], _vm->_screenSize);
+	memcpy(_buffers[dstbuffer]->pixels, _buffers[srcbuffer]->pixels, _vm->_screenSize);
 
 //	if (dstbuffer == kBitFront) updateScreen();
 
@@ -294,7 +292,7 @@
 void Gfx::floodFill(Gfx::Buffers buffer, const Common::Rect& r, byte color) {
 //	printf("Gfx::floodFill(%i, %i, %i, %i, %i)\n", color, left, top, right, bottom);
 
-	byte *d = _buffers[buffer] + (r.left + r.top * _vm->_screenWidth);
+	byte *d = (byte*)_buffers[buffer]->getBasePtr(r.left, r.top);
 	uint16 w = r.width() + 1;
 	uint16 h = r.height() + 1;
 
@@ -333,7 +331,7 @@
 	screenClip(q, dp);
 
 	byte *s = data + q.left + q.top * r.width();
-	byte *d = _buffers[buffer] + dp.x + dp.y * _vm->_screenWidth;
+	byte *d = (byte*)_buffers[buffer]->getBasePtr(dp.x, dp.y);
 
 	for (uint16 i = q.top; i < q.bottom; i++) {
 		for (uint16 j = q.left; j < q.right; j++) {
@@ -358,12 +356,12 @@
 	screenClip(q, dp);
 
 	byte *s = data + q.left + q.top * r.width();
-	byte *d = _buffers[buffer] + dp.x + dp.y * _vm->_screenWidth;
+	byte *d = (byte*)_buffers[buffer]->getBasePtr(dp.x, dp.y);
 
 	for (uint16 i = q.top; i < q.bottom; i++) {
 
 		uint16 n = dp.x % 4;
-		byte *m = _buffers[kMask0] + dp.x/4 + (dp.y + i - q.top)*_vm->_screenMaskWidth;
+		byte *m = _depthMask + dp.x/4 + (dp.y + i - q.top)*_vm->_screenMaskWidth;
 
 		for (uint16 j = q.left; j < q.right; j++) {
 			if (*s != 0) {
@@ -513,7 +511,7 @@
 
 void Gfx::backupDoorBackground(DoorData *data, int16 x, int16 y) {
 
-	byte *s = _buffers[kBit2] + x + y * _vm->_screenWidth;
+	byte *s = (byte*)_buffers[kBit2]->getBasePtr(x, y);
 	byte *d = data->_background;
 
 	for (uint16 i = 0; i < data->_cnv->_height ; i++) {
@@ -529,7 +527,7 @@
 void Gfx::backupGetBackground(GetData *data, int16 x, int16 y) {
 
 	byte *t = data->_cnv->_data0;
-	byte *s = _buffers[kBitBack] + x + y * _vm->_screenWidth;
+	byte *s = (byte*)_buffers[kBitBack]->getBasePtr(x, y);
 	byte *d = data->_backup;
 
 	for (uint16 i = 0; i < data->_cnv->_height ; i++) {
@@ -554,8 +552,8 @@
 
 	byte *t = cnv->_data0;
 	byte *s = background;
-	byte *d0 = _buffers[kBitBack] + r.left + r.top * _vm->_screenWidth;
-	byte *d1 = _buffers[kBit2] + r.left + r.top * _vm->_screenWidth;
+	byte *d0 = (byte*)_buffers[kBitBack]->getBasePtr(r.left, r.top);
+	byte *d1 = (byte*)_buffers[kBit2]->getBasePtr(r.left, r.top);
 
 	for (uint16 i = 0; i < r.height() ; i++) {
 		for (uint16 j = 0; j < r.width() ; j++) {
@@ -624,7 +622,7 @@
 }
 
 void Gfx::displayString(uint16 x, uint16 y, const char *text, byte color) {
-	byte *dst = _buffers[kBitFront] + x + y*_vm->_screenWidth;
+	byte *dst = (byte*)_buffers[kBitFront]->getBasePtr(x, y);
 	_font->setColor(color);
 	_font->drawString(dst, _vm->_screenWidth, text);
 }
@@ -746,12 +744,7 @@
 	Common::Rect q(width, height);
 	q.moveTo(left, top);
 
-	copyRect(
-		kBitBack,
-		q,
-		_buffers[kBit2] + q.left + q.top * _vm->_screenWidth,
-		_vm->_screenWidth
-	);
+	copyRect(kBitBack, q, (byte*)_buffers[kBit2]->getBasePtr(q.left, q.top), _vm->_screenWidth);
 
 	return;
 }
@@ -771,19 +764,19 @@
 
 
 void Gfx::setBackground(byte *background) {
-	memcpy(_buffers[kBitBack], background, _vm->_screenSize);
+	memcpy(_buffers[kBitBack]->pixels, background, _vm->_screenSize);
 	copyScreen(kBitBack, kBit2);
 }
 
 void Gfx::setMask(byte *mask) {
-	memcpy(_buffers[kMask0], mask, _vm->_screenMaskSize);
+	memcpy(_depthMask, mask, _vm->_screenMaskSize);
 }
 
 
 
 void Gfx::copyRect(Gfx::Buffers dstbuffer, const Common::Rect& r, byte *src, uint16 pitch) {
 
-	byte *d = _buffers[dstbuffer] + r.left + _vm->_screenWidth * r.top;
+	byte *d = (byte*)_buffers[dstbuffer]->getBasePtr(r.left, r.top);
 	byte *s = src;
 
 	for (uint16 _si = 0; _si < r.height(); _si++) {
@@ -799,7 +792,7 @@
 
 void Gfx::grabRect(byte *dst, const Common::Rect& r, Gfx::Buffers srcbuffer, uint16 pitch) {
 
-	byte *s = _buffers[srcbuffer] + r.left + _vm->_screenWidth * r.top;
+	byte *s = (byte*)_buffers[srcbuffer]->getBasePtr(r.left, r.top);
 
 	for (uint16 i = 0; i < r.height(); i++) {
 		memcpy(dst, s, r.width());
@@ -819,7 +812,7 @@
 void Gfx::plotMaskPixel(uint16 x, uint16 y, byte color) {
 
 	uint16 _ax = x + y * _vm->_screenWidth;
-	_buffers[kMask0][_ax >> 2] &= ~(3 << ((_ax & 3) << 1));
+	_depthMask[_ax >> 2] &= ~(3 << ((_ax & 3) << 1));
 
 	return;
 }
@@ -828,7 +821,7 @@
 	uint16 _di = r.left/4 + r.top * _vm->_screenMaskWidth;
 
 	for (uint16 _si = r.top; _si < r.bottom; _si++) {
-		memset(&_buffers[kMask0][_di], color, r.width()/4+1);
+		memset(&_depthMask[_di], color, r.width()/4+1);
 		_di += _vm->_screenMaskWidth;
 	}
 
@@ -836,7 +829,7 @@
 
 }
 void Gfx::intGrottaHackMask() {
-	memset(_buffers[kMask0] + 3600, 0, 3600);
+	memset(_depthMask + 3600, 0, 3600);
 	_bgLayers[1] = 500;
 	return;
 }
@@ -858,11 +851,15 @@
 	g_system->initSize(_vm->_screenWidth, _vm->_screenHeight);
 	g_system->endGFXTransaction();
 
-	_buffers[kBitFront] = (byte*)malloc(_vm->_screenSize);
-	_buffers[kBitBack]	= (byte*)malloc(_vm->_screenSize);
-	_buffers[kBit2]   = (byte*)malloc(_vm->_screenSize);
-	_buffers[kMask0] = (byte*)malloc(_vm->_screenMaskWidth * _vm->_screenHeight);
+	_buffers[kBitFront] = new Graphics::Surface;
+	_buffers[kBitFront]->create(_vm->_screenWidth, _vm->_screenHeight, 1);
+	_buffers[kBitBack] = new Graphics::Surface;
+	_buffers[kBitBack]->create(_vm->_screenWidth, _vm->_screenHeight, 1);
+	_buffers[kBit2] = new Graphics::Surface;
+	_buffers[kBit2]->create(_vm->_screenWidth, _vm->_screenHeight, 1);
 
+	_depthMask = (byte*)malloc(_vm->_screenMaskWidth * _vm->_screenHeight);
+
 	setBlackPalette();
 
 	_bgLayers[0] = _bgLayers[1] = _bgLayers[2] = _bgLayers[3] = 0;
@@ -882,11 +879,15 @@
 
 Gfx::~Gfx() {
 
-	free(_buffers[kMask0]);
-	free(_buffers[kBitFront]);
-	free(_buffers[kBitBack]);
-	free(_buffers[kBit2]);
+	free(_depthMask);
 
+	_buffers[kBitFront]->free();
+	delete _buffers[kBitFront];
+	_buffers[kBitBack]->free();
+	delete _buffers[kBitBack];
+	_buffers[kBit2]->free();
+	delete _buffers[kBit2];
+
 	delete _fonts[kFontDialogue];
 	delete _fonts[kFontLabel];
 	delete _fonts[kFontMenu];

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2007-08-06 08:45:59 UTC (rev 28468)
+++ scummvm/trunk/engines/parallaction/graphics.h	2007-08-06 13:22:21 UTC (rev 28469)
@@ -29,6 +29,7 @@
 #include "common/rect.h"
 #include "common/stream.h"
 
+#include "graphics/surface.h"
 
 #include "parallaction/defs.h"
 
@@ -154,9 +155,7 @@
 		// bit buffers
 		kBitFront,
 		kBitBack,
-		kBit2,
-		// mask buffers
-		kMask0
+		kBit2
 	};
 
 public:
@@ -233,7 +232,8 @@
 
 protected:
 	Parallaction*		_vm;
-	static byte *		_buffers[NUM_BUFFERS];
+	Graphics::Surface	*_buffers[NUM_BUFFERS];
+	byte				*_depthMask;
 	static byte			_mouseArrow[256];
 	StaticCnv			*_mouseComposedArrow;
 	Font				*_font;


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