aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Hesse2011-01-30 00:03:12 +0000
committerSven Hesse2011-01-30 00:03:12 +0000
commit4588d4cc97aafad974651a50cb8d58d7123dde54 (patch)
tree219462e342db7cef6f8b45423910b661105e7783
parentc498d70dd206432fbceffaa4637b520b936cf3f5 (diff)
downloadscummvm-rg350-4588d4cc97aafad974651a50cb8d58d7123dde54.tar.gz
scummvm-rg350-4588d4cc97aafad974651a50cb8d58d7123dde54.tar.bz2
scummvm-rg350-4588d4cc97aafad974651a50cb8d58d7123dde54.zip
GOB: Add Inter_Playtoons::readSprite()
svn-id: r55646
-rw-r--r--engines/gob/inter.h3
-rw-r--r--engines/gob/inter_playtoons.cpp49
2 files changed, 51 insertions, 1 deletions
diff --git a/engines/gob/inter.h b/engines/gob/inter.h
index 2dd1a22c1e..93fcd1e5ca 100644
--- a/engines/gob/inter.h
+++ b/engines/gob/inter.h
@@ -585,6 +585,9 @@ protected:
void oPlaytoons_openItk();
Common::String getFile(const char *path);
+
+private:
+ bool readSprite(const Common::String &file, int32 dataVar, int32 size, int32 offset);
};
class Inter_v7 : public Inter_Playtoons {
diff --git a/engines/gob/inter_playtoons.cpp b/engines/gob/inter_playtoons.cpp
index 577afe7c1c..71ce0ec5a2 100644
--- a/engines/gob/inter_playtoons.cpp
+++ b/engines/gob/inter_playtoons.cpp
@@ -265,7 +265,8 @@ void Inter_Playtoons::oPlaytoons_readData(OpFuncParams &params) {
return;
if (size < 0) {
- warning("Attempted to read a raw sprite from file \"%s\"", file.c_str());
+ if (readSprite(file, dataVar, size, offset))
+ WRITE_VAR(1, 0);
return;
} else if (size == 0) {
dataVar = 0;
@@ -404,4 +405,50 @@ Common::String Inter_Playtoons::getFile(const char *path) {
return path;
}
+bool Inter_Playtoons::readSprite(const Common::String &file, int32 dataVar,
+ int32 size, int32 offset) {
+
+ bool palette = false;
+ if (size < -1000) {
+ palette = true;
+ size += 1000;
+ }
+
+ int index = -size - 1;
+ if ((index < 0) || (index >= Draw::kSpritesCount) || !_vm->_draw->_spritesArray[index]) {
+ warning("No such sprite");
+ return false;
+ }
+
+ SurfacePtr sprite = _vm->_draw->_spritesArray[index];
+ if (sprite->getBPP() != 1) {
+ warning("bpp != 1");
+ return false;
+ }
+
+ Common::SeekableReadStream *stream = _vm->_dataIO->getFile(file);
+ if (!stream) {
+ warning("No such file \"%s\"", file.c_str());
+ return false;
+ }
+
+ int32 spriteSize = sprite->getWidth() * sprite->getHeight();
+ int32 dataSize = stream->size();
+
+ if (palette)
+ dataSize -= 768;
+
+ int32 readSize = MIN(spriteSize, dataSize);
+ if (readSize <= 0)
+ return true;
+
+ stream->read(sprite->getData(), readSize);
+
+ if (palette)
+ stream->read((byte *)_vm->_global->_pPaletteDesc->vgaPal, 768);
+
+ delete stream;
+ return true;
+}
+
} // End of namespace Gob