[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,2.423,2.424 gfx.h,1.112,1.113 object.cpp,1.212,1.213 scumm.h,1.551,1.552 verbs.cpp,1.122,1.123

Max Horn fingolfin at users.sourceforge.net
Mon Mar 28 12:18:57 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16741

Modified Files:
	gfx.cpp gfx.h object.cpp scumm.h verbs.cpp 
Log Message:
Cleaned up the object mode code; removed the friend class ScummEngine from class Gdi; moved dither code to ScummEngine

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.423
retrieving revision 2.424
diff -u -d -r2.423 -r2.424
--- gfx.cpp	26 Mar 2005 06:00:57 -0000	2.423
+++ gfx.cpp	28 Mar 2005 20:18:15 -0000	2.424
@@ -540,10 +540,10 @@
 	}
 
 	if (_renderMode == Common::kRenderCGA)
-		gdi.ditherCGA(_compositeBuf + x + y * _screenWidth, _screenWidth, x, y, width, height);
+		ditherCGA(_compositeBuf + x + y * _screenWidth, _screenWidth, x, y, width, height);
 
 	if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
-		gdi.ditherHerc(_compositeBuf + x + y * _screenWidth, _herculesBuf, _screenWidth, &x, &y, &width, &height);
+		ditherHerc(_compositeBuf + x + y * _screenWidth, _herculesBuf, _screenWidth, &x, &y, &width, &height);
 		// center image on the screen
 		_system->copyRectToScreen(_herculesBuf + x + y * Common::kHercW, 
 			Common::kHercW, x + (Common::kHercW - _screenWidth * 2) / 2, y, width, height);
@@ -575,7 +575,7 @@
 // CGA dithers 4x4 square with direct substitutes
 // Odd lines have colors swapped, so there will be checkered patterns.
 // But apparently there is a mistake for 10th color.
