SHERLOCK: 3DO: load walk.anim for player

This commit is contained in:
Martin Kiewitz 2015-06-11 21:30:32 +02:00
parent 515d5422a7
commit 7ff3336a65
4 changed files with 30 additions and 28 deletions

View file

@ -169,7 +169,7 @@ bool Animation::play3DO(const Common::String &filename, bool intro, int minDelay
// Load initial image // Load initial image
Common::String graphicsName = "prologue/" + filename + ".3da"; Common::String graphicsName = "prologue/" + filename + ".3da";
ImageFile3DO images(graphicsName, true); ImageFile3DO images(graphicsName);
events.wait(minDelay); events.wait(minDelay);

View file

@ -34,6 +34,9 @@ void ImageFile::setVm(SherlockEngine *vm) {
_vm = vm; _vm = vm;
} }
ImageFile::ImageFile() {
}
ImageFile::ImageFile(const Common::String &name, bool skipPal, bool animImages) { ImageFile::ImageFile(const Common::String &name, bool skipPal, bool animImages) {
Common::SeekableReadStream *stream = _vm->_res->load(name); Common::SeekableReadStream *stream = _vm->_res->load(name);
@ -240,28 +243,29 @@ void ImageFile3DO::setVm(SherlockEngine *vm) {
_vm = vm; _vm = vm;
} }
ImageFile3DO::ImageFile3DO(const Common::String &name, bool animImages) { ImageFile3DO::ImageFile3DO(const Common::String &name) {
Common::File *dataStream = new Common::File(); Common::File *dataStream = new Common::File();
if (!dataStream->open(name)) { if (!dataStream->open(name)) {
error("unable to open %s\n", name.c_str()); error("unable to open %s\n", name.c_str());
} }
load(*dataStream, animImages); load(*dataStream, false); // this is never called for room data
delete dataStream; delete dataStream;
} }
ImageFile3DO::ImageFile3DO(Common::SeekableReadStream &stream) { ImageFile3DO::ImageFile3DO(Common::SeekableReadStream &stream, bool roomData) {
load(stream, false); load(stream, false);
} }
ImageFile3DO::~ImageFile3DO() { ImageFile3DO::~ImageFile3DO() {
for (uint idx = 0; idx < size(); ++idx) // already done in ImageFile destructor
(*this)[idx]._frame.free(); //for (uint idx = 0; idx < size(); ++idx)
// (*this)[idx]._frame.free();
} }
void ImageFile3DO::load(Common::SeekableReadStream &stream, bool animImages) { void ImageFile3DO::load(Common::SeekableReadStream &stream, bool roomData) {
uint32 headerId = stream.readUint32BE(); uint32 headerId = stream.readUint32BE();
assert(!stream.eos()); assert(!stream.eos());
@ -280,7 +284,7 @@ void ImageFile3DO::load(Common::SeekableReadStream &stream, bool animImages) {
default: default:
// Sherlock animation file (.3da files) // Sherlock animation file (.3da files)
loadAnimationFile(stream, animImages); loadAnimationFile(stream);
break; break;
} }
} }
@ -294,7 +298,7 @@ inline uint16 ImageFile3DO::convertPixel(uint16 pixel3DO) {
return ((red << 11) | (green << 6) | (blue)); return ((red << 11) | (green << 6) | (blue));
} }
void ImageFile3DO::loadAnimationFile(Common::SeekableReadStream &stream, bool animImages) { void ImageFile3DO::loadAnimationFile(Common::SeekableReadStream &stream) {
int streamSize = stream.size(); int streamSize = stream.size();
uint32 compressedSize = 0; uint32 compressedSize = 0;
@ -307,22 +311,14 @@ void ImageFile3DO::loadAnimationFile(Common::SeekableReadStream &stream, bool an
frame._height = stream.readByte() + 1; // 1 byte BE height frame._height = stream.readByte() + 1; // 1 byte BE height
frame._paletteBase = 0; frame._paletteBase = 0;
if (animImages) { frame._rleEncoded = true; // always compressed
// Animation cutscene image files use a 16-bit x offset if (frame._width & 0x8000) {
frame._offset.x = stream.readUint16BE(); frame._width &= 0x7FFF;
frame._rleEncoded = true; // always compressed compressedSize += 0x10000;
if (frame._width & 0x8000) {
frame._width &= 0x7FFF;
compressedSize += 0x10000;
}
frame._offset.y = stream.readByte();
} else {
// Standard image files have a separate byte for the RLE flag, and an 8-bit X offset
//frame._rleEncoded = stream.readByte() == 1;
//frame._offset.x = stream.readByte();
//frame._offset.y = stream.readByte();
} }
frame._offset.x = stream.readUint16BE();
frame._offset.y = stream.readByte();
frame._size = 0; frame._size = 0;
//warning("getting frame %d from offset %d", this->size(), stream.pos()); //warning("getting frame %d from offset %d", this->size(), stream.pos());

View file

@ -87,6 +87,7 @@ private:
public: public:
byte _palette[256 * 3]; byte _palette[256 * 3];
public: public:
ImageFile();
ImageFile(const Common::String &name, bool skipPal = false, bool animImages = false); ImageFile(const Common::String &name, bool skipPal = false, bool animImages = false);
ImageFile(Common::SeekableReadStream &stream, bool skipPal = false); ImageFile(Common::SeekableReadStream &stream, bool skipPal = false);
~ImageFile(); ~ImageFile();
@ -97,7 +98,7 @@ struct ImageFile3DOPixelLookupTable {
uint16 pixelColor[256]; uint16 pixelColor[256];
}; };
class ImageFile3DO : public Common::Array<ImageFrame> { class ImageFile3DO : public ImageFile { // Common::Array<ImageFrame> {
private: private:
static SherlockEngine *_vm; static SherlockEngine *_vm;
@ -126,11 +127,11 @@ private:
/** /**
* Load animation graphics file * Load animation graphics file
*/ */
void loadAnimationFile(Common::SeekableReadStream &stream, bool animImages); void loadAnimationFile(Common::SeekableReadStream &stream);
public: public:
ImageFile3DO(const Common::String &name, bool animImages = false); ImageFile3DO(const Common::String &name);
ImageFile3DO(Common::SeekableReadStream &stream); ImageFile3DO(Common::SeekableReadStream &stream, bool roomData = false);
~ImageFile3DO(); ~ImageFile3DO();
static void setVm(SherlockEngine *vm); static void setVm(SherlockEngine *vm);
}; };

View file

@ -198,7 +198,12 @@ bool People::loadWalk() {
if (_data[PLAYER]._walkLoaded) { if (_data[PLAYER]._walkLoaded) {
return false; return false;
} else { } else {
_data[PLAYER]._images = new ImageFile("walk.vgs"); if (_vm->getPlatform() != Common::kPlatform3DO) {
_data[PLAYER]._images = new ImageFile("walk.vgs");
} else {
// Load walk.anim on 3DO, which is a cel animation file
_data[PLAYER]._images = new ImageFile3DO("walk.anim");
}
_data[PLAYER].setImageFrame(); _data[PLAYER].setImageFrame();
_data[PLAYER]._walkLoaded = true; _data[PLAYER]._walkLoaded = true;