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

kirben at users.sourceforge.net kirben at users.sourceforge.net
Sat Sep 30 04:15:12 CEST 2006


Revision: 24023
          http://svn.sourceforge.net/scummvm/?rev=24023&view=rev
Author:   kirben
Date:     2006-09-29 19:15:02 -0700 (Fri, 29 Sep 2006)

Log Message:
-----------
Add changes and stubs for 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/res.cpp
    scummvm/trunk/engines/agos/vga.cpp

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2006-09-29 22:24:03 UTC (rev 24022)
+++ scummvm/trunk/engines/agos/agos.cpp	2006-09-30 02:15:02 UTC (rev 24023)
@@ -575,6 +575,18 @@
 		_soundIndexBase = 1660 / 4;
 		_vgaBaseDelay = 1;
 		_numVars = 256;
+	} else if (getGameType() == GType_ELVIRA) {
+		gss = PTR(simon1_settings);
+		_numTextBoxes = 20;
+		_numVideoOpcodes = 56;
+#ifndef PALMOS_68K
+		_vgaMemSize = 1000000;
+#else
+		_vgaMemSize = gVars->memory[kMemSimon1Games];
+#endif
+		_tableMemSize = 150000;
+		_vgaBaseDelay = 1;
+		_numVars = 512;
 	} else {
 		gss = PTR(simon1_settings);
 		_tableIndexBase = 1576 / 4;
@@ -779,10 +791,14 @@
 }
 
 uint AGOSEngine::getVarOrByte() {
-	uint a = *_codePtr++;
-	if (a != 255)
-		return a;
-	return readVariable(*_codePtr++);
+	if (getGameType() == GType_ELVIRA) {
+		return getVarOrWord();
+	} else {
+		uint a = *_codePtr++;
+		if (a != 255)
+			return a;
+		return readVariable(*_codePtr++);
+	}
 }
 
 uint AGOSEngine::getVarOrWord() {
@@ -801,7 +817,7 @@
 }
 
 uint AGOSEngine::getVarWrapper() {
-	if (getGameType() == GType_PP)
+	if (getGameType() == GType_ELVIRA || getGameType() == GType_PP)
 		return getVarOrWord();
 	else
 		return getVarOrByte();
@@ -809,7 +825,6 @@
 
 Item *AGOSEngine::getNextItemPtr() {
 	int a = getNextWord();
-
 	switch (a) {
 	case -1:
 		return _subjectItem;
@@ -969,10 +984,8 @@
 	for (;;) {
 		if (!first)
 			error("unlinkItem: parent empty");
-		if (first->sibling == 0) {
-			warning("unlinkItem: parent does not contain child");
-			return;
-		}
+		if (first->sibling == 0)
+			error("unlinkItem: parent does not contain child");
 
 		next = derefItem(first->sibling);
 		if (next == item) {
@@ -1563,7 +1576,7 @@
 			clearBackFromTop(134);
 			_usePaletteDelay = true;
 		}
-	} else {
+	} else if (getGameType() == GType_SIMON2 || getGameType() == GType_FF) {
 		_scrollX = 0;
 		_scrollY = 0;
 		_scrollXMax = 0;
@@ -1716,11 +1729,11 @@
 bool AGOSEngine::isSpriteLoaded(uint16 id, uint16 zoneNum) {
 	VgaSprite *vsp = _vgaSprites;
 	while (vsp->id) {
-		if (getGameType() == GType_SIMON1 || getGameType() == GType_WW) {
-			if (vsp->id == id)
+		if (getGameType() == GType_SIMON2 || getGameType() == GType_FF || getGameType() == GType_PP) {
+			if (vsp->id == id && vsp->zoneNum == zoneNum)
 				return true;
 		} else {
-			if (vsp->id == id && vsp->zoneNum == zoneNum)
+			if (vsp->id == id)
 				return true;
 		}
 		vsp++;
@@ -1876,17 +1889,17 @@
 	vsp->y = y;
 	vsp->x = x;
 	vsp->image = 0;
-	if (getGameType() == GType_WW)
+	if (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2 || getGameType() == GType_WW)
 		vsp->palette = 0;
 	else
 		vsp->palette = palette;
 	vsp->id = vgaSpriteId;
-	if (getGameType() == GType_SIMON1 || getGameType() == GType_WW)
+
+	if (getGameType() == GType_SIMON2 || getGameType() == GType_FF || getGameType() == GType_PP)
+		vsp->zoneNum = zoneNum;
+	else
 		vsp->zoneNum = zoneNum = vgaSpriteId / 100;
-	else
-		vsp->zoneNum = zoneNum;
 
-
 	for (;;) {
 		vpe = &_vgaBufferPointers[zoneNum];
 		_zoneNumber = zoneNum;
@@ -2229,7 +2242,7 @@
 		}
 
 		midi.startTrack (0);
-	} else {
+	} else if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) {
 		midi.stop();
 		midi.setLoop (true); // Must do this BEFORE loading music. (GMF may have its own override.)
 
@@ -2242,6 +2255,8 @@
 
 		midi.loadS1D (&f);
 		midi.startTrack (0);
+	} else {
+		warning("Old music type not support");
 	}
 }
 

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2006-09-29 22:24:03 UTC (rev 24022)
+++ scummvm/trunk/engines/agos/agos.h	2006-09-30 02:15:02 UTC (rev 24023)
@@ -973,6 +973,12 @@
 	uint16 getDoorState(Item *item, uint16 d);
 	uint16 getExitOf(Item *item, uint16 d);
 
+	// Opcodes, Elvira 1 only
+	void oe1_setFF();
+	void oe1_zoneDisk();
+	void oe1_opcode176();
+	void oe1_opcode178();
+
 	// Opcodes, Waxworks only
 	void oww_whereTo();
 	void oww_menu();

Modified: scummvm/trunk/engines/agos/intern.h
===================================================================
--- scummvm/trunk/engines/agos/intern.h	2006-09-29 22:24:03 UTC (rev 24022)
+++ scummvm/trunk/engines/agos/intern.h	2006-09-30 02:15:02 UTC (rev 24023)
@@ -35,6 +35,9 @@
 	uint16 subroutine_id;
 	uint16 roomExitStates;
 	uint16 roomExit[1];
+	uint16 roomShort;
+	uint16 roomLong;
+	uint16 flags;
 };
 
 struct SubObject : Child {
@@ -55,9 +58,21 @@
 
 struct SubUserFlag : Child {
 	uint16 subroutine_id;
-	uint16 userFlags[4];
+	uint16 userFlags[8];
+	uint16 userItems[1];
 };
 
+struct SubContainer : Child {
+	uint16 subroutine_id;
+	uint16 volume;
+	uint16 flags;
+};
+
+struct SubGenExit : Child {
+	uint16 subroutine_id;
+	uint16 dest[6];
+};
+
 enum {
 	SubRoom_SIZE = sizeof(SubRoom) - sizeof(uint16),
 	SubObject_SIZE = sizeof(SubObject) - sizeof(int16)

Modified: scummvm/trunk/engines/agos/items.cpp
===================================================================
--- scummvm/trunk/engines/agos/items.cpp	2006-09-29 22:24:03 UTC (rev 24022)
+++ scummvm/trunk/engines/agos/items.cpp	2006-09-30 02:15:02 UTC (rev 24023)
@@ -321,6 +321,7 @@
 
 		opcode_table[56] = &AGOSEngine::o_copyff;
 
+		opcode_table[60] = &AGOSEngine::oe1_setFF;
 		opcode_table[61] = &AGOSEngine::o_clear;
 
 		opcode_table[64] = &AGOSEngine::o_let;
@@ -418,6 +419,9 @@
 		opcode_table[173] = NULL;
 		opcode_table[174] = NULL;
 
+		opcode_table[176] = &AGOSEngine::oe1_opcode176;
+
+		opcode_table[178] = &AGOSEngine::oe1_opcode178;
 		opcode_table[179] = NULL;
 
 		opcode_table[182] = NULL;
@@ -497,6 +501,7 @@
 
 		opcode_table[265] = &AGOSEngine::o_ifEndTune;
 		opcode_table[266] = &AGOSEngine::o_setAdjNoun;
+		opcode_table[267] = &AGOSEngine::oe1_zoneDisk;
 		opcode_table[268] = &AGOSEngine::o_saveUserGame;
 		opcode_table[269] = &AGOSEngine::o_loadUserGame;
 		opcode_table[271] = &AGOSEngine::o_stopTune;
@@ -827,7 +832,7 @@
 void AGOSEngine::o_oflag() {
 	// 28: item has prop
 	SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2);
-	byte num = getVarOrByte();
+	uint num = getVarOrByte();
 	setScriptCondition(subObject != NULL && (subObject->objectFlags & (1 << num)) != 0);
 }
 
@@ -1806,9 +1811,35 @@
 }
 
 // -----------------------------------------------------------------------
-// Waxworks 1 Opcodes
+// Elvira 1 Opcodes
 // -----------------------------------------------------------------------
 
+void AGOSEngine::oe1_setFF() {
+	writeNextVarContents(0xFF);
+}
+
+void AGOSEngine::oe1_zoneDisk() {
+	getVarOrWord();
+	getVarOrWord();
+}
+
+void AGOSEngine::oe1_opcode176() {
+	getNextItemPtr();
+	getVarOrWord();
+	getNextItemPtr();
+}
+
+
+void AGOSEngine::oe1_opcode178() {
+	getNextItemPtr();
+	getVarOrWord();
+}
+
+
+// -----------------------------------------------------------------------
+// Waxworks Opcodes
+// -----------------------------------------------------------------------
+
 void AGOSEngine::oww_whereTo() {
 	// 85: where to
 	Item *i = getNextItemPtr();

Modified: scummvm/trunk/engines/agos/res.cpp
===================================================================
--- scummvm/trunk/engines/agos/res.cpp	2006-09-29 22:24:03 UTC (rev 24022)
+++ scummvm/trunk/engines/agos/res.cpp	2006-09-30 02:15:02 UTC (rev 24023)
@@ -255,7 +255,7 @@
 int AGOSEngine::allocGamePcVars(File *in) {
 	uint item_array_size, item_array_inited, stringtable_num;
 	uint32 version;
-	uint i, start;
+	uint i, firstItem;
 
 	item_array_size = in->readUint32BE();
 	version = in->readUint32BE();
@@ -264,11 +264,11 @@
 
 	if (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2) {
 		item_array_inited = item_array_size;
-		start = 0;
+		firstItem = 0;
 	} else {
 		item_array_inited += 2;				// first two items are predefined
 		item_array_size += 2;
-		start = 1;
+		firstItem = 1;
 	}
 
 	if (version != 0x80)
@@ -281,7 +281,7 @@
 	_itemArraySize = item_array_size;
 	_itemArrayInited = item_array_inited;
 
-	for (i = start; i < item_array_inited; i++) {
+	for (i = firstItem; i < item_array_inited; i++) {
 		_itemArrayPtr[i] = (Item *)allocateItem(sizeof(Item));
 	}
 
@@ -308,14 +308,8 @@
 	createPlayer();
 	readGamePcText(&in);
 
-	int start;
-	if (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2) {
-		start = 0;
-	} else {
-		start = 2;
-	}
-
-	for (i = start; i < num_inited_objects; i++) {
+	int firstItem = (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2) ? 0 : 2;
+	for (i = firstItem; i < num_inited_objects; i++) {
 		readItemFromGamePc(&in, _itemArrayPtr[i]);
 	}
 
@@ -449,11 +443,11 @@
 
 void AGOSEngine::readItemChildren(Common::File *in, Item *item, uint type) {
 	if (type == 1) {
-		if (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2) {
-			// FIXME
-			in->readUint32BE();
-			in->readUint32BE();
-			in->readUint16BE();
+		if (getGameType() == GType_ELVIRA) {
+			SubRoom *subRoom = (SubRoom *)allocateChildBlock(item, 1, sizeof(SubRoom));
+			subRoom->roomShort = in->readUint32BE();
+			subRoom->roomLong = in->readUint32BE();
+			subRoom->flags = in->readUint16BE();
 		} else {
 			uint fr1 = in->readUint16BE();
 			uint fr2 = in->readUint16BE();
@@ -497,23 +491,23 @@
 
 		subObject->objectName = (uint16)in->readUint32BE();
 	} else if (type == 4) {
-		// FIXME
+		SubGenExit *genExit = (SubGenExit *)allocateChildBlock(item, 4, sizeof(SubGenExit));
+		genExit->dest[0] = (uint16)fileReadItemID(in);
+		genExit->dest[1] = (uint16)fileReadItemID(in);
+		genExit->dest[2] = (uint16)fileReadItemID(in);
+		genExit->dest[3] = (uint16)fileReadItemID(in);
+		genExit->dest[4] = (uint16)fileReadItemID(in);
+		genExit->dest[5] = (uint16)fileReadItemID(in);
 		fileReadItemID(in);
 		fileReadItemID(in);
 		fileReadItemID(in);
 		fileReadItemID(in);
 		fileReadItemID(in);
 		fileReadItemID(in);
-		fileReadItemID(in);
-		fileReadItemID(in);
-		fileReadItemID(in);
-		fileReadItemID(in);
-		fileReadItemID(in);
-		fileReadItemID(in);
 	} else if (type == 7) {
-		// FIXME
-		in->readUint16BE();
-		in->readUint16BE();
+		SubContainer *container = (SubContainer *)allocateChildBlock(item, 7, sizeof(SubContainer));
+		container->volume = in->readUint16BE();
+		container->flags = in->readUint16BE();
 	} else if (type == 8) {
 		SubUserChain *chain = (SubUserChain *)allocateChildBlock(item, 8, sizeof(SubUserChain));
 		chain->chChained = (uint16)fileReadItemID(in);
@@ -522,13 +516,13 @@
 		setUserFlag(item, 1, in->readUint16BE());
 		setUserFlag(item, 2, in->readUint16BE());
 		setUserFlag(item, 3, in->readUint16BE());
-		if (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2) {
+		if (getGameType() == GType_ELVIRA) {
 			setUserFlag(item, 4, in->readUint16BE());
 			setUserFlag(item, 5, in->readUint16BE());
 			setUserFlag(item, 6, in->readUint16BE());
 			setUserFlag(item, 7, in->readUint16BE());
-			// FIXME
-			fileReadItemID(in); 
+			SubUserFlag *subUserFlag = (SubUserFlag *) findChildOfType(item, 9);
+			subUserFlag->userItems[0] = (uint16)fileReadItemID(in); 
 			fileReadItemID(in);
 			fileReadItemID(in);
 			fileReadItemID(in);
@@ -889,7 +883,7 @@
 			else
 				sprintf(filename, "%.3d%d.pkd", id / 2, type);
 		} else {
-			if (getGameType() == GType_WW) {
+			if (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) {
 				sprintf(filename, "%.2d%d.VGA", id / 2, type);
 			} else {
 				sprintf(filename, "%.3d%d.VGA", id / 2, type);

Modified: scummvm/trunk/engines/agos/vga.cpp
===================================================================
--- scummvm/trunk/engines/agos/vga.cpp	2006-09-29 22:24:03 UTC (rev 24022)
+++ scummvm/trunk/engines/agos/vga.cpp	2006-09-30 02:15:02 UTC (rev 24023)
@@ -137,11 +137,11 @@
 			}
 		}
 
-		if (getGameType() == GType_SIMON1 || getGameType() == GType_WW) {
+		if (getGameType() == GType_SIMON2 || getGameType() == GType_FF || getGameType() == GType_PP) {
+			opcode = *_vcPtr++;
+		} else {
 			opcode = READ_BE_UINT16(_vcPtr);
 			_vcPtr += 2;
-		} else {
-			opcode = *_vcPtr++;
 		}
 
 		if (opcode >= _numVideoOpcodes)
@@ -195,11 +195,11 @@
 VgaSprite *AGOSEngine::findCurSprite() {
 	VgaSprite *vsp = _vgaSprites;
 	while (vsp->id) {
-		if (getGameType() == GType_SIMON1 || getGameType() == GType_WW) {
-			if (vsp->id == _vgaCurSpriteId)
+		if (getGameType() == GType_SIMON2 || getGameType() == GType_FF || getGameType() == GType_PP) {
+			if (vsp->id == _vgaCurSpriteId && vsp->zoneNum == _vgaCurZoneNum)
 				break;
 		} else {
-			if (vsp->id == _vgaCurSpriteId && vsp->zoneNum == _vgaCurZoneNum)
+			if (vsp->id == _vgaCurSpriteId)
 				break;
 		}
 		vsp++;
@@ -236,6 +236,18 @@
 }
 
 void AGOSEngine::vcSkipNextInstruction() {
+
+	static const byte opcodeParamLenElvira1[] = {
+		0, 6,  2, 10, 6, 4, 2, 2,
+		4, 4,  8,  2, 0, 2, 2, 2,
+		2, 2,  2,  2, 0, 4, 2, 2,
+		2, 8,  0, 10, 0, 8, 0, 2,
+		2, 0,  0,  0, 0, 2, 4, 2,
+		4, 4,  0,  0, 2, 2, 2, 4,
+		4, 0, 18,  2, 4, 4, 4, 0,
+		4
+	};
+
 	static const byte opcodeParamLenWW[] = {
 		0, 6, 2, 10, 6, 4, 2, 2,
 		4, 4, 8, 2, 2, 2, 2, 2,
@@ -295,9 +307,12 @@
 	} else if (getGameType() == GType_SIMON1) {
 		opcode = vcReadNextWord();
 		_vcPtr += opcodeParamLenSimon1[opcode];
+	} else if (getGameType() == GType_WW) {
+		opcode = vcReadNextWord();
+		_vcPtr += opcodeParamLenWW[opcode];
 	} else {
 		opcode = vcReadNextWord();
-		_vcPtr += opcodeParamLenWW[opcode];
+		_vcPtr += opcodeParamLenElvira1[opcode];
 	}
 
 	if (_continousVgaScript)
@@ -405,12 +420,12 @@
 
 	windowNum = vcReadNextWord();		/* 0 */
 
-	if (getGameType() == GType_SIMON1 || getGameType() == GType_WW) {
+	if (getGameType() == GType_SIMON2 || getGameType() == GType_FF || getGameType() == GType_PP) {
+		zoneNum = vcReadNextWord();	/* 0 */
 		vgaSpriteId = vcReadNextWord();	/* 2 */
-		zoneNum = vgaSpriteId / 100;
 	} else {
-		zoneNum = vcReadNextWord();	/* 0 */
 		vgaSpriteId = vcReadNextWord();	/* 2 */
+		zoneNum = vgaSpriteId / 100;
 	}
 
 	x = vcReadNextWord();			/* 4 */
@@ -424,7 +439,7 @@
 	while (vsp->id)
 		vsp++;
 
-	if (getGameType() == GType_WW)
+	if (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2 || getGameType() == GType_WW)
 		vsp->palette = 0;
 	else
 		vsp->palette = palette;
@@ -843,10 +858,10 @@
 	state.y = (int16)vcReadNextWord();
 	state.y -= _scrollY;
 
-	if (getGameType() == GType_SIMON1 || getGameType() == GType_WW) {
+	if (getGameType() == GType_SIMON2 || getGameType() == GType_FF || getGameType() == GType_PP) {
+		state.flags = vcReadNextByte();
+	} else {
 		state.flags = vcReadNextWord();
-	} else {
-		state.flags = vcReadNextByte();
 	}
 
 	if (state.image < 0)
@@ -904,7 +919,7 @@
 		return;
 	}
 
-	if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2 || getGameType() == GType_WW) {
+	if (getGameType() != GType_FF && getGameType() != GType_PP) {
 		if (state.flags & kDFCompressedFlip) {
 			state.depack_src = vc10_uncompressFlip(state.depack_src, width, height);
 		} else if (state.flags & kDFFlip) {
@@ -932,7 +947,7 @@
 
 	vlut = &_video_windows[_windowNum * 4];
 
-	if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2 || getGameType() == GType_WW) {
+	if (getGameType() != GType_FF && getGameType() != GType_PP) {
 		state->draw_width = state->width * 2;
 	} 
 
@@ -976,7 +991,7 @@
 
 	assert(state->draw_width != 0 && state->draw_height != 0);
 
-	if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2 || getGameType() == GType_WW) {
+	if (getGameType() != GType_FF && getGameType() != GType_PP) {
 		state->draw_width *= 4;
 	}
 
@@ -1228,7 +1243,7 @@
 
 		/* vc10_helper_5 */
 	} else if ((((_lockWord & 0x20) && state->palette == 0) || state->palette == 0xC0) &&
-		getGameType() != GType_WW) {
+		(getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2)) {
 		const byte *src;
 		byte *dst;
 		uint h, i;
@@ -1608,10 +1623,10 @@
 void AGOSEngine::vc21_endRepeat() {
 	int16 a = vcReadNextWord();
 	const byte *tmp = _vcPtr + a;
-	if (getGameType() == GType_SIMON1 || getGameType() == GType_WW)
+	if (getGameType() == GType_SIMON2 || getGameType() == GType_FF || getGameType() == GType_PP)
+		tmp += 3;
+	else
 		tmp += 4;
-	else
-		tmp += 3;
 
 	uint16 val = READ_LE_UINT16(tmp);
 	if (val != 0) {
@@ -1713,10 +1728,10 @@
 
 	vsp->x += (int16)vcReadNextWord();
 	vsp->y += (int16)vcReadNextWord();
-	if (getGameType() == GType_SIMON1 || getGameType() == GType_WW) {
+	if (getGameType() == GType_SIMON2 || getGameType() == GType_FF || getGameType() == GType_PP) {
+		vsp->flags = vcReadNextByte();
+	} else {
 		vsp->flags = vcReadNextWord();
-	} else {
-		vsp->flags = vcReadNextByte();
 	}
 
 	_vgaSpriteChanged++;


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