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

Kirben at users.sourceforge.net Kirben at users.sourceforge.net
Thu Jun 21 05:14:21 CEST 2007


Revision: 27577
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27577&view=rev
Author:   Kirben
Date:     2007-06-20 20:14:20 -0700 (Wed, 20 Jun 2007)

Log Message:
-----------
Use frameBuffer directly, in order to drop extra buffer (frontBuffer) and cleanup code.

Modified Paths:
--------------
    scummvm/trunk/engines/agos/agos.cpp
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/animation.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_ww.cpp
    scummvm/trunk/engines/agos/window.cpp

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/agos.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -208,7 +208,6 @@
 	_cepeFlag = 0;
 	_copyPartialMode = 0;
 	_fastMode = 0;
-	_useBackGround = 0;
 	
 	_backFlag = 0;
 
@@ -502,7 +501,6 @@
 	_noOracleScroll = 0;
 
 	_backGroundBuf = 0;
-	_frontBuf = 0;
 	_backBuf = 0;
 	_scaleBuf = 0;
 
@@ -602,7 +600,6 @@
 
 	// allocate buffers
 	_backGroundBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
-	_frontBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
 
 	if (getGameType() == GType_FF || getGameType() == GType_PP) {
 		_backBuf = (byte *)calloc(_screenWidth * _screenHeight, 1);
@@ -935,7 +932,6 @@
 	free(_textMem);
 
 	free(_backGroundBuf);
-	free(_frontBuf);
 	free(_backBuf);
 	free(_scaleBuf);
 
@@ -1068,7 +1064,6 @@
 	free(_textMem);
 
 	free(_backGroundBuf);
-	free(_frontBuf);
 	free(_backBuf);
 	free(_scaleBuf);
 

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/agos.h	2007-06-21 03:14:20 UTC (rev 27577)
@@ -550,7 +550,6 @@
 	bool _oopsValid;
 
 	byte *_backGroundBuf;
-	byte *_frontBuf;
 	byte *_backBuf;
 	byte *_scaleBuf;
 
@@ -1130,7 +1129,6 @@
 	void restoreWindow(WindowBlock *window);
 	void restoreBlock(uint h, uint w, uint y, uint x);
 
-	byte *getFrontBuf();
 	byte *getBackBuf();
 	byte *getBackGround();
 	byte *getScaleBuf();
@@ -1171,10 +1169,7 @@
 	void dumpSingleBitmap(int file, int image, const byte *offs, int w, int h, byte base);
 	void dumpBitmap(const char *filename, const byte *offs, int w, int h, int flags, const byte *palette, byte base);
 
-	void clearBackFromTop(uint lines);
-	void fillFrontFromBack(uint x, uint y, uint w, uint h);
 	void fillBackGroundFromBack(uint lines);
-	void fillBackFromFront(uint x, uint y, uint w, uint h);
 
 	virtual void doOutput(const byte *src, uint len);
 	void clsCheck(WindowBlock *window);

Modified: scummvm/trunk/engines/agos/animation.cpp
===================================================================
--- scummvm/trunk/engines/agos/animation.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/animation.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -30,6 +30,7 @@
 #include "common/system.h"
 
 #include "graphics/cursorman.h"
+#include "graphics/surface.h"
 
 #include "agos/animation.h"
 #include "agos/intern.h"
@@ -140,7 +141,7 @@
 
 	// Resolution is smaller in Amiga verison so always clear screen
 	if (_width == 384 && _height == 280) {
-		memset(_vm->_frontBuf, 0, _vm->_screenHeight * _vm->_screenWidth);
+		_vm->_system->clearScreen();
 	}
 
 	_ticks = _vm->_system->getMillis();
@@ -155,7 +156,9 @@
 	_vm->o_killAnimate();
 
 	if (_vm->getBitFlag(41)) {
-		memcpy(_vm->_backBuf, _vm->_frontBuf, _frameSize);
+		Graphics::Surface *screen = _vm->_system->lockScreen();
+		memcpy(_vm->_backBuf, (byte *)screen->pixels, _frameSize);
+		_vm->_system->unlockScreen();
 	} else {
 		uint8 palette[1024];
 		memset(palette, 0, sizeof(palette));
@@ -303,8 +306,9 @@
 }
 
 bool MoviePlayer::processFrame() {
-	copyFrameToBuffer(_vm->getFrontBuf(), (_vm->_screenWidth - _width) / 2, (_vm->_screenHeight - _height) / 2, _vm->_screenWidth);
-	_vm->_system->copyRectToScreen(_vm->getFrontBuf(), _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
+	Graphics::Surface *screen = _vm->_system->lockScreen();
+	copyFrameToBuffer((byte *)screen->pixels, (_vm->_screenWidth - _width) / 2, (_vm->_screenHeight - _height) / 2, _vm->_screenWidth);
+	_vm->_system->unlockScreen();
 
 	if ((_bgSoundStream == NULL) || ((int)(_mixer->getSoundElapsedTime(_bgSound) * _framesPerSec) / 1000 < _frameNum + 1) ||
 		_frameSkipped > _framesPerSec) {

Modified: scummvm/trunk/engines/agos/charset.cpp
===================================================================
--- scummvm/trunk/engines/agos/charset.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/charset.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -25,9 +25,13 @@
 
 #include "common/stdafx.h"
 
+#include "common/system.h"
+
 #include "agos/agos.h"
 #include "agos/intern.h"
 
+#include "graphics/surface.h"
+
 namespace AGOS {
 
 void AGOSEngine_Feeble::doOutput(const byte *src, uint len) {
@@ -712,13 +716,15 @@
 	_lockWord |= 0x8000;
 
 	if (window->height != 1) {
+		Graphics::Surface *screen = _system->lockScreen();
+
 		byte *src, *dst;
 		uint16 w, h;
 
 		w = window->width * 8;
 		h = (window->height -1) * 8;
 
-		dst = getFrontBuf() + window->y * _screenWidth + window->x * 8;
+		dst = (byte *)screen->pixels + window->y * _screenWidth + window->x * 8;
 		src = dst + 8 * _screenWidth;
 
 		do {
@@ -726,6 +732,8 @@
 			src += _screenWidth;
 			dst += _screenWidth;
 		} while (--h);
+
+		_system->unlockScreen();
 	} 
 
 	colorBlock(window, window->x * 8, (window->height - 1) * 8 + window->y, window->width * 8, 8);
@@ -2169,14 +2177,16 @@
 
 	_lockWord |= 0x8000;
 
-	dst = getFrontBuf() + y * _dxSurfacePitch + x + window->textColumnOffset;
+	Graphics::Surface *screen = _system->lockScreen();
 
 	if (getGameType() == GType_FF || getGameType() == GType_PP) {
+		dst = getBackGround() + y * _dxSurfacePitch + x + window->textColumnOffset;
 		h = 13;
 		w =  feebleFontSize[chr - 0x20];
 
 		src = feeble_windowFont + (chr - 0x20) * 13;
 	} else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
+		dst = (byte *)screen->pixels + y * _dxSurfacePitch + x + window->textColumnOffset;
 		h = 8;
 		w = 6;
 
@@ -2212,6 +2222,7 @@
 			error("windowDrawChar: Unknown language %d\n", _language);
 		}
 	} else {
+		dst = (byte *)screen->pixels + y * _dxSurfacePitch + x + window->textColumnOffset;
 		h = 8;
 		w = 6;
 
@@ -2259,6 +2270,8 @@
 		dst += _dxSurfacePitch;
 	} while (--h);
 
+	_system->unlockScreen();
+
 	_lockWord &= ~0x8000;
 }
 

Modified: scummvm/trunk/engines/agos/draw.cpp
===================================================================
--- scummvm/trunk/engines/agos/draw.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/draw.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -27,19 +27,13 @@
 
 #include "common/system.h"
 
+#include "graphics/surface.h"
+
 #include "agos/agos.h"
 #include "agos/intern.h"
 
 namespace AGOS {
 
-byte *AGOSEngine::getFrontBuf() {
-	if (getGameType() != GType_PP && getGameType() != GType_FF)
-		_updateScreen = true;
-
-	_dxSurfacePitch = _screenWidth;
-	return _frontBuf;
-}
-
 byte *AGOSEngine::getBackBuf() {
 	_dxSurfacePitch = _screenWidth;
 	return _useBackGround ? _backGroundBuf : _backBuf;
@@ -547,10 +541,13 @@
 
 	uint curHeight = (getGameType() == GType_SIMON2) ? _boxStarHeight : 134;
 
+
 	for (int i = 0; i < 5; i++) {
 		ha = _hitAreas;
 		count = ARRAYSIZE(_hitAreas);
 
+		Graphics::Surface *screen = _system->lockScreen();
+
 		do {
 			if (ha->id != 0 && ha->flags & kBFBoxInUse && !(ha->flags & kBFBoxDead)) {
 
@@ -578,7 +575,7 @@
 				if (x_ >= 311)
 					continue;
 
-				dst = getFrontBuf();
+				dst = (byte *)screen->pixels;
 
 				dst += (((_dxSurfacePitch / 4) * y_) * 4) + x_;
 
@@ -617,6 +614,8 @@
 			}
 		} while (ha++, --count);
 
+		_system->unlockScreen();
+
 		delay(100);
 
 		setMoveRect(0, 0, 320, curHeight);
@@ -634,11 +633,7 @@
 	const byte *src;
 	uint x, y;
 
-	if (getGameType() == GType_SIMON2) {
-		dst = getBackGround();
-	} else {
-		dst = getFrontBuf();
-	}
+	dst = getBackGround();
 
 	if (_scrollXMax == 0) {
 		uint screenSize = 8 * _screenWidth;
@@ -661,8 +656,7 @@
 		_scrollY += _scrollFlag;
 		vcWriteVar(250, _scrollY);
 
-		memcpy(_backBuf, _frontBuf, _screenWidth * _screenHeight);
-		memcpy(_backGroundBuf, _backBuf, _screenHeight * _scrollWidth);
+		memcpy(_backBuf, _backGroundBuf, _screenHeight * _scrollWidth);
 	} else {
 		if (_scrollFlag < 0) {
 			memmove(dst + 8, dst, _screenWidth * _scrollHeight - 8);
@@ -690,8 +684,7 @@
 		if (getGameType() == GType_SIMON2) {
 			memcpy(_window4BackScn, _backGroundBuf, _scrollHeight * _screenWidth);
 		} else {
-			memcpy(_backBuf, _frontBuf, _screenWidth * _screenHeight);
-			memcpy(_backGroundBuf, _backBuf, _scrollHeight * _screenWidth);
+			memcpy(_backBuf, _backGroundBuf, _scrollHeight * _screenWidth);
 		}
 
 		setMoveRect(0, 0, 320, _scrollHeight);
@@ -716,45 +709,15 @@
 	}
 }
 
-void AGOSEngine::clearBackFromTop(uint lines) {
-	memset(_backBuf, 0, lines * _screenWidth);
-}
-
 void AGOSEngine::clearSurfaces(uint num_lines) {
+	Graphics::Surface *screen = _system->lockScreen();
+
+	memset((byte *)screen->pixels, 0, num_lines * _screenWidth);
 	memset(_backBuf, 0, num_lines * _screenWidth);
 
-	_system->copyRectToScreen(_backBuf, _screenWidth, 0, 0, _screenWidth, num_lines);
-
-	if (_useBackGround) {
-		memset(_frontBuf, 0, num_lines * _screenWidth);
-		memset(_backGroundBuf, 0, num_lines * _screenWidth);
-	}
+	_system->unlockScreen();
 }
 
-void AGOSEngine::fillFrontFromBack(uint x, uint y, uint w, uint h) {
-	uint offs = x + y * _screenWidth;
-	byte *s = _backBuf + offs;
-	byte *d = _frontBuf + offs;
-
-	do {
-		memcpy(d, s, w);
-		d += _screenWidth;
-		s += _screenWidth;
-	} while (--h);
-}
-
-void AGOSEngine::fillBackFromFront(uint x, uint y, uint w, uint h) {
-	uint offs = x + y * _screenWidth;
-	byte *s = _frontBuf + offs;
-	byte *d = _backBuf + offs;
-
-	do {
-		memcpy(d, s, w);
-		d += _screenWidth;
-		s += _screenWidth;
-	} while (--h);
-}
-
 void AGOSEngine::fillBackGroundFromBack(uint lines) {
 	memcpy(_backGroundBuf, _backBuf, lines * _screenWidth);
 }
@@ -782,18 +745,18 @@
 		}
 	}
 
+	Graphics::Surface *screen = _system->lockScreen();
 	if (getGameType() == GType_PP || getGameType() == GType_FF) {
-		_system->copyRectToScreen(getBackBuf(), _screenWidth, 0, 0, _screenWidth, _screenHeight);
-		_system->updateScreen();
+		memcpy((byte *)screen->pixels, getBackBuf(), _screenWidth * _screenHeight);
 
 		if (getGameId() != GID_DIMP)
-			memcpy(getBackBuf(), getFrontBuf(), _screenWidth * _screenHeight);
+			memcpy(getBackBuf(), getBackGround(), _screenWidth * _screenHeight);
 	} else {
 		if (_window4Flag == 2) {
 			_window4Flag = 0;
 
 			uint16 srcWidth, width, height;
-			byte *dst = getFrontBuf();
+			byte *dst = (byte *)screen->pixels;
 
 			const byte *src = _window4BackScn;
 			if (_window3Flag == 1) {
@@ -827,18 +790,17 @@
 			_window6Flag = 0;
 
 			byte *src = _window6BackScn;
-			byte *dst = getFrontBuf() + 16320;
+			byte *dst = (byte *)screen->pixels + 16320;
 			for (int i = 0; i < 80; i++) {
 				memcpy(dst, src, 48);
 				dst += _screenWidth;
 				src += 48;
 			}
 		}
-
-		_system->copyRectToScreen(getFrontBuf(), _screenWidth, 0, 0, _screenWidth, _screenHeight);
-		_system->updateScreen();
 	}
 
+	_system->unlockScreen();
+
 	if (getGameType() == GType_FF && _scrollFlag) {
 		scrollScreen();
 	}

Modified: scummvm/trunk/engines/agos/event.cpp
===================================================================
--- scummvm/trunk/engines/agos/event.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/event.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -34,6 +34,8 @@
 
 #include "gui/about.h"
 
+#include "graphics/surface.h"
+
 #include "sound/audiocd.h"
 
 namespace AGOS {
@@ -366,13 +368,17 @@
 
 void AGOSEngine::drawStuff(const byte *src, uint xoffs) {
 	const uint8 y = (getPlatform() == Common::kPlatformAtariST) ? 132 : 135;
-	byte *dst = getFrontBuf() + y * _screenWidth + xoffs;
 
+	Graphics::Surface *screen = _system->lockScreen();
+	byte *dst = (byte *)screen->pixels + y * _screenWidth + xoffs;
+
 	for (uint h = 0; h < 6; h++) {
 		memcpy(dst, src, 4);
 		src += 4;
 		dst += _screenWidth;
 	}
+
+	_system->unlockScreen();
 }
 
 void AGOSEngine::imageEvent2(VgaTimerEntry * vte, uint dx) {
@@ -587,11 +593,6 @@
 		animateSprites();
 	} 
 
-	if (_copyPartialMode == 2) {
-		fillFrontFromBack(0, 0, _screenWidth, _screenHeight);
-		_copyPartialMode = 0;
-	}
-
 	if (_displayScreen) {
 		if (getGameType() == GType_FF) {
 			if (!getBitFlag(78)) {
@@ -627,13 +628,6 @@
 			processVgaEvents();
 	} 
 
-	if (_updateScreen) {
-		_system->copyRectToScreen(getFrontBuf(), _screenWidth, 0, 0, _screenWidth, _screenHeight);
-		_system->updateScreen();
-
-		_updateScreen = false;
-	}
-
 	if (_displayScreen) {
 		displayScreen();
 		_displayScreen = false;

Modified: scummvm/trunk/engines/agos/gfx.cpp
===================================================================
--- scummvm/trunk/engines/agos/gfx.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/gfx.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -25,6 +25,10 @@
 
 #include "common/stdafx.h"
 
+#include "common/system.h"
+
+#include "graphics/surface.h"
+
 #include "agos/agos.h"
 #include "agos/intern.h"
 #include "agos/vga.h"
@@ -289,6 +293,9 @@
 }
 
 void AGOSEngine_Feeble::drawImage(VC10_state *state) {
+	state->surf_addr = getBackBuf();
+	state->surf_pitch = _dxSurfacePitch;
+
 	if (state->flags & kDFCompressed) {
 		if (state->flags & kDFScaled) {
 			state->surf_addr = getScaleBuf();
@@ -357,8 +364,9 @@
 				scaleClip(_scaleHeight, _scaleWidth, _scaleY, _scaleX, _scaleY + _scrollY);
 			}
 		} else {
-			if (!drawImage_clip(state))
+			if (!drawImage_clip(state)) {
 				return;
+			}
 
 			state->surf_addr += state->x + state->y * state->surf_pitch;
 
@@ -373,14 +381,18 @@
 
 			if (state->flags & kDFMasked) {
 				if (getGameType() == GType_FF && !getBitFlag(81)) {
-					if (state->x  > _feebleRect.right)
+					if (state->x  > _feebleRect.right) {
 						return;
-					if (state->y > _feebleRect.bottom)
+					}
+					if (state->y > _feebleRect.bottom) {
 						return;
-					if (state->x + state->width < _feebleRect.left)
+					}
+					if (state->x + state->width < _feebleRect.left) {
 						return;
-					if (state->y + state->height < _feebleRect.top)
+					}
+					if (state->y + state->height < _feebleRect.top) {
 						return;
+					}
 				}
 
 				dstPtr = state->surf_addr;
@@ -423,8 +435,9 @@
 			}
 		}
 	} else {
-		if (!drawImage_clip(state))
+		if (!drawImage_clip(state)) {
 			return;
+		}
 
 		state->surf_addr += state->x + state->y * state->surf_pitch;
 
@@ -448,7 +461,7 @@
 			dst += _screenWidth;
 			src += state->width;
 		} while (--state->draw_height);
-	} 
+	}
 }
 
 void AGOSEngine_Simon1::drawMaskedImage(VC10_state *state) {
@@ -629,6 +642,8 @@
 	if (!drawImage_clip(state))
 		return;
 
+	Graphics::Surface *screen = _system->lockScreen();
+
 	if (getFeatures() & GF_32COLOR)
 		state->palette = 0xC0;
 
@@ -663,7 +678,7 @@
 
 			_window4Flag = 1;
 		} else {
-			state->surf_addr = getFrontBuf();
+			state->surf_addr = (byte *)screen->pixels;
 			state->surf_pitch = _screenWidth;
 
 			xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -697,7 +712,7 @@
 			state->surf2_addr = getBackGround();
 			state->surf2_pitch = _screenWidth;
 
-			state->surf_addr = getFrontBuf();
+			state->surf_addr = (byte *)screen->pixels;
 			state->surf_pitch = _screenWidth;
 
 			xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -717,6 +732,8 @@
 	} else {
 		drawVertImage(state);
 	}
+
+	 _system->unlockScreen();
 }
 
 void AGOSEngine::drawBackGroundImage(VC10_state *state) {
@@ -812,6 +829,8 @@
 	if (!drawImage_clip(state))
 		return;
 
+	Graphics::Surface *screen = _system->lockScreen();
+
 	uint16 xoffs, yoffs;
 	if (getGameType() == GType_WW) {
 		if (_windowNum == 4 || (_windowNum >= 10 && _windowNum <= 27)) {
@@ -827,7 +846,7 @@
 
 			_window4Flag = 1;
 		} else {
-			state->surf_addr = getFrontBuf();
+			state->surf_addr = (byte *)screen->pixels;
 			state->surf_pitch = _screenWidth;
 
 			xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -847,7 +866,7 @@
 
 			_window4Flag = 1;
 		} else {
-			state->surf_addr = getFrontBuf();
+			state->surf_addr = (byte *)screen->pixels;
 			state->surf_pitch = _screenWidth;
 
 			xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -861,7 +880,7 @@
 			xoffs = state->x * 8;
 			yoffs = state->y;
 		} else if (_windowNum == 2 || _windowNum == 3) {
-			state->surf_addr = getFrontBuf();
+			state->surf_addr = (byte *)screen->pixels;
 			state->surf_pitch = _screenWidth;
 
 			xoffs = (vlut[0] * 2 + state->x) * 8;
@@ -894,6 +913,8 @@
 	} else {
 		drawVertImage(state);
 	}
+
+	 _system->unlockScreen();
 }
 
 void AGOSEngine::horizontalScroll(VC10_state *state) {
@@ -1280,7 +1301,6 @@
 	setImage(vga_res_id);
 
 	if (getGameType() == GType_FF || getGameType() == GType_PP) {
-		fillFrontFromBack(0, 0, _screenWidth, _screenHeight);
 		fillBackGroundFromBack(_screenHeight);
 		_syncFlag2 = 1;
 	} else {
@@ -1298,6 +1318,7 @@
 		uint width = _videoWindows[updateWindow * 4 + 2] * 16;
 		uint height = _videoWindows[updateWindow * 4 + 3];
 
+		Graphics::Surface *screen = _system->lockScreen();
 		byte *dst = getBackGround() + xoffs + yoffs * _screenWidth;
 		byte *src;
 		uint srcWidth;
@@ -1311,9 +1332,10 @@
 				src = _window4BackScn;
 				srcWidth = _videoWindows[18] * 16;
 			} else if (updateWindow == 3 || updateWindow == 9) {
-				src = getFrontBuf() + xoffs + yoffs * _screenWidth;
+				src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
 				srcWidth = _screenWidth;
 			} else {
+				_system->unlockScreen();
 				_lockWord &= ~0x20;
 				return;
 			}
@@ -1325,9 +1347,10 @@
 				src = _window4BackScn + xoffs + yoffs * 320;
 				srcWidth = _videoWindows[18] * 16;
 			} else if (updateWindow == 0) {
-				src = getFrontBuf() + xoffs + yoffs * _screenWidth;
+				src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
 				srcWidth = _screenWidth;
 			} else {
+				_system->unlockScreen();
 				_lockWord &= ~0x20;
 				return;
 			}
@@ -1336,9 +1359,10 @@
 				src = _window4BackScn;
 				srcWidth = _videoWindows[18] * 16;
 			} else if (updateWindow == 3 || updateWindow == 9) {
-				src = getFrontBuf() + xoffs + yoffs * _screenWidth;
+				src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
 				srcWidth = _screenWidth;
 			} else {
+				_system->unlockScreen();
 				_lockWord &= ~0x20;
 				return;
 			}
@@ -1347,9 +1371,10 @@
 				src = _window4BackScn;
 				srcWidth = _videoWindows[18] * 16;
 			} else if (updateWindow == 3) {
-				src = getFrontBuf() + xoffs + yoffs * _screenWidth;
+				src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
 				srcWidth = _screenWidth;
 			} else {
+				_system->unlockScreen();
 				_lockWord &= ~0x20;
 				return;
 			}
@@ -1359,7 +1384,7 @@
 				src = _window6BackScn;
 				srcWidth = 48;
 			} else if (updateWindow == 2 || updateWindow == 3) {
-				src = getFrontBuf() + xoffs + yoffs * _screenWidth;
+				src = (byte *)screen->pixels + xoffs + yoffs * _screenWidth;
 				srcWidth = _screenWidth;
 			} else {
 				src = _window4BackScn;
@@ -1376,7 +1401,7 @@
 		}
 
 		if (getGameType() == GType_ELVIRA1 && updateWindow == 3 && _bottomPalette) {
-			dst = getFrontBuf() + 133 * _screenWidth;
+			dst = (byte *)screen->pixels + 133 * _screenWidth;
 			int size = 67 * _screenWidth;
 
 			while (size--) {
@@ -1384,6 +1409,8 @@
 				dst++;
 			}
 		}
+
+		_system->unlockScreen();
 	}
 
 	_lockWord &= ~0x20;

Modified: scummvm/trunk/engines/agos/icons.cpp
===================================================================
--- scummvm/trunk/engines/agos/icons.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/icons.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -25,8 +25,12 @@
 
 #include "common/stdafx.h"
 
+#include "common/system.h"
+
 #include "common/file.h"
 
+#include "graphics/surface.h"
+
 #include "agos/agos.h"
 
 namespace AGOS {
@@ -193,8 +197,10 @@
 	byte *src;
 
 	_lockWord |= 0x8000;
-	dst = getFrontBuf();
 
+	Graphics::Surface *screen = _system->lockScreen();
+	dst = (byte *)screen->pixels;
+
 	dst += 110;
 	dst += x;
 	dst += (y + window->y) * _dxSurfacePitch;
@@ -207,6 +213,8 @@
 	src += READ_LE_UINT16(&((uint16 *)src)[icon * 2 + 1]);
 	decompressIcon(dst, src, 20, 10, 208, _dxSurfacePitch);
 
+	_system->unlockScreen();
+
 	_lockWord &= ~0x8000;
 }
 
@@ -215,8 +223,10 @@
 	byte *src;
 
 	_lockWord |= 0x8000;
-	dst = getFrontBuf();
 
+	Graphics::Surface *screen = _system->lockScreen();
+	dst = (byte *)screen->pixels;
+
 	dst += (x + window->x) * 8;
 	dst += (y * 25 + window->y) * _dxSurfacePitch;
 
@@ -231,6 +241,8 @@
 		decompressIcon(dst, src, 24, 12, 224, _dxSurfacePitch);
 	}
 
