Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
/* 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/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/x/xcmdglue.h"
/**************************************************
*
* USED IN:
* Standard Macromedia Director XObject
*
**************************************************/
/*
--XCMDGlue, Tool, 1.6.4, 14aug93
--Interface to XCMD's and XFCN's
--© 1989, 1990 MacroMind, Inc.
--by John Thompson
ISI mNew
X mDispose
XI mVerbDispose
S mName
V mVerb
XO mSetHandler
O mGetHandler
*/
namespace Director {
const char *const XCMDGlueXObj::xlibName = "XCMDGlue";
const XlibFileDesc XCMDGlueXObj::fileNames[] = {
{ "XCMDGlue", nullptr },
{ nullptr, nullptr },
};
static const MethodProto xlibMethods[] = {
{ "new", XCMDGlueXObj::m_new, 2, 2, 200 },
{ "dispose", XCMDGlueXObj::m_dispose, 0, 0, 200 },
{ "verbDispose", XCMDGlueXObj::m_verbDispose, 1, 1, 200 },
{ "name", XCMDGlueXObj::m_name, 0, 0, 200 },
{ "verb", XCMDGlueXObj::m_verb, 0, 0, 200 },
{ "setHandler", XCMDGlueXObj::m_setHandler, 1, 1, 200 },
{ "getHandler", XCMDGlueXObj::m_getHandler, 0, 0, 200 },
{ nullptr, nullptr, 0, 0, 0 }
};
XCMDGlueXObject::XCMDGlueXObject(ObjectType ObjectType) :Object<XCMDGlueXObject>("XCMDGlue") {
_objType = ObjectType;
}
void XCMDGlueXObj::open(ObjectType type, const Common::Path &path) {
if (type == kXObj) {
XCMDGlueXObject::initMethods(xlibMethods);
XCMDGlueXObject *xobj = new XCMDGlueXObject(kXObj);
g_lingo->exposeXObject(xlibName, xobj);
}
}
void XCMDGlueXObj::close(ObjectType type) {
if (type == kXObj) {
XCMDGlueXObject::cleanupMethods();
g_lingo->_globalvars[xlibName] = Datum();
}
}
void XCMDGlueXObj::m_new(int nargs) {
g_lingo->printSTUBWithArglist("XCMDGlueXObj::m_new", nargs);
g_lingo->dropStack(nargs);
g_lingo->push(g_lingo->_state->me);
}
XOBJSTUBNR(XCMDGlueXObj::m_dispose)
XOBJSTUBNR(XCMDGlueXObj::m_verbDispose)
XOBJSTUB(XCMDGlueXObj::m_name, "")
XOBJSTUB(XCMDGlueXObj::m_verb, 0)
XOBJSTUBNR(XCMDGlueXObj::m_setHandler)
XOBJSTUB(XCMDGlueXObj::m_getHandler, 0)
}

View File

