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

joostp at users.sourceforge.net joostp at users.sourceforge.net
Thu Aug 26 13:01:08 CEST 2010


Revision: 52399
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52399&view=rev
Author:   joostp
Date:     2010-08-26 11:01:08 +0000 (Thu, 26 Aug 2010)

Log Message:
-----------
TOOLS: add extract_fascination_cd tool

Modified Paths:
--------------
    tools/trunk/Makefile.common
    tools/trunk/NEWS
    tools/trunk/tools.cpp

Added Paths:
-----------
    tools/trunk/engines/gob/extract_fascination_cd.cpp
    tools/trunk/engines/gob/extract_fascination_cd.h

Modified: tools/trunk/Makefile.common
===================================================================
--- tools/trunk/Makefile.common	2010-08-26 07:31:54 UTC (rev 52398)
+++ tools/trunk/Makefile.common	2010-08-26 11:01:08 UTC (rev 52399)
@@ -162,6 +162,7 @@
 tools_OBJS := \
 	engines/agos/compress_agos.o \
 	engines/gob/compress_gob.o \
+	engines/gob/extract_fascination_cd.o \
 	engines/kyra/compress_kyra.o \
 	engines/queen/compress_queen.o \
 	engines/saga/compress_saga.o \

Modified: tools/trunk/NEWS
===================================================================
--- tools/trunk/NEWS	2010-08-26 07:31:54 UTC (rev 52398)
+++ tools/trunk/NEWS	2010-08-26 11:01:08 UTC (rev 52399)
@@ -2,6 +2,8 @@
         http://scummvm.svn.sourceforge.net/viewvc/scummvm/tools/trunk/?view=log
 
 1.2.0 (????-??-??)
+ - Add extract_fascination_cd tool for extracting STK archives from a mode1/2048
+   Fascination CD image.
  - Fix bug #2984225: "Tools: configure should check if libwxgtk2.8-dev is installed".
  - Add version information to tools.
  - Respect $BINDIR when installing (similar to ScummVM).

Added: tools/trunk/engines/gob/extract_fascination_cd.cpp
===================================================================
--- tools/trunk/engines/gob/extract_fascination_cd.cpp	                        (rev 0)
+++ tools/trunk/engines/gob/extract_fascination_cd.cpp	2010-08-26 11:01:08 UTC (rev 52399)
@@ -0,0 +1,122 @@
+/* extract_fascination_cd - a tool for extracting .stk archives from a mode1/2048 Fascination CD image
+ * Copyright (C) 2010  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ *
+ */
+
+#include "common/endian.h"
+#include "common/file.h"
+#include "common/util.h"
+
+#include "extract_fascination_cd.h"
+
+
+enum {
+	STK_HEADER_ENTRY_SIZE = 22
+};
+
+struct STKFile {
+	const char *stkFilename;
+	const char *firstEntryName;	
+} static const stkFile[] = {
+	{ "disk0.stk", "INTRO1.TOT" },
+	{ "disk1.stk", "DOUCHE.TOT" },
+	{ "disk2.stk", "PLANQUE.TOT" },
+	{ "disk3.stk", "MELANGE.TOT" },
+};
+
+
+ExtractFascinationCD::ExtractFascinationCD(const std::string &name) : Tool(name, TOOLTYPE_EXTRACTION) {
+	ToolInput input;
+	input.format = "*.iso";
+	_inputPaths.push_back(input);
+
+	_shorthelp = "Extract data files from a Fascination ISO.";
+	_helptext = "Usage: " + _name + " [-o outputdir] <infile>\n" + _shorthelp + "\n";
+}
+
+void ExtractFascinationCD::execute(void) {
+	if (_outputPath.empty())
+		_outputPath.setFullPath("./");
+
+	// Open ISO file
+	Common::File file(_inputPaths[0].path, "rb");
+	assert(file.isOpen());
+	uint32 fileSize = file.size();
+
+	// Sanity check the file size
+	if (fileSize > (16 * 1024 * 1024)) {
+		error("'%s' is too large to be a Fascination mode1/2048 ISO", _inputPaths[0].path.c_str());
+	}
+
+	if (fileSize % 2048) {
+		error("'%s' doesn't appear to be a mode1/2048 ISO", _inputPaths[0].path.c_str());
+	}
+
+	// Load ISO file to memory. (Should only be ~10MB, and this simplifies the code)
+	byte *data = new byte[fileSize];
+	file.read_noThrow(data, fileSize);
+	file.close();
+	
+	print("Loaded '%s' (%d bytes)\n", _inputPaths[0].path.c_str(), fileSize);
+	
+	for (uint32 i = 0; i < ARRAYSIZE(stkFile); i++) {
+		// initialize curPos to start of file
+		byte *curPos = data;	
+	
+		while (curPos < data + fileSize) {
+			// search for known first entry of STK files
+			if (!memcmp(curPos, stkFile[i].firstEntryName, strlen(stkFile[i].firstEntryName))) {
+				byte *stkFileStart = curPos - 2;	// the actual STK start is 2 bytes prior
+				uint16 numStkEntries = READ_LE_UINT16(stkFileStart); // read number of entries in STK file
+				assert(numStkEntries > 0 && numStkEntries < 0xFF);
+				
+				// Determine length of file by adding offset and size of the last entry
+				const uint32 lastEntrySize = READ_LE_UINT32(curPos + ((numStkEntries - 1) * STK_HEADER_ENTRY_SIZE) + 13);
+				const uint32 lastEntryOffset = READ_LE_UINT32(curPos + ((numStkEntries - 1) * STK_HEADER_ENTRY_SIZE) + 17);
+				const uint32 stkEntrySize = lastEntryOffset + lastEntrySize;
+
+				print("Found '%s' at %x (size: %d).  Extracting...\n", stkFile[i].stkFilename, curPos - data - 2, stkEntrySize);
+				
+				// write STK file
+				Common::File output;
+				_outputPath.setFullName(stkFile[i].stkFilename);
+				output.open(_outputPath, "wb");
+				assert(output.isOpen());
+				output.write(stkFileStart, stkEntrySize);
+				output.close();
+
+				curPos += stkEntrySize;
+			}
+		
+			curPos++;
+		}
+	}
+	
+	delete[] data;
+}
+
+
+#ifdef STANDALONE_MAIN
+int main(int argc, char *argv[]) {
+	ExtractFascinationCD fe(argv[0]);
+	return fe.run(argc, argv);
+}
+#endif
+


