[Scummvm-cvs-logs] SF.net SVN: scummvm:[42163] scummvm/trunk/engines/agos

Kirben at users.sourceforge.net Kirben at users.sourceforge.net
Mon Jul 6 08:21:59 CEST 2009


Revision: 42163
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42163&view=rev
Author:   Kirben
Date:     2009-07-06 06:21:59 +0000 (Mon, 06 Jul 2009)

Log Message:
-----------
Use graphics surfaces for screen buffers, and always use correct pitch when writing to the frameBuffer.

Modified Paths:
--------------
    scummvm/trunk/engines/agos/agos.cpp
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/charset-fontdata.cpp
    scummvm/trunk/engines/agos/charset.cpp
    scummvm/trunk/engines/agos/draw.cpp
    scummvm/trunk/engines/agos/event.cpp
    scummvm/trunk/engines/agos/gfx.cpp
    scummvm/trunk/engines/agos/icons.cpp
    scummvm/trunk/engines/agos/menus.cpp
    scummvm/trunk/engines/agos/oracle.cpp
    scummvm/trunk/engines/agos/verb.cpp
    scummvm/trunk/engines/agos/vga.cpp
    scummvm/trunk/engines/agos/vga_e2.cpp
    scummvm/trunk/engines/agos/vga_pn.cpp
    scummvm/trunk/engines/agos/vga_s2.cpp
    scummvm/trunk/engines/agos/vga_ww.cpp
    scummvm/trunk/engines/agos/window.cpp

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/agos.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -33,6 +33,8 @@
 #include "agos/agos.h"
 #include "agos/vga.h"
 
+#include "graphics/surface.h"
+
 #include "sound/mididrv.h"
 #include "sound/mods/protracker.h"
 #include "sound/audiocd.h"
@@ -182,8 +184,6 @@
 
 	_subroutineList = 0;
 
-	_dxSurfacePitch = 0;
-
 	_recursionDepth = 0;
 
 	_lastVgaTick = 0;
@@ -490,12 +490,13 @@
 	_backGroundBuf = 0;
 	_backBuf = 0;
 	_scaleBuf = 0;
+	_window4BackScn = 0;
+	_window6BackScn = 0;
+	printf("Cleared all\n");
 
 	_window3Flag = 0;
 	_window4Flag = 0;
 	_window6Flag = 0;
-	_window4BackScn = 0;
-	_window6BackScn = 0;
 
 	_moveXMin = 0;
 	_moveYMin = 0;
@@ -580,26 +581,34 @@
 	syncSoundSettings();
 
 	// allocate buffers
-	_backGroundBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
+	_backGroundBuf = new Graphics::Surface();
+	_backGroundBuf->create(_screenWidth, _screenHeight, 1);
 
 	if (getGameType() == GType_FF || getGameType() == GType_PP) {
-		_backBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
-		_scaleBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
+		_backBuf = new Graphics::Surface();
+		_backBuf->create(_screenWidth, _screenHeight, 1);
+		_scaleBuf = new Graphics::Surface();
+		_scaleBuf->create(_screenWidth, _screenHeight, 1);
 	}
 
 	if (getGameType() == GType_SIMON2) {
-		_window4BackScn = (byte *)calloc(_screenWidth * _screenHeight, 1);
+		_window4BackScn = new Graphics::Surface();
+		_window4BackScn->create(_screenWidth, _screenHeight, 1);
 	} else if (getGameType() == GType_SIMON1) {
-		_window4BackScn = (byte *)calloc(_screenWidth * 134, 1);
+		_window4BackScn = new Graphics::Surface();
+		_window4BackScn->create(_screenWidth, 134, 1);
 	} else if (getGameType() == GType_WW || getGameType() == GType_ELVIRA2) {
-		_window4BackScn = (byte *)calloc(224 * 127, 1);
+		_window4BackScn = new Graphics::Surface();
+		_window4BackScn->create(224, 127, 1);
 	} else if (getGameType() == GType_ELVIRA1) {
+		_window4BackScn = new Graphics::Surface();
 		if (getPlatform() == Common::kPlatformAmiga && (getFeatures() & GF_DEMO)) {
-			_window4BackScn = (byte *)calloc(224 * 196, 1);
+			_window4BackScn->create(224, 196, 1);
 		} else {
-			_window4BackScn = (byte *)calloc(224 * 144, 1);
+			_window4BackScn->create(224, 144, 1);
 		}
-		_window6BackScn = (byte *)calloc(48 * 80, 1);
+		_window6BackScn = new Graphics::Surface();
+		_window6BackScn->create(48, 80, 1);
 	}
 
 	setupGame();

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/agos.h	2009-07-06 06:21:59 UTC (rev 42163)
@@ -276,8 +276,6 @@
 
 	Subroutine *_subroutineList;
 
-	uint16 _dxSurfacePitch;
-
 	uint8 _recursionDepth;
 
 	uint32 _lastVgaTick;
@@ -527,8 +525,6 @@
 	uint8 _window3Flag;
 	uint8 _window4Flag;
 	uint8 _window6Flag;
-	byte *_window4BackScn;
-	byte *_window6BackScn;
 
 	uint16 _moveXMin, _moveYMin;
 	uint16 _moveXMax, _moveYMax;
@@ -566,9 +562,11 @@
 	byte _saveLoadType, _saveLoadSlot;
 	char _saveLoadName[108];
 
-	byte *_backGroundBuf;
-	byte *_backBuf;
-	byte *_scaleBuf;
+	Graphics::Surface *_backGroundBuf;
+	Graphics::Surface *_backBuf;
+	Graphics::Surface *_scaleBuf;
+	Graphics::Surface *_window4BackScn;
+	Graphics::Surface *_window6BackScn;
 
 	Common::RandomSource _rnd;
 

Modified: scummvm/trunk/engines/agos/charset-fontdata.cpp
===================================================================
--- scummvm/trunk/engines/agos/charset-fontdata.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/charset-fontdata.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -2090,7 +2090,7 @@
 void AGOSEngine::windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) {
 	const byte *src;
 	byte color, *dst;
-	uint h, w, i;
+	uint dstPitch, h, w, i;
 
 	if (_noOracleScroll)
 		return;
@@ -2100,7 +2100,8 @@
 	Graphics::Surface *screen = _system->lockScreen();
 
 	if (getGameType() == GType_FF || getGameType() == GType_PP) {
-		dst = getBackGround() + y * _dxSurfacePitch + x + window->textColumnOffset;
+		dst = getBackGround();
+		dstPitch = _backGroundBuf->pitch;
 		h = 13;
 		w = getFeebleFontSize(chr);
 
@@ -2109,7 +2110,8 @@
 		else
 			src = feeble_windowFont + (chr - 32) * 13;
 	} else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
-		dst = (byte *)screen->pixels + y * _dxSurfacePitch + x + window->textColumnOffset;
+		dst = (byte *)screen->pixels;
+		dstPitch = screen->pitch;
 		h = 8;
 		w = 6;
 
@@ -2145,7 +2147,8 @@
 			error("windowDrawChar: Unknown language %d", _language);
 		}
 	} else if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) {
-		dst = (byte *)screen->pixels + y * _dxSurfacePitch + x + window->textColumnOffset;
+		dst = (byte *)screen->pixels;
+		dstPitch = screen->pitch;
 		h = 8;
 		w = 6;
 
@@ -2169,18 +2172,21 @@
 			error("windowDrawChar: Unknown language %d", _language);
 		}
 	} else if (getGameType() == GType_ELVIRA1) {
-		dst = (byte *)screen->pixels + y * _dxSurfacePitch + x + window->textColumnOffset;
+		dst = (byte *)screen->pixels;
+		dstPitch = screen->pitch;
 		h = 8;
 		w = 6;
 
 		src = english_elvira1Font + (chr - 32) * 8;
 	} else {
-		dst = (byte *)screen->pixels + y * _dxSurfacePitch + x + window->textColumnOffset;
+		dst = (byte *)screen->pixels;
+		dstPitch = screen->pitch;
 		h = 8;
 		w = 8;
 
 		src = english_pnFont + (chr - 32) * 8;
 	}
+	dst += y * dstPitch + x + window->textColumnOffset;
 
 	color = window->textColor;
 	if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW)
