1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 /*
24  * Use the SerialPort XObject to send and receive data over the Macintosh’s
25  * two standard serial ports (commonly called the modem and printer ports).
26  * This XObject is built into Macromedia Director, so you don’t have to open
27  * an XLibrary to use it.
28  *
29  * Reference: Director 4 Using Lingo, pages 315-320
30  */
31 
32 #include "director/director.h"
33 #include "director/lingo/lingo.h"
34 #include "director/lingo/lingo-object.h"
35 #include "director/lingo/xlibs/serialportxobj.h"
36 
37 namespace Director {
38 
39 const char *SerialPortXObj::xlibName = "SerialPort";
40 const char *SerialPortXObj::fileNames[] = {
41 	"SerialPort",
42 	0
43 };
44 
45 static MethodProto xlibMethods[] = {
46 	{ "new",				SerialPortXObj::m_new,			 1, 1,	200 },	// D2
47 	{ "GetPortNum",			SerialPortXObj::m_getPortNum,	 0, 0,	200 },	// D2
48 	{ "WriteString",		SerialPortXObj::m_writeString,	 1, 1,	200 },	// D2
49 	{ "WriteChar",			SerialPortXObj::m_writeChar,	 1, 1,	200 },	// D2
50 	{ "ReadString",			SerialPortXObj::m_readString,	 0, 0,  200 },	// D2
51 	{ "ReadChar",			SerialPortXObj::m_readChar,		 0, 0,  200 },	// D2
52 	{ "ReadCount",			SerialPortXObj::m_readCount,	 0, 0,  200 },	// D2
53 	{ "ReadFlush",			SerialPortXObj::m_readFlush,	 0, 0,  200 },	// D2
54 	{ "ConfigChan",			SerialPortXObj::m_configChan,	 2, 2,  200 },	// D2
55 	{ "HShakeChan",			SerialPortXObj::m_hShakeChan,	 3, 3,  200 },	// D2
56 	{ "SetUp",				SerialPortXObj::m_setUp,		 3, 3,  200 },	// D2
57 	{ 0, 0, 0, 0, 0 }
58 };
59 
open(int type)60 void SerialPortXObj::open(int type) {
61 	if (type == kXObj) {
62 		SerialPortXObject::initMethods(xlibMethods);
63 		SerialPortXObject *xobj = new SerialPortXObject(kXObj);
64 		g_lingo->_globalvars[xlibName] = xobj;
65 	}
66 }
67 
close(int type)68 void SerialPortXObj::close(int type) {
69 	if (type == kXObj) {
70 		SerialPortXObject::cleanupMethods();
71 		g_lingo->_globalvars[xlibName] = Datum();
72 	}
73 }
74 
75 
SerialPortXObject(ObjectType ObjectType)76 SerialPortXObject::SerialPortXObject(ObjectType ObjectType) :Object<SerialPortXObject>("SerialPort") {
77 	_objType = ObjectType;
78 }
79 
m_new(int nargs)80 void SerialPortXObj::m_new(int nargs) {
81 	g_lingo->printSTUBWithArglist("SerialPortXObj::m_new", nargs);
82 	g_lingo->dropStack(nargs);
83 	g_lingo->push(g_lingo->_currentMe);
84 }
85 
m_getPortNum(int nargs)86 void SerialPortXObj::m_getPortNum(int nargs) {
87 	g_lingo->printSTUBWithArglist("SerialPortXObj::m_getPortNum", nargs);
88 	g_lingo->dropStack(nargs);
89 	g_lingo->push(Datum());
90 }
91 
m_writeString(int nargs)92 void SerialPortXObj::m_writeString(int nargs) {
93 	g_lingo->printSTUBWithArglist("SerialPortXObj::m_writeString", nargs);
94 	g_lingo->dropStack(nargs);
95 	g_lingo->push(Datum());
96 }
97 
m_writeChar(int nargs)98 void SerialPortXObj::m_writeChar(int nargs) {
99 	g_lingo->printSTUBWithArglist("SerialPortXObj::m_writeChar", nargs);
100 	g_lingo->dropStack(nargs);
101 	g_lingo->push(Datum());
102 }
103 
m_readString(int nargs)104 void SerialPortXObj::m_readString(int nargs) {
105 	g_lingo->printSTUBWithArglist("SerialPortXObj::m_readString", nargs);
106 	g_lingo->dropStack(nargs);
107 	g_lingo->push(Datum());
108 }
109 
m_readChar(int nargs)110 void SerialPortXObj::m_readChar(int nargs) {
111 	g_lingo->printSTUBWithArglist("SerialPortXObj::m_readChar", nargs);
112 	g_lingo->dropStack(nargs);
113 	g_lingo->push(Datum());
114 }
115 
m_readCount(int nargs)116 void SerialPortXObj::m_readCount(int nargs) {
117 	g_lingo->printSTUBWithArglist("SerialPortXObj::m_readCount", nargs);
118 	g_lingo->dropStack(nargs);
119 	g_lingo->push(Datum());
120 }
121 
m_readFlush(int nargs)122 void SerialPortXObj::m_readFlush(int nargs) {
123 	g_lingo->printSTUBWithArglist("SerialPortXObj::m_readFlush", nargs);
124 	g_lingo->dropStack(nargs);
125 	g_lingo->push(Datum());
126 }
127 
m_configChan(int nargs)128 void SerialPortXObj::m_configChan(int nargs) {
129 	g_lingo->printSTUBWithArglist("SerialPortXObj::m_configChan", nargs);
130 	g_lingo->dropStack(nargs);
131 	g_lingo->push(Datum());
132 }
133 
m_hShakeChan(int nargs)134 void SerialPortXObj::m_hShakeChan(int nargs) {
135 	g_lingo->printSTUBWithArglist("SerialPortXObj::m_hShakeChan", nargs);
136 	g_lingo->dropStack(nargs);
137 	g_lingo->push(Datum());
138 }
139 
m_setUp(int nargs)140 void SerialPortXObj::m_setUp(int nargs) {
141 	g_lingo->printSTUBWithArglist("SerialPortXObj::m_setUp", nargs);
142 	g_lingo->dropStack(nargs);
143 	g_lingo->push(Datum());
144 }
145 
146 
147 
148 } // End of namespace Director
149