Property changes on: tools/trunk/engines/gob/extract_fascination_cd.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Added: tools/trunk/engines/gob/extract_fascination_cd.h
===================================================================
--- tools/trunk/engines/gob/extract_fascination_cd.h	                        (rev 0)
+++ tools/trunk/engines/gob/extract_fascination_cd.h	2010-08-26 11:01:08 UTC (rev 52399)
@@ -0,0 +1,36 @@
+/* extract_fascination_cd - a tool for extracting .stk archives from a mode1/2048 Fascination CD image
+ * Copyright (C) 2010  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ *
+ */
+
+#ifndef EXTRACT_FASCINATION_CD_H
+#define EXTRACT_FASCINATION_CD_H
+
+#include "compress.h"
+
+class ExtractFascinationCD : public Tool {
+public:
+	ExtractFascinationCD(const std::string &name = "extract_fascination_cd");
+
+	virtual void execute();
+};
+
+#endif
+


Property changes on: tools/trunk/engines/gob/extract_fascination_cd.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Modified: tools/trunk/tools.cpp
===================================================================
--- tools/trunk/tools.cpp	2010-08-26 07:31:54 UTC (rev 52398)
+++ tools/trunk/tools.cpp	2010-08-26 11:01:08 UTC (rev 52399)
@@ -48,6 +48,7 @@
 #include "engines/cine/extract_cine.h"
 #include "engines/cruise/extract_cruise_pc.h"
 #include "engines/gob/extract_gob_stk.h"
+#include "engines/gob/extract_fascination_cd.h"
 #include "engines/kyra/extract_kyra.h"
 #include "engines/scumm/extract_loom_tg16.h"
 #include "engines/scumm/extract_mm_apple.h"
@@ -82,6 +83,7 @@
 	_tools.push_back(new ExtractCine());
 	_tools.push_back(new ExtractCruisePC());
 	_tools.push_back(new ExtractGobStk());
+	_tools.push_back(new ExtractFascinationCD());
 	_tools.push_back(new ExtractKyra());
 	_tools.push_back(new ExtractLoomTG16());
 	_tools.push_back(new ExtractMMApple());


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