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

Kirben at users.sourceforge.net Kirben at users.sourceforge.net
Sat Jun 9 07:30:22 CEST 2007


Revision: 27227
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27227&view=rev
Author:   Kirben
Date:     2007-06-08 22:30:20 -0700 (Fri, 08 Jun 2007)

Log Message:
-----------
Add dirtyClips code for Simon the Sorcerer 1/2.

Modified Paths:
--------------
    scummvm/trunk/engines/agos/agos.cpp
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/draw.cpp
    scummvm/trunk/engines/agos/vga.cpp

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2007-06-09 01:33:58 UTC (rev 27226)
+++ scummvm/trunk/engines/agos/agos.cpp	2007-06-09 05:30:20 UTC (rev 27227)
@@ -336,6 +336,7 @@
 	_showPreposition = 0;
 	_showMessageFlag = 0;
 
+	_newDirtyClip = false;
 	_copyScnFlag = 0;
 	_vgaSpriteChanged = 0;
 

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2007-06-09 01:33:58 UTC (rev 27226)
+++ scummvm/trunk/engines/agos/agos.h	2007-06-09 05:30:20 UTC (rev 27227)
@@ -90,7 +90,8 @@
 	int16 x, y;
 	uint16 flags;
 	uint16 priority;
-	uint16 windowNum, zoneNum;
+	uint16 windowNum;
+	uint16 zoneNum;
 	VgaSprite() { memset(this, 0, sizeof(*this)); }
 };
 
@@ -117,8 +118,9 @@
 	int16 y;
 	uint16 width;
 	uint16 height;
-	uint16 window;
+	uint16 windowNum;
 	uint16 id;
+	uint16 zoneNum;
 	AnimTable() { memset(this, 0, sizeof(*this)); }
 };
 
@@ -414,6 +416,7 @@
 	bool _showPreposition;
 	bool _showMessageFlag;
 
+	bool _newDirtyClip;
 	uint _copyScnFlag, _vgaSpriteChanged;
 
 	byte *_block, *_blockEnd;
@@ -478,7 +481,7 @@
 
 	HitArea _hitAreas[250];
 
-	AnimTable _screenAnim1[60];
+	AnimTable _screenAnim1[90];
 	VgaPointersEntry _vgaBufferPointers[450];
 	VgaSprite _vgaSprites[200];
 	VgaSleepStruct _waitEndTable[60];
@@ -1151,6 +1154,7 @@
 	virtual void animateSprites();
 
 	void dirtyClips();
+	void dirtyClipCheck(int16 x, int16 y, int16 w, int16 h);
 	void dirtyBackGround();
 	void restoreBackGround();
 	void saveBackGround(VgaSprite *vsp);

Modified: scummvm/trunk/engines/agos/draw.cpp
===================================================================
--- scummvm/trunk/engines/agos/draw.cpp	2007-06-09 01:33:58 UTC (rev 27226)
+++ scummvm/trunk/engines/agos/draw.cpp	2007-06-09 05:30:20 UTC (rev 27227)
@@ -209,7 +209,12 @@
 	restoreBackGround();
 
 	vsp = _vgaSprites;
-	while (vsp->id) {
+	for (; vsp->id !=0; vsp++) {
+		if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) &&
+			!(vsp->windowNum & 0x8000)) {
+			continue;
+		}
+
 		vsp->windowNum &= 0x7FFF;
 
 		vpe = &_vgaBufferPointers[vsp->zoneNum];
@@ -223,7 +228,6 @@
 		saveBackGround(vsp);
 
 		drawImage_init(vsp->image, vsp->palette, vsp->x, vsp->y, vsp->flags);
-		vsp++;
 	}
 
 	if (getGameType() == GType_ELVIRA1 && _variableArray[293]) {
@@ -304,9 +308,123 @@
 }
 
 void AGOSEngine::dirtyClips() {
-	// TODO
+	int16 x, y, w, h;
+restart:
+	_newDirtyClip = 0;
+
+	VgaSprite *vsp = _vgaSprites;
+	while (vsp->id != 0) {
+		if (vsp->windowNum & 0x8000) {
+			x = vsp->x;
+			y = vsp->y;
+			w = 1;
+			h = 1;
+
+			if (vsp->image != 0) {
+				const byte *ptr = _curVgaFile2 + vsp->image * 8;
+				w = READ_BE_UINT16(ptr + 6) / 8;
+				h = ptr[5];
+			}
+
+			dirtyClipCheck(x, y, w, h);
+		}
+		vsp++;
+	}
+
+	AnimTable *animTable = _screenAnim1;
+	while (animTable->srcPtr != 0) {
+		if (animTable->windowNum & 0x8000) {
+			x = animTable->x + _scrollX;
+			y = animTable->y;
+			w = animTable->width * 2;
+			h = animTable->height;
+
+			dirtyClipCheck(x, y, w, h);
+		}
+		animTable++;
+	}
+
+	if (_newDirtyClip != 0)
+		goto restart;
+	
 }
 
