[Scummvm-cvs-logs] CVS: scummvm/scumm base-costume.cpp,2.14,2.15 charset.cpp,2.97,2.98 cursor.cpp,2.8,2.9 debugger.cpp,1.125,1.126 gfx.cpp,2.283,2.284 gfx.h,1.64,1.65 object.cpp,1.175,1.176 saveload.cpp,1.168,1.169 script_v5.cpp,1.251,1.252 script_v6.cpp,1.378,1.379 script_v6he.cpp,2.84,2.85 scumm.cpp,1.118,1.119 scumm.h,1.440,1.441 verbs.cpp,1.104,1.105

Max Horn fingolfin at users.sourceforge.net
Sat Aug 14 12:43:02 CEST 2004


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

Modified Files:
	base-costume.cpp charset.cpp cursor.cpp debugger.cpp gfx.cpp 
	gfx.h object.cpp saveload.cpp script_v5.cpp script_v6.cpp 
	script_v6he.cpp scumm.cpp scumm.h verbs.cpp 
Log Message:
Modified VirtScreen to inherit from Graphics::Surface, and added getPixels()/getBackPixels() accessors (these changes make it a bit easier to implement smooth scrolling); also replaced some uses of rtBuffer by proper access through the corresponding VirtScreen

Index: base-costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/base-costume.cpp,v
retrieving revision 2.14
retrieving revision 2.15
diff -u -d -r2.14 -r2.15
--- base-costume.cpp	11 Aug 2004 04:46:41 -0000	2.14
+++ base-costume.cpp	14 Aug 2004 19:41:59 -0000	2.15
@@ -30,13 +30,13 @@
 	byte result = 0;
 
 	if (drawVirScr)
-		_outptr = _vm->getResourceAddress(rtBuffer, 5) + vs.xstart;
+		_outptr = _vm->virtscr[0].getPixels(0, 0);
 	else
-		_outptr = vs.screenPtr + vs.xstart;
+		_outptr = vs.getPixels(0, 0);
 
-	_outwidth = vs.width;
-	_outheight = vs.height;
-	_numStrips = vs.width / 8;
+	_outwidth = vs.w;
+	_outheight = vs.h;
+	_numStrips = _outwidth / 8;
 
 	if (_vm->_version == 1) {
 		_xmove = 0;

Index: charset.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/charset.cpp,v
retrieving revision 2.97
retrieving revision 2.98
diff -u -d -r2.97 -r2.98
--- charset.cpp	14 Aug 2004 00:24:12 -0000	2.97
+++ charset.cpp	14 Aug 2004 19:41:59 -0000	2.98
@@ -980,7 +980,7 @@
 		_textScreenID = vs->number;
 	}
 	if (_ignoreCharsetMask || !vs->hasTwoBuffers) {
-		dest_ptr = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
+		dest_ptr = vs->getPixels(_left, drawTop);
 	} else {
 		dest_ptr = (byte *)_vm->gdi._textSurface.pixels + _top * _vm->gdi._textSurface.pitch + _left;
 	}
@@ -1096,14 +1096,14 @@
 		_textScreenID = vs->number;
 	}
 	if (_ignoreCharsetMask || !vs->hasTwoBuffers) {
-		dst = vs->screenPtr + vs->xstart + drawTop * vs->width + _left;
+		dst = vs->getPixels(_left, drawTop);
 	} else {
 		dst = (byte *)_vm->gdi._textSurface.pixels + (_top - _vm->_screenTop) * _vm->gdi._textSurface.pitch + _left;
 	}
 
 	back = dst;
 	if (_blitAlso && vs->hasTwoBuffers) {
-		dst = vs->backBuf + vs->xstart + drawTop * vs->width + _left;
+		dst = vs->getBackPixels(_left, drawTop);
 	}
 
 	if (is2byte) {
@@ -1120,11 +1120,12 @@
 		// once to each of the two buffers. That should hypothetically yield
 		// identical results, though I didn't try it and right now I don't know
 		// any spots where I can test this...
+		warning("This is broken?!");
 		int h = height;
 		do {
 			memcpy(back, dst, width);
-			back += vs->width;
-			dst += vs->width;
+			back += vs->pitch;
+			dst += vs->pitch;
 		} while (--h);
 	}
 	
@@ -1151,7 +1152,7 @@
 	bits = *src++;
 	numbits = 8;
 
-	for (y = 0; y < height && y + drawTop < vs->height; y++) {
+	for (y = 0; y < height && y + drawTop < vs->h; y++) {
 		for (x = 0; x < width; x++) {
 			color = (bits >> (8 - bpp)) & 0xFF;
 			
@@ -1166,7 +1167,7 @@
 				numbits = 8;
 			}
 		}
-		dst += vs->width - width;
+		dst += vs->pitch - width;
 	}
 }
 
@@ -1174,22 +1175,22 @@
 	int y, x;
 	byte bits = 0;
 
-	for (y = 0; y < height && y + drawTop < vs->height; y++) {
+	for (y = 0; y < height && y + drawTop < vs->h; y++) {
 		for (x = 0; x < width; x++) {
 			if ((x % 8) == 0)
 				bits = *src++;
 			if ((bits & revBitMask[x % 8]) && y + drawTop >= 0) {
 				if (_dropShadow) {
 					*(dst + 1) = _shadowColor;
-					*(dst + vs->width) = _shadowColor;
-					*(dst + vs->width + 1) = _shadowColor;
+					*(dst + vs->pitch) = _shadowColor;
+					*(dst + vs->pitch + 1) = _shadowColor;
 				}					
 				*dst = _color;
 			}
 			dst++;
 		}
 
-		dst += vs->width - width;
+		dst += vs->pitch - width;
 	}
 }
 
