From 1e47d4a13c591b35ebee848aeb9e7cfc41a8b67f Mon Sep 17 00:00:00 2001 From: stevenhoefel Date: Thu, 12 Jan 2017 14:08:53 +1100 Subject: DIRECTOR: D3 frame/sprite scripts. Categorise scripts into groups. --- engines/director/frame.cpp | 10 +++++++-- engines/director/lingo/lingo.cpp | 14 ++++++------- engines/director/lingo/lingo.h | 2 +- engines/director/resource.cpp | 2 +- engines/director/score.cpp | 44 +++++++++++++++++++++++++--------------- 5 files changed, 44 insertions(+), 28 deletions(-) diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp index 1d689abce9..a4b3b6abd1 100644 --- a/engines/director/frame.cpp +++ b/engines/director/frame.cpp @@ -653,8 +653,14 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteID) { Graphics::Surface tmpSurface; tmpSurface.create(r.width(), r.height(), Graphics::PixelFormat::createFormatCLUT8()); - - tmpSurface.fillRect(Common::Rect(r.width(), r.height()), 0); + if (_vm->getVersion() <= 3 && _sprites[spriteID]->_spriteType == 0x0c) { + tmpSurface.fillRect(Common::Rect(r.width(), r.height()), 255); + tmpSurface.frameRect(Common::Rect(r.width(), r.height()), 0); + //TODO: don't override, work out how to display correctly. + _sprites[spriteID]->_ink = kInkTypeTransparent; + } else { + tmpSurface.fillRect(Common::Rect(r.width(), r.height()), 0); + } switch (_sprites[spriteID]->_ink) { case kInkTypeCopy: diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index 1fd4a43c3b..e6b4e11d49 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -282,8 +282,8 @@ Symbol *Lingo::getHandler(Common::String &name) { return _handlers[entityIndex]; } -void Lingo::processEvent(LEvent event, int entityId) { - if (entityId <= 0) +void Lingo::processEvent(LEvent event, ScriptType st, int entityId) { + if (entityId <= 0) return; _currentEntityId = entityId; @@ -291,13 +291,11 @@ void Lingo::processEvent(LEvent event, int entityId) { if (!_eventHandlerTypes.contains(event)) error("processEvent: Unknown event %d for entity %d", event, entityId); - ScriptType st = event2script(event); - - if (st != kNoneScript) { - executeScript(st, entityId + 1); - } else if (_handlers.contains(ENTITY_INDEX(event, entityId))) { - call(_eventHandlerTypes[event], 0); + if (_handlers.contains(ENTITY_INDEX(event, entityId))) { + call(_eventHandlerTypes[event], 0); //D4+ Events pop(); + } else if (_scripts[st].contains(entityId)) { + executeScript(st, entityId + 1); //D3 list of scripts. } else { debugC(8, kDebugLingoExec, "STUB: processEvent(%s) for %d", _eventHandlerTypes[event], entityId); } diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 41d0444a32..dc796d7760 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -181,7 +181,7 @@ public: ScriptType event2script(LEvent ev); Symbol *getHandler(Common::String &name); - void processEvent(LEvent event, int entityId); + void processEvent(LEvent event, ScriptType st, int entityId); void initBuiltIns(); void initFuncs(); diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp index 711ce0474d..da7f3b69b0 100644 --- a/engines/director/resource.cpp +++ b/engines/director/resource.cpp @@ -56,7 +56,7 @@ void DirectorEngine::loadEXE() { if (!exeStream) error("Failed to open EXE '%s'", getEXEName().c_str()); - _lingo->processEvent(kEventStart, 0); + _lingo->processEvent(kEventStart, kMovieScript, 0); exeStream->seek(-4, SEEK_END); exeStream->seek(exeStream->readUint32LE()); diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 267536b5d2..50f36ee627 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -143,7 +143,7 @@ Score::Score(DirectorEngine *vm, Archive *archive) { _movieArchive = archive; _lingo = _vm->getLingo(); _soundManager = _vm->getSoundManager(); - _lingo->processEvent(kEventPrepareMovie, 0); + _lingo->processEvent(kEventPrepareMovie, kMovieScript, 0); _movieScriptCount = 0; _labels = NULL; _font = NULL; @@ -900,7 +900,7 @@ void Score::startLoop() { _stopPlay = false; _nextFrameTime = 0; - _lingo->processEvent(kEventStartMovie, 0); + _lingo->processEvent(kEventStartMovie, kMovieScript, 0); _frames[_currentFrame]->prepareFrame(this); while (!_stopPlay && _currentFrame < _frames.size()) { @@ -918,22 +918,23 @@ void Score::update() { _surface->copyFrom(*_trailSurface); // Enter and exit from previous frame (Director 4) - _lingo->processEvent(kEventEnterFrame, _frames[_currentFrame]->_actionId); - _lingo->processEvent(kEventExitFrame, _frames[_currentFrame]->_actionId); + _lingo->processEvent(kEventEnterFrame, kFrameScript, _frames[_currentFrame]->_actionId); + _lingo->processEvent(kEventExitFrame, kFrameScript, _frames[_currentFrame]->_actionId); // 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: Check if this is also possibly a kSpriteScript? + _lingo->processEvent(kEventBeginSprite, kCastScript, _frames[_currentFrame]->_sprites[i]->_scriptId); } } } // 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); + _lingo->processEvent(kEventPrepareFrame, kFrameScript, _currentFrame); Common::SortedArray