diff options
author | Thierry Crozat | 2017-11-17 23:35:19 +0000 |
---|---|---|
committer | Thierry Crozat | 2018-01-23 02:15:41 +0000 |
commit | 177539ba2ed85af4aa27a72110948063a8257a03 (patch) | |
tree | dc948008f919ac345d695300e880de406141d14e | |
parent | cbfa0a0640eeeb2c86edd9c8d4f3e5925c437e05 (diff) | |
download | scummvm-rg350-177539ba2ed85af4aa27a72110948063a8257a03.tar.gz scummvm-rg350-177539ba2ed85af4aa27a72110948063a8257a03.tar.bz2 scummvm-rg350-177539ba2ed85af4aa27a72110948063a8257a03.zip |
SUPERNOVA: Load images on demand
-rw-r--r-- | engines/supernova/graphics.cpp | 3 | ||||
-rw-r--r-- | engines/supernova/state.cpp | 2 | ||||
-rw-r--r-- | engines/supernova/supernova.cpp | 23 | ||||
-rw-r--r-- | engines/supernova/supernova.h | 3 |
4 files changed, 17 insertions, 14 deletions
diff --git a/engines/supernova/graphics.cpp b/engines/supernova/graphics.cpp index ee2bfe8e3a..d461d79c93 100644 --- a/engines/supernova/graphics.cpp +++ b/engines/supernova/graphics.cpp @@ -50,7 +50,8 @@ MSNImageDecoder::~MSNImageDecoder() { bool MSNImageDecoder::init(int filenumber) { Common::File file; if (!file.open(Common::String::format("msn_data.%03d", filenumber))) { - error("File %s could not be read!", file.getName()); + warning("Image data file %s could not be read!", file.getName()); + return false; } _filenumber = filenumber; diff --git a/engines/supernova/state.cpp b/engines/supernova/state.cpp index 95f48e4ce5..2aa5546a9d 100644 --- a/engines/supernova/state.cpp +++ b/engines/supernova/state.cpp @@ -594,7 +594,7 @@ void GameManager::processInput() { for (int i = 0; (_currentRoom->getObject(i)->_id != INVALIDOBJECT) && (field == -1) && i < kMaxObject; i++) { click = _currentRoom->getObject(i)->_click; - if (click != 255) { + if (click != 255 && _vm->_currentImage) { MSNImageDecoder::ClickField *clickField = _vm->_currentImage->_clickField; do { if ((_mouseX >= clickField[click].x1) && (_mouseX <= clickField[click].x2) && diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index 80a8404599..56ea113eac 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -100,7 +100,7 @@ SupernovaEngine::SupernovaEngine(OSystem *syst) : Engine(syst) , _console(NULL) , _gm(NULL) - , _currentImage(_images) + , _currentImage(NULL) , _brightness(255) , _menuBrightness(255) , _delay(33) @@ -126,6 +126,7 @@ SupernovaEngine::SupernovaEngine(OSystem *syst) SupernovaEngine::~SupernovaEngine() { DebugMan.clearAllDebugChannels(); + delete _currentImage; delete _rnd; delete _console; delete _gm; @@ -329,10 +330,6 @@ Common::Error SupernovaEngine::loadGameStrings() { } void SupernovaEngine::initData() { - // Images - for (int i = 0; i < 44; ++i) - _images[i].init(i); - // Sound // Note: // - samples start with a header of 6 bytes: 01 SS SS 00 AD 00 @@ -458,6 +455,9 @@ void SupernovaEngine::renderImageSection(int section) { } void SupernovaEngine::renderImage(int section) { + if (!_currentImage) + return; + bool sectionVisible = true; if (section > 128) { @@ -477,12 +477,17 @@ void SupernovaEngine::renderImage(int section) { } bool SupernovaEngine::setCurrentImage(int filenumber) { - if (filenumber == -1 || filenumber > ARRAYSIZE(_images) - 1) { - warning("Trying to display image from out of bound file number %d", filenumber); + if (_currentImage && _currentImage->_filenumber == filenumber) + return true; + + delete _currentImage; + _currentImage = new MSNImageDecoder(); + if (!_currentImage->init(filenumber)) { + delete _currentImage; + _currentImage = NULL; return false; } - _currentImage = &(_images[filenumber]); _system->getPaletteManager()->setPalette(_currentImage->getPalette(), 16, 239); paletteBrightness(); return true; @@ -690,7 +695,7 @@ void SupernovaEngine::paletteBrightness() { } for (uint i = 0; i < 717; ++i) { const byte *imagePalette; - if (_currentImage->getPalette()) { + if (_currentImage && _currentImage->getPalette()) { imagePalette = _currentImage->getPalette(); } else { imagePalette = palette + 48; diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h index 8aace03c1f..895f49dc92 100644 --- a/engines/supernova/supernova.h +++ b/engines/supernova/supernova.h @@ -90,9 +90,6 @@ public: ScreenBufferStack _screenBuffer; byte _mouseNormal[256]; byte _mouseWait[256]; - // TODO check this! There are 56 data files (0 to 55) and at least the outro - // tries to displayimage from file 55 (and fails!). - MSNImageDecoder _images[44]; MSNImageDecoder *_currentImage; struct SoundSample { byte *_buffer; |