@@ -1274,11 +1275,8 @@
 	}
 	if (_ignoreCharsetMask) {
 		VirtScreen *vs = &_vm->virtscr[kMainVirtScreen];
-		s.pixels = vs->screenPtr + vs->xstart + _vm->_screenTop * vs->width;
-		s.w = vs->width;
-		s.h = vs->height;
-		s.pitch = vs->width;
-		s.bytesPerPixel = 1;
+		s = *vs;
+		s.pixels = vs->getPixels(0, _vm->_screenTop);
 	} else {
 		s = _vm->gdi._textSurface;
 	}

Index: cursor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/cursor.cpp,v
retrieving revision 2.8
retrieving revision 2.9
diff -u -d -r2.8 -r2.9
--- cursor.cpp	27 Jun 2004 13:32:50 -0000	2.8
+++ cursor.cpp	14 Aug 2004 19:41:59 -0000	2.9
@@ -84,7 +84,7 @@
 		return;
 	}
 
-	grabCursor(vs->screenPtr + (y - vs->topline) * vs->width + x, w, h);
+	grabCursor((byte *)vs->pixels + (y - vs->topline) * vs->pitch + x, w, h);
 
 }
 
@@ -119,15 +119,17 @@
 	w *= 8;
 	h *= 8;
 
-	dst = buf = (byte *) malloc(w * h);
-	src = vs->screenPtr + vs->xstart;
+	// Backup the screen content
+	dst = buf = (byte *)malloc(w * h);
+	src = vs->getPixels(0, 0);
 
 	for (i = 0; i < h; i++) {
 		memcpy(dst, src, w);
 		dst += w;
-		src += vs->width;
+		src += vs->pitch;
 	}
 
+	// Do some drawing
 	drawBox(0, 0, w - 1, h - 1, 0xFF);
 
 	vs->hasTwoBuffers = false;
@@ -136,14 +138,16 @@
 	vs->hasTwoBuffers = true;
 	gdi.enableZBuffer();
 
-	grabCursor(vs->screenPtr + vs->xstart, w, h);
+	// Grab the data we just drew and setup the cursor with it
+	grabCursor(vs->getPixels(0, 0), w, h);
 
+	// Restore the screen content
 	src = buf;
-	dst = vs->screenPtr + vs->xstart;
+	dst = vs->getPixels(0, 0);
 
 	for (i = 0; i < h; i++) {
 		memcpy(dst, src, w);
-		dst += vs->width;
+		dst += vs->pitch;
 		src += w;
 	}
 

Index: debugger.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/debugger.cpp,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -d -r1.125 -r1.126
--- debugger.cpp	8 Aug 2004 22:44:15 -0000	1.125
+++ debugger.cpp	14 Aug 2004 19:41:59 -0000	1.126
@@ -705,7 +705,7 @@
 		x2 = right - 1;
 
 
