[Scummvm-cvs-logs] scummvm master -> 0a2e64b903a65e9ffcfc3f7f81eba708c774d0f2

criezy criezy at scummvm.org
Sat Aug 3 19:43:40 CEST 2013


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
0a2e64b903 DEVTOOLS: Include English menu in mortevielle dat file


Commit: 0a2e64b903a65e9ffcfc3f7f81eba708c774d0f2
    https://github.com/scummvm/scummvm/commit/0a2e64b903a65e9ffcfc3f7f81eba708c774d0f2
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2013-08-03T08:50:14-07:00

Commit Message:
DEVTOOLS: Include English menu in mortevielle dat file

Changed paths:
  A devtools/create_mortdat/menudata.h
    devtools/create_mortdat/create_mortdat.cpp
    dists/engine-data/mort.dat
    engines/mortevielle/menu.cpp



diff --git a/devtools/create_mortdat/create_mortdat.cpp b/devtools/create_mortdat/create_mortdat.cpp
index 653a075..93ca721 100644
--- a/devtools/create_mortdat/create_mortdat.cpp
+++ b/devtools/create_mortdat/create_mortdat.cpp
@@ -41,6 +41,7 @@
 #include "create_mortdat.h"
 #include "enginetext.h"
 #include "gametext.h"
+#include "menudata.h"
 
 
 bool File::open(const char *filename, AccessMode mode) {
@@ -200,10 +201,36 @@ void writeGameStrings() {
 	writeStaticStrings(gameDataDe, kGameStrings, 2);
 }
 
+/**
+ * Write out the data for the English menu
+ */
+void writeMenuBlock() {
+	// Write out a section header to the output file and the font data
+	const char menuHeader[4] = { 'M', 'E', 'N', 'U' };
+	outputFile.write(menuHeader, 4);				// Section Id
+	outputFile.writeWord(strlen(menuDataEn) / 8);	// Section size
+	// Write each 8-characters block as a byte (one bit per character)
+	// ' ' -> 0, anything else -> 1
+	byte value;
+	int valueCpt = 0;
+	const char* str = menuDataEn;
+	while (*str != 0) {
+		if (*(str++) != ' ')
+			value |= (1 << (7 - valueCpt));
+		++valueCpt;
+		if (valueCpt == 8) {
+			outputFile.writeByte(value);
+			value = 0;
+			valueCpt = 0;
+		}
+	}
+}
+
 void process() {
 	writeFontBlock();
 	writeGameStrings();
 	writeEngineStrings();
+	writeMenuBlock();
 }
 
 /**
diff --git a/devtools/create_mortdat/menudata.h b/devtools/create_mortdat/menudata.h
new file mode 100644
index 0000000..aa4557b
--- /dev/null
+++ b/devtools/create_mortdat/menudata.h
@@ -0,0 +1,79 @@
+/* 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 for extracting needed resource data from different language
+ * version of the Mortevielle executable files into a new file mort.dat - this
+ * is required for the ScummVM Mortevielle module to work properly
+ */
+
+#ifndef MENUDATA_H
+#define MENUDATA_H
+
+const char *menuDataEn =
+	"   @@@                  "
+	"    @                   "
+	"   @  @ @@   @@@ @@@    "
+	"   @   @  @   @   @     "
+	"  @   @  @    @  @      "
+	"  @   @  @    @ @       "
+	"@@@ @@@ @@    @@        "
+	"                        "
+	"   @@   @@              "
+	"   @@  @ @              "
+	"  @ @ @ @   @@@  @@@ @@@"
+	"  @  @  @  @   @  @   @ "
+	" @     @  @    @  @  @  "
+	" @     @  @   @   @ @   "
+	"@@@   @@@ @@@@    @@    "
+	"                        "
+	"      @           @     "
+	"     @@           @     "
+	"    @ @    @@@@ @@@@    "
+	"   @  @   @   @  @      "
+	"  @@@@@  @      @       "
+	" @    @  @   @  @       "
+	"@@@ @@@   @@@   @@      "
+	"                        "
+	"    @@@@@       @@@  @@@"
+	"   @    @        @  @  @"
+	"  @       @@@   @   @   "
+	"   @@@@  @   @  @  @@@  "
+	"      @ @@@@@  @   @    "
+	" @    @ @      @  @     "
+	"@@@@@@  @@@  @@@ @@@    "
+	"                        "
+	"@@@@@@@       @@@ @@@   "
+	"@  @  @        @   @    "
+	"  @    @@@@   @   @   @@"
+	"  @   @   @   @   @@ @  "
+	" @   @   @   @   @  @@  "
+	" @   @   @   @   @   @  "
+	"@@@   @@@@  @@@ @@@  @@@"
+	"                        "
+	"   @@@@@@@  @   @@@     "
+	"    @    @       @      "
+	"   @  @   @@    @   @@@ "
+	"   @@@@    @    @  @   @"
+	"  @  @    @    @  @@@@@ "
+	"  @       @    @  @     "
+	"@@@     @@@  @@@  @@@   "
+	"                        ";
+
+#endif
diff --git a/dists/engine-data/mort.dat b/dists/engine-data/mort.dat
index fca30ab..466c491 100644
Binary files a/dists/engine-data/mort.dat and b/dists/engine-data/mort.dat differ
diff --git a/engines/mortevielle/menu.cpp b/engines/mortevielle/menu.cpp
index f86fd20..aa8d67e 100644
--- a/engines/mortevielle/menu.cpp
+++ b/engines/mortevielle/menu.cpp
@@ -491,14 +491,56 @@ void Menu::initMenu(MortevielleEngine *vm) {
 
 	int i;
 	Common::File f;
+	
+	bool enMenuLoaded = false;
+	if (_vm->getLanguage() == Common::EN_ANY) {
+		// Open the mort.dat file
+		if (!f.open(MORT_DAT))
+			warning("File %s not found. Using default menu from game data", MORT_DAT);
+		else {
+			// Validate the data file header
+			char fileId[4];
+			f.read(fileId, 4);
+			// Do not display warnings here. They would already have been displayed in MortevielleEngine::loadMortDat().
+			if (strncmp(fileId, "MORT", 4) == 0 && f.readByte() >= MORT_DAT_REQUIRED_VERSION) {
+				f.readByte();		// Minor version
+				// Loop to load resources from the data file
+				while (f.pos() < f.size()) {
+					// Get the Id and size of the next resource
+					char dataType[4];
+					int dataSize;
+					f.read(dataType, 4);
+					dataSize = f.readUint16LE();
+					if (!strncmp(dataType, "MENU", 4)) {
+						// MENU section
+						if (dataSize <= 7 * 24) {
+							f.read(_charArr, dataSize);
+							enMenuLoaded = true;
+						} else
+							warning("Wrong size %d for menu data. Expected %d or less", dataSize, 7*24);
+						break;
+					} else {
+						// Other sections
+						f.skip(dataSize);
+					}
+				}
+			}
+			// Close the file
+			f.close();
+			if (!enMenuLoaded)
+				warning("Failed to load English menu. Will use default menu from game data instead");
+		}
+	}
 
-	if (!f.open("menufr.mor"))
-		if (!f.open("menual.mor"))
-			if (!f.open("menu.mor"))
-				error("Missing file - menufr.mor or menual.mor or menu.mor");
+	if (!enMenuLoaded) {
+		if (!f.open("menufr.mor"))
+			if (!f.open("menual.mor"))
+				if (!f.open("menu.mor"))
+					error("Missing file - menufr.mor or menual.mor or menu.mor");
 
-	f.read(_charArr, 7 * 24);
-	f.close();
+		f.read(_charArr, 7 * 24);
+		f.close();
+	}
 
 	// Skipped: dialog asking to swap floppy
 






More information about the Scummvm-git-logs mailing list