aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMartin Kiewitz2015-06-08 12:47:38 +0200
committerMartin Kiewitz2015-06-08 12:47:38 +0200
commitae64cca8f01f4e56873ac6afa58610366ea8238a (patch)
tree908a98b0707e0b9519010cbe461d61a3f964b75f /engines
parent26ed7954c3789eebbaa29425ad22988eab3660fb (diff)
downloadscummvm-rg350-ae64cca8f01f4e56873ac6afa58610366ea8238a.tar.gz
scummvm-rg350-ae64cca8f01f4e56873ac6afa58610366ea8238a.tar.bz2
scummvm-rg350-ae64cca8f01f4e56873ac6afa58610366ea8238a.zip
SHERLOCK: bit of work on 3DO graphic resources
Diffstat (limited to 'engines')
-rw-r--r--engines/sherlock/resources.cpp54
-rw-r--r--engines/sherlock/resources.h19
2 files changed, 59 insertions, 14 deletions
diff --git a/engines/sherlock/resources.cpp b/engines/sherlock/resources.cpp
index c5814965ad..ab5c6ab56f 100644
--- a/engines/sherlock/resources.cpp
+++ b/engines/sherlock/resources.cpp
@@ -600,6 +600,39 @@ ImageFile3DO::~ImageFile3DO() {
}
void ImageFile3DO::load(Common::SeekableReadStream &stream, bool animImages) {
+ uint32 headerId = stream.readUint32BE();
+
+ // Sekk back to the start
+ stream.seek(0);
+
+ // Identify type of file
+ switch (headerId) {
+ case MKTAG('C', 'C', 'B', ' '):
+ // .cel file (title1a.cel etc.)
+ load3DOCelFile(stream);
+ break;
+
+ case MKTAG('A', 'N', 'I', 'M'):
+ // 3DO animation file (walk.anim)
+ break;
+
+ default:
+ // Sherlock animation file (.3da files)
+ loadAnimationFile(stream, animImages);
+ break;
+ }
+}
+
+// 3DO uses RGB555, we use RGB565 internally so that more platforms are able to run us
+inline uint16 ImageFile3DO::convertPixel(uint16 pixel3DO) {
+ byte red = (pixel3DO >> 10) & 0x1F;
+ byte green = (pixel3DO >> 5) & 0x1F;
+ byte blue = pixel3DO & 0x1F;;
+
+ return ((red << 11) | (green << 6) | (blue));
+}
+
+void ImageFile3DO::loadAnimationFile(Common::SeekableReadStream &stream, bool animImages) {
int streamSize = stream.size();
uint32 compressedSize = 0;
@@ -635,23 +668,18 @@ void ImageFile3DO::load(Common::SeekableReadStream &stream, bool animImages) {
// Load data for frame and decompress it
byte *data = new byte[compressedSize];
stream.read(data, compressedSize);
- decompressFrame(&stream, frame, data);
+ decompressAnimationFrame(&stream, frame, data);
delete[] data;
push_back(frame);
}
}
-// 3DO uses RGB555, we use RGB565 internally so that more platforms are able to run us
-inline uint16 ImageFile3DO::convertPixel(uint16 pixel3DO) {
- byte red = (pixel3DO >> 10) & 0x1F;
- byte green = (pixel3DO >> 5) & 0x1F;
- byte blue = pixel3DO & 0x1F;;
-
- return ((red << 11) | (green << 6) | (blue));
-}
-
-void ImageFile3DO::decompressFrame(Common::SeekableReadStream *stream, ImageFrame &frame, const byte *src) {
+// Decompresses an animation frame of a .3DA file
+// note: the .3DA files seem to use an "in memory" format, which uses the same compression technique
+// as regular 3DO cel files, but every scanline is started with a length UINT16 and each scanline
+// also starts on UINT32 boundaries
+void ImageFile3DO::decompressAnimationFrame(Common::SeekableReadStream *stream, ImageFrame &frame, const byte *src) {
frame._frame.create(frame._width, frame._height, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
uint16 *dest = (uint16 *)frame._frame.getPixels();
Common::fill(dest, dest + frame._width * frame._height, 0);
@@ -722,4 +750,8 @@ void ImageFile3DO::decompressFrame(Common::SeekableReadStream *stream, ImageFram
}
}
+void ImageFile3DO::load3DOCelFile(Common::SeekableReadStream &stream) {
+ warning("3DO-cel file loader currently missing");
+}
+
} // End of namespace Sherlock
diff --git a/engines/sherlock/resources.h b/engines/sherlock/resources.h
index 0d820be304..44da810d29 100644
--- a/engines/sherlock/resources.h
+++ b/engines/sherlock/resources.h
@@ -232,12 +232,25 @@ private:
void load(Common::SeekableReadStream &stream, bool animImages);
/**
- * Decompress a single frame for the sprite
+ * convert pixel RGB values from RGB555 to RGB565
*/
- void decompressFrame(Common::SeekableReadStream *stream, ImageFrame &frame, const byte *src);
-
inline uint16 convertPixel(uint16 pixel3DO);
+ /**
+ * Load 3DO cel file
+ */
+ void load3DOCelFile(Common::SeekableReadStream &stream);
+
+ /**
+ * Load animation graphics file
+ */
+ void loadAnimationFile(Common::SeekableReadStream &stream, bool animImages);
+
+ /**
+ * Decompress a single frame for the sprite
+ */
+ void decompressAnimationFrame(Common::SeekableReadStream *stream, ImageFrame &frame, const byte *src);
+
public:
ImageFile3DO(const Common::String &name, bool animImages = false);
ImageFile3DO(Common::SeekableReadStream &stream);