-	ptr = vs->screenPtr + x1 + y * vs->width;
+	ptr = (byte *)vs->pixels + x1 + y * vs->pitch;
 
 	while (x1++ <= x2) {
 		*ptr++ = color;
@@ -784,7 +784,7 @@
 
 	VirtScreen *vs = _vm->findVirtScreen(coords.ul.y);
 	if (vs != NULL)
-		_vm->markRectAsDirty(vs->number, 0, vs->width, 0, vs->height);
+		_vm->markRectAsDirty(vs->number, 0, vs->w, 0, vs->h);
 	_vm->drawDirtyScreenParts();
 	_vm->_system->updateScreen();
 }

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.283
retrieving revision 2.284
diff -u -d -r2.283 -r2.284
--- gfx.cpp	10 Aug 2004 23:51:52 -0000	2.283
+++ gfx.cpp	14 Aug 2004 19:41:59 -0000	2.284
@@ -28,6 +28,8 @@
 
 namespace Scumm {
 
+static void blit(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h);
+
 struct StripTable {
 	int offsets[160];
 	int run[160];
@@ -235,14 +237,16 @@
 	}
 
 	vs->number = slot;
-	vs->width = width;
+	vs->w = width;
 	vs->topline = top;
-	vs->height = height;
+	vs->h = height;
 	vs->hasTwoBuffers = twobufs;
 	vs->xstart = 0;
 	vs->backBuf = NULL;
+	vs->bytesPerPixel = 1;
+	vs->pitch = width;
 
-	size = vs->width * vs->height;
+	size = vs->pitch * vs->h;
 	if (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:
@@ -251,15 +255,15 @@
 		// memory overhead (namely for every pixel we want to scroll, we need
 		// one additional byte in the buffer).
 		if (_version >= 7) {
-			size += width * 8;
+			size += vs->pitch * 8;
 		} else {
-			size += width * 4;
+			size += vs->pitch * 4;
 		}
 	}
 
 	createResource(rtBuffer, slot + 1, size);
-	vs->screenPtr = getResourceAddress(rtBuffer, slot + 1);
-	memset(vs->screenPtr, 0, size);			// reset background
+	vs->pixels = getResourceAddress(rtBuffer, slot + 1);
+	memset(vs->pixels, 0, size);			// reset background
 
 	if (twobufs) {
 		vs->backBuf = createResource(rtBuffer, slot + 5, size);
@@ -275,7 +279,7 @@
 	int i;
 
 	for (i = 0; i < 3; i++, vs++) {
-		if (y >= vs->topline && y < vs->topline + vs->height) {
+		if (y >= vs->topline && y < vs->topline + vs->h) {
 			return vs;
 		}
 	}
@@ -288,13 +292,13 @@
 
 	if (left > right || top > bottom)
 		return;
-	if (top > vs->height || bottom < 0)
+	if (top > vs->h || bottom < 0)
 		return;
 
 	if (top < 0)
 		top = 0;
-	if (bottom > vs->height)
-		bottom = vs->height;
+	if (bottom > vs->h)
+		bottom = vs->h;
 
 	if (virt == kMainVirtScreen && dirtybit) {
 		lp = left / 8 + _screenStartStrip;
@@ -355,8 +359,8 @@
 		// Small side note: most of our GFX code relies on this identity:
 		// gdi._numStrips * 8 == _screenWidth == vs->width
 		VirtScreen *vs = &virtscr[kMainVirtScreen];
-		gdi.drawStripToScreen(vs, 0, vs->width, 0, vs->height);
-		vs->setDirtyRange(vs->height, 0);
+		gdi.drawStripToScreen(vs, 0, vs->w, 0, vs->h);
+		vs->setDirtyRange(vs->h, 0);
 	} else {
 		updateDirtyScreen(kMainVirtScreen);
 	}
@@ -381,7 +385,7 @@
  */
 void Gdi::updateDirtyScreen(VirtScreen *vs) {
 	// Do nothing for unused virtual screens
-	if (vs->height == 0)
+	if (vs->h == 0)
 		return;
 
 	int i;
@@ -392,7 +396,7 @@
 		if (vs->bdirty[i]) {
 			const int top = vs->tdirty[i];
 			const int bottom = vs->bdirty[i];
-			vs->tdirty[i] = vs->height;
+			vs->tdirty[i] = vs->h;
 			vs->bdirty[i] = 0;
 			if (i != (_numStrips - 1) && vs->bdirty[i + 1] == bottom && vs->tdirty[i + 1] == top) {
 				// Simple optimizations: if two or more neighbouring strips
@@ -419,11 +423,11 @@
 	if (bottom <= top)
 		return;
 
-	if (top >= vs->height)
+	if (top >= vs->h)
 		return;
 
-	assert(top >= 0 && bottom <= vs->height);	// Paranoia checks
-	assert(x >= 0 && width <= vs->width);
+	assert(top >= 0 && bottom <= vs->h);	// Paranoia checks
+	assert(x >= 0 && width <= vs->w);
 	assert(_textSurface.pixels);
 	assert(_compositeBuf);
 
@@ -438,7 +442,7 @@
 	const int height = bottom - top;
 	
 	// Compute screen etc. buffer pointers 
-	const byte *src = vs->screenPtr + (x + vs->xstart) + top * vs->width;
+	const byte *src = vs->getPixels(x, top);
 	byte *dst = _compositeBuf + x + y * _vm->_screenWidth;
 	const byte *text = (byte *)_textSurface.pixels + x + y * _textSurface.pitch;
 
@@ -450,7 +454,7 @@
 			else
 				dst[w] = text[w];
 		}
-		src += vs->width;
+		src += vs->pitch;
 		dst += _vm->_screenWidth;
 		text += _textSurface.pitch;
 	}
@@ -601,7 +605,7 @@
 		room = getResourceAddress(rtRoom, _roomResource);
 
 	gdi.drawBitmap(room + _IM00_offs,
-					&virtscr[0], s, 0, _roomWidth, virtscr[0].height, s, num, 0, _roomStrips);
+					&virtscr[0], s, 0, _roomWidth, virtscr[0].h, s, num, 0, _roomStrips);
 }
 
 void ScummEngine::restoreBG(Common::Rect rect, byte backColor) {
@@ -616,19 +620,18 @@
 	if ((vs = findVirtScreen(rect.top)) == NULL)
 		return;
 
-	if (rect.left > vs->width)
+	if (rect.left > vs->w)
 		return;
 
 	// Convert 'rect' to local (virtual screen) coordinates
 	rect.top -= vs->topline;
 	rect.bottom -= vs->topline;
 
-	rect.clip(vs->width, vs->height);
+	rect.clip(vs->w, vs->h);
 
 	markRectAsDirty(vs->number, rect, USAGE_BIT_RESTORED);
 
-	const int offset = rect.top * vs->width + vs->xstart + rect.left;
-	screenBuf = vs->screenPtr + offset;
+	screenBuf = vs->getPixels(rect.left, rect.top);
 
 	int height = rect.height();
 	int width = rect.width();
@@ -637,7 +640,7 @@
 		return;
 
 	if (vs->hasTwoBuffers && _currentRoom != 0 && isLightOn()) {
-		blit(screenBuf, vs->backBuf + offset, width, height);
+		blit(screenBuf, vs->pitch, vs->getBackPixels(rect.left, rect.top), vs->pitch, width, height);
 		if (vs->number == kMainVirtScreen && _charset->_hasMask) {
 			// Note: At first sight it may look as if this could
 			// be optimized to (rect.right - rect.left) / 8 and
@@ -653,7 +656,7 @@
 	} else {
 		while (height--) {
 			memset(screenBuf, backColor, width);
-			screenBuf += vs->width;
+			screenBuf += vs->pitch;
 		}
 	}
 }
@@ -672,26 +675,26 @@
 		// currently covered by the charset mask.
 
 		VirtScreen *vs = &_vm->virtscr[_textScreenID];
-		if (!vs->height)
+		if (!vs->h)
 			return;
 
-		_vm->markRectAsDirty(vs->number, Common::Rect(vs->width, vs->height), USAGE_BIT_RESTORED);
+		_vm->markRectAsDirty(vs->number, Common::Rect(vs->w, vs->h), USAGE_BIT_RESTORED);
 	
-		byte *screenBuf = vs->screenPtr + vs->xstart;
+		byte *screenBuf = vs->getPixels(0, 0);
 
 		if (vs->hasTwoBuffers && _vm->_currentRoom != 0 && _vm->isLightOn()) {
-			const byte *backBuf = vs->backBuf + vs->xstart;
+			const byte *backBuf = vs->getBackPixels(0, 0);
 
 			if (vs->number == kMainVirtScreen) {
 				// Clean out the charset mask
 				memset(_vm->gdi._textSurface.pixels, CHARSET_MASK_TRANSPARENCY, _vm->gdi._textSurface.pitch * _vm->gdi._textSurface.h);
 			} else {
 				// Restore from back buffer
-				_vm->blit(screenBuf, backBuf, vs->width, vs->height);
+				blit(screenBuf, vs->pitch, backBuf, vs->pitch, vs->w, vs->h);
 			}
 		} else {
 			// Clear area
-			memset(screenBuf, 0, vs->height * vs->width);
+			memset(screenBuf, 0, vs->h * vs->pitch);
 		}
 	}
 }
@@ -714,22 +717,22 @@
 #pragma mark --- Misc ---
 #pragma mark -
 
-void ScummEngine::blit(byte *dst, const byte *src, int w, int h) {
+static void blit(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h) {
 	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)
 
-	if (w==_screenWidth)
-		memcpy (dst, src, w*h);
-	else
-	{
+	if (w == srcPitch && w == dstPitch) {
+		memcpy(dst, src, w*h);
+	} else {
 		do {
 			memcpy(dst, src, w);
-			dst += _screenWidth;
-			src += _screenWidth;
+			dst += dstPitch;
+			src += srcPitch;
 		} while (--h);
 	}
 }
@@ -758,45 +761,45 @@
 	// Clip the coordinates
 	if (x < 0)
 		x = 0;
-	else if (x >= vs->width)
+	else if (x >= vs->w)
 		return;
 
 	if (x2 < 0)
 		return;
-	else if (x2 > vs->width)
-		x2 = vs->width;
+	else if (x2 > vs->w)
+		x2 = vs->w;
 
 	if (y < 0)
 		y = 0;
-	else if (y > vs->height)
+	else if (y > vs->h)
 		return;
 
 	if (y2 < 0)
 		return;
-	else if (y2 > vs->height)
-		y2 = vs->height;
+	else if (y2 > vs->h)
+		y2 = vs->h;
 	
 	markRectAsDirty(vs->number, x, x2, y, y2);
 
-	backbuff = vs->screenPtr + vs->xstart + y * vs->width + x;
+	backbuff = vs->getPixels(x, y);
 
 	width = x2 - x;
 	height = y2 - y;
 	if (color == -1) {
 		if (vs->number != kMainVirtScreen)
 			error("can only copy bg to main window");
-		bgbuff = vs->backBuf + vs->xstart + y * vs->width + x;
-		blit(backbuff, bgbuff, width, height);
+		bgbuff = vs->getBackPixels(x, y);
+		blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height);
 	} else {
 		while (height--) {
 			memset(backbuff, color, width);
-			backbuff += vs->width;
+			backbuff += vs->pitch;
 		}
 	}
 }
 
 void ScummEngine::drawFlashlight() {
-	int i, j, offset, x, y;
+	int i, j, x, y;
 	VirtScreen *vs = &virtscr[kMainVirtScreen];
 
 	// Remove the flash light first if it was previously drawn
@@ -808,7 +811,7 @@
 			i = _flashlight.h;
 			do {
 				memset(_flashlight.buffer, 0, _flashlight.w);
-				_flashlight.buffer += vs->width;
+				_flashlight.buffer += vs->pitch;
 			} while (--i);
 		}
 		_flashlight.isDrawn = false;