+	_system->unlockScreen();
+
 	_lockWord &= ~0x8000;
 }
 
@@ -239,8 +251,10 @@
 	byte *src;
 
 	_lockWord |= 0x8000;
-	dst = getFrontBuf();
 
+	Graphics::Surface *screen = _system->lockScreen();
+	dst = (byte *)screen->pixels;
+
 	dst += (x + window->x) * 8;
 	dst += (y * 20 + window->y) * _dxSurfacePitch;
 
@@ -255,6 +269,8 @@
 		decompressIcon(dst, src, 24, 10, color, _dxSurfacePitch);
 	}
 
+	_system->unlockScreen();
+
 	_lockWord &= ~0x8000;
 }
 
@@ -263,8 +279,10 @@
 	byte *src;
 
 	_lockWord |= 0x8000;
-	dst = getFrontBuf();
 
+	Graphics::Surface *screen = _system->lockScreen();
+	dst = (byte *)screen->pixels;
+
 	dst += (x + window->x) * 8;
 	dst += (y * 8 + window->y) * _dxSurfacePitch;
 
@@ -279,6 +297,8 @@
 		decompressIcon(dst, src, 24, 12, color, _dxSurfacePitch);
 	}
 
+	_system->unlockScreen();
+
 	_lockWord &= ~0x8000;
 }
 
