2009-12-29 23:18:24 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
2010-01-03 08:27:33 +00:00
|
|
|
|
2010-11-25 04:49:11 +00:00
|
|
|
#include "mohawk/cursors.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
#include "mohawk/myst.h"
|
|
|
|
#include "mohawk/graphics.h"
|
2010-11-29 20:51:04 +00:00
|
|
|
#include "mohawk/myst_areas.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
#include "mohawk/myst_scripts.h"
|
2009-12-30 23:02:14 +00:00
|
|
|
#include "mohawk/sound.h"
|
2010-05-23 18:33:55 +00:00
|
|
|
#include "mohawk/video.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
#include "gui/message.h"
|
|
|
|
|
|
|
|
namespace Mohawk {
|
|
|
|
|
2010-11-18 05:47:16 +00:00
|
|
|
MystScriptEntry::MystScriptEntry() {
|
|
|
|
type = kMystScriptNone;
|
|
|
|
var = 0;
|
|
|
|
argc = 0;
|
|
|
|
argv = 0;
|
2010-11-29 21:01:30 +00:00
|
|
|
resourceId = 0;
|
2010-11-18 05:47:16 +00:00
|
|
|
u1 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
MystScriptEntry::~MystScriptEntry() {
|
|
|
|
delete[] argv;
|
|
|
|
}
|
|
|
|
|
2010-12-01 14:57:05 +00:00
|
|
|
const uint8 MystScriptParser::_stackMap[11] = {
|
2009-12-29 23:18:24 +00:00
|
|
|
kSeleniticStack,
|
|
|
|
kStoneshipStack,
|
|
|
|
kMystStack,
|
|
|
|
kMechanicalStack,
|
|
|
|
kChannelwoodStack,
|
2010-11-29 21:01:02 +00:00
|
|
|
kIntroStack,
|
2009-12-29 23:18:24 +00:00
|
|
|
kDniStack,
|
2010-11-29 21:01:02 +00:00
|
|
|
kMystStack,
|
|
|
|
kCreditsStack,
|
|
|
|
kMystStack,
|
2009-12-29 23:18:24 +00:00
|
|
|
kMystStack
|
|
|
|
};
|
|
|
|
|
2010-12-01 14:57:05 +00:00
|
|
|
const uint16 MystScriptParser::_startCard[11] = {
|
2009-12-29 23:18:24 +00:00
|
|
|
1282,
|
|
|
|
2029,
|
|
|
|
4396,
|
|
|
|
6122,
|
|
|
|
3137,
|
2010-11-29 21:01:02 +00:00
|
|
|
1,
|
2009-12-29 23:18:24 +00:00
|
|
|
5038,
|
2010-11-29 21:01:02 +00:00
|
|
|
4134,
|
|
|
|
10000,
|
|
|
|
4739,
|
|
|
|
4741
|
2009-12-29 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// NOTE: Credits Start Card is 10000
|
|
|
|
|
2010-12-26 14:31:03 +00:00
|
|
|
MystScriptParser::MystScriptParser(MohawkEngine_Myst *vm) :
|
|
|
|
_vm(vm),
|
|
|
|
_globals(vm->_gameState->_globals) {
|
2010-12-01 03:30:00 +00:00
|
|
|
setupCommonOpcodes();
|
2009-12-29 23:18:24 +00:00
|
|
|
_invokingResource = NULL;
|
2010-11-29 20:56:21 +00:00
|
|
|
_savedCardId = 0;
|
|
|
|
_savedCursorId = 0;
|
2010-11-30 17:55:41 +00:00
|
|
|
_tempVar = 0;
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
MystScriptParser::~MystScriptParser() {
|
2010-12-01 03:30:00 +00:00
|
|
|
for (uint32 i = 0; i < _opcodes.size(); i++)
|
|
|
|
delete _opcodes[i];
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-12-01 03:30:00 +00:00
|
|
|
#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, &MystScriptParser::x, #x))
|
|
|
|
|
|
|
|
void MystScriptParser::setupCommonOpcodes() {
|
|
|
|
// These opcodes are common to each stack
|
|
|
|
|
|
|
|
// "Standard" Opcodes
|
|
|
|
OPCODE(0, o_toggleVar);
|
|
|
|
OPCODE(1, o_setVar);
|
|
|
|
OPCODE(2, o_changeCardSwitch);
|
|
|
|
OPCODE(3, o_takePage);
|
|
|
|
OPCODE(4, o_redrawCard);
|
|
|
|
// Opcode 5 Not Present
|
|
|
|
OPCODE(6, o_goToDest);
|
|
|
|
OPCODE(7, o_goToDest);
|
|
|
|
OPCODE(8, o_goToDest);
|
|
|
|
OPCODE(9, o_triggerMovie);
|
|
|
|
OPCODE(10, o_toggleVarNoRedraw);
|
|
|
|
// Opcode 11 Not Present
|
|
|
|
OPCODE(12, o_changeCardSwitch);
|
|
|
|
OPCODE(13, o_changeCardSwitch);
|
|
|
|
OPCODE(14, o_drawAreaState);
|
|
|
|
OPCODE(15, o_redrawAreaForVar);
|
|
|
|
OPCODE(16, o_changeCardDirectional);
|
|
|
|
OPCODE(17, o_changeCardPush);
|
|
|
|
OPCODE(18, o_changeCardPop);
|
|
|
|
OPCODE(19, o_enableAreas);
|
|
|
|
OPCODE(20, o_disableAreas);
|
|
|
|
OPCODE(21, o_directionalUpdate);
|
|
|
|
OPCODE(22, o_goToDest);
|
|
|
|
OPCODE(23, o_toggleAreasActivation);
|
|
|
|
OPCODE(24, o_playSound);
|
|
|
|
// Opcode 25 is unused; original calls replaceSound
|
|
|
|
OPCODE(26, o_stopSoundBackground);
|
|
|
|
OPCODE(27, o_playSoundBlocking);
|
2010-12-14 19:11:16 +00:00
|
|
|
OPCODE(28, o_copyBackBufferToScreen);
|
|
|
|
OPCODE(29, o_copyImageToBackBuffer);
|
2010-12-18 13:12:56 +00:00
|
|
|
OPCODE(30, o_changeBackgroundSound);
|
2010-12-01 03:30:00 +00:00
|
|
|
OPCODE(31, o_soundPlaySwitch);
|
|
|
|
OPCODE(32, o_soundResumeBackground);
|
2010-12-14 19:11:16 +00:00
|
|
|
OPCODE(33, o_copyImageToScreen);
|
2010-12-01 03:30:00 +00:00
|
|
|
OPCODE(34, o_changeCard);
|
|
|
|
OPCODE(35, o_drawImageChangeCard);
|
|
|
|
OPCODE(36, o_changeMainCursor);
|
|
|
|
OPCODE(37, o_hideCursor);
|
|
|
|
OPCODE(38, o_showCursor);
|
|
|
|
OPCODE(39, o_delay);
|
|
|
|
OPCODE(40, o_changeStack);
|
|
|
|
OPCODE(41, o_changeCardPlaySoundDirectional);
|
|
|
|
OPCODE(42, o_directionalUpdatePlaySound);
|
|
|
|
OPCODE(43, o_saveMainCursor);
|
|
|
|
OPCODE(44, o_restoreMainCursor);
|
|
|
|
// Opcode 45 Not Present
|
|
|
|
OPCODE(46, o_soundWaitStop);
|
|
|
|
// Opcodes 47 to 99 Not Present
|
|
|
|
|
|
|
|
OPCODE(0xFFFF, NOP);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-12-01 03:30:00 +00:00
|
|
|
#undef OPCODE
|
|
|
|
|
2010-11-18 05:47:16 +00:00
|
|
|
void MystScriptParser::runScript(MystScript script, MystResource *invokingResource) {
|
|
|
|
debugC(kDebugScript, "Script Size: %d", script->size());
|
|
|
|
for (uint16 i = 0; i < script->size(); i++) {
|
|
|
|
MystScriptEntry &entry = script->operator[](i);
|
|
|
|
debugC(kDebugScript, "\tOpcode %d: %d", i, entry.opcode);
|
2010-11-29 21:01:30 +00:00
|
|
|
|
2010-12-01 03:30:00 +00:00
|
|
|
if (entry.type == kMystScriptNormal)
|
2010-11-29 21:01:30 +00:00
|
|
|
_invokingResource = invokingResource;
|
2010-12-01 03:30:00 +00:00
|
|
|
else
|
2010-11-29 21:01:30 +00:00
|
|
|
_invokingResource = _vm->_resources[entry.resourceId];
|
|
|
|
|
2010-11-18 05:47:16 +00:00
|
|
|
runOpcode(entry.opcode, entry.var, entry.argc, entry.argv);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MystScriptParser::runOpcode(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
|
|
|
bool ranOpcode = false;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-12-01 03:30:00 +00:00
|
|
|
for (uint16 i = 0; i < _opcodes.size(); i++)
|
|
|
|
if (_opcodes[i]->op == op) {
|
|
|
|
(this->*(_opcodes[i]->proc)) (op, var, argc, argv);
|
2009-12-29 23:18:24 +00:00
|
|
|
ranOpcode = true;
|
|
|
|
break;
|
|
|
|
}
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
if (!ranOpcode)
|
2010-12-01 03:39:47 +00:00
|
|
|
warning("Trying to run invalid opcode %d", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-12-16 16:12:38 +00:00
|
|
|
const Common::String MystScriptParser::getOpcodeDesc(uint16 op) {
|
2010-12-01 03:30:00 +00:00
|
|
|
for (uint16 i = 0; i < _opcodes.size(); i++)
|
|
|
|
if (_opcodes[i]->op == op)
|
|
|
|
return _opcodes[i]->desc;
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-12-16 16:12:38 +00:00
|
|
|
return Common::String::format("%d", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-18 05:47:16 +00:00
|
|
|
MystScript MystScriptParser::readScript(Common::SeekableReadStream *stream, MystScriptType type) {
|
|
|
|
assert(stream);
|
|
|
|
assert(type != kMystScriptNone);
|
|
|
|
|
|
|
|
MystScript script = MystScript(new Common::Array<MystScriptEntry>());
|
|
|
|
|
|
|
|
uint16 opcodeCount = stream->readUint16LE();
|
|
|
|
script->resize(opcodeCount);
|
|
|
|
|
|
|
|
for (uint16 i = 0; i < opcodeCount; i++) {
|
|
|
|
MystScriptEntry &entry = script->operator[](i);
|
|
|
|
entry.type = type;
|
|
|
|
|
|
|
|
// u0 only exists in INIT and EXIT scripts
|
|
|
|
if (type != kMystScriptNormal)
|
2010-11-29 21:01:30 +00:00
|
|
|
entry.resourceId = stream->readUint16LE();
|
2010-11-18 05:47:16 +00:00
|
|
|
|
|
|
|
entry.opcode = stream->readUint16LE();
|
|
|
|
entry.var = stream->readUint16LE();
|
|
|
|
entry.argc = stream->readUint16LE();
|
|
|
|
|
|
|
|
if (entry.argc > 0) {
|
|
|
|
entry.argv = new uint16[entry.argc];
|
|
|
|
for (uint16 j = 0; j < entry.argc; j++)
|
|
|
|
entry.argv[j] = stream->readUint16LE();
|
|
|
|
}
|
|
|
|
|
|
|
|
// u1 exists only in EXIT scripts
|
|
|
|
if (type == kMystScriptExit)
|
|
|
|
entry.u1 = stream->readUint16LE();
|
|
|
|
}
|
|
|
|
|
|
|
|
return script;
|
|
|
|
}
|
|
|
|
|
2010-11-29 20:49:42 +00:00
|
|
|
uint16 MystScriptParser::getVar(uint16 var) {
|
2010-11-29 20:59:44 +00:00
|
|
|
switch(var) {
|
|
|
|
case 105:
|
|
|
|
return _tempVar;
|
2010-12-06 20:29:45 +00:00
|
|
|
case 106:
|
2010-12-26 14:31:03 +00:00
|
|
|
return _globals.ending;
|
2010-11-29 20:59:44 +00:00
|
|
|
default:
|
|
|
|
warning("Unimplemented var getter 0x%02x (%d)", var, var);
|
|
|
|
return _vm->_varStore->getVar(var);
|
|
|
|
}
|
2010-11-29 20:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MystScriptParser::toggleVar(uint16 var) {
|
|
|
|
warning("Unimplemented var toggle 0x%02x (%d)", var, var);
|
|
|
|
_vm->_varStore->setVar(var, (_vm->_varStore->getVar(var) + 1) % 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MystScriptParser::setVarValue(uint16 var, uint16 value) {
|
2010-11-29 20:59:44 +00:00
|
|
|
if (var == 105) {
|
|
|
|
if (_tempVar != value)
|
|
|
|
_tempVar = value;
|
|
|
|
} else {
|
|
|
|
warning("Unimplemented var setter 0x%02x (%d)", var, var);
|
|
|
|
_vm->_varStore->setVar(var, value);
|
|
|
|
}
|
|
|
|
|
2010-11-29 20:49:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-01-25 01:39:44 +00:00
|
|
|
// NOTE: Check to be used on Opcodes where var is thought
|
2009-12-29 23:18:24 +00:00
|
|
|
// not to be used. This emits a warning if var is nonzero.
|
|
|
|
// It is possible that the opcode does use var 0 in this case,
|
|
|
|
// but this will catch the majority of missed cases.
|
|
|
|
void MystScriptParser::varUnusedCheck(uint16 op, uint16 var) {
|
|
|
|
if (var != 0)
|
|
|
|
warning("Opcode %d: Unused Var %d", op, var);
|
|
|
|
}
|
|
|
|
|
2010-11-29 20:58:45 +00:00
|
|
|
void MystScriptParser::animatedUpdate(uint16 argc, uint16 *argv, uint16 delay) {
|
|
|
|
uint16 argsRead = 0;
|
|
|
|
|
|
|
|
while (argsRead < argc) {
|
|
|
|
Common::Rect rect = Common::Rect(argv[argsRead], argv[argsRead + 1], argv[argsRead + 2], argv[argsRead + 3]);
|
|
|
|
uint16 kind = argv[argsRead + 4];
|
|
|
|
uint16 steps = argv[argsRead + 5];
|
|
|
|
|
|
|
|
debugC(kDebugScript, "\trect.left: %d", rect.left);
|
|
|
|
debugC(kDebugScript, "\trect.top: %d", rect.top);
|
|
|
|
debugC(kDebugScript, "\trect.right: %d", rect.right);
|
|
|
|
debugC(kDebugScript, "\trect.bottom: %d", rect.bottom);
|
|
|
|
|
|
|
|
debugC(kDebugScript, "\tkind / direction: %d", kind);
|
|
|
|
debugC(kDebugScript, "\tsteps: %d", steps);
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
_vm->_gfx->runTransition(kind, rect, steps, delay);
|
2010-11-29 20:58:45 +00:00
|
|
|
|
|
|
|
argsRead += 6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
void MystScriptParser::unknown(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-07 01:03:29 +00:00
|
|
|
warning("Unimplemented opcode 0x%02x (%d)", op, op);
|
|
|
|
warning("\tUses var %d", var);
|
|
|
|
warning("\tArg count = %d", argc);
|
2011-01-03 20:40:07 +00:00
|
|
|
|
2010-11-07 01:03:29 +00:00
|
|
|
if (argc) {
|
|
|
|
Common::String str;
|
|
|
|
str += Common::String::format("%d", argv[0]);
|
2011-01-03 20:40:07 +00:00
|
|
|
|
|
|
|
for (uint16 i = 1; i < argc; i++)
|
2010-11-07 01:03:29 +00:00
|
|
|
str += Common::String::format(", %d", argv[i]);
|
2011-01-03 20:40:07 +00:00
|
|
|
|
2010-11-07 01:03:29 +00:00
|
|
|
warning("\tArgs: %s\n", str.c_str());
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MystScriptParser::NOP(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_toggleVar(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-12-05 08:36:41 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Toggle var %d", op, var);
|
|
|
|
|
2010-11-29 20:49:42 +00:00
|
|
|
toggleVar(var);
|
2010-11-29 20:54:52 +00:00
|
|
|
_vm->redrawArea(var);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_setVar(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-12-05 08:36:41 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Set var %d: %d", op, var, argv[0]);
|
|
|
|
|
2011-01-03 20:40:07 +00:00
|
|
|
if (setVarValue(var, argv[0]))
|
2010-11-29 20:54:52 +00:00
|
|
|
_vm->redrawArea(var);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_changeCardSwitch(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:54:52 +00:00
|
|
|
// Opcodes 2, 12, and 13 are the same
|
|
|
|
uint16 value = getVar(var);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:54:52 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: changeCardSwitch var %d: %d", op, var, value);
|
|
|
|
|
|
|
|
if (value)
|
2010-11-29 20:59:17 +00:00
|
|
|
_vm->changeToCard(argv[value -1 ], true);
|
2010-11-29 20:54:52 +00:00
|
|
|
else if (_invokingResource != NULL)
|
2010-11-29 20:59:17 +00:00
|
|
|
_vm->changeToCard(_invokingResource->getDest(), true);
|
2010-11-29 20:54:52 +00:00
|
|
|
else
|
|
|
|
warning("Missing invokingResource in altDest call");
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_takePage(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:57:27 +00:00
|
|
|
uint16 cursorId = argv[0];
|
2010-12-26 14:31:03 +00:00
|
|
|
uint16 oldPage = _globals.heldPage;
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:57:27 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: takePage Var %d CursorId %d", op, var, cursorId);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:57:27 +00:00
|
|
|
// Take / drop page
|
|
|
|
toggleVar(var);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-12-26 14:31:03 +00:00
|
|
|
if (oldPage != _globals.heldPage) {
|
2010-11-29 21:03:02 +00:00
|
|
|
_vm->_cursor->hideCursor();
|
2010-11-29 20:57:27 +00:00
|
|
|
_vm->redrawArea(var);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:57:27 +00:00
|
|
|
// Set new cursor
|
2010-12-26 14:31:03 +00:00
|
|
|
if (_globals.heldPage)
|
2010-11-29 20:57:27 +00:00
|
|
|
_vm->setMainCursor(cursorId);
|
|
|
|
else
|
|
|
|
_vm->setMainCursor(kDefaultMystCursor);
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
_vm->_cursor->showCursor();
|
2010-11-29 20:57:27 +00:00
|
|
|
}
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_redrawCard(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:56:56 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Redraw card", op);
|
|
|
|
|
|
|
|
_vm->drawCardBackground();
|
|
|
|
_vm->drawResourceImages();
|
2010-12-14 19:11:16 +00:00
|
|
|
_vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
|
|
|
|
_vm->_system->updateScreen();
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_goToDest(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:56:56 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Change To Dest of Invoking Resource", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:56 +00:00
|
|
|
if (_invokingResource != NULL)
|
2010-11-29 20:59:17 +00:00
|
|
|
_vm->changeToCard(_invokingResource->getDest(), true);
|
2010-11-29 20:56:56 +00:00
|
|
|
else
|
|
|
|
warning("Opcode %d: Missing invokingResource", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_triggerMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:55:50 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Trigger Type 6 Resource Movie..", op);
|
2010-12-06 20:29:45 +00:00
|
|
|
// TODO: If movie has sound, pause background music
|
2010-11-29 20:55:31 +00:00
|
|
|
|
2010-11-29 20:55:50 +00:00
|
|
|
int16 direction = 1;
|
2011-01-03 20:40:07 +00:00
|
|
|
if (argc == 1)
|
2010-11-29 20:55:50 +00:00
|
|
|
direction = argv[0];
|
2011-01-03 20:40:07 +00:00
|
|
|
|
2010-11-29 20:55:50 +00:00
|
|
|
debugC(kDebugScript, "\tDirection: %d", direction);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:55:50 +00:00
|
|
|
// Trigger resource 6 movie overriding play direction
|
2010-12-06 20:29:45 +00:00
|
|
|
MystResourceType6 *resource = static_cast<MystResourceType6 *>(_invokingResource);
|
|
|
|
resource->playMovie();
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-12-06 20:29:45 +00:00
|
|
|
// TODO: If movie has sound, resume background music
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_toggleVarNoRedraw(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:54:52 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: toggleVarNoRedraw", op);
|
2010-11-29 20:49:42 +00:00
|
|
|
|
2010-11-29 20:54:52 +00:00
|
|
|
toggleVar(var);
|
2010-11-29 20:49:42 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_drawAreaState(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:54:52 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: drawAreaState, state: %d", op, argv[0]);
|
|
|
|
debugC(kDebugScript, "\tVar: %d", var);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:55:31 +00:00
|
|
|
MystResourceType8 *parent = static_cast<MystResourceType8 *>(_invokingResource->_parent);
|
|
|
|
parent->drawConditionalDataToScreen(argv[0]);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_redrawAreaForVar(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-12-14 19:11:16 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: redraw area", op);
|
2010-11-29 20:54:52 +00:00
|
|
|
debugC(kDebugScript, "\tvar: %d", var);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:54:52 +00:00
|
|
|
_vm->redrawArea(var);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_changeCardDirectional(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
// Used by Channelwood Card 3262 (In Elevator)
|
2010-11-29 20:56:04 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Change Card with optional directional update", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:04 +00:00
|
|
|
uint16 cardId = argv[0];
|
|
|
|
uint16 directionalUpdateDataSize = argv[1];
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:04 +00:00
|
|
|
debugC(kDebugScript, "\tcardId: %d", cardId);
|
|
|
|
debugC(kDebugScript, "\tdirectonal update data size: %d", directionalUpdateDataSize);
|
|
|
|
|
2010-11-29 20:59:17 +00:00
|
|
|
_vm->changeToCard(cardId, false);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:58:45 +00:00
|
|
|
animatedUpdate(directionalUpdateDataSize, &argv[2], 0);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Opcode 17 and 18 form a pair, where Opcode 17 jumps to a card,
|
|
|
|
// but with the current cardId stored.
|
|
|
|
// Opcode 18 then "pops" this stored CardId and returns to that card.
|
|
|
|
|
|
|
|
// TODO: The purpose of the optional argv[1] on Opcode 17 and argv[0]
|
|
|
|
// on Opcode 18 which are always 4, 5 or 6 is unknown.
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_changeCardPush(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2009-12-29 23:18:24 +00:00
|
|
|
varUnusedCheck(op, var);
|
|
|
|
|
|
|
|
if (argc == 2) {
|
|
|
|
debugC(kDebugScript, "Opcode %d: Jump to Card Id, Storing Current Card Id", op);
|
|
|
|
|
|
|
|
uint16 cardId = argv[0];
|
|
|
|
debugC(kDebugScript, "\tJump to CardId: %d", cardId);
|
|
|
|
|
|
|
|
uint16 u0 = argv[1]; // TODO
|
|
|
|
debugC(kDebugScript, "\tu0: %d", u0);
|
|
|
|
|
2010-11-29 20:56:21 +00:00
|
|
|
_savedCardId = _vm->getCurCard();
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:21 +00:00
|
|
|
debugC(kDebugScript, "\tCurrent CardId: %d", _savedCardId);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:59:17 +00:00
|
|
|
_vm->changeToCard(cardId, true);
|
2009-12-29 23:18:24 +00:00
|
|
|
} else
|
|
|
|
unknown(op, var, argc, argv);
|
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_changeCardPop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2009-12-29 23:18:24 +00:00
|
|
|
varUnusedCheck(op, var);
|
|
|
|
|
|
|
|
if (argc == 1) {
|
|
|
|
debugC(kDebugScript, "Opcode %d: Return To Stored Card Id", op);
|
2010-11-29 20:56:21 +00:00
|
|
|
debugC(kDebugScript, "\tCardId: %d", _savedCardId);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
uint16 u0 = argv[0];
|
|
|
|
debugC(kDebugScript, "\tu0: %d", u0);
|
|
|
|
|
2010-11-29 20:59:17 +00:00
|
|
|
_vm->changeToCard(_savedCardId, true);
|
2009-12-29 23:18:24 +00:00
|
|
|
} else
|
|
|
|
unknown(op, var, argc, argv);
|
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_enableAreas(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2009-12-29 23:18:24 +00:00
|
|
|
varUnusedCheck(op, var);
|
|
|
|
|
|
|
|
if (argc > 0) {
|
|
|
|
debugC(kDebugScript, "Opcode %d: Enable Hotspots", op);
|
|
|
|
|
|
|
|
uint16 count = argv[0];
|
|
|
|
|
|
|
|
if (argc != count + 1)
|
|
|
|
unknown(op, var, argc, argv);
|
|
|
|
else {
|
|
|
|
for (uint16 i = 0; i < count; i++) {
|
|
|
|
debugC(kDebugScript, "Enable hotspot index %d", argv[i + 1]);
|
|
|
|
_vm->setResourceEnabled(argv[i + 1], true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
unknown(op, var, argc, argv);
|
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_disableAreas(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2009-12-29 23:18:24 +00:00
|
|
|
varUnusedCheck(op, var);
|
|
|
|
|
|
|
|
if (argc > 0) {
|
|
|
|
debugC(kDebugScript, "Opcode %d: Disable Hotspots", op);
|
|
|
|
|
|
|
|
uint16 count = argv[0];
|
|
|
|
|
|
|
|
if (argc != count + 1)
|
|
|
|
unknown(op, var, argc, argv);
|
|
|
|
else {
|
|
|
|
for (uint16 i = 0; i < count; i++) {
|
|
|
|
debugC(kDebugScript, "Disable hotspot index %d", argv[i + 1]);
|
|
|
|
if (argv[i + 1] == 0xFFFF) {
|
|
|
|
if (_invokingResource != NULL)
|
|
|
|
_invokingResource->setEnabled(false);
|
|
|
|
else
|
|
|
|
warning("Unknown Resource in disableHotspots script Opcode");
|
|
|
|
} else
|
|
|
|
_vm->setResourceEnabled(argv[i + 1], false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
unknown(op, var, argc, argv);
|
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_directionalUpdate(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:58:28 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Transition / Directional update", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:58:45 +00:00
|
|
|
animatedUpdate(argc, argv, 0);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_toggleAreasActivation(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:54:52 +00:00
|
|
|
if (argc > 0) {
|
|
|
|
debugC(kDebugScript, "Opcode %d: Toggle areas activation", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:54:52 +00:00
|
|
|
uint16 count = argv[0];
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:54:52 +00:00
|
|
|
if (argc != count + 1)
|
|
|
|
unknown(op, var, argc, argv);
|
|
|
|
else {
|
|
|
|
for (uint16 i = 0; i < count; i++) {
|
|
|
|
debugC(kDebugScript, "Enable/Disable hotspot index %d", argv[i + 1]);
|
|
|
|
|
|
|
|
MystResource *resource = 0;
|
|
|
|
if (argv[i + 1] == 0xFFFF)
|
|
|
|
resource = _invokingResource;
|
|
|
|
else
|
|
|
|
resource = _vm->_resources[argv[i + 1]];
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:54:52 +00:00
|
|
|
if (resource)
|
|
|
|
resource->setEnabled(!resource->isEnabled());
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
unknown(op, var, argc, argv);
|
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_playSound(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2009-12-29 23:18:24 +00:00
|
|
|
varUnusedCheck(op, var);
|
|
|
|
|
|
|
|
if (argc == 1) {
|
|
|
|
uint16 soundId = argv[0];
|
|
|
|
|
|
|
|
debugC(kDebugScript, "Opcode %d: playSound", op);
|
|
|
|
debugC(kDebugScript, "\tsoundId: %d", soundId);
|
|
|
|
|
2010-12-18 13:12:56 +00:00
|
|
|
_vm->_sound->replaceSound(soundId);
|
2009-12-29 23:18:24 +00:00
|
|
|
} else
|
|
|
|
unknown(op, var, argc, argv);
|
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_stopSoundBackground(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:56:04 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: stopSoundBackground", op);
|
2010-12-18 13:12:56 +00:00
|
|
|
_vm->_sound->stopBackground();
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_playSoundBlocking(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:56:04 +00:00
|
|
|
uint16 soundId = argv[0];
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:04 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: playSoundBlocking", op);
|
|
|
|
debugC(kDebugScript, "\tsoundId: %d", soundId);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:04 +00:00
|
|
|
_vm->_sound->playSoundBlocking(soundId);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-12-14 19:11:16 +00:00
|
|
|
void MystScriptParser::o_copyBackBufferToScreen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
|
|
|
debugC(kDebugScript, "Opcode %d: Copy back buffer to screen", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
Common::Rect rect;
|
2010-12-14 19:11:16 +00:00
|
|
|
if (argv[0] == 0xFFFF) {
|
|
|
|
// Used in Stoneship Card 2111 (Compass Rose)
|
|
|
|
// Used in Mechanical Card 6267 (Code Lock)
|
|
|
|
rect = _invokingResource->getRect();
|
|
|
|
} else {
|
|
|
|
// Used in ... TODO: Fill in.
|
|
|
|
rect = Common::Rect(argv[0], argv[1], argv[2], argv[3]);
|
|
|
|
}
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-12-14 19:11:16 +00:00
|
|
|
debugC(kDebugScript, "\trect.left: %d", rect.left);
|
|
|
|
debugC(kDebugScript, "\trect.top: %d", rect.top);
|
|
|
|
debugC(kDebugScript, "\trect.right: %d", rect.right);
|
|
|
|
debugC(kDebugScript, "\trect.bottom: %d", rect.bottom);
|
2010-12-11 12:59:56 +00:00
|
|
|
|
2010-12-14 19:11:16 +00:00
|
|
|
_vm->_gfx->copyBackBufferToScreen(rect);
|
|
|
|
_vm->_system->updateScreen();
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-12-14 19:11:16 +00:00
|
|
|
void MystScriptParser::o_copyImageToBackBuffer(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
|
|
|
uint16 imageId = argv[0];
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-12-14 19:11:16 +00:00
|
|
|
Common::Rect srcRect = Common::Rect(argv[1], argv[2], argv[3], argv[4]);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-12-14 19:11:16 +00:00
|
|
|
Common::Rect dstRect = Common::Rect(argv[5], argv[6], 544, 333);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-12-14 19:11:16 +00:00
|
|
|
if (dstRect.left == -1 || dstRect.top == -1) {
|
|
|
|
// Interpreted as full screen
|
|
|
|
dstRect.left = 0;
|
|
|
|
dstRect.top = 0;
|
|
|
|
}
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-12-14 19:11:16 +00:00
|
|
|
dstRect.right = dstRect.left + srcRect.width();
|
|
|
|
dstRect.bottom = dstRect.top + srcRect.height();
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-12-14 19:11:16 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Copy image to back buffer", op);
|
|
|
|
debugC(kDebugScript, "\timageId: %d", imageId);
|
|
|
|
debugC(kDebugScript, "\tsrcRect.left: %d", srcRect.left);
|
|
|
|
debugC(kDebugScript, "\tsrcRect.top: %d", srcRect.top);
|
|
|
|
debugC(kDebugScript, "\tsrcRect.right: %d", srcRect.right);
|
|
|
|
debugC(kDebugScript, "\tsrcRect.bottom: %d", srcRect.bottom);
|
|
|
|
debugC(kDebugScript, "\tdstRect.left: %d", dstRect.left);
|
|
|
|
debugC(kDebugScript, "\tdstRect.top: %d", dstRect.top);
|
|
|
|
debugC(kDebugScript, "\tdstRect.right: %d", dstRect.right);
|
|
|
|
debugC(kDebugScript, "\tdstRect.bottom: %d", dstRect.bottom);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-12-14 19:11:16 +00:00
|
|
|
_vm->_gfx->copyImageSectionToBackBuffer(imageId, srcRect, dstRect);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Implement common engine function for read and processing of sound blocks
|
|
|
|
// for use by this opcode and VIEW sound block.
|
|
|
|
// TODO: Though the playSound and PlaySoundBlocking opcodes play sounds immediately,
|
|
|
|
// this opcode changes the main background sound playing..
|
2011-01-03 20:40:07 +00:00
|
|
|
// Current behavior here and with VIEW sound block is not right as demonstrated
|
|
|
|
// by Channelwood Card 3280 (Tank Valve) and water flow sound behavior in pipe
|
2009-12-29 23:18:24 +00:00
|
|
|
// on cards leading from shed...
|
2010-12-18 13:12:56 +00:00
|
|
|
void MystScriptParser::o_changeBackgroundSound(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2009-12-29 23:18:24 +00:00
|
|
|
varUnusedCheck(op, var);
|
|
|
|
|
|
|
|
int16 *soundList = NULL;
|
|
|
|
uint16 *soundListVolume = NULL;
|
|
|
|
|
|
|
|
// Used on Stoneship Card 2080
|
|
|
|
// Used on Channelwood Card 3225 with argc = 8 i.e. Conditional Sound List
|
|
|
|
if (argc == 1 || argc == 2 || argc == 8) {
|
|
|
|
debugC(kDebugScript, "Opcode %d: Process Sound Block", op);
|
|
|
|
uint16 decodeIdx = 0;
|
|
|
|
|
|
|
|
int16 soundAction = argv[decodeIdx++];
|
|
|
|
uint16 soundVolume = 65535;
|
|
|
|
if (soundAction == kMystSoundActionChangeVolume || soundAction > 0) {
|
|
|
|
soundVolume = argv[decodeIdx++];
|
|
|
|
} else if (soundAction == kMystSoundActionConditional) {
|
|
|
|
debugC(kDebugScript, "Conditional sound list");
|
|
|
|
uint16 condVar = argv[decodeIdx++];
|
2010-11-29 20:49:42 +00:00
|
|
|
uint16 condVarValue = getVar(condVar);
|
2009-12-29 23:18:24 +00:00
|
|
|
uint16 condCount = argv[decodeIdx++];
|
|
|
|
|
|
|
|
debugC(kDebugScript, "\tcondVar: %d = %d", condVar, condVarValue);
|
|
|
|
debugC(kDebugScript, "\tcondCount: %d", condCount);
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
soundList = new int16[condCount];
|
|
|
|
soundListVolume = new uint16[condCount];
|
|
|
|
|
|
|
|
if (condVarValue >= condCount)
|
|
|
|
warning("Opcode %d: Conditional sound variable outside range", op);
|
|
|
|
else {
|
|
|
|
for (uint16 i = 0; i < condCount; i++) {
|
|
|
|
soundList[i] = argv[decodeIdx++];
|
|
|
|
debugC(kDebugScript, "\t\tCondition %d: Action %d", i, soundList[i]);
|
|
|
|
if (soundAction == kMystSoundActionChangeVolume || soundAction > 0) {
|
|
|
|
soundListVolume[i] = argv[decodeIdx++];
|
|
|
|
} else
|
|
|
|
soundListVolume[i] = 65535;
|
|
|
|
debugC(kDebugScript, "\t\tCondition %d: Volume %d", i, soundListVolume[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
soundAction = soundList[condVarValue];
|
|
|
|
soundVolume = soundListVolume[condVarValue];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (soundAction == kMystSoundActionContinue)
|
|
|
|
debugC(kDebugScript, "Continue current sound");
|
|
|
|
else if (soundAction == kMystSoundActionChangeVolume) {
|
|
|
|
debugC(kDebugScript, "Continue current sound, change volume");
|
|
|
|
debugC(kDebugScript, "\tVolume: %d", soundVolume);
|
2010-12-18 13:12:56 +00:00
|
|
|
_vm->_sound->changeBackgroundVolume(soundVolume);
|
2009-12-29 23:18:24 +00:00
|
|
|
} else if (soundAction == kMystSoundActionStop) {
|
|
|
|
debugC(kDebugScript, "Stop sound");
|
2010-12-18 13:12:56 +00:00
|
|
|
_vm->_sound->stopBackground();
|
2009-12-29 23:18:24 +00:00
|
|
|
} else if (soundAction > 0) {
|
|
|
|
debugC(kDebugScript, "Play new Sound, change volume");
|
|
|
|
debugC(kDebugScript, "\tSound: %d", soundAction);
|
|
|
|
debugC(kDebugScript, "\tVolume: %d", soundVolume);
|
2010-12-18 13:12:56 +00:00
|
|
|
_vm->_sound->replaceBackground(soundAction, soundVolume);
|
2009-12-29 23:18:24 +00:00
|
|
|
} else {
|
|
|
|
debugC(kDebugScript, "Unknown");
|
|
|
|
warning("Unknown sound control value in opcode %d", op);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
unknown(op, var, argc, argv);
|
|
|
|
|
|
|
|
delete[] soundList;
|
|
|
|
soundList = NULL;
|
|
|
|
delete[] soundListVolume;
|
|
|
|
soundListVolume = NULL;
|
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_soundPlaySwitch(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:56:04 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Switch Choice of Play Sound", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:04 +00:00
|
|
|
uint16 value = getVar(var);
|
2011-01-03 20:40:07 +00:00
|
|
|
|
2010-11-29 20:56:04 +00:00
|
|
|
if (value < argc) {
|
|
|
|
uint16 soundId = argv[value];
|
2009-12-29 23:18:24 +00:00
|
|
|
debugC(kDebugScript, "\tvar: %d", var);
|
2010-11-29 20:56:04 +00:00
|
|
|
debugC(kDebugScript, "\tsoundId: %d", soundId);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:04 +00:00
|
|
|
if (soundId)
|
2010-12-18 13:12:56 +00:00
|
|
|
_vm->_sound->replaceSound(soundId);
|
2010-11-29 20:56:04 +00:00
|
|
|
}
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_soundResumeBackground(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:56:21 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: soundResumeBackground", op);
|
2010-12-18 13:12:56 +00:00
|
|
|
_vm->_sound->resumeBackground();
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-12-14 19:11:16 +00:00
|
|
|
void MystScriptParser::o_copyImageToScreen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
|
|
|
uint16 imageId = argv[0];
|
|
|
|
|
|
|
|
Common::Rect srcRect = Common::Rect(argv[1], argv[2], argv[3], argv[4]);
|
|
|
|
|
|
|
|
Common::Rect dstRect = Common::Rect(argv[5], argv[6], 544, 333);
|
|
|
|
|
|
|
|
if (dstRect.left == -1 || dstRect.top == -1) {
|
|
|
|
// Interpreted as full screen
|
|
|
|
dstRect.left = 0;
|
|
|
|
dstRect.top = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
dstRect.right = dstRect.left + srcRect.width();
|
|
|
|
dstRect.bottom = dstRect.top + srcRect.height();
|
|
|
|
|
|
|
|
debugC(kDebugScript, "Opcode %d: Copy image to screen", op);
|
|
|
|
debugC(kDebugScript, "\timageId: %d", imageId);
|
|
|
|
debugC(kDebugScript, "\tsrcRect.left: %d", srcRect.left);
|
|
|
|
debugC(kDebugScript, "\tsrcRect.top: %d", srcRect.top);
|
|
|
|
debugC(kDebugScript, "\tsrcRect.right: %d", srcRect.right);
|
|
|
|
debugC(kDebugScript, "\tsrcRect.bottom: %d", srcRect.bottom);
|
|
|
|
debugC(kDebugScript, "\tdstRect.left: %d", dstRect.left);
|
|
|
|
debugC(kDebugScript, "\tdstRect.top: %d", dstRect.top);
|
|
|
|
debugC(kDebugScript, "\tdstRect.right: %d", dstRect.right);
|
|
|
|
debugC(kDebugScript, "\tdstRect.bottom: %d", dstRect.bottom);
|
|
|
|
|
|
|
|
_vm->_gfx->copyImageSectionToScreen(imageId, srcRect, dstRect);
|
|
|
|
_vm->_system->updateScreen();
|
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_changeCard(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:58:28 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Change Card", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:58:28 +00:00
|
|
|
uint16 cardId = argv[0];
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:58:28 +00:00
|
|
|
// Argument 1 if present is not used
|
|
|
|
// uint16 u0 = argv[1];
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:58:28 +00:00
|
|
|
debugC(kDebugScript, "\tTarget Card: %d", cardId);
|
|
|
|
//debugC(kDebugScript, "\tu0: %d", u0); // Unused data
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:59:17 +00:00
|
|
|
_vm->changeToCard(cardId, true);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_drawImageChangeCard(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2009-12-29 23:18:24 +00:00
|
|
|
varUnusedCheck(op, var);
|
|
|
|
|
|
|
|
if (argc == 3) {
|
|
|
|
debugC(kDebugScript, "Opcode %d: Draw Full Screen Image, Delay then Change Card", op);
|
|
|
|
|
|
|
|
uint16 imageId = argv[0];
|
|
|
|
uint16 cardId = argv[1];
|
|
|
|
uint16 delay = argv[2]; // TODO: Not sure about argv[2] being delay..
|
|
|
|
|
|
|
|
debugC(kDebugScript, "\timageId: %d", imageId);
|
|
|
|
debugC(kDebugScript, "\tcardId: %d", cardId);
|
|
|
|
debugC(kDebugScript, "\tdelay: %d", delay);
|
|
|
|
|
|
|
|
_vm->_gfx->copyImageToScreen(imageId, Common::Rect(0, 0, 544, 333));
|
2010-12-14 19:11:16 +00:00
|
|
|
_vm->_system->updateScreen();
|
2009-12-29 23:18:24 +00:00
|
|
|
_vm->_system->delayMillis(delay * 100);
|
2010-11-29 20:59:17 +00:00
|
|
|
_vm->changeToCard(cardId, true);
|
2009-12-29 23:18:24 +00:00
|
|
|
} else
|
|
|
|
unknown(op, var, argc, argv);
|
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_changeMainCursor(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:56:21 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Change main cursor", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:21 +00:00
|
|
|
uint16 cursorId = argv[0];
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-11-29 20:56:21 +00:00
|
|
|
debugC(kDebugScript, "Cursor: %d", cursorId);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:21 +00:00
|
|
|
_vm->setMainCursor(cursorId);
|
|
|
|
_vm->_cursor->setCursor(cursorId);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_hideCursor(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:56:21 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Hide Cursor", op);
|
|
|
|
_vm->_cursor->hideCursor();
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_showCursor(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:56:21 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Show Cursor", op);
|
|
|
|
_vm->_cursor->showCursor();
|
|
|
|
}
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_delay(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:56:21 +00:00
|
|
|
// Used on Mechanical Card 6327 (Elevator)
|
|
|
|
debugC(kDebugScript, "Opcode %d: Delay", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:21 +00:00
|
|
|
uint16 time = argv[0];
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:21 +00:00
|
|
|
debugC(kDebugScript, "\tTime: %d", time);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:21 +00:00
|
|
|
_vm->_system->delayMillis(time);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_changeStack(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2009-12-29 23:18:24 +00:00
|
|
|
Audio::SoundHandle *handle;
|
|
|
|
varUnusedCheck(op, var);
|
|
|
|
|
|
|
|
if (argc == 3) {
|
|
|
|
debugC(kDebugScript, "Opcode %d: changeStack", op);
|
|
|
|
|
|
|
|
uint16 targetStack = argv[0];
|
|
|
|
uint16 soundIdLinkSrc = argv[1];
|
|
|
|
uint16 soundIdLinkDst = argv[2];
|
|
|
|
|
|
|
|
debugC(kDebugScript, "\tTarget Stack: %d", targetStack);
|
|
|
|
debugC(kDebugScript, "\tSource Stack Link Sound: %d", soundIdLinkSrc);
|
|
|
|
debugC(kDebugScript, "\tDestination Stack Link Sound: %d", soundIdLinkDst);
|
|
|
|
|
|
|
|
_vm->_sound->stopSound();
|
|
|
|
|
|
|
|
if (_vm->getFeatures() & GF_DEMO) {
|
|
|
|
|
|
|
|
// The demo has linking sounds too for this, but it just sounds completely
|
|
|
|
// wrong as you're not actually linking when using this opcode. The sounds are only
|
|
|
|
// played for the full game linking.
|
|
|
|
if (!_vm->_tweaksEnabled) {
|
2010-12-18 13:12:56 +00:00
|
|
|
handle= _vm->_sound->replaceSound(soundIdLinkSrc);
|
2009-12-29 23:18:24 +00:00
|
|
|
while (_vm->_mixer->isSoundHandleActive(*handle))
|
|
|
|
_vm->_system->delayMillis(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
// No need to have a table for just this data...
|
|
|
|
if (targetStack == 1) {
|
|
|
|
_vm->changeToStack(kDemoSlidesStack);
|
2010-11-29 20:59:17 +00:00
|
|
|
_vm->changeToCard(1000, true);
|
2009-12-29 23:18:24 +00:00
|
|
|
} else if (targetStack == 2) {
|
|
|
|
_vm->changeToStack(kDemoPreviewStack);
|
2010-11-29 20:59:17 +00:00
|
|
|
_vm->changeToCard(3000, true);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!_vm->_tweaksEnabled) {
|
2010-12-18 13:12:56 +00:00
|
|
|
handle = _vm->_sound->replaceSound(soundIdLinkDst);
|
2009-12-29 23:18:24 +00:00
|
|
|
while (_vm->_mixer->isSoundHandleActive(*handle))
|
|
|
|
_vm->_system->delayMillis(10);
|
|
|
|
}
|
|
|
|
} else {
|
2010-12-18 13:12:56 +00:00
|
|
|
handle = _vm->_sound->replaceSound(soundIdLinkSrc);
|
2009-12-29 23:18:24 +00:00
|
|
|
while (_vm->_mixer->isSoundHandleActive(*handle))
|
|
|
|
_vm->_system->delayMillis(10);
|
|
|
|
|
|
|
|
// TODO: Play Flyby Entry Movie on Masterpiece Edition..? Only on Myst to Age Link?
|
|
|
|
|
2010-12-01 14:57:05 +00:00
|
|
|
_vm->changeToStack(_stackMap[targetStack]);
|
|
|
|
_vm->changeToCard(_startCard[targetStack], true);
|
2010-11-30 20:25:21 +00:00
|
|
|
|
2010-12-18 13:12:56 +00:00
|
|
|
handle = _vm->_sound->replaceSound(soundIdLinkDst);
|
2010-11-30 20:25:21 +00:00
|
|
|
while (_vm->_mixer->isSoundHandleActive(*handle))
|
|
|
|
_vm->_system->delayMillis(10);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
unknown(op, var, argc, argv);
|
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_changeCardPlaySoundDirectional(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:58:45 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Play Sound, Change Card and Directional Update Screen Region", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:58:45 +00:00
|
|
|
uint16 cardId = argv[0];
|
|
|
|
uint16 soundId = argv[1];
|
|
|
|
uint16 delayBetweenSteps = argv[2];
|
|
|
|
uint16 dataSize = argv[3];
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:58:45 +00:00
|
|
|
debugC(kDebugScript, "\tcard: %d", cardId);
|
|
|
|
debugC(kDebugScript, "\tsound: %d", soundId);
|
|
|
|
debugC(kDebugScript, "\tdelay between steps: %d", delayBetweenSteps);
|
|
|
|
debugC(kDebugScript, "\tanimated update data size: %d", dataSize);
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-11-29 20:58:45 +00:00
|
|
|
if (soundId)
|
2010-12-18 13:12:56 +00:00
|
|
|
_vm->_sound->replaceSound(soundId);
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-11-29 20:59:17 +00:00
|
|
|
_vm->changeToCard(cardId, false);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:58:45 +00:00
|
|
|
animatedUpdate(dataSize, &argv[4], delayBetweenSteps);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_directionalUpdatePlaySound(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:58:28 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Play Sound and Directional Update Screen Region", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:58:28 +00:00
|
|
|
uint16 soundId = argv[0];
|
|
|
|
uint16 delayBetweenSteps = argv[1];
|
|
|
|
uint16 dataSize = argv[2];
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-11-29 20:58:28 +00:00
|
|
|
debugC(kDebugScript, "\tsound: %d", soundId);
|
2010-11-29 20:58:45 +00:00
|
|
|
debugC(kDebugScript, "\tdelay between steps: %d", delayBetweenSteps);
|
|
|
|
debugC(kDebugScript, "\tanimated update data size: %d", dataSize);
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-11-29 20:58:28 +00:00
|
|
|
if (soundId)
|
2010-12-18 13:12:56 +00:00
|
|
|
_vm->_sound->replaceSound(soundId);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:58:45 +00:00
|
|
|
animatedUpdate(dataSize, &argv[3], delayBetweenSteps);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_saveMainCursor(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:56:21 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Save main cursor", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:21 +00:00
|
|
|
_savedCursorId = _vm->getMainCursor();
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_restoreMainCursor(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:56:21 +00:00
|
|
|
debugC(kDebugScript, "Opcode %d: Restore main cursor", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 20:56:21 +00:00
|
|
|
_vm->setMainCursor(_savedCursorId);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
void MystScriptParser::o_soundWaitStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
|
2010-11-29 20:56:21 +00:00
|
|
|
// Used on Selenitic Card 1191 (Maze Runner)
|
|
|
|
// Used on Mechanical Card 6267 (Code Lock)
|
|
|
|
// Used when Button is pushed...
|
|
|
|
debugC(kDebugScript, "Opcode %d: Wait for foreground sound to finish", op);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 21:03:02 +00:00
|
|
|
// TODO: Implement
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Mohawk
|