@@ -841,32 +844,31 @@
 		_flashlight.x = gdi._numStrips * 8 - _flashlight.w;
 	if (_flashlight.y < 0)
 		_flashlight.y = 0;
-	else if (_flashlight.y + _flashlight.h> vs->height)
-		_flashlight.y = vs->height - _flashlight.h;
+	else if (_flashlight.y + _flashlight.h> vs->h)
+		_flashlight.y = vs->h - _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);
 		vs->tdirty[i] = 0;
-		vs->bdirty[i] = vs->height;
+		vs->bdirty[i] = vs->h;
 	}
 
 	byte *bgbak;
-	offset = _flashlight.y * vs->width + vs->xstart + _flashlight.x;
-	_flashlight.buffer = vs->screenPtr + offset;
-	bgbak = vs->backBuf + offset;
+	_flashlight.buffer = vs->getPixels(_flashlight.x, _flashlight.y);
+	bgbak = vs->getBackPixels(_flashlight.x, _flashlight.y);
 
-	blit(_flashlight.buffer, bgbak, _flashlight.w, _flashlight.h);
+	blit(_flashlight.buffer, vs->pitch, bgbak, vs->pitch, _flashlight.w, _flashlight.h);
 
 	// Round the corners. To do so, we simply hard-code a set of nicely
 	// rounded corners.
 	static const int corner_data[] = { 8, 6, 4, 3, 2, 2, 1, 1 };
 	int minrow = 0;
 	int maxcol = _flashlight.w - 1;