@@ -2201,7 +2207,7 @@
 
 			b <<= 1;
 		} while (++i != w);
-		dst += _dxSurfacePitch;
+		dst += dstPitch;
 	} while (--h);
 
 	_system->unlockScreen();

Modified: scummvm/trunk/engines/agos/charset.cpp
===================================================================
--- scummvm/trunk/engines/agos/charset.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/charset.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -639,13 +639,13 @@
 		w = window->width * 8;
 		h = (window->height -1) * 8;
 
-		dst = (byte *)screen->pixels + window->y * _screenWidth + window->x * 8;
-		src = dst + 8 * _screenWidth;
+		dst = (byte *)screen->pixels + window->y * screen->pitch + window->x * 8;
+		src = dst + 8 * screen->pitch;
 
 		do {
 			memcpy(dst, src, w);
-			src += _screenWidth;
-			dst += _screenWidth;
+			src += screen->pitch;
+			dst += screen->pitch;
 		} while (--h);
 
 		_system->unlockScreen();

Modified: scummvm/trunk/engines/agos/draw.cpp
===================================================================
--- scummvm/trunk/engines/agos/draw.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/draw.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -35,18 +35,15 @@
 namespace AGOS {
 
 byte *AGOSEngine::getBackBuf() {
-	_dxSurfacePitch = _screenWidth;
-	return _backBuf;
+	return (byte *)_backBuf->pixels;
 }
 
 byte *AGOSEngine::getBackGround() {
-	_dxSurfacePitch = _screenWidth;
-	return _backGroundBuf;
+	return (byte *)_backGroundBuf->pixels;
 }
 
 byte *AGOSEngine::getScaleBuf() {
-	_dxSurfacePitch = _screenWidth;
-	return _scaleBuf;
+	return (byte *)_scaleBuf->pixels;
 }
 
 void AGOSEngine_Feeble::animateSpritesByY() {
@@ -166,7 +163,7 @@
 			_wallOn--;
 
 			VC10_state state;
-			state.srcPtr = getBackGround() + 3 * _screenWidth + 3 * 16;
+			state.srcPtr = getBackGround() + 3 * _backGroundBuf->pitch + 3 * 16;
 			state.height = state.draw_height = 127;
 			state.width = state.draw_width = 14;
 			state.y = 0;
@@ -230,7 +227,7 @@
 		debug(0, "Using special wall");
 
 		uint8 color, h, len;
-		byte *dst = _window4BackScn;
+		byte *dst = (byte *)_window4BackScn->pixels;
 
 		color = (_variableArray[293] & 1) ? 13 : 15;
 		_wallOn = 2;
@@ -260,7 +257,7 @@
 	} else if (getGameType() == GType_ELVIRA2 && _variableArray[71] & 2) {
 		// Used by the Unholy Barrier spell
 		uint8 color, h, len;
-		byte *dst = _window4BackScn;
+		byte *dst = (byte *)_window4BackScn->pixels;
 
 		color = 1;
 		_wallOn = 2;
@@ -495,11 +492,11 @@
 	int16 y = vsp->y - _scrollY;
 
 	if (_window3Flag == 1) {
-		animTable->srcPtr = (const byte *)_window4BackScn;
+		animTable->srcPtr = (const byte *)_window4BackScn->pixels;
 	} else {
 		int xoffs = (_videoWindows[vsp->windowNum * 4 + 0] * 2 + x) * 8;
 		int yoffs = (_videoWindows[vsp->windowNum * 4 + 1] + y);
-		animTable->srcPtr = getBackGround() + xoffs + yoffs * _screenWidth;
+		animTable->srcPtr = getBackGround() + yoffs * _backGroundBuf->pitch + xoffs;
 	}
 
 	animTable->x = x;
@@ -571,39 +568,39 @@
 
 				dst = (byte *)screen->pixels;
 
-				dst += (((_dxSurfacePitch / 4) * y_) * 4) + x_;
+				dst += (((screen->pitch / 4) * y_) * 4) + x_;
 
-				b = _dxSurfacePitch;
+				b = screen->pitch;
 				dst[4] = color;
 				dst[b+1] = color;
 				dst[b+4] = color;
 				dst[b+7] = color;
-				b += _dxSurfacePitch;
+				b += screen->pitch;
 				dst[b+2] = color;
 				dst[b+4] = color;
 				dst[b+6] = color;
-				b += _dxSurfacePitch;
+				b += screen->pitch;
 				dst[b+3] = color;
 				dst[b+5] = color;
-				b += _dxSurfacePitch;
+				b += screen->pitch;
 				dst[b] = color;
 				dst[b+1] = color;
 				dst[b+2] = color;
 				dst[b+6] = color;
 				dst[b+7] = color;
 				dst[b+8] = color;
-				b += _dxSurfacePitch;
+				b += screen->pitch;
 				dst[b+3] = color;
 				dst[b+5] = color;
-				b += _dxSurfacePitch;
+				b += screen->pitch;
 				dst[b+2] = color;
 				dst[b+4] = color;
 				dst[b+6] = color;
-				b += _dxSurfacePitch;
+				b += screen->pitch;
 				dst[b+1] = color;
 				dst[b+4] = color;
 				dst[b+7] = color;
-				b += _dxSurfacePitch;
+				b += screen->pitch;
 				dst[b+4] = color;
 			}
 		} while (ha++, --count);
@@ -645,7 +642,7 @@
 		}
 
 		src = _scrollImage + y / 2;
-		decodeRow(dst, src + readUint32Wrapper(src), _scrollWidth, _dxSurfacePitch);
+		decodeRow(dst, src + readUint32Wrapper(src), _scrollWidth, _backGroundBuf->pitch);
 
 		_scrollY += _scrollFlag;
 		vcWriteVar(250, _scrollY);
@@ -670,13 +667,19 @@
 			src = _scrollImage + x / 2;
 		else
 			src = _scrollImage + x * 4;
-		decodeColumn(dst, src + readUint32Wrapper(src), _scrollHeight, _dxSurfacePitch);
+		decodeColumn(dst, src + readUint32Wrapper(src), _scrollHeight, _backGroundBuf->pitch);
 
 		_scrollX += _scrollFlag;
 		vcWriteVar(251, _scrollX);
 
 		if (getGameType() == GType_SIMON2) {
-			memcpy(_window4BackScn, _backGroundBuf, _scrollHeight * _screenWidth);
+			src = getBackGround();
+			dst = (byte *)_window4BackScn->pixels;
+			for (int i = 0; i < _scrollHeight; i++) {
+				memcpy(dst, src, _screenWidth);
+				src += _backGroundBuf->pitch;
+				dst += _window4BackScn->pitch;
+			}
 		} else {
 			fillBackFromBackGround(_scrollHeight, _screenWidth);
 		}
@@ -707,27 +710,53 @@
 	_system->fillScreen(0);
 
 	if (_backBuf) {
-		memset(_backBuf, 0, _screenHeight * _screenWidth);
+		memset(getBackBuf(), 0, _backBuf->h * _backBuf->pitch);
 	}
 }
 
 void AGOSEngine::fillBackFromBackGround(uint16 height, uint16 width) {
-	memcpy(_backBuf, _backGroundBuf, height * width);
+	byte *src = getBackGround();
+	byte *dst = getBackBuf();
+	for (int i = 0; i < height; i++) {
+		memcpy(dst, src, width);
+		src += _backGroundBuf->pitch;
+		dst += _backBuf->pitch;
+	}
 }
 
 void AGOSEngine::fillBackFromFront() {
 	Graphics::Surface *screen = _system->lockScreen();
-	memcpy(_backBuf, (byte *)screen->pixels, _screenHeight * _screenWidth);
+	byte *src = (byte *)screen->pixels;
+	byte *dst = getBackBuf();
+
+	for (int i = 0; i < _screenHeight; i++) {
+		memcpy(dst, src, _screenWidth);
+		src += screen->pitch;
+		dst += _backBuf->pitch;
+	}
 	_system->unlockScreen();
 }
 
 void AGOSEngine::fillBackGroundFromBack() {
-	memcpy(_backGroundBuf, _backBuf, _screenHeight * _screenWidth);
+	byte *src = getBackBuf();
+	byte *dst = getBackGround();
+	for (int i = 0; i < _screenHeight; i++) {
+		memcpy(dst, src, _screenWidth);
+		src += _backBuf->pitch;
+		dst += _backGroundBuf->pitch;
+	}
 }
 
 void AGOSEngine::fillBackGroundFromFront() {
 	Graphics::Surface *screen = _system->lockScreen();
-	memcpy(_backGroundBuf, (byte *)screen->pixels, _screenHeight * _screenWidth);
+	byte *src = (byte *)screen->pixels;
+	byte *dst = getBackGround();
+
+	for (int i = 0; i < _screenHeight; i++) {
+		memcpy(dst, src, _screenWidth);
+		src += screen->pitch;
+		dst += _backGroundBuf->pitch;
+	}
 	_system->unlockScreen();
 }
 