@@ -0,0 +1,52 @@
/* 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 DIRECTOR_LINGO_XLIBS_XCMDGLUE_H
#define DIRECTOR_LINGO_XLIBS_XCMDGLUE_H
namespace Director {
class XCMDGlueXObject : public Object<XCMDGlueXObject> {
public:
XCMDGlueXObject(ObjectType objType);
};
namespace XCMDGlueXObj {
extern const char *const 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_verbDispose(int nargs);
void m_name(int nargs);
void m_verb(int nargs);
void m_setHandler(int nargs);
void m_getHandler(int nargs);
} // End of namespace XCMDGlueXObj
} // End of namespace Director
#endif

View File

@@ -0,0 +1,101 @@
/* 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/>.
*
*/
/*************************************
*
* USED IN:
* מיץ פטל (Mitz Petel)
*
*************************************/
/*
* -- Xio - Functions for file manipulation 10Aug96 Moty Aharobnovitz
* xio
* I mNew --Creates a new instance of the XObject
* X mDispose --Disposes of XObject instance
* IS mUnlock --Given a correct code, enables usage of the Xobject
* IS mDeleteFile --Removes a file from the file system
* ISS mCopyFile --Copies a file from source to dest
*/
#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/x/xio.h"
namespace Director {
const char *const XioXObj::xlibName = "Xio";
const XlibFileDesc XioXObj::fileNames[] = {
{ "XIO", nullptr },
{ nullptr, nullptr },
};
static const MethodProto xlibMethods[] = {
{ "New", XioXObj::m_new, 0, 0, 400 }, // D4
{ "Dispose", XioXObj::m_dispose, 0, 0, 400 }, // D4
{ "Unlock", XioXObj::m_unlock, 1, 1, 400 }, // D4
{ "DeleteFile", XioXObj::m_deleteFile, 1, 1, 400 }, // D4
{ "CopyFile", XioXObj::m_copyFile, 2, 2, 400 }, // D4
{ nullptr, nullptr, 0, 0, 0 }
};
void XioXObj::open(ObjectType type, const Common::Path &path) {
if (type == kXObj) {
XioXObject::initMethods(xlibMethods);
XioXObject *xobj = new XioXObject(kXObj);
g_lingo->exposeXObject(xlibName, xobj);
}
}
void XioXObj::close(ObjectType type) {
if (type == kXObj) {
XioXObject::cleanupMethods();
g_lingo->_globalvars[xlibName] = Datum();
}
}
XioXObject::XioXObject(ObjectType ObjectType) :Object<XioXObject>("Xio") {
_objType = ObjectType;
}
void XioXObj::m_new(int nargs) {
g_lingo->push(g_lingo->_state->me);
}
void XioXObj::m_dispose(int nargs) {
g_lingo->printSTUBWithArglist("XioXObj::m_dispose", nargs);
g_lingo->dropStack(nargs);
}
void XioXObj::m_unlock(int nargs) {
Common::String unlockPassword = g_lingo->pop().asString();
warning("XioXObj::m_unlock: Unlocked with password \"%s\"", unlockPassword.c_str());
g_lingo->push(Datum(1));
}
XOBJSTUB(XioXObj::m_deleteFile, 1)
XOBJSTUB(XioXObj::m_copyFile, 1)
} // End of namespace Director

View File

@@ -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/>.
*
*/
#ifndef DIRECTOR_LINGO_XLIBS_XIOXOBJ_H
#define DIRECTOR_LINGO_XLIBS_XIOXOBJ_H
namespace Director {
class XioXObject : public Object<XioXObject> {
public:
XioXObject(ObjectType objType);
};
namespace XioXObj {
extern const char *const 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_unlock(int nargs);
void m_deleteFile(int nargs);
void m_copyFile(int nargs);
} // End of namespace XioXObj
} // End of namespace Director
#endif

View File