+void AGOSEngine::dirtyClipCheck(int16 x, int16 y, int16 w, int16 h) {
+	int16 width, height, tmp;
+
+	VgaSprite *vsp = _vgaSprites;
+	for (; vsp->id != 0; vsp++) {
+		if (vsp->windowNum & 0x8000)
+			continue;
+
+		if (vsp->image == 0)
+			continue;
+
+		const byte *ptr = _curVgaFile2 + vsp->image * 8;
+		width = READ_BE_UINT16(ptr + 6) / 8;
+		height = ptr[5];
+
+		tmp = vsp->x;
+		if (tmp >= x) {
+			tmp -= w;
+			if (tmp >= x)
+				continue;
+		} else {
+			tmp += width;
+			if (tmp < x)
+				continue;
+		}
+
+		tmp = vsp->y;
+		if (tmp >= y) {
+			tmp -= h;
+			if (tmp >= y)
+				continue;
+		} else {
+			tmp += height;
+			if (tmp < y)
+				continue;
+		}
+
+		vsp->windowNum |= 0x8000;
+		_newDirtyClip = 1;
+	}
+
+	AnimTable *animTable = _screenAnim1;
+	for (; animTable->srcPtr != 0; animTable++) {
+		if (animTable->windowNum & 0x8000)
+			continue;
+
+		width = animTable->width * 2;
+		height = animTable->height;
+
+		tmp = animTable->x + _scrollX;
+		if (tmp >= x) {
+			tmp -= w;
+			if (tmp >= x)
+				continue;
+		} else {
+			tmp += width;
+			if (tmp < x)
+				continue;
+		}
+
+		tmp = animTable->y;
+		if (tmp >= y) {
+			tmp -= h;
+			if (tmp >= y)
+				continue;
+		} else {
+			tmp += height;
+			if (tmp < y)
+				continue;
+		}
+
+		animTable->windowNum |= 0x8000;
+		_newDirtyClip = 1;
+	}
+}
+
 void AGOSEngine::restoreBackGround() {
 	if (getGameType() == GType_ELVIRA1 && getPlatform() == Common::kPlatformAtariST &&
 		(getFeatures() & GF_DEMO)) {
@@ -326,12 +444,11 @@
 		animTable--;
 
 		if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) &&
-			!(animTable->window & 0x8000)) {
-			//continue;
+			!(animTable->windowNum & 0x8000)) {
+			continue;
 		}
 
-		animTable->window &= 0x7FFF;
-		_windowNum = animTable->window;	
+		_windowNum = animTable->windowNum & 0x7FFF;	
 
 		VC10_state state;
 		state.srcPtr  = animTable->srcPtr;
@@ -346,9 +463,9 @@
 		_backFlag = 1;
 		drawImage(&state);
 
-		//if (getGameType() != GType_SIMON1 && getGameType() != GType_SIMON2) {
+		if (getGameType() != GType_SIMON1 && getGameType() != GType_SIMON2) {
 			animTable->srcPtr = 0;
-		//}
+		}
 	}
 	_backFlag = 0;
 
@@ -357,7 +474,7 @@
 
 		animTable = animTableTmp = _screenAnim1;
 		while (animTable->srcPtr) {
-			if (!(animTable->window & 8000)) {
+			if (!(animTable->windowNum & 0x8000)) {
 				memcpy(animTableTmp, animTable, sizeof(AnimTable));
 				animTableTmp++;
 			}
@@ -402,8 +519,12 @@
 	}
 
 	animTable->height = ptr[5];
-	animTable->window = vsp->windowNum;
+	animTable->windowNum = vsp->windowNum;
 	animTable->id = vsp->id;
+	animTable->zoneNum = vsp->zoneNum;
+
+	animTable++;
+	animTable->srcPtr = 0;
 }
 
 void AGOSEngine::displayBoxStars() {
@@ -575,6 +696,20 @@
 	}
 
 	_scrollFlag = 0;
+
+	if (getGameType() == GType_SIMON2) {
+		AnimTable *animTable = _screenAnim1;
+		while (animTable->srcPtr) {
+			animTable->srcPtr = 0;
+			animTable++;
+		}
+
+		VgaSprite *vsp = _vgaSprites;
+		while (vsp->id) {
+			vsp->windowNum |= 0x8000;
+			vsp++;
+		}
+	}
 }
 
 void AGOSEngine::clearBackFromTop(uint lines) {

Modified: scummvm/trunk/engines/agos/vga.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga.cpp	2007-06-09 01:33:58 UTC (rev 27226)
+++ scummvm/trunk/engines/agos/vga.cpp	2007-06-09 05:30:20 UTC (rev 27227)
@@ -215,8 +215,8 @@
 void AGOSEngine::dirtyBackGround() {
 	AnimTable *animTable = _screenAnim1;
 	while (animTable->srcPtr) {
-		if (animTable->id == _vgaCurSpriteId) {
-			animTable->window |= 0x8000;
+		if (animTable->id == _vgaCurSpriteId && ((getGameType() == GType_SIMON1) || animTable->zoneNum == _vgaCurZoneNum)) {
+			animTable->windowNum |= 0x8000;
 			break;
 		}
 		animTable++;


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