[Scummvm-cvs-logs] SF.net SVN: scummvm: [26386] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Thu Apr 5 18:05:01 CEST 2007


Revision: 26386
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26386&view=rev
Author:   drmccoy
Date:     2007-04-05 09:04:59 -0700 (Thu, 05 Apr 2007)

Log Message:
-----------
Added save/load stub for Gob3, recognizing the use of "INTRO.$$$" as an extra background buffer

Modified Paths:
--------------
    scummvm/trunk/engines/gob/inter.h
    scummvm/trunk/engines/gob/inter_bargon.cpp
    scummvm/trunk/engines/gob/inter_v1.cpp
    scummvm/trunk/engines/gob/inter_v2.cpp
    scummvm/trunk/engines/gob/inter_v3.cpp

Modified: scummvm/trunk/engines/gob/inter.h
===================================================================
--- scummvm/trunk/engines/gob/inter.h	2007-04-05 15:38:30 UTC (rev 26385)
+++ scummvm/trunk/engines/gob/inter.h	2007-04-05 16:04:59 UTC (rev 26386)
@@ -472,6 +472,9 @@
 	virtual const char *getOpcodeGoblinDesc(int i);
 
 	bool o3_getTotTextItemPart(OpFuncParams &params);
+	bool o3_checkData(OpFuncParams &params);
+	bool o3_readData(OpFuncParams &params);
+	bool o3_writeData(OpFuncParams &params);
 };
 
 } // End of namespace Gob

Modified: scummvm/trunk/engines/gob/inter_bargon.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_bargon.cpp	2007-04-05 15:38:30 UTC (rev 26385)
+++ scummvm/trunk/engines/gob/inter_bargon.cpp	2007-04-05 16:04:59 UTC (rev 26386)
@@ -692,8 +692,7 @@
 		val = load16();
 		_vm->_global->_inter_execPtr += val << 1;
 		warning("unimplemented opcodeGob: %d", i);
-	}
-	else
+	} else
 		(this->*op) (params);
 }
 

Modified: scummvm/trunk/engines/gob/inter_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v1.cpp	2007-04-05 15:38:30 UTC (rev 26385)
+++ scummvm/trunk/engines/gob/inter_v1.cpp	2007-04-05 16:04:59 UTC (rev 26386)
@@ -697,8 +697,7 @@
 		_vm->_global->_inter_execPtr -= 2;
 		int16 cmd = load16();
 		_vm->_global->_inter_execPtr += cmd * 2;
-	}
-	else
+	} else
 		(this->*op) (params);
 }
 

Modified: scummvm/trunk/engines/gob/inter_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v2.cpp	2007-04-05 15:38:30 UTC (rev 26385)
+++ scummvm/trunk/engines/gob/inter_v2.cpp	2007-04-05 16:04:59 UTC (rev 26386)
@@ -699,8 +699,7 @@
 		_vm->_global->_inter_execPtr -= 2;
 		val = load16();
 		_vm->_global->_inter_execPtr += val << 1;
-	}
-	else
+	} else
 		(this->*op) (params);
 }
 
@@ -831,8 +830,7 @@
 	
 	if (expr & 0x8000) {
 		_vm->_draw->_renderFlags |= expr & 0x3FFF;
-	}
-	else {
+	} else {
 		if (expr & 0x4000)
 			_vm->_draw->_renderFlags &= expr & 0x3FFF;
 		else
@@ -1587,8 +1585,7 @@
 	if (*_vm->_global->_inter_execPtr == 99) {
 		_vm->_global->_inter_execPtr++;
 		loopCount = *_vm->_global->_inter_execPtr++;
-	}
-	else
+	} else
 		loopCount = 1;
 
 	for (int i = 0; i < loopCount; i++) {
@@ -1785,6 +1782,7 @@
 	evalExpr(0);
 	varOff = _vm->_parse->parseVarIndex();
 
+	size = -1;
 	handle = 1;
 	if (!scumm_stricmp(_vm->_global->_inter_resStr, "cat.inf"))
 		size = _vm->getSaveSize(SAVE_CAT);
@@ -1800,10 +1798,8 @@
 		if (handle >= 0) {
 			_vm->_dataIO->closeData(handle);
 			size = _vm->_dataIO->getDataSize(_vm->_global->_inter_resStr);
-		} else {
-			size = -1;
+		} else
 			warning("File \"%s\" not found", _vm->_global->_inter_resStr);
-		}
 	}
 	if (size == -1)
 		handle = -1;