@@ -287,8 +307,10 @@
 	byte *src;
 
 	_lockWord |= 0x8000;
-	dst = getFrontBuf();
 
+	Graphics::Surface *screen = _system->lockScreen();
+	dst = (byte *)screen->pixels;
+
 	dst += (x + window->x) * 8;
 	dst += (y * 8 + window->y) * _dxSurfacePitch;
 
@@ -302,6 +324,8 @@
 		decompressIconPlanar(dst, src, 24, 12, 16, _dxSurfacePitch, false);
 	}
 
+	_system->unlockScreen();
+
 	_lockWord &= ~0x8000;
 }
 
@@ -882,7 +906,8 @@
 		src = _arrowImage;
 	}
 
-	byte *dst = getFrontBuf() + y * _screenWidth + x * 8;
+	Graphics::Surface *screen = _system->lockScreen();
+	byte *dst = (byte *)screen->pixels + y * _screenWidth + x * 8;
 
 	for (h = 0; h < 19; h++) {
 		for (w = 0; w < 16; w++) {
@@ -892,6 +917,8 @@
 		src += dir;
 		dst+= _screenWidth;
 	}
+
+	_system->unlockScreen();
 }
 
 void AGOSEngine::removeArrows(WindowBlock *window, uint num) {

Modified: scummvm/trunk/engines/agos/menus.cpp
===================================================================
--- scummvm/trunk/engines/agos/menus.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/menus.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -26,7 +26,10 @@
 #include "common/stdafx.h"
 
 #include "common/file.h"
+#include "common/system.h"
 
+#include "graphics/surface.h"
+
 #include "agos/agos.h"
 #include "agos/intern.h"
 
@@ -145,7 +148,8 @@
 
 	mouseOff();
 
-	src = getFrontBuf() + 2832;
+	Graphics::Surface *screen = _system->lockScreen();
+	src = (byte *)screen->pixels + 2832;
 	w = 48;
 	h = 82;
 
@@ -160,6 +164,8 @@
 	for (i = 120; i != 130; i++)
 		disableBox(i);
 
+	_system->unlockScreen();
+
 	mouseOn();
 }
 