@@ -0,0 +1,128 @@
/* 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/>.
*
*/
/*************************************
*
* USED IN:
* Iron Helix
*
*************************************/
#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/x/xplayanim.h"
namespace Director {
const char *const XPlayAnim::xlibName = "XPlayAnim";
const XlibFileDesc XPlayAnim::fileNames[] = {
{ "XPlayAnim", nullptr },
{ nullptr, nullptr },
};
static const BuiltinProto builtins[] = {
{ "XPlayAnim", XPlayAnim::b_xplayanim, 3, 3, 300, HBLTIN },
{ nullptr, nullptr, 0, 0, 0, VOIDSYM }
};
void XPlayAnim::open(ObjectType type, const Common::Path &path) {
g_lingo->initBuiltIns(builtins);
}
void XPlayAnim::close(ObjectType type) {
g_lingo->cleanupBuiltIns(builtins);
}
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();
debug(5, "LB::b_xPlayAnim: x: %i y: %i", x, y);
Video::PacoDecoder *video = new Video::PacoDecoder();
bool result = video->loadFile(Common::Path(filename, g_director->_dirSeparator));
if (!result) {
warning("b_xPlayAnim: PACo video not loaded: %s", filename.c_str());
delete video;
return;
}
// 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 = nullptr;
Common::Event event;
bool keepPlaying = true;
video->start();
while (!video->endOfVideo()) {
if (g_director->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_director->delayMillis(10);
}
if (frame != nullptr)
// 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

View File

@@ -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_XPLAYANIM_H
#define DIRECTOR_LINGO_XLIBS_XPLAYANIM_H
namespace Director {
namespace XPlayAnim {
extern const char *const xlibName;
extern const XlibFileDesc fileNames[];
void open(ObjectType type, const Common::Path &path);
void close(ObjectType type);
void b_xplayanim(int nargs);
} // End of namespace XPlayAnim
} // End of namespace Director
#endif

View File

@@ -0,0 +1,236 @@
/* 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/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/x/xplaypacoxfcn.h"
/**************************************************
*
* USED IN:
* jman
*
**************************************************/
#include "video/paco_decoder.h"
namespace Director {
struct PACoPlayer {
Video::PacoDecoder *_video;
};
class XPlayPACoState : public Object<XPlayPACoState> {
public:
XPlayPACoState();
~XPlayPACoState();
int openfile(Common::String &rawPath);
int close(int playerId);
Common::String play(int playerId, int posX, int posY);
Common::HashMap<int, PACoPlayer> _players;
int _nextId;
};
XPlayPACoState::XPlayPACoState() : Object<XPlayPACoState>("XPlayPACo") {
_nextId = 1;
}
XPlayPACoState::~XPlayPACoState() {
for (auto it : _players) {
delete it._value._video;
it._value._video = nullptr;
}
}
int XPlayPACoState::openfile(Common::String &rawPath) {
Common::Path path = findPath(rawPath);
if (path.empty()) {
warning("XPlayPACo::openfile: Could not resolve path %s", rawPath.c_str());
return -1;
}
Video::PacoDecoder *dec = new Video::PacoDecoder();
if (!dec->loadFile(path)) {
delete dec;
return -1;
}
int result = _nextId;
_nextId++;
_players[result] = PACoPlayer();
_players[result]._video = dec;
return result;
}
int XPlayPACoState::close(int playerId) {
if (_players.contains(playerId)) {
_players[playerId]._video->close();
delete _players[playerId]._video;
_players.erase(playerId);
}
return 0;
}
Common::String XPlayPACoState::play(int playerId, int posX, int posY) {
if (_players.contains(playerId)) {
Video::PacoDecoder *video = _players[playerId]._video;
// save the current palette
byte origPalette[256 * 3];
uint16 origCount = g_director->getPaletteColorCount();
if (origCount > 256) {
warning("callPacoPlay: too big palette, %d > 256", origCount);
origCount = 256;
}
memcpy(origPalette, g_director->getPalette(), origCount * 3);
byte videoPalette[256 * 3];
Graphics::Surface const *frame = nullptr;
Common::Event event;
bool keepPlaying = true;
video->start();
memcpy(videoPalette, video->getPalette(), 256 * 3);
while (!video->endOfVideo()) {
if (g_director->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();
// Palette info gets set after the frame is decoded
if (video->hasDirtyPalette()) {
byte *palette = const_cast<byte *>(video->getPalette());
memcpy(videoPalette, palette, 256 * 3);
}
// Video palette order is going to be different to the screen, we need to untangle it
Graphics::Surface *dither = frame->convertTo(g_director->_wm->_pixelformat, videoPalette, 256, origPalette, origCount, Graphics::kDitherNaive);
int width = MIN(dither->w + posX, (int)g_system->getWidth()) - posX;
int height = MIN(dither->h + posY, (int)g_system->getHeight()) - posY;
g_system->copyRectToScreen(dither->getPixels(), dither->pitch, posX, posY, width, height);
dither->free();
delete dither;
}
g_system->updateScreen();
g_director->delayMillis(10);
}
}
return "0 0";
}
const char *XPlayPACoXFCN::xlibName = "XPlayPACo";
const XlibFileDesc XPlayPACoXFCN::fileNames[] = {
{ "Presto.rsrc", "jman" },
{ "XPlayPACo", nullptr },
{ nullptr, nullptr }
};
static BuiltinProto builtins[] = {
{ "XPlayPACo", XPlayPACoXFCN::m_XPlayPACo, -1, 0, 300, HBLTIN },
{ nullptr, nullptr, 0, 0, 0, VOIDSYM }
};
void XPlayPACoXFCN::open(ObjectType type, const Common::Path &path) {
g_lingo->initBuiltIns(builtins);
if (!g_lingo->_openXLibsState.contains("XPlayPACo")) {
XPlayPACoState *pacoState = new XPlayPACoState();
g_lingo->_openXLibsState.setVal("XPlayPACo", pacoState);
}
}
void XPlayPACoXFCN::close(ObjectType type) {
g_lingo->cleanupBuiltIns(builtins);
if (g_lingo->_openXLibsState.contains("XPlayPACo")) {
AbstractObject *pacoState = g_lingo->_openXLibsState.getVal("XPlayPACo");
delete pacoState;
g_lingo->_openXLibsState.erase("XPlayPACo");
}
}
void XPlayPACoXFCN::m_XPlayPACo(int nargs) {
g_lingo->printSTUBWithArglist("m_XPlayPACo", nargs);
XPlayPACoState *state = (XPlayPACoState *)g_lingo->_openXLibsState.getVal("XPlayPACo");
Datum result;
if (nargs == 0) {
warning("XPlayPACoXFCN: no arguments");
} else {
Common::String cmd = g_lingo->peek(nargs - 1).asString();
if (cmd.equalsIgnoreCase("openfile")) {
if (nargs == 2) {
Common::String filename = g_lingo->peek(0).asString();
result = state->openfile(filename);
} else {
warning("XPlayPACoXFCN: expected 1 arg for openfile");
}
} else if (cmd.equals("set")) {
} else if (cmd.equals("play")) {
if (nargs >= 2) {
int playerId = g_lingo->peek(nargs - 2).asInt();
int posX = 0;
int posY = 0;
for (int i = nargs - 3; i >= 0; i -= 2) {
Datum paramName = g_lingo->peek(i);
Datum paramValue = g_lingo->peek(i - 1);
if (paramName.asString().equalsIgnoreCase("posX")) {
posX = paramValue.asInt();
} else if (paramName.asString().equalsIgnoreCase("posY")) {
posY = paramValue.asInt();
}
}
result = state->play(playerId, posX, posY);
} else {
warning("XPlayPACoXFCN: expected at least 1 arg for play");
}
} else if (cmd.equals("close")) {
if (nargs == 2) {
int playerId = g_lingo->peek(nargs - 2).asInt();
result = state->close(playerId);
} else {
warning("XPlayPACoXFCN: expected 1 arg for close");
}
} else {
warning("XPlayPACoXFCN: Unknown command %s", cmd.c_str());
}
}
g_lingo->dropStack(nargs);
g_lingo->push(result);
}
}

View File

@@ -0,0 +1,41 @@
/* 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 DIRECTOR_LINGO_XLIBS_XPLAYPACOXFCN_H
#define DIRECTOR_LINGO_XLIBS_XPLAYPACOXFCN_H
namespace Director {
namespace XPlayPACoXFCN {
extern const char *xlibName;
extern const XlibFileDesc fileNames[];
void open(ObjectType type, const Common::Path &path);
void close(ObjectType type);
void m_XPlayPACo(int nargs);
} // End of namespace XPlayPACoXFCN
} // End of namespace Director
#endif

View File

@@ -0,0 +1,194 @@
/* 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/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/v/voyagerxsound.h"
#include "director/lingo/xlibs/x/xsoundxfcn.h"
/**************************************************
*
* USED IN:
* puppetmotel
*
**************************************************/
namespace Director {
const char *const XSoundXFCN::xlibName = "XSound";
const XlibFileDesc XSoundXFCN::fileNames[] = {
{ "XSound", "puppetmotel" },
{ "_XSound", "puppetmotel" },
{ nullptr, nullptr },
};
static const BuiltinProto builtins[] = {
{ "XSound", XSoundXFCN::m_XSound, -1, 0, 400, HBLTIN },
{ nullptr, nullptr, 0, 0, 0, VOIDSYM }
};
void XSoundXFCN::open(ObjectType type, const Common::Path &path) {
g_lingo->initBuiltIns(builtins);
if (!g_lingo->_openXLibsState.contains("XSound")) {
VoyagerXSoundXObject *xobj = new VoyagerXSoundXObject(type);
g_lingo->_openXLibsState.setVal("XSound", xobj);
}
}
void XSoundXFCN::close(ObjectType type) {
g_lingo->cleanupBuiltIns(builtins);
}
void XSoundXFCN::m_XSound(int nargs) {
g_lingo->printSTUBWithArglist("XSoundXFCN::m_XSound", nargs);
VoyagerXSoundXObject *xobj = (VoyagerXSoundXObject *)g_lingo->_openXLibsState.getVal("XSound");
if (nargs == 0) {
warning("XSoundXFCN: need at least one arg");
g_lingo->push(Datum());
return;
}
Datum cmd = g_lingo->peek(nargs-1);
if (cmd.type != STRING) {
warning("XSoundXFCN: arg 1 needs to be string");
g_lingo->dropStack(nargs);
g_lingo->push(Datum());
return;
}
Common::String cmdName = cmd.asString();
if (cmdName == "open") {
ARGNUMCHECK(3);
Datum monostereo = g_lingo->pop();
Datum numchan = g_lingo->pop();
g_lingo->pop();
g_lingo->push(xobj->open(numchan.asInt(), monostereo.asInt()));
} else if (cmdName == "close") {
ARGNUMCHECK(1);
g_lingo->pop();
xobj->close();
g_lingo->push(Datum(0));
} else if (cmdName == "status") {
ARGNUMCHECK(2);
Datum chan = g_lingo->pop();
g_lingo->pop();
g_lingo->push(xobj->status(chan.asInt()));
} else if (cmdName == "playfile") {
if (nargs < 3) {
warning("XSoundXFCN::playfile: expected at least 3 args");
g_lingo->dropStack(nargs);
g_lingo->push(0);
return;
} else if (nargs > 5) {
g_lingo->dropStack(nargs - 5);
nargs = 5;
}
Datum tend(-1);
if (nargs == 5) {
tend = g_lingo->pop();
nargs--;
}
Datum tstart(-1);
if (nargs == 4) {
tstart = g_lingo->pop();
nargs--;
}
Common::String path = g_lingo->pop().asString();
Datum chan = g_lingo->pop();
g_lingo->pop();
int result = xobj->playfile(chan.asInt(), path, tstart.asInt(), tend.asInt());
g_lingo->push(result);
} else if (cmdName == "stop") {
ARGNUMCHECK(2);
Datum chan = g_lingo->pop();
g_lingo->pop();
xobj->stop(chan.asInt());
g_lingo->push(1);
} else if (cmdName == "volume") {
ARGNUMCHECK(3);
Datum vol = g_lingo->pop();
Datum chan = g_lingo->pop();
g_lingo->pop();
xobj->volume(chan.asInt(), vol.asInt());
g_lingo->push(1);
} else if (cmdName == "leftRightVol") {
ARGNUMCHECK(4);
Datum rvol = g_lingo->pop();
Datum lvol = g_lingo->pop();
Datum chan = g_lingo->pop();
g_lingo->pop();
xobj->leftrightvol(chan.asInt(), (uint8)lvol.asInt(), (uint8)rvol.asInt());
g_lingo->push(1);
} else if (cmdName == "fade") {
if (nargs < 3) {
warning("XSoundXFCN::fade: expected at least 2 args");
g_lingo->dropStack(nargs);
g_lingo->push(Datum());
return;
}
if (nargs > 5) {
warning("VoyagerXSoundXObj: dropping %d extra args", nargs - 5);
g_lingo->dropStack(nargs - 5);
nargs = 5;
}
bool autoStop = false;
int duration = 0;
if (nargs == 5) {
autoStop = (bool)g_lingo->pop().asInt();
nargs--;
}
if (nargs == 4) {
duration = g_lingo->pop().asInt();
nargs--;
}
int endVol = g_lingo->pop().asInt();
int chan = g_lingo->pop().asInt();
g_lingo->pop();
g_lingo->push(Datum(xobj->fade(chan, endVol, duration, autoStop)));
} else if (cmdName == "frequency") {
ARGNUMCHECK(3);
Datum percent = g_lingo->pop();
Datum chan = g_lingo->pop();
g_lingo->pop();
xobj->frequency(chan.asInt(), percent.asInt());
g_lingo->push(1);
} else if (cmdName == "pan") {
ARGNUMCHECK(3);
Datum percent = g_lingo->pop();
Datum chan = g_lingo->pop();
g_lingo->pop();
xobj->pan(chan.asInt(), percent.asInt());
g_lingo->push(1);
} else {
warning("XSoundXFCN: unknown command %s", cmdName.c_str());
g_lingo->dropStack(nargs);
g_lingo->push(Datum());
return;
}
}
}

View File

@@ -0,0 +1,41 @@
/* 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 DIRECTOR_LINGO_XLIBS_XSOUNDXFCN_H
#define DIRECTOR_LINGO_XLIBS_XSOUNDXFCN_H
namespace Director {
namespace XSoundXFCN {
extern const char *const xlibName;
extern const XlibFileDesc fileNames[];
void open(ObjectType type, const Common::Path &path);
void close(ObjectType type);
void m_XSound(int nargs);
} // End of namespace XSoundXFCN
} // End of namespace Director
#endif

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 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/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/x/xwin.h"
/**************************************************
*
* USED IN:
* hellcab-win
*
**************************************************/
/*
-- XWIN External Factory. 9jul93 JU
--XWIN
I mNew --Creates a new instance of the XObject
X mDispose --Disposes of XObject instance.
II mWriteChar, charNum --Writes a single character. Returns error code
IS mWriteString, string --Writes out a string of chars. Returns error code
I mReadChar --Returns a single character
S mReadWord --Returns the next word of an input file
S mReadLine --Returns the next line of an input file
S mReadFile --Returns the remainder of the file
SSS mReadToken, breakString, skipString
I mGetPosition --Returns the file position
II mSetPosition, newPos --Sets the file position. Returns error code
I mGetLength --Returns the number of chars in the file
ISS mSetFinderInfo, typeString, creatorString
S mGetFinderInfo --Gets the finder info
S mFileName --Returns the name of the file
I mDelete --Delete the file and dispose of me
I mStatus --Returns result code of the last file io activity
SI +mError, errorCode --Returns error message string
V mReadPICT --Return handle to Metafile
S mNativeFileName --Returns the native (dos) name of the file
I mhwnd --window handle
*/
namespace Director {
const char *const XWINXObj::xlibName = "XWIN";
const XlibFileDesc XWINXObj::fileNames[] = {
{ "XWIN", nullptr },
{ nullptr, nullptr },
};
static const MethodProto xlibMethods[] = {
{ "new", XWINXObj::m_new, 0, 0, 300 },
{ "dispose", XWINXObj::m_dispose, 0, 0, 300 },
{ "writeChar", XWINXObj::m_writeChar, 1, 1, 300 },
{ "writeString", XWINXObj::m_writeString, 1, 1, 300 },
{ "readChar", XWINXObj::m_readChar, 0, 0, 300 },
{ "readWord", XWINXObj::m_readWord, 0, 0, 300 },
{ "readLine", XWINXObj::m_readLine, 0, 0, 300 },
{ "readFile", XWINXObj::m_readFile, 0, 0, 300 },
{ "readToken", XWINXObj::m_readToken, 2, 2, 300 },
{ "getPosition", XWINXObj::m_getPosition, 0, 0, 300 },
{ "setPosition", XWINXObj::m_setPosition, 1, 1, 300 },
{ "getLength", XWINXObj::m_getLength, 0, 0, 300 },
{ "setFinderInfo", XWINXObj::m_setFinderInfo, 2, 2, 300 },
{ "getFinderInfo", XWINXObj::m_getFinderInfo, 0, 0, 300 },
{ "fileName", XWINXObj::m_fileName, 0, 0, 300 },
{ "delete", XWINXObj::m_delete, 0, 0, 300 },
{ "status", XWINXObj::m_status, 0, 0, 300 },
{ "error", XWINXObj::m_error, 1, 1, 300 },
{ "readPICT", XWINXObj::m_readPICT, 0, 0, 300 },
{ "nativeFileName", XWINXObj::m_nativeFileName, 0, 0, 300 },
{ "hwnd", XWINXObj::m_hwnd, 0, 0, 300 },
{ nullptr, nullptr, 0, 0, 0 }
};
static const BuiltinProto xlibBuiltins[] = {
{ nullptr, nullptr, 0, 0, 0, VOIDSYM }
};
XWINXObject::XWINXObject(ObjectType ObjectType) :Object<XWINXObject>("XWIN") {
_objType = ObjectType;
}
void XWINXObj::open(ObjectType type, const Common::Path &path) {
XWINXObject::initMethods(xlibMethods);
XWINXObject *xobj = new XWINXObject(type);
g_lingo->exposeXObject(xlibName, xobj);
g_lingo->initBuiltIns(xlibBuiltins);
}
void XWINXObj::close(ObjectType type) {
XWINXObject::cleanupMethods();
g_lingo->_globalvars[xlibName] = Datum();
}
void XWINXObj::m_new(int nargs) {
g_lingo->printSTUBWithArglist("XWINXObj::m_new", nargs);
g_lingo->dropStack(nargs);
g_lingo->push(g_lingo->_state->me);
}
XOBJSTUBNR(XWINXObj::m_dispose)
XOBJSTUB(XWINXObj::m_writeChar, 0)
XOBJSTUB(XWINXObj::m_writeString, 0)
XOBJSTUB(XWINXObj::m_readChar, 0)
XOBJSTUB(XWINXObj::m_readWord, "")
XOBJSTUB(XWINXObj::m_readLine, "")
XOBJSTUB(XWINXObj::m_readFile, "")
XOBJSTUB(XWINXObj::m_readToken, "")
XOBJSTUB(XWINXObj::m_getPosition, 0)
XOBJSTUB(XWINXObj::m_setPosition, 0)
XOBJSTUB(XWINXObj::m_getLength, 0)
XOBJSTUB(XWINXObj::m_setFinderInfo, 0)
XOBJSTUB(XWINXObj::m_getFinderInfo, "")
XOBJSTUB(XWINXObj::m_fileName, "")
XOBJSTUB(XWINXObj::m_delete, 0)
XOBJSTUB(XWINXObj::m_status, 0)
XOBJSTUB(XWINXObj::m_error, "")
XOBJSTUB(XWINXObj::m_readPICT, 0)
XOBJSTUB(XWINXObj::m_nativeFileName, "")
XOBJSTUB(XWINXObj::m_hwnd, 0)
}

View File

@@ -0,0 +1,66 @@
/* 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 DIRECTOR_LINGO_XLIBS_XWIN_H
#define DIRECTOR_LINGO_XLIBS_XWIN_H
namespace Director {
class XWINXObject : public Object<XWINXObject> {
public:
XWINXObject(ObjectType objType);
};
namespace XWINXObj {
extern const char *const 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_writeChar(int nargs);
void m_writeString(int nargs);
void m_readChar(int nargs);
void m_readWord(int nargs);
void m_readLine(int nargs);
void m_readFile(int nargs);
void m_readToken(int nargs);
void m_getPosition(int nargs);
void m_setPosition(int nargs);
void m_getLength(int nargs);
void m_setFinderInfo(int nargs);
void m_getFinderInfo(int nargs);
void m_fileName(int nargs);
void m_delete(int nargs);
void m_status(int nargs);
void m_error(int nargs);
void m_readPICT(int nargs);
void m_nativeFileName(int nargs);
void m_hwnd(int nargs);
} // End of namespace XWINXObj
} // End of namespace Director
#endif