-void Gdi::ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height) const {
+void ScummEngine::ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height) const {
 	byte *ptr;
 	int idx1, idx2;
 	static const byte cgaDither[2][2][16] = {
@@ -589,7 +589,7 @@
 
 		idx1 = (y + y1) % 2;
 
-		if (_vm->_version == 2)
+		if (_version == 2)
 			idx1 = 0;
 
 		for (int x1 = 0; x1 < width; x1++) {
@@ -608,7 +608,7 @@
 // dd      cccc0
 //         cccc1
 //         dddd0
-void Gdi::ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *width, int *height) const {
+void ScummEngine::ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *width, int *height) const {
 	byte *srcptr, *dstptr;
 	int xo = *x, yo = *y, widtho = *width, heighto = *height;
 	int idx1, idx2, dsty = 0, y1;
@@ -813,9 +813,7 @@
 	else
 		room = getResourceAddress(rtRoom, _roomResource);
 
-	gdi._objectMode = false;
-	gdi.drawBitmap(room + _IM00_offs,
-					&virtscr[0], s, 0, _roomWidth, virtscr[0].h, s, num, 0);
+	gdi.drawBitmap(room + _IM00_offs, &virtscr[0], s, 0, _roomWidth, virtscr[0].h, s, num, 0);
 }
 
 void ScummEngine::restoreBG(Common::Rect rect, byte backColor) {
@@ -1340,6 +1338,16 @@
 	// Check whether lights are turned on or not
 	const bool lightsOn = _vm->isLightOn();
 
+	_objectMode = (flag & dbObjectMode) == dbObjectMode;
+	
+	if (_objectMode && _vm->_version == 1) {
+		if (_vm->_features & GF_NES) {
+			// TODO: Maybe call decodeNESObject here?
+		} else {
+			decodeC64Gfx(ptr, _C64.objectMap, (width / 8) * (height / 8) * 3);
+		}
+	}
+
 	CHECK_HEAP;
 	if (_vm->_features & GF_SMALL_HEADER) {
 		smap_ptr = ptr;

Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- gfx.h	26 Mar 2005 06:00:58 -0000	1.112
+++ gfx.h	28 Mar 2005 20:18:34 -0000	1.113
@@ -202,11 +202,11 @@
 #define CHARSET_MASK_TRANSPARENCY	253
 
 class Gdi {
-	friend class ScummEngine;	// Mostly for the code in saveload.cpp ...
+//	friend class ScummEngine;	// Mostly for the code in saveload.cpp ...
 	ScummEngine *_vm;
 
 public:
-
+	byte _transparentColor;
 	int _numZBuffer;
 	int _imgBufOffs[8];
 	int32 _numStrips;
@@ -217,7 +217,6 @@
 protected:
 	byte *_roomPalette;
 	byte _decomp_shr, _decomp_mask;
-	byte _transparentColor;
 	uint32 _vertStripNextInc;
 
 	bool _zbufferDisabled;
@@ -270,11 +269,8 @@
 	void decompressMaskImg(byte *dst, const byte *src, int height) const;
 
 	/* Misc */
-	void ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height) const;
-	void ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *width, int *height) const;
+	void decodeC64Gfx(const byte *src, byte *dst, int size) const;
 
-	byte *getMaskBuffer(int x, int y, int z);
-	
 	int getZPlanes(const byte *smap_ptr, const byte *zplane_list[9], bool bmapImage) const;
 
 	StripTable *generateStripTable(const byte *src, int width, int height, StripTable *table) const;
@@ -288,7 +284,6 @@
 	void drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int width, const int height,
 	                int stripnr, int numstrip, byte flag);
 
-	void decodeC64Gfx(const byte *src, byte *dst, int size) const;
 	void decodeNESGfx(const byte *room);
 	void decodeNESObject(const byte *ptr, int xpos, int ypos, int width, int height);
 
@@ -297,14 +292,16 @@
 	
 	void copyVirtScreenBuffers(Common::Rect rect);
 
+	byte *getMaskBuffer(int x, int y, int z);
 	void disableZBuffer() { _zbufferDisabled = true; }
 	void enableZBuffer() { _zbufferDisabled = false; }
 
 	void resetBackground(int top, int bottom, int strip);
 
 	enum DrawBitmapFlags {
-		dbAllowMaskOr = 1,
-		dbDrawMaskOnAll = 2
+		dbAllowMaskOr   = 1 << 0,
+		dbDrawMaskOnAll = 1 << 1,
+		dbObjectMode    = 2 << 2
 	};
 };
 

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.212
retrieving revision 1.213
diff -u -d -r1.212 -r1.213
--- object.cpp	28 Mar 2005 19:49:02 -0000	1.212
+++ object.cpp	28 Mar 2005 20:18:35 -0000	1.213
@@ -433,7 +433,7 @@
 		return;
 
 	ObjectData &od = _objs[obj];
-	int xpos, ypos, height, width;
+	int height, width;
 	const byte *ptr;
 	int x, a, numstrip;
 	int tmp;
@@ -446,8 +446,8 @@
 
 	checkRange(_numGlobalObjects - 1, 0, od.obj_nr, "Object %d out of range in drawObject");
 
-	xpos = od.x_pos / 8;
-	ypos = od.y_pos;
+	const int xpos = od.x_pos / 8;
+	const int ypos = od.y_pos;
 
 	width = od.width / 8;
 	height = od.height &= 0xFFFFFFF8;	// Mask out last 3 bits
@@ -483,14 +483,11 @@
 	}
 
 	if (numstrip != 0) {
-		byte flags = od.flags;
+		byte flags = od.flags | Gdi::dbObjectMode;
 
-		gdi._objectMode = true;
 		if (_version == 1) {
 			if (_features & GF_NES) {
 				gdi.decodeNESObject(ptr, xpos, ypos, width, height);
-			} else {
-				gdi.decodeC64Gfx(ptr, gdi._C64.objectMap, width * (height / 8) * 3);
 			}
 		}
 		// Sam & Max needs this to fix object-layering problems with

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.551
retrieving revision 1.552
diff -u -d -r1.551 -r1.552
--- scumm.h	27 Mar 2005 01:07:22 -0000	1.551
+++ scumm.h	28 Mar 2005 20:18:35 -0000	1.552
@@ -983,6 +983,8 @@
 	void drawDirtyScreenParts();
 	void updateDirtyScreen(VirtScreenNumber slot);
 	void drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b);
+	void ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height) const;
+	void ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *width, int *height) const;
 
 public:
 	VirtScreen *findVirtScreen(int y);

Index: verbs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/verbs.cpp,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- verbs.cpp	25 Mar 2005 00:56:03 -0000	1.122
+++ verbs.cpp	28 Mar 2005 20:18:36 -0000	1.123
@@ -578,13 +578,9 @@
 		imptr = getObjectImage(obim, 1);
 	}
 	assert(imptr);
-	if (_version == 1) {
-		gdi._objectMode = true;
-		gdi.decodeC64Gfx(imptr, gdi._C64.objectMap, imgw * imgh * 3);
-	}
 	for (i = 0; i < imgw; i++) {
 		tmp = xstrip + i;
-		gdi.drawBitmap(imptr, vs, tmp, ydiff, imgw * 8, imgh * 8, i, 1, Gdi::dbAllowMaskOr);
+		gdi.drawBitmap(imptr, vs, tmp, ydiff, imgw * 8, imgh * 8, i, 1, Gdi::dbAllowMaskOr | Gdi::dbObjectMode);
 	}
 
 	vst = &_verbs[verb];





More information about the Scummvm-git-logs mailing list