@@ -1834,16 +1830,13 @@
 	if (!scumm_stricmp(_vm->_global->_inter_resStr, "cat.inf")) {
 		_vm->loadGameData(SAVE_CAT, dataVar, size, offset);
 		return false;
-	}
-	else if (!scumm_stricmp(_vm->_global->_inter_resStr, "cat.cat")) {
+	} else if (!scumm_stricmp(_vm->_global->_inter_resStr, "cat.cat")) {
 		_vm->loadGameData(SAVE_CAT, dataVar, size, offset);
 		return false;
-	}
-	else if (!scumm_stricmp(_vm->_global->_inter_resStr, "save.inf")) {
+	} else if (!scumm_stricmp(_vm->_global->_inter_resStr, "save.inf")) {
 		_vm->loadGameData(SAVE_SAV, dataVar, size, offset);
 		return false;
-	}
-	else if (!scumm_stricmp(_vm->_global->_inter_resStr, "bloc.inf")) {
+	} else if (!scumm_stricmp(_vm->_global->_inter_resStr, "bloc.inf")) {
 		_vm->loadGameData(SAVE_BLO, dataVar, size, offset);
 		return false;
 	}

Modified: scummvm/trunk/engines/gob/inter_v3.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v3.cpp	2007-04-05 15:38:30 UTC (rev 26385)
+++ scummvm/trunk/engines/gob/inter_v3.cpp	2007-04-05 16:04:59 UTC (rev 26386)
@@ -27,6 +27,8 @@
 #include "gob/gob.h"
 #include "gob/inter.h"
 #include "gob/global.h"
+#include "gob/dataio.h"
+#include "gob/draw.h"
 #include "gob/game.h"
 #include "gob/parse.h"
 
@@ -516,7 +518,7 @@
 		OPCODE(o1_waitEndPlay),
 		OPCODE(o1_playComposition),
 		OPCODE(o2_getFreeMem),
-		OPCODE(o2_checkData),
+		OPCODE(o3_checkData),
 		/* 40 */
 		{NULL, ""},
 		OPCODE(o1_prepareStr),
@@ -534,8 +536,8 @@
 		OPCODE(o1_loadFont),
 		/* 4C */
 		OPCODE(o1_freeFont),
-		OPCODE(o2_readData),
-		OPCODE(o2_writeData),
+		OPCODE(o3_readData),
+		OPCODE(o3_writeData),
 		OPCODE(o1_manageDataFile),
 	};
 
@@ -685,8 +687,7 @@
 		_vm->_global->_inter_execPtr -= 2;
 		val = load16();
 		_vm->_global->_inter_execPtr += val << 1;
-	}
-	else
+	} else
 		(this->*op) (params);
 }
 
@@ -881,4 +882,130 @@
 	return false;
 }
 