@@ -756,8 +785,13 @@
 
 	Graphics::Surface *screen = _system->lockScreen();
 	if (getGameType() == GType_PP || getGameType() == GType_FF) {
-		memcpy((byte *)screen->pixels, getBackBuf(), _screenWidth * _screenHeight);
-
+		byte *src = getBackBuf();
+		byte *dst = (byte *)screen->pixels;
+		for (int i = 0; i < _screenHeight; i++) {
+			memcpy(dst, src, _screenWidth);
+			src += _backBuf->pitch;
+			dst += screen->pitch;
+		}
 		if (getGameId() != GID_DIMP)
 			fillBackFromBackGround(_screenHeight, _screenWidth);
 	} else {
@@ -767,12 +801,12 @@
 			uint16 srcWidth, width, height;
 			byte *dst = (byte *)screen->pixels;
 
-			const byte *src = _window4BackScn;
+			const byte *src = (const byte *)_window4BackScn->pixels;
 			if (_window3Flag == 1) {
 				src = getBackGround();
 			}
 
-			dst += (_moveYMin + _videoWindows[17]) * _screenWidth;
+			dst += (_moveYMin + _videoWindows[17]) * screen->pitch;
 			dst += (_videoWindows[16] * 16) + _moveXMin;
 
 			src += (_videoWindows[18] * 16 * _moveYMin);
@@ -785,7 +819,7 @@
 
 			for (; height > 0; height--) {
 				memcpy(dst, src, width);
-				dst += _screenWidth;
+				dst += screen->pitch;
 				src += srcWidth;
 			}
 
@@ -798,12 +832,12 @@
 		if (_window6Flag == 2) {
 			_window6Flag = 0;
 
-			byte *src = _window6BackScn;
-			byte *dst = (byte *)screen->pixels + 16320;
+			byte *src = (byte *)_window6BackScn->pixels;
+			byte *dst = (byte *)screen->pixels + 51 * screen->pitch;
 			for (int i = 0; i < 80; i++) {
-				memcpy(dst, src, 48);
-				dst += _screenWidth;
-				src += 48;
+				memcpy(dst, src, _window6BackScn->w);
+				dst += screen->pitch;
+				src += _window6BackScn->pitch;
 			}
 		}
 	}

Modified: scummvm/trunk/engines/agos/event.cpp
===================================================================
--- scummvm/trunk/engines/agos/event.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/event.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -367,12 +367,12 @@
 	const uint8 y = (getPlatform() == Common::kPlatformAtariST) ? 132 : 135;
 
 	Graphics::Surface *screen = _system->lockScreen();
-	byte *dst = (byte *)screen->pixels + y * _screenWidth + xoffs;
+	byte *dst = (byte *)screen->pixels + y * screen->pitch + xoffs;
 
 	for (uint h = 0; h < 6; h++) {
 		memcpy(dst, src, 4);
 		src += 4;
-		dst += _screenWidth;
+		dst += screen->pitch;
 	}
 
 	_system->unlockScreen();

Modified: scummvm/trunk/engines/agos/gfx.cpp
===================================================================
--- scummvm/trunk/engines/agos/gfx.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/gfx.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -272,13 +272,13 @@
 	byte *src = getScaleBuf();
 	byte *dst = getBackBuf();
 
-	dst += _dxSurfacePitch * dstRect.top + dstRect.left;
+	dst += dstRect.top * _backBuf->pitch + dstRect.left;
 
 	for (int dstY = 0; dstY < scaledH; dstY++) {
 		if (dstRect.top + dstY >= 0 && dstRect.top + dstY < _screenHeight) {
 			int srcY = (dstY * h) / scaledH;
-			byte *srcPtr = src + _dxSurfacePitch * srcY;
-			byte *dstPtr = dst + _dxSurfacePitch * dstY;
+			byte *srcPtr = src + _scaleBuf->pitch * srcY;
+			byte *dstPtr = dst + _backBuf->pitch * dstY;
 			for (int dstX = 0; dstX < scaledW; dstX++) {
 				if (dstRect.left + dstX >= 0 && dstRect.left + dstX < _screenWidth) {
 					int srcX = (dstX * w) / scaledW;
@@ -292,12 +292,12 @@
 
 void AGOSEngine_Feeble::drawImage(VC10_state *state) {
 	state->surf_addr = getBackBuf();
-	state->surf_pitch = _dxSurfacePitch;
+	state->surf_pitch = _backBuf->pitch;
 
 	if (state->flags & kDFCompressed) {
 		if (state->flags & kDFScaled) {
 			state->surf_addr = getScaleBuf();
-			state->surf_pitch = _dxSurfacePitch;
+			state->surf_pitch = _scaleBuf->pitch;
 
 			uint w, h;
 			byte *src, *dst, *dstPtr;
@@ -314,7 +314,7 @@
 				h = 0;
 				do {
 					*dst = *src;
-					dst += _screenWidth;
+					dst += state->surf_pitch;
 					src++;
 				} while (++h != state->draw_height);
 				dstPtr++;
@@ -330,7 +330,7 @@
 			}
 		} else if (state->flags & kDFOverlayed) {
 			state->surf_addr = getScaleBuf();
-			state->surf_pitch = _dxSurfacePitch;
+			state->surf_pitch = _scaleBuf->pitch;
 			state->surf_addr += (state->x + _scrollX) + (state->y + _scrollY) * state->surf_pitch;
 
 			uint w, h;
@@ -352,7 +352,7 @@
 					color = *src;
 					if (color != 0)
 						*dst = color;
-					dst += _screenWidth;
+					dst += state->surf_pitch;
 					src++;
 				} while (++h != state->draw_height);
 				dstPtr++;
@@ -406,7 +406,7 @@
 						color = *src;
 						if (color)
 							*dst = color;
-						dst += _screenWidth;
+						dst += state->surf_pitch;
 						src++;
 					} while (++h != state->draw_height);
 					dstPtr++;
@@ -425,7 +425,7 @@
 						color = *src;
 						if ((state->flags & kDFNonTrans) || color != 0)
 							*dst = color;
-						dst += _screenWidth;
+						dst += state->surf_pitch;
 						src++;
 					} while (++h != state->draw_height);
 					dstPtr++;
@@ -456,7 +456,7 @@
 					dst[count] = color;
 				}
 			}
-			dst += _screenWidth;
+			dst += state->surf_pitch;
 			src += state->width;
 		} while (--state->draw_height);
 	}
@@ -557,8 +557,8 @@
 						dst[count * 2 + 1] = src[count * 2 + 1];
 				}
 			}
-			src += _screenWidth;
-			dst += _screenWidth;
+			src += state->surf2_pitch;
+			dst += state->surf_pitch;
 			mask += state->width * 8;
 		} while (--state->draw_height);
 	}
@@ -615,7 +615,7 @@
 				dst += 8;
 				src += 5;
 			} while (--count);
-			dstPtr += _screenWidth;
+			dstPtr += state->surf_pitch;
 		} while (--state->draw_height);
 	} else {
 		src = state->srcPtr + (state->width * state->y_skip * 16) + (state->x_skip * 8);
@@ -628,7 +628,7 @@
 			for (i = 0; i != state->draw_width; i++)
 				if ((state->flags & kDFNonTrans) || src[i])
 					dst[i] = src[i] + state->paletteMod;
-			dst += _screenWidth;
+			dst += state->surf_pitch;
 			src += state->width * 16;
 		} while (--h);
 	}
