From 6cf9272bbf0cb9d20f0f86f1f2a75f088928b7e6 Mon Sep 17 00:00:00 2001 From: Scott Percival Date: Fri, 5 Jul 2024 10:04:10 +0800 Subject: [PATCH] DIRECTOR: XOBJ: Add modded version of MoveMouse from Jungle Park --- engines/director/lingo/lingo-object.cpp | 2 + engines/director/lingo/xlibs/movemousejp.cpp | 143 +++++++++++++++++++ engines/director/lingo/xlibs/movemousejp.h | 57 ++++++++ engines/director/module.mk | 1 + 4 files changed, 203 insertions(+) create mode 100644 engines/director/lingo/xlibs/movemousejp.cpp create mode 100644 engines/director/lingo/xlibs/movemousejp.h diff --git a/engines/director/lingo/lingo-object.cpp b/engines/director/lingo/lingo-object.cpp index ecdd2fe0fdb..70eee59f8c5 100644 --- a/engines/director/lingo/lingo-object.cpp +++ b/engines/director/lingo/lingo-object.cpp @@ -89,6 +89,7 @@ #include "director/lingo/xlibs/mmaskxobj.h" #include "director/lingo/xlibs/mmovie.h" #include "director/lingo/xlibs/moovxobj.h" +#include "director/lingo/xlibs/movemousejp.h" #include "director/lingo/xlibs/movemousexobj.h" #include "director/lingo/xlibs/movieidxxobj.h" #include "director/lingo/xlibs/movutils.h" @@ -268,6 +269,7 @@ static struct XLibProto { XLIBDEF(MMaskXObj, kXObj, 400), // D4 XLIBDEF(MoovXObj, kXObj, 300), // D3 XLIBDEF(MovUtilsXObj, kXObj, 400), // D4 + XLIBDEF(MoveMouseJPXObj, kXObj, 400), // D4 XLIBDEF(MoveMouseXObj, kXObj, 400), // D4 XLIBDEF(MovieIdxXObj, kXObj, 400), // D4 XLIBDEF(MovUtilsXObj, kXObj, 400), // D4 diff --git a/engines/director/lingo/xlibs/movemousejp.cpp b/engines/director/lingo/xlibs/movemousejp.cpp new file mode 100644 index 00000000000..d178333dad1 --- /dev/null +++ b/engines/director/lingo/xlibs/movemousejp.cpp @@ -0,0 +1,143 @@ +/* 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 . + * + */ + +#include "common/system.h" + +#include "director/director.h" +#include "director/lingo/lingo.h" +#include "director/lingo/lingo-object.h" +#include "director/lingo/lingo-utils.h" +#include "director/lingo/xlibs/movemousejp.h" + +/************************************************** + * + * USED IN: + * junglepark + * + **************************************************/ + +/* +-- MoveMouse . Implimented by @Sakai Youichi +--MoveMouse +I mNew --Creates a new instance of the XObject +X mDispose --Disposes of XObject instance +S mName --Returns the XObject name (Widget) +I mStatus --Returns an integer status code +SI mError, code --Returns an error string +S mLastError --Returns last error string +III mAdd, arg1, arg2 --Returns arg1+arg2 +SSI mFirst, str, nchars --Return the first nchars of string str +V mMul, f1, f2 --Returns f1*f2 as floating point +X mGlobals --Sample code to Read & Modify globals +X mSymbols --Sample code to work with Symbols +X mSendPerform --Sample code to show SendPerform call +X mFactory --Sample code to find Factory objects +III mSetMouseLoc,h,v --Sample code to find Factory objects +I mWtop --Sample code to find Factory objects +I mWbottom --Sample code to find Factory objects +I mWleft --Sample code to find Factory objects +I mWright --Sample code to find Factory objects +I mCtop --Sample code to find Factory objects +I mCbottom --Sample code to find Factory objects +I mCleft --Sample code to find Factory objects +I mCright --Sample code to find Factory objects +S mGetWindowsDir --GetWindows Directory + */ + +namespace Director { + +const char *MoveMouseJPXObj::xlibName = "MoveMouse"; +const XlibFileDesc MoveMouseJPXObj::fileNames[] = { + { "MOVEWIN", "junglepark" }, + { "MOVEMOUSE", "junglepark" }, + { nullptr, nullptr }, +}; + +static MethodProto xlibMethods[] = { + { "new", MoveMouseJPXObj::m_new, 0, 0, 400 }, + { "dispose", MoveMouseJPXObj::m_dispose, 0, 0, 400 }, + { "setMouseLoc", MoveMouseJPXObj::m_setMouseLoc, 2, 2, 400 }, + { "wtop", MoveMouseJPXObj::m_wtop, 0, 0, 400 }, + { "wbottom", MoveMouseJPXObj::m_wbottom, 0, 0, 400 }, + { "wleft", MoveMouseJPXObj::m_wleft, 0, 0, 400 }, + { "wright", MoveMouseJPXObj::m_wright, 0, 0, 400 }, + { "ctop", MoveMouseJPXObj::m_ctop, 0, 0, 400 }, + { "cbottom", MoveMouseJPXObj::m_cbottom, 0, 0, 400 }, + { "cleft", MoveMouseJPXObj::m_cleft, 0, 0, 400 }, + { "cright", MoveMouseJPXObj::m_cright, 0, 0, 400 }, + { "getWindowsDir", MoveMouseJPXObj::m_getWindowsDir, 0, 0, 400 }, + { nullptr, nullptr, 0, 0, 0 } +}; + +static BuiltinProto xlibBuiltins[] = { + + { nullptr, nullptr, 0, 0, 0, VOIDSYM } +}; + +MoveMouseJPXObject::MoveMouseJPXObject(ObjectType ObjectType) :Object("MoveMouse") { + _objType = ObjectType; +} + +void MoveMouseJPXObj::open(ObjectType type, const Common::Path &path) { + MoveMouseJPXObject::initMethods(xlibMethods); + MoveMouseJPXObject *xobj = new MoveMouseJPXObject(type); + if (type == kXtraObj) + g_lingo->_openXtras.push_back(xlibName); + g_lingo->exposeXObject(xlibName, xobj); + g_lingo->initBuiltIns(xlibBuiltins); +} + +void MoveMouseJPXObj::close(ObjectType type) { + MoveMouseJPXObject::cleanupMethods(); + g_lingo->_globalvars[xlibName] = Datum(); + +} + +void MoveMouseJPXObj::m_new(int nargs) { + g_lingo->printSTUBWithArglist("MoveMouseJPXObj::m_new", nargs); + g_lingo->dropStack(nargs); + g_lingo->push(g_lingo->_state->me); +} + +XOBJSTUBNR(MoveMouseJPXObj::m_dispose) + +void MoveMouseJPXObj::m_setMouseLoc(int nargs) { + if (nargs != 2) { + warning("MoveMouseJPXObj::m_setMouseLoc: expected 2 arguments"); + g_lingo->dropStack(nargs); + return; + } + int y = g_lingo->pop().asInt(); + int x = g_lingo->pop().asInt(); + g_system->warpMouse(x, y); +} + +XOBJSTUB(MoveMouseJPXObj::m_wtop, 0) +XOBJSTUB(MoveMouseJPXObj::m_wbottom, 0) +XOBJSTUB(MoveMouseJPXObj::m_wleft, 0) +XOBJSTUB(MoveMouseJPXObj::m_wright, 0) +XOBJSTUB(MoveMouseJPXObj::m_ctop, 0) +XOBJSTUB(MoveMouseJPXObj::m_cbottom, 0) +XOBJSTUB(MoveMouseJPXObj::m_cleft, 0) +XOBJSTUB(MoveMouseJPXObj::m_cright, 0) +XOBJSTUB(MoveMouseJPXObj::m_getWindowsDir, "") + +} diff --git a/engines/director/lingo/xlibs/movemousejp.h b/engines/director/lingo/xlibs/movemousejp.h new file mode 100644 index 00000000000..89424c4cc7e --- /dev/null +++ b/engines/director/lingo/xlibs/movemousejp.h @@ -0,0 +1,57 @@ +/* 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 . + * + */ + +#ifndef DIRECTOR_LINGO_XLIBS_MOVEMOUSEJP_H +#define DIRECTOR_LINGO_XLIBS_MOVEMOUSEJP_H + +namespace Director { + +class MoveMouseJPXObject : public Object { +public: + MoveMouseJPXObject(ObjectType objType); +}; + +namespace MoveMouseJPXObj { + +extern const char *xlibName; +extern const XlibFileDesc fileNames[]; + +void open(ObjectType type, const Common::Path &path); +void close(ObjectType type); + +void m_new(int nargs); +void m_dispose(int nargs); +void m_setMouseLoc(int nargs); +void m_wtop(int nargs); +void m_wbottom(int nargs); +void m_wleft(int nargs); +void m_wright(int nargs); +void m_ctop(int nargs); +void m_cbottom(int nargs); +void m_cleft(int nargs); +void m_cright(int nargs); +void m_getWindowsDir(int nargs); + +} // End of namespace MoveMouseJPXObj + +} // End of namespace Director + +#endif diff --git a/engines/director/module.mk b/engines/director/module.mk index 494771c5732..f8445e85cde 100644 --- a/engines/director/module.mk +++ b/engines/director/module.mk @@ -118,6 +118,7 @@ MODULE_OBJS = \ lingo/xlibs/mmaskxobj.o \ lingo/xlibs/mmovie.o \ lingo/xlibs/moovxobj.o \ + lingo/xlibs/movemousejp.o \ lingo/xlibs/movemousexobj.o \ lingo/xlibs/movieidxxobj.o \ lingo/xlibs/movutils.o \