[Scummvm-cvs-logs] CVS: scummvm/scumm charset.cpp,2.75,2.76 gfx.cpp,2.245,2.246 nut_renderer.cpp,1.36,1.37 script_v6.cpp,1.238,1.239 scummvm.cpp,2.529,2.530 verbs.cpp,1.85,1.86

Max Horn fingolfin at users.sourceforge.net
Sun Jan 4 05:21:09 CET 2004


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

Modified Files:
	charset.cpp gfx.cpp nut_renderer.cpp script_v6.cpp scummvm.cpp 
	verbs.cpp 
Log Message:
replaced many instances of _screenWidth by VirtScreen::width, where approriate (there are cases, like when dealing with the camera, where _screenWidth is correct; in other places we still use it, because the VirtScreen is not available in that place at this time, will be fixed later). Reason for all this: eventually a clean seperation will allow us to use a main screen which is wider than the real screen width -> useful for V7+ smooth scrolling

Index: charset.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/charset.cpp,v
retrieving revision 2.75
retrieving revision 2.76
diff -u -d -r2.75 -r2.76
--- charset.cpp	3 Jan 2004 22:45:23 -0000	2.75
+++ charset.cpp	4 Jan 2004 13:09:02 -0000	2.76
@@ -973,7 +973,7 @@
 	
 	drawTop = _top - vs->topline;
 	char_ptr = _fontPtr + chr * 8;
-	dest_ptr = vs->screenPtr + vs->xstart + drawTop * _vm->_screenWidth + _left;
+	dest_ptr = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
 	mask_ptr = _vm->getMaskBuffer(_left, drawTop, 0);
 	useMask = (vs->number == 0 && !_ignoreCharsetMask);
 
@@ -1091,12 +1091,12 @@
 
 
 	byte *mask = _vm->getMaskBuffer(_left, drawTop, 0);
-	byte *dst = vs->screenPtr + vs->xstart + drawTop * _vm->_screenWidth + _left;
+	byte *dst = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
 
 	byte *back = dst;
 	if (_blitAlso) {
 		dst = _vm->getResourceAddress(rtBuffer, vs->number + 5)
-			+ vs->xstart + drawTop * _vm->_screenWidth + _left;
+			+ vs->xstart + drawTop * vs->width + _left;
 	}
 
 	if (is2byte) {
@@ -1110,8 +1110,8 @@
 		int h = height;
 		do {
 			memcpy(back, dst, width);
-			back += _vm->_screenWidth;
-			dst += _vm->_screenWidth;
+			back += vs->width;
+			dst += vs->width;
 		} while (--h);
 	}
 	
@@ -1167,7 +1167,7 @@
 				maskpos++;
 			}
 		}
-		dst += _vm->_screenWidth - width;
+		dst += vs->width - width;
 		mask += _vm->gdi._numStrips;
 	}
 }
@@ -1189,8 +1189,8 @@
 			if ((bits & revBitMask[x % 8]) && y + drawTop >= 0) {
 				if (_dropShadow) {
 					*(dst + 1) = _shadowColor;
-					*(dst + _vm->_screenWidth) = _shadowColor;
-					*(dst + _vm->_screenWidth + 1) = _shadowColor;
+					*(dst + vs->width) = _shadowColor;
+					*(dst + vs->width + 1) = _shadowColor;
 				}					
 				*dst = _color;
 				if (useMask) {
@@ -1215,7 +1215,7 @@
 			}
 		}
 
