diff options
-rw-r--r-- | engines/director/director.cpp | 9 | ||||
-rw-r--r-- | engines/director/director.h | 4 | ||||
-rw-r--r-- | engines/director/frame.cpp | 46 | ||||
-rw-r--r-- | engines/director/score.cpp | 71 | ||||
-rw-r--r-- | engines/director/score.h | 1 |
5 files changed, 70 insertions, 61 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp index e1f4ef1bdb..26b3387601 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -112,7 +112,9 @@ Common::Error DirectorEngine::run() { //_mainArchive = new RIFFArchive(); //_mainArchive->openFile("bookshelf_example.mmm"); - loadMMMNames(ConfMan.get("path")); + scanMovies(ConfMan.get("path")); + + loadSharedCastsFrom(_sharedCastFile); loadMainArchive(); _currentScore = new Score(this, _mainArchive); @@ -124,7 +126,7 @@ Common::Error DirectorEngine::run() { return Common::kNoError; } -Common::HashMap<Common::String, Score *> DirectorEngine::loadMMMNames(Common::String folder) { +Common::HashMap<Common::String, Score *> DirectorEngine::scanMovies(const Common::String &folder) { Common::FSNode directory(folder); Common::FSList movies; const char *sharedMMMname; @@ -142,8 +144,9 @@ Common::HashMap<Common::String, Score *> DirectorEngine::loadMMMNames(Common::St if (!movies.empty()) { for (Common::FSList::const_iterator i = movies.begin(); i != movies.end(); ++i) { debugC(2, kDebugLoading, "File: %s", i->getName().c_str()); + if (Common::matchString(i->getName().c_str(), sharedMMMname, true)) { - loadSharedCastsFrom(i->getName()); + _sharedCastFile = i->getName(); continue; } diff --git a/engines/director/director.h b/engines/director/director.h index 4cb8640d5b..f8207f49ce 100644 --- a/engines/director/director.h +++ b/engines/director/director.h @@ -102,7 +102,7 @@ protected: private: const DirectorGameDescription *_gameDescription; - Common::HashMap<Common::String, Score *> loadMMMNames(Common::String folder); + Common::HashMap<Common::String, Score *> scanMovies(const Common::String &folder); void loadEXE(); void loadEXEv3(Common::SeekableReadStream *stream); void loadEXEv4(Common::SeekableReadStream *stream); @@ -125,6 +125,8 @@ private: byte *_currentPalette; uint16 _currentPaletteLength; Lingo *_lingo; + + Common::String _sharedCastFile; }; } // End of namespace Director diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp index 174581f336..421336d133 100644 --- a/engines/director/frame.cpp +++ b/engines/director/frame.cpp @@ -95,7 +95,7 @@ void Frame::readChannel(Common::SeekableSubReadStreamEndian &stream, uint16 offs if (size <= 16) readSprite(stream, offset, size); else { - //read > 1 sprites channel + // read > 1 sprites channel while (size > 16) { byte spritePosition = (offset - 32) / 16; uint16 nextStart = (spritePosition + 1) * 16 + 32; @@ -125,13 +125,13 @@ void Frame::readMainChannels(Common::SeekableSubReadStreamEndian &stream, uint16 offset++; break; case kTransFlagsPosition: { - uint8 transFlags = stream.readByte(); - if (transFlags & 0x80) - _transArea = 1; - else - _transArea = 0; - _transDuration = transFlags & 0x7f; - offset++; + uint8 transFlags = stream.readByte(); + if (transFlags & 0x80) + _transArea = 1; + else + _transArea = 0; + _transDuration = transFlags & 0x7f; + offset++; } break; case kTransChunkSizePosition: @@ -244,7 +244,7 @@ void Frame::readSprite(Common::SeekableSubReadStreamEndian &stream, uint16 offse fieldPosition += 2; break; default: - //end cycle, go to next sprite channel + // end of channel, go to next sprite channel readSprite(stream, spriteStart + 16, finishPosition - fieldPosition); fieldPosition = finishPosition; break; @@ -257,7 +257,7 @@ void Frame::prepareFrame(Score *score) { renderSprites(*score->_trailSurface, true); if (_transType != 0) - //TODO Handle changing area case + //T ODO Handle changing area case playTransition(score); if (_sound1 != 0 || _sound2 != 0) { @@ -268,16 +268,16 @@ void Frame::prepareFrame(Score *score) { } void Frame::playSoundChannel() { - debug(0, "Sound2 %d", _sound2); debug(0, "Sound1 %d", _sound1); + debug(0, "Sound2 %d", _sound2); } void Frame::playTransition(Score *score) { uint16 duration = _transDuration * 250; // _transDuration in 1/4 of sec - duration = (duration == 0 ? 250 : duration); // director support transition duration = 0, but animation play like value = 1, idk. + duration = (duration == 0 ? 250 : duration); // director supports transition duration = 0, but animation play like value = 1, idk. if (_transChunkSize == 0) - _transChunkSize = 1; //equal 1 step + _transChunkSize = 1; // equal to 1 step uint16 stepDuration = duration / _transChunkSize; uint16 steps = duration / stepDuration; @@ -428,6 +428,7 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { warning("Cast id %d not found", _sprites[i]->_castId); continue; } else { + warning("Getting cast id %d from shared cast"); cast = _vm->getSharedCasts()->getVal(_sprites[i]->_castId); } } else { @@ -447,10 +448,7 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { } if (!img->getSurface()) { - //TODO - //BMPDecoder doesnt cover all BITD resources (not all have first two bytes 'BM') - //Some BITD's first two bytes 0x6 0x0 - warning("Can not load image %d", _sprites[i]->_castId); + warning("Frame::renderSprites: Could not load image %d", _sprites[i]->_castId); continue; } @@ -472,7 +470,7 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { surface.blitFrom(*img->getSurface(), Common::Point(x, y)); break; case kInkTypeTransparent: - //FIXME: is it always white (last entry in pallette)? + // FIXME: is it always white (last entry in pallette)? surface.transBlitFrom(*img->getSurface(), Common::Point(x, y), _vm->getPaletteColorCount() - 1); break; case kInkTypeBackgndTrans: @@ -512,7 +510,7 @@ void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId) { switch (button->buttonType) { case kTypeCheckBox: - //Magic numbers: checkbox square need to move left about 5px from text and 12px side size (d4) + // Magic numbers: checkbox square need to move left about 5px from text and 12px side size (D4) surface.frameRect(Common::Rect(x - 17, y, x + 12, y + 12), 0); break; case kTypeButton: @@ -624,7 +622,7 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteID) { if (textCast->borderSize != kSizeNone) { uint16 size = textCast->borderSize; - //Indent from borders, measured in d4 + // Indent from borders, measured in d4 x -= 1; y -= 4; @@ -662,7 +660,7 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteID) { } void Frame::drawBackgndTransSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect) { - uint8 skipColor = _vm->getPaletteColorCount() - 1; //FIXME is it always white (last entry in pallette) ? + uint8 skipColor = _vm->getPaletteColorCount() - 1; // FIXME is it always white (last entry in pallette) ? for (int ii = 0; ii < sprite.h; ii++) { const byte *src = (const byte *)sprite.getBasePtr(0, ii); @@ -686,7 +684,7 @@ void Frame::drawGhostSprite(Graphics::ManagedSurface &target, const Graphics::Su for (int j = 0; j < drawRect.width(); j++) { if ((getSpriteIDFromPos(Common::Point(drawRect.left + j, drawRect.top + ii)) != 0) && (*src != skipColor)) - *dst = (_vm->getPaletteColorCount() - 1) - *src; //Oposite color + *dst = (_vm->getPaletteColorCount() - 1) - *src; // Oposite color src++; dst++; @@ -772,7 +770,7 @@ void Frame::drawMatteSprite(Graphics::ManagedSurface &target, const Graphics::Su } uint16 Frame::getSpriteIDFromPos(Common::Point pos) { - //Find first from top to bottom + // Find first from top to bottom for (uint16 i = _drawRects.size() - 1; i > 0; i--) { if (_drawRects[i].contains(pos)) return i; @@ -781,4 +779,4 @@ uint16 Frame::getSpriteIDFromPos(Common::Point pos) { return 0; } -} //End of namespace Director +} // End of namespace Director diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 90506519ac..2d3ae798bd 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -160,7 +160,6 @@ void Score::loadArchive() { } Common::Array<uint16> vwci = _movieArchive->getResourceIDList(MKTAG('V','W','C','I')); - if (vwci.size() > 0) { Common::Array<uint16>::iterator iterator; @@ -169,7 +168,6 @@ void Score::loadArchive() { } Common::Array<uint16> stxt = _movieArchive->getResourceIDList(MKTAG('S','T','X','T')); - if (stxt.size() > 0) { loadScriptText(*_movieArchive->getResource(MKTAG('S','T','X','T'), *stxt.begin())); } @@ -218,6 +216,8 @@ void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) { if (_vm->getVersion() > 3) { stream.skip(16); + + warning("STUB: Score::loadFrames. Skipping initial bytes"); //Unknown, some bytes - constant (refer to contuinity). } @@ -244,7 +244,6 @@ void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) { frameSize -= channelSize + 4; } frame->readChannel(stream, channelOffset, channelSize); - } _frames.push_back(frame); @@ -409,10 +408,10 @@ void Score::loadScriptText(Common::SeekableSubReadStreamEndian &stream) { for (uint32 i = 0; i < strLen; i++) { byte ch = stream.readByte(); - if (ch == 0x0d) { - //in old Mac systems \r was the code for end-of-line instead. + // Convert Mac line endings + if (ch == 0x0d) ch = '\n'; - } + script += ch; } @@ -496,8 +495,8 @@ void Score::loadCastInfo(Common::SeekableSubReadStreamEndian &stream, uint16 id) } void Score::gotoloop() { - //This command has the playback head contonuously return to the first marker to to the left and then loop back. - //If no marker are to the left of the playback head, the playback head continues to the right. + // This command has the playback head contonuously return to the first marker to to the left and then loop back. + // If no marker are to the left of the playback head, the playback head continues to the right. Common::SortedArray<Label *>::iterator i; for (i = _labels->begin(); i != _labels->end(); ++i) { @@ -514,25 +513,25 @@ void Score::gotonext() { for (i = _labels->begin(); i != _labels->end(); ++i) { if ((*i)->name == _currentLabel) { if (i != _labels->end()) { - //return to the first marker to to the right + // return to the first marker to to the right ++i; _currentFrame = (*i)->number; return; } else { - //if no markers are to the right of the playback head, - //the playback head goes to the first marker to the left + // if no markers are to the right of the playback head, + // the playback head goes to the first marker to the left _currentFrame = (*i)->number; return; } } } - //If there are not markers to the left, - //the playback head goes to frame 1, (Director frame array start from 1, engine from 0) + // If there are not markers to the left, + // the playback head goes to frame 1, (Director frame array start from 1, engine from 0) _currentFrame = 0; } void Score::gotoprevious() { - //One label + // One label if (_labels->begin() == _labels->end()) { _currentFrame = (*_labels->begin())->number; return; @@ -602,7 +601,7 @@ Common::Array<Common::String> Score::loadStrings(Common::SeekableSubReadStreamEn } uint16 count = stream.readUint16(); - offset += (count + 1) * 4 + 2; //positions info + uint16 count + offset += (count + 1) * 4 + 2; // positions info + uint16 count uint32 startPos = stream.readUint32() + offset; for (uint16 i = 0; i < count; i++) { @@ -689,7 +688,7 @@ TextCast::TextCast(Common::SeekableSubReadStreamEndian &stream) { if (flags & 0x4) textFlags.push_back(kTextFlagDoNotWrap); - //TODO: FIXME: guesswork + // TODO: FIXME: guesswork fontId = stream.readByte(); fontSize = stream.readByte(); @@ -752,20 +751,24 @@ void Score::update() { _surface->clear(); _surface->copyFrom(*_trailSurface); - //Enter and exit from previous frame (Director 4) + // Enter and exit from previous frame (Director 4) _lingo->processEvent(kEventEnterFrame, _frames[_currentFrame]->_actionId); _lingo->processEvent(kEventExitFrame, _frames[_currentFrame]->_actionId); - //TODO Director 6 - another order + // TODO Director 6 - another order + // TODO Director 6 step: send beginSprite event to any sprites whose span begin in the upcoming frame + if (_vm->getVersion() >= 6) { + for (uint16 i = 0; i < CHANNEL_COUNT; i++) { + if (_frames[_currentFrame]->_sprites[i]->_enabled) { + _lingo->processEvent(kEventBeginSprite, i); + } + } + } - //TODO Director 6 step: send beginSprite event to any sprites whose span begin in the upcoming frame - //for (uint16 i = 0; i < CHANNEL_COUNT; i++) { - // if (_frames[_currentFrame]->_sprites[i]->_enabled) - // _lingo->processEvent(kEventBeginSprite, i); - //} + // TODO Director 6 step: send prepareFrame event to all sprites and the script channel in upcoming frame + if (_vm->getVersion() >= 6) + _lingo->processEvent(kEventPrepareFrame, _currentFrame); - //TODO Director 6 step: send prepareFrame event to all sprites and the script channel in upcoming frame - //_lingo->processEvent(kEventPrepareFrame, _currentFrame); _currentFrame++; Common::SortedArray<Label *>::iterator i; @@ -776,31 +779,33 @@ void Score::update() { } _frames[_currentFrame]->prepareFrame(this); - //Stage is drawn between the prepareFrame and enterFrame events (Lingo in a Nutshell) + // Stage is drawn between the prepareFrame and enterFrame events (Lingo in a Nutshell) byte tempo = _frames[_currentFrame]->_tempo; if (tempo) { if (tempo > 161) { - //Delay + // Delay _nextFrameTime = g_system->getMillis() + (256 - tempo) * 1000; return; } else if (tempo <= 60) { - //FPS + // FPS _nextFrameTime = g_system->getMillis() + (float)tempo / 60 * 1000; _currentFrameRate = tempo; } else if (tempo >= 136) { - //TODO Wait for channel tempo - 135 + // TODO Wait for channel tempo - 135 + warning("STUB: tempo >= 136"); } else if (tempo == 128) { - //TODO Wait for Click/Key + // TODO Wait for Click/Key + warning("STUB: tempo == 128"); } else if (tempo == 135) { - //Wait for sound channel 1 + // Wait for sound channel 1 while (_soundManager->isChannelActive(1)) { processEvents(); } } else if (tempo == 134) { - //Wait for sound channel 2 + // Wait for sound channel 2 while (_soundManager->isChannelActive(2)) { processEvents(); } @@ -825,7 +830,7 @@ void Score::processEvents() { if (event.type == Common::EVENT_LBUTTONDOWN) { Common::Point pos = g_system->getEventManager()->getMousePos(); - //TODO there is dont send frame id + // TODO there is dont send frame id _lingo->processEvent(kEventMouseDown, _frames[_currentFrame]->getSpriteIDFromPos(pos)); } diff --git a/engines/director/score.h b/engines/director/score.h index a9ac1f97de..9d929adc6a 100644 --- a/engines/director/score.h +++ b/engines/director/score.h @@ -188,6 +188,7 @@ public: void setCurrentFrame(uint16 frameId) { _currentFrame = frameId; } Common::String getMacName() const { return _macName; } Sprite *getSpriteById(uint16 id); + private: void update(); void readVersion(uint32 rid); |