[Scummvm-git-logs] scummvm master -> 1902b94c13efd7740865ffec7612a4f6f1e36919
rvanlaar
noreply at scummvm.org
Sun Mar 6 15:50:06 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1902b94c13 DIRECTOR: LINGO: move XPlayAnim to XObject
Commit: 1902b94c13efd7740865ffec7612a4f6f1e36919
https://github.com/scummvm/scummvm/commit/1902b94c13efd7740865ffec7612a4f6f1e36919
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2022-03-06T16:49:32+01:00
Commit Message:
DIRECTOR: LINGO: move XPlayAnim to XObject
XPlayAnim is an XObject. It was only used as a regular builtin during
development.
Changed paths:
A engines/director/lingo/xlibs/xplayanim.cpp
A engines/director/lingo/xlibs/xplayanim.h
engines/director/lingo/lingo-builtins.cpp
engines/director/lingo/lingo-builtins.h
engines/director/lingo/lingo-object.cpp
engines/director/module.mk
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 2031f696a8a..54f2658b966 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -22,8 +22,6 @@
#include "common/system.h"
#include "common/tokenizer.h"
-#include "video/paco_decoder.h"
-
#include "gui/message.h"
#include "graphics/macgui/macwindowmanager.h"
@@ -226,8 +224,6 @@ static BuiltinProto builtins[] = {
{ "scummvmAssert", LB::b_scummvmassert,1, 2, 200, HBLTIN },
{ "scummvmAssertEqual", LB::b_scummvmassertequal,2,3,200,HBLTIN },
- // Expose Paco
- { "XPlayAnim", LB::b_xPlayAnim, 3,3, 300, HBLTIN },
// XCMD/XFCN (HyperCard), normally exposed
{ "GetVolumes", LB::b_getVolumes, 0, 0, 400, FBLTIN },
@@ -2727,70 +2723,6 @@ void LB::b_scummvmassertequal(int nargs) {
assert(result == 1);
}
-void LB::b_xPlayAnim(int nargs){
- int y = g_lingo->pop().asInt();
- int x = g_lingo->pop().asInt();
- Common::String filename = g_lingo->pop().asString();
-
- debugN(5, "LB::b_xPlayAnim: x: %i y: %i", x, y);
- Video::PacoDecoder *video = new Video::PacoDecoder();
- video->loadFile(Common::Path(filename, g_director->_dirSeparator));
-
- // save the current palette
- byte origPalette[256 * 3];
- uint16 origCount = g_director->getPaletteColorCount();
-
- if (origCount > 256) {
- warning("b_xPlayAnim: too big palette, %d > 256", origCount);
- origCount = 256;
- }
-
- memcpy(origPalette, g_director->getPalette(), origCount * 3);
- Graphics::Surface const *frame;
- Common::Event event;
- bool keepPlaying = true;
- video->start();
- while (!video->endOfVideo()) {
- if (g_system->getEventManager()->pollEvent(event)) {
- switch(event.type) {
- case Common::EVENT_QUIT:
- g_director->processEventQUIT();
- // fallthrough
- case Common::EVENT_KEYDOWN:
- case Common::EVENT_RBUTTONDOWN:
- case Common::EVENT_LBUTTONDOWN:
- keepPlaying = false;
- break;
- default:
- break;
- }
- }
- if (!keepPlaying)
- break;
- if (video->needsUpdate()) {
- frame = video->decodeNextFrame();
- g_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
- }
- if (video->hasDirtyPalette()) {
- byte *palette = const_cast<byte *>(video->getPalette());
- g_director->setPalette(palette, 256);
- }
-
- g_system->updateScreen();
- g_system->delayMillis(10);
-
- }
- // Display the last frame after the video is done
- g_director->getCurrentWindow()->getSurface()->copyRectToSurface(
- frame->getPixels(), frame->pitch, x, y, frame->w, frame->h
- );
-
- video->close();
- delete video;
- // restore the palette
- g_director->setPalette(origPalette, origCount);
-}
-
void LB::b_getVolumes(int nargs) {
// Right now, only "Journeyman Project 2: Buried in Time" is known to check
// for its volume name.
diff --git a/engines/director/lingo/lingo-builtins.h b/engines/director/lingo/lingo-builtins.h
index b9bdadedf4d..5694b9bbc48 100644
--- a/engines/director/lingo/lingo-builtins.h
+++ b/engines/director/lingo/lingo-builtins.h
@@ -194,8 +194,6 @@ void b_numberofwords(int nargs);
void b_scummvmassert(int nargs);
void b_scummvmassertequal(int nargs);
-void b_xPlayAnim(int nargs);
-
// XCMD/XFCN (HyperCard), normally exposed
void b_getVolumes(int nargs);
diff --git a/engines/director/lingo/lingo-object.cpp b/engines/director/lingo/lingo-object.cpp
index ae78e022b23..36fa46ffc8b 100644
--- a/engines/director/lingo/lingo-object.cpp
+++ b/engines/director/lingo/lingo-object.cpp
@@ -48,6 +48,7 @@
#include "director/lingo/xlibs/soundjam.h"
#include "director/lingo/xlibs/videodiscxobj.h"
#include "director/lingo/xlibs/winxobj.h"
+#include "director/lingo/xlibs/xplayanim.h"
namespace Director {
@@ -131,6 +132,7 @@ static struct XLibProto {
{ VideodiscXObj::fileNames, VideodiscXObj::open, VideodiscXObj::close, kXObj, 200 }, // D2
{ RearWindowXObj::fileNames, RearWindowXObj::open, RearWindowXObj::close, kXObj, 400 }, // D4
{ MoveMouseXObj::fileNames, MoveMouseXObj::open, MoveMouseXObj::close, kXObj, 400 }, // D4
+ { XPlayAnim::fileNames, XPlayAnim::open, XPlayAnim::close, kXObj, 300 }, // D3
{ nullptr, nullptr, nullptr, 0, 0 }
};
diff --git a/engines/director/lingo/xlibs/xplayanim.cpp b/engines/director/lingo/xlibs/xplayanim.cpp
new file mode 100644
index 00000000000..7c1a07dc9c9
--- /dev/null
+++ b/engines/director/lingo/xlibs/xplayanim.cpp
@@ -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/>.
+ *
+ */
+
+#include "video/paco_decoder.h"
+
+#include "director/director.h"
+#include "director/window.h"
+#include "director/lingo/lingo.h"
+#include "director/lingo/lingo-object.h"
+#include "director/lingo/xlibs/xplayanim.h"
+
+namespace Director {
+
+const char *XPlayAnim::xlibName = "XPlayAnim";
+const char *XPlayAnim::fileNames[] = {
+ "XPlayAnim",
+ nullptr
+};
+
+static BuiltinProto builtins[] = {
+ { "XPlayAnim", XPlayAnim::b_xplayanim, 3, 3, 300, HBLTIN },
+ { nullptr, nullptr, 0, 0, 0, VOIDSYM }
+};
+
+void XPlayAnim::open(int type) {
+ g_lingo->initBuiltIns(builtins);
+}
+
+void XPlayAnim::close(int type) {
+ g_lingo->cleanupBuiltIns();
+}
+
+void XPlayAnim::b_xplayanim(int nargs) {
+ int y = g_lingo->pop().asInt();
+ int x = g_lingo->pop().asInt();
+ Common::String filename = g_lingo->pop().asString();
+
+ debugN(5, "LB::b_xPlayAnim: x: %i y: %i", x, y);
+ Video::PacoDecoder *video = new Video::PacoDecoder();
+ video->loadFile(Common::Path(filename, g_director->_dirSeparator));
+
+ // save the current palette
+ byte origPalette[256 * 3];
+ uint16 origCount = g_director->getPaletteColorCount();
+
+ if (origCount > 256) {
+ warning("b_xPlayAnim: too big palette, %d > 256", origCount);
+ origCount = 256;
+ }
+
+ memcpy(origPalette, g_director->getPalette(), origCount * 3);
+ Graphics::Surface const *frame;
+ Common::Event event;
+ bool keepPlaying = true;
+ video->start();
+ while (!video->endOfVideo()) {
+ if (g_system->getEventManager()->pollEvent(event)) {
+ switch(event.type) {
+ case Common::EVENT_QUIT:
+ g_director->processEventQUIT();
+ // fallthrough
+ case Common::EVENT_KEYDOWN:
+ case Common::EVENT_RBUTTONDOWN:
+ case Common::EVENT_LBUTTONDOWN:
+ keepPlaying = false;
+ break;
+ default:
+ break;
+ }
+ }
+ if (!keepPlaying)
+ break;
+ if (video->needsUpdate()) {
+ frame = video->decodeNextFrame();
+ g_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
+ }
+ if (video->hasDirtyPalette()) {
+ byte *palette = const_cast<byte *>(video->getPalette());
+ g_director->setPalette(palette, 256);
+ }
+
+ g_system->updateScreen();
+ g_system->delayMillis(10);
+
+ }
+ // Display the last frame after the video is done
+ g_director->getCurrentWindow()->getSurface()->copyRectToSurface(
+ frame->getPixels(), frame->pitch, x, y, frame->w, frame->h
+ );
+
+ video->close();
+ delete video;
+ // restore the palette
+ g_director->setPalette(origPalette, origCount);
+}
+
+} // End of namespace Director
diff --git a/engines/director/lingo/xlibs/xplayanim.h b/engines/director/lingo/xlibs/xplayanim.h
new file mode 100644
index 00000000000..864485b12aa
--- /dev/null
+++ b/engines/director/lingo/xlibs/xplayanim.h
@@ -0,0 +1,50 @@
+/* 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/>.
+ *
+ */
+
+/*************************************
+ *
+ * Xobject to play PACo video files
+ *
+ * USED IN:
+ * Hell Cab, Journeyman Mac, Iron Helix Mac
+ *
+ *************************************/
+
+#ifndef DIRECTOR_LINGO_XLIBS_XPLAYANIMXOBJ_H
+#define DIRECTOR_LINGO_XLIBS_XPLAYANIMXOBJ_H
+
+namespace Director {
+
+namespace XPlayAnim {
+
+extern const char *xlibName;
+extern const char *fileNames[];
+
+void open(int type);
+void close(int type);
+
+void b_xplayanim(int nargs);
+
+} // End of namespace XPlayAnim
+
+} // End of namespace Director
+
+#endif
\ No newline at end of file
diff --git a/engines/director/module.mk b/engines/director/module.mk
index 34cf701b160..b4eb6a8d0eb 100644
--- a/engines/director/module.mk
+++ b/engines/director/module.mk
@@ -50,7 +50,8 @@ MODULE_OBJS = \
lingo/xlibs/serialportxobj.o \
lingo/xlibs/soundjam.o \
lingo/xlibs/videodiscxobj.o \
- lingo/xlibs/winxobj.o
+ lingo/xlibs/winxobj.o \
+ lingo/xlibs/xplayanim.o
# HACK: Skip this when including the file for detection objects.
ifeq "$(USE_RULES)" "1"
More information about the Scummvm-git-logs
mailing list