[Scummvm-cvs-logs] SF.net SVN: scummvm:[35120] tools/trunk
spookypeanut at users.sourceforge.net
spookypeanut at users.sourceforge.net
Tue Nov 18 23:42:08 CET 2008
Revision: 35120
http://scummvm.svn.sourceforge.net/scummvm/?rev=35120&view=rev
Author: spookypeanut
Date: 2008-11-18 22:42:08 +0000 (Tue, 18 Nov 2008)
Log Message:
-----------
Add tool to extract files from mac version of t7g
Modified Paths:
--------------
tools/trunk/Makefile
Added Paths:
-----------
tools/trunk/extract_t7g_mac.cpp
Modified: tools/trunk/Makefile
===================================================================
--- tools/trunk/Makefile 2008-11-18 20:16:50 UTC (rev 35119)
+++ tools/trunk/Makefile 2008-11-18 22:42:08 UTC (rev 35120)
@@ -84,6 +84,7 @@
extract_mm_nes$(EXEEXT) \
extract_parallaction$(EXEEXT) \
extract_scumm_mac$(EXEEXT) \
+ extract_t7g_mac$(EXEEXT) \
extract_zak_c64$(EXEEXT) \
extract_gob_stk$(EXEEXT) \
tools_gui$(EXEEXT)
@@ -190,6 +191,9 @@
extract_scumm_mac$(EXEEXT): extract_scumm_mac.o util.o
$(CXX) $(LDFLAGS) -o $@ $+
+extract_t7g_mac$(EXEEXT): extract_t7g_mac.o util.o
+ $(CXX) $(LDFLAGS) -o $@ $+
+
extract_zak_c64$(EXEEXT): extract_zak_c64.o util.o
$(CXX) $(LDFLAGS) -o $@ $+
Added: tools/trunk/extract_t7g_mac.cpp
===================================================================
--- tools/trunk/extract_t7g_mac.cpp (rev 0)
+++ tools/trunk/extract_t7g_mac.cpp 2008-11-18 22:42:08 UTC (rev 35120)
@@ -0,0 +1,62 @@
+#include "util.h"
+
+#define NUM_FILES 45
+
+int main(int argc, char *argv[]) {
+ FILE *ifp;
+ char *filenames[NUM_FILES];
+
+ if (argc != 2) {
+ printf("Usage: %s <file>\n", argv[0]);
+ exit(2);
+ }
+
+ if ((ifp = fopen(argv[1], "rb")) == NULL) {
+ error("Could not open \'%s\'", argv[1]);
+ }
+
+ // Load the file names
+ printf("Getting the name of the files...\n");
+ if (fseek(ifp, 0x1BEEA8, SEEK_SET)) {
+ fclose(ifp);
+ error("Seek error");
+ }
+ for (int i = 0; i < NUM_FILES; i++) {
+ uint8 len = readByte(ifp);
+ char *name = new char[len + 1];
+ fread(name, len, 1, ifp);
+ name[len] = 0;
+ filenames[i] = name;
+ }
+
+ // Extract the data
+ printf("Extracting the files...\n");
+ if (fseek(ifp, 0x1777B2, SEEK_SET)) {
+ fclose(ifp);
+ error("Seek error");
+ }
+ for (int i = 0; i < NUM_FILES; i++) {
+ printf(" %s\n", filenames[i]);
+ uint32 file_size = readUint32BE(ifp);
+
+ byte *buf = new byte[file_size];
+ if (!buf) {
+ fclose(ifp);
+ error("Could not allocate %ld bytes of memory", file_size);
+ }
+
+ FILE *ofp = fopen(filenames[i], "wb");
+ fread(buf, 1, file_size, ifp);
+ fwrite(buf, 1, file_size, ofp);
+ fclose(ofp);
+ delete[] buf;
+ }
+
+ // Free the allocated filenames
+ for (int i = 0; i < NUM_FILES; i++) {
+ delete[] filenames[i];
+ }
+
+ fclose(ifp);
+ return 0;
+}
Property changes on: tools/trunk/extract_t7g_mac.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
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