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

kirben at users.sourceforge.net kirben at users.sourceforge.net
Mon Oct 16 06:31:17 CEST 2006


Revision: 24344
          http://svn.sourceforge.net/scummvm/?rev=24344&view=rev
Author:   kirben
Date:     2006-10-15 21:31:09 -0700 (Sun, 15 Oct 2006)

Log Message:
-----------
Auto decrunch the gamexx file when required

Modified Paths:
--------------
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/game.cpp
    scummvm/trunk/engines/agos/intern.h
    scummvm/trunk/engines/agos/res.cpp
    scummvm/trunk/engines/agos/subroutine.cpp

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2006-10-15 21:50:34 UTC (rev 24343)
+++ scummvm/trunk/engines/agos/agos.h	2006-10-16 04:31:09 UTC (rev 24344)
@@ -41,7 +41,7 @@
 //#define DUMP_FILE_NR 8
 //#define DUMP_BITMAPS_FILE_NR 8
 
-uint fileReadItemID(Common::File *in);
+uint fileReadItemID(Common::SeekableReadStream *in);
 
 #define CHECK_BOUNDS(x, y) assert((uint)(x) < ARRAYSIZE(y))
 
@@ -532,15 +532,16 @@
 	uint16 readUint16Wrapper(const void *src);
 	uint32 readUint32Wrapper(const void *src);
 
-	int allocGamePcVars(Common::File *in);
+	int allocGamePcVars(Common::SeekableReadStream *in);
 	void createPlayer();
 	void allocateStringTable(int num);
 	void setupStringTable(byte *mem, int num);
 	void setupLocalStringTable(byte *mem, int num);
-	void readGamePcText(Common::File *in);
-	void readItemChildren(Common::File *in, Item *item, uint tmp);
-	void readItemFromGamePc(Common::File *in, Item *item);
+	void readGamePcText(Common::SeekableReadStream *in);
+	void readItemChildren(Common::SeekableReadStream *in, Item *item, uint tmp);
+	void readItemFromGamePc(Common::SeekableReadStream *in, Item *item);
 	void loadGamePcFile();
+	void readGamePcFile(Common::SeekableReadStream *in);
 	void decompressData(const char *srcName, byte *dst, uint32 offset, uint32 srcSize, uint32 dstSize);
 	void loadOffsets(const char *filename, int number, uint32 &file, uint32 &offset, uint32 &compressedSize, uint32 &size);
 	void loadSound(uint sound, int pan, int vol, uint type);
@@ -564,11 +565,11 @@
 	void allocTablesHeap();
 
 	Subroutine *createSubroutine(uint a);
-	void readSubroutine(Common::File *in, Subroutine *sub);
+	void readSubroutine(Common::SeekableReadStream *in, Subroutine *sub);
 	SubroutineLine *createSubroutineLine(Subroutine *sub, int a);
-	void readSubroutineLine(Common::File *in, SubroutineLine *new_table, Subroutine *sub);
-	byte *readSingleOpcode(Common::File *in, byte *ptr);
-	void readSubroutineBlock(Common::File *in);
+	void readSubroutineLine(Common::SeekableReadStream *in, SubroutineLine *new_table, Subroutine *sub);
+	byte *readSingleOpcode(Common::SeekableReadStream *in, byte *ptr);
+	void readSubroutineBlock(Common::SeekableReadStream *in);
 
 	Subroutine *getSubroutineByID(uint subroutine_id);
 

Modified: scummvm/trunk/engines/agos/game.cpp
===================================================================
--- scummvm/trunk/engines/agos/game.cpp	2006-10-15 21:50:34 UTC (rev 24343)
+++ scummvm/trunk/engines/agos/game.cpp	2006-10-16 04:31:09 UTC (rev 24344)
@@ -225,7 +225,7 @@
 };
 
 static const ADGameFileDescription WAXWORKSAMIGA_GameFiles[] = {
-	{ "gameamiga",		GAME_BASEFILE,	"e6207a69cf7356f13acbe8d14bdd844e"},  // Unpacked version
+	{ "gameamiga",		GAME_BASEFILE,	"eca24fe7c3e005caca47cecac56f7245"},
 	{ "icon.pkd",		GAME_ICONFILE,	"4822a91c18b1b2005ac17fc617f7dcbe"},
 	{ "menus.dat",		GAME_MENUFILE,	"3409eeb8ca8b46fc04da99de67573f5e"},
 	{ "stripped.txt",	GAME_STRFILE,	"6faaebff2786216900061eeb978f10af"},
@@ -267,7 +267,7 @@
 };
 
 static const ADGameFileDescription SIMON1AMIGA_ECS_DEMO_GameFiles[] = {
-	{ "gameamiga",		GAME_BASEFILE,	"a12b696170f14eca5ff75f1549829251"},  // Unpacked version
+	{ "gameamiga",		GAME_BASEFILE,	"4696309eed9d7335c62ebb87a0f006ad"},
 	{ "icon.pkd",		GAME_ICONFILE,	"ebc96af15bfaf75ba8210326b9260d2f"},
 	{ "stripped.txt",	GAME_STRFILE,	"8edde5b9498dc9f31da1093028da467c"},
 	{ "tbllist",		GAME_TBLFILE,	"1247e024e1f13ca54c1e354120c7519c"},
@@ -851,7 +851,7 @@
 
 		GType_WW,
 		GID_WAXWORKS,
-		GF_OLD_BUNDLE | GF_CRUNCHED,
+		GF_OLD_BUNDLE | GF_CRUNCHED | GF_CRUNCHED_GAMEPC,
 	},
 
 	// Waxworks - English DOS Floppy