@@ -648,10 +648,10 @@
 	uint16 xoffs, yoffs;
 	if (getGameType() == GType_SIMON2) {
 		state->surf2_addr = getBackGround();
-		state->surf2_pitch = _screenWidth;
+		state->surf2_pitch = _backGroundBuf->pitch;
 
-		state->surf_addr = _window4BackScn;
-		state->surf_pitch = _screenWidth;
+		state->surf_addr = (byte *)_window4BackScn->pixels;
+		state->surf_pitch = _window4BackScn->pitch;
 
 		xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
 		yoffs = (vlut[1] - _videoWindows[17] + state->y);
@@ -665,9 +665,9 @@
 		// The DOS Floppy demo was based off Waxworks engine
 		if (_windowNum == 4 || (_windowNum >= 10 && _windowNum <= 27)) {
 			state->surf2_addr = getBackGround();
-			state->surf2_pitch = _screenWidth;
+			state->surf2_pitch = _backGroundBuf->pitch;
 
-			state->surf_addr = _window4BackScn;
+			state->surf_addr = (byte *)_window4BackScn;
 			state->surf_pitch = _videoWindows[18] * 16;
 
 			xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -680,7 +680,7 @@
 			_window4Flag = 1;
 		} else {
 			state->surf_addr = (byte *)screen->pixels;
-			state->surf_pitch = _screenWidth;
+			state->surf_pitch = screen->pitch;
 
 			xoffs = (vlut[0] * 2 + state->x) * 8;
 			yoffs = vlut[1] + state->y;
@@ -689,16 +689,16 @@
 		if (_windowNum == 3 || _windowNum == 4 || _windowNum >= 10) {
 			if (_window3Flag == 1) {
 				state->surf2_addr = getBackGround();
-				state->surf2_pitch = _screenWidth;
+				state->surf2_pitch = _backGroundBuf->pitch;
 
 				state->surf_addr = getBackGround();
-				state->surf_pitch = _screenWidth;
+				state->surf_pitch = _backGroundBuf->pitch;
 			} else {
 				state->surf2_addr = getBackGround();
-				state->surf2_pitch = _screenWidth;
+				state->surf2_pitch = _backGroundBuf->pitch;
 
-				state->surf_addr = _window4BackScn;
-				state->surf_pitch = _screenWidth;
+				state->surf_addr = (byte *)_window4BackScn->pixels;
+				state->surf_pitch = _window4BackScn->pitch;
 			}
 
 			xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -711,10 +711,10 @@
 			_window4Flag = 1;
 		} else {
 			state->surf2_addr = getBackGround();
-			state->surf2_pitch = _screenWidth;
+			state->surf2_pitch = _backGroundBuf->pitch;
 
 			state->surf_addr = (byte *)screen->pixels;
-			state->surf_pitch = _screenWidth;
+			state->surf_pitch = screen->pitch;
 
 			xoffs = (vlut[0] * 2 + state->x) * 8;
 			yoffs = vlut[1] + state->y;
@@ -862,7 +862,7 @@
 	uint16 xoffs = 0, yoffs = 0;
 	if (getGameType() == GType_WW) {
 		if (_windowNum == 4 || (_windowNum >= 10 && _windowNum <= 27)) {
-			state->surf_addr = _window4BackScn;
+			state->surf_addr = (byte *)_window4BackScn->pixels;
 			state->surf_pitch = _videoWindows[18] * 16;
 
 			xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -875,14 +875,14 @@
 			_window4Flag = 1;
 		} else {
 			state->surf_addr = (byte *)screen->pixels;
-			state->surf_pitch = _screenWidth;
+			state->surf_pitch = screen->pitch;
 
 			xoffs = (vlut[0] * 2 + state->x) * 8;
 			yoffs = vlut[1] + state->y;
 		}
 	} else if (getGameType() == GType_ELVIRA2) {
 		if (_windowNum == 4 || _windowNum >= 10) {
-			state->surf_addr = _window4BackScn;
+			state->surf_addr = (byte *)_window4BackScn->pixels;
 			state->surf_pitch = _videoWindows[18] * 16;
 
 			xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -895,26 +895,26 @@
 			_window4Flag = 1;
 		} else {
 			state->surf_addr = (byte *)screen->pixels;
-			state->surf_pitch = _screenWidth;
+			state->surf_pitch = screen->pitch;
 
 			xoffs = (vlut[0] * 2 + state->x) * 8;
 			yoffs = vlut[1] + state->y;
 		}
 	} else if (getGameType() == GType_ELVIRA1) {
 		if (_windowNum == 6) {
-			state->surf_addr = _window6BackScn;
-			state->surf_pitch = 48;
+			state->surf_addr = (byte *)_window6BackScn->pixels;
+			state->surf_pitch = _window6BackScn->pitch;
 
 			xoffs = state->x * 8;
 			yoffs = state->y;
 		} else if (_windowNum == 2 || _windowNum == 3) {
 			state->surf_addr = (byte *)screen->pixels;
-			state->surf_pitch = _screenWidth;
+			state->surf_pitch = screen->pitch;
 
 			xoffs = (vlut[0] * 2 + state->x) * 8;
 			yoffs = vlut[1] + state->y;
 		} else {
-			state->surf_addr = _window4BackScn;
+			state->surf_addr = (byte *)_window4BackScn->pixels;
 			state->surf_pitch = _videoWindows[18] * 16;
 
 			xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
@@ -928,7 +928,7 @@
 		}
 	} else {
 		state->surf_addr = (byte *)screen->pixels;
-		state->surf_pitch = _screenWidth;
+		state->surf_pitch = screen->pitch;
 
 		xoffs = (vlut[0] * 2 + state->x) * 8;
 		yoffs = vlut[1] + state->y;
@@ -957,7 +957,7 @@
 void AGOSEngine::horizontalScroll(VC10_state *state) {
 	const byte *src;
 	byte *dst;
-	int w;
+	int dstPitch, w;
 
 	if (getGameType() == GType_FF)
 		_scrollXMax = state->width - 640;
@@ -974,9 +974,11 @@
 	vcWriteVar(251, _scrollX);
 
 	if (getGameType() == GType_SIMON2) {
-		dst = _window4BackScn;
+		dst = (byte *)_window4BackScn->pixels;
+		dstPitch = _window4BackScn->pitch;
 	} else {
 		dst = getBackBuf();
+		dstPitch = _backBuf->pitch;
 	}
 
 	if (getGameType() == GType_FF)
@@ -985,7 +987,7 @@
 		src = state->srcPtr + _scrollX * 4;
 
 	for (w = 0; w < _screenWidth; w += 8) {
-		decodeColumn(dst, src + readUint32Wrapper(src), state->height, _dxSurfacePitch);
+		decodeColumn(dst, src + readUint32Wrapper(src), state->height, dstPitch);
 		dst += 8;
 		src += 4;
 	}
@@ -1015,7 +1017,7 @@
 	src = state->srcPtr + _scrollY / 2;
 
 	for (h = 0; h < _screenHeight; h += 8) {
-		decodeRow(dst, src + READ_LE_UINT32(src), state->width, _dxSurfacePitch);
+		decodeRow(dst, src + READ_LE_UINT32(src), state->width, _backBuf->pitch);
 		dst += 8 * state->width;
 		src += 4;
 	}
@@ -1366,21 +1368,21 @@
 		uint height = _videoWindows[updateWindow * 4 + 3];
 
 		Graphics::Surface *screen = _system->lockScreen();
-		byte *dst = getBackGround() + xoffs + yoffs * _screenWidth;
+		byte *dst = (byte *)_backGroundBuf->getBasePtr(xoffs, yoffs);
 		byte *src = 0;
 		uint srcWidth = 0;
 
 		if (getGameType() == GType_SIMON2) {
-			src = _window4BackScn + xoffs + yoffs * 320;
+			src = (byte *)_window4BackScn->getBasePtr(xoffs, yoffs);
 			srcWidth = 320;
 		} else if (getGameType() == GType_SIMON1 && (getFeatures() & GF_DEMO)) {
 			// The DOS Floppy demo was based off Waxworks engine
 			if (updateWindow == 4 || updateWindow >= 10) {
-				src = _window4BackScn;
+				src = (byte *)_window4BackScn->pixels;
 				srcWidth = _videoWindows[18] * 16;
 			} else if (updateWindow == 3 || updateWindow == 9) {
-				src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
-				srcWidth = _screenWidth;
+				src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+				srcWidth = screen->pitch;
 			} else {
 				_system->unlockScreen();
 				_videoLockOut &= ~0x20;
@@ -1388,14 +1390,14 @@
 			}
 		} else if (getGameType() == GType_SIMON1) {
 			if (updateWindow == 4) {
-				src = _window4BackScn;
+				src = (byte *)_window4BackScn->pixels;
 				srcWidth = _videoWindows[18] * 16;
 			} else if (updateWindow >= 10) {
-				src = _window4BackScn + xoffs + yoffs * 320;
+				src = (byte *)_window4BackScn->pixels + xoffs + yoffs * 320;
 				srcWidth = _videoWindows[18] * 16;
 			} else if (updateWindow == 0) {
-				src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
-				srcWidth = _screenWidth;
+				src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+				srcWidth = screen->pitch;
 			} else {
 				_system->unlockScreen();
 				_videoLockOut &= ~0x20;
@@ -1403,11 +1405,11 @@
 			}
 		} else if (getGameType() == GType_WW) {
 			if (updateWindow == 4 || updateWindow >= 10) {
-				src = _window4BackScn;
+				src = (byte *)_window4BackScn->pixels;
 				srcWidth = _videoWindows[18] * 16;
 			} else if (updateWindow == 3 || updateWindow == 9) {
-				src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
-				srcWidth = _screenWidth;
+				src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+				srcWidth = screen->pitch;
 			} else {
 				_system->unlockScreen();
 				_videoLockOut &= ~0x20;
@@ -1415,11 +1417,11 @@
 			}
 		} else if (getGameType() == GType_ELVIRA2) {
 			if (updateWindow == 4 || updateWindow >= 10) {
-				src = _window4BackScn;
+				src = (byte *)_window4BackScn->pixels;
 				srcWidth = _videoWindows[18] * 16;
 			} else if (updateWindow == 3) {
-				src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
-				srcWidth = _screenWidth;
+				src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+				srcWidth = screen->pitch;
 			} else {
 				_system->unlockScreen();
 				_videoLockOut &= ~0x20;
@@ -1428,25 +1430,25 @@
 		} else if (getGameType() == GType_ELVIRA1) {
 			if (updateWindow == 6) {
 				_window6Flag = 1;
-				src = _window6BackScn;
+				src = (byte *)_window6BackScn->pixels;
 				srcWidth = 48;
 			} else if (updateWindow == 2 || updateWindow == 3) {
-				src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
-				srcWidth = _screenWidth;
+				src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+				srcWidth = screen->pitch;
 			} else {
-				src = _window4BackScn;
+				src = (byte *)_window4BackScn->pixels;
 				srcWidth = _videoWindows[18] * 16;
 			}
 		} else {
-			src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
-			srcWidth = _screenWidth;
+			src = (byte *)screen->pixels + yoffs * screen->pitch + xoffs;
+			srcWidth = screen->pitch;
 		}
 
 		_boxStarHeight = height;
 
 		for (; height > 0; height--) {
 			memcpy(dst, src, width);
-			dst += _screenWidth;
+			dst += _backGroundBuf->pitch;
 			src += srcWidth;
 		}
 
@@ -1455,15 +1457,15 @@
 			dst = (byte *)screen->pixels + 48;
 			memset(dst, color, 224);
 
-			dst = (byte *)screen->pixels + 132 * _screenWidth + 48;
+			dst = (byte *)screen->pixels + 132 * screen->pitch + 48;
 			memset(dst, color, 224);
 		} else if (getGameType() == GType_ELVIRA1 && updateWindow == 3 && _bottomPalette) {
-			dst = (byte *)screen->pixels + 133 * _screenWidth;
-			int size = 67 * _screenWidth;
+			dst = (byte *)screen->pixels + 133 * screen->pitch;
 
-			while (size--) {
-				*dst += 0x10;
-				dst++;
+			for (int h = 0; h < 67; h++) {
+				for (int w = 0; w < _screenWidth; w++)
+					dst[w] += 0x10;
+				dst += screen->pitch;
 			}
 		}
 
@@ -1480,16 +1482,16 @@
 
 	Graphics::Surface *screen = _system->lockScreen();
 
-	dst = (byte *)screen->pixels + 136 * _screenWidth;
+	dst = (byte *)screen->pixels + 136 * screen->pitch;
 	uint8 len = 52;
 
 	while (len--) {
 		dst[0] = color;
 		dst[319] = color;
-		dst += _screenWidth;
+		dst += screen->pitch;
 	}
 
-	dst = (byte *)screen->pixels + 187 * _screenWidth;
+	dst = (byte *)screen->pixels + 187 * screen->pitch;
 	memset(dst, color, _screenWidth);
 
 	_system->unlockScreen();

Modified: scummvm/trunk/engines/agos/icons.cpp
===================================================================
--- scummvm/trunk/engines/agos/icons.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/icons.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -211,15 +211,15 @@
 
 	dst += 110;
 	dst += x;
-	dst += (y + window->y) * _dxSurfacePitch;
+	dst += (y + window->y) * screen->pitch;
 
 	src = _iconFilePtr;
 	src += READ_LE_UINT16(src + icon * 4 + 0);
-	decompressIcon(dst, src, 20, 10, 224, _dxSurfacePitch);
+	decompressIcon(dst, src, 20, 10, 224, screen->pitch);
 
 	src = _iconFilePtr;
 	src += READ_LE_UINT16(src + icon * 4 + 2);
-	decompressIcon(dst, src, 20, 10, 208, _dxSurfacePitch);
+	decompressIcon(dst, src, 20, 10, 208, screen->pitch);
 
 	_system->unlockScreen();
 
@@ -236,17 +236,17 @@
 	dst = (byte *)screen->pixels;
 
 	dst += (x + window->x) * 8;
-	dst += (y * 25 + window->y) * _dxSurfacePitch;
+	dst += (y * 25 + window->y) * screen->pitch;
 
 	if (getPlatform() == Common::kPlatformAmiga) {
 		src = _iconFilePtr;
 		src += READ_BE_UINT32(src + icon * 4);
 		uint8 color = (getFeatures() & GF_32COLOR) ? 224 : 240;
-		decompressIconPlanar(dst, src, 24, 12, color, _dxSurfacePitch);
+		decompressIconPlanar(dst, src, 24, 12, color, screen->pitch);
 	} else {
 		src = _iconFilePtr;
 		src += READ_LE_UINT16(src + icon * 2);
-		decompressIcon(dst, src, 24, 12, 224, _dxSurfacePitch);
+		decompressIcon(dst, src, 24, 12, 224, screen->pitch);
 	}
 
 	_system->unlockScreen();
@@ -264,17 +264,17 @@
 	dst = (byte *)screen->pixels;
 
 	dst += (x + window->x) * 8;
-	dst += (y * 20 + window->y) * _dxSurfacePitch;
+	dst += (y * 20 + window->y) * screen->pitch;
 
 	uint8 color = dst[0] & 0xF0;
 	if (getPlatform() == Common::kPlatformAmiga) {
 		src = _iconFilePtr;
 		src += READ_BE_UINT32(src + icon * 4);
-		decompressIconPlanar(dst, src, 24, 10, color, _dxSurfacePitch);
+		decompressIconPlanar(dst, src, 24, 10, color, screen->pitch);
 	} else {
 		src = _iconFilePtr;
 		src += READ_LE_UINT16(src + icon * 2);
-		decompressIcon(dst, src, 24, 10, color, _dxSurfacePitch);
+		decompressIcon(dst, src, 24, 10, color, screen->pitch);
 	}
 
 	_system->unlockScreen();
@@ -292,17 +292,17 @@
 	dst = (byte *)screen->pixels;
 
 	dst += (x + window->x) * 8;
-	dst += (y * 8 + window->y) * _dxSurfacePitch;
+	dst += (y * 8 + window->y) * screen->pitch;
 
 	uint color = dst[0] & 0xF0;
 	if (getFeatures() & GF_PLANAR) {
 		src = _iconFilePtr;
 		src += READ_BE_UINT32(src + icon * 4);
-		decompressIconPlanar(dst, src, 24, 12, color, _dxSurfacePitch);
+		decompressIconPlanar(dst, src, 24, 12, color, screen->pitch);
 	} else {
 		src = _iconFilePtr;
 		src += READ_LE_UINT16(src + icon * 2);
-		decompressIcon(dst, src, 24, 12, color, _dxSurfacePitch);
+		decompressIcon(dst, src, 24, 12, color, screen->pitch);
 	}
 
 	_system->unlockScreen();
@@ -320,16 +320,16 @@
 	dst = (byte *)screen->pixels;
 
 	dst += (x + window->x) * 8;
-	dst += (y * 8 + window->y) * _dxSurfacePitch;
+	dst += (y * 8 + window->y) * screen->pitch;
 
 	if (getFeatures() & GF_PLANAR) {
 		src = _iconFilePtr;
 		src += READ_BE_UINT16(src + icon * 2);
-		decompressIconPlanar(dst, src, 24, 12, 16, _dxSurfacePitch);
+		decompressIconPlanar(dst, src, 24, 12, 16, screen->pitch);
 	} else {
 		src = _iconFilePtr;
 		src += icon * 288;
-		decompressIconPlanar(dst, src, 24, 12, 16, _dxSurfacePitch, false);
+		decompressIconPlanar(dst, src, 24, 12, 16, screen->pitch, false);
 	}
 
 	_system->unlockScreen();
@@ -344,14 +344,14 @@
 	_videoLockOut |= 0x8000;
 
 	Graphics::Surface *screen = _system->lockScreen();
-	dst = (byte *)screen->pixels + y * _dxSurfacePitch + x * 8;
+	dst = (byte *)screen->pixels + y * screen->pitch + x * 8;
 	src = _iconFilePtr + icon * 146;
 
 	if (icon == 0xFF) {
 		// Draw Blank Icon
 		for (int yp = 0; yp < 24; yp++) {
 			memset(dst, 0, 24);
-			dst += _dxSurfacePitch;
+			dst += screen->pitch;
 		}
 	} else {
 		uint8 palette[4];
@@ -364,7 +364,7 @@
 			uint32 v1 = (READ_BE_UINT16(src) << 8) | *(src + 4);
 			uint32 v2 = (READ_BE_UINT16(src + 2) << 8) | *(src + 5);
 			for (int xp = 0; xp < 24; ++xp, v1 >>= 1, v2 >>= 1) {
-				dst[yp * _screenWidth + (23 - xp)] = palette[((v1 & 1) << 1) | (v2 & 1)];
+				dst[yp * screen->pitch + (23 - xp)] = palette[((v1 & 1) << 1) | (v2 & 1)];
 			}
 		}
 	}
@@ -952,7 +952,7 @@
 	}
 
 	Graphics::Surface *screen = _system->lockScreen();
-	byte *dst = (byte *)screen->pixels + y * _screenWidth + x * 8;
+	byte *dst = (byte *)screen->pixels + y * screen->pitch + x * 8;
 
 	for (h = 0; h < 19; h++) {
 		for (w = 0; w < 16; w++) {
@@ -960,7 +960,7 @@
 		}
 
 		src += dir;
-		dst+= _screenWidth;
+		dst+= screen->pitch;
 	}
 
 	_system->unlockScreen();
@@ -1043,7 +1043,7 @@
 // Personal Nightmare specific
 void AGOSEngine_PN::drawIconHitBar() {
 	Graphics::Surface *screen = _system->lockScreen();
-	byte *dst = (byte *)screen->pixels + 3 * _dxSurfacePitch + 6 * 8;
+	byte *dst = (byte *)screen->pixels + 3 * screen->pitch + 6 * 8;
 	const byte *src = hitBarData;
 	uint8 color = (getPlatform() == Common::kPlatformPC) ? 7 : 15;
 
@@ -1058,7 +1058,7 @@
 				b <<= 1;
 			}
 		}
-		dst += _dxSurfacePitch;
+		dst += screen->pitch;
 	}
 
 	_system->unlockScreen();

Modified: scummvm/trunk/engines/agos/menus.cpp
===================================================================
--- scummvm/trunk/engines/agos/menus.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/menus.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -170,7 +170,7 @@
 	mouseOff();
 
 	Graphics::Surface *screen = _system->lockScreen();
-	src = (byte *)screen->pixels + 2832;
+	src = (byte *)screen->pixels + 8 * screen->pitch + 272;
 	w = 48;
 	h = 82;
 
@@ -179,7 +179,7 @@
 			if (src[i] != 0)
 				src[i] = 14;
 		}
-		src += _dxSurfacePitch;
+		src += screen->pitch;
 	} while (--h);
 
 	for (i = 120; i != 130; i++)
