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

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Thu May 14 01:38:12 CEST 2009


Revision: 40546
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40546&view=rev
Author:   strangerke
Date:     2009-05-13 23:38:11 +0000 (Wed, 13 May 2009)

Log Message:
-----------
Gob - Add a tool to create itk/stk archives. Compression and STK2.1 not yet implemented.

Modified Paths:
--------------
    tools/trunk/Makefile
    tools/trunk/Makefile.mingw
    tools/trunk/dist/msvc9/tools.sln

Added Paths:
-----------
    tools/trunk/compress_gob.cpp
    tools/trunk/dist/msvc9/compress_gob.vcproj

Modified: tools/trunk/Makefile
===================================================================
--- tools/trunk/Makefile	2009-05-13 23:08:36 UTC (rev 40545)
+++ tools/trunk/Makefile	2009-05-13 23:38:11 UTC (rev 40546)
@@ -59,6 +59,7 @@
 
 TARGETS := \
 	compress_agos$(EXEEXT) \
+	compress_gob$(EXEEXT) \
 	compress_kyra$(EXEEXT) \
 	compress_queen$(EXEEXT) \
 	compress_saga$(EXEEXT) \
@@ -116,6 +117,9 @@
 compress_agos$(EXEEXT): compress_agos.o compress.o util.o
 	$(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
 
+compress_gob$(EXEEXT): compress_gob.o util.o
+	$(CXX) $(LDFLAGS) -o $@ $+
+
 compress_kyra$(EXEEXT): compress_kyra.o kyra_pak.o compress.o util.o
 	$(CXX) $(LDFLAGS) -o $@ $+ -lvorbis -logg -lvorbisenc -lFLAC
 
@@ -170,6 +174,9 @@
 extract_agos$(EXEEXT): extract_agos.o
 	$(CXX) $(LDFLAGS) -o $@ $+
 
+extract_gob_stk$(EXEEXT): extract_gob_stk.o util.o
+	$(CXX) $(LDFLAGS) -o $@ $+
+
 extract_kyra$(EXEEXT): extract_kyra.o kyra_pak.o kyra_ins.o util.o
 	$(CXX) $(LDFLAGS) -o $@ $+
 
@@ -197,9 +204,6 @@
 extract_zak_c64$(EXEEXT): extract_zak_c64.o util.o
 	$(CXX) $(LDFLAGS) -o $@ $+
 
-extract_gob_stk$(EXEEXT): extract_gob_stk.o util.o
-	$(CXX) $(LDFLAGS) -o $@ $+
-
 tools_gui$(EXEEXT): tools_gui.o
 	$(CXX) $(LDFLAGS) -o $@ $+ `wx-config --libs`
 

Modified: tools/trunk/Makefile.mingw
===================================================================
--- tools/trunk/Makefile.mingw	2009-05-13 23:08:36 UTC (rev 40545)
+++ tools/trunk/Makefile.mingw	2009-05-13 23:38:11 UTC (rev 40546)
@@ -12,6 +12,7 @@
 	mkdir -p $(SCUMMVMPATH)
 	mkdir -p $(SCUMMVMPATH)/tools
 	strip compress_agos.exe -o $(SCUMMVMPATH)/tools/compress_agos.exe
+	strip compress_gob.exe -o $(SCUMMVMPATH)/tools/compress_gob.exe
 	strip compress_kyra.exe -o $(SCUMMVMPATH)/tools/compress_kyra.exe
 	strip compress_queen.exe -o $(SCUMMVMPATH)/tools/compress_queen.exe
 	strip compress_saga.exe -o $(SCUMMVMPATH)/tools/compress_saga.exe

Added: tools/trunk/compress_gob.cpp
===================================================================
--- tools/trunk/compress_gob.cpp	                        (rev 0)
+++ tools/trunk/compress_gob.cpp	2009-05-13 23:38:11 UTC (rev 40546)
@@ -0,0 +1,210 @@
+/* compress_gob - .stk/.itk archive creation tool, based on a conf file.
+ * Copyright (C) 2007 The ScummVM project
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "util.h"
+#define confSTK21 "STK21"
+#define confSTK10 "STK10"
+
+struct Chunk {
+	char name[64];
+	uint32 size, offset;
+	bool packed;
+
+	Chunk *next;
+
+	Chunk() : next(0) { }
+	~Chunk() { delete next; }
+};
+
+Chunk *readChunkConf (FILE *gobconf, uint16 &chunkCount);
+void *rewriteHeader (FILE *stk, uint16 chunkCount, Chunk *chunks);
+void *writeBody (FILE *stk, uint16 chunkcount, Chunk *chunks);
+
+Chunk *readChunkList(FILE *stk, FILE *gobConf);
+
+void extractChunks(FILE *stk, Chunk *chunks);
+byte *unpackData(byte *src, uint32 &size);
+
+int main(int argc, char **argv) {
+	char *outFilename;
+	char *tmpStr;
+	Chunk *chunks;
+	FILE *stk;
+	FILE *gobConf;
+	uint16 chunkCount;
+
+	if ((argc < 2) || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
+		printf("Usage: %s <Conf file>\n\n", argv[0]);
+		printf("The archive will be created into the current directory.\n");
+		return -1;
+	}
+
+	if (!(gobConf = fopen(argv[1], "r")))
+		error("Couldn't open conf file \"%s\"", argv[1]);
+
+	outFilename = new char[strlen(argv[1]) + 5];
+	strcpy(outFilename, argv[1]);
+	tmpStr = strstr(outFilename, ".");
+	if (tmpStr != 0)
+		strncpy(tmpStr, ".stk\0", 5);
+	else
+		strcat(outFilename, ".stk\0");
+
+	if (!(stk = fopen(outFilename, "wb")))
+		error("Couldn't create file \"%s\"", outFilename);
+
+	chunks = readChunkConf(gobConf, chunkCount);
+	fclose(gobConf);
+	
+	writeBody(stk, chunkCount, chunks);
+	rewriteHeader(stk, chunkCount, chunks);
+
+	delete chunks;
+	fclose(stk);
+	return 0;
+}
+
+void extractError(FILE *f1, FILE *f2, Chunk *chunks, const char *msg) {
+	if (f1)
+		fclose(f1);
+	if (f2)
+		fclose(f2);
+	delete chunks;
+
+	error(msg);
+}
+
+Chunk *readChunkConf(FILE *gobConf, uint16 &chunkCount) {
+	Chunk *chunks = new Chunk;
+	Chunk *curChunk = chunks;
+	char buffer [1024];
+
+	chunkCount = 1;
+
+// first read (signature, not yet used)
+	fscanf(gobConf, "%s", buffer);
+	fscanf(gobConf, "%s", buffer);
+	while (!feof(gobConf)) {
+		strcpy(curChunk->name, buffer);
+		fscanf(gobConf, "%s", buffer);
+		if (strcmp(buffer, "1") == 0) 
+			curChunk->packed = true;
+		else
+			curChunk->packed = false;
+
+		fscanf(gobConf, "%s", buffer);
+		if (!feof(gobConf)) {
+			curChunk->next = new Chunk;
+			curChunk = curChunk->next;
+			chunkCount++;
+		}
+	}
+	return chunks;
+}
+
+void *writeBody (FILE *stk, uint16 chunkCount, Chunk *chunks)
+{
+	Chunk *curChunk = chunks;
+	FILE *src;
+	char buffer[4096];
+	int count;
+
+	for (count = 0; count < 2 + (chunkCount * 22); count++) {
+		buffer[count] = '\0';
+	}
+	fwrite(buffer, 1, 2 + (chunkCount * 22), stk);
+
+	for (;;) {
+		if (!(src = fopen(curChunk->name, "rb")))
+			error("Couldn't open conf file \"%s\"", curChunk->name);
+		curChunk->size = 0;
+		for (;;) {
+			count=fread(buffer, 1, 4096, src);
+			fwrite(buffer, 1, count, stk);
+			curChunk->size += count;
+			if (count < 4096)
+				break;
+		}
+		printf("%s taille %d\n", curChunk->name, curChunk->size);
+		fclose(src);
+		if (curChunk->next != 0)
+			curChunk = curChunk->next;
+		else
+			break;
+	}
+	return 0;
+}
+
+void *rewriteHeader (FILE *stk, uint16 chunkCount, Chunk *chunks)
+{
+	uint16 i;
+	char buffer[1024];
+	Chunk *curChunk = chunks;
+	uint32 filPos;
+
+	rewind(stk);
+
+//	The structure of the header is the following :
+//+ 2 bytes : numbers of files archived in the .stk/.itk
+//	Then, for each files :
+//+ 13 bytes : the filename, terminated by '\0'. In original, there's 
+//  garbage after if the filename has not the maximum length
+//+ 4  bytes : size of the chunk
+//+ 4  bytes : start position of the chunk in the file
+//+ 1  byte  : If 0 : not compressed, if 1 : compressed
+	filPos = 2 + (chunkCount * 22);
+
+	buffer[0] = chunkCount & 0xFF;
+	buffer[1] = chunkCount >> 8;
+	fwrite(buffer, 1, 2, stk);
+	// TODO : Implement STK21
+	for (;;)
+	{
+		for (i = 0; i < 13; i++)
+			if (i < strlen(curChunk->name))
+				buffer[i] = curChunk->name[i];
+			else
+				buffer[i] = '\0';
+		fwrite(buffer, 1, 13, stk);
+		
+		buffer[0] = curChunk->size;
+		buffer[1] = curChunk->size >> 8;
+		buffer[2] = curChunk->size >> 16;
+		buffer[3] = curChunk->size >> 24;
+		buffer[4] = filPos;
+		buffer[5] = filPos >> 8;
+		buffer[6] = filPos >> 16;
+		buffer[7] = filPos >> 24;
+
+// Compression not yet implemented => always uncompressed
+//		buffer[8]=curChunk->packed?'\1':'\0';
+		buffer[8] = '\0';
+		fwrite(buffer, 1, 9, stk);
+		filPos += curChunk->size;
+
+		if (curChunk->next != 0)
+			curChunk = curChunk->next;
+		else
+			break;
+	}
+	return 0;
+}


Property changes on: tools/trunk/compress_gob.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: tools/trunk/dist/msvc9/compress_gob.vcproj
===================================================================
--- tools/trunk/dist/msvc9/compress_gob.vcproj	                        (rev 0)
+++ tools/trunk/dist/msvc9/compress_gob.vcproj	2009-05-13 23:38:11 UTC (rev 40546)
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="windows-1250"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9,00"
+	Name="compress_gob"
+	ProjectGUID="{8C4BC409-2EEC-41F5-A017-972F38414289}"
+	RootNamespace="compress_gob"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="Debug"
+			IntermediateDirectory="Debug"
+			ConfigurationType="1"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/wd4996"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(OutDir)/compress_gob.exe"
+				LinkIncremental="2"
+				IgnoreDefaultLibraryNames="libc.lib;libcmt.lib"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)/compress_gob.pdb"
+				SubSystem="1"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
+			ConfigurationType="1"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/wd4996"
+				Optimization="3"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(OutDir)/compress_gob.exe"
+				LinkIncremental="1"
+				IgnoreDefaultLibraryNames="libc.lib;libcmt.lib"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath="..\..\compress_gob.cpp"
+			>
+		</File>
+		<File
+			RelativePath="..\..\util.cpp"
+			>
+		</File>
+		<File
+			RelativePath="..\..\util.h"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>


Property changes on: tools/trunk/dist/msvc9/compress_gob.vcproj
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Modified: tools/trunk/dist/msvc9/tools.sln
===================================================================
--- tools/trunk/dist/msvc9/tools.sln	2009-05-13 23:08:36 UTC (rev 40545)
+++ tools/trunk/dist/msvc9/tools.sln	2009-05-13 23:38:11 UTC (rev 40546)
@@ -51,6 +51,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "extract_parallaction", "extract_parallaction.vcproj", "{F4B04E6F-5916-44DA-A957-E8FA789D2CBC}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compress_gob", "compress_gob.vcproj", "{8C4BC409-2EEC-41F5-A017-972F38414289}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Win32 = Debug|Win32
@@ -97,6 +99,10 @@
 		{FF790984-B460-4B34-8471-26E66B8ECD4C}.Debug|Win32.Build.0 = Debug|Win32
 		{FF790984-B460-4B34-8471-26E66B8ECD4C}.Release|Win32.ActiveCfg = Release|Win32
 		{FF790984-B460-4B34-8471-26E66B8ECD4C}.Release|Win32.Build.0 = Release|Win32
+		{C151022B-EAC8-4680-9018-C0A897F7F9C6}.Debug|Win32.ActiveCfg = Debug|Win32
+		{C151022B-EAC8-4680-9018-C0A897F7F9C6}.Debug|Win32.Build.0 = Debug|Win32
+		{C151022B-EAC8-4680-9018-C0A897F7F9C6}.Release|Win32.ActiveCfg = Release|Win32
+		{C151022B-EAC8-4680-9018-C0A897F7F9C6}.Release|Win32.Build.0 = Release|Win32
 		{0B9A669F-83C2-4AE4-841F-3B015713605C}.Debug|Win32.ActiveCfg = Debug|Win32
 		{0B9A669F-83C2-4AE4-841F-3B015713605C}.Debug|Win32.Build.0 = Debug|Win32
 		{0B9A669F-83C2-4AE4-841F-3B015713605C}.Release|Win32.ActiveCfg = Release|Win32
@@ -117,6 +123,10 @@
 		{A59D7F94-4875-4337-8246-A28F21A1DF78}.Debug|Win32.Build.0 = Debug|Win32
 		{A59D7F94-4875-4337-8246-A28F21A1DF78}.Release|Win32.ActiveCfg = Release|Win32
 		{A59D7F94-4875-4337-8246-A28F21A1DF78}.Release|Win32.Build.0 = Release|Win32
+		{7F599814-F7B1-4C4C-931C-04C05B0CA670}.Debug|Win32.ActiveCfg = Debug|Win32
+		{7F599814-F7B1-4C4C-931C-04C05B0CA670}.Debug|Win32.Build.0 = Debug|Win32
+		{7F599814-F7B1-4C4C-931C-04C05B0CA670}.Release|Win32.ActiveCfg = Release|Win32
+		{7F599814-F7B1-4C4C-931C-04C05B0CA670}.Release|Win32.Build.0 = Release|Win32
 		{5BCEC6FE-1EDD-464F-B09A-660C9B706AFD}.Debug|Win32.ActiveCfg = Debug|Win32
 		{5BCEC6FE-1EDD-464F-B09A-660C9B706AFD}.Debug|Win32.Build.0 = Debug|Win32
 		{5BCEC6FE-1EDD-464F-B09A-660C9B706AFD}.Release|Win32.ActiveCfg = Release|Win32
@@ -149,14 +159,10 @@
 		{F4B04E6F-5916-44DA-A957-E8FA789D2CBC}.Debug|Win32.Build.0 = Debug|Win32
 		{F4B04E6F-5916-44DA-A957-E8FA789D2CBC}.Release|Win32.ActiveCfg = Release|Win32
 		{F4B04E6F-5916-44DA-A957-E8FA789D2CBC}.Release|Win32.Build.0 = Release|Win32
-		{7F599814-F7B1-4C4C-931C-04C05B0CA670}.Debug|Win32.ActiveCfg = Debug|Win32
-		{7F599814-F7B1-4C4C-931C-04C05B0CA670}.Debug|Win32.Build.0 = Debug|Win32
-		{7F599814-F7B1-4C4C-931C-04C05B0CA670}.Release|Win32.ActiveCfg = Release|Win32
-		{7F599814-F7B1-4C4C-931C-04C05B0CA670}.Release|Win32.Build.0 = Release|Win32
-		{C151022B-EAC8-4680-9018-C0A897F7F9C6}.Debug|Win32.ActiveCfg = Debug|Win32
-		{C151022B-EAC8-4680-9018-C0A897F7F9C6}.Debug|Win32.Build.0 = Debug|Win32
-		{C151022B-EAC8-4680-9018-C0A897F7F9C6}.Release|Win32.ActiveCfg = Release|Win32
-		{C151022B-EAC8-4680-9018-C0A897F7F9C6}.Release|Win32.Build.0 = Release|Win32
+		{8C4BC409-2EEC-41F5-A017-972F38414289}.Debug|Win32.ActiveCfg = Debug|Win32
+		{8C4BC409-2EEC-41F5-A017-972F38414289}.Debug|Win32.Build.0 = Debug|Win32
+		{8C4BC409-2EEC-41F5-A017-972F38414289}.Release|Win32.ActiveCfg = Release|Win32
+		{8C4BC409-2EEC-41F5-A017-972F38414289}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE


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