[Scummvm-cvs-logs] SF.net SVN: scummvm: [24378] tools/trunk

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Wed Oct 18 21:01:35 CEST 2006


Revision: 24378
          http://svn.sourceforge.net/scummvm/?rev=24378&view=rev
Author:   lordhoto
Date:     2006-10-18 12:01:29 -0700 (Wed, 18 Oct 2006)

Log Message:
-----------
Added support for Amiga files in extract_kyra.

Modified Paths:
--------------
    tools/trunk/extract_kyra.cpp
    tools/trunk/extract_kyra.h

Modified: tools/trunk/extract_kyra.cpp
===================================================================
--- tools/trunk/extract_kyra.cpp	2006-10-18 19:00:16 UTC (rev 24377)
+++ tools/trunk/extract_kyra.cpp	2006-10-18 19:01:29 UTC (rev 24378)
@@ -29,12 +29,14 @@
 				"%s filename [OPTIONS]\n"
 				"Here are the options, default is listing files to stdout\n"
 				"-o xxx   Extract only file 'xxx'\n"
-				"-x       Extract all files\n",
+				"-x       Extract all files\n"
+				"-a       Use this if you want to extract files from the Amiga .PAK files\n",
 				argv[0]);
 		return false;
 	}
 	
 	bool extractAll = false, extractOne = false;
+	bool isAmiga = false;
 	uint8 param = 0;
 	
 	// looking for the parameters
@@ -53,11 +55,13 @@
 				++pos;
 			} else if (argv[pos][1] == 'x') {
 				extractAll = true;
+			} else if (argv[pos][1] == 'a') {
+				isAmiga = true;
 			}
 		}
 	}
 
-	PAKFile myfile(argv[1]);
+	PAKFile myfile(argv[1], isAmiga);
 	
 	if(extractAll) {
 		myfile.outputAllFiles();
@@ -70,13 +74,14 @@
 	return true;
 }
 
-PAKFile::PAKFile(const char* file) {
+PAKFile::PAKFile(const char* file, bool isAmiga) {
 	FILE *pakfile = fopen(file, "rb");
 	if (!pakfile) {
 		error("couldn't open file '%s'", file);
 	}
 	
 	_open = true;
+	_isAmiga = isAmiga;
 	_filesize = fileSize(pakfile);
 
 	_buffer = new uint8[_filesize];
@@ -90,7 +95,7 @@
 void PAKFile::drawFilelist(void) {
 	const char* currentName = 0;
 	
-	uint32 startoffset = READ_LE_UINT32(_buffer);
+	uint32 startoffset = _isAmiga ? READ_BE_UINT32(_buffer) : READ_LE_UINT32(_buffer);
 	uint32 endoffset = 0;
 	uint8* position = _buffer + 4;
 	
@@ -103,7 +108,7 @@
 
 		position += strlgt + 1;
 		// skip offset
-		endoffset = READ_LE_UINT32(position);
+		endoffset = _isAmiga ? READ_BE_UINT32(position) : READ_LE_UINT32(position);
 		if (endoffset > _filesize) {
 			endoffset = _filesize;
 		} else if (endoffset == 0) {
@@ -124,7 +129,7 @@
 void PAKFile::outputFile(const char* file) {
 	const char* currentName = 0;
 	
-	uint32 startoffset = READ_LE_UINT32(_buffer);
+	uint32 startoffset = _isAmiga ? READ_BE_UINT32(_buffer) : READ_LE_UINT32(_buffer);
 	uint32 endoffset = 0;
 	uint8* position = _buffer + 4;
 	
@@ -135,9 +140,10 @@
 		if (!(*currentName))
 			break;
 
+
 		position += strlgt + 1;
 		// skip offset
-		endoffset = READ_LE_UINT32(position);
+		endoffset = _isAmiga ? READ_BE_UINT32(position) : READ_LE_UINT32(position);
 		if (endoffset > _filesize) {
 			endoffset = _filesize;
 		} else if (endoffset == 0) {
@@ -167,7 +173,7 @@
 void PAKFile::outputAllFiles(void) {
 	const char* currentName = 0;
 	
-	uint32 startoffset = READ_LE_UINT32(_buffer);
+	uint32 startoffset = _isAmiga ? READ_BE_UINT32(_buffer) : READ_LE_UINT32(_buffer);
 	uint32 endoffset = 0;
 	uint8* position = _buffer + 4;
 	
@@ -180,7 +186,7 @@
 
 		position += strlgt + 1;
 		// skip offset
-		endoffset = READ_LE_UINT32(position);
+		endoffset = _isAmiga ? READ_BE_UINT32(position) : READ_LE_UINT32(position);
 		if (endoffset > _filesize) {
 			endoffset = _filesize;
 		} else if (endoffset == 0) {

Modified: tools/trunk/extract_kyra.h
===================================================================
--- tools/trunk/extract_kyra.h	2006-10-18 19:00:16 UTC (rev 24377)
+++ tools/trunk/extract_kyra.h	2006-10-18 19:01:29 UTC (rev 24378)
@@ -29,7 +29,7 @@
 // standard Package format for Kyrandia games
 class PAKFile {
 	public:
-		PAKFile(const char* file);
+		PAKFile(const char* file, bool isAmiga);
 		~PAKFile() { delete [] _buffer; }
 		
 		void drawFilelist(void);
@@ -41,6 +41,7 @@
 
 	private:
 		bool _open;
+		bool _isAmiga;
 		uint8* _buffer; // the whole file	
 		uint32 _filesize;	
 };


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