[Scummvm-git-logs] scummvm master -> 28803606e9fadaefeeddc24ed947697490b72696

bluegr noreply at scummvm.org
Mon Nov 2 22:52:35 UTC 2026


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

Summary:
ce542e82ce NANCY: NANCY19: Remember the character being played in saved games
dbf2bc1d25 NANCY: NANCY19: Put script graphics back on screen after loading
bc7f39a110 NANCY: Show the state of movie records in list_records
2595194934 NANCY: NANCY24: Don't scale a game drawn at the screen's resolution
43ba2e4c85 NANCY: NANCY24: Stretch backgrounds smaller than the viewport
5de23618f3 NANCY: NANCY23: Make a missing font file a debug message
712437d6e5 NANCY: NANCY19: Treat a value left out of Save:Data as nil
41b39d541d NANCY: NANCY19: Show no text for an autotext key that isn't there
7335451569 NANCY: NANCY19: Prefer a record's own functions for player input
298d7c0f95 NANCY: NANCY19: Add an image cache for the pictures of overlays
8d0ba9b298 NANCY: NANCY19: Don't run paused records at all
c585dbd9e5 NANCY: NANCY24: Add Clean to records, and AR:GetActualField
9e4f7682aa NANCY: NANCY24: Let scripts set the paused field of Movie records
6f132c8e10 NANCY: NANCY24: Add timeMultiplier and RemoveAllStages to Transformers
5749201835 NANCY: NANCY24: Add enableRotate to Summary records
3a6fd331c9 NANCY: NANCY24: Add Streams:GetFrame
10b64f25b3 NANCY: NANCY24: Renumber the sound channels
ac7e951270 NANCY: NANCY24: Add channelType to Sound records
4a5c8ed05b NANCY: NANCY24: Let an overlay show its picture at several places
9aca6f31b3 NANCY: NANCY24: Add overlay drawing to records
d08e8f976b NANCY: NANCY24: Add task completion functions
e8b0ddb3a8 NANCY: NANCY24: Implement Timer records
744c613b2e NANCY: NANCY24: Add detection entry
99acf49c6f NANCY: NANCY19: Hide an NDUI panel on every hide
b2f5cffd13 NANCY: NANCY19: Run engine calls on the coroutine that is running
2001dabd79 NANCY: NANCY19: Fix clicks on rotated hotspots
b3913a5074 NANCY: NANCY19: Only draw the visible part of resized pictures
9aeae19241 NANCY: NANCY19: Don't recopy a movie frame when the movie moves
7b71064570 NANCY: NANCY19: Don't redraw hidden overlays when they move
e387dfeb6d NANCY: NANCY24: Fix the position of pictures drawn with Draw:OVL
46459c6a74 NANCY: NANCY21: Speed up particle drawing
3d02d293ff NANCY: NANCY19: Allow saving vectors with Save:Data
0d88efe4cc NANCY: NANCY23: Add Point multiplication, negation and text
a32f392e2a NANCY: NANCY24: Draw input-taking streams in front of all others
67b8352677 NANCY: NANCY24: Add Sound:Duration
3009f11780 NANCY: NANCY24: Add path waypoints
0b07d1e41d NANCY: NANCY25: Show no text for the empty autotext key
b585054045 NANCY: NANCY25: Allow five player characters
26c461b857 NANCY: NANCY25: Move the Streams functions to Scene and Game
9cd8ea4916 NANCY: NANCY25: Add Game:ShowLink
c4847c01ba NANCY: NANCY25: Add the new fields of particle stages
28803606e9 NANCY: NANCY25: Add detection entry


Commit: ce542e82ced1ef025d64565c46b73117c0e86680
    https://github.com/scummvm/scummvm/commit/ce542e82ced1ef025d64565c46b73117c0e86680
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:02+02:00

Commit Message:
NANCY: NANCY19: Remember the character being played in saved games

>From Nancy19 on, the scripts switch characters, and the character index
in the saved player data was never updated. Saves always restored
character 0, which is George in Nancy20, so loading a save in scene
2920 hid her fidget movies.

Changed paths:
    engines/nancy/state/scene.cpp


diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 119c8636616..2c0576962b7 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -1906,6 +1906,12 @@ void Scene::synchronize(Common::Serializer &ser) {
 		_ndui->saveState(((UIStateData *)getPuzzleData(UIStateData::getTag()))->changes);
 	}
 
+	// Nancy19 and up switch characters from their scripts, which don't keep
+	// track of who is being played, so a saved game gets told here
+	if (ser.isSaving() && g_nancy->getGameType() >= kGameTypeNancy19) {
+		((PlayerCharacterData *)getPuzzleData(PlayerCharacterData::getTag()))->characterIndex = g_nancy->getPlayerCharacter();
+	}
+
 	byte numPuzzleData = _puzzleData.size();
 	ser.syncAsByte(numPuzzleData);
 


Commit: dbf2bc1d2580c1178a8fc043ef6112fe5e52e3ed
    https://github.com/scummvm/scummvm/commit/dbf2bc1d2580c1178a8fc043ef6112fe5e52e3ed
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:05+02:00

Commit Message:
NANCY: NANCY19: Put script graphics back on screen after loading

Loading a game re-enters the scene state, which takes every graphic off
the screen. Only the frame and the viewport were put back, so the
graphics of script records disappeared while their hotspots still
worked. Records now put back their own graphics, along with the
backgrounds of the scene streams.

Changed paths:
    engines/nancy/script/convo.cpp
    engines/nancy/script/convo.h
    engines/nancy/script/particles.cpp
    engines/nancy/script/particles.h
    engines/nancy/script/record.h
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h
    engines/nancy/script/scenecontext.cpp
    engines/nancy/script/scenecontext.h
    engines/nancy/script/xsheet.cpp
    engines/nancy/script/xsheet.h
    engines/nancy/state/scene.cpp
    engines/nancy/state/scenestream.cpp
    engines/nancy/state/scenestream.h


diff --git a/engines/nancy/script/convo.cpp b/engines/nancy/script/convo.cpp
index db7c44dd29d..f7b389d9eb6 100644
--- a/engines/nancy/script/convo.cpp
+++ b/engines/nancy/script/convo.cpp
@@ -144,6 +144,10 @@ void ConvoRecord::onZChanged() {
 	_xsheet.setZ(getZ(), getContext());
 }
 
+void ConvoRecord::registerGraphics() {
+	_xsheet.registerGraphics();
+}
+
 void ConvoRecord::updateGraphics() {
 	_xsheet.setVisible(hasStarted());
 }
diff --git a/engines/nancy/script/convo.h b/engines/nancy/script/convo.h
index 90045b050f7..b3906f26b44 100644
--- a/engines/nancy/script/convo.h
+++ b/engines/nancy/script/convo.h
@@ -60,6 +60,7 @@ public:
 	virtual ~ConvoRecord();
 
 	void updateGraphics() override;
+	void registerGraphics() override;
 
 	// Responses can be added while the scripts named by the record are run
 	void addResponse(ConvoResponse *response) { _responses.push_back(response); }
