diff options
author | Tomas Jakobsson | 2013-01-06 18:58:33 +0100 |
---|---|---|
committer | Tomas Jakobsson | 2013-01-06 20:04:45 +0100 |
commit | 548b505b687fec897b6d35903253f8935c8bf5ff (patch) | |
tree | bc500b29a7c2e3f3f4f357d0c35f6e2f4ffb9a19 /engines/parallaction/disk_ns.cpp | |
parent | b85d51c4a3dc4cca681ca4b6cdd6826aabc7e68e (diff) | |
download | scummvm-rg350-548b505b687fec897b6d35903253f8935c8bf5ff.tar.gz scummvm-rg350-548b505b687fec897b6d35903253f8935c8bf5ff.tar.bz2 scummvm-rg350-548b505b687fec897b6d35903253f8935c8bf5ff.zip |
PARALLACTION: Update to new IFFDecoder for ILBM images
Diffstat (limited to 'engines/parallaction/disk_ns.cpp')
-rw-r--r-- | engines/parallaction/disk_ns.cpp | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp index bad854525d..f03f16ca37 100644 --- a/engines/parallaction/disk_ns.cpp +++ b/engines/parallaction/disk_ns.cpp @@ -22,9 +22,11 @@ #include "common/config-manager.h" #include "common/fs.h" +#include "common/iff_container.h" #include "common/memstream.h" #include "common/substream.h" #include "common/textconsole.h" +#include "graphics/decoders/iff.h" #include "parallaction/parser.h" #include "parallaction/parallaction.h" @@ -312,7 +314,7 @@ void DosDisk_ns::decodeCnv(byte *data, uint16 numFrames, uint16 width, uint16 he int32 decsize = numFrames * width * height; bool packed = (stream->size() - stream->pos()) != decsize; if (packed) { - Graphics::PackBitsReadStream decoder(*stream); + Common::PackBitsReadStream decoder(*stream); decoder.read(data, decsize); } else { stream->read(data, decsize); @@ -914,17 +916,15 @@ void AmigaDisk_ns::buildMask(byte* buf) { void AmigaDisk_ns::loadBackground(BackgroundInfo& info, const char *name) { - PaletteFxRange ranges[6]; - byte pal[768]; - Common::SeekableReadStream *s = openFile(name); - ILBMLoader loader(&info.bg, pal, ranges); - loader.load(s, true); + Graphics::IFFDecoder decoder; + decoder.loadStream(*s); + info.bg.copyFrom(*decoder.getSurface()); info.width = info.bg.w; info.height = info.bg.h; - byte *p = pal; + const byte *p = decoder.getPalette(); for (uint i = 0; i < 32; i++) { byte r = *p >> 2; p++; @@ -935,8 +935,15 @@ void AmigaDisk_ns::loadBackground(BackgroundInfo& info, const char *name) { info.palette.setEntry(i, r, g, b); } - for (uint j = 0; j < 6; j++) { - info.setPaletteRange(j, ranges[j]); + const Common::Array<Graphics::IFFDecoder::PaletteRange> &paletteRanges = decoder.getPaletteRanges(); + for (uint j = 0; j < 6 && j < paletteRanges.size(); j++) { + PaletteFxRange range; + range._timer = paletteRanges[j].timer; + range._step = paletteRanges[j].step; + range._flags = paletteRanges[j].flags; + range._first = paletteRanges[j].first; + range._last = paletteRanges[j].last; + info.setPaletteRange(j, range); } } @@ -952,19 +959,25 @@ void AmigaDisk_ns::loadMask_internal(BackgroundInfo& info, const char *name) { return; // no errors if missing mask files: not every location has one } - byte pal[768]; - ILBMLoader loader(ILBMLoader::BODYMODE_MASKBUFFER, pal); - loader.load(s, true); + Graphics::IFFDecoder decoder; + decoder.setNumRelevantPlanes(2); // use only 2 first bits from each pixel + decoder.setPixelPacking(true); // pack 4 2bit pixels into 1 byte + decoder.loadStream(*s); + const byte *p = decoder.getPalette(); byte r, g, b; for (uint i = 0; i < 4; i++) { - r = pal[i*3]; - g = pal[i*3+1]; - b = pal[i*3+2]; + r = p[i*3]; + g = p[i*3+1]; + b = p[i*3+2]; info.layers[i] = (((r << 4) & 0xF00) | (g & 0xF0) | (b >> 4)) & 0xFF; } - info._mask = loader._maskBuffer; + info._mask = new MaskBuffer; + // surface width was shrunk to 1/4th of the bitmap width due to the pixel packing + info._mask->create(decoder.getSurface()->w * 4, decoder.getSurface()->h); + memcpy(info._mask->data, decoder.getSurface()->pixels, info._mask->size); + info._mask->bigEndian = true; } void AmigaDisk_ns::loadPath_internal(BackgroundInfo& info, const char *name) { @@ -977,9 +990,15 @@ void AmigaDisk_ns::loadPath_internal(BackgroundInfo& info, const char *name) { return; // no errors if missing path files: not every location has one } - ILBMLoader loader(ILBMLoader::BODYMODE_PATHBUFFER); - loader.load(s, true); - info._path = loader._pathBuffer; + Graphics::IFFDecoder decoder; + decoder.setNumRelevantPlanes(1); // use only first bit from each pixel + decoder.setPixelPacking(true); // pack 8 1bit pixels into 1 byte + decoder.loadStream(*s); + + info._path = new PathBuffer; + // surface width was shrunk to 1/8th of the bitmap width due to the pixel packing + info._path->create(decoder.getSurface()->w * 8, decoder.getSurface()->h); + memcpy(info._path->data, decoder.getSurface()->pixels, info._path->size); info._path->bigEndian = true; } |