aboutsummaryrefslogtreecommitdiff
path: root/engines/tucker
diff options
context:
space:
mode:
authorFilippos Karapetis2012-09-13 01:50:45 +0300
committerFilippos Karapetis2012-09-13 01:50:45 +0300
commit617545cb5f73c6ca8f14e3e5b1093e23fb68468b (patch)
tree1c92e218cd7287869f151b6fcff1e4972bb65ec1 /engines/tucker
parentd182fe0221ed8c734c5aab3c18b006c0cc562af4 (diff)
downloadscummvm-rg350-617545cb5f73c6ca8f14e3e5b1093e23fb68468b.tar.gz
scummvm-rg350-617545cb5f73c6ca8f14e3e5b1093e23fb68468b.tar.bz2
scummvm-rg350-617545cb5f73c6ca8f14e3e5b1093e23fb68468b.zip
TUCKER: Switch to the common PCX decoder
Diffstat (limited to 'engines/tucker')
-rw-r--r--engines/tucker/resource.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/engines/tucker/resource.cpp b/engines/tucker/resource.cpp
index bee09f7391..1b04f3fae9 100644
--- a/engines/tucker/resource.cpp
+++ b/engines/tucker/resource.cpp
@@ -29,6 +29,9 @@
#include "audio/decoders/vorbis.h"
#include "audio/decoders/wave.h"
+#include "graphics/surface.h"
+#include "graphics/decoders/pcx.h"
+
#include "tucker/tucker.h"
#include "tucker/graphics.h"
@@ -298,23 +301,21 @@ void TuckerEngine::loadImage(const char *fname, uint8 *dst, int type) {
return;
}
}
- f.seek(128, SEEK_SET);
- int size = 0;
- while (size < 64000) {
- int code = f.readByte();
- if (code >= 0xC0) {
- const int sz = code - 0xC0;
- code = f.readByte();
- memset(dst + size, code, sz);
- size += sz;
- } else {
- dst[size++] = code;
- }
- }
+
+ ::Graphics::PCXDecoder pcx;
+ if (!pcx.loadStream(f))
+ 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);
+ if (pcxSurface->w != 320 || pcxSurface->h != 200)
+ error("Invalid PCX surface size (%d x %d)", pcxSurface->w, pcxSurface->h);
+ for (uint16 y = 0; y < pcxSurface->h; y++)
+ memcpy(dst + y * 320, pcxSurface->getBasePtr(0, y), pcxSurface->w);
+
if (type != 0) {
- if (f.readByte() != 12)
- return;
- f.read(_currentPalette, 768);
+ memcpy(_currentPalette, pcx.getPalette(), 3 * 256);
setBlackPalette();
}
}