@@ -170,7 +176,8 @@
 
 	mouseOff();
 
-	src = getFrontBuf() + ha->y * _dxSurfacePitch + ha->x;
+	Graphics::Surface *screen = _system->lockScreen();
+	src = (byte *)screen->pixels + ha->y * _dxSurfacePitch + ha->x;
 	w = ha->width;
 	h = ha->height;
 
@@ -182,6 +189,8 @@
 		src += _dxSurfacePitch;
 	} while (--h);
 
+	_system->unlockScreen();
+
 	mouseOn();
 }
 

Modified: scummvm/trunk/engines/agos/oracle.cpp
===================================================================
--- scummvm/trunk/engines/agos/oracle.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/oracle.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -26,7 +26,10 @@
 #include "common/stdafx.h"
 
 #include "common/savefile.h"
+#include "common/system.h"
 
+#include "graphics/surface.h"
+
 #include "agos/agos.h"
 #include "agos/intern.h"
 #include "agos/vga.h"
@@ -247,8 +250,8 @@
 	byte *src, *dst;
 	uint16 w, h;
 
-	dst = getFrontBuf() + 103 * _screenWidth + 136;
-	src = getFrontBuf() + 106 * _screenWidth + 136;
+	dst = getBackGround() + 103 * _screenWidth + 136;
+	src = getBackGround() + 106 * _screenWidth + 136;
 
 	for (h = 0; h < 21; h++) {
 		for (w = 0; w < 360; w++) {
@@ -276,8 +279,8 @@
 	byte *src, *dst;
 	uint16 w, h;
 
-	src = getFrontBuf() + 203 * _screenWidth + 136;
-	dst = getFrontBuf() + 206 * _screenWidth + 136;
+	src = getBackGround() + 203 * _screenWidth + 136;
+	dst = getBackGround() + 206 * _screenWidth + 136;
 
 	for (h = 0; h < 77; h++) {
 		memcpy(dst, src, 360);
@@ -507,7 +510,7 @@
 	x = window->x + window->textColumn;
 	y = window->y + window->textRow;
 
-	dst = getFrontBuf() + _dxSurfacePitch * y + x;
+	dst = getBackGround() + _dxSurfacePitch * y + x;
 
 	for (h = 0; h < 13; h++) {
 		for (w = 0; w < 8; w++) {

Modified: scummvm/trunk/engines/agos/verb.cpp
===================================================================
--- scummvm/trunk/engines/agos/verb.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/verb.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -26,6 +26,10 @@
 // Verb and hitarea handling
 #include "common/stdafx.h"
 
+#include "common/system.h"
+
+#include "graphics/surface.h"
+
 #include "agos/agos.h"
 #include "agos/intern.h"
 
@@ -832,8 +836,10 @@
 	int w, h, i;
 
 	_lockWord |= 0x8000;
-	src = getFrontBuf() + ha->y * _dxSurfacePitch + ha->x;
 
+	Graphics::Surface *screen = _system->lockScreen();
+	src = (byte *)screen->pixels + ha->y * _dxSurfacePitch + ha->x;
+
 	// WORKAROUND: Hitareas for saved game names aren't adjusted for scrolling locations
 	if (getGameType() == GType_SIMON2 && ha->id >= 208 && ha->id <= 213) {
 		src -= _scrollX * 8;
@@ -875,6 +881,8 @@
 		src += _dxSurfacePitch;
 	} while (--h);
 
+	_system->unlockScreen();
+
 	_lockWord &= ~0x8000;
 }
 

Modified: scummvm/trunk/engines/agos/vga.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/vga.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -32,6 +32,8 @@
 
 #include "common/system.h"
 
+#include "graphics/surface.h"
+
 namespace AGOS {
 
 // Opcode tables
@@ -698,12 +700,6 @@
 		}
 	}
 
-	state.surf2_addr = getFrontBuf();
-	state.surf2_pitch = _dxSurfacePitch;
-
-	state.surf_addr = getBackBuf();
-	state.surf_pitch = _dxSurfacePitch;
-
 	drawImage(&state);
 }
 
@@ -1170,7 +1166,9 @@
 		_window4Flag = 1;
 	} else {
 		if (getGameType() == GType_ELVIRA1 && num == 3) {
-			memset(getFrontBuf(), color, _screenWidth * _screenHeight);
+			Graphics::Surface *screen = _system->lockScreen();
+			memset((byte *)screen->pixels, color, _screenWidth * _screenHeight);
+			 _system->unlockScreen();
 		} else if (num == 4) {
 			const uint16 *vlut = &_videoWindows[num * 4];
 			uint xoffs = (vlut[0] - _videoWindows[16]) * 16;
@@ -1219,7 +1217,7 @@
 	uint16 windowNum = vcReadNextWord();
 
 	if (getGameType() == GType_FF || getGameType() == GType_PP) {
-		_copyPartialMode = 2;
+		memcpy(_backGroundBuf, _backBuf, _screenHeight * _screenWidth);
 	} else {
 		setWindowImage(windowNum, vga_res);
 	}

Modified: scummvm/trunk/engines/agos/vga_e2.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga_e2.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/vga_e2.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -31,6 +31,8 @@
 
 #include "common/system.h"
 
+#include "graphics/surface.h"
+
 namespace AGOS {
 
 void AGOSEngine_Elvira2::setupVideoOpcodes(VgaOpcodeProc *op) {
@@ -85,7 +87,10 @@
 		}
 	} else {
 		const uint16 *vlut = &_videoWindows[num * 4];
-		uint16 *dst = (uint16 *)getFrontBuf() + vlut[0] * 8 + vlut[1] * _dxSurfacePitch / 2;
+
+		Graphics::Surface *screen = _system->lockScreen();
+		uint16 *dst = (uint16 *)screen->pixels + vlut[0] * 8 + vlut[1] * _dxSurfacePitch / 2;
+
 		uint width = vlut[2] * 16 / 2;
 		uint height = vlut[3];
 
@@ -101,6 +106,8 @@
 			}
 			dst += _dxSurfacePitch / 2;
 		}
+
+		_system->unlockScreen();
 	}
 }
 
