[Scummvm-git-logs] scummvm master -> c7eba6419d97dc3d05635d6efcd303b85ed5473e

moralrecordings code at moral.net.au
Sat May 16 16:26:56 UTC 2020


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

Summary:
522a916d1e DIRECTOR: LINGO: Implement b_put
d8cbadd201 DIRECTOR: Invert sound looping bit
00de545c74 DIRECTOR: LINGO: Reverse arguments to b_put
c7eba6419d DIRECTOR: LINGO: Buffer events during script execution


Commit: 522a916d1e036ec49329b99500139ff7af646a1a
    https://github.com/scummvm/scummvm/commit/522a916d1e036ec49329b99500139ff7af646a1a
Author: Scott Percival (code at moral.net.au)
Date: 2020-05-16T23:43:01+08:00

Commit Message:
DIRECTOR: LINGO: Implement b_put

Director allows printing debug messages to the Message window
using "put(...)", which is represented in the bytecode as a
function call.
This is unrelated to the assignment operator "put [x] into [y]".

Changed paths:
    engines/director/lingo/lingo-builtins.cpp
    engines/director/lingo/lingo-builtins.h


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 0e6156f2ef..91cc0f3bea 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -180,7 +180,7 @@ static struct BuiltinProto {
 	{ "HMStoFrames",	LB::b_HMStoFrames,	4, 4, false, 3, FBLTIN },	//		D3 f
 	{ "param",	 		LB::b_param,		1, 1, true,  4, FBLTIN },	//			D4 f
 	{ "printFrom",	 	LB::b_printFrom,	-1,0, false, 2, BLTIN },	// D2 c
-		// put															// D2
+	{ "put",			LB::b_put,			-1,0, false, 2, BLTIN },	// D2
 		// set															// D2
 	{ "showGlobals",	LB::b_showGlobals,	0, 0, false, 2, BLTIN },	// D2 c
 	{ "showLocals",		LB::b_showLocals,	0, 0, false, 2, BLTIN },	// D2 c
@@ -1373,6 +1373,17 @@ void LB::b_cursor(int nargs) {
 	}
 }
 
+void LB::b_put(int nargs) {
+	// Prints a statement to the Message window
+	Common::String output;
+	for (int i = 0; i < nargs; i++) {
+		output += g_lingo->pop().asString();
+		if (i < nargs - 1)
+			output += " ";
+	}
+	debug("-- %s", output.c_str());
+}
+
 void LB::b_showGlobals(int nargs) {
 	warning("STUB: b_showGlobals");
 }
diff --git a/engines/director/lingo/lingo-builtins.h b/engines/director/lingo/lingo-builtins.h
index a83aa4a411..26213e5eef 100644
--- a/engines/director/lingo/lingo-builtins.h
+++ b/engines/director/lingo/lingo-builtins.h
@@ -93,6 +93,7 @@ namespace LB {
 	void b_HMStoFrames(int nargs);
 	void b_param(int nargs);
 	void b_printFrom(int nargs);
+	void b_put(int nargs);
 	void b_showGlobals(int nargs);
 	void b_showLocals(int nargs);
 	void b_value(int nargs);


Commit: d8cbadd20158984d88ec1fd9b0a8ec5e91e2c7a3
    https://github.com/scummvm/scummvm/commit/d8cbadd20158984d88ec1fd9b0a8ec5e91e2c7a3
Author: Scott Percival (code at moral.net.au)
Date: 2020-05-17T00:00:16+08:00

Commit Message:
DIRECTOR: Invert sound looping bit

Changed paths:
    engines/director/cast.cpp


diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index c2a9ade8d0..7264fb9c42 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -137,7 +137,7 @@ SoundCast::SoundCast(Common::ReadStreamEndian &stream, uint16 version) {
 		for (int i = 0; i < 0xe; i++) {
 			stream.readByte();
 		}
-		_looping = stream.readByte() & 0x10;
+		_looping = stream.readByte() & 0x10 ? 0 : 1;
 	}
 }
 


Commit: 00de545c744b4dc50b2d4e210dc819becb3eddf6
    https://github.com/scummvm/scummvm/commit/00de545c744b4dc50b2d4e210dc819becb3eddf6
Author: Scott Percival (code at moral.net.au)
Date: 2020-05-17T00:14:12+08:00

Commit Message:
DIRECTOR: LINGO: Reverse arguments to b_put

