aboutsummaryrefslogtreecommitdiff
path: root/engines/supernova
diff options
context:
space:
mode:
authorJaromir Wysoglad2019-06-28 11:55:35 +0200
committerThierry Crozat2019-07-28 15:09:14 +0100
commit12f4211fb22141de409becced10826a926a28fe8 (patch)
tree70c324ddc32623735c4205b0031fae6ae5729520 /engines/supernova
parent80c1cd9e613b9204e4eb095c5dc788526c9b6006 (diff)
downloadscummvm-rg350-12f4211fb22141de409becced10826a926a28fe8.tar.gz
scummvm-rg350-12f4211fb22141de409becced10826a926a28fe8.tar.bz2
scummvm-rg350-12f4211fb22141de409becced10826a926a28fe8.zip
SUPERNOVA: Load MS2 datafiles from .dat file.
Diffstat (limited to 'engines/supernova')
-rw-r--r--engines/supernova/graphics.cpp59
-rw-r--r--engines/supernova/graphics.h1
2 files changed, 52 insertions, 8 deletions
diff --git a/engines/supernova/graphics.cpp b/engines/supernova/graphics.cpp
index af3a1b30ad..479a12e3df 100644
--- a/engines/supernova/graphics.cpp
+++ b/engines/supernova/graphics.cpp
@@ -25,6 +25,7 @@
#include "common/stream.h"
#include "common/system.h"
#include "common/config-manager.h"
+#include "common/memstream.h"
#include "graphics/palette.h"
#include "graphics/surface.h"
@@ -69,6 +70,7 @@ MSNImage::~MSNImage() {
bool MSNImage::init(int filenumber) {
Common::File file;
+ _filenumber = filenumber;
if (_MSPart == 1) {
if (!file.open(Common::String::format("msn_data.%03d", filenumber))) {
warning("Image data file msn_data.%03d could not be read!", filenumber);
@@ -76,19 +78,19 @@ bool MSNImage::init(int filenumber) {
}
}
else if (_MSPart == 2) {
- if (!file.open(Common::String::format("ms2_data.%03d", filenumber))) {
- warning("Image data file ms2_data.%03d could not be read!", filenumber);
- return false;
+ if (!loadFromEngineDataFile()) {
+ if (!file.open(Common::String::format("ms2_data.%03d", filenumber))) {
+ warning("Image data file ms2_data.%03d could not be read!", filenumber);
+ return false;
+ }
+ loadStream(file);
}
}
- _filenumber = filenumber;
- loadStream(file);
-
return true;
}
-bool MSNImage::loadFromEngineDataFile() {
+bool MSNImage::loadPbmFromEngineDataFile() {
Common::String name;
Common::File f;
char id[5], lang[5];
@@ -149,6 +151,47 @@ bool MSNImage::loadFromEngineDataFile() {
return false;
}
+bool MSNImage::loadFromEngineDataFile() {
+ Common::String name;
+ Common::File f;
+ char id[5], lang[5];
+ id[4] = lang[4] = '\0';
+ if (_MSPart == 1) {
+ return false;
+ } else if (_MSPart == 2) {
+ if (_filenumber == 15)
+ name = "M015";
+ else
+ return false;
+
+ if (!f.open(SUPERNOVA2_DAT))
+ return false;
+
+ f.read(id, 3);
+ if (strncmp(id, "MS2", 3) != 0)
+ return false;
+ int version = f.readByte();
+ if (version != SUPERNOVA2_DAT_VERSION)
+ return false;
+ }
+
+ Common::String cur_lang = ConfMan.get("language");
+
+ while (!f.eos()) {
+ f.read(id, 4);
+ f.read(lang, 4);
+ uint32 size = f.readUint32LE();
+ if (f.eos())
+ break;
+ if (name == id && cur_lang == lang) {
+ return loadStream(*f.readStream(size));
+ } else
+ f.skip(size);
+ }
+
+ return false;
+}
+
bool MSNImage::loadStream(Common::SeekableReadStream &stream) {
destroy();
@@ -211,7 +254,7 @@ bool MSNImage::loadStream(Common::SeekableReadStream &stream) {
// Newspaper images may be in the engine data file. So first try to read
// it from there.
- if (!loadFromEngineDataFile()) {
+ if (!loadPbmFromEngineDataFile()) {
// Load the image from the stream
byte zwCodes[256] = {0};
byte numRepeat = stream.readByte();
diff --git a/engines/supernova/graphics.h b/engines/supernova/graphics.h
index 5a790ec249..c69d650a80 100644
--- a/engines/supernova/graphics.h
+++ b/engines/supernova/graphics.h
@@ -81,6 +81,7 @@ public:
private:
int _MSPart;
bool loadFromEngineDataFile();
+ bool loadPbmFromEngineDataFile();
bool loadSections();
};