[Scummvm-git-logs] scummvm-tools master -> acbc51395cd2cbe5261a8c1a175be979a5bc0348

sev- sev at scummvm.org
Tue Oct 6 10:23:22 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:
acbc51395c TOOLS: Added tool for extracting NGI's .nl archives


Commit: acbc51395cd2cbe5261a8c1a175be979a5bc0348
    https://github.com/scummvm/scummvm-tools/commit/acbc51395cd2cbe5261a8c1a175be979a5bc0348
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-10-06T12:23:09+02:00

Commit Message:
TOOLS: Added tool for extracting NGI's .nl archives

Changed paths:
  A engines/ngi/dib2png.pl
  A engines/ngi/extract_ngi.cpp
    Makefile
    Makefile.common
    NEWS


diff --git a/Makefile b/Makefile
index 7d8998030..03258d211 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_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)
 ifeq "$(USE_WXWIDGETS)" "1"
 	$(STRIP) scummvm-tools$(EXEEXT)      -o $(srcdir)/$(WIN32BUILD)/scummvm-tools$(EXEEXT)
@@ -259,6 +260,7 @@ endif
 	$(STRIP) descumm$(EXEEXT) -o $(AMIGAOSPATH)/descumm$(EXEEXT)
 	$(STRIP) desword2$(EXEEXT) -o $(AMIGAOSPATH)/desword2$(EXEEXT)
 	$(STRIP) extract_mohawk$(EXEEXT) -o $(AMIGAOSPATH)/extract_mohawk$(EXEEXT)
+	$(STRIP) extract_ngi$(EXEEXT) -o $(AMIGAOSPATH)/extract_ngi$(EXEEXT)
 	$(STRIP) gob_loadcalc$(EXEEXT) -o $(AMIGAOSPATH)/gob_loadcalc$(EXEEXT)
 ifeq "$(USE_WXWIDGETS)" "1"
 	$(STRIP) scummvm-tools$(EXEEXT) -o $(AMIGAOSPATH)/scummvm-tools$(EXEEXT)
diff --git a/Makefile.common b/Makefile.common
index 4c87f1dd0..5b2f172a8 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -31,6 +31,7 @@ PROGRAMS = \
 	desword2 \
 	gob_loadcalc \
 	extract_mohawk \
+	extract_ngi \
 	construct_mohawk \
 	scummvm-tools-cli
 
@@ -145,6 +146,10 @@ extract_mohawk_OBJS := \
 	engines/mohawk/utils.o \
 	$(UTILS)
 
+extract_ngi_OBJS := \
+	engines/ngi/extract_ngi.o \
+	$(UTILS)
+
 construct_mohawk_OBJS := \
 	engines/mohawk/construct_mohawk.o \
 	engines/mohawk/utils.o \
diff --git a/NEWS b/NEWS
index 89b66b00a..5681d3788 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,9 @@
 For a more comprehensive changelog of the latest experimental code, see:
         https://github.com/scummvm/scummvm-tools/commits/
 
+2.3.0 (XXXX-XX-XX)
+ - Added tool for exctracting NGI's .nl archives
+
 2.2.0 (2020-09-27)
  - Add a tool to extract Lost Eden archives
  - Fix number of issues with prince translation generation.
diff --git a/engines/ngi/dib2png.pl b/engines/ngi/dib2png.pl
new file mode 100644
index 000000000..bcbfe64f6
--- /dev/null
+++ b/engines/ngi/dib2png.pl
@@ -0,0 +1,22 @@
+#!/bin/perl
+#
+#
+
+use Fcntl qw(SEEK_END);
+
+my $file = shift or die "Usage: $0 file";
+
+open IN, $file or die "Cannot open file $file: $!";
+
+seek IN, -32, SEEK_END;
+
+if (read(IN, $header, 32) != 32) {
+  die "Something terrible happened";
+}
+
+(undef, undef, $width, $height) = unpack "VVVV", $header;
+
+print "$width x $height\n";
+
+exec "convert -size ${width}x${height} -flip gray:$file $file.png";
+
diff --git a/engines/ngi/extract_ngi.cpp b/engines/ngi/extract_ngi.cpp
new file mode 100644
index 000000000..32df3cfca
--- /dev/null
+++ b/engines/ngi/extract_ngi.cpp
@@ -0,0 +1,121 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM 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.
+ *
+ * This is a utility to unpack Nikita engine's archive files.
+ */
+
+#include "common/scummsys.h"
+#include "common/endian.h"
+#include "common/file.h"
+
+static void unpackFile(Common::File &fp, const char *outDir) {
+	char filePath[512];
+
+	fp.seek(4, SEEK_SET);
+
+	unsigned int count = fp.readUint16LE(); // How many entries?
+
+	fp.seek(20, SEEK_SET);
+
+	unsigned int key = fp.readUint16LE();
+
+	byte key1, key2;
+
+	key1 = key & 0xff;
+	key2 = (key >> 8) & 0xff;
+
+	printf("count: %d\n", count);
+
+	int fatSize = count * 32;
+
+	fp.seek(32, SEEK_SET);
+
+	byte *o = (byte *)calloc(fatSize, 1);
+
+	fp.read_noThrow(o, fatSize);
+
+	for (int i = 0; i < fatSize; i++) {
+		key1 = (key1 << 1) ^ key2;
+		key2 = (key2 >> 1) ^ key1;
+
+		o[i] ^= key1;
+	}
+
+	char fname[13];
+	int flags, extVal, offset, size;
+	for (int i = 0; i < count; i++) {
+		memcpy(fname, &o[i * 32], 12);
+		fname[12] = 0;
+		flags = READ_LE_UINT32(&o[i * 32 + 16]);
+		extVal = READ_LE_UINT32(&o[i * 32 + 20]);
+		offset = READ_LE_UINT32(&o[i * 32 + 24]);
+		size = READ_LE_UINT32(&o[i * 32 + 28]);
+		printf("[%s]: %.8x %.8x %.8x %.8x\n", fname, flags, extVal, offset, size);
+
+		if (flags & 0x1e0) {
+			printf("File has flags: %.8x\n", flags & 0x1e0);
+		}
+
+		sprintf(filePath, "%s/%s", outDir, fname);
+		Common::File out;
+
+		out.open(filePath, "wb");
+
+		byte *dest = (byte *)malloc(size);
+
+		fp.seek(offset, SEEK_SET);
+		fp.read_noThrow(dest, size);
+		out.write(dest, size);
+		free(dest);
+
+		out.close();
+	}
+}
+
+int showUsage() {
+	printf("USAGE: extract_ngi [input file] [output directory]\n");
+	return -1;
+}
+
+int main(int argc, char *argv[]) {
+	int i;
+	char tmp[512];
+
+	if (argc == 3) {
+		strcpy(tmp, argv[1]);
+		for (i = 0; tmp[i] != 0; i++) {
+			tmp[i] = toupper(tmp[i]);
+		}
+
+		Common::File fp;
+
+		fp.open(argv[1], "rb");
+		if (fp.isOpen()) {
+			unpackFile(fp, argv[2]);
+			fp.close();
+		} else {
+			printf("Couldn't open input file '%s'\n", argv[1]);
+			return -1;
+		}
+	} else {
+		return showUsage();
+	}
+	return 0;
+}




More information about the Scummvm-git-logs mailing list