@@ -198,7 +198,7 @@
 	mouseOff();
 
 	Graphics::Surface *screen = _system->lockScreen();
-	src = (byte *)screen->pixels + ha->y * _dxSurfacePitch + ha->x;
+	src = (byte *)screen->pixels + ha->y * screen->pitch + ha->x;
 	w = ha->width;
 	h = ha->height;
 
@@ -207,7 +207,7 @@
 			if (src[i] == 14)
 				src[i] = 15;
 		}
-		src += _dxSurfacePitch;
+		src += screen->pitch;
 	} while (--h);
 
 	_system->unlockScreen();

Modified: scummvm/trunk/engines/agos/oracle.cpp
===================================================================
--- scummvm/trunk/engines/agos/oracle.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/oracle.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -246,28 +246,28 @@
 	byte *src, *dst;
 	uint16 w, h;
 
-	dst = getBackGround() + 103 * _screenWidth + 136;
-	src = getBackGround() + 106 * _screenWidth + 136;
+	dst = getBackGround() + 103 * _backGroundBuf->pitch + 136;
+	src = getBackGround() + 106 * _backGroundBuf->pitch + 136;
 
 	for (h = 0; h < 21; h++) {
 		for (w = 0; w < 360; w++) {
 			if (dst[w] == 0 || dst[w] == 113  || dst[w] == 116 || dst[w] == 252)
 				dst[w] = src[w];
 		}
-		dst += _screenWidth;
-		src += _screenWidth;
+		dst += _backGroundBuf->pitch;
+		src += _backGroundBuf->pitch;
 	}
 
 	for (h = 0; h < 80; h++) {
 		memcpy(dst, src, 360);
-		dst += _screenWidth;
-		src += _screenWidth;
+		dst += _backGroundBuf->pitch;
+		src += _backGroundBuf->pitch;
 	}
 
 	for (h = 0; h < 3; h++) {
 		memset(dst, 0, 360);
-		dst += _screenWidth;
-		src += _screenWidth;
+		dst += _backGroundBuf->pitch;
+		src += _backGroundBuf->pitch;
 	}
 }
 
