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

kirben at users.sourceforge.net kirben at users.sourceforge.net
Tue Oct 3 16:02:20 CEST 2006


Revision: 24099
          http://svn.sourceforge.net/scummvm/?rev=24099&view=rev
Author:   kirben
Date:     2006-10-03 07:02:14 -0700 (Tue, 03 Oct 2006)

Log Message:
-----------
Cleanup

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

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2006-10-03 13:40:05 UTC (rev 24098)
+++ scummvm/trunk/engines/agos/agos.cpp	2006-10-03 14:02:14 UTC (rev 24099)
@@ -1362,30 +1362,29 @@
 	return NULL;
 }
 
-void AGOSEngine::loadZone(uint vga_res) {
+void AGOSEngine::loadZone(uint zoneNum) {
 	VgaPointersEntry *vpe;
-	uint32 size;
 
-	CHECK_BOUNDS(vga_res, _vgaBufferPointers);
+	CHECK_BOUNDS(zoneNum, _vgaBufferPointers);
 
-	vpe = _vgaBufferPointers + vga_res;
+	vpe = _vgaBufferPointers + zoneNum;
 	if (vpe->vgaFile1 != NULL)
 		return;
 
 	// Loading order is important
 	// due to resource managment
 
-	loadVGAFile(vga_res * 2, 2, size);
+	loadVGAFile(zoneNum, 2);
 	vpe->vgaFile2 = _block;
 	vpe->vgaFile2End = _blockEnd;
 
-	loadVGAFile(vga_res * 2, 1, size);
+	loadVGAFile(zoneNum, 1);
 	vpe->vgaFile1 = _block;
 	vpe->vgaFile1End = _blockEnd;
 
 	vpe->sfxFile = NULL;
 	if (!(getFeatures() & GF_ZLIBCOMP)) {
-		loadVGAFile(vga_res * 2, 3, size);
+		loadVGAFile(zoneNum, 3);
 		vpe->sfxFile = _block;
 		vpe->sfxFileEnd = _blockEnd;
 	}

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2006-10-03 13:40:05 UTC (rev 24098)
+++ scummvm/trunk/engines/agos/agos.h	2006-10-03 14:02:14 UTC (rev 24099)
@@ -728,7 +728,7 @@
 
 	void set_video_mode_internal(uint16 mode, uint16 vga_res_id);
 
-	void loadZone(uint vga_res);
+	void loadZone(uint zoneNum);
 
 	void loadSprite(uint windowNum, uint vga_res, uint vga_sprite_id, uint x, uint y, uint palette);
 	void playSpeech(uint speech_id, uint vga_sprite_id);
@@ -1136,8 +1136,8 @@
 	byte *getBackGround();
 	byte *getScaleBuf();
 
-	byte *loadVGAFile(uint id, uint type, uint32 &dstSize);
-	void loadSimonVGAFile(uint vga_id);
+	void loadVGAFile(uint id, uint type);
+	void loadSimonVGAFile(uint id);
 
 	int init();
 	int go();

Modified: scummvm/trunk/engines/agos/res.cpp
===================================================================
--- scummvm/trunk/engines/agos/res.cpp	2006-10-03 13:40:05 UTC (rev 24098)
+++ scummvm/trunk/engines/agos/res.cpp	2006-10-03 14:02:14 UTC (rev 24099)
@@ -554,24 +554,24 @@
 #undef SD_TYPE_LITERAL
 #undef SD_TYPE_MATCH
 
-void AGOSEngine::loadSimonVGAFile(uint vga_id) {
+void AGOSEngine::loadSimonVGAFile(uint id) {
 	uint32 offs, size;
 
 	if (getFeatures() & GF_OLD_BUNDLE) {
 		File in;
 		char filename[15];
-		if (vga_id == 23)
-			vga_id = 112;
-		if (vga_id == 328)
-			vga_id = 119;
+		if (id == 23)
+			id = 112;
+		else if (id == 328)
+			id = 119;
 
 		if (getPlatform() == Common::kPlatformAmiga) {
 			if (getFeatures() & GF_TALKIE)
-				sprintf(filename, "0%d.out", vga_id);
+				sprintf(filename, "0%d.out", id);
 			else 
-				sprintf(filename, "0%d.pkd", vga_id);
+				sprintf(filename, "0%d.pkd", id);
 		} else {
-			sprintf(filename, "0%d.VGA", vga_id);
+			sprintf(filename, "0%d.VGA", id);
 		}
 
 		in.open(filename);
@@ -591,18 +591,18 @@
 		}
 		in.close();
 	} else {
-		offs = _gameOffsetsPtr[vga_id];
+		offs = _gameOffsetsPtr[id];
 
-		size = _gameOffsetsPtr[vga_id + 1] - offs;
+		size = _gameOffsetsPtr[id + 1] - offs;
 		readGameFile(_vgaBufferPointers[11].vgaFile2, offs, size);
 	}
 }
 
-byte *AGOSEngine::loadVGAFile(uint id, uint type, uint32 &dstSize) {
+void AGOSEngine::loadVGAFile(uint id, uint type) {
 	File in;
 	char filename[15];
 	byte *dst = NULL;
-	uint32 file, offs, srcSize;
+	uint32 file, offs, srcSize, dstSize;
 	uint extraBuffer = 0;
 
 	if (getGameType() == GType_PP) {
@@ -618,11 +618,7 @@
 	}
 
 	if (getFeatures() & GF_ZLIBCOMP) {
-		if (getPlatform() == Common::kPlatformAmiga) {
-			loadOffsets((const char*)"gfxindex.dat", id / 2 * 3 + type, file, offs, srcSize, dstSize);
-		} else {
-			loadOffsets((const char*)"graphics.vga", id / 2 * 3 + type, file, offs, srcSize, dstSize);
-		}
+		loadOffsets(getFileName(GAME_GFXIDXFILE), id * 3 + type, file, offs, srcSize, dstSize);
 
 		if (getPlatform() == Common::kPlatformAmiga)
 			sprintf(filename, "GFX%d.VGA", file);
@@ -634,52 +630,46 @@
 	} else if (getFeatures() & GF_OLD_BUNDLE) {
 		if (getPlatform() == Common::kPlatformAmiga) {
 			if (getFeatures() & GF_TALKIE)
-				sprintf(filename, "%.3d%d.out", id / 2, type);
+				sprintf(filename, "%.3d%d.out", id, type);
 			else
-				sprintf(filename, "%.3d%d.pkd", id / 2, type);
+				sprintf(filename, "%.3d%d.pkd", id, type);
 		} else {
 			if (getGameType() == GType_ELVIRA || getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) {
-				sprintf(filename, "%.2d%d.VGA", id / 2, type);
+				sprintf(filename, "%.2d%d.VGA", id, type);
 			} else {
-				sprintf(filename, "%.3d%d.VGA", id / 2, type);
+				sprintf(filename, "%.3d%d.VGA", id, type);
 			}
 		}
 
 		in.open(filename);
-		if (in.isOpen() == false) {
-			if (type == 3) 
-				return NULL;
-			else
-				error("loadVGAFile: Can't load %s", filename);
-		}
+		if (in.isOpen() == true) {
+			dstSize = srcSize = in.size();
+			if (getFeatures() & GF_CRUNCHED) {
+				byte *srcBuffer = (byte *)malloc(srcSize);
+				if (in.read(srcBuffer, srcSize) != srcSize)
+					error("loadVGAFile: Read failed");
 
-		dstSize = srcSize = in.size();
-		if (getFeatures() & GF_CRUNCHED) {
-			byte *srcBuffer = (byte *)malloc(srcSize);
-			if (in.read(srcBuffer, srcSize) != srcSize)
-				error("loadVGAFile: Read failed");
-
-			dstSize = READ_BE_UINT32(srcBuffer + srcSize - 4);
-			dst = allocBlock (dstSize + extraBuffer);
-			decrunchFile(srcBuffer, dst, srcSize);
-			free(srcBuffer);
-		} else {
-			dst = allocBlock(dstSize + extraBuffer);
-			if (in.read(dst, dstSize) != dstSize)
-				error("loadVGAFile: Read failed");
+				dstSize = READ_BE_UINT32(srcBuffer + srcSize - 4);
+				dst = allocBlock (dstSize + extraBuffer);
+				decrunchFile(srcBuffer, dst, srcSize);
+				free(srcBuffer);
+			} else {
+				dst = allocBlock(dstSize + extraBuffer);
+				if (in.read(dst, dstSize) != dstSize)
+					error("loadVGAFile: Read failed");
+			}
+			in.close();
+		} else if (type != 3) {
+			error("loadVGAFile: Can't load %s", filename);
 		}
-		in.close();
 	} else {
-		id += (type - 1);
+		id = id * 2 + (type - 1);
 		offs = _gameOffsetsPtr[id];
 
 		dstSize = _gameOffsetsPtr[id + 1] - offs;
 		dst = allocBlock(dstSize + extraBuffer);
 		readGameFile(dst, offs, dstSize);
 	}
-
-	dstSize += extraBuffer;
-	return dst;
 }
 
 static const char *dimpSoundList[32] = {


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