diff options
author | Paul Gilbert | 2010-06-20 05:25:34 +0000 |
---|---|---|
committer | Paul Gilbert | 2010-06-20 05:25:34 +0000 |
commit | d6cd656f15aed3ac3b8428442f9397944e6b2c85 (patch) | |
tree | 46285c9764589ea5f7961464d50eb5e41988aa63 | |
parent | f2983093e83425d7a5b14cbb43b1ba2d995e29f4 (diff) | |
download | scummvm-rg350-d6cd656f15aed3ac3b8428442f9397944e6b2c85.tar.gz scummvm-rg350-d6cd656f15aed3ac3b8428442f9397944e6b2c85.tar.bz2 scummvm-rg350-d6cd656f15aed3ac3b8428442f9397944e6b2c85.zip |
Added support for the alternate encoding for depth surfaces
svn-id: r50069
-rw-r--r-- | engines/m4/mads_scene.cpp | 30 | ||||
-rw-r--r-- | engines/m4/mads_scene.h | 2 |
2 files changed, 22 insertions, 10 deletions
diff --git a/engines/m4/mads_scene.cpp b/engines/m4/mads_scene.cpp index 43b39af0db..8a33424602 100644 --- a/engines/m4/mads_scene.cpp +++ b/engines/m4/mads_scene.cpp @@ -650,7 +650,7 @@ void MadsSceneResources::load(int sceneNumber, const char *resName, int v0, M4Su int resSceneId = stream->readUint16LE(); assert(resSceneId == sceneNumber); artFileNum = stream->readUint16LE(); - drawStyle = stream->readUint16LE(); + depthStyle = stream->readUint16LE(); width = stream->readUint16LE(); height = stream->readUint16LE(); @@ -685,16 +685,15 @@ void MadsSceneResources::load(int sceneNumber, const char *resName, int v0, M4Su if (!surface) { surface = new M4Surface(width, height); ssFlag = true; - } + } else if ((width != surface->width()) || (height != surface->height())) + surface->setSize(width, height); + int walkSize = gfxSize; - if (drawStyle == 2) { - width >>= 2; - walkSize = width * height; - } if (!depthSurface) { depthSurface = new M4Surface(width, height); dsFlag = true; - } + } else if ((width != depthSurface->width()) || (height != depthSurface->height())) + depthSurface->setSize(width, height); // For Rex Nebular, read in the scene's compressed walk surface information @@ -708,9 +707,22 @@ void MadsSceneResources::load(int sceneNumber, const char *resName, int v0, M4Su byte *destP = depthSurface->getBasePtr(0, 0); const byte *srcP = walkData; byte runLength; + + // Run length encoded depth data while ((runLength = *srcP++) != 0) { - Common::set_to(destP, destP + runLength, *srcP++); - destP += runLength; + if (depthStyle == 2) { + // 2-bit depth pixels + byte byteVal = *srcP++; + for (int byteCtr = 0; byteCtr < runLength; ++byteCtr) { + byte v = byteVal; + for (int bitCtr = 0; bitCtr < 4; ++bitCtr, v >>= 2) + *destP++ = v & 3; + } + } else { + // 8-bit depth pixels + Common::set_to(destP, destP + runLength, *srcP++); + destP += runLength; + } } free(walkData); diff --git a/engines/m4/mads_scene.h b/engines/m4/mads_scene.h index c4c6dedc0e..ef5cd312d7 100644 --- a/engines/m4/mads_scene.h +++ b/engines/m4/mads_scene.h @@ -39,7 +39,7 @@ class MadsSceneResources: public SceneResources { public: int sceneId; int artFileNum; - int drawStyle; + int depthStyle; int width; int height; Common::Array<MadsObject> objects; |