@@ -275,13 +275,13 @@
 	byte *src, *dst;
 	uint16 w, h;
 
-	src = getBackGround() + 203 * _screenWidth + 136;
-	dst = getBackGround() + 206 * _screenWidth + 136;
+	src = getBackGround() + 203 * _backGroundBuf->pitch + 136;
+	dst = getBackGround() + 206 * _backGroundBuf->pitch + 136;
 
 	for (h = 0; h < 77; h++) {
 		memcpy(dst, src, 360);
-		dst -= _screenWidth;
-		src -= _screenWidth;
+		dst -= _backGroundBuf->pitch;
+		src -= _backGroundBuf->pitch;
 	}
 
 	for (h = 0; h < 24; h++) {
@@ -294,8 +294,8 @@
 				src[w] = 0;
 			}
 		}
-		dst -= _screenWidth;
-		src -= _screenWidth;
+		dst -= _backGroundBuf->pitch;
+		src -= _backGroundBuf->pitch;
 	}
 }
 
@@ -315,7 +315,7 @@
 	srcRect.bottom = 43;
 
 	src = _iconFilePtr;
-	dst = getBackBuf() + _screenWidth * dstRect.top + dstRect.left;
+	dst = getBackBuf() + _backBuf->pitch * dstRect.top + dstRect.left;
 
 	for (h = 0; h < dstRect.height(); h++) {
 		for (w = 0; w < dstRect.width(); w++) {
@@ -323,7 +323,7 @@
 				dst[w] = src[w];
 		}
 		src += 336;
-		dst += _screenWidth;
+		dst += _backBuf->pitch;
 	}
 }
 
