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

kirben at users.sourceforge.net kirben at users.sourceforge.net
Thu Oct 5 15:46:59 CEST 2006


Revision: 24124
          http://svn.sourceforge.net/scummvm/?rev=24124&view=rev
Author:   kirben
Date:     2006-10-05 06:46:48 -0700 (Thu, 05 Oct 2006)

Log Message:
-----------
Fix startup of Elvira 1

Modified Paths:
--------------
    scummvm/trunk/engines/agos/agos.cpp
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/intern.h
    scummvm/trunk/engines/agos/items.cpp
    scummvm/trunk/engines/agos/rooms.cpp
    scummvm/trunk/engines/agos/vga.cpp

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2006-10-05 10:10:26 UTC (rev 24123)
+++ scummvm/trunk/engines/agos/agos.cpp	2006-10-05 13:46:48 UTC (rev 24124)
@@ -775,16 +775,23 @@
 }
 
 void AGOSEngine::createPlayer() {
-	Child *child;
+	SubPlayer *p;
 
 	_currentPlayer = _itemArrayPtr[1];
 	_currentPlayer->adjective = -1;
 	_currentPlayer->noun = 10000;
 
-	child = (Child *)allocateChildBlock(_currentPlayer, 3, sizeof(Child));
-	if (child == NULL)
+	p = (SubPlayer *)allocateChildBlock(_currentPlayer, 3, sizeof(SubPlayer));
+	if (p == NULL)
 		error("createPlayer: player create failure");
 
+	p->size = 0;
+	p->weight = 0;
+	p->strength = 6000;
+	//p->flag = xxx;
+	p->level = 1;
+	p->score = 0;
+
 	setUserFlag(_currentPlayer, 0, 0);
 }
 
@@ -1798,6 +1805,15 @@
 	}
 }
 
+int AGOSEngine::wordMatch(Item *item, int16 a, int16 n) {
+	if ((a == -1) && (n == item->noun))
+		return 1;
+	if ((a == item->adjective) && (n == item->noun))
+		return 1 ;
+
+	return 0;
+}
+
 Item *AGOSEngine::derefItem(uint item) {
 	if (item >= _itemArraySize) {
 		debug(1, "derefItem: invalid item %d", item);
@@ -1806,6 +1822,31 @@
 	return _itemArrayPtr[item];
 }
 
+Item *AGOSEngine::findMaster(int16 pe, int16 a, int16 n) {
+	uint j;
+
+	for (j = 1; j < _itemArraySize; j++) {
+		Item *item = derefItem(j);
+		if (wordMatch(item, a, n))
+			return item;
+	}
+
+	return NULL;
+}
+
+Item *AGOSEngine::nextMaster(int16 pe, Item *i, int16 a, int16 n) {
+	uint j;
+	uint first = itemPtrToID(i) + 1;
+
+	for (j = first; j < _itemArraySize; j++) {
+		Item *item = derefItem(j);
+		if (wordMatch(item, a, n))
+			return item;
+	}
+
+	return NULL;
+}
+
 uint AGOSEngine::itemPtrToID(Item *id) {
 	uint i;
 	for (i = 0; i != _itemArraySize; i++)

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2006-10-05 10:10:26 UTC (rev 24123)
+++ scummvm/trunk/engines/agos/agos.h	2006-10-05 13:46:48 UTC (rev 24124)
@@ -989,6 +989,11 @@
 	void o_unloadZone();
 	void o_unfreezeZones();
 
+	Item *findMaster(int16 pe, int16 a, int16 n);
+	Item *nextMaster(int16 pe, Item *item, int16 a, int16 n);
+	int16 levelOf(Item *item);
+	int wordMatch(Item *item, int16 a, int16 n);
+
 	uint16 getDoorState(Item *item, uint16 d);
 	uint16 getExitOf(Item *item, uint16 d);
 	void moveDirn(Item *i, int x);
@@ -1012,6 +1017,8 @@
 	void oe1_setFF();
 	void oe1_opcode176();
 	void oe1_opcode178();
+	void oe1_findMaster();
+	void oe1_nextMaster();
 	void oe1_zoneDisk();
 	void oe1_printStats();
 

Modified: scummvm/trunk/engines/agos/intern.h
===================================================================
--- scummvm/trunk/engines/agos/intern.h	2006-10-05 10:10:26 UTC (rev 24123)
+++ scummvm/trunk/engines/agos/intern.h	2006-10-05 13:46:48 UTC (rev 24124)
@@ -56,6 +56,16 @@
 	int16 objectFlagValue[1];
 };
 
+struct SubPlayer : Child {
+	int16 userKey;
+	int16 size;
+	int16 weight;
+	int16 strength;
+	int16 flags;
+	int16 level;
+	int32 score;
+};
+
 struct SubUserChain : Child {
 	uint16 subroutine_id;
 	uint16 chChained;

Modified: scummvm/trunk/engines/agos/items.cpp
===================================================================
--- scummvm/trunk/engines/agos/items.cpp	2006-10-05 10:10:26 UTC (rev 24123)
+++ scummvm/trunk/engines/agos/items.cpp	2006-10-05 13:46:48 UTC (rev 24124)
@@ -248,6 +248,8 @@
 
 	op[152] = &AGOSEngine::o_debug;
 
+	op[164] = &AGOSEngine::o1_rescan;
+
 	op[176] = &AGOSEngine::oe1_opcode176;
 
 	op[178] = &AGOSEngine::oe1_opcode178;
@@ -260,6 +262,9 @@
 	op[207] = &AGOSEngine::o_getNext;
 	op[208] = &AGOSEngine::o_getChildren;
 
+	op[219] = &AGOSEngine::oe1_findMaster;
+	op[220] = &AGOSEngine::oe1_nextMaster;
+
 	op[224] = &AGOSEngine::o_picture;
 	op[225] = &AGOSEngine::o_loadZone;
 	op[226] = &AGOSEngine::o1_animate;
@@ -1759,16 +1764,49 @@
 }
 
 void AGOSEngine::oe1_opcode176() {
+	// 176
 	getNextItemPtr();
 	getVarOrWord();
 	getNextItemPtr();
 }
 
 void AGOSEngine::oe1_opcode178() {
+	// 178
 	getNextItemPtr();
 	getVarOrWord();
 }
 
+void AGOSEngine::oe1_findMaster() {
+	// 219: find master
+	int16 ad, no;
+	int16 d = getVarOrWord();
+
+	ad = (d == 1) ? _scriptAdj1 : _scriptAdj2;
+	no = (d == 1) ? _scriptNoun1 : _scriptNoun2;
+
+	d = getVarOrWord();
+	if (d == 1)
+		_subjectItem = findMaster(levelOf(me()), ad, no);
+	else
+		_objectItem = findMaster(levelOf(me()), ad, no);
+}
+
+void AGOSEngine::oe1_nextMaster() {
+	// 220: next master
+	int16 ad, no;
+	Item *item = getNextItemPtr();
+	int16 d = getVarOrWord();
+
+	ad = (d == 1) ? _scriptAdj1 : _scriptAdj2;
+	no = (d == 1) ? _scriptNoun1 : _scriptNoun2;
+
+	d = getVarOrWord();
+	if (d == 1)
+		_subjectItem = nextMaster(levelOf(me()), item, ad, no);
+	else
+		_objectItem = nextMaster(levelOf(me()), item, ad, no);
+}
+
 void AGOSEngine::oe1_zoneDisk() {
 	// 267: zone disk 
 	getVarOrWord();
@@ -2813,4 +2851,12 @@
 	_lockWord &= ~0x8000;
 }
 
+int16 AGOSEngine::levelOf(Item *item) {
+	SubPlayer *p = (SubPlayer *) findChildOfType(item, 3);
+	if(p == NULL)
+		return 0;
+
+	return p->level;
+}
+
 } // End of namespace AGOS

