DIRECTOR: Added stub for SerialPort XObj and automatically preload it

This commit is contained in:
Eugene Sandulenko 2021-08-03 00:47:48 +02:00
parent 7a3a6160be
commit 5e0dc15bb1
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
5 changed files with 202 additions and 0 deletions

View File

@ -42,6 +42,7 @@
#include "director/lingo/xlibs/orthoplayxobj.h"
#include "director/lingo/xlibs/palxobj.h"
#include "director/lingo/xlibs/popupmenuxobj.h"
#include "director/lingo/xlibs/serialportxobj.h"
#include "director/lingo/xlibs/soundjam.h"
#include "director/lingo/xlibs/videodiscxobj.h"
#include "director/lingo/xlibs/winxobj.h"
@ -122,6 +123,7 @@ static struct XLibProto {
{ "PalXObj", PalXObj::open, PalXObj::close, kXObj, 400 }, // D4
{ "PopUp Menu XObj", PopUpMenuXObj::open, PopUpMenuXObj::close, kXObj | kXtraObj, 200 }, // D2
{ "LabelDrv", LabelDrvXObj::open, LabelDrvXObj::close, kXObj, 400 }, // D4
{ "SerialPort", SerialPortXObj::open, SerialPortXObj::close, kXObj | kXtraObj, 200 }, // D2
{ "SoundJam", SoundJam::open, SoundJam::close, kXObj, 400 }, // D4
{ "Videodisc XObj", VideodiscXObj::open, VideodiscXObj::close, kXObj | kXtraObj, 200 }, // D2
{ "winXObj", RearWindowXObj::open, RearWindowXObj::close, kXObj, 400 }, // D4

View File

@ -0,0 +1,144 @@
/* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* Use the SerialPort XObject to send and receive data over the Macintoshs
* two standard serial ports (commonly called the modem and printer ports).
* This XObject is built into Macromedia Director, so you dont have to open
* an XLibrary to use it.
*
* Reference: Director 4 Using Lingo, pages 315-320
*/
#include "director/director.h"
#include "director/lingo/lingo.h"
#include "director/lingo/lingo-object.h"
#include "director/lingo/xlibs/serialportxobj.h"
namespace Director {
static const char *xlibName = "SerialPort";
static MethodProto xlibMethods[] = {
{ "new", SerialPortXObj::m_new, 1, 1, 200 }, // D2
{ "GetPortNum", SerialPortXObj::m_getPortNum, 0, 0, 200 }, // D2
{ "WriteString", SerialPortXObj::m_writeString, 1, 1, 200 }, // D2
{ "WriteChar", SerialPortXObj::m_writeChar, 1, 1, 200 }, // D2
{ "ReadString", SerialPortXObj::m_readString, 0, 0, 200 }, // D2
{ "ReadChar", SerialPortXObj::m_readChar, 0, 0, 200 }, // D2
{ "ReadCount", SerialPortXObj::m_readCount, 0, 0, 200 }, // D2
{ "ReadFlush", SerialPortXObj::m_readFlush, 0, 0, 200 }, // D2
{ "ConfigChan", SerialPortXObj::m_configChan, 2, 2, 200 }, // D2
{ "HShakeChan", SerialPortXObj::m_hShakeChan, 3, 3, 200 }, // D2
{ "SetUp", SerialPortXObj::m_setUp, 3, 3, 200 }, // D2
{ 0, 0, 0, 0, 0 }
};
void SerialPortXObj::open(int type) {
if (type == kXObj) {
SerialPortXObject::initMethods(xlibMethods);
SerialPortXObject *xobj = new SerialPortXObject(kXObj);
g_lingo->_globalvars[xlibName] = xobj;
}
}
void SerialPortXObj::close(int type) {
if (type == kXObj) {
SerialPortXObject::cleanupMethods();
g_lingo->_globalvars[xlibName] = Datum();
}
}
SerialPortXObject::SerialPortXObject(ObjectType ObjectType) :Object<SerialPortXObject>("SerialPort") {
_objType = ObjectType;
}
void SerialPortXObj::m_new(int nargs) {
g_lingo->printSTUBWithArglist("SerialPortXObj::m_new", nargs);
g_lingo->dropStack(nargs);
g_lingo->push(g_lingo->_currentMe);
}
void SerialPortXObj::m_getPortNum(int nargs) {
g_lingo->printSTUBWithArglist("SerialPortXObj::m_getPortNum", nargs);
g_lingo->dropStack(nargs);
g_lingo->push(Datum());
}
void SerialPortXObj::m_writeString(int nargs) {
g_lingo->printSTUBWithArglist("SerialPortXObj::m_writeString", nargs);
g_lingo->dropStack(nargs);
g_lingo->push(Datum());
}
void SerialPortXObj::m_writeChar(int nargs) {
g_lingo->printSTUBWithArglist("SerialPortXObj::m_writeChar", nargs);
g_lingo->dropStack(nargs);
g_lingo->push(Datum());
}
void SerialPortXObj::m_readString(int nargs) {
g_lingo->printSTUBWithArglist("SerialPortXObj::m_readString", nargs);
g_lingo->dropStack(nargs);
g_lingo->push(Datum());
}
void SerialPortXObj::m_readChar(int nargs) {
g_lingo->printSTUBWithArglist("SerialPortXObj::m_readChar", nargs);
g_lingo->dropStack(nargs);
g_lingo->push(Datum());
}
void SerialPortXObj::m_readCount(int nargs) {
g_lingo->printSTUBWithArglist("SerialPortXObj::m_readCount", nargs);
g_lingo->dropStack(nargs);
g_lingo->push(Datum());
}
void SerialPortXObj::m_readFlush(int nargs) {
g_lingo->printSTUBWithArglist("SerialPortXObj::m_readFlush", nargs);
g_lingo->dropStack(nargs);
g_lingo->push(Datum());
}
void SerialPortXObj::m_configChan(int nargs) {
g_lingo->printSTUBWithArglist("SerialPortXObj::m_configChan", nargs);
g_lingo->dropStack(nargs);
g_lingo->push(Datum());
}
void SerialPortXObj::m_hShakeChan(int nargs) {
g_lingo->printSTUBWithArglist("SerialPortXObj::m_hShakeChan", nargs);
g_lingo->dropStack(nargs);
g_lingo->push(Datum());
}
void SerialPortXObj::m_setUp(int nargs) {
g_lingo->printSTUBWithArglist("SerialPortXObj::m_setUp", nargs);
g_lingo->dropStack(nargs);
g_lingo->push(Datum());
}
} // End of namespace Director

View File

@ -0,0 +1,54 @@
/* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef DIRECTOR_LINGO_XLIBS_SERIALPORTXOBJ_H
#define DIRECTOR_LINGO_XLIBS_SERIALPORTXOBJ_H
namespace Director {
class SerialPortXObject : public Object<SerialPortXObject> {
public:
SerialPortXObject(ObjectType objType);
};
namespace SerialPortXObj {
void open(int type);
void close(int type);
void m_new(int nargs);
void m_getPortNum(int nargs);
void m_writeString(int nargs);
void m_writeChar(int nargs);
void m_readString(int nargs);
void m_readChar(int nargs);
void m_readCount(int nargs);
void m_readFlush(int nargs);
void m_configChan(int nargs);
void m_hShakeChan(int nargs);
void m_setUp(int nargs);
} // End of namespace SerialPortXObj
} // End of namespace Director
#endif

View File

@ -44,6 +44,7 @@ MODULE_OBJS = \
lingo/xlibs/palxobj.o \
lingo/xlibs/orthoplayxobj.o \
lingo/xlibs/popupmenuxobj.o \
lingo/xlibs/serialportxobj.o \
lingo/xlibs/soundjam.o \
lingo/xlibs/videodiscxobj.o \
lingo/xlibs/winxobj.o

View File

@ -393,6 +393,7 @@ void Window::loadStartMovieXLibs() {
if (strcmp(g_director->getGameId(), "warlock") == 0 && g_director->getPlatform() == Common::kPlatformMacintosh) {
g_lingo->openXLib("FPlayXObj", kXObj);
}
g_lingo->openXLib("SerialPort", kXObj);
}
} // End of namespace Director