@@ -355,7 +355,7 @@
 	srcRect.right = srcRect.left + 42;
 
 	src = _iconFilePtr + srcRect.top * 336 + srcRect.left;
-	dst = getBackBuf() + _screenWidth * dstRect.top + dstRect.left;
+	dst = getBackBuf() + _backBuf->pitch * dstRect.top + dstRect.left;
 
 	for (h = 0; h < dstRect.height(); h++) {
 		for (w = 0; w < dstRect.width(); w++) {
@@ -363,7 +363,7 @@
 				dst[w] = src[w];
 		}
 		src += 336;
-		dst += _screenWidth;
+		dst += _backBuf->pitch;
 	}
 }
 
@@ -506,14 +506,14 @@
 	x = window->x + window->textColumn;
 	y = window->y + window->textRow;
 
-	dst = getBackGround() + _dxSurfacePitch * y + x;
+	dst = getBackGround() + _backGroundBuf->pitch * y + x;
 
 	for (h = 0; h < 13; h++) {
 		for (w = 0; w < 8; w++) {
 			if (dst[w] == 113  || dst[w] == 116 || dst[w] == 252)
 				dst[w] = 0;
 		}
-		dst += _screenWidth;
+		dst += _backGroundBuf->pitch;
 	}
 
 	_videoLockOut &= ~0x8000;

Modified: scummvm/trunk/engines/agos/verb.cpp
===================================================================
--- scummvm/trunk/engines/agos/verb.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/verb.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -967,7 +967,7 @@
 	_videoLockOut |= 0x8000;
 
 	Graphics::Surface *screen = _system->lockScreen();
-	src = (byte *)screen->pixels + ha->y * _dxSurfacePitch + ha->x;
+	src = (byte *)screen->pixels + ha->y * screen->pitch + ha->x;
 
 	// WORKAROUND: Hitareas for saved game names aren't adjusted for scrolling locations
 	if (getGameType() == GType_SIMON2 && ha->id >= 208 && ha->id <= 213) {
@@ -1019,7 +1019,7 @@
 				}
 			}
 		}
-		src += _dxSurfacePitch;
+		src += screen->pitch;
 	} while (--h);
 
 	_system->unlockScreen();