@@ -931,7 +931,7 @@
 
 		GType_SIMON1,
 		GID_SIMON1AMIGA,
-		GF_32COLOR | GF_CRUNCHED | GF_OLD_BUNDLE | GF_DEMO,
+		GF_32COLOR | GF_CRUNCHED | GF_CRUNCHED_GAMEPC | GF_OLD_BUNDLE | GF_DEMO,
 	},
 
 	// Simon the Sorcerer 1 - English Amiga AGA Floppy

Modified: scummvm/trunk/engines/agos/intern.h
===================================================================
--- scummvm/trunk/engines/agos/intern.h	2006-10-15 21:50:34 UTC (rev 24343)
+++ scummvm/trunk/engines/agos/intern.h	2006-10-16 04:31:09 UTC (rev 24344)
@@ -205,12 +205,13 @@
 };
 
 enum GameFeatures {
-	GF_TALKIE     = 1 << 0,
-	GF_OLD_BUNDLE = 1 << 1,
-	GF_CRUNCHED   = 1 << 2,
-	GF_ZLIBCOMP   = 1 << 3,
-	GF_32COLOR    = 1 << 4,
-	GF_DEMO       = 1 << 5
+	GF_TALKIE           = 1 << 0,
+	GF_OLD_BUNDLE      = 1 << 1,
+	GF_CRUNCHED        = 1 << 2,
+	GF_CRUNCHED_GAMEPC = 1 << 3,
+	GF_ZLIBCOMP        = 1 << 4,
+	GF_32COLOR         = 1 << 5,
+	GF_DEMO            = 1 << 6
 };
 
 enum GameFileTypes {

Modified: scummvm/trunk/engines/agos/res.cpp
===================================================================
--- scummvm/trunk/engines/agos/res.cpp	2006-10-15 21:50:34 UTC (rev 24343)
+++ scummvm/trunk/engines/agos/res.cpp	2006-10-16 04:31:09 UTC (rev 24344)
@@ -108,7 +108,7 @@
 	in.close();
 }
 