+bool Inter_v3::o3_checkData(OpFuncParams &params) {
+	int16 handle;
+	int16 varOff;
+	int32 size;
+
+	evalExpr(0);
+	varOff = _vm->_parse->parseVarIndex();
+
+	size = -1;
+	handle = 1;
+	if (!scumm_stricmp(_vm->_global->_inter_resStr, "intro.$$$"))
+		size = _vm->getSaveSize(SAVE_SAV);
+	else if (!scumm_stricmp(_vm->_global->_inter_resStr, "cat.inf"))
+		warning("Gob3 Stub: Requested save file size");
+	else {
+		handle = _vm->_dataIO->openData(_vm->_global->_inter_resStr);
+
+		if (handle >= 0) {
+			_vm->_dataIO->closeData(handle);
+			size = _vm->_dataIO->getDataSize(_vm->_global->_inter_resStr);
+		} else
+			warning("File \"%s\" not found", _vm->_global->_inter_resStr);
+	}
+	if (size == -1)
+		handle = -1;
+
+	WRITE_VAR_OFFSET(varOff, handle);
+	WRITE_VAR(16, (uint32) size);
+
+	return false;
+}
+
+bool Inter_v3::o3_readData(OpFuncParams &params) {
+	int32 retSize;
+	int32 size;
+	int32 offset;
+	int16 dataVar;
+	int16 handle;
+	byte *buf;
+
+	evalExpr(0);
+	dataVar = _vm->_parse->parseVarIndex();
+	size = _vm->_parse->parseValExpr();
+	evalExpr(0);
+	offset = _vm->_global->_inter_resVal;
+
+	debugC(2, kDebugFileIO, "Read from file \"%s\" (%d, %d bytes at %d)",
+			_vm->_global->_inter_resStr, dataVar, size, offset);
+
+	if (!scumm_stricmp(_vm->_global->_inter_resStr, "intro.$$$")) {
+		_vm->loadGameData(SAVE_SAV, dataVar, size, offset);
+		return false;
+	} else if (!scumm_stricmp(_vm->_global->_inter_resStr, "cat.inf")) {
+		warning("Gob3 Stub: Game state loading");
+		return false;
+	}
+
+	if (size < 0) {
+		warning("Attempted to read a raw sprite from file \"%s\"",
+				_vm->_global->_inter_resStr);
+		return false ;
+	} else if (size == 0) {
+		dataVar = 0;
+		size = READ_LE_UINT32(_vm->_game->_totFileData + 0x2C) * 4;
+	}
+
+	buf = _vm->_global->_inter_variables + dataVar;
+	memset(_vm->_global->_inter_variablesSizes + dataVar, 0, size);
+
+	if (_vm->_global->_inter_resStr[0] == 0) {
+		WRITE_VAR(1, size);
+		return false;
+	}
+
+	WRITE_VAR(1, 1);
+	handle = _vm->_dataIO->openData(_vm->_global->_inter_resStr);
+
+	if (handle < 0)
+		return false;
+
+	_vm->_draw->animateCursor(4);
+	if (offset < 0)
+		_vm->_dataIO->seekData(handle, -offset - 1, SEEK_END);
+	else
+		_vm->_dataIO->seekData(handle, offset, SEEK_SET);
+
+	if (((dataVar >> 2) == 59) && (size == 4)) {
+		WRITE_VAR(59, _vm->_dataIO->readUint32(handle));
+		// The scripts in some versions divide through 256^3 then,
+		// effectively doing a LE->BE conversion
+		if ((_vm->_platform != Common::kPlatformPC) && (VAR(59) < 256))
+			WRITE_VAR(59, SWAP_BYTES_32(VAR(59)));
+	} else
+		retSize = _vm->_dataIO->readData(handle, buf, size);
+
+	if (retSize == size)
+		WRITE_VAR(1, 0);
+
+	_vm->_dataIO->closeData(handle);
+	return false;
+}
+
+bool Inter_v3::o3_writeData(OpFuncParams &params) {
+	int32 offset;
+	int32 size;
+	int16 dataVar;
+
+	evalExpr(0);
+	dataVar = _vm->_parse->parseVarIndex();
+	size = _vm->_parse->parseValExpr();
+	evalExpr(0);
+	offset = _vm->_global->_inter_resVal;
+
+	debugC(2, kDebugFileIO, "Write to file \"%s\" (%d, %d bytes at %d)",
+			_vm->_global->_inter_resStr, dataVar, size, offset);
+
+	if (!scumm_stricmp(_vm->_global->_inter_resStr, "intro.$$$"))
+		_vm->saveGameData(SAVE_SAV, dataVar, size, offset);
+	else if (!scumm_stricmp(_vm->_global->_inter_resStr, "cat.inf"))
+		warning("Gob3 Stub: Game state saving");
+	else
+		warning("Attempted to write to file \"%s\"", _vm->_global->_inter_resStr);
+
+	return false;
+}
+
 } // End of namespace Gob


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