Modified: scummvm/trunk/engines/agos/vga.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/vga.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -1182,11 +1182,12 @@
 void AGOSEngine::vc32_saveScreen() {
 	if (getGameType() == GType_PN) {
 		Graphics::Surface *screen = _system->lockScreen();
-
 		byte *dst = getBackGround();
 		byte *src = (byte *)screen->pixels;
-		memcpy(dst, src, 64000);
-
+		for (int i = 0; i < _screenHeight; i++) {
+			memcpy(dst, src, _screenWidth);
+			dst += screen->pitch;
+		}
 		_system->unlockScreen();
 	} else {
 		uint16 xoffs = _videoWindows[4 * 4 + 0] * 16;
@@ -1194,12 +1195,12 @@
 		uint16 width = _videoWindows[4 * 4 + 2] * 16;
 		uint16 height = _videoWindows[4 * 4 + 3];
 
-		byte *dst = getBackGround() + xoffs + yoffs * _screenWidth;
-		byte *src = _window4BackScn;
+		byte *dst = (byte *)_backGroundBuf->getBasePtr(xoffs, yoffs);
+		byte *src = (byte *)_window4BackScn->pixels;;
 		uint16 srcWidth = _videoWindows[4 * 4 + 2] * 16;
 		for (; height > 0; height--) {
 			memcpy(dst, src, width);
-			dst += _screenWidth;
+			dst += _backGroundBuf->pitch;
 			src += srcWidth;
 		}
 	}
@@ -1228,11 +1229,11 @@
 
 void AGOSEngine::clearVideoBackGround(uint16 num, uint16 color) {
 	const uint16 *vlut = &_videoWindows[num * 4];
-	byte *dst = getBackGround() + vlut[0] * 16 + vlut[1] * _dxSurfacePitch;
+	byte *dst = (byte *)_backGroundBuf->getBasePtr(vlut[0] * 16, vlut[1]);
 
 	for (uint h = 0; h < vlut[3]; h++) {
 		memset(dst, color, vlut[2] * 16);
-		dst += _screenWidth;
+		dst += _backGroundBuf->pitch;
 	}
 }
 
@@ -1250,14 +1251,18 @@
 
 	if (getGameType() == GType_ELVIRA1 && num == 3) {
 		Graphics::Surface *screen = _system->lockScreen();
-		memset((byte *)screen->pixels, color, _screenWidth * _screenHeight);
+		byte *dst = (byte *)screen->pixels;
+		for (int i = 0; i < _screenHeight; i++) {
+			memset(dst, color, _screenWidth);
+			dst += screen->pitch;
+		}
 		 _system->unlockScreen();
 	} else if (num == 4) {
 		const uint16 *vlut = &_videoWindows[num * 4];
 		uint16 xoffs = (vlut[0] - _videoWindows[16]) * 16;
 		uint16 yoffs = (vlut[1] - _videoWindows[17]);
 		uint16 dstWidth = _videoWindows[18] * 16;
-		byte *dst = _window4BackScn + xoffs + yoffs * dstWidth;
+		byte *dst = (byte *)_window4BackScn->pixels + xoffs + yoffs * dstWidth;
 
 		setMoveRect(0, 0, vlut[2] * 16, vlut[3]);
 

Modified: scummvm/trunk/engines/agos/vga_e2.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga_e2.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/vga_e2.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -77,7 +77,7 @@
 	uint8 height = vlut[3];
 
 	if (num == 4) {
-		byte *dst = _window4BackScn;
+		byte *dst = (byte *)_window4BackScn->pixels;
 
 		for (uint8 h = 0; h < height; h++) {
 			for (uint8 w = 0; w < width; w++) {
@@ -90,7 +90,7 @@
 		}
 	} else {
 		Graphics::Surface *screen = _system->lockScreen();
-		byte *dst = (byte *)screen->pixels + vlut[0] * 16 + vlut[1] * _dxSurfacePitch;
+		byte *dst = (byte *)screen->getBasePtr(vlut[0] * 16, vlut[1]);
 
 		if (getGameType() == GType_ELVIRA2 && num == 7) {
 			dst -= 8;
@@ -104,7 +104,7 @@
 				val |= color * 16;
 				WRITE_LE_UINT16(dst + w * 2, val);
 			}
-			dst += _dxSurfacePitch;
+			dst += screen->pitch;
 		}
 
 		_system->unlockScreen();
@@ -218,18 +218,19 @@
 	uint16 dissolveDelay = dissolveCheck * 2 / speed;
 	uint16 dissolveCount = dissolveCheck * 2 / speed;
 
+	Graphics::Surface *screen = _system->lockScreen();
+
 	int16 xoffs = _videoWindows[num * 4 + 0] * 16;
 	int16 yoffs = _videoWindows[num * 4 + 1];
-	int16 offs = xoffs + yoffs * _screenWidth;
+	int16 offs = xoffs + yoffs * screen->pitch;
 
 	uint16 count = dissolveCheck * 2;
 	while (count--) {
-		Graphics::Surface *screen = _system->lockScreen();
 		byte *dstPtr = (byte *)screen->pixels + offs;
 
 		yoffs = _rnd.getRandomNumber(dissolveY);
-		dst = dstPtr + yoffs * _screenWidth;
-		src = _window4BackScn + yoffs * 224;
+		dst = dstPtr + yoffs * screen->pitch;
+		src = (byte *)_window4BackScn->pixels + yoffs * _window4BackScn->pitch;
 
 		xoffs = _rnd.getRandomNumber(dissolveX);
 		dst += xoffs;
@@ -252,15 +253,15 @@
 		dstOffs2 = dst;
 
 		yoffs = (dissolveY - 1) * 2 - (yoffs * 2);
-		src = srcOffs + yoffs * 224;
-		dst = dstOffs + yoffs * _screenWidth;
+		src = srcOffs + yoffs * _window4BackScn->pitch;
+		dst = dstOffs + yoffs * screen->pitch;
 
 		color = 0xF0;
 		*dst &= color;
 		*dst |= *src & 0xF;
 
-		dst = dstOffs2 + yoffs * _screenWidth;
-		src = srcOffs2 + yoffs * 224;
+		dst = dstOffs2 + yoffs * screen->pitch;
+		src = srcOffs2 + yoffs * _window4BackScn->pitch;
 
 		*dst &= color;
 		*dst |= *src & 0xF;
@@ -291,19 +292,20 @@
 	uint16 dissolveDelay = dissolveCheck * 2 / speed;
 	uint16 dissolveCount = dissolveCheck * 2 / speed;
 
+	Graphics::Surface *screen = _system->lockScreen();
+
 	int16 xoffs = _videoWindows[num * 4 + 0] * 16;
 	int16 yoffs = _videoWindows[num * 4 + 1];
-	int16 offs = xoffs + yoffs * _screenWidth;
+	int16 offs = xoffs + yoffs * screen->pitch;
 
 	uint16 count = dissolveCheck * 2;
 	while (count--) {
-		Graphics::Surface *screen = _system->lockScreen();
 		byte *dstPtr = (byte *)screen->pixels + offs;
 		color |= dstPtr[0] & 0xF0;
 
 		yoffs = _rnd.getRandomNumber(dissolveY);
 		xoffs = _rnd.getRandomNumber(dissolveX);
-		dst = dstPtr + xoffs + yoffs * _screenWidth;
+		dst = dstPtr + xoffs + yoffs * screen->pitch;
 		*dst = color;
 
 		dstOffs = dst;
@@ -313,7 +315,7 @@
 		*dst = color;
 
 		yoffs = (dissolveY - 1) * 2 - (yoffs * 2);
-		dst = dstOffs + yoffs * _screenWidth;
+		dst = dstOffs + yoffs * screen->pitch;
 		*dst = color;
 
 		dst += xoffs;
@@ -354,18 +356,22 @@
 }
 
 void AGOSEngine::vc56_fullScreen() {
+	uint8 palette[1024];
+
 	Graphics::Surface *screen = _system->lockScreen();
-
 	byte *dst = (byte *)screen->pixels;
-	byte *src = _curVgaFile2 + 32;
+	byte *src = _curVgaFile2 + 800;
 
-	memcpy(dst, src + 768, _screenHeight * _screenWidth);
-
+	for (int i = 0; i < _screenHeight; i++) {
+		memcpy(dst, src, _screenWidth);
+		src += 320;
+		dst += screen->pitch;
+	}
 	 _system->unlockScreen();
 
 	//fullFade();
 
-	uint8 palette[1024];
+	src = _curVgaFile2 + 32;
 	for (int i = 0; i < 256; i++) {
 		palette[i * 4 + 0] = *src++ * 4;
 		palette[i * 4 + 1] = *src++ * 4;

Modified: scummvm/trunk/engines/agos/vga_pn.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga_pn.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/vga_pn.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -168,7 +168,7 @@
 					if (dst[w] == 15)
 						dst[w] = 4;
 				}
-				dst += _screenWidth;
+				dst += screen->pitch;
 			}
 			_system->unlockScreen();
 		} else if (num == 2) {

Modified: scummvm/trunk/engines/agos/vga_s2.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga_s2.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/vga_s2.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -28,6 +28,8 @@
 #include "agos/agos.h"
 #include "agos/intern.h"
 
+#include "graphics/surface.h"
+
 namespace AGOS {
 
 void AGOSEngine_Simon2::setupVideoOpcodes(VgaOpcodeProc *op) {
@@ -215,7 +217,7 @@
 	uint16 xoffs = vlut[0] * 16;
 	uint16 yoffs = vlut[1];
 	uint16 dstWidth = _videoWindows[18] * 16;
-	byte *dst = _window4BackScn + xoffs + yoffs * dstWidth;
+	byte *dst = (byte *)_window4BackScn->pixels + xoffs + yoffs * dstWidth;
 
 	setMoveRect(0, 0, vlut[2] * 16, vlut[3]);
 

Modified: scummvm/trunk/engines/agos/vga_ww.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga_ww.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/vga_ww.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -145,14 +145,19 @@
 	uint h, tmp;
 
 	Graphics::Surface *screen = _system->lockScreen();
+	dstPtr = (byte *)screen->pixels;
 
 	if (a == 6) {
 		src = _curVgaFile2 + 800;
-		dstPtr = (byte *)screen->pixels;
-		memcpy(dstPtr, src, 64000);
+
+		for (int i = 0; i < _screenHeight; i++) {
+			memcpy(dst, src, _screenWidth);
+			src += 320;
+			dst += screen->pitch;
+		}
+
 		tmp = 4 - 1;
 	} else {
-		dstPtr = (byte *)screen->pixels;
 		tmp = a - 1;
 	}
 
@@ -160,15 +165,14 @@
 	while (tmp--)
 		src += 1536 * 16 + 1712;
 
-
 	src += 800;
 
 	if (a != 5) {
-		dst = dstPtr + 7448;
+		dst = dstPtr + 23 * screen->pitch + 88;
 		for (h = 0; h < 177; h++) {
 			memcpy(dst, src, 144);
 			src += 144;
-			dst += _screenWidth;
+			dst += screen->pitch;
 		}
 
 		if (a != 6) {
@@ -179,11 +183,11 @@
 		src = _curVgaFile2 + 9984 * 16 + 15344;
 	}
 
-	dst = dstPtr + 50296;
+	dst = dstPtr + 157 * screen->pitch + 56;
 	for (h = 0; h < 17; h++) {
 		memcpy(dst, src, 208);
 		src += 208;
-		dst += _screenWidth;
+		dst += screen->pitch;
 	}
 
 	_system->unlockScreen();

Modified: scummvm/trunk/engines/agos/window.cpp
===================================================================
--- scummvm/trunk/engines/agos/window.cpp	2009-07-06 02:46:59 UTC (rev 42162)
+++ scummvm/trunk/engines/agos/window.cpp	2009-07-06 06:21:59 UTC (rev 42163)
@@ -128,14 +128,14 @@
 
 	_videoLockOut |= 0x8000;
 
-	dst = getBackGround() + _dxSurfacePitch * window->y + window->x;
+	dst = getBackGround() + _backGroundBuf->pitch * window->y + window->x;
 
 	for (h = 0; h < window->height; h++) {
 		for (w = 0; w < window->width; w++) {
 			if (dst[w] == 113 || dst[w] == 116 || dst[w] == 252)
 				dst[w] = window->fillColor;
 		}
-		dst += _screenWidth;
+		dst += _backGroundBuf->pitch;
 	}
 
 	_videoLockOut &= ~0x8000;
@@ -171,7 +171,7 @@
 	_videoLockOut |= 0x8000;
 
 	Graphics::Surface *screen = _system->lockScreen();
-	byte *dst = (byte *)screen->pixels + y * _screenWidth + x;
+	byte *dst = (byte *)screen->pixels + y * screen->pitch + x;
 
 	uint8 color = window->fillColor;
 	if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW)
@@ -179,7 +179,7 @@
 
 	do {
 		memset(dst, color, w);
-		dst += _screenWidth;
+		dst += screen->pitch;
 	} while (--h);
 
 	_system->unlockScreen();
@@ -236,8 +236,8 @@
 	dst = (byte *)screen->pixels;
 	src = getBackGround();
 
-	dst += y * _dxSurfacePitch;
-	src += y * _dxSurfacePitch;
+	dst += y * screen->pitch;
+	src += y * _backGroundBuf->pitch;
 
 	uint8 paletteMod = 0;
 	if (getGameType() == GType_ELVIRA1 && !(getFeatures() & GF_DEMO) && y >= 133)
@@ -247,8 +247,8 @@
 		for (i = x; i < w; i++)
 			dst[i] = src[i] + paletteMod;
 		y++;
-		dst += _dxSurfacePitch;
-		src += _dxSurfacePitch;
+		dst += screen->pitch;
+		src += _backGroundBuf->pitch;
 	}
 
 	_system->unlockScreen();


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