diff options
author | Iskrich | 2016-05-26 01:16:29 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 11c9bbd9cb78ea4229e9cd64ad1d31e46d32ec41 (patch) | |
tree | 8c43f44c1cda1d1d521a0678d11def7737518be0 /engines | |
parent | 2de66ee08396ca70bdb75e47867e7bd386c5bb9b (diff) | |
download | scummvm-rg350-11c9bbd9cb78ea4229e9cd64ad1d31e46d32ec41.tar.gz scummvm-rg350-11c9bbd9cb78ea4229e9cd64ad1d31e46d32ec41.tar.bz2 scummvm-rg350-11c9bbd9cb78ea4229e9cd64ad1d31e46d32ec41.zip |
DIRECTOR: Play score, display DIB sprites
Diffstat (limited to 'engines')
-rw-r--r-- | engines/director/dib.cpp | 7 | ||||
-rw-r--r-- | engines/director/director.cpp | 34 | ||||
-rw-r--r-- | engines/director/score.cpp | 207 | ||||
-rw-r--r-- | engines/director/score.h | 70 |
4 files changed, 168 insertions, 150 deletions
diff --git a/engines/director/dib.cpp b/engines/director/dib.cpp index 4310e547e7..6053d55a77 100644 --- a/engines/director/dib.cpp +++ b/engines/director/dib.cpp @@ -100,17 +100,10 @@ bool DIBDecoder::loadStream(Common::SeekableReadStream &stream) { uint16 imageRawSize = stream.size() - 40; Common::SeekableSubReadStream subStream(&stream, 40, stream.size()); - warning("w: %d h: %d bpp: %d pal: %d size: %d (size rep: %d) comp: %x", width, height, bitsPerPixel, _paletteColorCount, imageRawSize, imageSize, compression); - _codec = Image::createBitmapCodec(compression, width, height, bitsPerPixel); if (!_codec) return false; _surface = _codec->decodeFrame(subStream); - - //FIXME - g_system->getPaletteManager()->setPalette(_palette, 0, _paletteColorCount - 1); - g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, width, height); - return true; } diff --git a/engines/director/director.cpp b/engines/director/director.cpp index a4366b5eee..5c2c7adc6d 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -66,37 +66,13 @@ DirectorEngine::~DirectorEngine() { Common::Error DirectorEngine::run() { debug("Starting v%d Director game", getVersion()); - initGraphics(640, 480, true); - //FIXME - RIFFArchive riff; - riff.openFile("bookshelf_example.mmm"); - Director::DIBDecoder img; - - Common::SeekableReadStream *pal = riff.getResource(MKTAG('C', 'L', 'U', 'T'), 1025); - img.loadPalette(*pal); - - Common::SeekableReadStream *dib = riff.getResource(MKTAG('D', 'I', 'B', ' '), 1026); - img.loadStream(*dib); - - Common::SeekableReadStream *scr = riff.getResource(MKTAG('V','W','S','C'),1024); - Director::Score score = Director::Score(*scr); - - bool stop = false; - - while (!stop) { - Common::Event event; - - while (_eventMan->pollEvent(event)) { - if (event.type == Common::EVENT_QUIT) - stop = true; - } - - g_system->updateScreen(); - g_system->delayMillis(50); - } + _mainArchive = new RIFFArchive(); + _mainArchive->openFile("bookshelf_example.mmm"); - return Common::kNoError; + Common::SeekableReadStream *scr = _mainArchive->getResource(MKTAG('V','W','S','C'), 1024); + Score score(*scr); + score.play(); if (getPlatform() == Common::kPlatformWindows) loadEXE(); diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 299ef34776..964ea39df7 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -19,10 +19,19 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ + #include "director/score.h" #include "common/stream.h" #include "common/debug.h" +#include "common/system.h" +#include "director/dib.h" +#include "director/resource.h" + +#include "graphics/palette.h" +#include "common/events.h" +#include "engines/util.h" + namespace Director { Score::Score(Common::SeekableReadStream &stream) { @@ -32,78 +41,88 @@ Score::Score(Common::SeekableReadStream &stream) { uint16 channelSize; uint16 channelOffset; - Frame* initial = new Frame(); - frames.push_back(initial); + Frame *initial = new Frame(); + _frames.push_back(initial); while (size != 0) { uint16 frameSize = stream.readUint16BE(); size -= frameSize; frameSize -= 2; - Frame* frame = new Frame(*frames.back()); - while(frameSize != 0) { + Frame *frame = new Frame(*_frames.back()); + while (frameSize != 0) { channelSize = stream.readByte() * 2; channelOffset = stream.readByte() * 2; frame->readChannel(stream, channelOffset, channelSize); frameSize -= channelSize + 2; } - frames.push_back(frame); - debug("*************FRAME %d****************", frames.size() - 1); - for (byte i = 0; i < CHANNEL_COUNT; i++) { - debug("Channel %d, enabled %d, castId %d, X %d, Y %d, width %d, height %d", - i, frame->sprites[i]->enabled, - frame->sprites[i]->castId, - frame->sprites[i]->startPoint.x, - frame->sprites[i]->startPoint.y, - frame->sprites[i]->width, - frame->sprites[i]->height); - } + _frames.push_back(frame); } //remove initial frame - frames.remove_at(0); + _frames.remove_at(0); +} + +void Score::play() { + initGraphics(800, 800, true); + uint32 frameId = 0; + + bool stop = false; + + while (frameId != _frames.size() && !stop) { + Common::Event event; + + while (g_system->getEventManager()->pollEvent(event)) { + if (event.type == Common::EVENT_QUIT) + stop = true; + } + _frames[frameId]->display(); + frameId++; + g_system->updateScreen(); + g_system->delayMillis(200); + } } Frame::Frame() { - transFlags = 0; - transChunkSize = 0; - tempo = 0; + _transFlags = 0; + _transChunkSize = 0; + _tempo = 0; - sound1 = 0; - sound2 = 0; - soundType1 = 0; - soundType2 = 0; + _sound1 = 0; + _sound2 = 0; + _soundType1 = 0; + _soundType2 = 0; - actionId = 0; - skipFrameFlag = 0; - blend = 0; + _actionId = 0; + _skipFrameFlag = 0; + _blend = 0; - sprites.resize(CHANNEL_COUNT); - for (uint16 i = 0; i < sprites.size(); i++) { - Sprite* sp = new Sprite(); - sprites[i] = sp; + _sprites.resize(CHANNEL_COUNT); + for (uint16 i = 0; i < _sprites.size(); i++) { + Sprite *sp = new Sprite(); + _sprites[i] = sp; } } -Frame::Frame(const Frame& frame) { - actionId = frame.actionId; - transFlags = frame.transFlags; - transType = frame.transType; - tempo = frame.tempo; - sound1 = frame.sound1; - sound2 = frame.sound2; - soundType1 = frame.soundType1; - soundType2 = frame.soundType2; - skipFrameFlag = frame.skipFrameFlag; - blend = frame.blend; +Frame::Frame(const Frame &frame) { + _actionId = frame._actionId; + _transFlags = frame._transFlags; + _transType = frame._transType; + _tempo = frame._tempo; + _sound1 = frame._sound1; + _sound2 = frame._sound2; + _soundType1 = frame._soundType1; + _soundType2 = frame._soundType2; + _skipFrameFlag = frame._skipFrameFlag; + _blend = frame._blend; - sprites.resize(CHANNEL_COUNT); + _sprites.resize(CHANNEL_COUNT); for (uint16 i = 0; i < CHANNEL_COUNT; i++) { - sprites[i] = new Sprite(*frame.sprites[i]);; + _sprites[i] = new Sprite(*frame._sprites[i]); } } Frame::~Frame() { - for (uint16 i = 0; i < sprites.size(); i++) { - delete sprites[i]; + for (uint16 i = 0; i < _sprites.size(); i++) { + delete _sprites[i]; } } @@ -126,7 +145,6 @@ void Frame::readChannel(Common::SeekableReadStream &stream, uint16 offset, uint1 } else { readMainChannels(stream, offset, size); } - } void Frame::readMainChannels(Common::SeekableReadStream &stream, uint16 offset, uint16 size) { @@ -135,47 +153,47 @@ void Frame::readMainChannels(Common::SeekableReadStream &stream, uint16 offset, while (offset < finishPosition) { switch(offset) { case kScriptIdPosition: - actionId = stream.readByte(); + _actionId = stream.readByte(); offset++; break; case kSoundType1Position: - soundType1 = stream.readByte(); + _soundType1 = stream.readByte(); offset++; break; case kTransFlagsPosition: - transFlags = stream.readByte(); + _transFlags = stream.readByte(); offset++; break; case kTransChunkSizePosition: - transChunkSize = stream.readByte(); + _transChunkSize = stream.readByte(); offset++; break; case kTempoPosition: - tempo = stream.readByte(); + _tempo = stream.readByte(); offset++; break; case kTransTypePosition: - transType = stream.readByte(); + _transType = stream.readByte(); offset++; break; case kSound1Position: - sound1 = stream.readUint16BE(); + _sound1 = stream.readUint16BE(); offset+=2; break; case kSkipFrameFlagsPosition: - skipFrameFlag = stream.readByte(); + _skipFrameFlag = stream.readByte(); offset++; break; case kBlendPosition: - blend = stream.readByte(); + _blend = stream.readByte(); offset++; break; case kSound2Position: - sound2 = stream.readUint16BE(); + _sound2 = stream.readUint16BE(); offset += 2; break; case kSound2TypePosition: - soundType2 = stream.readByte(); + _soundType2 = stream.readByte(); offset += 1; break; case kPaletePosition: @@ -188,18 +206,17 @@ void Frame::readMainChannels(Common::SeekableReadStream &stream, uint16 offset, debug("Field Position %d, Finish Position %d", offset, finishPosition); break; } - } - + } } void Frame::readSprite(Common::SeekableReadStream &stream, uint16 offset, uint16 size) { uint16 spritePosition = (offset - 32) / 16; uint16 spriteStart = spritePosition * 16 + 32; - + uint16 fieldPosition = offset - spriteStart; uint16 finishPosition = fieldPosition + size; - Sprite& sprite = *sprites[spritePosition]; + Sprite &sprite = *_sprites[spritePosition]; while (fieldPosition < finishPosition) { switch (fieldPosition) { @@ -208,7 +225,7 @@ void Frame::readSprite(Common::SeekableReadStream &stream, uint16 offset, uint16 fieldPosition++; break; case kSpritePositionEnabled: - sprite.enabled = (stream.readByte() != 0); + sprite._enabled = (stream.readByte() != 0); fieldPosition++; break; case kSpritePositionUnk2: @@ -216,27 +233,27 @@ void Frame::readSprite(Common::SeekableReadStream &stream, uint16 offset, uint16 fieldPosition += 2; break; case kSpritePositionFlags: - sprite.flags = stream.readUint16BE(); + sprite._flags = stream.readUint16BE(); fieldPosition += 2; break; case kSpritePositionCastId: - sprite.castId = stream.readUint16BE(); + sprite._castId = stream.readUint16BE(); fieldPosition += 2; break; case kSpritePositionY: - sprite.startPoint.y = stream.readUint16BE(); + sprite._startPoint.y = stream.readUint16BE(); fieldPosition += 2; break; case kSpritePositionX: - sprite.startPoint.x = stream.readUint16BE(); + sprite._startPoint.x = stream.readUint16BE(); fieldPosition += 2; break; case kSpritePositionWidth: - sprite.width = stream.readUint16BE(); + sprite._width = stream.readUint16BE(); fieldPosition += 2; break; case kSpritePositionHeight: - sprite.height = stream.readUint16BE(); + sprite._height = stream.readUint16BE(); fieldPosition += 2; break; default: @@ -248,23 +265,47 @@ void Frame::readSprite(Common::SeekableReadStream &stream, uint16 offset, uint16 } } +void Frame::display() { + //FIXME + RIFFArchive riff; + riff.openFile("bookshelf_example.mmm"); + + DIBDecoder palette; + Common::SeekableReadStream *pal = riff.getResource(MKTAG('C', 'L', 'U', 'T'), 1025); + palette.loadPalette(*pal); + g_system->getPaletteManager()->setPalette(palette.getPalette(), 0, 255); + + for (uint16 i = 0; i < CHANNEL_COUNT; i++) { + if (_sprites[i]->_enabled) { + DIBDecoder img; + uint32 castId = 1024 + _sprites[i]->_castId; + img.loadStream(*riff.getResource(MKTAG('D', 'I', 'B', ' '), castId)); + g_system->copyRectToScreen(img.getSurface()->getPixels(), img.getSurface()->pitch, + _sprites[i]->_startPoint.x, + _sprites[i]->_startPoint.y, + _sprites[i]->_height, + _sprites[i]->_width); + } + } +} + Sprite::Sprite() { - enabled = false; - width = 0; - flags = 0; - height = 0; - castId = 0; - castId = 0; + _enabled = false; + _width = 0; + _flags = 0; + _height = 0; + _castId = 0; + _castId = 0; } -Sprite::Sprite(const Sprite& sprite) { - enabled = sprite.enabled; - castId = sprite.castId; - flags = sprite.flags; - width = sprite.width; - height = sprite.height; - startPoint.x = sprite.startPoint.x; - startPoint.y = sprite.startPoint.y; +Sprite::Sprite(const Sprite &sprite) { + _enabled = sprite._enabled; + _castId = sprite._castId; + _flags = sprite._flags; + _width = sprite._width; + _height = sprite._height; + _startPoint.x = sprite._startPoint.x; + _startPoint.y = sprite._startPoint.y; } -} //End of namespace Director
\ No newline at end of file +} //End of namespace Director diff --git a/engines/director/score.h b/engines/director/score.h index 25d6cdda6e..cadd130312 100644 --- a/engines/director/score.h +++ b/engines/director/score.h @@ -23,6 +23,8 @@ #include "common/rect.h" #include "common/stream.h" #include "common/array.h" +#include "director/resource.h" + namespace Director { #define CHANNEL_COUNT 24 @@ -68,50 +70,56 @@ enum mainChannelsPosition { kPaletePosition = 15 }; -struct Sprite { +class Sprite { public: - bool enabled; - uint8 castId; - //castType type; - uint16 flags; - Common::Point startPoint; - uint16 width; - uint16 height; Sprite(); - Sprite(const Sprite& sprite); + Sprite(const Sprite &sprite); + bool _enabled; + uint8 _castId; + //castType type; + uint16 _flags; + Common::Point _startPoint; + uint16 _width; + uint16 _height; }; -struct Frame { +class Frame { public: - uint8 actionId; - - uint8 transFlags; - uint8 transChunkSize; - uint8 transType; - uint8 tempo; - - uint16 sound1; - uint8 soundType1; - uint16 sound2; - uint8 soundType2; - - uint8 skipFrameFlag; - uint8 blend; - Common::Array<Sprite*> sprites; - Frame(); ~Frame(); - Frame(const Frame& frame); + Frame(const Frame &frame); void readChannel(Common::SeekableReadStream &stream, uint16 offset, uint16 size); + void display(); + private: void readSprite(Common::SeekableReadStream &stream, uint16 offset, uint16 size); void readMainChannels(Common::SeekableReadStream &stream, uint16 offset, uint16 size); + +public: + uint8 _actionId; + uint8 _transFlags; + uint8 _transChunkSize; + uint8 _transType; + uint8 _tempo; + + uint16 _sound1; + uint8 _soundType1; + uint16 _sound2; + uint8 _soundType2; + + uint8 _skipFrameFlag; + uint8 _blend; + Common::Array<Sprite *> _sprites; + }; -struct Score { +class Score { +public: + Common::Array<Frame *> _frames; + public: - Score(Common::SeekableReadStream &stream); - Common::Array<Frame*> frames; + Score(Common::SeekableReadStream &stream); + void play(); }; -} //End of namespace Director
\ No newline at end of file +} //End of namespace Director |