-	int maxrow = (_flashlight.h - 1) * vs->width;
+	int maxrow = (_flashlight.h - 1) * vs->pitch;
 
-	for (i = 0; i < 8; i++, minrow += vs->width, maxrow -= vs->width) {
+	for (i = 0; i < 8; i++, minrow += vs->pitch, maxrow -= vs->pitch) {
 		int d = corner_data[i];
 
 		for (j = 0; j < d; j++) {
@@ -906,9 +908,9 @@
 	memset(dither_table, 0, sizeof(dither_table));
 
 	if (vs->hasTwoBuffers)
-		dst = vs->backBuf + (y * _numStrips + x) * 8;
+		dst = vs->backBuf + y * vs->pitch + x * 8;
 	else
-		dst = vs->screenPtr + (y * _numStrips + x) * 8;
+		dst = (byte *)vs->pixels + y * vs->pitch + x * 8;
 
 	mask_ptr = getMaskBuffer(x, y, 1);
 
@@ -951,7 +953,7 @@
 			}
 			if (left <= theX && theX < right) {
 				*dst = *ptr_dither_table++;
-				dst += vs->width;
+				dst += vs->pitch;
 			}
 		}
 		if (left <= theX && theX < right) {
@@ -1099,11 +1101,11 @@
 	}
 
 	bottom = y + height;
-	if (bottom > vs->height) {
-		warning("Gdi::drawBitmap, strip drawn to %d below window bottom %d", bottom, vs->height);
+	if (bottom > vs->h) {
+		warning("Gdi::drawBitmap, strip drawn to %d below window bottom %d", bottom, vs->h);
 	}
 
-	_vertStripNextInc = height * vs->width - 1;
+	_vertStripNextInc = height * vs->pitch - 1;
 
 	sx = x - vs->xstart / 8;
 
@@ -1132,7 +1134,7 @@
 		if (bottom > vs->bdirty[sx])
 			vs->bdirty[sx] = bottom;
 
-		backbuff_ptr = vs->screenPtr + (y * _numStrips + x) * 8;
+		backbuff_ptr = (byte *)vs->pixels + (y * _numStrips + x) * 8;
 		if (vs->hasTwoBuffers)
 			bgbak_ptr = vs->backBuf + (y * _numStrips + x) * 8;
 		else
@@ -1267,7 +1269,7 @@
 void Gdi::resetBackground(int top, int bottom, int strip) {
 	VirtScreen *vs = &_vm->virtscr[0];
 	byte *backbuff_ptr, *bgbak_ptr;
-	int offs, numLinesToProcess;
+	int numLinesToProcess;
 
 	assert(0 <= strip && strip < _numStrips);
 
@@ -1277,9 +1279,8 @@
 	if (bottom > vs->bdirty[strip])
 		vs->bdirty[strip] = bottom;
 
-	offs = top * vs->width + vs->xstart + strip * 8;
-	bgbak_ptr = vs->backBuf + offs;
-	backbuff_ptr = vs->screenPtr + offs;
+	bgbak_ptr = vs->getBackPixels(strip * 8, top);
+	backbuff_ptr = vs->getPixels(strip * 8, top);
 
 	numLinesToProcess = bottom - top;
 	if (numLinesToProcess) {
@@ -2297,7 +2298,7 @@
 	
 		// Fill screen 0 with black
 		
-		memset(vs->screenPtr + vs->xstart, 0, vs->width * vs->height);
+		memset(vs->getPixels(0, 0), 0, vs->pitch * vs->h);
 	
 		// Fade to black with the specified effect, if any.
 		switch (effect) {
@@ -2313,7 +2314,7 @@
 			break;
 		case 129:
 			// Just blit screen 0 to the display (i.e. display will be black)
-			vs->setDirtyRange(0, vs->height);
+			vs->setDirtyRange(0, vs->h);
 			updateDirtyScreen(kMainVirtScreen);
 			break;
 		case 134:
@@ -2350,7 +2351,7 @@
 	int i, j;
 	int bottom;
 	int l, t, r, b;
-	const int height = MIN((int)virtscr[0].height, _screenHeight);
+	const int height = MIN((int)virtscr[0].h, _screenHeight);
 
 	for (i = 0; i < 16; i++) {
 		delta[i] = transitionEffects[a].deltaTable[i];
@@ -2418,16 +2419,16 @@
 	// since we're only dealing with relatively small images, it shouldn't
 	// be too bad.
 
-	w = vs->width / width;
-	h = vs->height / height;
+	w = vs->w / width;
+	h = vs->h / height;
 
 	// When used correctly, vs->width % width and vs->height % height
 	// should both be zero, but just to be safe...
 
-	if (vs->width % width)
+	if (vs->w % width)
 		w++;
 
-	if (vs->height % height)
+	if (vs->h % height)
 		h++;
 
 	offsets = (int *) malloc(w * h * sizeof(int));
@@ -2441,7 +2442,7 @@
 	if (width == 1 && height == 1) {
 		// Optimized case for pixel-by-pixel dissolve
 
-		for (i = 0; i < vs->width * vs->height; i++)
+		for (i = 0; i < vs->w * vs->h; i++)
 			offsets[i] = i;
 
 		for (i = 1; i < w * h; i++) {
@@ -2454,9 +2455,9 @@
 	} else {
 		int *offsets2;
 
-		for (i = 0, x = 0; x < vs->width; x += width)
-			for (y = 0; y < vs->height; y += height)
-				offsets[i++] = y * vs->width + x;
+		for (i = 0, x = 0; x < vs->w; x += width)
+			for (y = 0; y < vs->h; y += height)
+				offsets[i++] = y * vs->pitch + x;
 
 		offsets2 = (int *) malloc(w * h * sizeof(int));
 		if (offsets2 == NULL) {
@@ -2493,9 +2494,9 @@
 		blits_before_refresh *= 2;
 
 	for (i = 0; i < w * h; i++) {
-		x = offsets[i] % vs->width;
-		y = offsets[i] / vs->width;
-		_system->copyRectToScreen(vs->screenPtr + vs->xstart + y * vs->width + x, vs->width, x, y + vs->topline, width, height);
+		x = offsets[i] % vs->pitch;
+		y = offsets[i] / vs->pitch;
+		_system->copyRectToScreen(vs->getPixels(x, y), vs->pitch, x, y + vs->topline, width, height);
 
 		if (++blits >= blits_before_refresh) {
 			blits = 0;
@@ -2519,9 +2520,9 @@
 	int step;
 
 	if ((dir == 0) || (dir == 1))
-		step = vs->height;
+		step = vs->h;
 	else
-		step = vs->width;
+		step = vs->w;
 
 	step = (step * kPictureDelay) / kScrolltime;
 
@@ -2529,12 +2530,12 @@
 	case 0:
 		//up
 		y = 1 + step;
-		while (y < vs->height) {
-			_system->move_screen(0, -step, vs->height);
-			_system->copyRectToScreen(vs->screenPtr + vs->xstart + (y - step) * vs->width,
-				vs->width,
-				0, vs->height - step,
-				vs->width, step);
+		while (y < vs->h) {
+			_system->move_screen(0, -step, vs->h);
+			_system->copyRectToScreen(vs->getPixels(0, y - step),
+				vs->pitch,
+				0, vs->h - step,
+				vs->w, step);
 			_system->updateScreen();
 			waitForTimer(kPictureDelay);
 
@@ -2544,12 +2545,12 @@
 	case 1:
 		// down
 		y = 1 + step;
-		while (y < vs->height) {
-			_system->move_screen(0, step, vs->height);
-			_system->copyRectToScreen(vs->screenPtr + vs->xstart + vs->width * (vs->height-y),
-				vs->width,
+		while (y < vs->h) {
+			_system->move_screen(0, step, vs->h);
+			_system->copyRectToScreen(vs->getPixels(0, vs->h - y),
+				vs->pitch,
 				0, 0,
-				vs->width, step);
+				vs->w, step);
 			_system->updateScreen();
 			waitForTimer(kPictureDelay);
 
@@ -2559,12 +2560,12 @@
 	case 2:
 		// left
 		x = 1 + step;
-		while (x < vs->width) {
-			_system->move_screen(-step, 0, vs->height);
-			_system->copyRectToScreen(vs->screenPtr + vs->xstart + x - step,
-				vs->width,
-				vs->width - step, 0,
-				step, vs->height);
+		while (x < vs->w) {
+			_system->move_screen(-step, 0, vs->h);
+			_system->copyRectToScreen(vs->getPixels(x - step, 0),
+				vs->pitch,
+				vs->w - step, 0,
+				step, vs->h);
 			_system->updateScreen();
 			waitForTimer(kPictureDelay);
 
@@ -2574,12 +2575,12 @@
 	case 3:
 		// right
 		x = 1 + step;
-		while (x < vs->width) {
-			_system->move_screen(step, 0, vs->height);
-			_system->copyRectToScreen(vs->screenPtr + vs->xstart + vs->width - x,
-				vs->width,
+		while (x < vs->w) {
+			_system->move_screen(step, 0, vs->h);
+			_system->copyRectToScreen(vs->getPixels(vs->w - x, 0),
+				vs->pitch,
 				0, 0,
-				step, vs->height);
+				step, vs->h);
 			_system->updateScreen();
 			waitForTimer(kPictureDelay);
 

Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- gfx.h	8 Aug 2004 22:09:50 -0000	1.64
+++ gfx.h	14 Aug 2004 19:41:59 -0000	1.65
@@ -79,7 +79,7 @@
  * Each of these virtual screens has a fixed number or id (see also
  * \ref VirtScreenNumber).
  */
-struct VirtScreen {
+struct VirtScreen : Graphics::Surface {
 	/**
 	 * The unique id of this screen (corresponds to its position in the
 	 * ScummEngine:virtscr array).
@@ -96,12 +96,6 @@
 	 */
 	uint16 topline;
 	
-	/** Width of the virtual screen (currently always identical to _screenWidth). */
-	uint16 width;
-
-	/** Height of the virtual screen. */
-	uint16 height;
-
 	/**
 	 * Horizontal scroll offset, tells how far the screen is scrolled to the
 	 * right. Only used for the main screen. After all, verbs and the
@@ -120,12 +114,6 @@
 	bool hasTwoBuffers;
 	
 	/**
-	 * Pointer to the screen's data buffer. This is where the content of
-	 * the screen is stored. Just as one would expect :-).
-	 */
-	byte *screenPtr;
-	
-	/**
 	 * Pointer to the screen's back buffer, if it has one (see also
 	 * the hasTwoBuffers member).
 	 * The backBuf is used by drawBitmap to store the background graphics of
@@ -167,6 +155,14 @@
 			bdirty[i] = bottom;
 		}
 	}
+	
+	byte *getPixels(int x, int y) const {
+		return (byte *)pixels + xstart + y * pitch + x;
+	}
+
+	byte *getBackPixels(int x, int y) const {
+		return (byte *)backBuf + xstart + y * pitch + x;
+	}
 };
 
 /** Palette cycles */

Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -d -r1.175 -r1.176
--- object.cpp	24 Jun 2004 12:32:19 -0000	1.175
+++ object.cpp	14 Aug 2004 19:41:59 -0000	1.176
@@ -1515,9 +1515,9 @@
 		bdd.srcheight = READ_LE_UINT16(&((const BompHeader *)bomp)->old.height);
 	}
 	
-	bdd.out = vs->screenPtr + vs->xstart;
-	bdd.outwidth = vs->width;
-	bdd.outheight = vs->height;
+	bdd.out = vs->getPixels(0, 0);
+	bdd.outwidth = vs->w;
+	bdd.outheight = vs->h;
 	if (_version == 8) {
 		bdd.dataptr = bomp + 8;	// Why this? See also useBompCursor
 	} else {
@@ -1570,17 +1570,17 @@
 
 	r = eo->rect;
 
-	if (r.bottom < 0 || r.right < 0 || r.top > vs->height || r.left > vs->width)
+	if (r.bottom < 0 || r.right < 0 || r.top > vs->h || r.left > vs->w)
 		return;
 
 	if (r.top < 0)
 		r.top = 0;
-	if (r.bottom > vs->height)
-		r.bottom = vs->height;
+	if (r.bottom > vs->h)
+		r.bottom = vs->h;
 	if (r.left < 0)
 		r.left = 0;
-	if (r.right > vs->width)
-		r.right = vs->width;
+	if (r.right > vs->w)
+		r.right = vs->w;
 
 	left_strip = r.left / 8;
 	right_strip = (r.right - 1) / 8;

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -d -r1.168 -r1.169
--- saveload.cpp	10 Aug 2004 02:19:16 -0000	1.168
+++ saveload.cpp	14 Aug 2004 19:41:59 -0000	1.169
@@ -286,9 +286,9 @@
 
 	// Restore the virtual screens and force a fade to black.
 	initScreens(kMainVirtScreen, _screenHeight);
-	VirtScreen *vs = &virtscr[0];
-	memset(vs->screenPtr + vs->xstart, 0, vs->width * vs->height);
-	vs->setDirtyRange(0, vs->height);
+	VirtScreen *vs = &virtscr[kMainVirtScreen];
+	memset(vs->getPixels(0, 0), 0, vs->pitch * vs->h);
+	vs->setDirtyRange(0, vs->h);
 	updateDirtyScreen(kMainVirtScreen);
 	updatePalette();
 	initScreens(sb, sh);

Index: script_v5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v5.cpp,v
retrieving revision 1.251
retrieving revision 1.252
diff -u -d -r1.251 -r1.252
--- script_v5.cpp	14 Aug 2004 01:16:53 -0000	1.251
+++ script_v5.cpp	14 Aug 2004 19:41:59 -0000	1.252
@@ -2762,8 +2762,8 @@
 				// For now, we force a redraw of the screen background. This 
 				// Makes the Zak end credits work more or less correctly.
 				VirtScreen *vs = &virtscr[0];
-				restoreBG(Common::Rect(0,vs->topline, vs->width, vs->topline + vs->height));
-				virtscr[0].setDirtyRange(0, virtscr[0].height);
+				restoreBG(Common::Rect(0,vs->topline, vs->w, vs->topline + vs->h));
+				vs->setDirtyRange(0, vs->h);
 				updateDirtyScreen(kMainVirtScreen);
 				
 				if (byte_2FCCF) {

Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.378
retrieving revision 1.379
diff -u -d -r1.378 -r1.379
--- script_v6.cpp	14 Aug 2004 15:14:01 -0000	1.378
+++ script_v6.cpp	14 Aug 2004 19:41:59 -0000	1.379
@@ -2739,12 +2739,12 @@
 
 		{
 			VirtScreen *vs = &virtscr[0];
-			if (args[1] < 0 || args[1] >= vs->width || args[2] < 0 || args[2] >= vs->height) {
+			if (args[1] < 0 || args[1] >= vs->w || args[2] < 0 || args[2] >= vs->h) {
 				// FIXME: Until we know what to do in this case...
-				warning("o6_kernelGetFunctions:113: asking for pixel (%d, %d) outside of %dx%d screen", args[1], args[2], vs->width, vs->height);
+				warning("o6_kernelGetFunctions:113: asking for pixel (%d, %d) outside of %dx%d screen", args[1], args[2], vs->w, vs->h);
 				push(0);
 			} else
-				push(vs->screenPtr[args[1] + args[2] * vs->width]);
+				push(*((byte *)vs->pixels + args[1] + args[2] * vs->pitch));
 		}
 		break;
 	case 115:
@@ -3123,9 +3123,7 @@
 		return;
 	}
 
-	int offset = (y - vs->topline) * vs->width + x + vs->xstart;
-
-	byte area = *(vs->screenPtr + offset);
+	byte area = *vs->getPixels(x, y - vs->topline);
 	push(area);
 }
 

Index: script_v6he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6he.cpp,v
retrieving revision 2.84
retrieving revision 2.85
diff -u -d -r2.84 -r2.85
--- script_v6he.cpp	14 Aug 2004 15:14:01 -0000	2.84
+++ script_v6he.cpp	14 Aug 2004 19:42:00 -0000	2.85
@@ -771,16 +771,13 @@
 	debug(1, "ScummEngine_v6he::virtScreenLoad(%d, %d, %d, %d, %d)", resIdx, x1, y1, x2, y2);
 	vsUnpackCtx ctx;
 	memset(&ctx, 0, sizeof(ctx));
-	int vs = 0; // XXX gdi_virtScreen = 0;
+	VirtScreen &vs = virtscr[kMainVirtScreen]; // XXX gdi_virtScreen = 0;
 
 	ArrayHeader *ah = (ArrayHeader *)getResourceAddress(rtString, resIdx);
 	virtScreenLoadUnpack(&ctx, ah->data);
 	for (int j = y1; j <= y2; ++j) {
-		uint32 yoff = (j - virtscr[kMainVirtScreen].topline) * 320;		
-		uint8 *p1 = getResourceAddress(rtBuffer, vs + 1);
-		p1 += yoff + virtscr[kMainVirtScreen].xstart + x1;
-		uint8 *p2 = getResourceAddress(rtBuffer, vs + 5);
-		p2 += yoff + virtscr[kMainVirtScreen].xstart + x1;
+		uint8 *p1 = vs.getPixels(x1, j - vs.topline);
+		uint8 *p2 = vs.getBackPixels(x1, j - vs.topline);
 		if (x2 >= x1) {
 			uint32 w = x2 - x1 + 1;
 			while (w--) {
@@ -852,12 +849,10 @@
 int ScummEngine_v6he::virtScreenSave(byte *dst, int x1, int y1, int x2, int y2) {
 	debug(1, "ScummEngine_v6he::virtScreenSave(%d, %d, %d, %d)", x1, y1, x2, y2);
 	int packedSize = 0;
-	int vs = 0; // XXX = gdi_virtScreen;
+	VirtScreen &vs = virtscr[kMainVirtScreen]; // XXX gdi_virtScreen = 0;
 
 	for (int j = y1; j <= y2; ++j) {
-		uint8 *p = getResourceAddress(rtBuffer, vs + 5);
-		p += virtscr[kMainVirtScreen].xstart;
-		p += (j - virtscr[kMainVirtScreen].topline) * 320 + x1;
+		uint8 *p = vs.getBackPixels(x1, j - vs.topline);
 		
 		int size = virtScreenSavePack(dst, p, x2 - x1 + 1, 0);
 		if (dst != 0) {

Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -d -r1.118 -r1.119
--- scumm.cpp	14 Aug 2004 15:23:44 -0000	1.118
+++ scumm.cpp	14 Aug 2004 19:42:00 -0000	1.119
@@ -1940,7 +1940,7 @@
 
 	if (_virtualMouse.y < 0)
 		_virtualMouse.y = -1;
-	if (_virtualMouse.y >= virtscr[0].height)
+	if (_virtualMouse.y >= virtscr[0].h)
 		_virtualMouse.y = -1;
 
 	//

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.440
retrieving revision 1.441
diff -u -d -r1.440 -r1.441
--- scumm.h	14 Aug 2004 16:30:39 -0000	1.440
+++ scumm.h	14 Aug 2004 19:42:00 -0000	1.441
@@ -972,8 +972,6 @@
 	void dissolveEffect(int width, int height);
 	void scrollEffect(int dir);
 
-	void blit(byte *dst, const byte *src, int w, int h);
-
 	// bomp
 public:
 	byte *_bompActorPalettePtr;

Index: verbs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/verbs.cpp,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- verbs.cpp	14 Aug 2004 10:38:34 -0000	1.104
+++ verbs.cpp	14 Aug 2004 19:42:00 -0000	1.105
@@ -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 * vs->width + rect.left;
+			dst = ptr = vs->getPixels(rect.left, rect.top);
 
 			// 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 += vs->width;
+				dst += vs->pitch;
 			}
 
 			markRectAsDirty(kVerbVirtScreen, rect);
@@ -143,7 +143,7 @@
 		if (new_box != -1) {
 			rect = v2_mouseover_boxes[new_box].rect;
 
-			dst = ptr = vs->screenPtr + vs->xstart + rect.top * vs->width + rect.left;
+			dst = ptr = vs->getPixels(rect.left, rect.top);
 
 			// 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 += vs->width;
+				dst += vs->pitch;
 			}
 
 			markRectAsDirty(kVerbVirtScreen, rect);
@@ -209,9 +209,9 @@
 
 	// Clear on all invocations
 	inventoryBox.top = vs->topline + 32;
-	inventoryBox.bottom = vs->topline + virtscr[2].height;
+	inventoryBox.bottom = vs->topline + virtscr[2].h;
 	inventoryBox.left = 0;
-	inventoryBox.right = vs->width;
+	inventoryBox.right = vs->w;
 	restoreBG(inventoryBox);
 
 	_string[1].charset = 1;





More information about the Scummvm-git-logs mailing list