-		dst += _vm->_screenWidth - width;
+		dst += vs->width - width;
 		mask += _vm->gdi._numStrips;
 	}
 }

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.245
retrieving revision 2.246
diff -u -d -r2.245 -r2.246
--- gfx.cpp	4 Jan 2004 12:35:51 -0000	2.245
+++ gfx.cpp	4 Jan 2004 13:09:02 -0000	2.246
@@ -228,8 +228,12 @@
 	}
 
 	if (!getResourceAddress(rtBuffer, 4)) {
-		// Since the size of screen 3 is fixed, there is no need to reallocate it
-		// if its size changed.
+		// Since the size of screen 3 is fixed, there is no need to reallocate
+		// it if its size changed.
+		// Not sure what it is good for, though. I think it may have been used
+		// in pre-V7 for the games messages (like 'Pause', Yes/No dialogs,
+		// version display, etc.). I don't know about V7, maybe the same is the
+		// case there. If so, we could probably just remove it completely.
 		if (_version >= 7) {
 			initVirtScreen(kUnkVirtScreen, 0, (_screenHeight / 2) - 10, _screenWidth, 13, false, false);
 		} else {
@@ -258,7 +262,7 @@
 	}
 
 	vs->number = slot;
-	vs->width = _screenWidth;
+	vs->width = width;
 	vs->topline = top;
 	vs->height = height;
 	vs->alloctwobuffers = twobufs;
@@ -268,10 +272,16 @@
 
 	size = vs->width * vs->height;
 	if (vs->scrollable) {
+		// Allow enough spaces so that rooms can be up to 4 resp. 8 screens
+		// wide. To achieve (horizontal!) scrolling, we use a neat trick:
+		// only the offset into the screen buffer (xstart) is changed. That way
+		// very little of the screen has to be redrawn, and we have a very low
+		// memory overhead (namely for every pixel we want to scroll, we need
+		// one additional byte in the buffer).
 		if (_version >= 7) {
-			size += _screenWidth * 8;
+			size += width * 8;
 		} else {
-			size += _screenWidth * 4;
+			size += width * 4;
 		}
 	}
 
@@ -455,8 +465,8 @@
 	if (_vm->_screenTop < 0)
 		_vm->_screenTop = 0;
 
-	ptr = vs->screenPtr + (x + vs->xstart) + (_vm->_screenTop + t) * _vm->_screenWidth;
-	_vm->_system->copy_rect(ptr, _vm->_screenWidth, x, vs->topline + t, w, height);
+	ptr = vs->screenPtr + (x + vs->xstart) + (_vm->_screenTop + t) * vs->width;
+	_vm->_system->copy_rect(ptr, vs->width, x, vs->topline + t, w, height);
 }
 
 /**
@@ -497,6 +507,9 @@
 	assert(h > 0);
 	assert(src != NULL);
 	assert(dst != NULL);
+	
+	// TODO: This function currently always assumes that srcPitch == dstPitch
+	// and furthermore that both equal _screenWidth.
 
 	if (w==_screenWidth)
 		memcpy (dst, src, w*h);
@@ -554,19 +567,19 @@
 	
 	markRectAsDirty(vs->number, x, x2, y, y2, 0);
 
-	backbuff = vs->screenPtr + vs->xstart + y * _screenWidth + x;
+	backbuff = vs->screenPtr + vs->xstart + y * vs->width + x;
 
 	width = x2 - x;
 	height = y2 - y;
 	if (color == -1) {
 		if (vs->number != kMainVirtScreen)
 			error("can only copy bg to main window");
-		bgbuff = getResourceAddress(rtBuffer, vs->number + 5) + vs->xstart + y * _screenWidth + x;
+		bgbuff = getResourceAddress(rtBuffer, vs->number + 5) + vs->xstart + y * vs->width + x;
 		blit(backbuff, bgbuff, width, height);
 	} else {
 		while (height--) {
 			memset(backbuff, color, width);
-			backbuff += _screenWidth;
+			backbuff += vs->width;
 		}
 	}
 }
@@ -625,6 +638,7 @@
 
 void ScummEngine::drawFlashlight() {
 	int i, j, offset, x, y;
+	VirtScreen *vs = &virtscr[kMainVirtScreen];
 
 	// Remove the flash light first if it was previously drawn
 	if (_flashlight.isDrawn) {
@@ -635,7 +649,7 @@
 			i = _flashlight.h;
 			do {
 				memset(_flashlight.buffer, 0, _flashlight.w);
-				_flashlight.buffer += _screenWidth;
+				_flashlight.buffer += vs->width;
 			} while (--i);
 		}
 		_flashlight.isDrawn = false;
@@ -646,8 +660,8 @@
 
 	// Calculate the area of the flashlight
 	if (_gameId == GID_ZAK256 || _version <= 2) {
-		x = _mouse.x + virtscr[0].xstart;
-		y = _mouse.y - virtscr[0].topline;
+		x = _mouse.x + vs->xstart;
+		y = _mouse.y - vs->topline;
 	} else {
 		Actor *a = derefActor(VAR(VAR_EGO), "drawFlashlight");
 		x = a->_pos.x;
@@ -668,20 +682,20 @@
 		_flashlight.x = gdi._numStrips * 8 - _flashlight.w;
 	if (_flashlight.y < 0)
 		_flashlight.y = 0;
-	else if (_flashlight.y + _flashlight.h> virtscr[0].height)
-		_flashlight.y = virtscr[0].height - _flashlight.h;
+	else if (_flashlight.y + _flashlight.h> vs->height)
+		_flashlight.y = vs->height - _flashlight.h;
 
 	// Redraw any actors "under" the flashlight
 	for (i = _flashlight.x / 8; i < (_flashlight.x + _flashlight.w) / 8; i++) {
 		assert(0 <= i && i < gdi._numStrips);
 		setGfxUsageBit(_screenStartStrip + i, USAGE_BIT_DIRTY);
-		virtscr[0].tdirty[i] = 0;
-		virtscr[0].bdirty[i] = virtscr[0].height;
+		vs->tdirty[i] = 0;
+		vs->bdirty[i] = vs->height;
 	}
 
 	byte *bgbak;
-	offset = _flashlight.y * _screenWidth + virtscr[0].xstart + _flashlight.x;
-	_flashlight.buffer = virtscr[0].screenPtr + offset;
+	offset = _flashlight.y * vs->width + vs->xstart + _flashlight.x;
+	_flashlight.buffer = vs->screenPtr + offset;
 	bgbak = getResourceAddress(rtBuffer, 5) + offset;
 
 	blit(_flashlight.buffer, bgbak, _flashlight.w, _flashlight.h);
@@ -691,9 +705,9 @@
 	int corner_data[] = { 8, 6, 4, 3, 2, 2, 1, 1 };
 	int minrow = 0;
 	int maxcol = _flashlight.w - 1;
-	int maxrow = (_flashlight.h - 1) * _screenWidth;
+	int maxrow = (_flashlight.h - 1) * vs->width;
 
-	for (i = 0; i < 8; i++, minrow += _screenWidth, maxrow -= _screenWidth) {
+	for (i = 0; i < 8; i++, minrow += vs->width, maxrow -= vs->width) {
 		int d = corner_data[i];
 
 		for (j = 0; j < d; j++) {
@@ -811,16 +825,16 @@
 		rect.left = 0;
 	if (rect.right < 0)
 		rect.right = 0;
-	if (rect.left > _screenWidth)
+	if (rect.left > vs->width)
 		return;
-	if (rect.right > _screenWidth)
-		rect.right = _screenWidth;
+	if (rect.right > vs->width)
+		rect.right = vs->width;
 	if (rect.bottom >= height)
 		rect.bottom = height;
 
 	markRectAsDirty(vs->number, rect.left, rect.right, rect.top - topline, rect.bottom - topline, USAGE_BIT_RESTORED);
 
-	int offset = (rect.top - topline) * _screenWidth + vs->xstart + rect.left;
+	int offset = (rect.top - topline) * vs->width + vs->xstart + rect.left;
 	backbuff = vs->screenPtr + offset;
 	bgbak = getResourceAddress(rtBuffer, vs->number + 5) + offset;
 
@@ -855,7 +869,7 @@
 	} else {
 		while (height--) {
 			memset(backbuff, backColor, width);
-			backbuff += _screenWidth;
+			backbuff += vs->width;
 		}
 	}
 }
@@ -981,7 +995,7 @@
 		warning("Gdi::drawBitmap, strip drawn to %d below window bottom %d", bottom, vs->height);
 	}
 
-	_vertStripNextInc = height * _vm->_screenWidth - 1;
+	_vertStripNextInc = height * vs->width - 1;
 
 	sx = x;
 	if (vs->scrollable)
@@ -1054,7 +1068,7 @@
 				}
 				if (left <= theX && theX < right) {
 					*dst = *ptr_dither_table++;
-					dst += _vm->_screenWidth;
+					dst += vs->width;
 				}
 			}
 			if (left <= theX && theX < right) {
@@ -1241,8 +1255,8 @@
 						dst[j] = dst2[j] = 12+i;
 					maskbits <<= 1;
 				}
-				dst += _vm->_screenWidth;
-				dst2 += _vm->_screenWidth;
+				dst += vs->width;
+				dst2 += vs->width;
 				mask_ptr += _numStrips;
 			}
 		}
@@ -3462,7 +3476,7 @@
 		return;
 	}
 
-	grabCursor(vs->screenPtr + (y - vs->topline) * _screenWidth + x, w, h);
+	grabCursor(vs->screenPtr + (y - vs->topline) * vs->width + x, w, h);
 
 }
 
@@ -3503,7 +3517,7 @@
 	for (i = 0; i < h; i++) {
 		memcpy(dst, src, w);
 		dst += w;
-		src += _screenWidth;
+		src += vs->width;
 	}
 
 	drawBox(0, 0, w - 1, h - 1, 0xFF);
@@ -3521,7 +3535,7 @@
 
 	for (i = 0; i < h; i++) {
 		memcpy(dst, src, w);
-		dst += _screenWidth;
+		dst += vs->width;
 		src += w;
 	}
 

Index: nut_renderer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/nut_renderer.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- nut_renderer.cpp	8 Nov 2003 21:59:32 -0000	1.36
+++ nut_renderer.cpp	4 Jan 2004 13:09:02 -0000	1.37
@@ -243,6 +243,7 @@
 		return;
 	}
 
+	VirtScreen *vs = &_vm->virtscr[kMainVirtScreen];
 	byte *dst, *mask = NULL;
 
 	// HACK: we draw the character a total of 7 times: 6 times shifted
@@ -262,7 +263,7 @@
 		y += offsetY[i];
 		color = cTable[i];
 		
-		dst = _vm->virtscr[0].screenPtr + (y + _vm->_screenTop) * _vm->_screenWidth + x + _vm->virtscr[0].xstart;
+		dst = vs->screenPtr + (y + _vm->_screenTop) * vs->width + x + vs->xstart;
 		if (useMask)
 			mask = _vm->getMaskBuffer(x, y + _vm->_screenTop, 0);
 		

Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.238
retrieving revision 1.239
diff -u -d -r1.238 -r1.239
--- script_v6.cpp	3 Jan 2004 21:26:44 -0000	1.238
+++ script_v6.cpp	4 Jan 2004 13:09:02 -0000	1.239
@@ -3257,7 +3257,7 @@
 		return;
 	}
 
-	int offset = (y - vs->topline) * _screenWidth + x + _screenLeft;
+	int offset = (y - vs->topline) * vs->width + x + _screenLeft;
 
 	byte area = *(getResourceAddress(rtBuffer, vs->number + 1) + offset);
 	push(area);

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.529
retrieving revision 2.530
diff -u -d -r2.529 -r2.530
--- scummvm.cpp	3 Jan 2004 22:21:56 -0000	2.529
+++ scummvm.cpp	4 Jan 2004 13:09:02 -0000	2.530
@@ -925,7 +925,6 @@
 	_verbRedraw = false;
 
 	allocResTypeData(rtBuffer, MKID('NONE'), 10, "buffer", 0);
-//	initVirtScreen(kMainVirtScreen, 0, 0, _screenWidth, _screenHeight, false, false);	// FIXME - why is this here? It seems we could remove it in f
 
 	setupScummVars();
 

Index: verbs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/verbs.cpp,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- verbs.cpp	3 Jan 2004 22:45:23 -0000	1.85
+++ verbs.cpp	4 Jan 2004 13:09:02 -0000	1.86
@@ -102,7 +102,7 @@
 }
 
 void ScummEngine::checkV2MouseOver(Common::Point pos) {
-	VirtScreen *vs = &virtscr[2];
+	VirtScreen *vs = &virtscr[kVerbVirtScreen];
 	Common::Rect rect;
 	byte *ptr, *dst;
 	int i, x, y, new_box = -1;
@@ -126,7 +126,7 @@
 		if (v2_mouseover_box != -1) {
 			rect = v2_mouseover_boxes[v2_mouseover_box].rect;
 
-			dst = ptr = vs->screenPtr + vs->xstart + rect.top * _screenWidth + rect.left;
+			dst = ptr = vs->screenPtr + vs->xstart + rect.top * vs->width + rect.left;
 
 			// Remove highlight.
 			for (y = rect.height() - 1; y >= 0; y--) {
@@ -134,7 +134,7 @@
 					if (dst[x] == v2_mouseover_boxes[v2_mouseover_box].hicolor)
 						dst[x] = v2_mouseover_boxes[v2_mouseover_box].color;
 				}
-				dst += _screenWidth;
+				dst += vs->width;
 			}
 
 			markRectAsDirty(kVerbVirtScreen, rect.left, rect.right, rect.top, rect.bottom, 0);
@@ -143,7 +143,7 @@
 		if (new_box != -1) {
 			rect = v2_mouseover_boxes[new_box].rect;
 
-			dst = ptr = vs->screenPtr + vs->xstart + rect.top * _screenWidth + rect.left;
+			dst = ptr = vs->screenPtr + vs->xstart + rect.top * vs->width + rect.left;
 
 			// Apply highlight
 			for (y = rect.height() - 1; y >= 0; y--) {
@@ -151,7 +151,7 @@
 					if (dst[x] == v2_mouseover_boxes[new_box].color)
 						dst[x] = v2_mouseover_boxes[new_box].hicolor;
 				}
-				dst += _screenWidth;
+				dst += vs->width;
 			}
 
 			markRectAsDirty(kVerbVirtScreen, rect.left, rect.right, rect.top, rect.bottom, 0);
@@ -164,7 +164,7 @@
 void ScummEngine::checkV2Inventory(int x, int y) {
 	int object = 0;
 
-	y -= virtscr[2].topline;
+	y -= virtscr[kVerbVirtScreen].topline;
 
 	if ((y < 34) || !(_mouseButStat & MBS_LEFT_CLICK)) 
 		return;
@@ -197,6 +197,7 @@
 }
 
 void ScummEngine::redrawV2Inventory() {
+	VirtScreen *vs = &virtscr[kVerbVirtScreen];
 	int i;
 	int max_inv;
 	Common::Rect inventoryBox;
@@ -207,10 +208,10 @@
 		return;
 
 	// Clear on all invocations
-	inventoryBox.top = virtscr[2].topline + 32;
-	inventoryBox.bottom = virtscr[2].topline + virtscr[2].height;
+	inventoryBox.top = vs->topline + 32;
+	inventoryBox.bottom = vs->topline + virtscr[2].height;
 	inventoryBox.left = 0;
-	inventoryBox.right = virtscr[2].width;
+	inventoryBox.right = vs->width;
 	restoreBG(inventoryBox);
 
 	_string[1].charset = 1;
@@ -223,7 +224,7 @@
 		if (obj == 0)
 			break;
 		
-		_string[1].ypos = v2_mouseover_boxes[i].rect.top + virtscr[2].topline;
+		_string[1].ypos = v2_mouseover_boxes[i].rect.top + vs->topline;
 		_string[1].xpos = v2_mouseover_boxes[i].rect.left;
 
 		_string[1].color = v2_mouseover_boxes[i].color;
@@ -245,7 +246,7 @@
 	// If necessary, draw "up" arrow
 	if (_inventoryOffset > 0) {
 		_string[1].xpos = v2_mouseover_boxes[kInventoryUpArrow].rect.left;
-		_string[1].ypos = v2_mouseover_boxes[kInventoryUpArrow].rect.top + virtscr[2].topline;
+		_string[1].ypos = v2_mouseover_boxes[kInventoryUpArrow].rect.top + vs->topline;
 	        _string[1].color = v2_mouseover_boxes[kInventoryUpArrow].color;
 		_messagePtr = (const byte *)" \1\2";
 		drawString(1);
@@ -254,7 +255,7 @@
 	// If necessary, draw "down" arrow
 	if (_inventoryOffset + 4 < getInventoryCount(_scummVars[VAR_EGO])) {
 		_string[1].xpos = v2_mouseover_boxes[kInventoryDownArrow].rect.left;
-		_string[1].ypos = v2_mouseover_boxes[kInventoryDownArrow].rect.top + virtscr[2].topline;
+		_string[1].ypos = v2_mouseover_boxes[kInventoryDownArrow].rect.top + vs->topline;
 	        _string[1].color = v2_mouseover_boxes[kInventoryDownArrow].color;
 		_messagePtr = (const byte *)" \3\4";
 		drawString(1);





More information about the Scummvm-git-logs mailing list