diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/supernova/graphics.cpp | 92 | ||||
-rw-r--r-- | engines/supernova/screen.cpp | 12 | ||||
-rw-r--r-- | engines/supernova/screen.h | 4 | ||||
-rw-r--r-- | engines/supernova/supernova.cpp | 130 | ||||
-rw-r--r-- | engines/supernova/supernova.h | 5 |
5 files changed, 135 insertions, 108 deletions
diff --git a/engines/supernova/graphics.cpp b/engines/supernova/graphics.cpp index 7bd1cc6063..fb248e3e81 100644 --- a/engines/supernova/graphics.cpp +++ b/engines/supernova/graphics.cpp @@ -96,36 +96,24 @@ bool MSNImage::loadPbmFromEngineDataFile() { Common::File f; char id[5], lang[5]; id[4] = lang[4] = '\0'; - if (_MSPart == 1) { - if (_filenumber == 1) - name = "IMG1"; - else if (_filenumber == 2) - name = "IMG2"; - else - - return false; - if (!f.open(SUPERNOVA_DAT)) - return false; - - f.read(id, 3); - if (strncmp(id, "MSN", 3) != 0) - return false; - int version = f.readByte(); - if (version != SUPERNOVA_DAT_VERSION) - return false; - } else if (_MSPart == 2) { - return false; - - if (!f.open(SUPERNOVA2_DAT)) - return false; + if (_MSPart == 2) + return false; + if (_filenumber == 1) + name = "IMG1"; + else if (_filenumber == 2) + name = "IMG2"; + else - f.read(id, 3); - if (strncmp(id, "MS2", 3) != 0) - return false; - int version = f.readByte(); - if (version != SUPERNOVA2_DAT_VERSION) - return false; - } + return false; + if (!f.open(SUPERNOVA_DAT)) + return false; + + f.read(id, 3); + if (strncmp(id, "MSN", 3) != 0) + return false; + int version = f.readByte(); + if (version != SUPERNOVA_DAT_VERSION) + return false; Common::String cur_lang = ConfMan.get("language"); @@ -133,8 +121,23 @@ bool MSNImage::loadPbmFromEngineDataFile() { // 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). - + int part; + uint32 gameBlockSize; while (!f.eos()) { + part = f.readByte(); + gameBlockSize = f.readUint32LE(); + if (f.eos()){ + return false; + } + if (part == _MSPart) { + break; + } else + f.skip(gameBlockSize); + } + + uint32 readSize = 0; + + while (readSize < gameBlockSize) { f.read(id, 4); f.read(lang, 4); uint32 size = f.readUint32LE(); @@ -142,8 +145,10 @@ bool MSNImage::loadPbmFromEngineDataFile() { break; if (name == id && cur_lang == lang) { return f.read(_encodedImage, size) == size; - } else + } else { f.skip(size); + readSize += size; + } } return false; @@ -164,20 +169,35 @@ bool MSNImage::loadFromEngineDataFile() { else return false; - if (!f.open(SUPERNOVA2_DAT)) + if (!f.open(SUPERNOVA_DAT)) return false; f.read(id, 3); - if (strncmp(id, "MS2", 3) != 0) + if (strncmp(id, "MSN", 3) != 0) return false; int version = f.readByte(); - if (version != SUPERNOVA2_DAT_VERSION) + if (version != SUPERNOVA_DAT_VERSION) return false; } Common::String cur_lang = ConfMan.get("language"); + int part; + uint32 gameBlockSize; while (!f.eos()) { + part = f.readByte(); + gameBlockSize = f.readUint32LE(); + if (f.eos()){ + return false; + } + if (part == _MSPart) { + break; + } else + f.skip(gameBlockSize); + } + + uint32 readSize = 0; + while (readSize < gameBlockSize) { f.read(id, 4); f.read(lang, 4); uint32 size = f.readUint32LE(); @@ -185,8 +205,10 @@ bool MSNImage::loadFromEngineDataFile() { break; if (name == id && cur_lang == lang) { return loadStream(*f.readStream(size)); - } else + } else { f.skip(size); + readSize += size; + } } return false; diff --git a/engines/supernova/screen.cpp b/engines/supernova/screen.cpp index 7dc04b0c82..8aacbe83b0 100644 --- a/engines/supernova/screen.cpp +++ b/engines/supernova/screen.cpp @@ -107,6 +107,7 @@ Marquee::Marquee(Screen *screen, MarqueeId id, const char *text) , _textBegin(text) , _delay(0) , _loop(false) + , _oldColor(nullptr) , _screen(screen) { if (_screen->_vm->_MSPart == 1) { _color = kColorLightBlue; @@ -117,6 +118,10 @@ Marquee::Marquee(Screen *screen, MarqueeId id, const char *text) _y = 1; } } else if (_screen->_vm->_MSPart == 2) { + byte purple[3] = {0x9b, 0x00, 0xfb}; + _oldColor = new byte[3]; + _screen->_vm->_system->getPaletteManager()->grabPalette(_oldColor, kColorPurple, 1); + _screen->_vm->_system->getPaletteManager()->setPalette(purple, kColorPurple, 1); _color = kColorPurple; if (id == kMarqueeIntro) { _y = 191; @@ -133,6 +138,13 @@ Marquee::Marquee(Screen *screen, MarqueeId id, const char *text) _screen->_textColor = _color; } +Marquee::~Marquee() { + if (_screen->_vm->_MSPart == 2) { + _screen->_vm->_system->getPaletteManager()->setPalette(_oldColor, kColorPurple, 1); + delete _oldColor; + } +} + void Marquee::clearText() { _screen->renderBox(_x, _y - 1, _textWidth + 1, 9, kColorBlack); } diff --git a/engines/supernova/screen.h b/engines/supernova/screen.h index 0779973fe9..5a94dc05d7 100644 --- a/engines/supernova/screen.h +++ b/engines/supernova/screen.h @@ -64,7 +64,7 @@ enum Color { kColorLightGreen = 13, kColorLightYellow = 14, kColorLightRed = 15, - kColorPurple = 35, + kColorPurple = 16, kColorCursorTransparent = kColorWhite25 }; @@ -102,6 +102,7 @@ public: }; Marquee(Screen *screen, MarqueeId id, const char *text); + ~Marquee(); bool renderCharacter(); void reset(); @@ -115,6 +116,7 @@ private: bool _loop; int _delay; int _color; + byte *_oldColor; int _x; int _y; int _textWidth; diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index d186995f6b..16569cf83a 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -197,47 +197,42 @@ Common::Error SupernovaEngine::loadGameStrings() { Common::File f; char id[5], lang[5]; id[4] = lang[4] = '\0'; - if (_MSPart == 1) { - if (!f.open(SUPERNOVA_DAT)) { - GUIErrorMessageFormat(_("Unable to locate the '%s' engine data file."), SUPERNOVA_DAT); - return Common::kReadingFailed; - } - f.read(id, 3); - if (strncmp(id, "MSN", 3) != 0) { - GUIErrorMessageFormat(_("The '%s' engine data file is corrupt."), SUPERNOVA_DAT); - return Common::kReadingFailed; - } + if (!f.open(SUPERNOVA_DAT)) { + GUIErrorMessageFormat(_("Unable to locate the '%s' engine data file."), SUPERNOVA_DAT); + return Common::kReadingFailed; + } + f.read(id, 3); + if (strncmp(id, "MSN", 3) != 0) { + GUIErrorMessageFormat(_("The '%s' engine data file is corrupt."), SUPERNOVA_DAT); + return Common::kReadingFailed; + } - int version = f.readByte(); - if (version != SUPERNOVA_DAT_VERSION) { - GUIErrorMessageFormat( - _("Incorrect version of the '%s' engine data file found. Expected %d but got %d."), - SUPERNOVA_DAT, SUPERNOVA_DAT_VERSION, version); - return Common::kReadingFailed; - } + int version = f.readByte(); + if (version != SUPERNOVA_DAT_VERSION) { + GUIErrorMessageFormat( + _("Incorrect version of the '%s' engine data file found. Expected %d but got %d."), + SUPERNOVA_DAT, SUPERNOVA_DAT_VERSION, version); + return Common::kReadingFailed; } - else if (_MSPart == 2) { - if (!f.open(SUPERNOVA2_DAT)) { - GUIErrorMessageFormat(_("Unable to locate the '%s' engine data file."), SUPERNOVA2_DAT); - return Common::kReadingFailed; - } - f.read(id, 3); - if (strncmp(id, "MS2", 3) != 0) { - GUIErrorMessageFormat(_("The '%s' engine data file is corrupt."), SUPERNOVA2_DAT); - return Common::kReadingFailed; - } - int version = f.readByte(); - if (version != SUPERNOVA2_DAT_VERSION) { - GUIErrorMessageFormat( - _("Incorrect version of the '%s' engine data file found. Expected %d but got %d."), - SUPERNOVA2_DAT, SUPERNOVA2_DAT_VERSION, version); + int part; + uint32 gameBlockSize; + while (!f.eos()) { + part = f.readByte(); + gameBlockSize = f.readUint32LE(); + if (f.eos()){ + GUIErrorMessageFormat(_("Unable to find block for part %d"), _MSPart); return Common::kReadingFailed; } + if (part == _MSPart) { + break; + } else + f.skip(gameBlockSize); } + uint32 readSize = 0; - while (!f.eos()) { + while (readSize < gameBlockSize) { f.read(id, 4); f.read(lang, 4); uint32 size = f.readUint32LE(); @@ -253,8 +248,10 @@ Common::Error SupernovaEngine::loadGameStrings() { size -= s.size() + 1; } return Common::kNoError; - } else + } else { f.skip(size); + readSize += size; + } } Common::Language l = Common::parseLanguage(cur_lang); @@ -517,47 +514,42 @@ Common::SeekableReadStream *SupernovaEngine::getBlockFromDatFile(Common::String Common::File f; char id[5], lang[5]; id[4] = lang[4] = '\0'; - if (_MSPart == 1) { - if (!f.open(SUPERNOVA_DAT)) { - GUIErrorMessageFormat(_("Unable to locate the '%s' engine data file."), SUPERNOVA_DAT); - return nullptr; - } - f.read(id, 3); - if (strncmp(id, "MSN", 3) != 0) { - GUIErrorMessageFormat(_("The '%s' engine data file is corrupt."), SUPERNOVA_DAT); - return nullptr; - } + if (!f.open(SUPERNOVA_DAT)) { + GUIErrorMessageFormat(_("Unable to locate the '%s' engine data file."), SUPERNOVA_DAT); + return nullptr; + } + f.read(id, 3); + if (strncmp(id, "MSN", 3) != 0) { + GUIErrorMessageFormat(_("The '%s' engine data file is corrupt."), SUPERNOVA_DAT); + return nullptr; + } - int version = f.readByte(); - if (version != SUPERNOVA_DAT_VERSION) { - GUIErrorMessageFormat( - _("Incorrect version of the '%s' engine data file found. Expected %d but got %d."), - SUPERNOVA_DAT, SUPERNOVA_DAT_VERSION, version); - return nullptr; - } + int version = f.readByte(); + if (version != SUPERNOVA_DAT_VERSION) { + GUIErrorMessageFormat( + _("Incorrect version of the '%s' engine data file found. Expected %d but got %d."), + SUPERNOVA_DAT, SUPERNOVA_DAT_VERSION, version); + return nullptr; } - else if (_MSPart == 2) { - if (!f.open(SUPERNOVA2_DAT)) { - GUIErrorMessageFormat(_("Unable to locate the '%s' engine data file."), SUPERNOVA2_DAT); - return nullptr; - } - f.read(id, 3); - if (strncmp(id, "MS2", 3) != 0) { - GUIErrorMessageFormat(_("The '%s' engine data file is corrupt."), SUPERNOVA2_DAT); - return nullptr; - } - int version = f.readByte(); - if (version != SUPERNOVA2_DAT_VERSION) { - GUIErrorMessageFormat( - _("Incorrect version of the '%s' engine data file found. Expected %d but got %d."), - SUPERNOVA2_DAT, SUPERNOVA2_DAT_VERSION, version); + int part; + uint32 gameBlockSize; + while (!f.eos()) { + part = f.readByte(); + gameBlockSize = f.readUint32LE(); + if (f.eos()){ + GUIErrorMessageFormat(_("Unable to find block for part %d"), _MSPart); return nullptr; } + if (part == _MSPart) { + break; + } else + f.skip(gameBlockSize); } + uint32 readSize = 0; - while (!f.eos()) { + while (readSize < gameBlockSize) { f.read(id, 4); f.read(lang, 4); uint32 size = f.readUint32LE(); @@ -565,8 +557,10 @@ Common::SeekableReadStream *SupernovaEngine::getBlockFromDatFile(Common::String break; if (name == id && cur_lang == lang) { return f.readStream(size); - } else + } else { f.skip(size); + readSize += size; + } } return nullptr; diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h index 8a6fe0f9c1..8139d5f00e 100644 --- a/engines/supernova/supernova.h +++ b/engines/supernova/supernova.h @@ -49,10 +49,7 @@ namespace Supernova { #define SAVEGAME_VERSION 10 #define SUPERNOVA_DAT "supernova.dat" -#define SUPERNOVA_DAT_VERSION 2 - -#define SUPERNOVA2_DAT "supernova2.dat" -#define SUPERNOVA2_DAT_VERSION 2 +#define SUPERNOVA_DAT_VERSION 3 class GuiElement; class ResourceManager; |