diff options
Diffstat (limited to 'engines/director/frame.cpp')
-rw-r--r-- | engines/director/frame.cpp | 118 |
1 files changed, 112 insertions, 6 deletions
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp index 0ce7f2be9b..6464943d99 100644 --- a/engines/director/frame.cpp +++ b/engines/director/frame.cpp @@ -27,9 +27,10 @@ #include "image/bmp.h" #include "director/director.h" +#include "director/cast.h" #include "director/frame.h" #include "director/images.h" -#include "director/resource.h" +#include "director/archive.h" #include "director/score.h" #include "director/sprite.h" @@ -54,7 +55,7 @@ Frame::Frame(DirectorEngine *vm) { _palette = NULL; - _sprites.resize(CHANNEL_COUNT); + _sprites.resize(CHANNEL_COUNT + 1); for (uint16 i = 0; i < _sprites.size(); i++) { Sprite *sp = new Sprite(); @@ -80,9 +81,9 @@ Frame::Frame(const Frame &frame) { debugC(1, kDebugLoading, "Frame. action: %d transType: %d transDuration: %d", _actionId, _transType, _transDuration); - _sprites.resize(CHANNEL_COUNT); + _sprites.resize(CHANNEL_COUNT + 1); - for (uint16 i = 0; i < CHANNEL_COUNT; i++) { + for (uint16 i = 0; i < CHANNEL_COUNT + 1; i++) { _sprites[i] = new Sprite(*frame._sprites[i]); } } @@ -112,6 +113,105 @@ void Frame::readChannel(Common::SeekableSubReadStreamEndian &stream, uint16 offs } } +void Frame::readChannels(Common::ReadStreamEndian *stream) { + _actionId = stream->readByte(); + _soundType1 = stream->readByte(); // type: 0x17 for sounds (sound is cast id), 0x16 for MIDI (sound is cmd id) + uint8 transFlags = stream->readByte(); // 0x80 is whole stage (vs changed area), rest is duration in 1/4ths of a second + + if (transFlags & 0x80) + _transArea = 1; + else + _transArea = 0; + _transDuration = transFlags & 0x7f; + + _transChunkSize = stream->readByte(); + _tempo = stream->readByte(); + _transType = static_cast<TransitionType>(stream->readByte()); + _sound1 = stream->readUint16(); + if (_vm->getPlatform() == Common::kPlatformMacintosh) { + _sound2 = stream->readUint16(); + _soundType2 = stream->readByte(); + } else { + byte unk[3]; + stream->read(unk, 3); + warning("unk1: %x unk2: %x unk3: %x", unk[0], unk[1], unk[2]); + } + _skipFrameFlag = stream->readByte(); + _blend = stream->readByte(); + + if (_vm->getPlatform() != Common::kPlatformMacintosh) { + _sound2 = stream->readUint16(); + _soundType2 = stream->readByte(); + } + + uint16 palette = stream->readUint16(); + + if (palette) { + warning("STUB: Palette info"); + } + + debugC(kDebugLoading, 8, "%d %d %d %d %d %d %d %d %d %d %d", _actionId, _soundType1, _transDuration, _transChunkSize, _tempo, _transType, _sound1, _skipFrameFlag, _blend, _sound2, _soundType2); + + _palette = new PaletteInfo(); + _palette->firstColor = stream->readByte(); // for cycles. note: these start at 0x80 (for pal entry 0)! + _palette->lastColor = stream->readByte(); + _palette->flags = stream->readByte(); + _palette->speed = stream->readByte(); + _palette->frameCount = stream->readUint16(); + + _palette->cycleCount = stream->readUint16(); + + byte unk[11]; + stream->read(unk, 6); + + if (_vm->getPlatform() == Common::kPlatformMacintosh) { + if (_vm->getVersion() < 4) { + stream->read(unk, 3); + } else { + stream->read(unk, 11); + //Common::hexdump(unk, 11); + + if (_vm->getVersion() >= 5) { + stream->read(unk, 7); + //Common::hexdump(unk, 7); + } + } + } + + for (int i = 0; i < CHANNEL_COUNT; i++) { + Sprite &sprite = *_sprites[i + 1]; + + sprite._x1 = stream->readByte(); + sprite._enabled = (stream->readByte() != 0); + sprite._x2 = stream->readUint16(); + + sprite._flags = stream->readUint16(); + sprite._ink = static_cast<InkType>(sprite._flags & 0x3f); + + if (sprite._flags & 0x40) + sprite._trails = 1; + else + sprite._trails = 0; + + sprite._castId = stream->readUint16(); + sprite._startPoint.y = stream->readUint16(); + sprite._startPoint.x = stream->readUint16(); + sprite._height = stream->readUint16(); + sprite._width = stream->readUint16(); + + debugC(kDebugLoading, 8, "%03d(%d)[%x,%x,%04x,%d/%d/%d/%d]", sprite._castId, sprite._enabled, sprite._x1, sprite._x2, sprite._flags, sprite._startPoint.x, sprite._startPoint.y, sprite._width, sprite._height); + + if (_vm->getPlatform() == Common::kPlatformMacintosh && _vm->getVersion() >= 4) { + sprite._scriptId = stream->readUint16(); + sprite._flags2 = stream->readByte(); // 0x40 editable, 0x80 moveable + sprite._unk2 = stream->readByte(); + + if (_vm->getVersion() >= 5) + sprite._unk3 = stream->readUint32(); + } + } +} + void Frame::readMainChannels(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size) { uint16 finishPosition = offset + size; @@ -179,6 +279,8 @@ void Frame::readMainChannels(Common::SeekableSubReadStreamEndian &stream, uint16 break; } } + + warning("%d %d %d %d %d %d %d %d %d %d %d", _actionId, _soundType1, _transDuration, _transChunkSize, _tempo, _transType, _sound1, _skipFrameFlag, _blend, _sound2, _soundType2); } void Frame::readPaletteInfo(Common::SeekableSubReadStreamEndian &stream) { @@ -198,11 +300,13 @@ void Frame::readSprite(Common::SeekableSubReadStreamEndian &stream, uint16 offse uint16 finishPosition = fieldPosition + size; Sprite &sprite = *_sprites[spritePosition]; + int x1 = 0; + int x2 = 0; while (fieldPosition < finishPosition) { switch (fieldPosition) { case kSpritePositionUnk1: - /*byte x1 = */ stream.readByte(); + x1 = stream.readByte(); fieldPosition++; break; case kSpritePositionEnabled: @@ -210,7 +314,7 @@ void Frame::readSprite(Common::SeekableSubReadStreamEndian &stream, uint16 offse fieldPosition++; break; case kSpritePositionUnk2: - /*byte x2 = */ stream.readUint16(); + x2 = stream.readUint16(); fieldPosition += 2; break; case kSpritePositionFlags: @@ -251,6 +355,8 @@ void Frame::readSprite(Common::SeekableSubReadStreamEndian &stream, uint16 offse break; } } + warning("%03d(%d)[%x,%x,%04x,%d/%d/%d/%d]", sprite._castId, sprite._enabled, x1, x2, sprite._flags, sprite._startPoint.x, sprite._startPoint.y, sprite._width, sprite._height); + } void Frame::prepareFrame(Score *score) { |