diff options
-rw-r--r-- | engines/supernova/graphics.cpp | 104 | ||||
-rw-r--r-- | engines/supernova/graphics.h | 4 | ||||
-rw-r--r-- | engines/supernova/supernova.cpp | 5 |
3 files changed, 70 insertions, 43 deletions
diff --git a/engines/supernova/graphics.cpp b/engines/supernova/graphics.cpp index 79087bfed8..ae71db6a7d 100644 --- a/engines/supernova/graphics.cpp +++ b/engines/supernova/graphics.cpp @@ -123,48 +123,72 @@ bool MSNImageDecoder::loadStream(Common::SeekableReadStream &stream) { return true; } -bool MSNImageDecoder::loadSection(int section) { +bool MSNImageDecoder::loadSection(int filenumber, int section) { + int imageWidth = 320; + int imageHeight = 200; _surface = new Graphics::Surface; - _surface->create(320, 200, g_system->getScreenFormat()); - byte *surfacePixels = static_cast<byte *>(_surface->getPixels()); - - const uint32 kInvalidAddress = 0x00FFFFFF; - - size_t image = section; - if (image < 128) { - do { - uint32 offset = (_section[image].addressHigh << 16) + _section[image].addressLow; - if (offset == kInvalidAddress || _section[image].x2 == 0) { - return false; - } - int width = _section[image].x2 - _section[image].x1 + 1; - int height = _section[image].y2 - _section[image].y1 + 1; - uint32 destAddress = 320 * _section[image].y1 + _section[image].x1; - while (height) { - Common::copy(_encodedImage + offset, _encodedImage + offset + width, surfacePixels + destAddress); - offset += width; - destAddress += 320; - --height; - } - - image = _section[image].next; - } while (image != 0); + _filenumber = filenumber; + + if (filenumber == 1 || filenumber == 2) { + imageWidth = 640; + imageHeight = 480; + _pitch = 640; + + _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) ? 11 : 0; + *surfacePixels++ = (_encodedImage[i] & 0x40) ? 11 : 0; + *surfacePixels++ = (_encodedImage[i] & 0x20) ? 11 : 0; + *surfacePixels++ = (_encodedImage[i] & 0x10) ? 11 : 0; + *surfacePixels++ = (_encodedImage[i] & 0x08) ? 11 : 0; + *surfacePixels++ = (_encodedImage[i] & 0x04) ? 11 : 0; + *surfacePixels++ = (_encodedImage[i] & 0x02) ? 11 : 0; + *surfacePixels++ = (_encodedImage[i] & 0x01) ? 11 : 0; + } } else { - image -= 128; - do { - int width = _section[image].x2 - _section[image].x1 + 1; - int height = _section[image].y2 - _section[image].y1 + 1; - uint32 destAddress = 320 * _section[image].y1 + _section[image].x1; - uint32 offset = (_section[image].addressHigh << 16) + _section[image].addressLow + destAddress; - while (height) { - Common::copy(_encodedImage + offset, _encodedImage + offset + width, surfacePixels + destAddress); - offset += 320; - destAddress += 320; - --height; - } - - image = _section[image].next; - } while (image != 0); + _pitch = 320; + _surface->create(imageWidth, imageHeight, g_system->getScreenFormat()); + byte *surfacePixels = static_cast<byte *>(_surface->getPixels()); + + const uint32 kInvalidAddress = 0x00FFFFFF; + + size_t image = section; + if (image < 128) { + do { + uint32 offset = (_section[image].addressHigh << 16) + _section[image].addressLow; + if (offset == kInvalidAddress || _section[image].x2 == 0) { + return false; + } + int width = _section[image].x2 - _section[image].x1 + 1; + int height = _section[image].y2 - _section[image].y1 + 1; + uint32 destAddress = imageWidth * _section[image].y1 + _section[image].x1; + while (height) { + Common::copy(_encodedImage + offset, _encodedImage + offset + width, surfacePixels + destAddress); + offset += width; + destAddress += imageWidth; + --height; + } + + image = _section[image].next; + } while (image != 0); + } else { + image -= 128; + do { + int width = _section[image].x2 - _section[image].x1 + 1; + int height = _section[image].y2 - _section[image].y1 + 1; + uint32 destAddress = imageWidth * _section[image].y1 + _section[image].x1; + uint32 offset = (_section[image].addressHigh << 16) + _section[image].addressLow + destAddress; + while (height) { + Common::copy(_encodedImage + offset, _encodedImage + offset + width, surfacePixels + destAddress); + offset += imageWidth; + destAddress += imageWidth; + --height; + } + + image = _section[image].next; + } while (image != 0); + } } return true; diff --git a/engines/supernova/graphics.h b/engines/supernova/graphics.h index 119051090e..d41b70769e 100644 --- a/engines/supernova/graphics.h +++ b/engines/supernova/graphics.h @@ -46,11 +46,13 @@ public: virtual const Graphics::Surface *getSurface() const { return _surface; } virtual const byte *getPalette() const { return _palette; } - bool loadSection(int _section); + bool loadSection(int filenumber, int section); static const int kMaxSections = 50; static const int kMaxClickFields = 80; + int _filenumber; + int _pitch; Graphics::Surface *_surface; byte *_palette; byte *_encodedImage; diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index c4911548c2..e00875f1d4 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -222,11 +222,12 @@ void SupernovaEngine::renderImage(int filenumber, int section, bool fullscreen) error("File %s could not be read!", file.getName()); } - if (_currentImage.loadStream(file) && _currentImage.loadSection(section)) { + if (_currentImage.loadStream(file) && _currentImage.loadSection(filenumber, section)) { _system->getPaletteManager()->setPalette(_currentImage.getPalette(), 16, 239); paletteBrightness(); if (fullscreen) { - _system->copyRectToScreen(_currentImage.getSurface()->getPixels(), 320, 0, 0, 320, 200); + _system->copyRectToScreen(_currentImage.getSurface()->getPixels(), + _currentImage._pitch, 0, 0, kScreenWidth, kScreenHeight); } else { size_t offset = _currentImage._section[section].y1 * 320 + _currentImage._section[section].x1; _system->copyRectToScreen(static_cast<const byte *>(_currentImage.getSurface()->getPixels()) + offset, |