[Scummvm-git-logs] scummvm-tools master -> 47579ad3d029647dbfbf4d0f12b347eb116a94de

sev- sev at scummvm.org
Mon Dec 7 22:08:34 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:
47579ad3d0 SCUMM: A new tool to extract loaklizator bundles


Commit: 47579ad3d029647dbfbf4d0f12b347eb116a94de
    https://github.com/scummvm/scummvm-tools/commit/47579ad3d029647dbfbf4d0f12b347eb116a94de
Author: Vladimir Serbinenko (phcoder at google.com)
Date: 2020-12-07T23:08:31+01:00

Commit Message:
SCUMM: A new tool to extract loaklizator bundles

Changed paths:
  A engines/scumm/extract_lokalizator.cpp
    .gitignore
    Makefile
    Makefile.common


diff --git a/.gitignore b/.gitignore
index 6eff6bb2d..88a2b72ba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,7 @@
 /config.h
 /config.log
 /extract_hadesch
+/extract_lokalizator
 
 /decompiler/doc/doc.pdf
 
diff --git a/Makefile b/Makefile
index 8f94b2f14..ccb21956c 100644
--- a/Makefile
+++ b/Makefile
@@ -147,6 +147,7 @@ endif
 	$(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_lokalizator$(EXEEXT)    -o $(srcdir)/$(WIN32BUILD)/extract_lokalizator$(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)
@@ -268,6 +269,7 @@ ifeq "$(USE_WXWIDGETS)" "1"
 endif
 	$(STRIP) scummvm-tools-cli$(EXEEXT) -o $(AMIGAOSPATH)/scummvm-tools-cli$(EXEEXT)
 	$(STRIP) extract_hadesch$(EXEEXT) -o $(AMIGAOSPATH)/extract_hadesch$(EXEEXT)
+	$(STRIP) extract_lokalizator$(EXEEXT) -o $(AMIGAOSPATH)/extract_lokalizator$(EXEEXT)
 
 
 #
diff --git a/Makefile.common b/Makefile.common
index 3955ca8bd..1fd3e3c43 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -35,7 +35,8 @@ PROGRAMS = \
 	extract_ngi \
 	construct_mohawk \
 	scummvm-tools-cli \
-	extract_hadesch
+	extract_hadesch \
+	extract_lokalizator
 
 ifdef USE_BOOST
 PROGRAMS += \
@@ -104,6 +105,9 @@ dekyra_OBJS := \
 extract_hadesch_OBJS := \
 	engines/hadesch/extract_hadesch.o
 
+extract_lokalizator_OBJS := \
+	engines/scumm/extract_lokalizator.o
+
 deprince_OBJS := \
 	engines/prince/deprince.o \
 	engines/prince/flags.o \
diff --git a/engines/scumm/extract_lokalizator.cpp b/engines/scumm/extract_lokalizator.cpp
new file mode 100644
index 000000000..b82a8f4ef
--- /dev/null
+++ b/engines/scumm/extract_lokalizator.cpp
@@ -0,0 +1,117 @@
+/* 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 i, 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);
+
+	for (i = 0; i < sz; i++) {
+	    unsigned int st = 214013 * i + 2531011;
+	    int r = (st >> 16) & 0x7FFF;
+	    buf[i] = buf[i] ^ r;
+	}
+
+	int filecnt = READ_LE_UINT32(buf + 0x14);
+
+	FILE *fout;
+
+	int ctr = 0;
+
+	fprintf (stderr, "%d files\n", filecnt);
+      
+	for (ctr = 0; ctr < filecnt; ctr++) {
+		unsigned char * headptr = buf + 0x18 + 0x4c * ctr;
+		char c = headptr[64];
+		headptr[64] = 0;
+		sprintf (fn, "%s/%s", argv[2], headptr);
+		headptr[64] = c;
+		int csz = READ_LE_UINT32(headptr+64+4);
+		int pos = READ_LE_UINT32(headptr+64+8);
+		fout = fopen(fn, "wb");
+		if (fout == NULL) {
+			fprintf (stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
+			return -3;
+		}
+		fwrite(buf + pos, csz, 1, fout);
+		fclose(fout);
+
+		if (csz > 4 && strcmp((const char*)headptr, "locale.msg") == 0) {
+			sprintf (fn, "%s/%s.unscrambled", argv[2], headptr);
+			fout = fopen(fn, "wb");
+			if (fout == NULL) {
+				fprintf (stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
+				return -3;
+			}
+			uint32 st = 0x12345678;
+			for (int p = 0; p < csz - 4; p++) {
+				byte x = 0;
+				switch (p&3) {
+				case 0:
+					x = st;
+					break;
+				case 1:
+					x = (st + 35);
+					break;
+				case 2:
+					x = (st + 70);
+					break;
+				case 3:
+					x = (st + 105);
+					st += 45707404;
+					break;
+				}
+				buf[pos+4+p] ^= x;
+			}
+
+			fwrite(buf + pos, csz, 1, fout);
+			fclose(fout);
+		}
+	}
+
+	return 0;
+}




More information about the Scummvm-git-logs mailing list