[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,2.150,2.151

Max Horn fingolfin at users.sourceforge.net
Fri Jun 6 13:56:05 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv4689

Modified Files:
	gfx.cpp 
Log Message:
rewrite code a bit: personally I find it much easier to understand what the code does this way (the &6 trick is cute, but obfuscates the meaning of the code)

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.150
retrieving revision 2.151
diff -u -d -r2.150 -r2.151
--- gfx.cpp	6 Jun 2003 12:27:33 -0000	2.150
+++ gfx.cpp	6 Jun 2003 20:55:39 -0000	2.151
@@ -1335,45 +1335,45 @@
 }
 
 void Gdi::drawStripC64Background(byte *dst, int stripnr, int height) {
-	int y, i, j;
 	height >>= 3;
-	for (y = 0; y < height; y++) {
+	for (int y = 0; y < height; y++) {
 		_C64Colors[3] = (_C64ColorMap[y + stripnr * height] & 7);
-		for (i = 0; i < 8; i++) {
-			for (j = 7; j >= 0; j--) {
-				byte c = _C64CharMap[_C64PicMap[y + stripnr * height] * 8 + i] >> (j & 6);
-				dst[7 - j] = _C64Colors[c & 3];
-			}
+		for (int i = 0; i < 8; i++) {
+			byte c = _C64CharMap[_C64PicMap[y + stripnr * height] * 8 + i];
+			dst[0] = dst[1] = _C64Colors[(c >> 6) & 3];
+			dst[2] = dst[3] = _C64Colors[(c >> 4) & 3];
+			dst[4] = dst[5] = _C64Colors[(c >> 2) & 3];
+			dst[6] = dst[7] = _C64Colors[(c >> 0) & 3];
 			dst += _vm->_screenWidth;
 		}
 	}
 }
 
 void Gdi::drawStripC64Object(byte *dst, int stripnr, int width, int height) {
-	int y, i, j;
 	height >>= 3;
 	width >>= 3;
-	for (y = 0; y < height; y++) {
+	for (int y = 0; y < height; y++) {
 		_C64Colors[3] = (_C64ObjectMap[y * width + stripnr + (width * height)] & 7);
-		for (i = 0; i < 8; i++) {
-			for (j = 7; j >= 0; j--) {
-				byte c = _C64CharMap[_C64ObjectMap[y * width + stripnr] * 8 + i] >> (j & 6);
-				dst[7 - j] = _C64Colors[c & 3];
-			}
+		for (int i = 0; i < 8; i++) {
+			byte c = _C64CharMap[_C64ObjectMap[y * width + stripnr] * 8 + i];
+			dst[0] = dst[1] = _C64Colors[(c >> 6) & 3];
+			dst[2] = dst[3] = _C64Colors[(c >> 4) & 3];
+			dst[4] = dst[5] = _C64Colors[(c >> 2) & 3];
+			dst[6] = dst[7] = _C64Colors[(c >> 0) & 3];
 			dst += _vm->_screenWidth;
 		}
 	}
 }
 
 void Gdi::drawStripC64Mask(byte *dst, int stripnr, int height) {
-	int y, i, j;
 	height >>= 3;
-	for (y = 0; y < height; y++) {
-		for (i = 0; i < 8; i++) {
-			for (j = 7; j >= 0; j--) {
-				byte c = _C64MaskChar[_C64MaskMap[y + stripnr * height] * 8 + i] >> (j & 6);
-				dst[7 - j] = c & 3;
-			}
+	for (int y = 0; y < height; y++) {
+		for (int i = 0; i < 8; i++) {
+			byte c = _C64MaskChar[_C64MaskMap[y + stripnr * height] * 8 + i];
+			dst[0] = dst[1] = (c >> 6) & 3;
+			dst[2] = dst[3] = (c >> 4) & 3;
+			dst[4] = dst[5] = (c >> 2) & 3;
+			dst[6] = dst[7] = (c >> 0) & 3;
 			dst += _vm->_screenWidth;
 		}
 	}





More information about the Scummvm-git-logs mailing list