[Scummvm-cvs-logs] CVS: tools kyra_unpak.cpp,NONE,1.1 kyra_unpak.h,NONE,1.1 Makefile,1.39,1.40 Makefile.mingw,1.20,1.21 README,1.25,1.26
James Brown
ender at users.sourceforge.net
Sun Nov 7 08:03:44 CET 2004
Update of /cvsroot/scummvm/tools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22462
Modified Files:
Makefile Makefile.mingw README
Added Files:
kyra_unpak.cpp kyra_unpak.h
Log Message:
Add tool for extracting files from Kyrandia .pak archives
--- NEW FILE: kyra_unpak.cpp ---
/* UnPak - Extractor for Kyrandia .pak archives
* Copyright (C) 2004- Johannes Schickel
* Copyright (C) 2004- The ScummVM Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /cvsroot/scummvm/tools/kyra_unpak.cpp,v 1.1 2004/11/07 15:57:46 ender Exp $
*
*/
#include "kyra_unpak.h"
int main(int argc, char **argv) {
if (argc < 2) {
printf("Use:\n"
"%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",
argv[0]);
return false;
}
bool extractAll = false, extractOne = false;
uint8 param = 0;
// looking for the parameters
for (int32 pos = 1; pos < argc; ++pos) {
if (*argv[pos] == '-') {
if (argv[pos][1] == 'o') {
extractOne = true;
param = pos + 1;
if (param >= argc) {
printf("you have to add a filename to option -o\n"
"like: unpackkyra A_E.PAK -o ALGAE.CPS\n");
return false;
}
++pos;
} else if (argv[pos][1] == 'x') {
extractAll = true;
}
}
}
PAKFile myfile(argv[1]);
if(extractAll) {
myfile.outputAllFiles();
} else if(extractOne) {
myfile.outputFile(argv[param]);
} else {
myfile.drawFilelist();
}
return true;
}
PAKFile::PAKFile(const char* file) {
FILE* pakfile = fopen(file, "r");
if (!pakfile) {
error("couldn't open file '%s'", file);
}
_open = true;
_buffer = new uint8[fileSize(pakfile)];
assert(_buffer);
_filesize = fileSize(pakfile);
fread(_buffer, fileSize(pakfile), 1, pakfile);
fclose(pakfile);
}
void PAKFile::drawFilelist(void) {
const char* currentName = 0;
uint32 startoffset = *(uint32*)_buffer;
uint32 endoffset = 0;
uint8* position = _buffer + 4;
for (;;) {
uint32 strlgt = strlen((const char*)position);
currentName = (const char*)position;
if (!(*currentName))
break;
position += strlgt + 1;
// scip offset
endoffset = *(uint32*)position;
if (endoffset > _filesize) {
endoffset = _filesize;
} else if (endoffset == 0) {
endoffset = _filesize;
}
position += 4;
printf("Filename: %s size: %d\n", currentName, endoffset - startoffset);
if (endoffset == _filesize) {
break;
}
startoffset = endoffset;
}
}
void PAKFile::outputFile(const char* file) {
const char* currentName = 0;
uint32 startoffset = *(uint32*)_buffer;
uint32 endoffset = 0;
uint8* position = _buffer + 4;
for (;;) {
uint32 strlgt = strlen((const char*)position);
currentName = (const char*)position;
if (!(*currentName))
break;
position += strlgt + 1;
// scip offset
endoffset = *(uint32*)position;
if (endoffset > _filesize) {
endoffset = _filesize;
} else if (endoffset == 0) {
endoffset = _filesize;
}
position += 4;
if (!strcmp(currentName, file)) {
FILE* output = fopen(file, "wb+");
fwrite(_buffer + startoffset, endoffset - startoffset, 1,output);
fclose(output);
return;
}
if (endoffset == _filesize) {
break;
}
startoffset = endoffset;
}
printf("File '%s' not found in this pakfile", file);
}
void PAKFile::outputAllFiles(void) {
const char* currentName = 0;
uint32 startoffset = *(uint32*)_buffer;
uint32 endoffset = 0;
uint8* position = _buffer + 4;
for (;;) {
uint32 strlgt = strlen((const char*)position);
currentName = (const char*)position;
if (!(*currentName))
break;
position += strlgt + 1;
// scip offset
endoffset = *(uint32*)position;
if (endoffset > _filesize) {
endoffset = _filesize;
} else if (endoffset == 0) {
endoffset = _filesize;
}
position += 4;
FILE* output = fopen(currentName, "wb+");
fwrite(_buffer + startoffset, endoffset - startoffset, 1,output);
fclose(output);
if (endoffset == _filesize) {
break;
}
startoffset = endoffset;
}
}
--- NEW FILE: kyra_unpak.h ---
/* UnPak - Extractor for Kyrandia .pak archives
* Copyright (C) 2004- Johannes Schickel
* Copyright (C) 2004- The ScummVM Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /cvsroot/scummvm/tools/kyra_unpak.h,v 1.1 2004/11/07 15:57:46 ender Exp $
*
*/
#ifndef UNPAK_H
#define UNPAK_H
#include "util.h"
// standard Package format for Kyrandia games
class PAKFile {
public:
PAKFile(const char* file);
~PAKFile() { delete [] _buffer; }
void drawFilelist(void);
void outputAllFiles(void);
void outputFile(const char* file);
bool isValid(void) {return (_buffer != 0);}
bool isOpen(void) {return _open;}
private:
bool _open;
uint8* _buffer; // the whole file
uint32 _filesize;
};
#endif
Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/tools/Makefile,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- Makefile 15 Oct 2004 15:22:21 -0000 1.39
+++ Makefile 7 Nov 2004 15:57:46 -0000 1.40
@@ -21,6 +21,7 @@
descumm$(EXEEXT) \
desword2$(EXEEXT) \
dekyra$(EXEEXT) \
+ kyra_unpak$(EXEEXT) \
extract$(EXEEXT) \
loom_tg16_extract$(EXEEXT) \
md5table$(EXEEXT) \
@@ -50,6 +51,9 @@
dekyra$(EXEEXT): dekyra.o util.o
$(CXX) $(LDFLAGS) -o $@ $+
+kyra_unpak$(EXEEXT): kyra_unpak.o util.o
+ $(CXX) $(LDFLAGS) -o $@ $+
+
extract$(EXEEXT): extract.o extract-common.o util.o
$(CC) $(LDFLAGS) -o $@ $+
Index: Makefile.mingw
===================================================================
RCS file: /cvsroot/scummvm/tools/Makefile.mingw,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- Makefile.mingw 16 Oct 2004 00:43:08 -0000 1.20
+++ Makefile.mingw 7 Nov 2004 15:57:46 -0000 1.21
@@ -11,6 +11,7 @@
strip compress_san.exe -o $(SCUMMVMPATH)/tools/compress_san.exe
strip convbdf.exe -o $(SCUMMVMPATH)/tools/convbdf.exe
strip dekyra.exe -o $(SCUMMVMPATH)/tools/dekyra.exe
+ strip kyra_unpak.exe -o $(SCUMMVMPATH)/tools/kyra_unpak.exe
strip descumm.exe -o $(SCUMMVMPATH)/tools/descumm.exe
strip desword2.exe -o $(SCUMMVMPATH)/tools/desword2.exe
strip extract.exe -o $(SCUMMVMPATH)/tools/extract.exe
Index: README
===================================================================
RCS file: /cvsroot/scummvm/tools/README,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- README 15 Oct 2004 15:22:21 -0000 1.25
+++ README 7 Nov 2004 15:57:46 -0000 1.26
@@ -7,6 +7,9 @@
example.
Extraction Tools:
+ kyra_unpak
+ Unpacks .PAK files from Kyrandia games
+
rescumm
Extracts Macintosh "single file" SCUMM games into their
component parts, for use with ScummVM.
@@ -63,8 +66,8 @@
desword2
Disassembles Broken Sword II scripts
- dekyra
- Basic script disassembler for Legend of Kyrandia games
+ dekyra
+ Basic script disassembler for Legend of Kyrandia games
Other tools:
simon1decr
More information about the Scummvm-git-logs
mailing list