@@ -211,10 +218,13 @@
 
 	int16 xoffs = _videoWindows[num * 4 + 0] * 16;
 	int16 yoffs = _videoWindows[num * 4 + 1];
-	byte *dstPtr = getFrontBuf() + xoffs + yoffs * _screenWidth;
+	int16 offs = xoffs + yoffs * _screenWidth;
 
 	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;
@@ -253,15 +263,15 @@
 		*dst &= color;
 		*dst |= *src & 0xF;
 
+		 _system->unlockScreen();
+
 		dissolveCount--;
 		if (!dissolveCount) {
 			if (count >= dissolveCheck)
 				dissolveDelay++;
 
 			dissolveCount = dissolveDelay;
-			_system->copyRectToScreen(getFrontBuf(), _screenWidth, 0, 0, _screenWidth, _screenHeight);
-			_system->updateScreen();
-			delay(0);
+			delay(1);
 		}
 	}
 }
@@ -281,11 +291,14 @@
 
 	int16 xoffs = _videoWindows[num * 4 + 0] * 16;
 	int16 yoffs = _videoWindows[num * 4 + 1];
-	byte *dstPtr = getFrontBuf() + xoffs + yoffs * _screenWidth;
-	color |= dstPtr[0] & 0xF0;
+	int16 offs = xoffs + yoffs * _screenWidth;
 
 	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;
