From d182fe0221ed8c734c5aab3c18b006c0cc562af4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 13 Sep 2012 01:49:58 +0300 Subject: QUEEN: Switch to the common PCX decoder --- engines/queen/display.cpp | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'engines/queen') diff --git a/engines/queen/display.cpp b/engines/queen/display.cpp index 83dc1a9f60..cd9a1075fa 100644 --- a/engines/queen/display.cpp +++ b/engines/queen/display.cpp @@ -23,9 +23,13 @@ #include "common/system.h" #include "common/events.h" +#include "common/stream.h" +#include "common/memstream.h" #include "graphics/cursorman.h" #include "graphics/palette.h" +#include "graphics/surface.h" +#include "graphics/decoders/pcx.h" #include "queen/display.h" #include "queen/input.h" @@ -806,28 +810,22 @@ void Display::fill(uint8 *dstBuf, uint16 dstPitch, uint16 x, uint16 y, uint16 w, } void Display::decodePCX(const uint8 *src, uint32 srcSize, uint8 *dst, uint16 dstPitch, uint16 *w, uint16 *h, uint8 *pal, uint16 palStart, uint16 palEnd) { - *w = READ_LE_UINT16(src + 12); - *h = READ_LE_UINT16(src + 14); + Common::MemoryReadStream str(src, srcSize); + + ::Graphics::PCXDecoder pcx; + if (!pcx.loadStream(str)) + error("Error while reading PCX image"); + + const ::Graphics::Surface *pcxSurface = pcx.getSurface(); + if (pcxSurface->format.bytesPerPixel != 1) + error("Invalid bytes per pixel in PCX surface (%d)", pcxSurface->format.bytesPerPixel); + *w = pcxSurface->w; + *h = pcxSurface->h; assert(palStart <= palEnd && palEnd <= 256); - const uint8 *palData = src + srcSize - 768; - memcpy(pal, palData + palStart * 3, (palEnd - palStart) * 3); - - src += 128; - for (int y = 0; y < *h; ++y) { - uint8 *p = dst; - while (p < dst + *w) { - uint8 col = *src++; - if ((col & 0xC0) == 0xC0) { - uint8 len = col & 0x3F; - memset(p, *src++, len); - p += len; - } else { - *p++ = col; - } - } - dst += dstPitch; - } + memcpy(pal, pcx.getPalette() + palStart * 3, (palEnd - palStart) * 3); + for (uint16 y = 0; y < pcxSurface->h; y++) + memcpy(dst + y * dstPitch, pcxSurface->getBasePtr(0, y), pcxSurface->w); } void Display::decodeLBM(const uint8 *src, uint32 srcSize, uint8 *dst, uint16 dstPitch, uint16 *w, uint16 *h, uint8 *pal, uint16 palStart, uint16 palEnd, uint8 colorBase) { -- cgit v1.2.3 From 89abab97e3124fa25eb4c7d3e8b38501747a8d17 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 26 Sep 2012 04:17:31 +0200 Subject: JANITORIAL: Remove trailing whitespaces. Powered by: git ls-files "*.cpp" "*.h" "*.m" "*.mm" | xargs sed -i -e 's/[ \t]*$//' --- engines/queen/queen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/queen') diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp index f3b183c84f..c403536e22 100644 --- a/engines/queen/queen.cpp +++ b/engines/queen/queen.cpp @@ -113,12 +113,12 @@ int QueenMetaEngine::getMaximumSaveSlot() const { return 99; } const ExtraGuiOptions QueenMetaEngine::getExtraGuiOptions(const Common::String &target) const { Common::String guiOptions; ExtraGuiOptions options; - + if (target.empty()) { options.push_back(queenExtraGuiOption); return options; } - + if (ConfMan.hasKey("guioptions", target)) { guiOptions = ConfMan.get("guioptions", target); guiOptions = parseGameGUIOptions(guiOptions); -- cgit v1.2.3