diff --git a/engines/nancy/script/particles.cpp b/engines/nancy/script/particles.cpp
index 0c8dc50e7c2..aedee198290 100644
--- a/engines/nancy/script/particles.cpp
+++ b/engines/nancy/script/particles.cpp
@@ -1019,6 +1019,12 @@ void registerParticleAPI(lua_State *L) {
 
 // The particles are drawn on a picture as large as the viewport, which is
 // started over every frame
+void ParticleRecord::registerGraphics() {
+	if (_canvas) {
+		_canvas->registerGraphics();
+	}
+}
+
 void ParticleRecord::updateGraphics() {
 	if (!isActive() || _count == 0) {
 		if (_canvas) {
diff --git a/engines/nancy/script/particles.h b/engines/nancy/script/particles.h
index 5a351e304f4..7a6cf4c76ba 100644
--- a/engines/nancy/script/particles.h
+++ b/engines/nancy/script/particles.h
@@ -81,6 +81,7 @@ public:
 	~ParticleRecord() override;
 
 	void updateGraphics() override;
+	void registerGraphics() override;
 
 	// For the stages
 	Particle &getParticle(uint index) { return _particles[index]; }
diff --git a/engines/nancy/script/record.h b/engines/nancy/script/record.h
index 9b874f67619..e8b8c107a3b 100644
--- a/engines/nancy/script/record.h
+++ b/engines/nancy/script/record.h
@@ -165,6 +165,10 @@ public:
 	// Shows or hides what the record draws, once the records of a frame have run
 	virtual void updateGraphics() {}
 
+	// Puts what the record draws back on the screen, after a change of the
+	// state of the engine took everything off it
+	virtual void registerGraphics() {}
+
 	// Enhancement: the player can skip what a scene plays. Whether the record is
 	// something that can be skipped, and what it does when the skipping begins.
 	virtual bool isSkippable() const { return false; }
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 0be661025f8..680d76d30ea 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -391,6 +391,13 @@ void SummaryRecord::showFacade() {
 	_facade.registerGraphics();
 }
 
+void SummaryRecord::registerGraphics() {
+	// The facade is only there once it has been shown
+	if (_facade._drawSurface.getPixels()) {
+		_facade.registerGraphics();
+	}
+}
+
 void SummaryRecord::setBackground(UI::Viewport *background) {
 	_background = background;
 	_numFrames = background ? background->getFrameCount() : 0;
@@ -880,6 +887,12 @@ bool OverrideRecord::hasMessagingName(const Common::String &name) {
 	return isNamed;
 }
 
+void OverrideRecord::registerGraphics() {
+	if (_canvas) {
+		_canvas->registerGraphics();
+	}
+}
+
 void OverrideRecord::onZChanged() {
 	if (_canvas) {
 		_canvas->setScriptZ(getZ(), getContext());
@@ -1065,6 +1078,10 @@ void OverlayRecord::onZChanged() {
 	_graphic.setScriptZ(getZ(), getContext());
 }
 
+void OverlayRecord::registerGraphics() {
+	_graphic.registerGraphics();
+}
+
 void OverlayRecord::updateGraphics() {
 	_graphic.setVisible(isActive() && _hasPicture);
 
@@ -1302,6 +1319,10 @@ void AnimOverlayRecord::onZChanged() {
 	_graphic.setScriptZ(getZ(), getContext());
 }
 
+void AnimOverlayRecord::registerGraphics() {
+	_graphic.registerGraphics();
+}
+
 void AnimOverlayRecord::updateGraphics() {
 	_graphic.setVisible(isActive() && _isVisible && _hasPicture);
 }
@@ -1727,6 +1748,10 @@ void TextRecord::onZChanged() {
 	_graphic.setScriptZ(getZ(), getContext());
 }
 
+void TextRecord::registerGraphics() {
+	_graphic.registerGraphics();
+}
+
 void TextRecord::updateGraphics() {
 	_graphic.setVisible(isActive());
 
@@ -1993,6 +2018,10 @@ bool MovieRecord::prepareReset() {
 	return true;
 }
 
+void MovieRecord::registerGraphics() {
+	_graphic.registerGraphics();
+}
+
 void MovieRecord::onZChanged() {
 	_graphic.setScriptZ(getZ(), getContext());
 }
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index d0ab1a6a437..39f4a9342ac 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -108,6 +108,8 @@ public:
 	// The viewport that shows the background, once it has been loaded
 	void setBackground(UI::Viewport *background);
 
+	void registerGraphics() override;
+
 protected:
 	void readTable(int tableIndex) override;
 	void runOnce() override;
@@ -216,6 +218,7 @@ public:
 	virtual ~OverrideRecord();
 
 	void updateGraphics() override;
+	void registerGraphics() override;
 	void onSave() override { callFunction("OnSave"); }
 	void onDie() override { callFunction("OnDie"); }
 	bool hasMessagingName(const Common::String &name) override;
@@ -249,6 +252,7 @@ public:
 	OverlayRecord(SceneContext &context) : Record(context, "ND.Overlay") {}
 
 	void updateGraphics() override;
+	void registerGraphics() override;
 
 protected:
 	void readTable(int tableIndex) override;
@@ -281,6 +285,7 @@ public:
 	AnimOverlayRecord(SceneContext &context) : Record(context, "ND.AnimOvlAR") {}
 
 	void updateGraphics() override;
+	void registerGraphics() override;
 
 	void setPaused(bool isPaused) { _isPaused = isPaused; }
 
@@ -366,6 +371,7 @@ public:
 	TextRecord(SceneContext &context) : Record(context, "ND.TextAR") {}
 
 	void updateGraphics() override;
+	void registerGraphics() override;
 
 	// Shows the next letter of a text that isn't shown at once, along with the
 	// markup in front of it. Returns false when there is nothing left to show.
@@ -411,6 +417,7 @@ public:
 	MovieRecord(SceneContext &context) : Record(context, "ND.Movie") {}
 
 	void updateGraphics() override;
+	void registerGraphics() override;
 	bool isSkippable() const override;
 
 	void setPaused(bool isPaused) { _isPaused = isPaused; }
diff --git a/engines/nancy/script/scenecontext.cpp b/engines/nancy/script/scenecontext.cpp
index 880721d865e..c78b1e4797c 100644
--- a/engines/nancy/script/scenecontext.cpp
+++ b/engines/nancy/script/scenecontext.cpp
@@ -316,6 +316,16 @@ bool SceneContext::skipSpeech() {
 	return hasSkipped;
 }
 
+void SceneContext::registerGraphics() {
+	for (Record *record : _records) {
+		record->registerGraphics();
+	}
+
+	for (Record *record : _newRecords) {
+		record->registerGraphics();
+	}
+}
+
 void SceneContext::end() {
 	for (Record *record : _records) {
 		record->onDie();
diff --git a/engines/nancy/script/scenecontext.h b/engines/nancy/script/scenecontext.h
index 973c6260d43..ab06bc9d09c 100644
--- a/engines/nancy/script/scenecontext.h
+++ b/engines/nancy/script/scenecontext.h
@@ -78,6 +78,9 @@ public:
 	// The scene is being deleted
 	bool isEnding() const { return _isEnding; }
 
+	// Puts what the records draw back on the screen
+	void registerGraphics();
+
 	// The Ref image of that name, which the records of the scene share. Places
 	// outside of it take the nearest pixel.
 	const RefImage *loadRef(const Common::String &name);
diff --git a/engines/nancy/script/xsheet.cpp b/engines/nancy/script/xsheet.cpp
index 0cad87f13f5..b8bc16b3345 100644
--- a/engines/nancy/script/xsheet.cpp
+++ b/engines/nancy/script/xsheet.cpp
@@ -74,6 +74,12 @@ bool XSheet::load(const Common::String &name) {
 	return true;
 }
 
+void XSheet::registerGraphics() {
+	for (Tree *tree : _trees) {
+		tree->graphic.registerGraphics();
+	}
+}
+
 void XSheet::clear() {
 	for (Tree *tree : _trees) {
 		delete tree;
@@ -292,6 +298,10 @@ void XsheetRecord::onZChanged() {
 // A restart doesn't hide the XSheet until the record runs again: the
 // conversation fidgets restart theirs in the middle of a frame, which made the
 // character blink every time
+void XsheetRecord::registerGraphics() {
+	_xsheet.registerGraphics();
+}
+
 void XsheetRecord::updateGraphics() {
 	_hasShown |= hasStarted();
 	_xsheet.setVisible(isActive() && _hasShown);
diff --git a/engines/nancy/script/xsheet.h b/engines/nancy/script/xsheet.h
index 9392d567afe..1a6727d2553 100644
--- a/engines/nancy/script/xsheet.h
+++ b/engines/nancy/script/xsheet.h
@@ -43,6 +43,7 @@ public:
 	// Shows the first frame
 	bool load(const Common::String &name);
 	void clear();
+	void registerGraphics();
 
 	bool isLoaded() const { return !_trees.empty(); }
 	const Common::String &getName() const { return _name; }
@@ -98,6 +99,7 @@ public:
 	XsheetRecord(SceneContext &context) : Record(context, "ND.XsheetAR") {}
 
 	void updateGraphics() override;
+	void registerGraphics() override;
 
 	// Enhancement: the character goes to the end of what it says along with
 	// the voice
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 2c0576962b7..2a331d666f4 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -1361,6 +1361,16 @@ void Scene::registerGraphics() {
 	_frame.registerGraphics();
 	_viewport.registerGraphics();
 
+	// The scenes of the streams, and from Nancy19 on the scripts of the main
+	// scene, have their own graphics
+	_streams.registerGraphics();
+
+#ifdef ENABLE_NANCY_V4
+	if (_scriptScene) {
+		_scriptScene->registerGraphics();
+	}
+#endif
+
 	// Pre-Nancy 10: inventory box is always-on-screen.
 	// Nancy 10+: a separate popup widget driven by UIIV (initially hidden).
 	// Nancy 16+: all of the UI is made of NDUI panels.
diff --git a/engines/nancy/state/scenestream.cpp b/engines/nancy/state/scenestream.cpp
index c75a4353db6..689d9cc33b2 100644
--- a/engines/nancy/state/scenestream.cpp
+++ b/engines/nancy/state/scenestream.cpp
@@ -296,6 +296,18 @@ bool SceneStream::loadScene() {
 	return true;
 }
 
+void SceneStream::registerGraphics() {
+	if (_background) {
+		_background->registerGraphics();
+	}
+
+#ifdef ENABLE_NANCY_V4
+	if (_scriptScene) {
+		_scriptScene->registerGraphics();
+	}
+#endif
+}
+
 void SceneStream::endScene() {
 #ifdef ENABLE_NANCY_V4
 	if (_scriptScene) {
@@ -478,6 +490,14 @@ void SceneStreamManager::begin(const Common::String &name, const Common::String
 	}
 }
 
+void SceneStreamManager::registerGraphics() {
+	for (SceneStream *stream : _streams) {
+		if (stream) {
+			stream->registerGraphics();
+		}
+	}
+}
+
 void SceneStreamManager::loadNow(const Common::String &name) {
 	SceneStream *stream = find(name);
 	if (!stream) {
diff --git a/engines/nancy/state/scenestream.h b/engines/nancy/state/scenestream.h
index 9d71ae9251e..dae94afb975 100644
--- a/engines/nancy/state/scenestream.h
+++ b/engines/nancy/state/scenestream.h
@@ -109,6 +109,9 @@ public:
 	// Nancy20: lets the records of the scene know that it is being left
 	void endScene();
 
+	// Puts the background and what the records draw back on the screen
+	void registerGraphics();
+
 	// Loads the scene the stream was asked to go to, without running it.
 	// Returns whether there was one, and it could be loaded.
 	bool loadNextScene();
@@ -182,6 +185,8 @@ public:
 	// instead of with the next frame
 	void loadNow(const Common::String &name);
 
+	void registerGraphics();
+
 	void changeScene(const Common::String &name, const SceneChangeDescription &sceneDescription);
 	void changeScene(const Common::String &name, const Common::String &sceneName, uint16 frameID);
 	Common::String getSceneName(const Common::String &name) const;


Commit: bc7f39a110c41fd489639784a222a06cfcabf7f7
    https://github.com/scummvm/scummvm/commit/bc7f39a110c41fd489639784a222a06cfcabf7f7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:07+02:00

Commit Message:
NANCY: Show the state of movie records in list_records

Movie records now also list their frame, whether they are playing or
paused, and whether their graphic is on screen, visible, and where.

Changed paths:
    engines/nancy/console.cpp
    engines/nancy/graphics.cpp
    engines/nancy/graphics.h
    engines/nancy/script/record.h
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h


diff --git a/engines/nancy/console.cpp b/engines/nancy/console.cpp
index 17bb8d482d9..97c78232bf1 100644
--- a/engines/nancy/console.cpp
+++ b/engines/nancy/console.cpp
@@ -790,6 +790,7 @@ bool NancyConsole::Cmd_listRecords(int argc, const char **argv) {
 			if (showsFields) {
 				Common::Array<Common::String> fields;
 				record->describeFields(fields);
+				record->describeState(fields);
 				for (const Common::String &field : fields) {
 					debugPrintf("      %s\n", field.c_str());
 				}
diff --git a/engines/nancy/graphics.cpp b/engines/nancy/graphics.cpp
index 2c732df91d6..c9febc1a5ac 100644
--- a/engines/nancy/graphics.cpp
+++ b/engines/nancy/graphics.cpp
@@ -568,6 +568,16 @@ void GraphicsManager::removeObject(RenderObject *object) {
 	}
 }
 
+bool GraphicsManager::hasObject(const RenderObject *object) const {
+	for (const RenderObject *r : _objects) {
+		if (r == object) {
+			return true;
+		}
+	}
+
+	return false;
+}
+
 void GraphicsManager::clearObjects() {
 	_objects.clear();
 }
diff --git a/engines/nancy/graphics.h b/engines/nancy/graphics.h
index 80326019d24..2edc7203454 100644
--- a/engines/nancy/graphics.h
+++ b/engines/nancy/graphics.h
@@ -81,6 +81,7 @@ public:
 
 	void addObject(RenderObject *object);
 	void removeObject(RenderObject *object);
+	bool hasObject(const RenderObject *object) const;
 	// Move an already-added object to its new place in the draw order
 	void reorderObject(RenderObject *object);
 	void clearObjects();
diff --git a/engines/nancy/script/record.h b/engines/nancy/script/record.h
index e8b8c107a3b..023a80af3f9 100644
--- a/engines/nancy/script/record.h
+++ b/engines/nancy/script/record.h
@@ -186,6 +186,9 @@ public:
 	// For the debugger: what the scripts gave the record, as "name = value"
 	void describeFields(Common::Array<Common::String> &lines);
 
+	// For the console: what the kind of record is up to, beyond its fields
+	virtual void describeState(Common::Array<Common::String> &lines) const {}
+
 protected:
 	lua_State *getLua() const;
 
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 680d76d30ea..b84e8fb7e15 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -2030,6 +2030,20 @@ void MovieRecord::updateGraphics() {
 	_graphic.setVisible(isActive() && _isVisible && !isSeeThrough());
 }
 
+void MovieRecord::describeState(Common::Array<Common::String> &lines) const {
+	lines.push_back(Common::String::format("[movie] frame %d of %d..%d, %s%s, played %d of %d",
+		_player.getCurrentFrame(), _firstFrame, _lastFrame,
+		_player.isRangePlaying() ? "playing" : "stopped", _isPaused ? ", paused" : "",
+		_numPlayed, _numLoops));
+
+	const Common::Rect position = _graphic.getScreenPosition();
+	lines.push_back(Common::String::format("[graphic] %s, %s, z %u, at (%d, %d, %d, %d), surface %dx%d%s",
+		g_nancy->_graphics->hasObject(&_graphic) ? "registered" : "NOT registered",
+		_graphic.isVisible() ? "visible" : "hidden", _graphic.getZOrder(),
+		position.left, position.top, position.right, position.bottom,
+		_graphic._drawSurface.w, _graphic._drawSurface.h, isSeeThrough() ? ", see-through" : ""));
+}
+
 // movie:Play() and movie:Pause()
 static int moviePlay(lua_State *L) {
 	MovieRecord *record = dynamic_cast<MovieRecord *>(checkRecord(L, 1));
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 39f4a9342ac..e06ff91da74 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -418,6 +418,7 @@ public:
 
 	void updateGraphics() override;
 	void registerGraphics() override;
+	void describeState(Common::Array<Common::String> &lines) const override;
 	bool isSkippable() const override;
 
 	void setPaused(bool isPaused) { _isPaused = isPaused; }


Commit: 2595194934dccda4d3cb4e00814de78f0d50c346
    https://github.com/scummvm/scummvm/commit/2595194934dccda4d3cb4e00814de78f0d50c346
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:13+02:00

Commit Message:
NANCY: NANCY24: Don't scale a game drawn at the screen's resolution

Nancy16 to Nancy23 draw the game at a lower resolution and scale it up
to 800x600. Nancy24 is drawn at 800x600 itself, so the scaling step is
skipped when both sizes are the same.

Changed paths:
    engines/nancy/graphics.cpp


diff --git a/engines/nancy/graphics.cpp b/engines/nancy/graphics.cpp
index c9febc1a5ac..0b7992f8943 100644
--- a/engines/nancy/graphics.cpp
+++ b/engines/nancy/graphics.cpp
@@ -128,11 +128,11 @@ void GraphicsManager::init() {
 	_screen.clear();
 
 	// Nancy16 runs at a higher resolution than the game was made for. The
-	// viewport's chunk holds the resolution the game gets drawn at.
-	if (g_nancy->getGameType() >= kGameTypeNancy16) {
-		auto *viewportData = GetEngineData(VIEW);
-		assert(viewportData);
-
+	// viewport's chunk holds the resolution the game gets drawn at, which is
+	// the one of the screen from Nancy24 on.
+	const VIEW *viewportData = GetEngineData(VIEW);
+	if (g_nancy->getGameType() >= kGameTypeNancy16 && viewportData &&
+			(viewportData->bounds.width() != _screen.w || viewportData->bounds.height() != _screen.h)) {
 		_gameSurface.create(viewportData->bounds.width(), viewportData->bounds.height(), getScreenPixelFormat());
 		_gameSurface.setTransparentColor(getTransColor());
 		_gameSurface.clear();


Commit: 43ba2e4c85f0afede2a789d6d9ae1558c2b4597d
    https://github.com/scummvm/scummvm/commit/43ba2e4c85f0afede2a789d6d9ae1558c2b4597d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:15+02:00

Commit Message:
NANCY: NANCY24: Stretch backgrounds smaller than the viewport

The cinematic scenes, and the one shown before Nancy's room, use a
640x385 background in an 800x480 viewport. It was read past its end,
which drew garbage or crashed. It is now stretched over the viewport,
while what the scene shows in it keeps its own coordinates.

Changed paths:
    engines/nancy/ui/viewport.cpp


diff --git a/engines/nancy/ui/viewport.cpp b/engines/nancy/ui/viewport.cpp
index 7812d28ad17..d3ce71dd9ad 100644
--- a/engines/nancy/ui/viewport.cpp
+++ b/engines/nancy/ui/viewport.cpp
@@ -298,10 +298,14 @@ void Viewport::setPreviousFrame() {
 }
 
 void Viewport::setVerticalScroll(uint scroll) {
-	assert((int)scroll + _drawSurface.h <= _fullFrame.h);
-
+	// A background smaller than the viewport gets stretched over it. Nancy24
+	// keeps one of the size of the earlier games, toast_BG, for the scenes
+	// that only play movies.
 	Common::Rect sourceBounds = _screenPosition;
 	sourceBounds.moveTo(0, scroll);
+	sourceBounds.clip(Common::Rect(_fullFrame.w, _fullFrame.h));
+	assert(!sourceBounds.isEmpty() && sourceBounds.top == (int)scroll);
+
 	_drawSurface.create(_fullFrame, sourceBounds);
 	_needsRedraw = true;
 
@@ -337,17 +341,19 @@ uint16 Viewport::getMaxScroll() const {
 }
 
 // Convert a viewport-space rectangle to screen coordinates
+// A background smaller than the viewport is stretched over it, but what goes
+// in the viewport is placed in its own pixels all the same
 Common::Rect Viewport::convertViewportToScreen(const Common::Rect &viewportRect) const {
-	Common::Rect ret = convertToScreen(viewportRect);
-	ret.translate(0, -getCurVerticalScroll());
+	Common::Rect ret = viewportRect;
+	ret.translate(_screenPosition.left, _screenPosition.top - getCurVerticalScroll());
 	ret.clip(_screenPosition);
 	return ret;
 }
 
 // Convert a screen-space coordinate to viewport coordinates
 Common::Rect Viewport::convertScreenToViewport(const Common::Rect &viewportRect) const {
-	Common::Rect ret = convertToLocal(viewportRect);
-	ret.translate(0, getCurVerticalScroll());
+	Common::Rect ret = viewportRect;
+	ret.translate(-_screenPosition.left, getCurVerticalScroll() - _screenPosition.top);
 	return ret;
 }
 


Commit: 5de23618f3f2bb615a671a9236312f967cdadc27
    https://github.com/scummvm/scummvm/commit/5de23618f3f2bb615a671a9236312f967cdadc27
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:16+02:00

Commit Message:
NANCY: NANCY23: Make a missing font file a debug message

Nancy24 asks for Digital Display2.ttf, which doesn't come with it. The
substitute font is used then, as for the Windows fonts

Changed paths:
    engines/nancy/font.cpp


diff --git a/engines/nancy/font.cpp b/engines/nancy/font.cpp
index 6fea5ec50e4..e8cfb607a91 100644
--- a/engines/nancy/font.cpp
+++ b/engines/nancy/font.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "common/debug.h"
 #include "common/file.h"
 
 #include "graphics/fontman.h"
@@ -215,7 +216,8 @@ void Font::setSystemFont(const Common::String &name, const Common::String &faceN
 			return;
 		}
 
-		warning("Could not load font file %s", fileName.toString().c_str());
+		// Nancy24 asks for Digital Display2.ttf, which doesn't come with it
+		debugC(1, kDebugEngine, "Could not load font file %s", fileName.toString().c_str());
 	}
 
 	// None of the Windows fonts the game asks for (Tahoma, Arial, Lucida Handwriting)


Commit: 712437d6e56367b84507f731f66f29cb2b3a3181
    https://github.com/scummvm/scummvm/commit/712437d6e56367b84507f731f66f29cb2b3a3181
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:17+02:00

Commit Message:
NANCY: NANCY19: Treat a value left out of Save:Data as nil

The sound system of Nancy24 calls Save:Data without a value, which the
original stores as nothing, instead of stopping the script.

Changed paths:
    engines/nancy/script/gameapi.cpp


diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index 89c5fd38d7f..a0a0334d732 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -860,10 +860,11 @@ static void readSavedValue(lua_State *L, const Common::Array<byte> &in, uint &po
 	}
 }
 
-// Save:Data(name, value)
+// Save:Data(name, value). A value left out counts as nil: Nancy24's
+// SoundSystem_SC forgets to pass one.
 static int saveData(lua_State *L) {
 	const char *name = luaL_checkstring(L, 2);
-	luaL_checkany(L, 3);
+	lua_settop(L, 3);
 
 	Common::Array<byte> packed;
 	if (!writeSavedValue(L, 3, packed, 0)) {


Commit: 41b39d541df10875a5a2feee3dbe0f3c213911b8
    https://github.com/scummvm/scummvm/commit/41b39d541df10875a5a2feee3dbe0f3c213911b8
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:19+02:00

Commit Message:
NANCY: NANCY19: Show no text for an autotext key that isn't there

A number display's texts before and after the number are autotext
keys. Nancy24's coin counter names one that doesn't exist, which the
original leaves empty; the key pushed the coin count out of view.

Changed paths:
    engines/nancy/script/uiapi.cpp


diff --git a/engines/nancy/script/uiapi.cpp b/engines/nancy/script/uiapi.cpp
index 3578ddd7272..80f7866f4e3 100644
--- a/engines/nancy/script/uiapi.cpp
+++ b/engines/nancy/script/uiapi.cpp
@@ -454,9 +454,11 @@ static UI::NDUI::Control *addControl(lua_State *L, int32 type, Common::MemoryWri
 	return control;
 }
 
-// The text kept under a key, or the key itself when there is none
+// The text kept under a key. A key that isn't there gives no text, as the
+// engine doesn't answer the control's request for it: Nancy24's coin counter
+// names "PennyCounter", which isn't in the autotext.
 static Common::String resolveText(const Common::String &key) {
-	Common::String text = key;
+	Common::String text;
 	findText(key, text);
 	return text;
 }


Commit: 7335451569f0890e6af19d8f9960784b4d80eadc
    https://github.com/scummvm/scummvm/commit/7335451569f0890e6af19d8f9960784b4d80eadc
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:20+02:00

Commit Message:
NANCY: NANCY19: Prefer a record's own functions for player input

A function a script gives a record for OnMouseMove, ChangeCursor or a
click or key now goes before the one every record has. The buttons of
Nancy24's phone call their OnMouseMove without a point, which failed,
so they never changed their picture and the call button stayed hidden.

Changed paths:
    engines/nancy/script/record.cpp


diff --git a/engines/nancy/script/record.cpp b/engines/nancy/script/record.cpp
index 715cad3a145..def823a4554 100644
--- a/engines/nancy/script/record.cpp
+++ b/engines/nancy/script/record.cpp
@@ -287,6 +287,28 @@ bool Record::callFunction(const char *name, int numArgs, int numResults) {
 	return LuaState::call(L, numArgs + 1, numResults, what.c_str());
 }
 
+// The functions scripts can give a record for what the player does
+static const char *const kEventFunctionNames[kNumRecordEvents] = {
+	"OnLeftClick", "OnRightClick", "OnLeftDown", "OnLeftUp", "OnRightDown", "OnRightUp",
+	"OnKeyDown", "OnKey", "OnKeyUp"
+};
+
+// The functions for what the player does, which scripts can give a record as
+// well. The Nancy23 and Nancy24 exes only have the ones of the scripts.
+static bool isEventFunctionName(const Common::String &key) {
+	if (key == "OnMouseMove" || key == "ChangeCursor") {
+		return true;
+	}
+
+	for (const char *name : kEventFunctionNames) {
+		if (key == name) {
+			return true;
+		}
+	}
+
+	return false;
+}
+
 int Record::getScriptField() {
 	lua_State *L = getLua();
 	const Common::String key = luaL_checkstring(L, 2);
@@ -308,6 +330,17 @@ int Record::getScriptField() {
 		return 1;
 	}
 
+	// A function the script stored under this name is used instead of the
+	// built-in one, e.g. Nancy24's buttons call OnMouseMove without a point
+	if (isEventFunctionName(key)) {
+		pushStoredValue(key.c_str());
+		if (lua_isfunction(L, -1)) {
+			return 1;
+		}
+
+		lua_pop(L, 1);
+	}
+
 	// The functions every record has
 	indexFunctions(L);
 	if (!lua_isnil(L, -1)) {
@@ -358,12 +391,6 @@ int Record::setScriptField() {
 	return 0;
 }
 
-// The functions scripts can give a record for what the player does
-static const char *const kEventFunctionNames[kNumRecordEvents] = {
-	"OnLeftClick", "OnRightClick", "OnLeftDown", "OnLeftUp", "OnRightDown", "OnRightUp",
-	"OnKeyDown", "OnKey", "OnKeyUp"
-};
-
 void Record::sendMouseMove(const ScriptPoint &point, bool inViewport) {
 	if (!isActive()) {
 		return;


Commit: 298d7c0f95f27f6e7db9b6df9b286fa94ea159ec
    https://github.com/scummvm/scummvm/commit/298d7c0f95f27f6e7db9b6df9b286fa94ea159ec
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:21+02:00

Commit Message:
NANCY: NANCY19: Add an image cache for the pictures of overlays

Every overlay decoded its picture anew, though many use the same one,
so the screens of Nancy24's phone took two seconds to come up. A cache
in the resource manager now keeps the last 16 pictures decoded, and
the overlays draw from them.

Changed paths:
    engines/nancy/resource/resource.cpp
    engines/nancy/resource/resource.h
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h


diff --git a/engines/nancy/resource/resource.cpp b/engines/nancy/resource/resource.cpp
index 40c36c68a1a..4bb0d5021b6 100644
--- a/engines/nancy/resource/resource.cpp
+++ b/engines/nancy/resource/resource.cpp
@@ -249,6 +249,43 @@ bool ResourceManager::loadImage(const Common::Path &name, Graphics::ManagedSurfa
 	return true;
 }
 
+// How many pictures the image cache keeps decoded
+static const uint kImageCacheSize = 16;
+
+Common::SharedPtr<Graphics::ManagedSurface> ResourceManager::loadCachedImage(const Common::String &name, const Common::String &treeName) {
+	const Common::String key = treeName + "/" + name;
+	++_imageCacheUses;
+
+	ImageCache::iterator found = _imageCache.find(key);
+	if (found != _imageCache.end()) {
+		found->_value.lastUse = _imageCacheUses;
+		return found->_value.image;
+	}
+
+	Common::SharedPtr<Graphics::ManagedSurface> image(new Graphics::ManagedSurface());
+	if (!loadImage(Common::Path(name), *image, treeName)) {
+		return Common::SharedPtr<Graphics::ManagedSurface>();
+	}
+
+	// The picture used longest ago leaves the cache. Whoever still uses it
+	// keeps it until they are done with it.
+	if (_imageCache.size() >= kImageCacheSize) {
+		ImageCache::iterator oldest = _imageCache.begin();
+		for (ImageCache::iterator it = _imageCache.begin(); it != _imageCache.end(); ++it) {
+			if (it->_value.lastUse < oldest->_value.lastUse) {
+				oldest = it;
+			}
+		}
+
+		_imageCache.erase(oldest);
+	}
+
+	CachedImage &cached = _imageCache[key];
+	cached.image = image;
+	cached.lastUse = _imageCacheUses;
+	return image;
+}
+
 IFF *ResourceManager::loadIFF(const Common::Path &name) {
 	// First, try to load external .cif
 	Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(name.append(".cif"));
diff --git a/engines/nancy/resource/resource.h b/engines/nancy/resource/resource.h
index dac7961438b..1ab762e1f78 100644
--- a/engines/nancy/resource/resource.h
+++ b/engines/nancy/resource/resource.h
@@ -22,6 +22,10 @@
 #ifndef NANCY_RESOURCE_RESOURCE_H
 #define NANCY_RESOURCE_RESOURCE_H
 
+#include "common/hash-str.h"
+#include "common/hashmap.h"
+#include "common/ptr.h"
+
 #include "engines/nancy/resource/cif.h"
 
 namespace Graphics {
@@ -43,6 +47,13 @@ public:
 	// This is accessed via the outSrc/outDest parameters.
 	bool loadImage(const Common::Path &name, Graphics::ManagedSurface &surf, const Common::String &treeName = Common::String(), Common::Rect *outSrc = nullptr, Common::Rect *outDest = nullptr);
 
+	// Loads a picture through the image cache. Nancy19+ scripts make many records
+	// of the same pictures, and Nancy24 makes a new scene for every screen of
+	// the phone, so decoding a picture each time was slow. The cache keeps the
+	// pictures it loaded last decoded, and hands the same one to everyone who
+	// asks for it. Null when there is no such picture.
+	Common::SharedPtr<Graphics::ManagedSurface> loadCachedImage(const Common::String &name, const Common::String &treeName);
+
 	// Loads a single IFF file. These can either be inside standalone .cif files, or embedded inside a ciftree
 	IFF *loadIFF(const Common::Path &name);
 
@@ -79,7 +90,18 @@ public:
 	bool exportCifTree(const Common::String &treeName, const Common::Array<Common::Path> &names);
 
 private:
+	// An entry of the image cache. When the cache is full, the picture used
+	// longest ago makes room.
+	struct CachedImage {
+		Common::SharedPtr<Graphics::ManagedSurface> image;
+		uint32 lastUse = 0;
+	};
+
+	typedef Common::HashMap<Common::String, CachedImage, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ImageCache;
+
 	Common::Array<Common::String> _cifTreeNames;
+	ImageCache _imageCache;		// by tree and name
+	uint32 _imageCacheUses = 0;	// counts the lookups, for lastUse
 };
 
 } // End of namespace Nancy
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index b84e8fb7e15..ebaca97e412 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -1020,6 +1020,24 @@ bool loadTreeImage(const Common::String &name, const Common::String &treeName, G
 #endif
 }
 
+// Overlays get their pictures from the image cache of the resource manager,
+// and hold on to the cached picture while they use it. Saved pictures aren't
+// cached: every record has its own.
+static bool loadCachedImage(const Common::String &name, const Common::String &treeName, Common::SharedPtr<Graphics::ManagedSurface> &cached, Graphics::ManagedSurface &image) {
+	if (treeName.equalsIgnoreCase(kPictureTreeName)) {
+		return loadTreeImage(name, treeName, image);
+	}
+
+	cached = g_nancy->_resource->loadCachedImage(name, treeName);
+	if (!cached) {
+		return false;
+	}
+
+	// The record draws from the cached picture, without a copy of its own
+	image.create(*cached, Common::Rect(cached->w, cached->h));
+	return true;
+}
+
 void OverlayRecord::readTable(int tableIndex) {
 	lua_State *L = getLua();
 
@@ -1032,7 +1050,7 @@ void OverlayRecord::readTable(int tableIndex) {
 	Common::String treeName;
 	readField(L, tableIndex, "tree", treeName);
 
-	if (!loadTreeImage(imageName, treeName, _image)) {
+	if (!loadCachedImage(imageName, treeName, _cachedImage, _image)) {
 		luaL_error(L, "Could not load overlay %s", imageName.c_str());
 	}
 
@@ -1239,7 +1257,7 @@ void AnimOverlayRecord::readTable(int tableIndex) {
 	Common::String treeName;
 	readField(L, tableIndex, "tree", treeName);
 
-	if (!loadTreeImage(imageName, treeName, _image)) {
+	if (!loadCachedImage(imageName, treeName, _cachedImage, _image)) {
 		luaL_error(L, "Could not load overlay %s", imageName.c_str());
 	}
 
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index e06ff91da74..44c9b6f0754 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -23,6 +23,7 @@
 #define NANCY_SCRIPT_RECORDS_H
 
 #include "common/array.h"
+#include "common/ptr.h"
 #include "common/rect.h"
 
 #include "engines/nancy/commontypes.h"
@@ -266,7 +267,8 @@ protected:
 private:
 	void applyRects();
 
-	Graphics::ManagedSurface _image;
+	Common::SharedPtr<Graphics::ManagedSurface> _cachedImage;	// kept while the record uses it
+	Graphics::ManagedSurface _image;	// the cached picture, or a saved one
 	ScriptRect _source;
 	ScriptRect _dest;
 	uint32 _modColor = 0xFFFFFFFF;	// what the colors of the picture get multiplied with
@@ -308,7 +310,8 @@ private:
 	void applyFrame();
 	void beginLoop();
 
-	Graphics::ManagedSurface _image;
+	Common::SharedPtr<Graphics::ManagedSurface> _cachedImage;	// kept while the record uses it
+	Graphics::ManagedSurface _image;	// the cached picture, or a saved one
 	Common::Array<ScriptRect> _sources;
 	ScriptRect _dest;
 	uint32 _modColor = 0xFFFFFFFF;


Commit: 8d0ba9b298d90eaf87f2436307548e848de1cfc8
    https://github.com/scummvm/scummvm/commit/8d0ba9b298d90eaf87f2436307548e848de1cfc8
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:23+02:00

Commit Message:
NANCY: NANCY19: Don't run paused records at all

A paused record now skips its frame entirely, as in the original. The
fidgets of Nancy24 pause their movies and set the frames themselves;
the movies went back to their first frame or ended, and flashed.

Changed paths:
    engines/nancy/script/record.cpp
    engines/nancy/script/record.h
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h


diff --git a/engines/nancy/script/record.cpp b/engines/nancy/script/record.cpp
index def823a4554..32e5534f239 100644
--- a/engines/nancy/script/record.cpp
+++ b/engines/nancy/script/record.cpp
@@ -166,7 +166,7 @@ void Record::update(double sceneTime, double elapsedTime) {
 
 	_wasActive = _isActive;
 
-	if (!_isActive) {
+	if (!_isActive || isPaused()) {
 		return;
 	}
 
diff --git a/engines/nancy/script/record.h b/engines/nancy/script/record.h
index 023a80af3f9..b5f97ea70f4 100644
--- a/engines/nancy/script/record.h
+++ b/engines/nancy/script/record.h
@@ -206,6 +206,9 @@ protected:
 	// Whether the record can start over, after getting itself ready for it
 	virtual bool prepareReset() { return false; }
 
+	// A paused record doesn't run at all, not even once, until it goes on
+	virtual bool isPaused() const { return false; }
+
 	// Whether the functions of the scripts take the place of what the record does
 	// by itself: Run, Render, and everything the player does
 	virtual bool isScripted() const { return false; }
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index ebaca97e412..af496edfedf 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -1999,7 +1999,7 @@ void MovieRecord::run(double sceneTime, double elapsedTime) {
 
 	_skipFrame = -1;
 
-	if (!_isPaused && _player.update()) {
+	if (_player.update()) {
 		drawFrame();
 	}
 
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 44c9b6f0754..82bb77fa981 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -432,6 +432,7 @@ protected:
 	void run(double sceneTime, double elapsedTime) override;
 	void onZChanged() override;
 	bool prepareReset() override;
+	bool isPaused() const override { return _isPaused; }
 	bool hasTransform() const override { return true; }
 	void onTransformChanged() override { applyPosition(); }
 	bool getField(const Common::String &key) override;


Commit: c585dbd9e52d716b26258eb50d3455949714dcee
    https://github.com/scummvm/scummvm/commit/c585dbd9e52d716b26258eb50d3455949714dcee
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:24+02:00

Commit Message:
NANCY: NANCY24: Add Clean to records, and AR:GetActualField

ar:Clean() clears what scripts stored in a record, its active
function too. AR:GetActualField(ar, name) gives what a script stored
under a name, e.g. the active function of a record rather than whether
it is active.

Changed paths:
    engines/nancy/script/record.cpp
    engines/nancy/script/record.h


diff --git a/engines/nancy/script/record.cpp b/engines/nancy/script/record.cpp
index 32e5534f239..9f4556a6c3e 100644
--- a/engines/nancy/script/record.cpp
+++ b/engines/nancy/script/record.cpp
@@ -80,6 +80,15 @@ void Record::storeValue(const char *name) {
 	lua_pop(L, 1);
 }
 
+void Record::clean() {
+	lua_State *L = getLua();
+	lua_pushlightuserdata(L, this);
+	lua_pushnil(L);
+	lua_rawset(L, LUA_REGISTRYINDEX);
+
+	_hasActiveFunction = false;
+}
+
 void Record::create(int tableIndex) {
 	lua_State *L = getLua();
 
@@ -637,6 +646,12 @@ static int recordRestart(lua_State *L) {
 	return 0;
 }
 
+// ar:Clean(), Nancy24
+static int recordClean(lua_State *L) {
+	checkRecord(L, 1)->clean();
+	return 0;
+}
+
 // ar:Render()
 static int recordRender(lua_State *L) {
 	checkRecord(L, 1)->render();
@@ -730,6 +745,7 @@ static const luaL_Reg kRecordFunctions[] = {
 	{ "__eq", recordEquals },
 	{ "Reset", recordReset },
 	{ "Restart", recordRestart },
+	{ "Clean", recordClean },
 	{ "Run", recordRun },
 	{ "Render", recordRender },
 	{ "OnMouseMove", recordOnMouseMove },
@@ -769,6 +785,13 @@ static int createRecord(lua_State *L) {
 	return 1;
 }
 
+// AR:GetActualField(ar, name), Nancy24: what a script stored in the record,
+// such as its "active" function rather than whether it is active
+static int recordGetActualField(lua_State *L) {
+	checkRecord(L, 2)->pushStoredValue(luaL_checkstring(L, 3));
+	return 1;
+}
+
 void registerRecordAPI(lua_State *L) {
 	for (uint i = 0; i < kNumRecordKinds; ++i) {
 		const char *typeName = getRecordTypeName((RecordKind)i);
@@ -793,6 +816,7 @@ void registerRecordAPI(lua_State *L) {
 
 	static const luaL_Reg kFactoryFunctions[] = {
 		{ "__index", indexFunctions },
+		{ "GetActualField", recordGetActualField },
 		{ nullptr, nullptr }
 	};
 
diff --git a/engines/nancy/script/record.h b/engines/nancy/script/record.h
index b5f97ea70f4..18352c3d7dc 100644
--- a/engines/nancy/script/record.h
+++ b/engines/nancy/script/record.h
@@ -136,6 +136,14 @@ public:
 	int getScriptField();
 	int setScriptField();
 
+	// What scripts stored in the record under a name, which the fields of its
+	// kind don't go through. AR:GetActualField (Nancy24) reads it.
+	void pushStoredValue(const char *name);
+
+	// Nancy24: clears everything scripts stored in the record, the function
+	// that says whether it is active as well
+	void clean();
+
 	// Calls a function a script stored in the record, with the record itself in
 	// front of the arguments on the stack. Returns false when there is no such
 	// function, or when it failed; no results are left then.
@@ -226,8 +234,6 @@ protected:
 	virtual bool getField(const Common::String &key) { return false; }
 	virtual bool setField(const Common::String &key) { return false; }
 
-	// What scripts stored in the record
-	void pushStoredValue(const char *name);
 	void storeValue(const char *name);	// pops the value
 
 private:


Commit: 9e4f7682aa8a446cd413e5036d9c61d982da74b6
    https://github.com/scummvm/scummvm/commit/9e4f7682aa8a446cd413e5036d9c61d982da74b6
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:24+02:00

Commit Message:
NANCY: NANCY24: Let scripts set the paused field of Movie records

Nancy24 has no Play and Pause methods anymore; scripts pause a movie
with movie.paused = true, e.g. the fidgets of RandomMovie_SC.

Changed paths:
    engines/nancy/script/records.cpp


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index af496edfedf..5d849718ae7 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -2146,6 +2146,9 @@ bool MovieRecord::setField(const Common::String &key) {
 		_player.setVolume((byte)CLIP<int>((int)(luaL_checknumber(L, 3) * 100.0 + 0.5), 0, 100));
 	} else if (key == "pauseOnLastFrame") {
 		_pausesOnLastFrame = lua_toboolean(L, 3) != 0;
+	} else if (key == "paused") {
+		// Nancy24 has no Play and Pause anymore
+		_isPaused = lua_toboolean(L, 3) != 0;
 	} else if (key == "visible") {
 		_isVisible = lua_toboolean(L, 3) != 0;
 	} else if (key == "frame") {


Commit: 6f132c8e104d830307eefca102dfa81444a9265a
    https://github.com/scummvm/scummvm/commit/6f132c8e104d830307eefca102dfa81444a9265a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:25+02:00

Commit Message:
NANCY: NANCY24: Add timeMultiplier and RemoveAllStages to Transformers

The multiplier speeds up the blends of a Transformer, e.g. for the
crossbar puzzle's fast button. RemoveAllStages lets a Transformer be
used again.

Changed paths:
    engines/nancy/script/transformer.cpp
    engines/nancy/script/transformer.h


diff --git a/engines/nancy/script/transformer.cpp b/engines/nancy/script/transformer.cpp
index d543dd1dbd4..00749f40370 100644
--- a/engines/nancy/script/transformer.cpp
+++ b/engines/nancy/script/transformer.cpp
@@ -37,6 +37,7 @@ TransformerRecord::TransformerRecord(SceneContext &context) :
 
 void TransformerRecord::readTable(int tableIndex) {
 	readField(getLua(), tableIndex, "sinLerp", _isSineLerp);
+	readField(getLua(), tableIndex, "timeMultiplier", _timeMultiplier);
 	_node->setZ(getLocalZ());
 }
 
@@ -201,7 +202,7 @@ void TransformerRecord::updateTransform() {
 void TransformerRecord::run(double sceneTime, double elapsedTime) {
 	bool hasChanged = false;
 	for (uint i = 0; i < _stages.size(); ++i) {
-		hasChanged |= advanceStage(_stages[i], elapsedTime);
+		hasChanged |= advanceStage(_stages[i], elapsedTime * _timeMultiplier);
 	}
 
 	if (hasChanged) {
@@ -265,6 +266,13 @@ int TransformerRecord::finishBlend(lua_State *L) {
 	return 0;
 }
 
+// transformer:RemoveAllStages(), Nancy24
+int TransformerRecord::removeAllStages(lua_State *L) {
+	_stages.clear();
+	updateTransform();
+	return 0;
+}
+
 // transformer:IsBlending(name)
 int TransformerRecord::isBlending(lua_State *L) {
 	lua_pushboolean(L, checkStage(L, 2).isBlending());
@@ -322,6 +330,10 @@ static int transformerAttach(lua_State *L) {
 	return checkTransformer(L)->attach(L);
 }
 
+static int transformerRemoveAllStages(lua_State *L) {
+	return checkTransformer(L)->removeAllStages(L);
+}
+
 static const luaL_Reg kTransformerFunctions[] = {
 	{ "Attach", transformerAttach },
 	{ "Blend", transformerBlend },
@@ -330,6 +342,7 @@ static const luaL_Reg kTransformerFunctions[] = {
 	{ "PushTranslation", transformerPushTranslation },
 	{ "PushRotation", transformerPushRotation },
 	{ "PushScale", transformerPushScale },
+	{ "RemoveAllStages", transformerRemoveAllStages },
 	{ nullptr, nullptr }
 };
 
@@ -342,6 +355,9 @@ bool TransformerRecord::getField(const Common::String &key) {
 	} else if (key == "blendedTransform") {
 		pushMatrix(L, _blendedTransform);
 		return true;
+	} else if (key == "timeMultiplier") {
+		lua_pushnumber(L, _timeMultiplier);
+		return true;
 	}
 
 	for (const luaL_Reg *function = kTransformerFunctions; function->name; ++function) {
@@ -377,6 +393,11 @@ bool TransformerRecord::setField(const Common::String &key) {
 		return true;
 	}
 
+	if (key == "timeMultiplier") {
+		_timeMultiplier = luaL_checknumber(L, 3);
+		return true;
+	}
+
 	if (key == "transform" || key == "blendedTransform") {
 		luaL_error(L, "You cannot set the transform or blendedTransform fields of a transformer AR directly");
 	}
diff --git a/engines/nancy/script/transformer.h b/engines/nancy/script/transformer.h
index 064f0ea049e..01be191e198 100644
--- a/engines/nancy/script/transformer.h
+++ b/engines/nancy/script/transformer.h
@@ -65,6 +65,7 @@ public:
 	int finishBlend(lua_State *L);
 	int isBlending(lua_State *L);
 	int attach(lua_State *L);
+	int removeAllStages(lua_State *L);
 
 protected:
 	void readTable(int tableIndex) override;
@@ -110,6 +111,7 @@ private:
 
 	Common::Array<Stage> _stages;
 	bool _isSineLerp = true;
+	double _timeMultiplier = 1.0;	// Nancy24: how much faster the blends go
 	ScriptMatrix _blendedTransform;	// where the stages are going
 	GraphNode *_node;
 };


Commit: 57492018359b2d1a53575a5736a786da39fea2db
    https://github.com/scummvm/scummvm/commit/57492018359b2d1a53575a5736a786da39fea2db
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:27+02:00

Commit Message:
NANCY: NANCY24: Add enableRotate to Summary records

Scripts turn off the turning at the sides of a node while something
plays, and can switch both that and the u-turn while the scene runs.

Changed paths:
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 5d849718ae7..2d09a9e0854 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -306,6 +306,7 @@ void SummaryRecord::readTable(int tableIndex) {
 	// whether the player can turn around
 	readField(L, tableIndex, "wrap", _wraps);
 	readField(L, tableIndex, "enableUturn", _hasUturn);
+	readField(L, tableIndex, "enableRotate", _canRotate);
 	readField(L, tableIndex, "facade", _isFacade);
 
 	// The background is behind everything else
@@ -424,9 +425,9 @@ SummaryRecord::Turn SummaryRecord::getTurnAt(const ScriptPoint &point, bool inVi
 	assert(boot);
 
 	const Common::Point place = point.toPoint();
-	if (boot->leftNodeHotspot.contains(place)) {
+	if (_canRotate && boot->leftNodeHotspot.contains(place)) {
 		return canTurn(kTurnLeft) ? kTurnLeft : kNoTurn;
-	} else if (boot->rightNodeHotspot.contains(place)) {
+	} else if (_canRotate && boot->rightNodeHotspot.contains(place)) {
 		return canTurn(kTurnRight) ? kTurnRight : kNoTurn;
 	} else if (boot->uturnNodeHotspot.contains(place)) {
 		return _hasUturn ? kTurnAround : kNoTurn;
@@ -519,7 +520,7 @@ void SummaryRecord::run(double sceneTime, double elapsedTime) {
 	_sceneTime = sceneTime;
 	updateTheme(sceneTime);
 
-	if (_numFrames <= 1 || _turn == kNoTurn) {
+	if (_numFrames <= 1 || _turn == kNoTurn || !_canRotate) {
 		return;
 	}
 
@@ -540,6 +541,25 @@ bool SummaryRecord::getField(const Common::String &key) {
 	if (key == "frame") {
 		lua_pushinteger(getLua(), _frame);
 		return true;
+	} else if (key == "enableRotate") {
+		lua_pushboolean(getLua(), _canRotate);
+		return true;
+	} else if (key == "enableUturn") {
+		lua_pushboolean(getLua(), _hasUturn);
+		return true;
+	}
+
+	return false;
+}
+
+// Nancy24 scripts stop the player from turning while something is going on
+bool SummaryRecord::setField(const Common::String &key) {
+	if (key == "enableRotate") {
+		_canRotate = lua_toboolean(getLua(), 3) != 0;
+		return true;
+	} else if (key == "enableUturn") {
+		_hasUturn = lua_toboolean(getLua(), 3) != 0;
+		return true;
 	}
 
 	return false;
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 82bb77fa981..32827383694 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -117,6 +117,7 @@ protected:
 	void run(double sceneTime, double elapsedTime) override;
 	bool hasTransform() const override { return true; }
 	bool getField(const Common::String &key) override;
+	bool setField(const Common::String &key) override;
 
 	void onMouseMove(const ScriptPoint &point, bool inViewport) override;
 	bool getCursor(const ScriptPoint &point, bool inViewport, uint &cursorType, bool &isHot) override;
@@ -152,6 +153,7 @@ private:
 
 	bool _wraps = true;
 	bool _hasUturn = true;
+	bool _canRotate = true;	// Nancy24: whether the sides turn the view
 	bool _isFacade = false;
 	RecordGraphic _facade;
 };


Commit: 3a6fd331c9f9a3e92af844598dcafa5f7fd0b1eb
    https://github.com/scummvm/scummvm/commit/3a6fd331c9f9a3e92af844598dcafa5f7fd0b1eb
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:27+02:00

Commit Message:
NANCY: NANCY24: Add Streams:GetFrame

It returns the frame of the scene of a stream, which the ambient
scripts use to play sounds for the direction the player looks in.

Changed paths:
    engines/nancy/script/gameapi.cpp
    engines/nancy/state/scenestream.cpp
    engines/nancy/state/scenestream.h


diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index a0a0334d732..dd25d4a19e2 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -1498,6 +1498,13 @@ static int streamsGetTime(lua_State *L) {
 	return 1;
 }
 
+// Streams:GetFrame(stream), Nancy24: the frame of the scene of the stream, or
+// -1 when there is none
+static int streamsGetFrame(lua_State *L) {
+	lua_pushinteger(L, NancySceneState.getStreams().getSceneFrame(luaL_checkstring(L, 2)));
+	return 1;
+}
+
 // Streams:GetStreams(withUI), Nancy21: the names of the running streams, the
 // main stream among them. The one of the UI is only in there when asked for.
 static int streamsGetStreams(lua_State *L) {
@@ -1538,6 +1545,7 @@ static const luaL_Reg kStreamsFunctions[] = {
 	{ "__index", streamsIndex },
 	{ "GetScene", streamsGetScene },
 	{ "GetTime", streamsGetTime },
+	{ "GetFrame", streamsGetFrame },
 	{ "GetStreams", streamsGetStreams },
 	{ "GetZ", streamsGetZ },
 	{ "GetTransform", streamsGetTransform },
diff --git a/engines/nancy/state/scenestream.cpp b/engines/nancy/state/scenestream.cpp
index 689d9cc33b2..69800a9bd31 100644
--- a/engines/nancy/state/scenestream.cpp
+++ b/engines/nancy/state/scenestream.cpp
@@ -571,16 +571,20 @@ Common::String SceneStreamManager::getSceneName(const Common::String &name) cons
 	return stream ? stream->getSceneName() : Common::String();
 }
 
-double SceneStreamManager::getSceneTime(const Common::String &name) const {
 #ifdef ENABLE_NANCY_V4
-	const Script::SceneContext *scene = nullptr;
+const Script::SceneContext *SceneStreamManager::findScriptScene(const Common::String &name) const {
 	if (name.equalsIgnoreCase(kMainStreamName)) {
-		scene = NancySceneState.getScriptScene();
-	} else {
-		const SceneStream *stream = name.empty() ? _running : find(name);
-		scene = stream ? stream->getScriptScene() : nullptr;
+		return NancySceneState.getScriptScene();
 	}
 
+	const SceneStream *stream = name.empty() ? _running : find(name);
+	return stream ? stream->getScriptScene() : nullptr;
+}
+#endif
+
+double SceneStreamManager::getSceneTime(const Common::String &name) const {
+#ifdef ENABLE_NANCY_V4
+	const Script::SceneContext *scene = findScriptScene(name);
 	if (scene) {
 		return scene->getTime();
 	}
@@ -589,6 +593,17 @@ double SceneStreamManager::getSceneTime(const Common::String &name) const {
 	return -1.0;
 }
 
+int SceneStreamManager::getSceneFrame(const Common::String &name) const {
+#ifdef ENABLE_NANCY_V4
+	const Script::SceneContext *scene = findScriptScene(name);
+	if (scene) {
+		return scene->getFrame();
+	}
+#endif
+
+	return -1;
+}
+
 // Nancy17 takes an item out of the inventory while its scene is up, in a stream
 // named after it. The item's scene doesn't put it back: the stream ending does.
 static void returnViewedItem(const Common::String &streamName) {
diff --git a/engines/nancy/state/scenestream.h b/engines/nancy/state/scenestream.h
index dae94afb975..cae8e099306 100644
--- a/engines/nancy/state/scenestream.h
+++ b/engines/nancy/state/scenestream.h
@@ -195,6 +195,9 @@ public:
 	// there is none
 	double getSceneTime(const Common::String &name) const;
 
+	// Nancy24: the frame of the scene the stream is in, or -1 when there is none
+	int getSceneFrame(const Common::String &name) const;
+
 	bool isRunning(const Common::String &name) const { return find(name) != nullptr; }
 
 	// The stream whose records are running or getting input; null for the main one
@@ -262,6 +265,8 @@ private:
 	Common::String _environment;
 
 #ifdef ENABLE_NANCY_V4
+	const Script::SceneContext *findScriptScene(const Common::String &name) const;
+
 	Script::ScriptMatrix _mainStreamTransform;
 #endif
 	ViewTransform _mainStreamViewTransform;


Commit: 10b64f25b384032efb9c87e8e7333c93a4380dc6
    https://github.com/scummvm/scummvm/commit/10b64f25b384032efb9c87e8e7333c93a4380dc6
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:31+02:00

Commit Message:
NANCY: NANCY24: Renumber the sound channels

Nancy24 has three Global channels, for the sounds that go on from
scene to scene, instead of five, and new ones for the inventory and
the phone. Sounds play on FX1 by default, which is channel 14 now.

Changed paths:
    engines/nancy/script/gameapi.cpp
    engines/nancy/script/records.cpp


diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index dd25d4a19e2..a067af3bbf8 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -1048,6 +1048,21 @@ static const SoundChannelName kNancy22SoundChannelNames[] = {
 	{ "AllGlobal", kChannelAllGlobal }
 };
 
+// Nancy24 has three Global channels instead of five, and channels of its own
+// for the sounds of the inventory and the phone
+static const SoundChannelName kNancy24SoundChannelNames[] = {
+	{ "Theme", 0 }, { "UIMusic", 1 }, { "EngineMusic", 2 },
+	{ "Global1", 3 }, { "Global2", 4 }, { "Global3", 5 },
+	{ "Ambient1", 6 }, { "Ambient2", 7 }, { "Ambient3", 8 }, { "Ambient4", 9 },
+	{ "Ambient5", 10 }, { "Ambient6", 11 }, { "Ambient7", 12 }, { "Ambient8", 13 },
+	{ "FX1", 14 }, { "FX2", 15 }, { "FX3", 16 }, { "FX4", 17 }, { "FX5", 18 }, { "FX6", 19 }, { "FX7", 20 }, { "FX8", 21 },
+	{ "InvFX", 22 }, { "PhoneFX", 23 }, { "UIFX", 24 }, { "EngineFX", 25 },
+	{ "NPCVoice", 26 }, { "PlayerVoice", 27 }, { "UIVoice", 28 }, { "EngineVoice", 29 },
+	{ "All", kChannelAll }, { "AllExceptTheme", kChannelAllExceptTheme }, { "AllMusic", kChannelAllMusic },
+	{ "AllFX", kChannelAllFX }, { "AllAmbient", kChannelAllAmbient }, { "AllVoice", kChannelAllVoice },
+	{ "AllGlobal", kChannelAllGlobal }
+};
+
 // Where the channels of each kind begin, and the end of the last kind
 struct SoundChannelLayout {
 	uint16 firstMusic;
@@ -1060,9 +1075,16 @@ struct SoundChannelLayout {
 
 static const SoundChannelLayout kSoundChannelLayout = { 0, 6, 6, 14, 24, kNumSoundChannels };
 static const SoundChannelLayout kNancy22SoundChannelLayout = { 0, 3, 8, 16, 26, kNumSoundChannels };
+static const SoundChannelLayout kNancy24SoundChannelLayout = { 0, 3, 6, 14, 26, kNumSoundChannels };
 
 static const SoundChannelLayout &getSoundChannelLayout() {
-	return g_nancy->getGameType() >= kGameTypeNancy22 ? kNancy22SoundChannelLayout : kSoundChannelLayout;
+	if (g_nancy->getGameType() <= kGameTypeNancy21) {
+		return kSoundChannelLayout;
+	} else if (g_nancy->getGameType() <= kGameTypeNancy23) {
+		return kNancy22SoundChannelLayout;
+	}
+
+	return kNancy24SoundChannelLayout;
 }
 
 void pushSoundChannel(lua_State *L, uint16 channel) {
@@ -1092,7 +1114,14 @@ bool isVoicePlaying() {
 static int soundChannelIndex(lua_State *L) {
 	const char *name = luaL_checkstring(L, 2);
 
-	if (g_nancy->getGameType() >= kGameTypeNancy22) {
+	if (g_nancy->getGameType() >= kGameTypeNancy24) {
+		for (const SoundChannelName &channel : kNancy24SoundChannelNames) {
+			if (scumm_stricmp(channel.name, name) == 0) {
+				pushSoundChannel(L, channel.channel);
+				return 1;
+			}
+		}
+	} else if (g_nancy->getGameType() >= kGameTypeNancy22) {
 		for (const SoundChannelName &channel : kNancy22SoundChannelNames) {
 			if (scumm_stricmp(channel.name, name) == 0) {
 				pushSoundChannel(L, channel.channel);
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 2d09a9e0854..3053ecf9367 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -1476,7 +1476,9 @@ void SoundRecord::readTable(int tableIndex) {
 }
 
 SoundRecord::SoundRecord(SceneContext &context) : Record(context, "ND.SoundAR") {
-	_channel = g_nancy->getGameType() >= kGameTypeNancy22 ? 16 : 14;
+	// FX1, which Nancy22 and Nancy23 have further up
+	const GameType gameType = g_nancy->getGameType();
+	_channel = (gameType >= kGameTypeNancy22 && gameType <= kGameTypeNancy23) ? 16 : 14;
 }
 
 // A sound that is playing while a movie gets skipped is cut short


Commit: ac7e951270265cdabada3f74a53b13eb596ac175
    https://github.com/scummvm/scummvm/commit/ac7e951270265cdabada3f74a53b13eb596ac175
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:32+02:00

Commit Message:
NANCY: NANCY24: Add channelType to Sound records

The channelType of a Sound record picks whether the sound goes by the
voice, music or effects volume, whatever channel it plays on.

Changed paths:
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h
    engines/nancy/sound.cpp
    engines/nancy/sound.h


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 3053ecf9367..20e6ee42de9 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -1465,6 +1465,10 @@ void SoundRecord::readTable(int tableIndex) {
 	readField(L, tableIndex, "loop", _isLooping);
 	readField(L, tableIndex, "useCC", _usesCaption);
 
+	lua_getfield(L, tableIndex, "channelType");
+	readChannelType(-1);
+	lua_pop(L, 1);
+
 	if (pushField(L, tableIndex, "sounds")) {
 		readStringList(L, -1, _names);
 		lua_pop(L, 1);
@@ -1481,6 +1485,35 @@ SoundRecord::SoundRecord(SceneContext &context) : Record(context, "ND.SoundAR")
 	_channel = (gameType >= kGameTypeNancy22 && gameType <= kGameTypeNancy23) ? 16 : 14;
 }
 
+void SoundRecord::readChannelType(int index) {
+	lua_State *L = getLua();
+
+	if (lua_isnoneornil(L, index)) {
+		_channelType.clear();
+		return;
+	}
+
+	_channelType = luaL_checkstring(L, index);
+	if (_channelType != "VOICE" && _channelType != "EFFECTS" && _channelType != "MUSIC") {
+		luaL_error(L, "%s was passed an invalid value", "channelType");
+	}
+}
+
+// A sound without a channelType set by the script uses the type of its channel
+const char *SoundRecord::getChannelType() const {
+	if (!_channelType.empty()) {
+		return _channelType.c_str();
+	} else if (_channel >= 26 && _channel <= 29) {
+		return "VOICE";
+	} else if (_channel >= 3 && _channel <= 25) {
+		return "EFFECTS";
+	} else if (_channel <= 2) {
+		return "MUSIC";
+	}
+
+	return "";
+}
+
 // A sound that is playing while a movie gets skipped is cut short
 void SoundRecord::onSkip() {
 	if (isActive() && hasStarted() && !_isLooping) {
@@ -1521,7 +1554,15 @@ void SoundRecord::runOnce() {
 	_sound.volume = (uint16)CLIP<int>((int)(_volume * 100.0), 0, 100);
 
 	g_nancy->_sound->loadSound(_sound);
-	g_nancy->_sound->playSound(_sound);
+	if (_channelType == "VOICE") {
+		g_nancy->_sound->playSound(_channel, Audio::Mixer::kSpeechSoundType);
+	} else if (_channelType == "MUSIC") {
+		g_nancy->_sound->playSound(_channel, Audio::Mixer::kMusicSoundType);
+	} else if (_channelType == "EFFECTS") {
+		g_nancy->_sound->playSound(_channel, Audio::Mixer::kSFXSoundType);
+	} else {
+		g_nancy->_sound->playSound(_sound);
+	}
 
 	_isPlaying = g_nancy->_sound->isSoundPlaying(_sound);
 	_wasPreempted = false;
@@ -1579,6 +1620,8 @@ bool SoundRecord::setField(const Common::String &key) {
 		}
 
 		_channel = checkSoundChannel(L, 3);
+	} else if (key == "channelType") {
+		readChannelType(3);
 	} else if (key == "volume") {
 		_volume = luaL_checknumber(L, 3);
 	} else if (key == "useCC") {
@@ -1618,6 +1661,8 @@ bool SoundRecord::getField(const Common::String &key) {
 		lua_pushcfunction(L, soundStopIfPlaying);
 	} else if (key == "channel") {
 		pushSoundChannel(L, _channel);
+	} else if (key == "channelType") {
+		lua_pushstring(L, getChannelType());
 	} else if (key == "volume") {
 		lua_pushnumber(L, _volume);
 	} else if (key == "loop") {
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 32827383694..7bcc89a8169 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -352,8 +352,13 @@ protected:
 	bool setField(const Common::String &key) override;
 
 private:
+	// Nancy24: "VOICE", "MUSIC" or "EFFECTS", the volume the sound goes by
+	void readChannelType(int index);
+	const char *getChannelType() const;
+
 	Common::Array<Common::String> _names;
 	uint16 _channel;	// FX1 unless the table says otherwise
+	Common::String _channelType;	// empty for the one of the channel
 	double _volume = 1.0;
 	bool _isLooping = false;
 	bool _usesCaption = true;
diff --git a/engines/nancy/sound.cpp b/engines/nancy/sound.cpp
index ca4dc1909db..204159af73a 100644
--- a/engines/nancy/sound.cpp
+++ b/engines/nancy/sound.cpp
@@ -387,6 +387,12 @@ void SoundManager::loadSound(const SoundDescription &description, SoundEffectDes
 }
 
 void SoundManager::playSound(uint16 channelID) {
+	if (channelID < _channels.size()) {
+		playSound(channelID, _channels[channelID].type);
+	}
+}
+
+void SoundManager::playSound(uint16 channelID, Audio::Mixer::SoundType type) {
 	if (channelID >= _channels.size() || _channels[channelID].stream == nullptr || isSoundPlaying(channelID))
 		return;
 
@@ -444,7 +450,7 @@ void SoundManager::playSound(uint16 channelID) {
 		}
 	}
 
-	_mixer->playStream(	chan.type,
+	_mixer->playStream(	type,
 						&chan.handle,
 						chan.streamForMixer,
 						channelID,
diff --git a/engines/nancy/sound.h b/engines/nancy/sound.h
index 0ff82579841..3cc966adf77 100644
--- a/engines/nancy/sound.h
+++ b/engines/nancy/sound.h
@@ -70,6 +70,8 @@ public:
 
 	void playSound(uint16 channelID);
 	void playSound(const SoundDescription &description);
+	// Nancy24 scripts can pick the volume a sound goes by, whatever its channel
+	void playSound(uint16 channelID, Audio::Mixer::SoundType type);
 	void playSound(const Common::String &chunkName);
 
 	void pauseSound(uint16 channelID, bool pause);


Commit: 4a5c8ed05b2af2d1f774e7beb22c0e57fe5f337b
    https://github.com/scummvm/scummvm/commit/4a5c8ed05b2af2d1f774e7beb22c0e57fe5f337b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:34+02:00

Commit Message:
NANCY: NANCY24: Let an overlay show its picture at several places

The onScreen of an overlay can be a table of rects, which the scripts
change as they go, e.g. the highlights of the cards in the match
puzzle. The picture is shown at each of them.

Changed paths:
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 20e6ee42de9..1ec1d8001db 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -270,6 +270,50 @@ static void placePicture(RecordGraphic &graphic, Graphics::ManagedSurface &image
 	graphic.setNeedsRedraw(true);
 }
 
+// Lays a picture placePicture() made over another surface, as it would show
+// on the screen. The origin is where the surface is in the viewport.
+static void blendPicture(Graphics::ManagedSurface &target, const RecordGraphic &picture, bool isKeyed, const Common::Point &origin) {
+	const Graphics::ManagedSurface &image = picture._drawSurface;
+	Common::Rect area = picture.getScreenPositionRaw();
+	area.translate(-origin.x, -origin.y);
+
+	byte transR, transG, transB;
+	image.format.colorToRGB(g_nancy->_graphics->getTransColor(), transR, transG, transB);
+	const bool hasAlpha = image.format.aBits() != 0;
+
+	for (int y = MAX<int>(0, -area.top); y < image.h && area.top + y < target.h; ++y) {
+		for (int x = MAX<int>(0, -area.left); x < image.w && area.left + x < target.w; ++x) {
+			byte alpha, red, green, blue;
+			image.format.colorToARGB(image.getPixel(x, y), alpha, red, green, blue);
+			if (isKeyed) {
+				if (red == transR && green == transG && blue == transB) {
+					continue;
+				}
+
+				if (!hasAlpha) {
+					alpha = 0xFF;
+				}
+			}
+
+			if (alpha == 0) {
+				continue;
+			}
+
+			const int targetX = area.left + x;
+			const int targetY = area.top + y;
+			byte oldAlpha, oldRed, oldGreen, oldBlue;
+			target.format.colorToARGB(target.getPixel(targetX, targetY), oldAlpha, oldRed, oldGreen, oldBlue);
+
+			const uint rest = 255 - alpha;
+			target.setPixel(targetX, targetY, target.format.ARGBToColor(
+				alpha + oldAlpha * rest / 255,
+				(red * alpha + oldRed * rest) / 255,
+				(green * alpha + oldGreen * rest) / 255,
+				(blue * alpha + oldBlue * rest) / 255));
+		}
+	}
+}
+
 static Graphics::ManagedSurface *s_drawTarget = nullptr;
 
 Graphics::ManagedSurface *getDrawTarget() {
@@ -1083,7 +1127,7 @@ void OverlayRecord::readTable(int tableIndex) {
 
 	_dest = _source;
 	if (pushField(L, tableIndex, "onScreen")) {
-		_dest = checkRect(L, -1);
+		readDest(-1);
 		lua_pop(L, 1);
 	}
 
@@ -1099,17 +1143,81 @@ void OverlayRecord::readTable(int tableIndex) {
 	_graphic.registerGraphics();
 }
 
+// The onScreen of an overlay is a rect, or in Nancy24 also a table of rects;
+// the picture is then shown at each of them. The scripts change the rects in
+// the table as they go, so the table is kept as it is.
+void OverlayRecord::readDest(int index) {
+	lua_State *L = getLua();
+
+	_hasDestTable = lua_istable(L, index);
+	if (_hasDestTable) {
+		lua_pushvalue(L, index);
+		storeValue("onScreen");
+		readDestTable(_tableDests);
+	} else {
+		_dest = checkRect(L, index);
+	}
+}
+
+void OverlayRecord::readDestTable(Common::Array<ScriptRect> &dests) {
+	lua_State *L = getLua();
+
+	dests.clear();
+	pushStoredValue("onScreen");
+	if (lua_istable(L, -1)) {
+		lua_pushnil(L);
+		while (lua_next(L, -2)) {
+			const ScriptRect *dest = testRect(L, -1);
+			if (dest) {
+				dests.push_back(*dest);
+			}
+
+			lua_pop(L, 1);
+		}
+	}
+
+	lua_pop(L, 1);
+}
+
 void OverlayRecord::applyRects() {
 	Common::Rect source = _source.toRect();
 	source.clip(Common::Rect(_image.w, _image.h));
 
 	// A script can leave the picture out until it knows what to show
-	_hasPicture = !source.isEmpty();
+	_hasPicture = !source.isEmpty() && (!_hasDestTable || !_tableDests.empty());
 	if (!_hasPicture) {
 		return;
 	}
 
-	placePicture(_graphic, _image, source, _dest, getTransform(), _modColor);
+	if (!_hasDestTable) {
+		placePicture(_graphic, _image, source, _dest, getTransform(), _modColor);
+		return;
+	}
+
+	// The copies of the picture are drawn into one surface that covers them all
+	const ScriptMatrix transform = getTransform();
+	const bool isKeyed = transform.isTranslation() && _modColor == kNoModColor;
+	Common::Array<RecordGraphic> pictures(_tableDests.size());
+	Common::Rect area;
+	for (uint i = 0; i < _tableDests.size(); ++i) {
+		placePicture(pictures[i], _image, source, _tableDests[i], transform, _modColor);
+		if (i == 0) {
+			area = pictures[i].getScreenPositionRaw();
+		} else {
+			area.extend(pictures[i].getScreenPositionRaw());
+		}
+	}
+
+	Graphics::ManagedSurface &out = _graphic._drawSurface;
+	out.create(MAX<int>(area.width(), 1), MAX<int>(area.height(), 1), g_nancy->_graphics->getTransparentPixelFormat());
+	out.clear(0);
+	_graphic.setTransparent(false);
+	for (const RecordGraphic &picture : pictures) {
+		blendPicture(out, picture, isKeyed, Common::Point(area.left, area.top));
+	}
+
+	_graphic.moveTo(area);
+	_graphic.setNeedsRedraw(true);
 }
 
 void OverlayRecord::onZChanged() {
@@ -1121,6 +1229,15 @@ void OverlayRecord::registerGraphics() {
 }
 
 void OverlayRecord::updateGraphics() {
+	if (_hasDestTable && isActive()) {
+		Common::Array<ScriptRect> dests;
+		readDestTable(dests);
+		if (dests != _tableDests) {
+			_tableDests = dests;
+			applyRects();
+		}
+	}
+
 	_graphic.setVisible(isActive() && _hasPicture);
 
 	if (_hasAttachment) {
@@ -1165,7 +1282,11 @@ bool OverlayRecord::getField(const Common::String &key) {
 	lua_State *L = getLua();
 
 	if (key == "onScreen") {
-		pushRect(L, _dest);
+		if (_hasDestTable) {
+			pushStoredValue("onScreen");
+		} else {
+			pushRect(L, _dest);
+		}
 	} else if (key == "source") {
 		pushRect(L, _source);
 	} else if (key == "modColor") {
@@ -1182,12 +1303,16 @@ bool OverlayRecord::setField(const Common::String &key) {
 
 	// Only a change gets the picture drawn anew
 	if (key == "onScreen") {
-		const ScriptRect dest = checkRect(L, 3);
-		if (dest == _dest) {
-			return true;
-		}
+		if (lua_istable(L, 3) || _hasDestTable) {
+			readDest(3);
+		} else {
+			const ScriptRect dest = checkRect(L, 3);
+			if (dest == _dest) {
+				return true;
+			}
 
-		_dest = dest;
+			_dest = dest;
+		}
 	} else if (key == "source") {
 		const ScriptRect source = checkRect(L, 3);
 		if (source == _source) {
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 7bcc89a8169..877988d7cb1 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -267,12 +267,16 @@ protected:
 	bool setField(const Common::String &key) override;
 
 private:
+	void readDest(int index);
+	void readDestTable(Common::Array<ScriptRect> &dests);
 	void applyRects();
 
 	Common::SharedPtr<Graphics::ManagedSurface> _cachedImage;	// kept while the record uses it
 	Graphics::ManagedSurface _image;	// the cached picture, or a saved one
 	ScriptRect _source;
 	ScriptRect _dest;
+	bool _hasDestTable = false;					// Nancy24: onScreen is a table of rects
+	Common::Array<ScriptRect> _tableDests;		// what it had when last drawn
 	uint32 _modColor = 0xFFFFFFFF;	// what the colors of the picture get multiplied with
 	bool _hasPicture = false;
 	RecordGraphic _graphic;


Commit: 9aca6f31b3ca779b9b5fe19941ee390ee55c114e
    https://github.com/scummvm/scummvm/commit/9aca6f31b3ca779b9b5fe19941ee390ee55c114e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:35+02:00

Commit Message:
NANCY: NANCY24: Add overlay drawing to records

A record that renders can now draw the picture of an Overlay record
once more, with Draw:OVL. It can use another part of the picture,
place, transform or color than the overlay's own, e.g. for the lit
nodes of the controls puzzle.

Changed paths:
    engines/nancy/script/gameapi.cpp
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h


diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index a067af3bbf8..64dce11a101 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -691,6 +691,7 @@ static const luaL_Reg kDrawFunctions[] = {
 	{ "Line", drawLine },
 	{ "Tri", drawTri },
 	{ "Circle", drawCircle },
+	{ "OVL", drawOverlay },
 	{ nullptr, nullptr }
 };
 
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 1ec1d8001db..b841a3c92f5 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -35,6 +35,7 @@
 
 #include "engines/nancy/script/api.h"
 #include "engines/nancy/script/convo.h"
+#include "engines/nancy/script/graphnode.h"
 #include "engines/nancy/script/luabind.h"
 #include "engines/nancy/script/particles.h"
 #include "engines/nancy/script/physics.h"
@@ -1278,6 +1279,82 @@ void OverlayRecord::renderNow() {
 	_isAttachmentDrawn = true;
 }
 
+// Draws the picture of the overlay once more. The source, onScreen, transform
+// and modColor in the table of Draw:OVL replace the overlay's own.
+void OverlayRecord::drawCopy(int tableIndex) {
+	lua_State *L = getLua();
+
+	ScriptRect source = _source;
+	ScriptRect dest = _dest;
+	ScriptMatrix transform = getTransform();
+	uint32 modColor = _modColor;
+
+	if (pushField(L, tableIndex, "source")) {
+		source = checkRect(L, -1);
+		lua_pop(L, 1);
+	}
+
+	if (pushField(L, tableIndex, "onScreen")) {
+		dest = checkRect(L, -1);
+		lua_pop(L, 1);
+	}
+
+	// A transform from the table is still combined with those of the nodes
+	// the overlay is attached to
+	if (pushField(L, tableIndex, "transform")) {
+		transform = checkMatrix(L, -1);
+		lua_pop(L, 1);
+
+		if (getParentNode()) {
+			transform = transform * getParentNode()->getTransform();
+		}
+	}
+
+	if (pushField(L, tableIndex, "modColor")) {
+		modColor = checkColor(L, -1);
+		lua_pop(L, 1);
+	}
+
+	Graphics::ManagedSurface *target = getDrawTarget();
+	if (!target) {
+		luaL_error(L, "Draw can only be used while a record is rendering");
+	}
+
+	Common::Rect from = source.toRect();
+	from.clip(Common::Rect(_image.w, _image.h));
+	if (from.isEmpty()) {
+		return;
+	}
+
+	const VIEW *viewport = GetEngineData(VIEW);
+	assert(viewport);
+	transform.m[3][0] -= viewport->screenPosition.left;
+	transform.m[3][1] -= viewport->screenPosition.top;
+
+	RecordGraphic picture;
+	placePicture(picture, _image, from, dest, transform, modColor);
+	blendPicture(*target, picture, transform.isTranslation() && modColor == kNoModColor, Common::Point());
+}
+
+// Draw:OVL(table), Nancy24: table.ar is the Overlay record to draw
+int drawOverlay(lua_State *L) {
+	luaL_checktype(L, 2, LUA_TTABLE);
+
+	lua_getfield(L, 2, "ar");
+	if (lua_isnil(L, -1)) {
+		return luaL_argerror(L, 2, "Reference to existing overlay AR must be provided (ar field is nil)");
+	}
+
+	OverlayRecord *overlay = dynamic_cast<OverlayRecord *>(checkRecord(L, -1));
+	if (!overlay) {
+		return luaL_typerror(L, -1, "ND.Overlay");
+	}
+
+	lua_pop(L, 1);
+	overlay->drawCopy(2);
+	return 0;
+}
+
 bool OverlayRecord::getField(const Common::String &key) {
 	lua_State *L = getLua();
 
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 877988d7cb1..141424bc508 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -75,6 +75,10 @@ Record *makeRecord(RecordKind kind, SceneContext &context);
 // function is running. Null at any other time.
 Graphics::ManagedSurface *getDrawTarget();
 
+// Draw:OVL(table), Nancy24: draws the picture of an Overlay record onto what
+// the record that is rendering draws
+int drawOverlay(lua_State *L);
+
 // What a record draws. Records are placed in the coordinates of the viewport.
 class RecordGraphic : public RenderObject {
 public:
@@ -257,6 +261,11 @@ public:
 	void updateGraphics() override;
 	void registerGraphics() override;
 
+	// Nancy24: Draw:OVL draws the picture once more while another record
+	// renders. The table at tableIndex can replace its source, onScreen,
+	// transform and modColor.
+	void drawCopy(int tableIndex);
+
 protected:
 	void readTable(int tableIndex) override;
 	void onZChanged() override;


Commit: d08e8f976be474ed95f840aa4246b426d78507d7
    https://github.com/scummvm/scummvm/commit/d08e8f976be474ed95f840aa4246b426d78507d7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:36+02:00

Commit Message:
NANCY: NANCY24: Add task completion functions

Instead of a flag, a task can have a completion function in the task
list script, which says whether the task is done; it can be checked
off only then. Player:LoadTaskCompletion sets these functions when the
task list loads, and unchecks tasks that aren't done anymore.

Changed paths:
    engines/nancy/script/api.h
    engines/nancy/script/gameapi.cpp
    engines/nancy/script/scenecontext.cpp
    engines/nancy/ui/ndui/enginehandlers.cpp


diff --git a/engines/nancy/script/api.h b/engines/nancy/script/api.h
index 47dec31b017..80fda505ded 100644
--- a/engines/nancy/script/api.h
+++ b/engines/nancy/script/api.h
@@ -83,6 +83,17 @@ bool getFlagByName(const Common::String &name, bool &value);
 // into the UI, once it has been made
 void showPlayerEntries();
 
+class SceneContext;
+
+// Nancy24: whether a task of the character being played is done, as its
+// completion function in the scripts says. A task without a completion
+// function is always done.
+bool isTaskComplete(const Common::String &text);
+
+// Drops the completion functions of tasks a scene gave, as the scene is
+// going away
+void forgetTaskCompletions(SceneContext *context);
+
 // Reads a cursor a script picked with "Cursor.<name>", "Cursor.<name>.hot"...
 // Returns false when the value is something else.
 bool testCursor(lua_State *L, int index, uint &cursorType, bool &isHot);
diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index 64dce11a101..f50c6a7edbf 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -1737,12 +1737,87 @@ static int playerAddJournalEntry(lua_State *L) {
 	return 0;
 }
 
-// Player:AddTask(text, flag[, character]): the task can be checked off once the flag is set
+// Nancy24 tells whether a task is done with a completion function of the
+// scripts, in place of a flag. The functions belong to the Lua state of the
+// scene that gave them, which is the scene of the task list stream, and are
+// dropped when that scene goes away.
+struct TaskCompletion {
+	SceneContext *context;
+	uint character;
+	Common::String text;
+	int ref;
+};
+
+static Common::Array<TaskCompletion> s_taskCompletions;
+
+static void setTaskCompletion(lua_State *L, int index, uint character, const Common::String &text) {
+	SceneContext *context = LuaState::getContext(L);
+	if (!context) {
+		return;
+	}
+
+	for (uint i = 0; i < s_taskCompletions.size(); ++i) {
+		const TaskCompletion &completion = s_taskCompletions[i];
+		if (completion.character == character && completion.text.equalsIgnoreCase(text)) {
+			luaL_unref(completion.context->getLua(), LUA_REGISTRYINDEX, completion.ref);
+			s_taskCompletions.remove_at(i);
+			break;
+		}
+	}
+
+	TaskCompletion completion;
+	completion.context = context;
+	completion.character = character;
+	completion.text = text;
+	lua_pushvalue(L, index);
+	completion.ref = luaL_ref(L, LUA_REGISTRYINDEX);
+	s_taskCompletions.push_back(completion);
+}
+
+bool isTaskComplete(const Common::String &text) {
+	const uint character = g_nancy->getPlayerCharacter();
+	for (const TaskCompletion &completion : s_taskCompletions) {
+		if (completion.character != character || !completion.text.equalsIgnoreCase(text)) {
+			continue;
+		}
+
+		lua_State *L = completion.context->getLua();
+		lua_rawgeti(L, LUA_REGISTRYINDEX, completion.ref);
+		if (!LuaState::call(L, 0, 1, "Error in the completion function of a task")) {
+			return false;
+		}
+
+		const bool isComplete = lua_toboolean(L, -1) != 0;
+		lua_pop(L, 1);
+		return isComplete;
+	}
+
+	return true;
+}
+
+void forgetTaskCompletions(SceneContext *context) {
+	for (uint i = 0; i < s_taskCompletions.size();) {
+		if (s_taskCompletions[i].context == context) {
+			s_taskCompletions.remove_at(i);
+		} else {
+			++i;
+		}
+	}
+}
+
+// Player:AddTask(text, flag[, character]): the task can be checked off once the
+// flag is set. Nancy24 gives a function that says whether it is done instead.
 static int playerAddTask(lua_State *L) {
 	const Common::String text = luaL_checkstring(L, 2);
-	const Common::String flagName = luaL_checkstring(L, 3);
 	const uint character = checkCharacter(L, 4);
 
+	Common::String flagName;
+	if (lua_isfunction(L, 3)) {
+		setTaskCompletion(L, 3, character, text);
+	} else {
+		flagName = luaL_checkstring(L, 3);
+	}
+
 	ScriptJournalData *data = getJournalData(character);
 	if (!data) {
 		return 0;
@@ -1787,6 +1862,42 @@ static int playerLoadTaskFlag(lua_State *L) {
 	return 0;
 }
 
+// Player:LoadTaskCompletion(text, function[, character]), Nancy24: gives a task
+// the function that says whether it is done, as the task list does once it
+// gets loaded. A task that was checked off but isn't done anymore gets unchecked.
+static int playerLoadTaskCompletion(lua_State *L) {
+	const Common::String text = luaL_checkstring(L, 2);
+	if (!lua_isfunction(L, 3)) {
+		return luaL_argerror(L, 3, "Completion argument must be a function");
+	}
+
+	lua_settop(L, 3);
+	const uint character = checkCharacter(L, 4);
+	setTaskCompletion(L, 3, character, text);
+
+	TasklistData *tasklistData = (TasklistData *)NancySceneState.getPuzzleData(TasklistData::getTag());
+	if (!tasklistData || character != g_nancy->getPlayerCharacter()) {
+		return 0;
+	}
+
+	for (uint i = 0; i < tasklistData->checkedEntries.size(); ++i) {
+		if (tasklistData->checkedEntries[i].equalsIgnoreCase(text)) {
+			if (!isTaskComplete(text)) {
+				tasklistData->checkedEntries.remove_at(i);
+
+				UI::NDUI::Manager *ui = NancySceneState.getNDUI();
+				if (ui) {
+					ui->takeAction(UI::NDUI::kActionSetValue, text, 0.0);
+				}
+			}
+
+			break;
+		}
+	}
+
+	return 0;
+}
+
 void showPlayerEntries() {
 	UI::NDUI::Manager *ui = NancySceneState.getNDUI();
 	const uint character = g_nancy->getPlayerCharacter();
@@ -1906,6 +2017,7 @@ static const luaL_Reg kPlayerFunctions[] = {
 	{ "AddJournalEntry", playerAddJournalEntry },
 	{ "AddTask", playerAddTask },
 	{ "LoadTaskFlag", playerLoadTaskFlag },
+	{ "LoadTaskCompletion", playerLoadTaskCompletion },
 	{ nullptr, nullptr }
 };
 
diff --git a/engines/nancy/script/scenecontext.cpp b/engines/nancy/script/scenecontext.cpp
index c78b1e4797c..5d8357a825c 100644
--- a/engines/nancy/script/scenecontext.cpp
+++ b/engines/nancy/script/scenecontext.cpp
@@ -29,6 +29,7 @@
 #include "engines/nancy/resource/resource.h"
 #include "engines/nancy/util.h"
 
+#include "engines/nancy/script/api.h"
 #include "engines/nancy/script/convo.h"
 #include "engines/nancy/script/graphnode.h"
 #include "engines/nancy/script/luabind.h"
@@ -75,6 +76,8 @@ SceneContext::~SceneContext() {
 		delete response;
 	}
 
+	forgetTaskCompletions(this);
+
 	for (GraphNode *node : _graphNodes) {
 		delete node;
 	}
diff --git a/engines/nancy/ui/ndui/enginehandlers.cpp b/engines/nancy/ui/ndui/enginehandlers.cpp
index bb6032a3abf..5be299f5590 100644
--- a/engines/nancy/ui/ndui/enginehandlers.cpp
+++ b/engines/nancy/ui/ndui/enginehandlers.cpp
@@ -29,6 +29,10 @@
 
 #include "engines/nancy/state/scene.h"
 
+#ifdef ENABLE_NANCY_V4
+#include "engines/nancy/script/api.h"
+#endif
+
 #include "engines/nancy/ui/ndui/manager.h"
 #include "engines/nancy/ui/ndui/panel.h"
 #include "engines/nancy/ui/ndui/button.h"
@@ -498,7 +502,12 @@ void Manager::onTasklistAction(const Action &action) {
 	}
 
 	int16 flag = _tasklistFlags.getValOrDefault(action.sender, kEvNoEvent);
-	if (flag != kEvNoEvent && NancySceneState.getEventFlag(flag, g_nancy->_false)) {
+	bool isDone = flag == kEvNoEvent || !NancySceneState.getEventFlag(flag, g_nancy->_false);
+#ifdef ENABLE_NANCY_V4
+	isDone = isDone && Script::isTaskComplete(action.sender);
+#endif
+
+	if (!isDone) {
 		takeAction(kActionSetValue, action.sender, 0.0);
 	} else {
 		TasklistData *tasklistData = (TasklistData *)NancySceneState.getPuzzleData(TasklistData::getTag());


Commit: e8b0ddb3a82cbffd3ef620a77ab32e7e3542ca8d
    https://github.com/scummvm/scummvm/commit/e8b0ddb3a82cbffd3ef620a77ab32e7e3542ca8d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:37+02:00

Commit Message:
NANCY: NANCY24: Implement Timer records

Nancy24's fidgets, conversations and puzzles wait with Timer records.
A timer is over after a fixed duration, after a random duration
between minDuration and maxDuration, or once it has counted through a
range of frames a number of times, and then calls its OnDone. Reset
and Restart can give a timer new values.

Changed paths:
  A engines/nancy/script/timer.cpp
  A engines/nancy/script/timer.h
    engines/nancy/module.mk
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h


diff --git a/engines/nancy/module.mk b/engines/nancy/module.mk
index b12b2d9da1b..35bce2f5187 100644
--- a/engines/nancy/module.mk
+++ b/engines/nancy/module.mk
@@ -231,6 +231,7 @@ MODULE_OBJS += \
   script/records.o \
   script/ref.o \
   script/scenecontext.o \
+  script/timer.o \
   script/transformer.o \
   script/types.o \
   script/uiapi.o \
diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index b841a3c92f5..cd5ec8392fd 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -42,6 +42,7 @@
 #include "engines/nancy/script/records.h"
 #include "engines/nancy/script/ref.h"
 #include "engines/nancy/script/scenecontext.h"
+#include "engines/nancy/script/timer.h"
 #include "engines/nancy/script/transformer.h"
 #include "engines/nancy/script/types.h"
 #include "engines/nancy/script/xsheet.h"
@@ -73,7 +74,8 @@ static const RecordKindNames kRecordKindNames[kNumRecordKinds] = {
 	{ "AnimOverlay", "ND.AnimOvlAR" },
 	{ "Physics", "ND.PhysicsAR" },
 	{ "Xsheet", "ND.XsheetAR" },
-	{ "Transformer", "ND.TransformerAR" }
+	{ "Transformer", "ND.TransformerAR" },
+	{ "Timer", "ND.TimerAR" }
 };
 
 const char *getRecordKindName(RecordKind kind) {
@@ -114,6 +116,8 @@ Record *makeRecord(RecordKind kind, SceneContext &context) {
 		return new XsheetRecord(context);
 	case kRecordTransformer:
 		return new TransformerRecord(context);
+	case kRecordTimer:
+		return new TimerRecord(context);
 	default:
 		return nullptr;
 	}
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 141424bc508..b9c27822220 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -60,8 +60,9 @@ enum RecordKind {
 	kRecordPhysics		= 11,	// Nancy21
 	kRecordXsheet		= 12,	// Nancy22
 	kRecordTransformer	= 13,	// Nancy22
+	kRecordTimer		= 14,	// Nancy24
 
-	kNumRecordKinds		= 14
+	kNumRecordKinds		= 15
 };
 
 // What scripts call the kind ("NavLogic"), and the type of its objects ("ND.NavLogic")
diff --git a/engines/nancy/script/timer.cpp b/engines/nancy/script/timer.cpp
new file mode 100644
index 00000000000..973ea26f153
--- /dev/null
+++ b/engines/nancy/script/timer.cpp
@@ -0,0 +1,298 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/random.h"
+
+#include "engines/nancy/nancy.h"
+
+#include "engines/nancy/script/luabind.h"
+#include "engines/nancy/script/timer.h"
+
+namespace Nancy {
+namespace Script {
+
+// PlayCounter
+
+void PlayCounter::setRange(int firstFrame, int lastFrame, int plays, int maxPlays) {
+	startPlay(lastFrame == -1 ? -1 : MAX(lastFrame - firstFrame, 0));
+	_firstFrame = firstFrame;
+	_maxPlays = maxPlays == 0 ? 0 : MAX(maxPlays, 1);
+	setPlays(plays);
+}
+
+void PlayCounter::setPlays(int plays) {
+	_plays = MAX(plays, 1);
+	if (_maxPlays != 0) {
+		_plays = MIN(_plays, _maxPlays);
+	}
+}
+
+// As in the original, the last frame passed here is counted from the first
+// frame of the range, while setRange() expects it counted from 0. This makes a
+// restarted range shorter, when it doesn't start at frame 0.
+void PlayCounter::restart() {
+	setRange(_firstFrame, _lastFrame, 1, _maxPlays);
+}
+
+void PlayCounter::startPlay(int lastFrame) {
+	_lastFrame = lastFrame == -1 ? -1 : MAX(lastFrame, 0);
+	_time = 0.0;
+	_leftover = 0.0;
+	_frame = 0;
+	_position = 0.0;
+	_hasEnded = false;
+}
+
+void PlayCounter::setRate(double framesPerSecond) {
+	_rate = MAX(framesPerSecond, 0.0);
+	if (_rate > 0.0) {
+		_period = 1.0 / _rate;
+	}
+}
+
+void PlayCounter::setFrame(int frame) {
+	frame = MAX(frame, _firstFrame) - _firstFrame;
+
+	_leftover = 0.0;
+	if (frame != _frame) {
+		_frame = MAX(frame, 0);
+		if (_lastFrame != -1) {
+			_frame = MIN(_frame, _lastFrame);
+			_hasEnded = frame > _lastFrame;
+		}
+	}
+
+	_position = _frame;
+}
+
+void PlayCounter::advancePlay(double seconds) {
+	_time += seconds;
+	if (_rate == 0.0) {
+		return;
+	}
+
+	_leftover += seconds;
+	const int startFrame = _frame;
+	_position = _leftover * _rate + _frame;
+	_frame += MAX((int)(_leftover * _rate), 0);
+
+	if (_lastFrame != -1) {
+		_hasEnded |= _frame > _lastFrame;
+		_frame = MIN(_frame, _lastFrame);
+		_position = MIN(_position, _lastFrame + 1 - 0.00001);
+	}
+
+	_leftover -= (_frame - startFrame) * _period;
+}
+
+// Time that goes past the end of a play counts toward the next play
+void PlayCounter::advance(double seconds) {
+	advancePlay(seconds);
+
+	if (_hasEnded && (_maxPlays == 0 || _plays != _maxPlays)) {
+		const double leftover = _leftover - _period;
+		++_plays;
+		startPlay(_lastFrame);
+		advancePlay(leftover);
+	}
+}
+
+double PlayCounter::getPlayDuration() const {
+	return _rate == 0.0 ? 0.0 : getNumFrames() * _period;
+}
+
+double PlayCounter::getDuration() const {
+	const double duration = getPlayDuration();
+	return _maxPlays == 0 ? duration : duration * _maxPlays;
+}
+
+// As in the original, this adds the full duration of a play for every play
+// so far, including the current one
+double PlayCounter::getElapsed() const {
+	return _plays == 1 ? _time : getPlayDuration() * _plays + _time;
+}
+
+// TimerRecord
+
+static const double kDefaultTimerRate = 15.0;
+
+TimerRecord::TimerRecord(SceneContext &context) : Record(context, "ND.TimerAR") {
+	_counter.setRate(kDefaultTimerRate);
+}
+
+void TimerRecord::readTable(int tableIndex) {
+	lua_State *L = getLua();
+
+	readField(L, tableIndex, "paused", _isPaused);
+
+	if (readField(L, tableIndex, "duration", _minDuration)) {
+		_maxDuration = _minDuration;
+		pickDuration();
+		return;
+	}
+
+	lua_getfield(L, tableIndex, "minDuration");
+	lua_getfield(L, tableIndex, "maxDuration");
+	const bool hasRange = !lua_isnil(L, -2) && !lua_isnil(L, -1);
+	lua_pop(L, 2);
+
+	if (hasRange) {
+		readField(L, tableIndex, "minDuration", _minDuration);
+		readField(L, tableIndex, "maxDuration", _maxDuration);
+		pickDuration();
+		return;
+	}
+
+	lua_getfield(L, tableIndex, "lastFrame");
+	const bool hasFrames = !lua_isnil(L, -1);
+	lua_pop(L, 1);
+
+	if (!hasFrames) {
+		luaL_error(L, "Timer must have (A) duration, (B) minDuration and maxDuration or (C) lastFrame");
+		return;
+	}
+
+	int firstFrame = _counter.getFirstFrame();
+	int lastFrame = _counter.getLastFrame();
+	int plays = 1;
+	int maxPlays = _counter.getMaxPlays();
+	int frame = firstFrame;
+	double framesPerSecond = _counter.getRate();
+	readField(L, tableIndex, "firstFrame", firstFrame);
+	readField(L, tableIndex, "lastFrame", lastFrame);
+	readField(L, tableIndex, "plays", plays);
+	readField(L, tableIndex, "maxPlays", maxPlays);
+	readField(L, tableIndex, "frame", frame);
+	readField(L, tableIndex, "fps", framesPerSecond);
+
+	_minDuration = _maxDuration = -1.0;
+	_counter.setRange(firstFrame, lastFrame, plays, maxPlays);
+	_counter.setRate(framesPerSecond);
+	_counter.setFrame(frame);
+}
+
+void TimerRecord::pickDuration() {
+	_counter.setRange(0, 0, 1, 1);
+
+	const double t = g_nancy->_randomSource->getRandomNumber(32767) / 32767.0;
+	const double duration = _minDuration + t * (_maxDuration - _minDuration);
+	if (duration == 0.0) {
+		_counter.setFrame(1);
+	} else {
+		_counter.setRate(1.0 / duration);
+	}
+}
+
+void TimerRecord::run(double sceneTime, double elapsedTime) {
+	_counter.advance(elapsedTime);
+
+	lua_State *L = getLua();
+	lua_pushnumber(L, _counter.getElapsed());
+	lua_pushnumber(L, elapsedTime);
+	callFunction("Run", 2);
+
+	if (_counter.hasEnded()) {
+		finish();
+	}
+}
+
+// Reset and Restart can be passed a table with new values, which is at stack
+// index 2. Without one, a timer with a duration picks a new duration, and
+// a timer with frames starts its counter over.
+bool TimerRecord::prepareReset() {
+	lua_State *L = getLua();
+
+	if (lua_gettop(L) > 1 && lua_istable(L, 2)) {
+		lua_settop(L, 2);
+		readTable(2);
+	} else if (hasDuration()) {
+		pickDuration();
+	} else {
+		_counter.restart();
+	}
+
+	return true;
+}
+
+bool TimerRecord::getField(const Common::String &key) {
+	lua_State *L = getLua();
+
+	if (key == "duration") {
+		lua_pushnumber(L, _counter.getDuration());
+	} else if (key == "minDuration") {
+		lua_pushnumber(L, hasDuration() ? _minDuration : _counter.getDuration());
+	} else if (key == "maxDuration") {
+		lua_pushnumber(L, hasDuration() ? _maxDuration : _counter.getDuration());
+	} else if (key == "firstFrame") {
+		lua_pushinteger(L, _counter.getFirstFrame());
+	} else if (key == "lastFrame") {
+		lua_pushinteger(L, _counter.getLastFrame());
+	} else if (key == "maxPlays") {
+		lua_pushinteger(L, _counter.getMaxPlays());
+	} else if (key == "fps") {
+		lua_pushnumber(L, _counter.getRate());
+	} else if (key == "paused") {
+		lua_pushboolean(L, _isPaused);
+	} else if (key == "t") {
+		// How far the counter is through the frames of the current play,
+		// from 0 to 1
+		double t = 0.0;
+		if (_counter.getLastFrame() != -1) {
+			t = CLIP(_counter.getPosition() / _counter.getNumFrames(), 0.0, 1.0);
+		}
+
+		lua_pushnumber(L, t);
+	} else if (key == "elapsed") {
+		lua_pushnumber(L, _counter.getElapsed());
+	} else if (key == "frame") {
+		lua_pushinteger(L, _counter.getFrame());
+	} else if (key == "plays") {
+		lua_pushinteger(L, _counter.getPlays());
+	} else {
+		return false;
+	}
+
+	return true;
+}
+
+bool TimerRecord::setField(const Common::String &key) {
+	lua_State *L = getLua();
+
+	if (key == "fps") {
+		_counter.setRate(luaL_checknumber(L, 3));
+	} else if (key == "paused") {
+		_isPaused = lua_toboolean(L, 3) != 0;
+	} else if (key == "frame") {
+		_counter.setFrame((int)luaL_checknumber(L, 3));
+	} else if (key == "plays") {
+		_counter.setPlays((int)luaL_checknumber(L, 3));
+	} else if (key == "duration" || key == "minDuration" || key == "maxDuration" ||
+			key == "maxPlays" || key == "firstFrame" || key == "lastFrame") {
+		luaL_error(L, "%s may only be set in a Reset or Restart call", key.c_str());
+	} else {
+		return false;
+	}
+
+	return true;
+}
+
+} // End of namespace Script
+} // End of namespace Nancy
diff --git a/engines/nancy/script/timer.h b/engines/nancy/script/timer.h
new file mode 100644
index 00000000000..e2ad3af4cba
--- /dev/null
+++ b/engines/nancy/script/timer.h
@@ -0,0 +1,115 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NANCY_SCRIPT_TIMER_H
+#define NANCY_SCRIPT_TIMER_H
+
+#include "engines/nancy/script/record.h"
+
+namespace Nancy {
+namespace Script {
+
+// The frame counter of the original. It goes through a range of frames at a
+// rate, once per play, for a number of plays. The current frame follows the
+// elapsed time, and a play is over once the time goes past the last frame.
+// Inside, frames are counted from the first frame of the range. A last frame
+// of -1 means that a play never ends.
+class PlayCounter {
+public:
+	void setRange(int firstFrame, int lastFrame, int plays, int maxPlays);
+	void advance(double seconds);
+	void restart();
+
+	void setRate(double framesPerSecond);
+	void setFrame(int frame);
+	void setPlays(int plays);
+
+	double getRate() const { return _rate; }
+	int getFrame() const { return _frame + _firstFrame; }
+	double getPosition() const { return _position + _firstFrame; }
+	int getFirstFrame() const { return _firstFrame; }
+	int getLastFrame() const { return _lastFrame + _firstFrame; }
+	int getNumFrames() const { return _lastFrame == -1 ? 0 : _lastFrame + 1; }
+	int getPlays() const { return _plays; }
+	int getMaxPlays() const { return _maxPlays; }
+
+	// The time all plays take together, and the time that has gone by in the
+	// plays so far
+	double getDuration() const;
+	double getElapsed() const;
+
+	// Whether all plays are over. A counter without a maximum number of plays
+	// never ends.
+	bool hasEnded() const { return _hasEnded && _maxPlays != 0 && _plays == _maxPlays; }
+
+private:
+	void startPlay(int lastFrame);
+	void advancePlay(double seconds);
+	double getPlayDuration() const;
+
+	double _time = 0.0;			// of the current play
+	double _leftover = 0.0;		// time that has not made a whole frame yet
+	double _rate = 0.0;
+	double _period = 0.0;
+	int _frame = 0;
+	double _position = 0.0;		// the frame, plus the fraction of it gone by
+	int _lastFrame = -1;
+	bool _hasEnded = false;		// the current play
+
+	int _firstFrame = -1;
+	int _plays = 1;
+	int _maxPlays = 0;			// 0 for no end
+};
+
+// Nancy24: a record that waits, and calls its OnDone when it is over. A timer
+// is over after a fixed duration, after a random duration between minDuration
+// and maxDuration, or once its frame counter has finished all its plays.
+// Scripts can start a timer over with new values, by passing them to its Reset
+// or Restart.
+class TimerRecord : public Record {
+public:
+	TimerRecord(SceneContext &context);
+
+protected:
+	void readTable(int tableIndex) override;
+	void run(double sceneTime, double elapsedTime) override;
+	bool prepareReset() override;
+	bool isPaused() const override { return _isPaused; }
+	bool getField(const Common::String &key) override;
+	bool setField(const Common::String &key) override;
+
+private:
+	bool hasDuration() const { return _minDuration != -1.0 || _maxDuration != -1.0; }
+
+	// Picks the duration, and sets the counter to a single frame that lasts
+	// that long
+	void pickDuration();
+
+	PlayCounter _counter;
+	double _minDuration = -1.0;
+	double _maxDuration = -1.0;
+	bool _isPaused = false;
+};
+
+} // End of namespace Script
+} // End of namespace Nancy
+
+#endif // NANCY_SCRIPT_TIMER_H


Commit: 744c613b2ebe79af4190cc467820ac4977909476
    https://github.com/scummvm/scummvm/commit/744c613b2ebe79af4190cc467820ac4977909476
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:38+02:00

Commit Message:
NANCY: NANCY24: Add detection entry

Marked as unstable, as the game can now start

Changed paths:
    engines/nancy/detection_tables.h


diff --git a/engines/nancy/detection_tables.h b/engines/nancy/detection_tables.h
index 0d3b427d23e..23e3be0a3a9 100644
--- a/engines/nancy/detection_tables.h
+++ b/engines/nancy/detection_tables.h
@@ -884,6 +884,14 @@ static const ADGameDescription gameDescriptions[] = {
 		ADGF_UNSTABLE | ADGF_DROPPLATFORM,
 		NANCY_GUIOPTIONS
 	},
+	{ // MD5 by bluegr
+		"nancy24", nullptr,
+		AD_ENTRY1s("ciftree.dat", "1a418226443084fc802f20a8465b6605", 78604194),
+		Common::EN_ANY,
+		Common::kPlatformWindows,
+		ADGF_UNSTABLE | ADGF_DROPPLATFORM,
+		NANCY_GUIOPTIONS
+	},
 
 	// Do not delete
 	AD_TABLE_END_MARKER


Commit: 99acf49c6febfd0efd5bcd73904f6d94e277f7e1
    https://github.com/scummvm/scummvm/commit/99acf49c6febfd0efd5bcd73904f6d94e277f7e1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:39+02:00

Commit Message:
NANCY: NANCY19: Hide an NDUI panel on every hide

Nancy16 hides a panel only after as many hides as it was shown. From
Nancy19 on, every hide hides it. Nancy25 opens the phone without
showing its panel, so the phone couldn't be closed after a call.

Changed paths:
    engines/nancy/ui/ndui/panel.cpp


diff --git a/engines/nancy/ui/ndui/panel.cpp b/engines/nancy/ui/ndui/panel.cpp
index ef735625867..31e25c32f6e 100644
--- a/engines/nancy/ui/ndui/panel.cpp
+++ b/engines/nancy/ui/ndui/panel.cpp
@@ -566,7 +566,7 @@ void Panel::finishBlending() {
 	_isDirty = true;
 }
 
-// Every show needs a matching hide before the panel goes away
+// Before Nancy19, every show needs a matching hide before the panel goes away
 void Panel::show() {
 	++_showCount;
 	if (_isCollapsed) {
@@ -597,20 +597,31 @@ void Panel::setCollapsed(bool isCollapsed) {
 	}
 }
 
+// Nancy19 and up don't count: a hide always hides, and tells the scripts. Nancy25
+// opens the phone without showing its panel, and closes it by hiding that.
 void Panel::hide() {
-	--_showCount;
-	if (_showCount == 0) {
-		setVisible(false);
-		_isShownWhenExpanded = false;
-		if (_capture) {
-			_capture->_isPressed = false;
-			_capture = nullptr;
+	if (g_nancy->getGameType() < kGameTypeNancy19) {
+		--_showCount;
+		if (_showCount < 0) {
+			_showCount = 0;
+			return;
 		}
 
-		fireEvent(kEventHide);
-	} else if (_showCount < 0) {
+		if (_showCount > 0) {
+			return;
+		}
+	} else {
 		_showCount = 0;
 	}
+
+	setVisible(false);
+	_isShownWhenExpanded = false;
+	if (_capture) {
+		_capture->_isPressed = false;
+		_capture = nullptr;
+	}
+
+	fireEvent(kEventHide);
 }
 
 void Panel::fireEvent(int32 eventType) {


Commit: b2f5cffd131da520abd62c3214adb3892be53d02
    https://github.com/scummvm/scummvm/commit/b2f5cffd131da520abd62c3214adb3892be53d02
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:40+02:00

Commit Message:
NANCY: NANCY19: Run engine calls on the coroutine that is running

Code in a coroutine runs on a Lua stack of its own, but the engine kept
using the main one, so a coroutine couldn't read the fields of records.
Nancy25's phone journal loads its entries that way, and stopped with
errors once Bess took over a call.

Changed paths:
    engines/nancy/script/luastate.cpp
    engines/nancy/script/luastate.h


diff --git a/engines/nancy/script/luastate.cpp b/engines/nancy/script/luastate.cpp
index dfec58c56cb..842cdc31058 100644
--- a/engines/nancy/script/luastate.cpp
+++ b/engines/nancy/script/luastate.cpp
@@ -36,8 +36,9 @@
 namespace Nancy {
 namespace Script {
 
-// Registry key of the scene a state belongs to
+// Registry keys of the scene a state belongs to, and of the state itself
 static const char kContextKey = 0;
+static const char kStateKey = 0;
 
 static void openLibrary(lua_State *L, lua_CFunction open, const char *name) {
 	lua_pushcfunction(L, open);
@@ -167,12 +168,80 @@ static int stringCompareNoCase(lua_State *L) {
 	return compareStrings(L, true);
 }
 
+static LuaState *getState(lua_State *L) {
+	lua_pushlightuserdata(L, (void *)const_cast<char *>(&kStateKey));
+	lua_rawget(L, LUA_REGISTRYINDEX);
+	LuaState *state = (LuaState *)lua_touserdata(L, -1);
+	lua_pop(L, 1);
+	return state;
+}
+
+// The code of a coroutine runs on a thread of its own. The engine's functions
+// work on the thread that is running, which the two below keep track of; a
+// record that a coroutine reads a field of has to find the key on its stack.
+void LuaState::resume(lua_State *L, int functionIndex) {
+	LuaState *state = getState(L);
+	lua_State *previous = state->_running;
+	state->_running = lua_tothread(L, functionIndex + 1);
+
+	const int status = lua_pcall(L, lua_gettop(L) - functionIndex, LUA_MULTRET, 0);
+	state->_running = previous;
+	if (status != 0) {
+		lua_error(L);
+	}
+}
+
+// coroutine.resume(coroutine, ...)
+int LuaState::resumeCoroutine(lua_State *L) {
+	luaL_argcheck(L, lua_isthread(L, 1), 1, "coroutine expected");
+
+	lua_pushvalue(L, lua_upvalueindex(1));
+	lua_insert(L, 1);
+	resume(L, 1);
+	return lua_gettop(L);
+}
+
+// coroutine.wrap(function) gives a function that resumes a new coroutine, and
+// raises its errors where it was called, like the one of the library
+int LuaState::wrapCoroutine(lua_State *L) {
+	lua_pushvalue(L, lua_upvalueindex(1));
+	lua_pushvalue(L, 1);
+	lua_call(L, 1, 1);
+
+	lua_pushvalue(L, lua_upvalueindex(2));
+	lua_pushcclosure(L, callWrappedCoroutine, 2);
+	return 1;
+}
+
+int LuaState::callWrappedCoroutine(lua_State *L) {
+	lua_pushvalue(L, lua_upvalueindex(2));
+	lua_insert(L, 1);
+	lua_pushvalue(L, lua_upvalueindex(1));
+	lua_insert(L, 2);
+	resume(L, 1);
+
+	if (!lua_toboolean(L, 1)) {
+		lua_settop(L, 2);
+		if (lua_isstring(L, -1)) {
+			luaL_where(L, 1);
+			lua_insert(L, -2);
+			lua_concat(L, 2);
+		}
+
+		lua_error(L);
+	}
+
+	return lua_gettop(L) - 1;
+}
+
 LuaState::LuaState(SceneContext *context) {
 	_state = luaL_newstate();
 	if (!_state) {
 		error("Could not create a Lua state");
 	}
 
+	_running = _state;
+
 	// Scripts get the base, table, string and math libraries, minus what
 	// would let them run other code or reach outside of the game
 	openLibrary(_state, luaopen_base, "");
@@ -180,6 +249,17 @@ LuaState::LuaState(SceneContext *context) {
 	openLibrary(_state, luaopen_string, LUA_STRLIBNAME);
 	openLibrary(_state, luaopen_math, LUA_MATHLIBNAME);
 
+	// resume and wrap go through the originals, the latter through create
+	lua_getglobal(_state, "coroutine");
+	lua_getfield(_state, -1, "create");
+	lua_getfield(_state, -2, "resume");
+	lua_pushvalue(_state, -1);
+	lua_pushcclosure(_state, resumeCoroutine, 1);
+	lua_setfield(_state, -4, "resume");
+	lua_pushcclosure(_state, wrapCoroutine, 2);
+	lua_setfield(_state, -2, "wrap");
+	lua_pop(_state, 1);
+
 	if (g_nancy->getGameType() >= kGameTypeNancy20) {
 		setLibraryFunction(_state, LUA_TABLIBNAME, "sort", tableSort);
 		setLibraryFunction(_state, LUA_MATHLIBNAME, "isnan", mathIsNaN);
@@ -222,6 +302,10 @@ LuaState::LuaState(SceneContext *context) {
 	lua_pushlightuserdata(_state, context);
 	lua_rawset(_state, LUA_REGISTRYINDEX);
 
+	lua_pushlightuserdata(_state, (void *)const_cast<char *>(&kStateKey));
+	lua_pushlightuserdata(_state, this);
+	lua_rawset(_state, LUA_REGISTRYINDEX);
+
 	registerAPI(_state);
 }
 
@@ -250,17 +334,17 @@ bool LuaState::runScript(const Common::String &name) {
 	delete stream;
 
 	Common::String chunkName = "=" + name;
-	int status = luaL_loadbuffer(_state, buffer, size, chunkName.c_str());
+	int status = luaL_loadbuffer(_running, buffer, size, chunkName.c_str());
 	delete[] buffer;
 
 	if (status != 0) {
-		warning("Could not load script %s: %s", name.c_str(), lua_tostring(_state, -1));
-		lua_pop(_state, 1);
+		warning("Could not load script %s: %s", name.c_str(), lua_tostring(_running, -1));
+		lua_pop(_running, 1);
 		return false;
 	}
 
 	Common::String what = "Failed initial run-through of script " + name;
-	return call(_state, 0, 0, what.c_str());
+	return call(_running, 0, 0, what.c_str());
 }
 
 bool LuaState::call(lua_State *L, int numArgs, int numResults, const char *what) {
diff --git a/engines/nancy/script/luastate.h b/engines/nancy/script/luastate.h
index fbdfbb389cf..0524023a3ec 100644
--- a/engines/nancy/script/luastate.h
+++ b/engines/nancy/script/luastate.h
@@ -41,7 +41,9 @@ public:
 	LuaState(SceneContext *context = nullptr);
 	~LuaState();
 
-	lua_State *get() const { return _state; }
+	// The thread whose code is running: the state itself, or one of the
+	// coroutines of its scripts while it runs
+	lua_State *get() const { return _running; }
 
 	// Loads the script of that name and runs its main chunk. Returns false when
 	// there is no such script, or when it fails.
@@ -55,7 +57,16 @@ public:
 	static SceneContext *getContext(lua_State *L);
 
 private:
+	static int resumeCoroutine(lua_State *L);
+	static int wrapCoroutine(lua_State *L);
+	static int callWrappedCoroutine(lua_State *L);
+
+	// Calls the original coroutine.resume, which is at the index below the
+	// coroutine and its arguments, with that coroutine as the running thread
+	static void resume(lua_State *L, int functionIndex);
+
 	lua_State *_state;
+	lua_State *_running;
 };
 
 } // End of namespace Script


Commit: 2001dabd799f37c12d3d85264f47c14b45a9a238
    https://github.com/scummvm/scummvm/commit/2001dabd799f37c12d3d85264f47c14b45a9a238
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:42+02:00

Commit Message:
NANCY: NANCY19: Fix clicks on rotated hotspots

A rotated or scaled hotspot now maps the mouse back through its
transform, so it reacts to clicks where it is drawn. Before, only two of
its corners were transformed, so the pieces of Nancy25's stacking
puzzle couldn't be picked up again after they were rotated.

Changed paths:
    engines/nancy/script/records.cpp


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index cd5ec8392fd..659a63243ed 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -719,17 +719,19 @@ void NavLogicRecord::run(double sceneTime, double elapsedTime) {
 	}
 }
 
+// The mouse is taken back to where the hotspot was before the transform, so a
+// turned hotspot is turned with its picture
 bool NavLogicRecord::isOver(const ScriptPoint &point) const {
-	if (!_ref) {
-		return transformRect(_hotspot, getTransform()).contains(point.x, point.y);
-	}
-
 	double x = point.x;
 	double y = point.y;
 	getTransform().inverse().transformPoint(x, y);
 
 	int refX = (int)x;
 	int refY = (int)y;
+	if (!_ref) {
+		return _hotspot.contains(refX, refY);
+	}
+
 	if (!_source.isEmpty() || !_hotspot.isEmpty()) {
 		if (!_hotspot.contains(refX, refY)) {
 			return false;


Commit: b3913a5074907f9a0a804239e475bd11cd1eaa9f
    https://github.com/scummvm/scummvm/commit/b3913a5074907f9a0a804239e475bd11cd1eaa9f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:43+02:00

Commit Message:
NANCY: NANCY19: Only draw the visible part of resized pictures

A rotated, resized or tinted picture gets drawn pixel by pixel. Only
its part inside the viewport is drawn now, and its pixels are copied as
they are when it isn't tinted. Nancy22's driving scenes and Nancy25's
map, which are far larger than the viewport, were very slow.

Changed paths:
    engines/nancy/script/records.cpp


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 659a63243ed..eef6f18265d 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -170,8 +170,6 @@ static const uint32 kNoModColor = 0xFFFFFFFF;
 // end up around, and so does a color the picture gets multiplied with, which
 // can darken it or make it see-through.
 static void placePicture(RecordGraphic &graphic, Graphics::ManagedSurface &image, const Common::Rect &source, const ScriptRect &dest, const ScriptMatrix &transform, uint32 modColor) {
-	// Larger than anything a script shows, and small enough to draw quickly
-	const int kMaxSize = 2048;
 	const int kLimit = 16000;
 
 	const bool isMovedOnly = transform.isTranslation();
@@ -193,7 +191,8 @@ static void placePicture(RecordGraphic &graphic, Graphics::ManagedSurface &image
 	const double offsetY = transform.m[3][1];
 	const double determinant = a * d - b * c;
 
-	Common::Rect area = getTransformedDest(dest, transform, source.width(), source.height());
+	const Common::Rect placed = getTransformedDest(dest, transform, source.width(), source.height());
+	Common::Rect area = placed;
 	if (!isMovedOnly) {
 		double minX = 0.0;
 		double minY = 0.0;
@@ -212,8 +211,19 @@ static void placePicture(RecordGraphic &graphic, Graphics::ManagedSurface &image
 
 		area.left = CLIP<int>((int)floor(minX), -kLimit, kLimit);
 		area.top = CLIP<int>((int)floor(minY), -kLimit, kLimit);
-		area.right = area.left + CLIP<int>((int)ceil(maxX) - area.left, 1, kMaxSize);
-		area.bottom = area.top + CLIP<int>((int)ceil(maxY) - area.top, 1, kMaxSize);
+		area.right = CLIP<int>((int)ceil(maxX), area.left, kLimit);
+		area.bottom = CLIP<int>((int)ceil(maxY), area.top, kLimit);
+	}
+
+	// Nothing shows outside the viewport, so only the part inside it gets drawn.
+	// The map of Nancy25 is far larger than the viewport when zoomed in.
+	const VIEW *viewport = GetEngineData(VIEW);
+	assert(viewport);
+
+	area.clip(Common::Rect(viewport->screenPosition.width(), viewport->screenPosition.height()));
+	const bool isOnScreen = !area.isEmpty();
+	if (!isOnScreen) {
+		area = Common::Rect(1, 1);
 	}
 
 	// Drawn with an alpha of its own, in place of the color that stands for
@@ -233,32 +243,56 @@ static void placePicture(RecordGraphic &graphic, Graphics::ManagedSurface &image
 	const uint modB = modColor & 0xFF;
 
 	// A picture squashed flat, or one without a size, shows nothing
-	const bool canDraw = isMovedOnly || (fabs(determinant) > 1e-9 && dest.width() != 0 && dest.height() != 0);
+	const bool canDraw = isOnScreen && (isMovedOnly || (fabs(determinant) > 1e-9 && dest.width() != 0 && dest.height() != 0));
 	const double scaleX = dest.width() != 0 ? (double)source.width() / dest.width() : 0.0;
 	const double scaleY = dest.height() != 0 ? (double)source.height() / dest.height() : 0.0;
 
+	// Back from the viewport to where a pixel is in the picture, which moves by
+	// the same steps from one pixel to the next
+	const double stepXAcross = d / determinant * scaleX;
+	const double stepYAcross = -b / determinant * scaleY;
+	const double stepXDown = -c / determinant * scaleX;
+	const double stepYDown = a / determinant * scaleY;
+	const double firstX = area.left + 0.5 - offsetX;
+	const double firstY = area.top + 0.5 - offsetY;
+	const double rowStartX = ((firstX * d - firstY * c) / determinant - dest.left) * scaleX;
+	const double rowStartY = ((firstY * a - firstX * b) / determinant - dest.top) * scaleY;
+
+	// A picture in the format drawn into, which keeps its colors, gets copied
+	// as it is
+	const bool isCopied = image.format == out.format && modColor == kNoModColor;
+	const uint32 colorMask = ~(uint32)(image.format.aMax() << image.format.aShift);
+	const uint32 transColor = g_nancy->_graphics->getTransColor() & colorMask;
+
 	for (int y = 0; canDraw && y < out.h; ++y) {
-		for (int x = 0; x < out.w; ++x) {
-			int sourceX = x;
-			int sourceY = y;
+		uint32 *outRow = (uint32 *)out.getBasePtr(0, y);
+		double pictureX = rowStartX + y * stepXDown;
+		double pictureY = rowStartY + y * stepYDown;
+
+		for (int x = 0; x < out.w; ++x, pictureX += stepXAcross, pictureY += stepYAcross) {
+			int sourceX = area.left - placed.left + x;
+			int sourceY = area.top - placed.top + y;
 
 			if (!isMovedOnly) {
-				// Back from the viewport to where the pixel is in the picture
-				const double movedX = area.left + x + 0.5 - offsetX;
-				const double movedY = area.top + y + 0.5 - offsetY;
-				const double placedX = (movedX * d - movedY * c) / determinant;
-				const double placedY = (movedY * a - movedX * b) / determinant;
-
-				sourceX = (int)floor((placedX - dest.left) * scaleX);
-				sourceY = (int)floor((placedY - dest.top) * scaleY);
+				sourceX = (int)floor(pictureX);
+				sourceY = (int)floor(pictureY);
 			}
 
 			if (sourceX < 0 || sourceX >= source.width() || sourceY < 0 || sourceY >= source.height()) {
 				continue;
 			}
 
+			const uint32 pixel = image.getPixel(source.left + sourceX, source.top + sourceY);
+			if (isCopied) {
+				if ((pixel & colorMask) != transColor) {
+					outRow[x] = pixel;
+				}
+
+				continue;
+			}
+
 			byte alpha, red, green, blue;
-			image.format.colorToARGB(image.getPixel(source.left + sourceX, source.top + sourceY), alpha, red, green, blue);
+			image.format.colorToARGB(pixel, alpha, red, green, blue);
 			if (red == transR && green == transG && blue == transB) {
 				continue;
 			}
@@ -267,7 +301,7 @@ static void placePicture(RecordGraphic &graphic, Graphics::ManagedSurface &image
 				alpha = 0xFF;
 			}
 
-			out.setPixel(x, y, out.format.ARGBToColor(alpha * modA / 255, red * modR / 255, green * modG / 255, blue * modB / 255));
+			outRow[x] = out.format.ARGBToColor(alpha * modA / 255, red * modR / 255, green * modG / 255, blue * modB / 255);
 		}
 	}
 


Commit: 9aeae1924102b7a85f2c439f7504a0fb2956b0c5
    https://github.com/scummvm/scummvm/commit/9aeae1924102b7a85f2c439f7504a0fb2956b0c5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:44+02:00

Commit Message:
NANCY: NANCY19: Don't recopy a movie frame when the movie moves

A resized movie copied its whole frame again every time it was moved
or zoomed, even if the frame stayed the same. It now copies it only
when the frame changes. This made the maps in Nancy22's driving scenes
and in Nancy25 choppy, as they are made of large movies that a camera
pans and zooms.

Changed paths:
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index eef6f18265d..d058f75bb8d 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -2221,6 +2221,11 @@ bool MovieRecord::isSeeThrough() const {
 }
 
 void MovieRecord::drawFrame() {
+	_hasFrame = false;
+	applyPosition();
+}
+
+void MovieRecord::applyPosition() {
 	if (isSeeThrough()) {
 		return;
 	}
@@ -2244,12 +2249,15 @@ void MovieRecord::drawFrame() {
 	}
 
 	// Turned, resized or colored frames get drawn anew, the way overlays are
-	if (_frame.w != _player.getWidth() || _frame.h != _player.getHeight()) {
-		_frame.create(_player.getWidth(), _player.getHeight(), g_nancy->_graphics->getScreenPixelFormat());
-	}
+	if (!_hasFrame || _frame.w != _player.getWidth() || _frame.h != _player.getHeight()) {
+		if (_frame.w != _player.getWidth() || _frame.h != _player.getHeight()) {
+			_frame.create(_player.getWidth(), _player.getHeight(), g_nancy->_graphics->getScreenPixelFormat());
+		}
 
-	_frame.clear(0);
-	_player.drawFrame(_frame, Common::Point(0, 0));
+		_frame.clear(0);
+		_player.drawFrame(_frame, Common::Point(0, 0));
+		_hasFrame = true;
+	}
 
 	Common::Rect clipped = source;
 	clipped.clip(Common::Rect(_frame.w, _frame.h));
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index b9c27822220..076af8a3ec6 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -461,8 +461,9 @@ protected:
 
 private:
 	bool isSeeThrough() const;
+	// The movie is at another frame, or shows another part of it
 	void drawFrame();
-	void applyPosition() { drawFrame(); }
+	void applyPosition();
 
 	Common::String _name;
 	MoviePlayer _player;
@@ -471,8 +472,10 @@ private:
 	ScriptRect _dest;
 	uint32 _modColor = 0xFFFFFFFF;	// what the colors of the frames get multiplied with
 
-	// What a turned, resized or colored frame gets drawn from
+	// What a turned, resized or colored frame gets drawn from. It is kept while
+	// the movie stays at the frame, for the transform to move it around.
 	Graphics::ManagedSurface _frame;
+	bool _hasFrame = false;
 
 	int _numLoops = 1;		// 0 for forever
 	int _numPlayed = 0;


Commit: 7b71064570cbb7d7ec20f10b89485c74d86ddc4e
    https://github.com/scummvm/scummvm/commit/7b71064570cbb7d7ec20f10b89485c74d86ddc4e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:45+02:00

Commit Message:
NANCY: NANCY19: Don't redraw hidden overlays when they move

A hidden overlay drew its picture again every time it was moved or
zoomed. It now waits until it is shown. The camera of Nancy22's driving
scenes and Nancy25's map moves the highlights of all its places, which
stay hidden until the mouse is over them, and redrawing them made the
map choppy.

Changed paths:
    engines/nancy/script/records.cpp
    engines/nancy/script/records.h


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index d058f75bb8d..9485c00086c 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -1220,7 +1220,19 @@ void OverlayRecord::readDestTable(Common::Array<ScriptRect> &dests) {
 	lua_pop(L, 1);
 }
 
+// A hidden picture gets placed once it shows again. The map of Nancy25 moves
+// many hidden ones with its camera.
+void OverlayRecord::onTransformChanged() {
+	if (isActive()) {
+		applyRects();
+	} else {
+		_isPlacementStale = true;
+	}
+}
+
 void OverlayRecord::applyRects() {
+	_isPlacementStale = false;
+
 	Common::Rect source = _source.toRect();
 	source.clip(Common::Rect(_image.w, _image.h));
 
@@ -1279,6 +1291,10 @@ void OverlayRecord::updateGraphics() {
 		}
 	}
 
+	if (_isPlacementStale && isActive()) {
+		applyRects();
+	}
+
 	_graphic.setVisible(isActive() && _hasPicture);
 
 	if (_hasAttachment) {
diff --git a/engines/nancy/script/records.h b/engines/nancy/script/records.h
index 076af8a3ec6..c419f56453c 100644
--- a/engines/nancy/script/records.h
+++ b/engines/nancy/script/records.h
@@ -271,7 +271,7 @@ protected:
 	void readTable(int tableIndex) override;
 	void onZChanged() override;
 	bool hasTransform() const override { return true; }
-	void onTransformChanged() override { applyRects(); }
+	void onTransformChanged() override;
 	void renderNow() override;
 	bool getField(const Common::String &key) override;
 	bool setField(const Common::String &key) override;
@@ -289,6 +289,7 @@ private:
 	Common::Array<ScriptRect> _tableDests;		// what it had when last drawn
 	uint32 _modColor = 0xFFFFFFFF;	// what the colors of the picture get multiplied with
 	bool _hasPicture = false;
+	bool _isPlacementStale = false;		// the transform changed while it was hidden
 	RecordGraphic _graphic;
 
 	// The picture as a script had it drawn by itself, which lasts for a frame


Commit: e387dfeb6d643fe6e5a94c5cee0c2c5ec3befd01
    https://github.com/scummvm/scummvm/commit/e387dfeb6d643fe6e5a94c5cee0c2c5ec3befd01
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:46+02:00

Commit Message:
NANCY: NANCY24: Fix the position of pictures drawn with Draw:OVL

Draw:OVL draws into a record's canvas, which covers the viewport, so
its positions are relative to the viewport. They were also moved up by
the viewport's position on the screen, so the highlights of Nancy25's
map showed 55 pixels too high, as did the pictures of Nancy24's
controls and keys puzzles.

Changed paths:
    engines/nancy/script/records.cpp


diff --git a/engines/nancy/script/records.cpp b/engines/nancy/script/records.cpp
index 9485c00086c..ea901ac5a5a 100644
--- a/engines/nancy/script/records.cpp
+++ b/engines/nancy/script/records.cpp
@@ -1382,11 +1382,8 @@ void OverlayRecord::drawCopy(int tableIndex) {
 		return;
 	}
 
-	const VIEW *viewport = GetEngineData(VIEW);
-	assert(viewport);
-	transform.m[3][0] -= viewport->screenPosition.left;
-	transform.m[3][1] -= viewport->screenPosition.top;
-
+	// The target canvas covers the viewport, and record positions are
+	// already relative to the viewport
 	RecordGraphic picture;
 	placePicture(picture, _image, from, dest, transform, modColor);
 	blendPicture(*target, picture, transform.isTranslation() && modColor == kNoModColor, Common::Point());


Commit: 46459c6a74d58c4b226180f27e0c55d04650ded4
    https://github.com/scummvm/scummvm/commit/46459c6a74d58c4b226180f27e0c55d04650ded4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:46+02:00

Commit Message:
NANCY: NANCY21: Speed up particle drawing

Particles now read and write the pixels of their images directly, and
skip the parts of each row that they don't cover. Nancy25's town scenes
have smoke made of over a thousand particles, and were very slow.

Changed paths:
    engines/nancy/script/particles.cpp


diff --git a/engines/nancy/script/particles.cpp b/engines/nancy/script/particles.cpp
index aedee198290..52cdae91dc3 100644
--- a/engines/nancy/script/particles.cpp
+++ b/engines/nancy/script/particles.cpp
@@ -1086,6 +1086,23 @@ static bool projectCorner(double x, double y, const ScriptMatrix &matrix, bool i
 	return point[2] >= 0.0 && point[2] <= point[3];
 }
 
+// Narrows the pixel range [first, last] of a row to the pixels x where
+// start + step * x is in [0, 1), with one pixel of margin on each side, as
+// each pixel is still tested on its own. Returns false if the range is empty.
+static bool narrowSpan(double start, double step, int &first, int &last) {
+	if (step == 0.0) {
+		return start >= 0.0 && start < 1.0;
+	}
+
+	const double atZero = -start / step;
+	const double atOne = (1.0 - start) / step;
+	const double low = CLIP<double>(floor(MIN(atZero, atOne)) - 1.0, first, last + 1.0);
+	const double high = CLIP<double>(ceil(MAX(atZero, atOne)) + 1.0, first - 1.0, last);
+	first = (int)low;
+	last = (int)high;
+	return first <= last;
+}
+
 // A particle is a square of a part of the image, sized, turned and moved into
 // place, then seen through the projection
 void ParticleRecord::drawParticle(const Particle &particle, const ScriptMatrix &transform) {
@@ -1134,46 +1151,76 @@ void ParticleRecord::drawParticle(const Particle &particle, const ScriptMatrix &
 	const int maxX = MIN<int>(target.w - 1, (int)ceil(MAX(MAX(x0, x1), MAX(x2, x3))));
 	const int minY = MAX<int>(0, (int)floor(MIN(MIN(y0, y1), MIN(y2, y3))));
 	const int maxY = MIN<int>(target.h - 1, (int)ceil(MAX(MAX(y0, y1), MAX(y2, y3))));
+	if (minX > maxX || minY > maxY) {
+		return;
+	}
 
+	// Both pictures are in the 32 bit format with alpha, so their pixels are read
+	// directly; that is a lot quicker for the thousands of particles of smoke
 	const Graphics::PixelFormat &format = target.format;
+	assert(format.bytesPerPixel == 4 && _image.format == format);
+
 	const uint32 colorA = particle.color >> 24;
 	const uint32 colorR = (particle.color >> 16) & 0xFF;
 	const uint32 colorG = (particle.color >> 8) & 0xFF;
 	const uint32 colorB = particle.color & 0xFF;
 
+	// Where the middle of a pixel is on the square, from 0 to 1 across and
+	// down, changes by the same amount from one pixel to the next
+	const double inverse = 1.0 / determinant;
+	const double acrossStepX = by * inverse;
+	const double downStepX = -ay * inverse;
+
+	const double uScale = (particle.right - particle.left) * _image.w;
+	const double vScale = (particle.bottom - particle.top) * _image.h;
+	const double uStart = particle.left * _image.w;
+	const double vStart = particle.top * _image.h;
+
 	for (int y = minY; y <= maxY; ++y) {
-		for (int x = minX; x <= maxX; ++x) {
-			// Where the middle of the pixel is on the square, from 0 to 1 across
-			const double px = x + 0.5 - x0;
-			const double py = y + 0.5 - y0;
-			const double across = (px * by - py * bx) / determinant;
-			const double down = (ax * py - ay * px) / determinant;
+		const double px = minX + 0.5 - x0;
+		const double py = y + 0.5 - y0;
+		double across = (px * by - py * bx) * inverse;
+		double down = (ax * py - ay * px) * inverse;
+
+		// The pixels of the row that a turned square covers
+		int first = 0;
+		int last = maxX - minX;
+		if (!narrowSpan(across, acrossStepX, first, last) || !narrowSpan(down, downStepX, first, last)) {
+			continue;
+		}
+
+		across += acrossStepX * first;
+		down += downStepX * first;
+
+		uint32 *row = (uint32 *)target.getBasePtr(0, y);
+		for (int x = minX + first; x <= minX + last; ++x, across += acrossStepX, down += downStepX) {
 			if (across < 0.0 || across >= 1.0 || down < 0.0 || down >= 1.0) {
 				continue;
 			}
 
-			const int u = CLIP<int>((int)(lerp(particle.left, particle.right, across) * _image.w), 0, _image.w - 1);
-			const int v = CLIP<int>((int)(lerp(particle.top, particle.bottom, down) * _image.h), 0, _image.h - 1);
-
-			uint8 a, r, g, b;
-			format.colorToARGB(_image.getPixel(u, v), a, r, g, b);
+			const int u = CLIP<int>((int)(uStart + uScale * across), 0, _image.w - 1);
+			const int v = CLIP<int>((int)(vStart + vScale * down), 0, _image.h - 1);
+			const uint32 source = *(const uint32 *)_image.getBasePtr(u, v);
 
-			const uint32 alpha = a * colorA / 255;
+			const uint32 alpha = ((source >> format.aShift) & 0xFF) * colorA / 255;
 			if (alpha == 0) {
 				continue;
 			}
 
-			uint8 da, dr, dg, db;
-			format.colorToARGB(target.getPixel(x, y), da, dr, dg, db);
+			const uint32 destination = row[x];
+			const uint32 da = (destination >> format.aShift) & 0xFF;
+			const uint32 dr = (destination >> format.rShift) & 0xFF;
+			const uint32 dg = (destination >> format.gShift) & 0xFF;
+			const uint32 db = (destination >> format.bShift) & 0xFF;
 
-			const uint32 sr = r * colorR / 255;
-			const uint32 sg = g * colorG / 255;
-			const uint32 sb = b * colorB / 255;
+			const uint32 sr = ((source >> format.rShift) & 0xFF) * colorR / 255;
+			const uint32 sg = ((source >> format.gShift) & 0xFF) * colorG / 255;
+			const uint32 sb = ((source >> format.bShift) & 0xFF) * colorB / 255;
 			const uint32 outA = alpha + da * (255 - alpha) / 255;
 			const uint32 outR = (sr * alpha + dr * (255 - alpha)) / 255;
 			const uint32 outG = (sg * alpha + dg * (255 - alpha)) / 255;
 			const uint32 outB = (sb * alpha + db * (255 - alpha)) / 255;
-			target.setPixel(x, y, format.ARGBToColor(outA, outR, outG, outB));
+			row[x] = (outA << format.aShift) | (outR << format.rShift) | (outG << format.gShift) | (outB << format.bShift);
 		}
 	}
 }


Commit: 3d02d293ff70a0a5bdcb4ea1c38e547270bae102
    https://github.com/scummvm/scummvm/commit/3d02d293ff70a0a5bdcb4ea1c38e547270bae102
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:48+02:00

Commit Message:
NANCY: NANCY19: Allow saving vectors with Save:Data

Save:Data couldn't save vectors, so Nancy25's stacking puzzle stopped
with an error when it saved its state, and the scene after it couldn't
read that state back. Vectors are now saved as tables of their numbers,
like the original does.

Changed paths:
    engines/nancy/script/gameapi.cpp


diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index f50c6a7edbf..1800d40db6d 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -713,6 +713,15 @@ static void writeSavedUint32(Common::Array<byte> &out, uint32 value) {
 	}
 }
 
+static void writeSavedNumber(Common::Array<byte> &out, double number) {
+	uint64 bits;
+	memcpy(&bits, &number, sizeof(bits));
+
+	out.push_back(kSavedNumber);
+	writeSavedUint32(out, (uint32)bits);
+	writeSavedUint32(out, (uint32)(bits >> 32));
+}
+
 // Packs the value at a stack index. Returns false for what can't be kept.
 static bool writeSavedValue(lua_State *L, int index, Common::Array<byte> &out, int depth) {
 	index = absoluteIndex(L, index);
@@ -724,16 +733,9 @@ static bool writeSavedValue(lua_State *L, int index, Common::Array<byte> &out, i
 	case LUA_TBOOLEAN:
 		out.push_back(lua_toboolean(L, index) ? kSavedTrue : kSavedFalse);
 		return true;
-	case LUA_TNUMBER: {
-		const double number = lua_tonumber(L, index);
-		uint64 bits;
-		memcpy(&bits, &number, sizeof(bits));
-
-		out.push_back(kSavedNumber);
-		writeSavedUint32(out, (uint32)bits);
-		writeSavedUint32(out, (uint32)(bits >> 32));
+	case LUA_TNUMBER:
+		writeSavedNumber(out, lua_tonumber(L, index));
 		return true;
-	}
 	case LUA_TSTRING: {
 		size_t length;
 		const char *text = lua_tolstring(L, index, &length);
@@ -775,7 +777,21 @@ static bool writeSavedValue(lua_State *L, int index, Common::Array<byte> &out, i
 		return true;
 	}
 	case LUA_TUSERDATA: {
-		// Rects are the only objects that can be kept, e.g. the parts of the
+		// The original's vectors are tables of their components, which get
+		// kept as such: Nancy25's StackingWin_SC reads them back with [1] and [2]
+		const ScriptVector *vector = testVector(L, index);
+		if (vector) {
+			out.push_back(kSavedTable);
+			writeSavedUint32(out, (uint32)vector->size);
+			for (int i = 0; i < vector->size; ++i) {
+				writeSavedNumber(out, i + 1);
+				writeSavedNumber(out, vector->v[i]);
+			}
+
+			return true;
+		}
+
+		// Of the other objects only rects can be kept, e.g. the parts of the
 		// screen Nancy23's photo manager gets handed
 		const ScriptRect *rect = testRect(L, index);
 		if (!rect) {


Commit: 0d88efe4cc281a08cd315c6fcbae001e1e7dfcf8
    https://github.com/scummvm/scummvm/commit/0d88efe4cc281a08cd315c6fcbae001e1e7dfcf8
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:48+02:00

Commit Message:
NANCY: NANCY23: Add Point multiplication, negation and text

Points can be multiplied by points or numbers, negated, and turned into
text like "P(10, 20)", and Point.origin gives a new (0, 0). Nancy25's
journal negates a point, so it stopped with an error and the game
showed no interface.

Changed paths:
    engines/nancy/script/types.cpp


diff --git a/engines/nancy/script/types.cpp b/engines/nancy/script/types.cpp
index 1c91df0e890..71a2616620e 100644
--- a/engines/nancy/script/types.cpp
+++ b/engines/nancy/script/types.cpp
@@ -400,17 +400,59 @@ static int pointSubtract(lua_State *L) {
 	return 1;
 }
 
+// Either side can be a number, which multiplies both coordinates
+static ScriptPoint checkPointFactor(lua_State *L, int index) {
+	if (lua_isnumber(L, index)) {
+		const int32 factor = (int32)lua_tonumber(L, index);
+		return ScriptPoint(factor, factor);
+	}
+
+	return checkPoint(L, index);
+}
+
+static int pointMultiply(lua_State *L) {
+	const ScriptPoint a = checkPointFactor(L, 1);
+	const ScriptPoint b = checkPointFactor(L, 2);
+	pushPoint(L, ScriptPoint(a.x * b.x, a.y * b.y));
+	return 1;
+}
+
+static int pointNegate(lua_State *L) {
+	const ScriptPoint &point = checkPoint(L, 1);
+	pushPoint(L, ScriptPoint(-point.x, -point.y));
+	return 1;
+}
+
+static int pointToString(lua_State *L) {
+	const ScriptPoint &point = checkPoint(L, 1);
+	lua_pushstring(L, Common::String::format("P(%d, %d)", point.x, point.y).c_str());
+	return 1;
+}
+
 static const luaL_Reg kPointFunctions[] = {
 	{ "__index", pointIndex },
 	{ "__newindex", pointNewIndex },
 	{ "__eq", pointEquals },
 	{ "__add", pointAdd },
+	{ "__mul", pointMultiply },
 	{ "__sub", pointSubtract },
+	{ "__unm", pointNegate },
+	{ "__tostring", pointToString },
 	{ nullptr, nullptr }
 };
 
+// Point.origin is a new point every time, since scripts can change points
+static int pointHelperIndex(lua_State *L) {
+	if (lua_type(L, 2) == LUA_TSTRING && strcmp(lua_tostring(L, 2), "origin") == 0) {
+		pushPoint(L, ScriptPoint(0, 0));
+		return 1;
+	}
+
+	return indexFunctions(L);
+}
+
 static const luaL_Reg kPointHelperFunctions[] = {
-	{ "__index", indexFunctions },
+	{ "__index", pointHelperIndex },
 	{ "New", pointNew },
 	{ nullptr, nullptr }
 };


Commit: a32f392e2a5ace041e7a3584ac54ee21cc75b49e
    https://github.com/scummvm/scummvm/commit/a32f392e2a5ace041e7a3584ac54ee21cc75b49e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:50+02:00

Commit Message:
NANCY: NANCY24: Draw input-taking streams in front of all others

Nancy25's scrapbook showed the desk behind it through itself. From
Nancy24 on, a stream that takes the input, like the scrapbook, is
drawn in front of all other streams, and any other stream is drawn at
the same depth as the stream that started it.

Changed paths:
    engines/nancy/script/gameapi.cpp
    engines/nancy/state/scenestream.cpp
    engines/nancy/state/scenestream.h


diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index 1800d40db6d..d7fd992cf3d 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -1397,8 +1397,16 @@ static int sceneBeginStream(lua_State *L) {
 		// TODO: "restartParent" and "isUI", which no script sets
 		readField(L, 2, "captureInput", flags.capturesInput);
 
-		// A stream is a step closer than the one that began it
-		flags.zOffset = 1;
+		// Before Nancy24, a stream is a step closer than the one that began it.
+		// From then on, a stream that keeps the input goes 10 in front of the
+		// frontmost stream, which is more than the z of a record spans, and any
+		// other one shares the z of the stream that began it.
+		if (g_nancy->getGameType() < kGameTypeNancy24) {
+			flags.zOffset = 1;
+		} else if (flags.capturesInput) {
+			const State::SceneStreamManager &streams = NancySceneState.getStreams();
+			flags.zOffset = streams.getFrontZOffset() + 10 - streams.getRunningZOffset();
+		}
 	} else {
 		name = luaL_checkstring(L, 2);
 		sceneName = luaL_checkstring(L, 3);
diff --git a/engines/nancy/state/scenestream.cpp b/engines/nancy/state/scenestream.cpp
index 69800a9bd31..404fbe6fa0d 100644
--- a/engines/nancy/state/scenestream.cpp
+++ b/engines/nancy/state/scenestream.cpp
@@ -439,6 +439,17 @@ double SceneStreamManager::getZ(const Common::String &name) const {
 	return stream ? stream->getZOffset() : 0.0;
 }
 
+int32 SceneStreamManager::getFrontZOffset() const {
+	int32 front = 0;
+	for (const SceneStream *stream : _streams) {
+		if (stream && !stream->isEnded()) {
+			front = MAX(front, stream->getZOffset());
+		}
+	}
+
+	return front;
+}
+
 void SceneStreamManager::getStreamNames(Common::Array<Common::String> &names, bool withUI) const {
 	if (withUI && find(kUIStreamName)) {
 		names.push_back(kUIStreamName);
diff --git a/engines/nancy/state/scenestream.h b/engines/nancy/state/scenestream.h
index cae8e099306..d0db739e5d3 100644
--- a/engines/nancy/state/scenestream.h
+++ b/engines/nancy/state/scenestream.h
@@ -245,10 +245,13 @@ public:
 	// What a stream gets drawn with; null when there is no such stream
 	const ViewTransform *getViewTransform(const Common::String &name);
 
-	// Nancy21: where a stream is among the others. Every stream is a step closer
-	// than the one that began it, and the main stream is at 0.
+	// Nancy21: where a stream is among the others. The main stream is at 0.
 	double getZ(const Common::String &name) const;
 
+	// The z of the frontmost stream, and of the one that is running
+	int32 getFrontZOffset() const;
+	int32 getRunningZOffset() const { return _running ? _running->getZOffset() : 0; }
+
 	// Keeps the streams in the saved game, and starts them again after loading
 	void store();
 	void restore();


Commit: 67b8352677e7ffe6085743f2e2632c732af87598
    https://github.com/scummvm/scummvm/commit/67b8352677e7ffe6085743f2e2632c732af87598
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:51+02:00

Commit Message:
NANCY: NANCY24: Add Sound:Duration

Sound:Duration returns how many seconds a sound file plays. Nancy25's
witness tapes puzzle uses it.

Changed paths:
    engines/nancy/script/gameapi.cpp
    engines/nancy/sound.cpp
    engines/nancy/sound.h


diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index d7fd992cf3d..7f0377aaa4c 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -1263,12 +1263,21 @@ static const luaL_Reg kSoundChannelFunctions[] = {
 	{ nullptr, nullptr }
 };
 
+// Sound:Duration(file), Nancy24: how many seconds a sound file plays, or 0 for
+// one that doesn't exist
+static int soundDuration(lua_State *L) {
+	const Audio::Timestamp length = g_nancy->_sound->getFileLength(luaL_checkstring(L, 2));
+	lua_pushnumber(L, (double)length.totalNumberOfFrames() / length.framerate());
+	return 1;
+}
+
 static const luaL_Reg kSoundFunctions[] = {
 	{ "__index", indexFunctions },
 	{ "Stop", soundStop },
 	{ "SetVolume", soundSetVolume },
 	{ "GetVolume", soundGetVolume },
 	{ "IsPlaying", soundIsPlaying },
+	{ "Duration", soundDuration },
 	{ nullptr, nullptr }
 };
 
diff --git a/engines/nancy/sound.cpp b/engines/nancy/sound.cpp
index 204159af73a..234bf20d260 100644
--- a/engines/nancy/sound.cpp
+++ b/engines/nancy/sound.cpp
@@ -759,6 +759,23 @@ Audio::Timestamp SoundManager::getLength(const Common::String &chunkName) {
 	return getLength(_commonSounds[chunkName]);
 }
 
+Audio::Timestamp SoundManager::getFileLength(const Common::String &soundName) {
+	if (soundName == "silence") {
+		return Audio::Timestamp();
+	}
+
+	Common::SeekableReadStream *file = SearchMan.createReadStreamForMember(Common::Path(soundName + ".his"));
+	if (!file) {
+		return Audio::Timestamp();
+	}
+
+	Audio::SeekableAudioStream *stream = makeHISStream(file, DisposeAfterUse::NO);
+	const Audio::Timestamp length = stream ? stream->getLength() : Audio::Timestamp();
+	delete stream;
+	delete file;
+	return length;
+}
+
 void SoundManager::recalculateSoundEffects() {
 	_shouldRecalculate = true;
 
diff --git a/engines/nancy/sound.h b/engines/nancy/sound.h
index 3cc966adf77..c9564cf0809 100644
--- a/engines/nancy/sound.h
+++ b/engines/nancy/sound.h
@@ -132,6 +132,8 @@ public:
 	Audio::Timestamp getLength(uint16 channelID);
 	Audio::Timestamp getLength(const SoundDescription &description);
 	Audio::Timestamp getLength(const Common::String &chunkName);
+	// How long the sound file plays, without loading it into a channel
+	Audio::Timestamp getFileLength(const Common::String &soundName);
 
 	bool isCommonSound(const Common::String &soundName) const { return _commonSounds.contains(soundName); }
 


Commit: 3009f1178019a94b60b19b24fa7711e75a7688df
    https://github.com/scummvm/scummvm/commit/3009f1178019a94b60b19b24fa7711e75a7688df
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:52+02:00

Commit Message:
NANCY: NANCY24: Add path waypoints

A path can now hold waypoints, which are sets of named numbers at given
times, and GetInterpolants blends them for any time in between.
Nancy25's map moves the car along such a path.

Changed paths:
    engines/nancy/script/mathtypes.cpp


diff --git a/engines/nancy/script/mathtypes.cpp b/engines/nancy/script/mathtypes.cpp
index 21d53bb9b70..056a4f820d3 100644
--- a/engines/nancy/script/mathtypes.cpp
+++ b/engines/nancy/script/mathtypes.cpp
@@ -20,6 +20,8 @@
  */
 
 #include "common/array.h"
+#include "common/hash-str.h"
+#include "common/hashmap.h"
 #include "common/scummsys.h"
 #include "common/util.h"
 
@@ -902,15 +904,22 @@ static const luaL_Reg kQuaternionHelperFunctions[] = {
 // for the car of the driving game that plays back a recorded drive, and Nancy23
 // for the dot that moves along the metro map.
 // Path:New{ { x, y, time }, ... } takes them in the order of their times.
+// From Nancy24 on, a path holds waypoints instead: named numbers at a time,
+// which Nancy25 moves the car on its map with.
 // TODO: The curves through the places that path:GetPosition(time, false) gives,
 // and RemovePoint, GetGuides and SetGuides, which no script uses
 static const char *const kPathType = "ND.Path";
 static const char *const kPathHelperType = "ND.PathHelper";
 
+typedef Common::HashMap<Common::String, double> PathFields;
+
 struct PathPoint {
-	double x;
-	double y;
-	double time;
+	double time = 0.0;
+	PathFields fields;
+
+	double get(const char *name) const {
+		return fields.getValOrDefault(name, 0.0);
+	}
 };
 
 typedef Common::Array<PathPoint> PathPoints;
@@ -935,8 +944,8 @@ static int pathNew(lua_State *L) {
 		lua_getfield(L, -1, "x");
 		lua_getfield(L, -2, "y");
 		lua_getfield(L, -3, "time");
-		points[i].x = luaL_checknumber(L, -3);
-		points[i].y = luaL_checknumber(L, -2);
+		points[i].fields["x"] = luaL_checknumber(L, -3);
+		points[i].fields["y"] = luaL_checknumber(L, -2);
 		points[i].time = luaL_checknumber(L, -1);
 		lua_pop(L, 4);
 	}
@@ -951,22 +960,46 @@ static int pathCollect(lua_State *L) {
 	return 0;
 }
 
+// path.count, Nancy24: how many waypoints there are; path.time: the time of the
+// last one, or 0 when there is none
+static int pathIndex(lua_State *L) {
+	const PathPoints &points = checkPath(L, 1);
+	const Common::String key = luaL_checkstring(L, 2);
+
+	if (key == "count") {
+		lua_pushinteger(L, points.size());
+		return 1;
+	}
+
+	if (key == "time") {
+		lua_pushnumber(L, points.empty() ? 0.0 : points.back().time);
+		return 1;
+	}
+
+	return indexFunctions(L);
+}
+
 // path:AddPoint({ x, y, time }) or path:AddPoint(x, y, time), Nancy20, which
 // puts the place after the ones up to its time
 static int pathAddPoint(lua_State *L) {
 	PathPoints &points = checkPath(L, 1);
 
-	PathPoint point = { 0.0, 0.0, 0.0 };
+	PathPoint point;
+	double x = 0.0;
+	double y = 0.0;
 	if (lua_istable(L, 2)) {
-		readField(L, 2, "x", point.x);
-		readField(L, 2, "y", point.y);
+		readField(L, 2, "x", x);
+		readField(L, 2, "y", y);
 		readField(L, 2, "time", point.time);
 	} else {
-		point.x = luaL_checknumber(L, 2);
-		point.y = luaL_checknumber(L, 3);
+		x = luaL_checknumber(L, 2);
+		y = luaL_checknumber(L, 3);
 		point.time = luaL_checknumber(L, 4);
 	}
 
+	point.fields["x"] = x;
+	point.fields["y"] = y;
+
 	uint index = 0;
 	while (index < points.size() && points[index].time <= point.time) {
 		++index;
@@ -976,6 +1009,101 @@ static int pathAddPoint(lua_State *L) {
 	return 0;
 }
 
+// path:AddWaypoint({ time = t, name = number, ... }), Nancy24: inserts the
+// waypoint in time order, ahead of any waypoints with the same time. Like the
+// original, it removes "time" from the table.
+static int pathAddWaypoint(lua_State *L) {
+	PathPoints &points = checkPath(L, 1);
+	if (!lua_istable(L, 2)) {
+		return luaL_error(L, "AddWaypoint must be fed a table as its sole parameter");
+	}
+
+	PathPoint point;
+	if (!readField(L, 2, "time", point.time)) {
+		return luaL_error(L, "AddWaypoint must be fed a table with a 'time' field");
+	}
+
+	lua_pushnil(L);
+	lua_setfield(L, 2, "time");
+
+	lua_pushnil(L);
+	while (lua_next(L, 2)) {
+		if (lua_type(L, -2) != LUA_TSTRING) {
+			return luaL_error(L, "AddWaypoint only takes named numbers");
+		}
+
+		point.fields[lua_tostring(L, -2)] = luaL_checknumber(L, -1);
+		lua_pop(L, 1);
+	}
+
+	uint index = 0;
+	while (index < points.size() && points[index].time < point.time) {
+		++index;
+	}
+
+	points.insert_at(index, point);
+	return 0;
+}
+
+// path:GetInterpolants(time[, loops]), Nancy24: returns a table of the named
+// numbers at the given time, linearly interpolated between the waypoints on
+// either side of it. A number that only one of the two waypoints has is taken
+// from that waypoint. Before the first waypoint and after the last one, their
+// numbers are returned as is, unless the path loops, in which case it starts
+// over after its last waypoint.
+static int pathGetInterpolants(lua_State *L) {
+	const PathPoints &points = checkPath(L, 1);
+	double time = luaL_checknumber(L, 2);
+	const bool loops = lua_toboolean(L, 3) != 0;
+
+	PathFields result;
+	if (points.size() == 1) {
+		result = points[0].fields;
+	} else if (points.size() > 1) {
+		const double lastTime = points.back().time;
+		if (loops && lastTime > 0.0 && (time >= lastTime || time < 0.0)) {
+			time -= floor(time / lastTime) * lastTime;
+		}
+
+		// The first waypoint after the time
+		uint next = 0;
+		while (next < points.size() && points[next].time <= time) {
+			++next;
+		}
+
+		if (next == 0 || next == points.size()) {
+			result = points[next == 0 ? 0 : next - 1].fields;
+		} else {
+			const PathPoint &from = points[next - 1];
+			const PathPoint &to = points[next];
+			const double progress = (time - from.time) / (to.time - from.time);
+
+			for (const auto &field : from.fields) {
+				PathFields::const_iterator other = to.fields.find(field._key);
+				if (other == to.fields.end()) {
+					result[field._key] = field._value;
+				} else {
+					result[field._key] = field._value + (other->_value - field._value) * progress;
+				}
+			}
+
+			for (const auto &field : to.fields) {
+				if (!result.contains(field._key)) {
+					result[field._key] = field._value;
+				}
+			}
+		}
+	}
+
+	lua_createtable(L, 0, result.size());
+	for (const auto &field : result) {
+		lua_pushnumber(L, field._value);
+		lua_setfield(L, -2, field._key.c_str());
+	}
+
+	return 1;
+}
+
 // path:GetPosition(time[, straight[, loops]]): where the path is at a time, in a
 // straight line between the places around it. A path that loops starts over
 // after its last place; one that doesn't stays at its ends.
@@ -1003,8 +1131,8 @@ static int pathGetPosition(lua_State *L) {
 	}
 
 	if (at) {
-		position.v[0] = at->x;
-		position.v[1] = at->y;
+		position.v[0] = at->get("x");
+		position.v[1] = at->get("y");
 		pushVector(L, position);
 		return 1;
 	}
@@ -1019,17 +1147,19 @@ static int pathGetPosition(lua_State *L) {
 	const double span = to.time - from.time;
 	const double progress = span != 0.0 ? (time - from.time) / span : 0.0;
 
-	position.v[0] = from.x + (to.x - from.x) * progress;
-	position.v[1] = from.y + (to.y - from.y) * progress;
+	position.v[0] = from.get("x") + (to.get("x") - from.get("x")) * progress;
+	position.v[1] = from.get("y") + (to.get("y") - from.get("y")) * progress;
 	pushVector(L, position);
 	return 1;
 }
 
 static const luaL_Reg kPathFunctions[] = {
-	{ "__index", indexFunctions },
+	{ "__index", pathIndex },
 	{ "__gc", pathCollect },
 	{ "GetPosition", pathGetPosition },
 	{ "AddPoint", pathAddPoint },
+	{ "AddWaypoint", pathAddWaypoint },
+	{ "GetInterpolants", pathGetInterpolants },
 	{ nullptr, nullptr }
 };
 


Commit: 0b07d1e41d1e65f69695ac02e9dfc069657c3ca3
    https://github.com/scummvm/scummvm/commit/0b07d1e41d1e65f69695ac02e9dfc069657c3ca3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:53+02:00

Commit Message:
NANCY: NANCY25: Show no text for the empty autotext key

Nancy25's autotext has an entry for the empty key with the text
"%%%", which showed up under the subtitles. The empty key now means
no text.

Changed paths:
    engines/nancy/script/gameapi.cpp
    engines/nancy/ui/ndui/control.cpp


diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index 7f0377aaa4c..8ad53fa8306 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -2057,6 +2057,11 @@ static const luaL_Reg kPlayerFunctions[] = {
 bool findText(const Common::String &key, Common::String &text) {
 	static const char *const kTableNames[] = { "AUTOTEXT", "CONVO" };
 
+	// Nancy25 has an autotext entry for the empty key, which means no text
+	if (key.empty()) {
+		return false;
+	}
+
 	for (const char *tableName : kTableNames) {
 		const CVTX *table = (const CVTX *)g_nancy->getEngineData(tableName);
 		if (table && table->texts.contains(key)) {
diff --git a/engines/nancy/ui/ndui/control.cpp b/engines/nancy/ui/ndui/control.cpp
index 45442cb1078..e57a7406648 100644
--- a/engines/nancy/ui/ndui/control.cpp
+++ b/engines/nancy/ui/ndui/control.cpp
@@ -53,13 +53,14 @@ void Control::read(Common::SeekableReadStream &stream) {
 	if (g_nancy->getGameType() >= kGameTypeNancy17) {
 		readFilename(stream, _tooltip);
 
-		// The texts are the keys of autotext entries, when there are any by their name
+		// Texts and tooltips are autotext keys when an autotext entry by that name
+		// exists. Nancy25 has an entry for the empty key, which is never shown.
 		const CVTX *autotext = (const CVTX *)g_nancy->getEngineData("AUTOTEXT");
-		if (autotext && autotext->texts.contains(_text)) {
+		if (autotext && !_text.empty() && autotext->texts.contains(_text)) {
 			_text = autotext->texts[_text];
 		}
 
-		if (autotext && autotext->texts.contains(_tooltip)) {
+		if (autotext && !_tooltip.empty() && autotext->texts.contains(_tooltip)) {
 			_tooltip = autotext->texts[_tooltip];
 		}
 	}


Commit: b58505404538eece11639a93567cd75b04465d1f
    https://github.com/scummvm/scummvm/commit/b58505404538eece11639a93567cd75b04465d1f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:54+02:00

Commit Message:
NANCY: NANCY25: Allow five player characters

Nancy25 has five playable characters: Bess, George, Nancy, Ned and the
tutorial's character, which the game starts with. Only three were
allowed, so the game couldn't switch to the tutorial's character and
showed no interface or subtitles. Saved games of the earlier games
still store three characters, and only Nancy15's two brothers share
their progress.

Changed paths:
    engines/nancy/commontypes.h
    engines/nancy/puzzledata.cpp
    engines/nancy/state/scene.cpp


diff --git a/engines/nancy/commontypes.h b/engines/nancy/commontypes.h
index 01fc6a52df6..9239a7a1e04 100644
--- a/engines/nancy/commontypes.h
+++ b/engines/nancy/commontypes.h
@@ -54,8 +54,10 @@ static const uint16 kNoSceneNancy17					= 0x7fff;	// what the Nancy17 data has i
 // Nancy15 alternates between three protagonists (Nancy and the Hardy boys
 // Frank and Joe), each of whom keeps their own UI and journal. The two
 // brothers share their progress: whichever is played second inherits it
-// from the other.
-static const uint kMaxPlayerCharacters				= 3;
+// from the other. Nancy25 has five playable characters: Bess, George, Nancy,
+// Ned and the tutorial's character.
+static const uint kMaxPlayerCharactersNancy15		= 3;	// before Nancy25
+static const uint kMaxPlayerCharacters				= 5;
 static const uint kPlayerCharacterFrank				= 1;
 static const uint kPlayerCharacterJoe				= 2;
 
diff --git a/engines/nancy/puzzledata.cpp b/engines/nancy/puzzledata.cpp
index 90f16354238..50f925aa5c5 100644
--- a/engines/nancy/puzzledata.cpp
+++ b/engines/nancy/puzzledata.cpp
@@ -147,6 +147,11 @@ static uint activePlayerCharacterSlot() {
 	return MIN<uint>(g_nancy->getPlayerCharacter(), kMaxPlayerCharacters - 1);
 }
 
+// Saved games of the games before Nancy25 store three characters
+static uint numSavedPlayerCharacters() {
+	return g_nancy->getGameType() >= kGameTypeNancy25 ? kMaxPlayerCharacters : kMaxPlayerCharactersNancy15;
+}
+
 Common::Array<JournalData::Entry> &JournalData::entries(uint16 surfaceID) {
 	return journalEntries[activePlayerCharacterSlot()][surfaceID];
 }
@@ -167,7 +172,7 @@ void JournalData::synchronize(Common::Serializer &ser) {
 	// Nancy15+ protagonists each keep their own journal. Only their slots are
 	// written, so the save format of every earlier game is untouched.
 	if (g_nancy->getGameType() >= kGameTypeNancy15) {
-		for (uint i = 1; i < kMaxPlayerCharacters; ++i) {
+		for (uint i = 1; i < numSavedPlayerCharacters(); ++i) {
 			syncOneJournal(ser, journalEntries[i]);
 		}
 	}
@@ -488,7 +493,7 @@ void CellPhoneData::synchronize(Common::Serializer &ser) {
 	// Nancy15+ protagonists each carry their own phone. Only their slots are
 	// written, so the save format of every earlier game is untouched.
 	if (g_nancy->getGameType() >= kGameTypeNancy15 && ser.getVersion() >= 12) {
-		for (uint i = 1; i < kMaxPlayerCharacters; ++i) {
+		for (uint i = 1; i < numSavedPlayerCharacters(); ++i) {
 			syncPhone(ser, phones[i]);
 		}
 	}
@@ -719,7 +724,7 @@ PlayerCharacterData::Inventory &PlayerCharacterData::getInventory(uint character
 void PlayerCharacterData::synchronize(Common::Serializer &ser) {
 	ser.syncAsUint16LE(characterIndex);
 
-	for (uint i = 0; i < kMaxPlayerCharacters; ++i) {
+	for (uint i = 0; i < numSavedPlayerCharacters(); ++i) {
 		ser.syncString(designs[i]);
 	}
 
@@ -762,7 +767,7 @@ void PlayerCharacterData::synchronize(Common::Serializer &ser) {
 }
 
 void InventorySoundOverrideData::synchronize(Common::Serializer &ser) {
-	for (uint i = 0; i < kMaxPlayerCharacters; ++i) {
+	for (uint i = 0; i < numSavedPlayerCharacters(); ++i) {
 		uint16 count = overrides[i].size();
 		ser.syncAsUint16LE(count);
 
@@ -1110,7 +1115,7 @@ void ScriptPictureData::synchronize(Common::Serializer &ser) {
 }
 
 void ScriptJournalData::synchronize(Common::Serializer &ser) {
-	for (uint i = 0; i < kMaxPlayerCharacters; ++i) {
+	for (uint i = 0; i < numSavedPlayerCharacters(); ++i) {
 		uint16 numEntries = journalEntries[i].size();
 		ser.syncAsUint16LE(numEntries);
 		journalEntries[i].resize(numEntries);
@@ -1132,7 +1137,7 @@ void ScriptJournalData::synchronize(Common::Serializer &ser) {
 }
 
 void PhoneBookData::synchronize(Common::Serializer &ser) {
-	for (uint i = 0; i < kMaxPlayerCharacters; ++i) {
+	for (uint i = 0; i < numSavedPlayerCharacters(); ++i) {
 		uint16 numEntries = entries[i].size();
 		ser.syncAsUint16LE(numEntries);
 		entries[i].resize(numEntries);
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index 2a331d666f4..d7733095545 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -1474,7 +1474,8 @@ void Scene::showInventoryButtons() {
 }
 
 void Scene::inheritBrotherProgress(uint characterIndex) {
-	if (characterIndex != kPlayerCharacterFrank && characterIndex != kPlayerCharacterJoe) {
+	if (g_nancy->getGameType() != kGameTypeNancy15 ||
+			(characterIndex != kPlayerCharacterFrank && characterIndex != kPlayerCharacterJoe)) {
 		return;
 	}
 


Commit: 26c461b8573f2aea2dc002f4537b18502606a26b
    https://github.com/scummvm/scummvm/commit/26c461b8573f2aea2dc002f4537b18502606a26b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:54+02:00

Commit Message:
NANCY: NANCY25: Move the Streams functions to Scene and Game

Nancy25 has no Streams object. Its functions moved to Scene, with
"Stream" in their names (like Scene:GetStreamScene), and
Streams.environment became Game.environment.

Changed paths:
    engines/nancy/script/gameapi.cpp


diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index 8ad53fa8306..aa5f89bfa33 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -451,6 +451,13 @@ static const uint kDifficultySenior = 2;
 static int gameIndex(lua_State *L) {
 	const Common::String key = luaL_checkstring(L, 2);
 
+	// Nancy25: replaces Streams.environment, the environment of the main
+	// stream's scene
+	if (key == "environment") {
+		lua_pushstring(L, NancySceneState.getStreams().getEnvironment().c_str());
+		return 1;
+	}
+
 	if (key == "difficulty") {
 		lua_pushstring(L, NancySceneState.getDifficulty() == kDifficultySenior ? "senior" : "junior");
 		return 1;
@@ -1517,22 +1524,6 @@ static int sceneRecords(lua_State *L) {
 	return 1;
 }
 
-static const luaL_Reg kSceneFunctions[] = {
-	{ "__index", sceneIndex },
-	{ "__newindex", sceneNewIndex },
-	{ "ARs", sceneRecords },
-	{ "Include", sceneInclude },
-	{ "BeginStream", sceneBeginStream },
-	{ "EndStream", sceneEndStream },
-	{ "ChangeScene", sceneChangeScene },
-	{ "GraphNode", sceneGraphNode },
-	{ "TransferChild", sceneTransferChild },
-	// Available since Nancy19, but used by game scripts from Nancy22 onwards
-	{ "Change", sceneChangeScene },
-	{ "Attach", sceneAttach },
-	{ nullptr, nullptr }
-};
-
 // Streams
 
 // Streams.environment is the environment of the main stream's scene
@@ -1616,6 +1607,30 @@ static const luaL_Reg kStreamsFunctions[] = {
 	{ nullptr, nullptr }
 };
 
+static const luaL_Reg kSceneFunctions[] = {
+	{ "__index", sceneIndex },
+	{ "__newindex", sceneNewIndex },
+	{ "ARs", sceneRecords },
+	{ "Include", sceneInclude },
+	{ "BeginStream", sceneBeginStream },
+	{ "EndStream", sceneEndStream },
+	{ "ChangeScene", sceneChangeScene },
+	{ "GraphNode", sceneGraphNode },
+	{ "TransferChild", sceneTransferChild },
+	// Available since Nancy19, but used by game scripts from Nancy22 onwards
+	{ "Change", sceneChangeScene },
+	{ "Attach", sceneAttach },
+	// Nancy25 moved the Streams functions here, with "Stream" in their names
+	{ "GetStreamScene", streamsGetScene },
+	{ "GetStreamTime", streamsGetTime },
+	{ "GetStreamFrame", streamsGetFrame },
+	{ "GetStreams", streamsGetStreams },
+	{ "GetStreamZ", streamsGetZ },
+	{ "GetStreamTransform", streamsGetTransform },
+	{ "SetStreamTransform", streamsSetTransform },
+	{ nullptr, nullptr }
+};
+
 // Hands a message to the scene or the record it is for, or else to the UI.
 // Returns whether a scene or a record took it.
 static bool deliverMessage(lua_State *L, const char *actionName, UI::NDUI::Action &action) {
@@ -2381,11 +2396,15 @@ void registerGameAPI(lua_State *L) {
 	lua_pushstring(L, "<n>");
 	lua_setfield(L, -2, "newline");
 	lua_pop(L, 1);
-	registerGlobal(L, "Streams", "ND.Streams", kStreamsFunctions);
-	luaL_getmetatable(L, "ND.Streams");
-	lua_pushstring(L, State::SceneStreamManager::getMainStreamName());
-	lua_setfield(L, -2, "mainName");
-	lua_pop(L, 1);
+	// Nancy25 has no Streams object, its functions are in Scene and Game
+	if (g_nancy->getGameType() < kGameTypeNancy25) {
+		registerGlobal(L, "Streams", "ND.Streams", kStreamsFunctions);
+		luaL_getmetatable(L, "ND.Streams");
+		lua_pushstring(L, State::SceneStreamManager::getMainStreamName());
+		lua_setfield(L, -2, "mainName");
+		lua_pop(L, 1);
+	}
+
 	registerGlobal(L, "Player", "ND.CurPlayer", kPlayerFunctions);
 	registerGlobal(L, "Message", "ND.Message", kMessageFunctions);
 	registerGlobal(L, "Viewport", "ND.Viewport", kViewportFunctions);


Commit: 9cd8ea4916ae1a6149d6009113f8085b633accc7
    https://github.com/scummvm/scummvm/commit/9cd8ea4916ae1a6149d6009113f8085b633accc7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:55+02:00

Commit Message:
NANCY: NANCY25: Add Game:ShowLink

Game:ShowLink opens a web page in the browser, with the URL taken from
an autotext entry. Nancy25's scrapbook uses it for its links.

Changed paths:
    engines/nancy/script/gameapi.cpp


diff --git a/engines/nancy/script/gameapi.cpp b/engines/nancy/script/gameapi.cpp
index aa5f89bfa33..a9879c8e195 100644
--- a/engines/nancy/script/gameapi.cpp
+++ b/engines/nancy/script/gameapi.cpp
@@ -448,9 +448,28 @@ static const luaL_Reg kKeyFunctions[] = {
 static const uint kDifficultyJunior = 0;
 static const uint kDifficultySenior = 2;
 
+// Game:ShowLink(key), Nancy25: opens the URL in the autotext entry for the
+// key in a web browser. Returns whether it was opened.
+static int gameShowLink(lua_State *L) {
+	const char *key = luaL_checkstring(L, 2);
+
+	Common::String url;
+	if (!findText(key, url)) {
+		return luaL_error(L, "Autotext '%s' not found", key);
+	}
+
+	lua_pushboolean(L, g_system->hasFeature(OSystem::kFeatureOpenUrl) && g_system->openUrl(url));
+	return 1;
+}
+
 static int gameIndex(lua_State *L) {
 	const Common::String key = luaL_checkstring(L, 2);
 
+	if (key == "ShowLink") {
+		lua_pushcfunction(L, gameShowLink);
+		return 1;
+	}
+
 	// Nancy25: replaces Streams.environment, the environment of the main
 	// stream's scene
 	if (key == "environment") {


Commit: c4847c01ba4011d2244b28d7772ae34928f0d044
    https://github.com/scummvm/scummvm/commit/c4847c01ba4011d2244b28d7772ae34928f0d044
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:56+02:00

Commit Message:
NANCY: NANCY25: Add the new fields of particle stages

Nancy25's smoke stopped with errors, as its scripts change where the
particles start through the "min" and "max" fields of the position
stage. These fields can now be read and changed. The color stage also
has "min" and "max" fields now, and darkens each particle by a random
factor between them.

Changed paths:
    engines/nancy/script/particles.cpp


diff --git a/engines/nancy/script/particles.cpp b/engines/nancy/script/particles.cpp
index 52cdae91dc3..0263a27bdc3 100644
--- a/engines/nancy/script/particles.cpp
+++ b/engines/nancy/script/particles.cpp
@@ -238,7 +238,9 @@ private:
 	bool _isAngle;
 };
 
-// "color": the "base" color the image gets multiplied with
+// "color": the "base" color the image gets multiplied with. From Nancy25 on,
+// its red, green and blue are scaled by a random factor between "min" and
+// "max" for each particle.
 class ParticleColorStage : public ParticleStage {
 public:
 	ParticleColorStage(ParticleRecord &record, lua_State *L, int tableIndex) : ParticleStage(record) {
@@ -247,17 +249,36 @@ public:
 			_color = checkColor(L, -1);
 			lua_pop(L, 1);
 		}
+
+		_isScaled = g_nancy->getGameType() >= kGameTypeNancy25;
+		if (_isScaled) {
+			readField(L, tableIndex, "min", _min);
+			readField(L, tableIndex, "max", _max);
+		}
 	}
 
 protected:
 	void initParticles(uint first, uint count) override {
 		for (uint i = first; i < first + count; ++i) {
-			_record.getParticle(i).color = _color;
+			_record.getParticle(i).color = _isScaled ? getScaledColor() : _color;
 		}
 	}
 
 private:
+	// Like the original, the factor is converted to 0-255 and the result is
+	// divided by 256
+	uint32 getScaledColor() const {
+		const uint32 factor = (uint32)(int32)(lerp(_min, _max, randomFraction()) * 255.0);
+		const uint32 red = ((_color >> 16) & 0xFF) * factor >> 8;
+		const uint32 green = ((_color >> 8) & 0xFF) * factor >> 8;
+		const uint32 blue = (_color & 0xFF) * factor >> 8;
+		return (_color & 0xFF000000) | (red & 0xFF) << 16 | (green & 0xFF) << 8 | (blue & 0xFF);
+	}
+
 	uint32 _color = 0xFFFFFFFF;
+	bool _isScaled = false;
+	double _min = 1.0;
+	double _max = 1.0;
 };
 
 // "sources": the parts of the image to pick from, as a list of rects
@@ -486,6 +507,36 @@ public:
 		readVectorField(L, tableIndex, "max", _max, 3);
 	}
 
+	// Nancy25: scripts can read and change "min" and "max", the range of
+	// positions the particles start at
+	bool getField(lua_State *L, const Common::String &key) override {
+		const double *corner = getCorner(key);
+		if (!corner) {
+			return false;
+		}
+
+		pushVector(L, ScriptVector(corner[0], corner[1], corner[2]));
+		return true;
+	}
+
+	bool setField(lua_State *L, const Common::String &key) override {
+		double *corner = getCorner(key);
+		if (!corner) {
+			return false;
+		}
+
+		const ScriptVector *vector = testVector(L, -1);
+		if (!vector) {
+			luaL_typerror(L, -1, "Vector");
+		}
+
+		for (int i = 0; i < 3; ++i) {
+			corner[i] = vector->v[i];
+		}
+
+		return true;
+	}
+
 protected:
 	void initParticles(uint first, uint count) override {
 		for (uint i = first; i < first + count; ++i) {
@@ -496,6 +547,16 @@ protected:
 		}
 	}
 
+	double *getCorner(const Common::String &key) {
+		if (key == "min") {
+			return _min;
+		} else if (key == "max") {
+			return _max;
+		}
+
+		return nullptr;
+	}
+
 private:
 	double _min[3] = { 0.0, 0.0, 0.0 };
 	double _max[3] = { 0.0, 0.0, 0.0 };


Commit: 28803606e9fadaefeeddc24ed947697490b72696
    https://github.com/scummvm/scummvm/commit/28803606e9fadaefeeddc24ed947697490b72696
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-11-03T00:51:56+02:00

Commit Message:
NANCY: NANCY25: Add detection entry

Marked as unstable, as the game now starts

Changed paths:
    engines/nancy/detection_tables.h


diff --git a/engines/nancy/detection_tables.h b/engines/nancy/detection_tables.h
index 23e3be0a3a9..c49c62422af 100644
--- a/engines/nancy/detection_tables.h
+++ b/engines/nancy/detection_tables.h
@@ -892,6 +892,14 @@ static const ADGameDescription gameDescriptions[] = {
 		ADGF_UNSTABLE | ADGF_DROPPLATFORM,
 		NANCY_GUIOPTIONS
 	},
+	{ // MD5 by bluegr
+		"nancy25", nullptr,
+		AD_ENTRY1s("ciftree.dat", "1bd3132fb7ad8998d31e2b64c5978c25", 86918002),
+		Common::EN_ANY,
+		Common::kPlatformWindows,
+		ADGF_UNSTABLE | ADGF_DROPPLATFORM,
+		NANCY_GUIOPTIONS
+	},
 
 	// Do not delete
 	AD_TABLE_END_MARKER




More information about the Scummvm-git-logs mailing list