@@ -304,15 +317,15 @@
 		dst += xoffs;
 		*dst = color;
 
+		 _system->unlockScreen();
+
 		dissolveCount--;
 		if (!dissolveCount) {
 			if (count >= dissolveCheck)
 				dissolveDelay++;
 
 			dissolveCount = dissolveDelay;
-			_system->copyRectToScreen(getFrontBuf(), _screenWidth, 0, 0, _screenWidth, _screenHeight);
-			_system->updateScreen();
-			delay(0);
+			delay(1);
 		}
 	}
 }
@@ -339,11 +352,15 @@
 }
 
 void AGOSEngine::vc56_fullScreen() {
+	Graphics::Surface *screen = _system->lockScreen();
+
+	byte *dst = (byte *)screen->pixels;
 	byte *src = _curVgaFile2 + 32;
-	byte *dst = getFrontBuf();
 
 	memcpy(dst, src + 768, _screenHeight * _screenWidth);
 
+	 _system->unlockScreen();
+
 	//fullFade();
 
 	uint8 palette[1024];

Modified: scummvm/trunk/engines/agos/vga_ww.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga_ww.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/vga_ww.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -31,6 +31,8 @@
 
 #include "common/system.h"
 
+#include "graphics/surface.h"
+
 namespace AGOS {
 
 void AGOSEngine_Waxworks::setupVideoOpcodes(VgaOpcodeProc *op) {
@@ -139,13 +141,15 @@
 	byte *src, *dst, *dstPtr;
 	uint h, tmp;
 
+	Graphics::Surface *screen = _system->lockScreen();
+
 	if (a == 6) {
 		src = _curVgaFile2 + 800;
-		dstPtr = getFrontBuf();
+		dstPtr = (byte *)screen->pixels;
 		memcpy(dstPtr, src, 64000);
 		tmp = 4 - 1;
 	} else {
-		dstPtr = getFrontBuf();
+		dstPtr = (byte *)screen->pixels;
 		tmp = a - 1;
 	}
 
@@ -164,8 +168,10 @@
 			dst += _screenWidth;
 		}
 
-		if (a != 6)
+		if (a != 6) {
+			_system->unlockScreen();
 			return;
+		}
 
 		src = _curVgaFile2 + 9984 * 16 + 15344;
 	}
@@ -177,6 +183,8 @@
 		dst += _screenWidth;
 	}
 
