[Scummvm-git-logs] scummvm master -> 1e47d4a13c591b35ebee848aeb9e7cfc41a8b67f

stevenhoefel stevenhoefel at hotmail.com
Thu Jan 12 04:09:03 CET 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
1e47d4a13c DIRECTOR: D3 frame/sprite scripts. Categorise scripts into groups.


Commit: 1e47d4a13c591b35ebee848aeb9e7cfc41a8b67f
    https://github.com/scummvm/scummvm/commit/1e47d4a13c591b35ebee848aeb9e7cfc41a8b67f
Author: stevenhoefel (stevenhoefel at hotmail.com)
Date: 2017-01-12T14:08:53+11:00

Commit Message:
DIRECTOR: D3 frame/sprite scripts. Categorise scripts into groups.

Changed paths:
    engines/director/frame.cpp
    engines/director/lingo/lingo.cpp
    engines/director/lingo/lingo.h
    engines/director/resource.cpp
    engines/director/score.cpp


diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 1d689ab..a4b3b6a 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 1fd4a43..e6b4e11 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 41d0444..dc796d7 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 711ce04..da7f3b6 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 267536b..50f36ee 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<Label *>::iterator i;
 	if (_labels != NULL) {
@@ -945,6 +946,7 @@ void Score::update() {
 	}
 
 	_currentFrame++;
+	if (_currentFrame >= _frames.size()) return;
 
 	_frames[_currentFrame]->prepareFrame(this);
 	// Stage is drawn between the prepareFrame and enterFrame events (Lingo in a Nutshell)
@@ -983,8 +985,9 @@ void Score::update() {
 }
 
 void Score::processEvents() {
-	if (_currentFrame > 0)
-		_lingo->processEvent(kEventIdle, _currentFrame - 1);
+	//TODO: re-instate when we know which script to run.
+	//if (_currentFrame > 0)
+	//	_lingo->processEvent(kEventIdle, _currentFrame - 1);
 
 	Common::Event event;
 
@@ -998,19 +1001,27 @@ void Score::processEvents() {
 			if (event.type == Common::EVENT_LBUTTONDOWN) {
 				Common::Point pos = g_system->getEventManager()->getMousePos();
 
-				//TODO: check that this is the order of script execution!
-				uint16 spriteId = _frames[_currentFrame]->getSpriteIDFromPos(pos);
-				_lingo->processEvent(kEventMouseDown, _frames[_currentFrame]->_sprites[spriteId]->_castId);
-				_lingo->processEvent(kEventMouseDown, _frames[_currentFrame]->_sprites[spriteId]->_scriptId);
+				//D3 doesn't have both mouse up and down.
+				if (_vm->getVersion() > 3) {
+					//TODO: check that this is the order of script execution!
+					uint16 spriteId = _frames[_currentFrame]->getSpriteIDFromPos(pos);
+					_lingo->processEvent(kEventMouseDown, kCastScript, _frames[_currentFrame]->_sprites[spriteId]->_castId);
+					_lingo->processEvent(kEventMouseDown, kSpriteScript, _frames[_currentFrame]->_sprites[spriteId]->_scriptId);
+				}
 			}
 
 			if (event.type == Common::EVENT_LBUTTONUP) {
 				Common::Point pos = g_system->getEventManager()->getMousePos();
 
-				//TODO: check that this is the order of script execution!
 				uint16 spriteId = _frames[_currentFrame]->getSpriteIDFromPos(pos);
-				_lingo->processEvent(kEventMouseUp, _frames[_currentFrame]->_sprites[spriteId]->_castId);
-				_lingo->processEvent(kEventMouseUp, _frames[_currentFrame]->_sprites[spriteId]->_scriptId);
+				if (_vm->getVersion() > 3) {
+					//TODO: check that this is the order of script execution!
+					_lingo->processEvent(kEventMouseUp, kCastScript, _frames[_currentFrame]->_sprites[spriteId]->_castId);
+					_lingo->processEvent(kEventMouseUp, kSpriteScript, _frames[_currentFrame]->_sprites[spriteId]->_scriptId);
+				} else {
+					//D3 doesn't have cast member or sprite scripts. Just Frame Scripts.
+					_lingo->processEvent(kEventMouseUp, kFrameScript, _frames[_currentFrame]->_sprites[spriteId]->_scriptId);
+				}
 			}
 
 			if (event.type == Common::EVENT_KEYDOWN) {
@@ -1034,7 +1045,8 @@ void Score::processEvents() {
 					warning("Keycode: %d", _vm->_keyCode);
 				}
 
-				_lingo->processEvent(kEventKeyDown, 0);
+				//TODO: is movie script correct? Can this be elsewhere?
+				_lingo->processEvent(kEventKeyDown, kMovieScript, 0);
 			}
 		}
 





More information about the Scummvm-git-logs mailing list