Modified: scummvm/trunk/engines/agos/rooms.cpp
===================================================================
--- scummvm/trunk/engines/agos/rooms.cpp	2006-10-05 10:10:26 UTC (rev 24123)
+++ scummvm/trunk/engines/agos/rooms.cpp	2006-10-05 13:46:48 UTC (rev 24124)
@@ -116,8 +116,13 @@
 				}
 
 				while ((i = in.readUint16BE()) != 0) {
-					_itemArrayPtr[i] = (Item *)allocateItem(sizeof(Item));
-					readItemFromGamePc(&in, _itemArrayPtr[i]);
+					Item *item = derefItem(i);
+					item = (Item *)allocateItem(sizeof(Item));
+					readItemFromGamePc(&in, item);
+
+					item->child = NULL;
+					item->parent = NULL;
+
 				}
 				in.close();
 

Modified: scummvm/trunk/engines/agos/vga.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga.cpp	2006-10-05 10:10:26 UTC (rev 24123)
+++ scummvm/trunk/engines/agos/vga.cpp	2006-10-05 13:46:48 UTC (rev 24124)
@@ -1278,20 +1278,28 @@
 
 	uint offs, offs2;
 	if (getGameType() == GType_ELVIRA) {
-		if (_windowNum == 2 || _windowNum == 3) {
-			offs = state->x * 8;
-			offs2 = state->y;
-		} else {
-			offs = ((vlut[0] - _video_windows[16]) * 2 + state->x) * 8;
-			offs2 = (vlut[1] - _video_windows[17] + state->y);
-		}
-	} else if (getGameType() == GType_WW) {
+		//if (_windowNum != 2 && _windowNum != 3) {
+		//	offs = ((vlut[0] - _video_windows[16]) * 2 + state->x) * 8;
+		//	offs2 = (vlut[1] - _video_windows[17] + state->y);
+		//} else {
+			offs = (vlut[0] * 2 + state->x) * 8;
+			offs2 = vlut[1] + state->y;
+		//}
+	} else if (getGameType() == GType_ELVIRA2) {
 		//if (_windowNum == 4 || _windowNum >= 10) {
-			offs = state->x * 8;
-			offs2 = state->y;
+		//	offs = ((vlut[0] - _video_windows[16]) * 2 + state->x) * 8;
+		//	offs2 = (vlut[1] - _video_windows[17] + state->y);
 		//} else {
+			offs = (vlut[0] * 2 + state->x) * 8;
+			offs2 = vlut[1] + state->y;
+		//}
+	} else if (getGameType() == GType_WW) {
+		//if (_windowNum == 4 || (_windowNum >= 10 && _windowsNum < 28)) {
 		//	offs = ((vlut[0] - _video_windows[16]) * 2 + state->x) * 8;
 		//	offs2 = (vlut[1] - _video_windows[17] + state->y);
+		//} else {
+			offs = (vlut[0] * 2 + state->x) * 8;
+			offs2 = vlut[1] + state->y;
 		//}
 	} else if (getGameType() == GType_SIMON1) {
 		// Allow one section of Simon the Sorcerer 1 introduction to be displayed


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