diff options
| author | Sven Hesse | 2007-04-05 16:04:59 +0000 | 
|---|---|---|
| committer | Sven Hesse | 2007-04-05 16:04:59 +0000 | 
| commit | 96c6ae041fdb14ad557abdb2d95fe2cd62f17a97 (patch) | |
| tree | 68968c5b897fcc05c200308f98d8a594dcc3d293 | |
| parent | f2c1600c3d68c57faa0d7607fe52420b233e34f1 (diff) | |
| download | scummvm-rg350-96c6ae041fdb14ad557abdb2d95fe2cd62f17a97.tar.gz scummvm-rg350-96c6ae041fdb14ad557abdb2d95fe2cd62f17a97.tar.bz2 scummvm-rg350-96c6ae041fdb14ad557abdb2d95fe2cd62f17a97.zip | |
Added save/load stub for Gob3, recognizing the use of "INTRO.$$$" as an extra background buffer
svn-id: r26386
| -rw-r--r-- | engines/gob/inter.h | 3 | ||||
| -rw-r--r-- | engines/gob/inter_bargon.cpp | 3 | ||||
| -rw-r--r-- | engines/gob/inter_v1.cpp | 3 | ||||
| -rw-r--r-- | engines/gob/inter_v2.cpp | 23 | ||||
| -rw-r--r-- | engines/gob/inter_v3.cpp | 137 | 
5 files changed, 145 insertions, 24 deletions
| diff --git a/engines/gob/inter.h b/engines/gob/inter.h index d0f07d96da..e05fc6f8dc 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -472,6 +472,9 @@ protected:  	virtual const char *getOpcodeGoblinDesc(int i);  	bool o3_getTotTextItemPart(OpFuncParams ¶ms); +	bool o3_checkData(OpFuncParams ¶ms); +	bool o3_readData(OpFuncParams ¶ms); +	bool o3_writeData(OpFuncParams ¶ms);  };  } // End of namespace Gob diff --git a/engines/gob/inter_bargon.cpp b/engines/gob/inter_bargon.cpp index 8476dfc8c6..de52eb270e 100644 --- a/engines/gob/inter_bargon.cpp +++ b/engines/gob/inter_bargon.cpp @@ -692,8 +692,7 @@ void Inter_Bargon::executeGoblinOpcode(int i, OpGobParams ¶ms) {  		val = load16();  		_vm->_global->_inter_execPtr += val << 1;  		warning("unimplemented opcodeGob: %d", i); -	} -	else +	} else  		(this->*op) (params);  } diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index f5627369f6..ebeaec481b 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -697,8 +697,7 @@ void Inter_v1::executeGoblinOpcode(int i, OpGobParams ¶ms) {  		_vm->_global->_inter_execPtr -= 2;  		int16 cmd = load16();  		_vm->_global->_inter_execPtr += cmd * 2; -	} -	else +	} else  		(this->*op) (params);  } diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index a297d88891..5ac41a5007 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -699,8 +699,7 @@ void Inter_v2::executeGoblinOpcode(int i, OpGobParams ¶ms) {  		_vm->_global->_inter_execPtr -= 2;  		val = load16();  		_vm->_global->_inter_execPtr += val << 1; -	} -	else +	} else  		(this->*op) (params);  } @@ -831,8 +830,7 @@ void Inter_v2::o2_setRenderFlags() {  	if (expr & 0x8000) {  		_vm->_draw->_renderFlags |= expr & 0x3FFF; -	} -	else { +	} else {  		if (expr & 0x4000)  			_vm->_draw->_renderFlags &= expr & 0x3FFF;  		else @@ -1587,8 +1585,7 @@ bool Inter_v2::o2_evaluateStore(OpFuncParams ¶ms) {  	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 @@ bool Inter_v2::o2_checkData(OpFuncParams ¶ms) {  	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 @@ bool Inter_v2::o2_checkData(OpFuncParams ¶ms) {  		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 @@ bool Inter_v2::o2_readData(OpFuncParams ¶ms) {  	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;  	} diff --git a/engines/gob/inter_v3.cpp b/engines/gob/inter_v3.cpp index e78f5df4dd..c1c73ab524 100644 --- a/engines/gob/inter_v3.cpp +++ b/engines/gob/inter_v3.cpp @@ -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 @@ void Inter_v3::setupOpcodes() {  		OPCODE(o1_waitEndPlay),  		OPCODE(o1_playComposition),  		OPCODE(o2_getFreeMem), -		OPCODE(o2_checkData), +		OPCODE(o3_checkData),  		/* 40 */  		{NULL, ""},  		OPCODE(o1_prepareStr), @@ -534,8 +536,8 @@ void Inter_v3::setupOpcodes() {  		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 @@ void Inter_v3::executeGoblinOpcode(int i, OpGobParams ¶ms) {  		_vm->_global->_inter_execPtr -= 2;  		val = load16();  		_vm->_global->_inter_execPtr += val << 1; -	} -	else +	} else  		(this->*op) (params);  } @@ -881,4 +882,130 @@ bool Inter_v3::o3_getTotTextItemPart(OpFuncParams ¶ms) {  	return false;  } +bool Inter_v3::o3_checkData(OpFuncParams ¶ms) { +	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 ¶ms) { +	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 ¶ms) { +	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 | 