+	_system->unlockScreen();
+
 	if (a == 6) {
 		//fullFade();
 		src = _curVgaFile2 + 32;
@@ -229,10 +237,10 @@
 		if (getGameType() == GType_FF || getGameType() == GType_PP) {
 			clearSurfaces(_screenHeight);
 		} else if (getGameType() == GType_WW) {
-			memset(getFrontBuf(), 0, _screenWidth * _screenHeight);
+			_system->clearScreen();
 		} else {
 			if (_windowNum != 4) {
-				memset(getFrontBuf(), 0, _screenWidth * _screenHeight);
+				_system->clearScreen();
 			}
 		}
 	}

Modified: scummvm/trunk/engines/agos/window.cpp
===================================================================
--- scummvm/trunk/engines/agos/window.cpp	2007-06-21 02:43:15 UTC (rev 27576)
+++ scummvm/trunk/engines/agos/window.cpp	2007-06-21 03:14:20 UTC (rev 27577)
@@ -25,6 +25,10 @@
 
 #include "common/stdafx.h"
 
+#include "common/system.h"
+
+#include "graphics/surface.h"
+
 #include "agos/agos.h"
 #include "agos/intern.h"
 
@@ -119,7 +123,7 @@
 
 	_lockWord |= 0x8000;
 
-	dst = getFrontBuf() + _dxSurfacePitch * window->y + window->x;
+	dst = getBackGround() + _dxSurfacePitch * window->y + window->x;
 
 	for (h = 0; h < window->height; h++) {
 		for (w = 0; w < window->width; w++) {
@@ -161,7 +165,8 @@
 void AGOSEngine::colorBlock(WindowBlock *window, uint16 x, uint16 y, uint16 w, uint16 h) {
 	_lockWord |= 0x8000;
 
-	byte *dst = getFrontBuf() + y * _screenWidth + x;
+	Graphics::Surface *screen = _system->lockScreen();
+	byte *dst = (byte *)screen->pixels + y * _screenWidth + x;
 
 	uint8 color = window->fill_color;
 	if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW)
@@ -172,6 +177,8 @@
 		dst += _screenWidth;
 	} while (--h);
 
+	_system->unlockScreen();
+
 	_lockWord &= ~0x8000;
 }
 
@@ -220,7 +227,8 @@
 	byte *dst, *src;
 	uint i;
 
-	dst = getFrontBuf();
+	Graphics::Surface *screen = _system->lockScreen();
+	dst = (byte *)screen->pixels;
 	src = getBackGround();
 
 	dst += y * _dxSurfacePitch;
@@ -237,6 +245,8 @@
 		dst += _dxSurfacePitch;
 		src += _dxSurfacePitch;
 	}
+
+	_system->unlockScreen();
 }
 
 void AGOSEngine::setTextColor(uint color) {


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