Changed paths:
    engines/director/lingo/lingo-builtins.cpp


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 91cc0f3bea..16a758bd85 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1376,12 +1376,13 @@ void LB::b_cursor(int nargs) {
 void LB::b_put(int nargs) {
 	// Prints a statement to the Message window
 	Common::String output;
-	for (int i = 0; i < nargs; i++) {
-		output += g_lingo->pop().asString();
-		if (i < nargs - 1)
+	for (int i = nargs - 1; i >= 0; i--) {
+		output += g_lingo->peek(i).asString();
+		if (i > 0)
 			output += " ";
 	}
 	debug("-- %s", output.c_str());
+	g_lingo->dropStack(nargs);
 }
 
 void LB::b_showGlobals(int nargs) {


Commit: c7eba6419d97dc3d05635d6efcd303b85ed5473e
    https://github.com/scummvm/scummvm/commit/c7eba6419d97dc3d05635d6efcd303b85ed5473e
Author: Scott Percival (code at moral.net.au)
Date: 2020-05-17T00:14:53+08:00

Commit Message:
DIRECTOR: LINGO: Buffer events during script execution

During execution of a Lingo script, there are certain actions which will
repaint the screen, delay, and trigger an event poll (such as calling
b_updateStage, or updating certain cast members). As part of this, Lingo
will record events (such as clicking on a cast member), but will not
process them until after the current script returns control to the engine.

Changed paths:
    engines/director/director.h
    engines/director/events.cpp
    engines/director/lingo/lingo-builtins.cpp
    engines/director/lingo/lingo-events.cpp
    engines/director/lingo/lingo.h


diff --git a/engines/director/director.h b/engines/director/director.h
index cdd47cedac..8fdbf8bfd6 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -127,7 +127,7 @@ public:
 	Archive *createArchive();
 
 	// events.cpp
-	void processEvents();
+	void processEvents(bool bufferLingoEvents = false);
 	void setDraggedSprite(uint16 id);
 	void releaseDraggedSprite();
 	uint32 getMacTicks();
diff --git a/engines/director/events.cpp b/engines/director/events.cpp
index 42081e3323..5793100c1e 100644
--- a/engines/director/events.cpp
+++ b/engines/director/events.cpp
@@ -52,7 +52,7 @@ bool processQuitEvent(bool click) {
 
 uint32 DirectorEngine::getMacTicks() { return g_system->getMillis() * 60 / 1000.; }
 
-void DirectorEngine::processEvents() {
+void DirectorEngine::processEvents(bool bufferLingoEvents) {
 	Common::Event event;
 
 	uint endTime = g_system->getMillis() + 10;
@@ -108,7 +108,7 @@ void DirectorEngine::processEvents() {
 				sc->_lastClickTime = sc->_lastEventTime;
 
 				debugC(3, kDebugEvents, "event: Button Down @(%d, %d), sprite id: %d", pos.x, pos.y, spriteId);
-				_lingo->processEvent(kEventMouseDown);
+				_lingo->registerEvent(kEventMouseDown);
 
 				if (currentFrame->_sprites[spriteId]->_moveable)
 					g_director->setDraggedSprite(spriteId);
@@ -125,7 +125,7 @@ void DirectorEngine::processEvents() {
 				sc->_mouseIsDown = false;
 				releaseDraggedSprite();
 
-				_lingo->processEvent(kEventMouseUp);
+				_lingo->registerEvent(kEventMouseUp);
 				sc->_currentMouseDownSpriteId = 0;
 				break;
 
@@ -152,7 +152,7 @@ void DirectorEngine::processEvents() {
 
 				sc->_lastEventTime = g_director->getMacTicks();
 				sc->_lastKeyTime = sc->_lastEventTime;
-				_lingo->processEvent(kEventKeyDown);
+				_lingo->registerEvent(kEventKeyDown);
 				break;
 
 			default:
@@ -160,11 +160,17 @@ void DirectorEngine::processEvents() {
 			}
 		}
 
+		if (!bufferLingoEvents)
+			_lingo->processEvents();
+
 		g_system->updateScreen();
 		g_system->delayMillis(10);
 
 		if (sc->getCurrentFrame() > 0)
-			_lingo->processEvent(kEventIdle);
+			_lingo->registerEvent(kEventIdle);
+
+		if (!bufferLingoEvents)
+			_lingo->processEvents();
 	}
 }
 
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 16a758bd85..f0ef57eaa0 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1822,6 +1822,7 @@ void LB::b_updateStage(int nargs) {
 	Frame *frame = score->_frames[curFrame];
 
 	frame->prepareFrame(score, true);
+	g_director->processEvents(true);
 }
 
 
diff --git a/engines/director/lingo/lingo-events.cpp b/engines/director/lingo/lingo-events.cpp
index bd155e5aac..0beb8cfde9 100644
--- a/engines/director/lingo/lingo-events.cpp
+++ b/engines/director/lingo/lingo-events.cpp
@@ -142,7 +142,7 @@ void Lingo::primaryEventHandler(LEvent event) {
 #endif
 }
 
-void Lingo::processInputEvent(LEvent event) {
+void Lingo::registerInputEvent(LEvent event) {
 	/* When the mouseDown or mouseUp occurs over a sprite, the message
 	 * goes first to the sprite script, then to the script of the cast
 	 * member, to the frame script and finally to the movie scripts.
@@ -169,25 +169,25 @@ void Lingo::processInputEvent(LEvent event) {
 	if (_vm->getVersion() > 3) {
 		if (true) {
 			// TODO: Check whether occurring over a sprite
-			processEvent(event, kSpriteScript, currentFrame->_sprites[spriteId]->_scriptId);
+			_eventQueue.push(LingoEvent(event, kSpriteScript, currentFrame->_sprites[spriteId]->_scriptId));
 		}
-		processEvent(event, kCastScript, currentFrame->_sprites[spriteId]->_castId);
-		processEvent(event, kFrameScript, score->_frames[score->getCurrentFrame()]->_actionId);
+		_eventQueue.push(LingoEvent(event, kCastScript, currentFrame->_sprites[spriteId]->_castId));
+		_eventQueue.push(LingoEvent(event, kFrameScript, score->_frames[score->getCurrentFrame()]->_actionId));
 		// TODO: Is the kFrameScript call above correct?
 	} else if (event == kEventMouseUp) {
 		// Frame script overrides sprite script
 		if (!currentFrame->_sprites[spriteId]->_scriptId) {
-			processEvent(kEventNone, kSpriteScript, currentFrame->_sprites[spriteId]->_castId + score->_castIDoffset);
-			processEvent(event, kSpriteScript, currentFrame->_sprites[spriteId]->_castId + score->_castIDoffset);
+			_eventQueue.push(LingoEvent(kEventNone, kSpriteScript, currentFrame->_sprites[spriteId]->_castId + score->_castIDoffset));
+			_eventQueue.push(LingoEvent(event, kSpriteScript, currentFrame->_sprites[spriteId]->_castId + score->_castIDoffset));
 		} else {
-			processEvent(kEventNone, kFrameScript, currentFrame->_sprites[spriteId]->_scriptId, spriteId);
+			_eventQueue.push(LingoEvent(kEventNone, kFrameScript, currentFrame->_sprites[spriteId]->_scriptId, spriteId));
 		}
 	} else if (event == kEventMouseDown) {
-		processEvent(event, kSpriteScript, currentFrame->_sprites[spriteId]->_castId + score->_castIDoffset);
+		_eventQueue.push(LingoEvent(event, kSpriteScript, currentFrame->_sprites[spriteId]->_castId + score->_castIDoffset));
 	}
 	if (event == kEventKeyDown) {
 		// TODO: is the above condition necessary or useful?
-		processEvent(event, kGlobalScript, 0);
+		_eventQueue.push(LingoEvent(event, kGlobalScript, 0));
 	}
 
 	runMovieScript(event);
@@ -204,13 +204,13 @@ void Lingo::runMovieScript(LEvent event) {
 
 	for (ScriptContextHash::iterator it = _archives[_archiveIndex].scriptContexts[kMovieScript].begin();
 			it != _archives[_archiveIndex].scriptContexts[kMovieScript].end(); ++it) {
-		processEvent(event, kMovieScript, it->_key);
+		_eventQueue.push(LingoEvent(event, kMovieScript, it->_key));
 		// TODO: How do know which script handles the message?
 	}
 	debugC(9, kDebugEvents, "STUB: processEvent(event, kMovieScript, ?)");
 }
 
-void Lingo::processFrameEvent(LEvent event) {
+void Lingo::registerFrameEvent(LEvent event) {
 	/* [in D4] the enterFrame, exitFrame, idle and timeout messages
 	 * are sent to a frame script and then a movie script.	If the
 	 * current frame has no frame script when the event occurs, the
@@ -238,12 +238,12 @@ void Lingo::processFrameEvent(LEvent event) {
 		assert(score->_frames[score->getCurrentFrame()] != nullptr);
 		entity = score->_frames[score->getCurrentFrame()]->_actionId;
 	}
-	processEvent(event, kFrameScript, entity);
+	_eventQueue.push(LingoEvent(event, kFrameScript, entity));
 
 	runMovieScript(event);
 }
 
-void Lingo::processGenericEvent(LEvent event) {
+void Lingo::registerGenericEvent(LEvent event) {
 	// Movie Script
 	if (event == kEventStart || event == kEventPrepareMovie ||
 			event == kEventStartMovie || event == kEventStopMovie)
@@ -254,14 +254,14 @@ void Lingo::processGenericEvent(LEvent event) {
 	runMovieScript(event);
 }
 
-void Lingo::processSpriteEvent(LEvent event) {
+void Lingo::registerSpriteEvent(LEvent event) {
 	Score *score = _vm->getCurrentScore();
 	Frame *currentFrame = score->_frames[score->getCurrentFrame()];
 	if (event == kEventBeginSprite) {
 		// TODO: Check if this is also possibly a kSpriteScript?
 		for (uint16 i = 0; i <= score->_numChannelsDisplayed; i++)
 			if (currentFrame->_sprites[i]->_enabled)
-				processEvent(event, kCastScript, currentFrame->_sprites[i]->_scriptId);
+				_eventQueue.push(LingoEvent(event, kCastScript, currentFrame->_sprites[i]->_scriptId));
 
 	} else {
 		warning("STUB: processSpriteEvent called for something else than kEventBeginSprite, additional logic probably needed");
@@ -269,20 +269,20 @@ void Lingo::processSpriteEvent(LEvent event) {
 
 }
 
-void Lingo::processEvent(LEvent event) {
+void Lingo::registerEvent(LEvent event) {
 	switch (event) {
 		case kEventKeyUp:
 		case kEventKeyDown:
 		case kEventMouseUp:
 		case kEventMouseDown:
-			processInputEvent(event);
+			registerInputEvent(event);
 			break;
 
 		case kEventIdle:
 		case kEventEnterFrame:
 		case kEventExitFrame:
 		case kEventNone:
-			processFrameEvent(event);
+			registerFrameEvent(event);
 			break;
 
 		case kEventStart:
@@ -290,19 +290,31 @@ void Lingo::processEvent(LEvent event) {
 		case kEventStopMovie:
 		case kEventTimeout:
 		case kEventPrepareMovie:
-			processGenericEvent(event);
+			registerGenericEvent(event);
 			break;
 		case kEventBeginSprite:
-			processSpriteEvent(event);
+			registerSpriteEvent(event);
 			break;
 
 		default:
-			warning("processEvent: Unhandled event %s", _eventHandlerTypes[event]);
+			warning("registerEvent: Unhandled event %s", _eventHandlerTypes[event]);
 	}
 
 	_dontPassEvent = false;
 }
 
+void Lingo::processEvent(LEvent event) {
+	registerEvent(event);
+	processEvents();
+}
+
+void Lingo::processEvents() {
+	while (!_eventQueue.empty()) {
+		LingoEvent el = _eventQueue.pop();
+		processEvent(el.event, el.st, el.entityId, el.channelId);
+	}
+}
+
 void Lingo::processEvent(LEvent event, ScriptType st, int entityId, int channelId) {
 	if (entityId < 0)
 		return;
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index f6103e93ea..2a46d9c8e9 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -237,6 +237,20 @@ struct CFrame {	/* proc/func call stack frame */
 	SymbolHash *localvars;
 };
 
+struct LingoEvent {
+	LEvent event;
+	ScriptType st;
+	int entityId;
+	int channelId;
+
+	LingoEvent (LEvent e, ScriptType s, int ei, int ci = -1) {
+		event = e;
+		st = s;
+		entityId = ei;
+		channelId = ci;
+	}
+};
+
 
 struct LingoArchive {
 	ScriptContextHash scriptContexts[kMaxScriptType + 1];
@@ -278,13 +292,15 @@ private:
 private:
 	void initEventHandlerTypes();
 	void primaryEventHandler(LEvent event);
-	void processInputEvent(LEvent event);
-	void processFrameEvent(LEvent event);
-	void processGenericEvent(LEvent event);
+	void registerInputEvent(LEvent event);
+	void registerFrameEvent(LEvent event);
+	void registerGenericEvent(LEvent event);
 	void runMovieScript(LEvent event);
-	void processSpriteEvent(LEvent event);
+	void registerSpriteEvent(LEvent event);
 	void processEvent(LEvent event, ScriptType st, int entityId, int channelId = -1);
 
+	Common::Queue<LingoEvent> _eventQueue;
+
 public:
 	ScriptContext *getScriptContext(ScriptType type, uint16 id);
 	Common::String getName(uint16 id);
@@ -292,6 +308,8 @@ public:
 	Symbol *getHandler(Common::String &name);
 
 	void processEvent(LEvent event);
+	void processEvents();
+	void registerEvent(LEvent event);
 
 public:
 	void execute(uint pc);




More information about the Scummvm-git-logs mailing list