[Scummvm-git-logs] scummvm master -> 8999b95053c6a22d4b4d639c584f1ad7513a5785

criezy criezy at scummvm.org
Wed May 29 01:03:18 CEST 2019


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

Summary:
9ff9264ab0 SUPERNOVA: Add better support of pbm format in create_supernova
66a335eb18 Revert "STARTREK: Start adding a console"
8999b95053 SUPERNOVA: Add English translation for Help screen


Commit: 9ff9264ab09d4ec46e965ffe85e4eea9461911c5
    https://github.com/scummvm/scummvm/commit/9ff9264ab09d4ec46e965ffe85e4eea9461911c5
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2019-05-28T23:39:34+01:00

Commit Message:
SUPERNOVA: Add better support of pbm format in create_supernova

The tool was only supporting a very restricted subset of the PBM
format, as written by gimp. Now it should support reading any
PDM file.

Changed paths:
    devtools/create_supernova/create_supernova.cpp
    devtools/create_supernova/file.cpp
    devtools/create_supernova/file.h


diff --git a/devtools/create_supernova/create_supernova.cpp b/devtools/create_supernova/create_supernova.cpp
index bf04004..9ce202c 100644
--- a/devtools/create_supernova/create_supernova.cpp
+++ b/devtools/create_supernova/create_supernova.cpp
@@ -32,27 +32,81 @@ void writeImage(File& outputFile, const char *name, const char* language) {
 	char str[256];
 
 	// Read header (and check we have a binary PBM file)
-	imgFile.readString(str, 256);
-	if (strcmp(str, "P4") != 0) {
-		imgFile.close();
-		printf("File '%s' doesn't seem to be a binary pbm file! This image will be skipped.\n", fileName);
-		return;
-	}
+	// See http://netpbm.sourceforge.net/doc/pbm.html
+	// Header is in the form:
+	// - A "magic number" for identifying the file type ("P4" for binary pdm)
+	// - Whitespace (blanks, TABs, CRs, LFs).
+	// - The width in pixels of the image, formatted as ASCII characters in decimal.
+	// - Whitespace.
+	// - The height in pixels of the image, again in ASCII decimal.
+	// - A single whitespace character (usually a newline).
+	// - The raster data.
+	// Before the whitespace character that delimits the raster, any characters from a "#"
+	// through the next carriage return or newline character, is a comment and is ignored.
+	// Note that the comment can starts in the middle of a line. Note also that if you have
+	// a comment right before the raster, the newline at the end of the comment is not
+	// sufficient to delimit the raster.
 
-	// Skip comments and then read and check size
-	do {
-		imgFile.readString(str, 256);
-	} while (str[0] == '#');
 	int w = 0, h = 0;
-	if (sscanf(str, "%d %d", &w, &h) != 2 || w != 640 || h != 480) {
-		imgFile.close();
-		printf("Binary pbm file '%s' doesn't have the expected size (expected: 640x480, read: %dx%d). This image will be skipped.\n", fileName, w, h);
-		return;
-	}
+	enum PbmState { PbmMagic, PbmWidth, PbmHeight};
+	PbmState state = PbmMagic;
+	int i = 0;
+	do {
+		char c = (char)imgFile.readByte();
+		if (c == '#') {
+			do {
+				c = (char)imgFile.readByte();
+			} while (c != '\r' && c != '\n' && !imgFile.eof());
+			// If the comment is after the height, we need to read one more character
+			// before the raster data begin.
+			if (state == PbmHeight && i > 0)
+				c = (char)imgFile.readByte();
+		}
+		if (isspace(c)) {
+			if (i > 0) {
+				str[i] = 0;
+				i = 0;
+				if (state == PbmMagic) {
+					if (strcmp(str, "P4") != 0) {
+						imgFile.close();
+						printf("File '%s' doesn't seem to be a binary pbm file! This image will be skipped.\n", fileName);
+						return;
+					}
+				} else {
+					int *s = state == PbmWidth ? &w : &h;
+					if (sscanf(str, "%d", s) != 1) {
+						imgFile.close();
+						printf("Failed to read image size in binary pbm file '%s'. This image will be skipped.\n", fileName);
+						return;
+					}
+				}
+				if (state == PbmMagic)
+					state = PbmWidth;
+				else if (state == PbmWidth)
+					state = PbmHeight;
+				else {
+					// We have finished reading the header.
+					// Check the size is as expected.
+					if (w != 640 || h != 480) {
+						imgFile.close();
+						printf("Binary pbm file '%s' doesn't have the expected size (expected: 640x480, read: %dx%d). This image will be skipped.\n", fileName, w, h);
+						return;
+					}
+					// And break out of the loop.
+					break;
+				}
+			}
+		} else
+			str[i++] = c;
+		if (imgFile.eof()) {
+			printf("Unexpected end of file in '%s' while reading pbm header! This image will be skipped.\n", fileName);
+			return;
+		}
+	} while (1);
 
 	// Write block header in output file (4 bytes).
 	// We convert the image name to upper case.
-	for (int i = 0 ; i < 4 ; ++i) {
+	for (i = 0 ; i < 4 ; ++i) {
 		if (name[i] >= 97 && name[i] <= 122)
 			outputFile.writeByte(name[i] - 32);
 		else
@@ -60,7 +114,7 @@ void writeImage(File& outputFile, const char *name, const char* language) {
 	}
 	// And write the language code on 4 bytes as well (padded with 0 if needed).
 	int languageLength = strlen(language);
-	for (int i = 0 ; i < 4 ; ++i) {
+	for (i = 0 ; i < 4 ; ++i) {
 		if (i < languageLength)
 			outputFile.writeByte(language[i]);
 		else
@@ -73,7 +127,7 @@ void writeImage(File& outputFile, const char *name, const char* language) {
 	// Write all the bytes. We should have 38400 bytes (640 * 480 / 8)
 	// However we need to invert the bits has the engine expects 1 for the background and 0 for the text (black)
 	// but pbm uses 0 for white and 1 for black.
-	for (int i = 0 ; i < 38400 ; ++i) {
+	for (i = 0 ; i < 38400 ; ++i) {
 		byte b = imgFile.readByte();
 		outputFile.writeByte(~b);
 	}
diff --git a/devtools/create_supernova/file.cpp b/devtools/create_supernova/file.cpp
index 5fb842a..d54258d 100644
--- a/devtools/create_supernova/file.cpp
+++ b/devtools/create_supernova/file.cpp
@@ -21,6 +21,10 @@ void File::write(const void *buffer, int len) {
 	fwrite(buffer, 1, len, f);
 }
 
+bool File::eof() {
+	return feof(f) != 0;
+}
+
 byte File::readByte() {
 	byte v;
 	read(&v, sizeof(byte));
@@ -39,16 +43,6 @@ uint32 File::readLong() {
 	return FROM_LE_32(v);
 }
 
-void File::readString(char* string, int bufferLength) {
-	int i = 0;
-	while (i < bufferLength - 1 && fread(string + i, 1, 1, f) == 1) {
-		if (string[i] == '\n' || string[i] == 0)
-			break;
-		++ i;
-	}
-	string[i] = 0;
-}
-
 void File::writeByte(byte v) {
 	write(&v, sizeof(byte));
 }
diff --git a/devtools/create_supernova/file.h b/devtools/create_supernova/file.h
index dd33e41..f285293 100644
--- a/devtools/create_supernova/file.h
+++ b/devtools/create_supernova/file.h
@@ -45,11 +45,11 @@ public:
 	uint32 pos();
 	long read(void *buffer, int len);
 	void write(const void *buffer, int len);
+	bool eof();
 
 	byte readByte();
 	uint16 readWord();
 	uint32 readLong();
-	void readString(char*, int bufferLength);
 	void writeByte(byte v);
 	void writeWord(uint16 v);
 	void writeLong(uint32 v);


Commit: 66a335eb187923a721edf9a433ac0361575c5f61
    https://github.com/scummvm/scummvm/commit/66a335eb187923a721edf9a433ac0361575c5f61
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2019-05-28T23:55:35+01:00

Commit Message:
Revert "STARTREK: Start adding a console"

This reverts commit 33fb9809c3a1353d927a3c7dfa41e673d79a089e.
The engine/startrek/console.h and engine/startrek/console.cpp
files were missing from that commit, which break compilation.

Changed paths:
    engines/startrek/events.cpp
    engines/startrek/graphics.cpp
    engines/startrek/module.mk
    engines/startrek/startrek.cpp
    engines/startrek/startrek.h


diff --git a/engines/startrek/events.cpp b/engines/startrek/events.cpp
index c425b09..d8935bd 100644
--- a/engines/startrek/events.cpp
+++ b/engines/startrek/events.cpp
@@ -19,7 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#include "startrek/console.h"
 #include "startrek/startrek.h"
 
 namespace StarTrek {
@@ -62,9 +61,6 @@ void StarTrekEngine::pollEvents(bool queueEvents) {
 			break;
 
 		case Common::EVENT_KEYDOWN:
-			if (event.kbd.keycode == Common::KEYCODE_d && (event.kbd.flags & Common::KBD_CTRL))
-				_console->attach();
-
 			if (queueEvents) {
 				trekEvent.type = TREKEVENT_KEYDOWN;
 				addEventToQueue(trekEvent);
diff --git a/engines/startrek/graphics.cpp b/engines/startrek/graphics.cpp
index c99d886..5c6a144 100644
--- a/engines/startrek/graphics.cpp
+++ b/engines/startrek/graphics.cpp
@@ -20,7 +20,6 @@
  */
 
 #include "startrek/common.h"
-#include "startrek/console.h"
 #include "startrek/graphics.h"
 
 #include "common/algorithm.h"
@@ -638,7 +637,6 @@ void Graphics::updateScreen() {
 		_mouseWarpY = -1;
 	}
 
-	//_vm->_console->onFrame();
 	_vm->_system->updateScreen();
 	_vm->_system->delayMillis(10);
 }
diff --git a/engines/startrek/module.mk b/engines/startrek/module.mk
index db2a3fb..0f82c85 100644
--- a/engines/startrek/module.mk
+++ b/engines/startrek/module.mk
@@ -5,7 +5,6 @@ MODULE_OBJS = \
 	awaymission.o \
 	bitmap.o \
 	common.o \
-	console.o \
 	detection.o \
 	events.o \
 	filestream.o \
diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp
index 12680c6..6160f9c 100644
--- a/engines/startrek/startrek.cpp
+++ b/engines/startrek/startrek.cpp
@@ -37,7 +37,6 @@
 #include "engines/util.h"
 #include "video/qt_decoder.h"
 
-#include "startrek/console.h"
 #include "startrek/filestream.h"
 #include "startrek/iwfile.h"
 #include "startrek/lzss.h"
@@ -108,18 +107,14 @@ StarTrekEngine::StarTrekEngine(OSystem *syst, const StarTrekGameDescription *gam
 StarTrekEngine::~StarTrekEngine() {
 	delete _activeMenu->nextMenu;
 	delete _activeMenu;
-
-	delete _console;
-	delete _sound;
 	delete _gfx;
-
+	delete _sound;
 	delete _macResFork;
 }
 
 Common::Error StarTrekEngine::run() {
 	_gfx = new Graphics(this);
 	_sound = new Sound(this);
-	_console = new Console(this);
 
 	if (getPlatform() == Common::kPlatformMacintosh) {
 		_macResFork = new Common::MacResManager();
diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h
index a575aad..bfc8266 100644
--- a/engines/startrek/startrek.h
+++ b/engines/startrek/startrek.h
@@ -61,7 +61,6 @@ namespace StarTrek {
 
 class StarTrekEngine;
 class Room;
-class Console;
 
 typedef String(StarTrekEngine::*TextGetterFunc)(int, uintptr, String *);
 
@@ -777,15 +776,14 @@ public:
 
 	Graphics *_gfx;
 	Sound *_sound;
-	Console *_console;
 	SharedPtr<IWFile> _iwFile;
-	SharedPtr<Room> _room;
 
 private:
 	Common::RandomSource _randomSource;
 	Common::SineTable _sineTable;
 
 	Common::MacResManager *_macResFork;
+	SharedPtr<Room> _room;
 };
 
 // Static function


Commit: 8999b95053c6a22d4b4d639c584f1ad7513a5785
    https://github.com/scummvm/scummvm/commit/8999b95053c6a22d4b4d639c584f1ad7513a5785
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2019-05-29T00:02:33+01:00

Commit Message:
SUPERNOVA: Add English translation for Help screen

Changed paths:
    dists/engine-data/supernova.dat


diff --git a/dists/engine-data/supernova.dat b/dists/engine-data/supernova.dat
index 5421142..a3c798b 100644
Binary files a/dists/engine-data/supernova.dat and b/dists/engine-data/supernova.dat differ





More information about the Scummvm-git-logs mailing list