[Scummvm-git-logs] scummvm-tools master -> e9cc8a8a7242b71baf121b728a5b4e21b028f772
sev-
sev at scummvm.org
Sun Dec 6 19:27:54 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-tools' repo located at https://github.com/scummvm/scummvm-tools .
Summary:
e9cc8a8a72 HADESCH: Publish my tool for extracting pod files
Commit: e9cc8a8a7242b71baf121b728a5b4e21b028f772
https://github.com/scummvm/scummvm-tools/commit/e9cc8a8a7242b71baf121b728a5b4e21b028f772
Author: Vladimir Serbinenko (phcoder at google.com)
Date: 2020-12-06T20:27:51+01:00
Commit Message:
HADESCH: Publish my tool for extracting pod files
This is a basic uncompressed archive used by Hades' Challenge.
Changed paths:
A engines/hadesch/extract_hadesch.cpp
.gitignore
Makefile
Makefile.common
diff --git a/.gitignore b/.gitignore
index 2ced923f3..6eff6bb2d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,6 +27,7 @@
/config.mk
/config.h
/config.log
+/extract_hadesch
/decompiler/doc/doc.pdf
diff --git a/Makefile b/Makefile
index 03258d211..8f94b2f14 100644
--- a/Makefile
+++ b/Makefile
@@ -146,6 +146,7 @@ endif
$(STRIP) deprince$(EXEEXT) -o $(srcdir)/$(WIN32BUILD)/deprince$(EXEEXT)
$(STRIP) descumm$(EXEEXT) -o $(srcdir)/$(WIN32BUILD)/descumm$(EXEEXT)
$(STRIP) desword2$(EXEEXT) -o $(srcdir)/$(WIN32BUILD)/desword2$(EXEEXT)
+ $(STRIP) extract_hadesch$(EXEEXT) -o $(srcdir)/$(WIN32BUILD)/extract_hadesch$(EXEEXT)
$(STRIP) extract_mohawk$(EXEEXT) -o $(srcdir)/$(WIN32BUILD)/extract_mohawk$(EXEEXT)
$(STRIP) extract_ngi$(EXEEXT) -o $(srcdir)/$(WIN32BUILD)/extract_ngi$(EXEEXT)
$(STRIP) gob_loadcalc$(EXEEXT) -o $(srcdir)/$(WIN32BUILD)/gob_loadcalc$(EXEEXT)
@@ -266,6 +267,7 @@ ifeq "$(USE_WXWIDGETS)" "1"
$(STRIP) scummvm-tools$(EXEEXT) -o $(AMIGAOSPATH)/scummvm-tools$(EXEEXT)
endif
$(STRIP) scummvm-tools-cli$(EXEEXT) -o $(AMIGAOSPATH)/scummvm-tools-cli$(EXEEXT)
+ $(STRIP) extract_hadesch$(EXEEXT) -o $(AMIGAOSPATH)/extract_hadesch$(EXEEXT)
#
diff --git a/Makefile.common b/Makefile.common
index 1044af300..3955ca8bd 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -34,7 +34,8 @@ PROGRAMS = \
extract_mohawk \
extract_ngi \
construct_mohawk \
- scummvm-tools-cli
+ scummvm-tools-cli \
+ extract_hadesch
ifdef USE_BOOST
PROGRAMS += \
@@ -100,6 +101,9 @@ dekyra_OBJS := \
engines/kyra/dekyra_v1.o \
$(UTILS)
+extract_hadesch_OBJS := \
+ engines/hadesch/extract_hadesch.o
+
deprince_OBJS := \
engines/prince/deprince.o \
engines/prince/flags.o \
diff --git a/engines/hadesch/extract_hadesch.cpp b/engines/hadesch/extract_hadesch.cpp
new file mode 100644
index 000000000..dfc0e7503
--- /dev/null
+++ b/engines/hadesch/extract_hadesch.cpp
@@ -0,0 +1,98 @@
+/* ScummVM Tools
+ *
+ * ScummVM Tools is the legal property of its developers, whose
+ * names are too numerous to list here. Please refer to the
+ * COPYRIGHT file distributed with this source distribution.
+ *
+ * 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.
+ */
+
+#include "common/endian.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+int main (int argc, char **argv) {
+ unsigned char * buf;
+ size_t sz;
+ FILE *fin;
+ char fn[1024];
+
+ if (argc < 3) {
+ fprintf (stderr, "USAGE: %s INFILE OUTDIR\n", argv[0]);
+ return -1;
+ }
+
+ fin = fopen (argv[1], "rb");
+ if (fin == NULL) {
+ fprintf (stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
+ return -2;
+ }
+ fseek (fin, 0, SEEK_END);
+ sz = ftell (fin);
+ fseek (fin, 0, SEEK_SET);
+
+ buf = (unsigned char *) malloc (sz);
+
+ fread (buf, 1, sz, fin);
+ fclose (fin);
+
+ if (memcmp (buf, "Pod\0file\0\0\0\0", 12) != 0
+ && memcmp (buf, "Pod File\0\0\0\0", 12) != 0
+ && memcmp (buf, "Pod\0\0\0\0\0\0\0\0\0", 12) != 0) {
+ fprintf (stderr, "Bad signature\n");
+ return 1;
+ }
+
+ int filecnt = READ_LE_UINT32(buf + 12);
+
+ FILE *fout;
+
+ int cur = filecnt * 16 + 16;
+ int ctr = 0;
+
+ fprintf (stderr, "%d files\n", filecnt);
+
+ for (ctr = 0; ctr < filecnt; ctr++) {
+ unsigned char * headptr = buf + 16 + 16 * ctr;
+ char c = headptr[12];
+ headptr[12] = 0;
+ sprintf (fn, "%s/%s", argv[2], headptr);
+ headptr[12] = c;
+ int csz = READ_LE_UINT32(headptr+12);
+ fout = fopen(fn, "wb");
+ if (fout == NULL) {
+ fprintf (stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
+ return -3;
+ }
+ fwrite(buf + cur, csz, 1, fout);
+ fclose(fout);
+ cur += csz;
+ }
+
+ if (cur < (int)sz) {
+ sprintf (fn, "%s/tail.bin", argv[2]);
+ fout = fopen(fn, "wb");
+ if (fout == NULL) {
+ fprintf (stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
+ return -3;
+ }
+ fwrite(buf + cur, sz - cur, 1, fout);
+ fclose(fout);
+ }
+
+ return 0;
+}
More information about the Scummvm-git-logs
mailing list