diff options
author | Eugene Sandulenko | 2016-10-28 22:48:28 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-10-29 08:07:19 -0700 |
commit | 703178e033934b7aa09ab5e995480d967ef7113a (patch) | |
tree | 799c1eb719c621ea22ca9544596e6d6f1bc7b485 | |
parent | 9f35d6fdc6cc4462f1cb3a9916aba298d0a3e1be (diff) | |
download | scummvm-rg350-703178e033934b7aa09ab5e995480d967ef7113a.tar.gz scummvm-rg350-703178e033934b7aa09ab5e995480d967ef7113a.tar.bz2 scummvm-rg350-703178e033934b7aa09ab5e995480d967ef7113a.zip |
DIRECTOR: Rework Channel data parsing
-rw-r--r-- | engines/director/archive.cpp | 2 | ||||
-rw-r--r-- | engines/director/frame.cpp | 104 | ||||
-rw-r--r-- | engines/director/frame.h | 8 | ||||
-rw-r--r-- | engines/director/score.cpp | 32 | ||||
-rw-r--r-- | engines/director/sprite.h | 8 |
5 files changed, 146 insertions, 8 deletions
diff --git a/engines/director/archive.cpp b/engines/director/archive.cpp index 9122572a95..53c5243458 100644 --- a/engines/director/archive.cpp +++ b/engines/director/archive.cpp @@ -347,6 +347,8 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff subStream.readUint32(); // imap length subStream.readUint32(); // unknown uint32 mmapOffset = subStream.readUint32() - startOffset - 4; + uint32 version = subStream.readUint32(); // 0 for 4.0, 0x4c1 for 5.0, 0x4c7 for 6.0, 0x708 for 8.5, 0x742 for 10.0 + warning("RIFX: version: %x", version); subStream.seek(mmapOffset); diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp index 57208888a7..9adbf003ee 100644 --- a/engines/director/frame.cpp +++ b/engines/director/frame.cpp @@ -54,7 +54,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 +80,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 +112,104 @@ 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, 9); + //Common::hexdump(unk, 6); + + #if 0 + if (_vm->getPlatform() == Common::kPlatformMacintosh) { + stream->read(unk, 11); + //Common::hexdump(unk, 11); + + if (_vm->getVersion() >= 5) { + stream->read(unk, 7); + //Common::hexdump(unk, 7); + } + } + #endif + + 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; diff --git a/engines/director/frame.h b/engines/director/frame.h index 68eb1e33bb..694d3a770c 100644 --- a/engines/director/frame.h +++ b/engines/director/frame.h @@ -35,6 +35,10 @@ class Sprite; #define CHANNEL_COUNT 24 +enum { + kChannelDataSize = (25 * 50) +}; + enum TransitionType { kTransNone, kTransWipeRight, @@ -97,6 +101,7 @@ struct PaletteInfo { uint8 flags; uint8 speed; uint16 frameCount; + uint16 cycleCount; }; @@ -105,6 +110,7 @@ public: Frame(DirectorEngine *vm); Frame(const Frame &frame); ~Frame(); + void readChannels(Common::ReadStreamEndian *stream); void readChannel(Common::SeekableSubReadStreamEndian &stream, uint16 offset, uint16 size); void prepareFrame(Score *score); uint16 getSpriteIDFromPos(Common::Point pos); @@ -123,7 +129,9 @@ private: void drawMatteSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect); void drawGhostSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect); void drawReverseSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect); + public: + byte _channelData[kChannelDataSize]; uint8 _actionId; uint8 _transDuration; uint8 _transArea; //1 - Whole Stage, 0 - Changing Area diff --git a/engines/director/score.cpp b/engines/director/score.cpp index b2b76548bf..2bb538a91d 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -23,6 +23,7 @@ #include "common/system.h" #include "common/config-manager.h" #include "common/events.h" +#include "common/memstream.h" #include "engines/util.h" #include "graphics/font.h" @@ -262,10 +263,15 @@ void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) { size -= 4; if (_vm->getVersion() > 3) { - stream.skip(16); + uint32 unk1 = stream.readUint32(); + uint32 unk2 = stream.readUint32(); + uint16 unk3 = stream.readUint16(); + uint16 unk4 = stream.readUint16(); + uint16 unk5 = stream.readUint16(); + uint16 unk6 = stream.readUint16(); size -= 16; - warning("STUB: Score::loadFrames. Skipping initial bytes"); + warning("STUB: Score::loadFrames. unk1: %x unk2: %x unk3: %x unk4: %x unk5: %x unk6: %x", unk1, unk2, unk3, unk4, unk5, unk6); //Unknown, some bytes - constant (refer to contuinity). } @@ -275,12 +281,20 @@ void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) { Frame *initial = new Frame(_vm); _frames.push_back(initial); + // This is a representation of the channelData. It gets overridden + // partically by channels, hence we keep it and read the score from left to right + // + // TODO Merge it with shared cast + byte channelData[kChannelDataSize]; + memset(channelData, 0, kChannelDataSize); + while (size != 0) { uint16 frameSize = stream.readUint16(); - warning("++++ score frame %d (frameSize %d) size %d", _frames.size(), frameSize, size); + debugC(kDebugLoading, 8, "++++ score frame %d (frameSize %d) size %d", _frames.size(), frameSize, size); size -= frameSize; frameSize -= 2; - Frame *frame = new Frame(*_frames.back()); + + Frame *frame = new Frame(_vm); while (frameSize != 0) { if (_vm->getVersion() < 4) { @@ -292,9 +306,17 @@ void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) { channelOffset = stream.readUint16(); frameSize -= channelSize + 4; } - frame->readChannel(stream, channelOffset, channelSize); + + assert(channelOffset + channelSize < kChannelDataSize); + + stream.read(&channelData[channelOffset], channelSize); } + Common::MemoryReadStreamEndian *str = new Common::MemoryReadStreamEndian(channelData, ARRAYSIZE(channelData), stream.isBE()); + frame->readChannels(str); + + delete str; + _frames.push_back(frame); } diff --git a/engines/director/sprite.h b/engines/director/sprite.h index e879f83599..7cf7a8a7ac 100644 --- a/engines/director/sprite.h +++ b/engines/director/sprite.h @@ -97,6 +97,14 @@ public: Sprite(); Sprite(const Sprite &sprite); ~Sprite(); + + byte _x1; + uint16 _x2; + uint16 _scriptId; + byte _flags2; // x40 editable, 0x80 moveable + byte _unk2; + uint32 _unk3; + bool _enabled; byte _castId; InkType _ink; |