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
Common::String graphicsName = "prologue/" + filename + ".3da";
ImageFile3DO images(graphicsName, true);
ImageFile3DO images(graphicsName);
events.wait(minDelay);

View File

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

View File

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

View File

@ -198,7 +198,12 @@ bool People::loadWalk() {
if (_data[PLAYER]._walkLoaded) {
return false;
} 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]._walkLoaded = true;