SUPERNOVA2: Add english translated image

This adds translated image of cyphered text inside Cabin room
I don't think I can get any closer to the original looks with
.pbm format.
This commit is contained in:
Jaromir Wysoglad 2019-06-18 10:31:49 +02:00 committed by Thierry Crozat
parent 76142e2e7d
commit 83e05ea13f
7 changed files with 33 additions and 22 deletions

View File

@ -87,9 +87,9 @@ void writeImage(File& outputFile, const char *name, const char* language) {
else { else {
// We have finished reading the header. // We have finished reading the header.
// Check the size is as expected. // Check the size is as expected.
if (w != 640 || h != 480) { if ((w != 640 || h != 480) && (w != 320 || h != 200)) {
imgFile.close(); 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); printf("Binary pbm file '%s' doesn't have the expected size (expected: 640x480 or 320x200, read: %dx%d). This image will be skipped.\n", fileName, w, h);
return; return;
} }
// And break out of the loop. // And break out of the loop.
@ -121,13 +121,13 @@ void writeImage(File& outputFile, const char *name, const char* language) {
outputFile.writeByte(0); outputFile.writeByte(0);
} }
// Write block size (640*480 / 8) // Write block size
outputFile.writeLong(38400); outputFile.writeLong(w * h / 8);
// Write all the bytes. We should have 38400 bytes (640 * 480 / 8) // Write all the bytes. We should have w * h / 8 bytes
// However we need to invert the bits has the engine expects 1 for the background and 0 for the text (black) // 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. // but pbm uses 0 for white and 1 for black.
for (i = 0 ; i < 38400 ; ++i) { for (i = 0 ; i < w * h / 8 ; ++i) {
byte b = imgFile.readByte(); byte b = imgFile.readByte();
outputFile.writeByte(~b); outputFile.writeByte(~b);
} }
@ -222,7 +222,7 @@ int main(int argc, char *argv[]) {
// 3 bytes: 'MS2' // 3 bytes: 'MS2'
// 1 byte: version // 1 byte: version
// -- data blocks // -- data blocks
// 4 bytes: header 'IMG1' and 'IMG2' for newspaper images (for file 1 and file 2 respectively), // 4 bytes: header 'IMG1' cyphered text image
// 'TEXT' for strings // 'TEXT' for strings
// 4 bytes: language code ('en\0', 'de\0'- see common/language.cpp) // 4 bytes: language code ('en\0', 'de\0'- see common/language.cpp)
// 4 bytes: block size n (uint32) // 4 bytes: block size n (uint32)
@ -240,7 +240,7 @@ int main(int argc, char *argv[]) {
// Other languages // Other languages
const char **l = &lang[0]; const char **l = &lang[0];
while(*l) { while(*l) {
// writeImage(outputFile, "img1", *l); writeImage(outputFile, "img1", *l);
// writeImage(outputFile, "img2", *l); // writeImage(outputFile, "img2", *l);
writeStrings(outputFile, *l); writeStrings(outputFile, *l);
++l; ++l;

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

Binary file not shown.

View File

@ -81,12 +81,9 @@ bool MS2Image::init(int filenumber) {
} }
bool MS2Image::loadFromEngineDataFile() { bool MS2Image::loadFromEngineDataFile() {
//TODO Common::String name;
/*Common::String name; if (_filenumber == 28)
if (_filenumber == 1)
name = "IMG1"; name = "IMG1";
else if (_filenumber == 2)
name = "IMG2";
else else
return false; return false;
@ -96,16 +93,16 @@ bool MS2Image::loadFromEngineDataFile() {
// or the format is not as expected. We will get those warning when reading the // or the format is not as expected. We will get those warning when reading the
// strings anyway (actually the engine will even refuse to start). // strings anyway (actually the engine will even refuse to start).
Common::File f; Common::File f;
if (!f.open(SUPERNOVA_DAT)) if (!f.open(SUPERNOVA2_DAT))
return false; return false;
char id[5], lang[5]; char id[5], lang[5];
id[4] = lang[4] = '\0'; id[4] = lang[4] = '\0';
f.read(id, 3); f.read(id, 3);
if (strncmp(id, "MSN", 3) != 0) if (strncmp(id, "MS2", 3) != 0)
return false; return false;
int version = f.readByte(); int version = f.readByte();
if (version != SUPERNOVA_DAT_VERSION) if (version != SUPERNOVA2_DAT_VERSION)
return false; return false;
while (!f.eos()) { while (!f.eos()) {
@ -118,7 +115,7 @@ bool MS2Image::loadFromEngineDataFile() {
return f.read(_encodedImage, size) == size; return f.read(_encodedImage, size) == size;
} else } else
f.skip(size); f.skip(size);
}*/ }
return false; return false;
} }
@ -222,8 +219,9 @@ bool MS2Image::loadStream(Common::SeekableReadStream &stream) {
bool MS2Image::loadSections() { bool MS2Image::loadSections() {
bool isPoster = _filenumber == 38; bool isPoster = _filenumber == 38;
int imageWidth = isPoster ? 640 : 320; bool isCypheredText = _filenumber == 28 && ConfMan.get("language") == "en";
int imageHeight = isPoster ? 480 : 200; int imageWidth = isPoster || isCypheredText ? 640 : 320;
int imageHeight = isPoster || isCypheredText ? 480 : 200;
_pitch = imageWidth; _pitch = imageWidth;
for (int section = 0; section < _numSections; ++section) { for (int section = 0; section < _numSections; ++section) {
@ -242,6 +240,19 @@ bool MS2Image::loadSections() {
*surfacePixels++ = (_encodedImage[i] & 0x02) ? kColorWhite63 : kColorBlack; *surfacePixels++ = (_encodedImage[i] & 0x02) ? kColorWhite63 : kColorBlack;
*surfacePixels++ = (_encodedImage[i] & 0x01) ? kColorWhite63 : kColorBlack; *surfacePixels++ = (_encodedImage[i] & 0x01) ? kColorWhite63 : kColorBlack;
} }
} else if (isCypheredText) {
surface->create(imageWidth, imageHeight, g_system->getScreenFormat());
byte *surfacePixels = static_cast<byte *>(surface->getPixels());
for (int i = 0; i < imageWidth * imageHeight / 8; ++i) {
*surfacePixels++ = (_encodedImage[i] & 0x80) ? kColorWhite44 : kColorBlack;
*surfacePixels++ = (_encodedImage[i] & 0x40) ? kColorWhite44 : kColorBlack;
*surfacePixels++ = (_encodedImage[i] & 0x20) ? kColorWhite44 : kColorBlack;
*surfacePixels++ = (_encodedImage[i] & 0x10) ? kColorWhite44 : kColorBlack;
*surfacePixels++ = (_encodedImage[i] & 0x08) ? kColorWhite44 : kColorBlack;
*surfacePixels++ = (_encodedImage[i] & 0x04) ? kColorWhite44 : kColorBlack;
*surfacePixels++ = (_encodedImage[i] & 0x02) ? kColorWhite44 : kColorBlack;
*surfacePixels++ = (_encodedImage[i] & 0x01) ? kColorWhite44 : kColorBlack;
}
} else { } else {
uint32 offset = (_section[section].addressHigh << 16) + _section[section].addressLow; uint32 offset = (_section[section].addressHigh << 16) + _section[section].addressLow;

View File

@ -22,6 +22,7 @@
#include "common/str.h" #include "common/str.h"
#include "common/system.h" #include "common/system.h"
#include "common/config-manager.h"
#include "engines/util.h" #include "engines/util.h"
#include "graphics/cursorman.h" #include "graphics/cursorman.h"
#include "graphics/palette.h" #include "graphics/palette.h"
@ -354,7 +355,8 @@ void Screen::renderImageSection(const MS2Image *image, int section, bool invert)
image->_section[section].y1, image->_section[section].y1,
image->_section[section].x2 + 1, image->_section[section].x2 + 1,
image->_section[section].y2 + 1); image->_section[section].y2 + 1);
if (image->_filenumber == 38) { if (image->_filenumber == 38 ||
(image->_filenumber == 28 && ConfMan.get("language") == "en")) {
sectionRect.setWidth(640); sectionRect.setWidth(640);
sectionRect.setHeight(480); sectionRect.setHeight(480);
if (_screenWidth != 640) { if (_screenWidth != 640) {

View File

@ -132,8 +132,6 @@ bool GameManager::deserialize(Common::ReadStream *in, int version) {
for (int i = 0; i < NUMROOMS; ++i) { for (int i = 0; i < NUMROOMS; ++i) {
_rooms[i]->deserialize(in, version); _rooms[i]->deserialize(in, version);
} }
delete _rooms[SHIP];
_rooms[SHIP] = new Ship(_vm, this);
_lastRoom = _rooms[lastRoomId]; _lastRoom = _rooms[lastRoomId];
changeRoom(curRoomId); changeRoom(curRoomId);