-int AGOSEngine::allocGamePcVars(File *in) {
+int AGOSEngine::allocGamePcVars(Common::SeekableReadStream *in) {
 	uint item_array_size, item_array_inited, stringtable_num;
 	uint32 version;
 	uint i;
@@ -118,11 +118,12 @@
 	item_array_inited = in->readUint32BE();
 	stringtable_num = in->readUint32BE();
 
+	// First two items are predefined
 	if (getGameType() == GType_ELVIRA1 || getGameType() == GType_ELVIRA2) {
 		item_array_size += 2;
 		item_array_inited = item_array_size;
 	} else {
-		item_array_inited += 2;				// first two items are predefined
+		item_array_inited += 2;		
 		item_array_size += 2;
 	}
 
@@ -149,27 +150,34 @@
 
 void AGOSEngine::loadGamePcFile() {
 	Common::File in;
-	int num_inited_objects;
-	int i, fileSize;
+	int fileSize;
 
-	/* read main gamepc file */
-	in.open(getFileName(GAME_BASEFILE));
-	if (in.isOpen() == false) {
-		error("loadGamePcFile: Can't load gamepc file '%s'", getFileName(GAME_BASEFILE));
-	}
+	if (getFileName(GAME_BASEFILE) != NULL) {
+		/* Read main gamexx file */
+		in.open(getFileName(GAME_BASEFILE));
+		if (in.isOpen() == false) {
+			error("loadGamePcFile: Can't load gamexx file '%s'", getFileName(GAME_BASEFILE));
+		}
 
-	num_inited_objects = allocGamePcVars(&in);
+		if (getFeatures() & GF_CRUNCHED_GAMEPC) {
+			uint srcSize = in.size();
+			byte *srcBuf = (byte *)malloc(srcSize);
+			in.read(srcBuf, srcSize);
 
-	createPlayer();
-	readGamePcText(&in);
+			uint dstSize = READ_BE_UINT32(srcBuf + srcSize - 4);
+			byte *dstBuf = (byte *)malloc(dstSize);
+			decrunchFile(srcBuf, dstBuf, srcSize);
+			free(srcBuf);
 
-	for (i = 2; i < num_inited_objects; i++) {
-		readItemFromGamePc(&in, _itemArrayPtr[i]);
+			Common::MemoryReadStream stream(dstBuf, dstSize);
+			readGamePcFile(&stream);
+			free(dstBuf);
+		} else {
+			readGamePcFile(&in);
+		}
+		in.close();
 	}
 
-	readSubroutineBlock(&in);
-	in.close();
-
 	if (getFileName(GAME_TBLFILE) != NULL) {
 		/* Read list of TABLE resources */
 		in.open(getFileName(GAME_TBLFILE));
@@ -243,7 +251,23 @@
 	}
 }
 
-void AGOSEngine::readGamePcText(Common::File *in) {
+void AGOSEngine::readGamePcFile(Common::SeekableReadStream *in) {
+	int num_inited_objects;
+	int i;
+
+	num_inited_objects = allocGamePcVars(in);
+
+	createPlayer();
+	readGamePcText(in);
+
+	for (i = 2; i < num_inited_objects; i++) {
+		readItemFromGamePc(in, _itemArrayPtr[i]);
+	}
+
+	readSubroutineBlock(in);
+}
+
+void AGOSEngine::readGamePcText(Common::SeekableReadStream *in) {
 	_textSize = in->readUint32BE();
 	_textMem = (byte *)malloc(_textSize);
 	if (_textMem == NULL)
@@ -254,7 +278,7 @@
 	setupStringTable(_textMem, _stringTabNum);
 }
 
-void AGOSEngine::readItemFromGamePc(Common::File *in, Item *item) {
+void AGOSEngine::readItemFromGamePc(Common::SeekableReadStream *in, Item *item) {
 	uint32 type;
 
 	if (getGameType() == GType_ELVIRA1) {
@@ -303,7 +327,7 @@
 	}
 }
 
-void AGOSEngine::readItemChildren(Common::File *in, Item *item, uint type) {
+void AGOSEngine::readItemChildren(Common::SeekableReadStream *in, Item *item, uint type) {
 	if (type == 1) {
 		if (getGameType() == GType_ELVIRA1) {
 			SubRoom *subRoom = (SubRoom *)allocateChildBlock(item, 1, sizeof(SubRoom));
@@ -435,7 +459,7 @@
 	}
 }
 
-uint fileReadItemID(Common::File *in) {
+uint fileReadItemID(Common::SeekableReadStream *in) {
 	uint32 val = in->readUint32BE();
 	if (val == 0xFFFFFFFF)
 		return 0;

Modified: scummvm/trunk/engines/agos/subroutine.cpp
===================================================================
--- scummvm/trunk/engines/agos/subroutine.cpp	2006-10-15 21:50:34 UTC (rev 24343)
+++ scummvm/trunk/engines/agos/subroutine.cpp	2006-10-16 04:31:09 UTC (rev 24344)
@@ -579,18 +579,18 @@
 	return true;
 }
 
-void AGOSEngine::readSubroutineBlock(File *in) {
+void AGOSEngine::readSubroutineBlock(Common::SeekableReadStream *in) {
 	while (in->readUint16BE() == 0) {
 		readSubroutine(in, createSubroutine(in->readUint16BE()));
 	}
 }
-void AGOSEngine::readSubroutine(File *in, Subroutine *sub) {
+void AGOSEngine::readSubroutine(Common::SeekableReadStream *in, Subroutine *sub) {
 	while (in->readUint16BE() == 0) {
 		readSubroutineLine(in, createSubroutineLine(sub, 0xFFFF), sub);
 	}
 }
 
-void AGOSEngine::readSubroutineLine(File *in, SubroutineLine *sl, Subroutine *sub) {
+void AGOSEngine::readSubroutineLine(Common::SeekableReadStream *in, SubroutineLine *sl, Subroutine *sub) {
 	byte line_buffer[2048], *q = line_buffer;
 	int size;
 
@@ -634,7 +634,7 @@
 	}
 }
 
-byte *AGOSEngine::readSingleOpcode(Common::File *in, byte *ptr) {
+byte *AGOSEngine::readSingleOpcode(Common::SeekableReadStream *in, byte *ptr) {
 	int i, l;
 	const char *string_ptr;
 	uint opcode, val;


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