2013-10-24 14:24:27 +01: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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-10-13 22:34:26 +01:00
|
|
|
#include "prince/script.h"
|
2013-10-22 01:05:24 +01:00
|
|
|
#include "prince/prince.h"
|
2013-10-30 02:28:07 +00:00
|
|
|
#include "prince/flags.h"
|
|
|
|
#include "prince/variatxt.h"
|
|
|
|
#include "prince/font.h"
|
2013-10-13 22:34:26 +01:00
|
|
|
|
2013-10-14 02:31:26 +01:00
|
|
|
#include "common/debug.h"
|
2013-10-13 22:34:26 +01:00
|
|
|
#include "common/debug-channels.h"
|
|
|
|
#include "common/stream.h"
|
2013-11-02 01:29:26 +00:00
|
|
|
#include "common/archive.h"
|
2013-10-13 22:34:26 +01:00
|
|
|
|
2013-11-02 15:28:56 +00:00
|
|
|
#include "audio/decoders/wave.h"
|
|
|
|
#include "audio/audiostream.h"
|
2013-10-13 22:34:26 +01:00
|
|
|
|
|
|
|
namespace Prince {
|
|
|
|
|
2013-10-14 02:31:26 +01:00
|
|
|
static const uint16 NUM_OPCODES = 144;
|
|
|
|
|
2013-10-13 22:34:26 +01:00
|
|
|
Script::Script(PrinceEngine *vm) :
|
2013-11-02 02:02:53 +00:00
|
|
|
_code(NULL), _stacktop(0), _vm(vm), _opcodeNF(false),
|
2013-11-05 22:15:55 +00:00
|
|
|
_waitFlag(0), _result(true) {
|
2013-10-13 22:34:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Script::~Script() {
|
2013-11-05 22:22:51 +00:00
|
|
|
delete[] _code;
|
2013-10-13 22:34:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-05 21:57:10 +00:00
|
|
|
void Script::setFlagValue(Flags::Id flagId, uint16 value) {
|
|
|
|
_flags[(uint16)flagId - FLAG_MASK] = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16 Script::getFlagValue(Flags::Id flagId) {
|
|
|
|
return _flags[(uint16)flagId - FLAG_MASK];
|
2013-11-04 11:28:10 +00:00
|
|
|
}
|
|
|
|
|
2013-10-13 22:34:26 +01:00
|
|
|
bool Script::loadFromStream(Common::SeekableReadStream &stream) {
|
2013-11-05 22:22:51 +00:00
|
|
|
_codeSize = stream.size();
|
|
|
|
_code = new byte[_codeSize];
|
2013-10-13 22:34:26 +01:00
|
|
|
|
2013-11-05 22:22:51 +00:00
|
|
|
if (!_code)
|
|
|
|
return false;
|
2013-10-13 22:34:26 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
stream.read(_code, _codeSize);
|
|
|
|
// Initialize the script
|
2013-11-04 16:07:19 +00:00
|
|
|
_mode = "fg";
|
2013-11-04 11:28:10 +00:00
|
|
|
_fgOpcodePC = READ_LE_UINT32(_code + 4);
|
|
|
|
_bgOpcodePC = 0;
|
2013-10-13 22:34:26 +01:00
|
|
|
|
2013-11-05 22:22:51 +00:00
|
|
|
return true;
|
2013-10-13 22:34:26 +01:00
|
|
|
}
|
|
|
|
|
2013-10-14 02:31:26 +01:00
|
|
|
void Script::debugScript(const char *s, ...) {
|
2013-10-30 02:28:07 +00:00
|
|
|
char buf[STRINGBUFLEN];
|
2013-11-02 02:02:53 +00:00
|
|
|
va_list va;
|
2013-10-14 02:31:26 +01:00
|
|
|
|
2013-11-05 22:22:51 +00:00
|
|
|
va_start(va, s);
|
|
|
|
vsnprintf(buf, STRINGBUFLEN, s, va);
|
|
|
|
va_end(va);
|
2013-10-14 02:31:26 +01:00
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
Common::String str = Common::String::format("@0x%08X: ", _lastInstruction);
|
2013-11-02 02:02:53 +00:00
|
|
|
str += Common::String::format("op %04d: ", _lastOpcode);
|
|
|
|
//debugC(10, DebugChannel::kScript, "PrinceEngine::Script %s %s", str.c_str(), buf);
|
|
|
|
|
2013-11-05 18:45:40 +00:00
|
|
|
debug("Prince::Script frame %08ld mode %s %s %s", _vm->_frameNr, _mode, str.c_str(), buf);
|
2013-10-14 02:31:26 +01:00
|
|
|
}
|
|
|
|
|
2013-10-13 22:34:26 +01:00
|
|
|
void Script::step() {
|
2013-11-04 11:28:10 +00:00
|
|
|
if (_bgOpcodePC) {
|
2013-11-04 16:07:19 +00:00
|
|
|
_mode = "bg";
|
2013-11-04 11:28:10 +00:00
|
|
|
_bgOpcodePC = step(_bgOpcodePC);
|
|
|
|
}
|
|
|
|
if (_fgOpcodePC) {
|
2013-11-04 16:07:19 +00:00
|
|
|
_mode = "fg";
|
2013-11-04 11:28:10 +00:00
|
|
|
_fgOpcodePC = step(_fgOpcodePC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 Script::step(uint32 opcodePC) {
|
|
|
|
_currentInstruction = opcodePC;
|
2013-11-18 16:19:21 +00:00
|
|
|
|
|
|
|
while (!_opcodeNF) {
|
2013-10-30 02:28:07 +00:00
|
|
|
_lastInstruction = _currentInstruction;
|
2013-10-14 02:31:26 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
// Get the current opcode
|
|
|
|
_lastOpcode = readScript16bits();
|
2013-10-14 02:31:26 +01:00
|
|
|
|
2013-11-18 16:19:21 +00:00
|
|
|
if (_lastOpcode > NUM_OPCODES)
|
|
|
|
error(
|
|
|
|
"Trying to execute unknown opcode @0x%04X: %02d",
|
|
|
|
_currentInstruction,
|
|
|
|
_lastOpcode);
|
2013-10-14 02:31:26 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
// Execute the current opcode
|
|
|
|
OpcodeFunc op = _opcodes[_lastOpcode];
|
|
|
|
(this->*op)();
|
|
|
|
if (_opcodeNF) {
|
|
|
|
_opcodeNF = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-11-04 11:28:10 +00:00
|
|
|
|
|
|
|
return _currentInstruction;
|
2013-10-13 22:34:26 +01:00
|
|
|
}
|
|
|
|
|
2013-10-15 00:10:29 +01:00
|
|
|
uint8 Script::getCodeByte(uint32 address) {
|
2013-11-05 22:22:51 +00:00
|
|
|
if (address >= _codeSize)
|
|
|
|
error("Trying to read a script byte at address 0x%04X, while the "
|
|
|
|
"script is just 0x%04X bytes long", address, _codeSize);
|
|
|
|
return _code[address];
|
2013-10-13 22:34:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8 Script::readScript8bits() {
|
2013-11-05 22:22:51 +00:00
|
|
|
uint8 data = getCodeByte(_currentInstruction);
|
|
|
|
_currentInstruction++;
|
|
|
|
return data;
|
2013-10-13 22:34:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16 Script::readScript16bits() {
|
2013-11-05 22:22:51 +00:00
|
|
|
uint8 lower = readScript8bits();
|
|
|
|
uint8 upper = readScript8bits();
|
|
|
|
return lower | (upper << 8);
|
2013-10-13 22:34:26 +01:00
|
|
|
}
|
|
|
|
|
2013-11-05 21:57:10 +00:00
|
|
|
uint16 Script::readScriptValue() {
|
|
|
|
uint16 value = readScript16bits();
|
|
|
|
if (value & FLAG_MASK) {
|
|
|
|
value = _flags[value - FLAG_MASK];
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2013-10-13 22:34:26 +01:00
|
|
|
uint32 Script::readScript32bits() {
|
2013-11-05 22:22:51 +00:00
|
|
|
uint16 lower = readScript16bits();
|
|
|
|
uint16 upper = readScript16bits();
|
|
|
|
return lower | (upper << 16);
|
2013-10-13 22:34:26 +01:00
|
|
|
}
|
|
|
|
|
2013-10-14 02:31:26 +01:00
|
|
|
void Script::O_WAITFOREVER() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_WAITFOREVER");
|
|
|
|
_opcodeNF = 1;
|
|
|
|
_currentInstruction -= 2;
|
2013-10-14 02:31:26 +01:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-14 02:31:26 +01:00
|
|
|
void Script::O_BLACKPALETTE() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_BLACKPALETTE");
|
2013-10-14 02:31:26 +01:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-14 02:31:26 +01:00
|
|
|
void Script::O_SETUPPALETTE() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_SETUPPALETTE");
|
2013-10-14 02:31:26 +01:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-14 02:31:26 +01:00
|
|
|
void Script::O_INITROOM() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 roomId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_INITROOM %d", roomId);
|
|
|
|
_vm->loadLocation(roomId);
|
|
|
|
_opcodeNF = 1;
|
2013-10-14 02:31:26 +01:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-15 00:10:29 +01:00
|
|
|
void Script::O_SETSAMPLE() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 sampleId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
int32 sampleNameOffset = readScript32bits();
|
2013-11-18 16:19:21 +00:00
|
|
|
const char * sampleName = (const char *)&_code[_currentInstruction + sampleNameOffset - 4];
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_SETSAMPLE %d %s", sampleId, sampleName);
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_FREESAMPLE() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 sample = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_FREESAMPLE %d", sample);
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-15 23:21:00 +01:00
|
|
|
void Script::O_PLAYSAMPLE() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 sampleId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
uint16 loopType = readScript16bits();
|
|
|
|
debugScript("O_PLAYSAMPLE sampleId %d loopType %d", sampleId, loopType);
|
2013-11-05 22:15:55 +00:00
|
|
|
_vm->playSample(sampleId, loopType);
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_PUTOBJECT() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 roomId = readScriptValue();
|
|
|
|
uint16 slot = readScriptValue();
|
|
|
|
uint16 objectId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_PUTOBJECT roomId %d, slot %d, objectId %d", roomId, slot, objectId);
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_REMOBJECT() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 roomId = readScriptValue();
|
|
|
|
uint16 objectId = readScriptValue();
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_REMOBJECT roomId %d objectId %d", roomId, objectId);
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_SHOWANIM() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slot = readScriptValue();
|
|
|
|
uint16 animId = readScriptValue();
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_SHOWANIM slot %d, animId %d", slot, animId);
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_CHECKANIMEND() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slot = readScriptValue();
|
|
|
|
uint16 frameId = readScriptValue();
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_CHECKANIMEND slot %d, frameId %d", slot, frameId);
|
|
|
|
_opcodeNF = 1;
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
2013-10-15 00:10:29 +01:00
|
|
|
|
|
|
|
void Script::O_FREEANIM() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slot = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_FREEANIM slot %d", slot);
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-15 23:21:00 +01:00
|
|
|
void Script::O_CHECKANIMFRAME() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slot = readScriptValue();
|
|
|
|
uint16 frameId = readScriptValue();
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_CHECKANIMFRAME slot %d, frameId %d", slot, frameId);
|
|
|
|
_opcodeNF = 1;
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
|
|
|
|
2013-10-15 00:10:29 +01:00
|
|
|
void Script::O_PUTBACKANIM() {
|
2013-11-08 23:17:20 +00:00
|
|
|
uint16 roomId = readScriptValue();
|
|
|
|
uint16 slot = readScriptValue();
|
|
|
|
int32 animId = readScript32bits();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_PUTBACKANIM roomId %d, slot %d, animId %d", roomId, slot, animId);
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
|
|
|
void Script::O_REMBACKANIM() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 roomId = readScriptValue();
|
|
|
|
uint16 slot = readScriptValue();
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_REMBACKANIM roomId %d, slot %d", roomId, slot);
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O_CHECKBACKANIMFRAME() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slotId = readScriptValue();
|
|
|
|
uint16 frameId = readScriptValue();
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_CHECKBACKANIMFRAME slotId %d, frameId %d", slotId, frameId);
|
|
|
|
_opcodeNF = 1;
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O_FREEALLSAMPLES() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_FREEALLSAMPLES");
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O_SETMUSIC() {
|
2013-10-30 02:28:07 +00:00
|
|
|
uint16 musicId = readScript16bits();
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_SETMUSIC musicId %d", musicId);
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O_STOPMUSIC() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_STOPMUSIC");
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O__WAIT() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 pause = readScriptValue();
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O__WAIT pause %d", pause);
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-11-02 02:02:53 +00:00
|
|
|
if (_waitFlag == 0) {
|
|
|
|
// set new wait flag value and continue
|
|
|
|
_waitFlag = pause;
|
|
|
|
_opcodeNF = 1;
|
|
|
|
_currentInstruction -= 4;
|
|
|
|
return;
|
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-11-02 02:02:53 +00:00
|
|
|
--_waitFlag;
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-11-02 02:02:53 +00:00
|
|
|
if (_waitFlag > 0) {
|
|
|
|
_opcodeNF = 1;
|
|
|
|
_currentInstruction -= 4;
|
|
|
|
return;
|
|
|
|
}
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O_UPDATEOFF() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_UPDATEOFF");
|
2013-11-18 16:19:21 +00:00
|
|
|
//_updateEnable = false;
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O_UPDATEON() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_UPDATEON");
|
2013-11-18 16:19:21 +00:00
|
|
|
//_updateEnable = true;
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O_UPDATE () {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_UPDATE");
|
2013-11-18 16:19:21 +00:00
|
|
|
// Refresh screen
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_CLS() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_CLS");
|
2013-11-18 16:19:21 +00:00
|
|
|
// do nothing
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-14 02:31:26 +01:00
|
|
|
void Script::O__CALL() {
|
2013-10-30 02:28:07 +00:00
|
|
|
int32 address = readScript32bits();
|
|
|
|
_stack[_stacktop] = _currentInstruction;
|
|
|
|
_stacktop++;
|
|
|
|
_currentInstruction += address - 4;
|
|
|
|
debugScript("O__CALL 0x%04X", _currentInstruction);
|
2013-10-14 02:31:26 +01:00
|
|
|
}
|
2013-11-04 11:40:22 +00:00
|
|
|
|
2013-10-14 02:31:26 +01:00
|
|
|
void Script::O_RETURN() {
|
2013-10-30 02:28:07 +00:00
|
|
|
// Get the return address
|
|
|
|
if (_stacktop > 0) {
|
|
|
|
_stacktop--;
|
|
|
|
_currentInstruction = _stack[_stacktop];
|
|
|
|
debugScript("O_RETURN 0x%04X", _currentInstruction);
|
|
|
|
} else {
|
|
|
|
error("Return: Stack is empty");
|
|
|
|
}
|
2013-10-14 02:31:26 +01:00
|
|
|
}
|
2013-11-04 11:40:22 +00:00
|
|
|
|
2013-10-14 02:31:26 +01:00
|
|
|
void Script::O_GO() {
|
2013-10-30 02:28:07 +00:00
|
|
|
int32 opPC = readScript32bits();
|
|
|
|
debugScript("O_GO 0x%04X", opPC);
|
|
|
|
_currentInstruction += opPC - 4;
|
2013-10-14 02:31:26 +01:00
|
|
|
}
|
2013-11-04 11:40:22 +00:00
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O_BACKANIMUPDATEOFF() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slotId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_BACKANIMUPDATEOFF slotId %d", slotId);
|
2013-10-14 02:31:26 +01:00
|
|
|
}
|
2013-10-15 00:10:29 +01:00
|
|
|
|
|
|
|
void Script::O_BACKANIMUPDATEON() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slot = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_BACKANIMUPDATEON %d", slot);
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-14 02:31:26 +01:00
|
|
|
void Script::O_CHANGECURSOR() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 cursorId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_CHANGECURSOR %x", cursorId);
|
2013-10-14 02:31:26 +01:00
|
|
|
}
|
2013-10-28 00:06:21 +00:00
|
|
|
|
|
|
|
void Script::O_CHANGEANIMTYPE() {
|
2013-10-30 02:28:07 +00:00
|
|
|
// NOT IMPLEMENTED
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
|
|
|
|
2013-10-14 02:31:26 +01:00
|
|
|
void Script::O__SETFLAG() {
|
2013-11-05 21:57:10 +00:00
|
|
|
Flags::Id flagId = readScriptFlagId();
|
|
|
|
uint16 value = readScriptValue();
|
2013-10-28 00:06:21 +00:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O__SETFLAG 0x%04X (%s) = %d", flagId, Flags::getFlagName(flagId), value);
|
|
|
|
|
2013-11-05 21:57:10 +00:00
|
|
|
setFlagValue((Flags::Id)(flagId), value);
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_COMPARE() {
|
2013-11-05 21:57:10 +00:00
|
|
|
Flags::Id flagId = readScriptFlagId();
|
|
|
|
uint16 value = readScriptValue();
|
2013-10-28 00:06:21 +00:00
|
|
|
|
2013-11-05 21:57:10 +00:00
|
|
|
_result = getFlagValue(flagId) != value;
|
|
|
|
debugScript("O_COMPARE flagId 0x%04X (%s), value %d == %d (%d)", flagId, Flags::getFlagName(flagId), value, getFlagValue(flagId), _result);
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_JUMPZ() {
|
2013-10-30 02:28:07 +00:00
|
|
|
int32 offset = readScript32bits();
|
|
|
|
if (! _result) {
|
|
|
|
_currentInstruction += offset - 4;
|
|
|
|
}
|
2013-11-05 18:45:40 +00:00
|
|
|
|
|
|
|
debugScript("O_JUMPZ result = %d, next %08x, offset 0x%08X", _result, _currentInstruction, offset);
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_JUMPNZ() {
|
2013-10-30 02:28:07 +00:00
|
|
|
int32 offset = readScript32bits();
|
|
|
|
if (_result) {
|
|
|
|
_currentInstruction += offset - 4;
|
|
|
|
}
|
2013-11-05 18:45:40 +00:00
|
|
|
|
|
|
|
debugScript("O_JUMPNZ result = %d, next %08x, offset 0x%08X", _result, _currentInstruction, offset);
|
2013-10-14 02:31:26 +01:00
|
|
|
}
|
2013-10-15 00:10:29 +01:00
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O_EXIT() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 exitCode = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_EXIT exitCode %d", exitCode);
|
2013-11-18 16:19:21 +00:00
|
|
|
// Set exit code and shows credits
|
|
|
|
// if exit code == 0x02EAD
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
2013-10-15 00:10:29 +01:00
|
|
|
|
|
|
|
void Script::O_ADDFLAG() {
|
2013-11-05 21:57:10 +00:00
|
|
|
Flags::Id flagId = readScriptFlagId();
|
|
|
|
uint16 value = readScriptValue();
|
2013-10-15 00:10:29 +01:00
|
|
|
|
2013-11-05 21:57:10 +00:00
|
|
|
setFlagValue(flagId, getFlagValue(flagId) + value);
|
|
|
|
if (getFlagValue(flagId))
|
2013-10-30 02:28:07 +00:00
|
|
|
_result = 1;
|
|
|
|
else
|
|
|
|
_result = 0;
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_ADDFLAG flagId %04x (%s), value %d", flagId, Flags::getFlagName(flagId), value);
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_TALKANIM() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 animSlot = readScriptValue();
|
|
|
|
uint16 slot = readScriptValue();
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_TALKANIM animSlot %d, slot %d", animSlot, slot);
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-15 23:21:00 +01:00
|
|
|
void Script::O_SUBFLAG() {
|
2013-11-05 21:57:10 +00:00
|
|
|
Flags::Id flagId = readScriptFlagId();
|
|
|
|
uint16 value = readScriptValue();
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-11-05 21:57:10 +00:00
|
|
|
setFlagValue(flagId, getFlagValue(flagId) - value);
|
|
|
|
if (getFlagValue(flagId))
|
2013-10-30 02:28:07 +00:00
|
|
|
_result = 1;
|
|
|
|
else
|
|
|
|
_result = 0;
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_SUBFLAG flagId %d, value %d", flagId, value);
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
2013-10-15 00:10:29 +01:00
|
|
|
|
|
|
|
void Script::O_SETSTRING() {
|
2013-10-30 02:28:07 +00:00
|
|
|
int32 offset = readScript32bits();
|
2013-11-02 01:29:26 +00:00
|
|
|
_currentString = offset;
|
2013-10-15 00:10:29 +01:00
|
|
|
|
2013-11-18 16:19:21 +00:00
|
|
|
// FIXME: Make it better ;)
|
2013-10-30 02:28:07 +00:00
|
|
|
if (offset >= 80000) {
|
2013-11-05 18:45:40 +00:00
|
|
|
debugScript("GetVaria %s", _vm->_variaTxt->getString(offset - 80000));
|
2013-10-30 02:28:07 +00:00
|
|
|
}
|
|
|
|
else if (offset < 2000) {
|
|
|
|
uint32 of = READ_LE_UINT32(_vm->_talkTxt+offset*4);
|
|
|
|
const char * txt = (const char *)&_vm->_talkTxt[of];
|
|
|
|
_string = &_vm->_talkTxt[of];
|
2013-11-05 18:45:40 +00:00
|
|
|
debugScript("TalkTxt %d %s", of, txt);
|
2013-10-30 02:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-11-02 01:29:26 +00:00
|
|
|
debugScript("O_SETSTRING %04d", offset);
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O_ANDFLAG() {
|
2013-11-05 21:57:10 +00:00
|
|
|
Flags::Id flagId = readScriptFlagId();
|
|
|
|
uint16 value = readScriptValue();
|
2013-10-15 00:10:29 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_ANDFLAG flagId %d, value %d", flagId, value);
|
2013-10-28 00:06:21 +00:00
|
|
|
|
2013-11-05 21:57:10 +00:00
|
|
|
setFlagValue(flagId, getFlagValue(flagId) & value);
|
2013-10-28 00:06:21 +00:00
|
|
|
|
2013-11-05 21:57:10 +00:00
|
|
|
if (getFlagValue(flagId)) {
|
2013-10-30 02:28:07 +00:00
|
|
|
_result = 1;
|
|
|
|
} else {
|
|
|
|
_result = 0;
|
|
|
|
}
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O_GETMOBDATA() {
|
2013-11-05 21:57:10 +00:00
|
|
|
Flags::Id flagId = readScriptFlagId();
|
2013-10-30 02:28:07 +00:00
|
|
|
uint16 mobId = readScript16bits();
|
|
|
|
uint16 mobOffset = readScript16bits();
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_GETMOBDATA flagId %d, modId %d, mobOffset %d", flagId, mobId, mobOffset);
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O_ORFLAG() {
|
2013-11-05 21:57:10 +00:00
|
|
|
Flags::Id flagId = readScriptFlagId();
|
|
|
|
uint16 value = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
|
|
|
|
debugScript("O_ORFLAG flagId %d, value %d", flagId, value);
|
2013-11-05 21:57:10 +00:00
|
|
|
|
|
|
|
setFlagValue(flagId, getFlagValue(flagId) | value);
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-11-05 21:57:10 +00:00
|
|
|
if (getFlagValue(flagId)) {
|
2013-10-30 02:28:07 +00:00
|
|
|
_result = 1;
|
|
|
|
} else {
|
|
|
|
_result = 0;
|
|
|
|
}
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-28 00:06:21 +00:00
|
|
|
void Script::O_SETMOBDATA() {
|
2013-11-14 14:44:24 +00:00
|
|
|
uint16 mobId = readScriptValue();
|
|
|
|
uint16 mobOffset = readScriptValue();
|
|
|
|
uint16 value = readScriptValue();
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_SETMOBDATA mobId %d, mobOffset %d, value %d", mobId, mobOffset, value);
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_XORFLAG() {
|
2013-11-05 21:57:10 +00:00
|
|
|
Flags::Id flagId = readScriptFlagId();
|
|
|
|
uint16 value = readScriptValue();
|
2013-10-28 00:06:21 +00:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_XORFLAG flagId %d, value %d", flagId, value);
|
2013-10-28 00:06:21 +00:00
|
|
|
|
2013-11-05 21:57:10 +00:00
|
|
|
setFlagValue(flagId, getFlagValue(flagId) ^ value);
|
2013-10-28 00:06:21 +00:00
|
|
|
|
2013-11-05 21:57:10 +00:00
|
|
|
if (getFlagValue(flagId)) {
|
2013-10-30 02:28:07 +00:00
|
|
|
_result = 1;
|
|
|
|
} else {
|
|
|
|
_result = 0;
|
|
|
|
}
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_GETMOBTEXT() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 value = readScriptValue();
|
2013-10-28 00:06:21 +00:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_GETMOBTEXT value %d", value);
|
2013-11-18 16:19:21 +00:00
|
|
|
// Use Mob::ExamText as current string
|
2013-10-28 00:06:21 +00:00
|
|
|
}
|
2013-10-15 00:10:29 +01:00
|
|
|
|
|
|
|
void Script::O_MOVEHERO() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 heroId = readScriptValue();
|
|
|
|
uint16 x = readScriptValue();
|
|
|
|
uint16 y = readScriptValue();
|
|
|
|
uint16 dir = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
|
|
|
|
debugScript("O_MOVEHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir);
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_WALKHERO() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 heroId = readScriptValue();
|
2013-10-15 00:10:29 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_WALKHERO %d", heroId);
|
|
|
|
_opcodeNF = 1;
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_SETHERO() {
|
2013-11-14 14:44:24 +00:00
|
|
|
uint16 hero = readScriptValue();
|
|
|
|
uint16 x = readScriptValue();
|
|
|
|
uint16 y = readScriptValue();
|
|
|
|
uint16 dir = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_SETHERO hero %d, x %d, y %d, dir %d", hero, x, y, dir);
|
|
|
|
}
|
|
|
|
|
2013-10-14 02:31:26 +01:00
|
|
|
void Script::O_HEROOFF() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 heroId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_HEROOFF %d", heroId);
|
2013-11-18 16:19:21 +00:00
|
|
|
// sets hero visible flag to false
|
2013-10-14 02:31:26 +01:00
|
|
|
}
|
2013-10-15 00:10:29 +01:00
|
|
|
|
|
|
|
void Script::O_HEROON() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 heroId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_HEROON %d", heroId);
|
2013-11-18 16:19:21 +00:00
|
|
|
// sets hero visible flag to true
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_CLSTEXT() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slot = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_CLSTEXT slot %d", slot);
|
2013-11-18 16:19:21 +00:00
|
|
|
// Sets text line to null
|
|
|
|
// Sets text timeout to zero
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_CALLTABLE() {
|
|
|
|
uint16 flag = readScript16bits();
|
|
|
|
int32 table = readScript32bits();
|
|
|
|
|
|
|
|
debugScript("O_CALLTABLE flag %d, table %d", flag, table);
|
2013-11-18 16:19:21 +00:00
|
|
|
// makes a call from script function table
|
|
|
|
// must read table pointer from _code and
|
|
|
|
// use table entry as next opcode
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_CHANGEMOB() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 mob = readScriptValue();
|
|
|
|
uint16 value = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_CHANGEMOB mob %d, value %d", mob, value);
|
2013-11-18 16:19:21 +00:00
|
|
|
// Probably sets mobs visible flag to value
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_ADDINV() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 hero = readScriptValue();
|
|
|
|
uint16 item = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_ADDINV hero %d, item %d", hero, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_REMINV() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 hero = readScriptValue();
|
|
|
|
uint16 item = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_REMINV hero %d, item %d", hero, item);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_REPINV() {
|
|
|
|
uint16 hero = readScript16bits();
|
|
|
|
uint16 item1 = readScript16bits();
|
|
|
|
uint16 item2 = readScript16bits();
|
2013-11-18 16:19:21 +00:00
|
|
|
// shouldn't be uses
|
|
|
|
error("O_REPINV hero %d, item1 %d, item2 %d", hero, item1, item2);
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_OBSOLETE_GETACTION() {
|
2013-11-18 16:19:21 +00:00
|
|
|
// shouldn't be uses
|
|
|
|
error("O_OBSOLETE_GETACTION");
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_ADDWALKAREA() {
|
|
|
|
uint16 x1 = readScript16bits();
|
|
|
|
uint16 y1 = readScript16bits();
|
|
|
|
uint16 x2 = readScript16bits();
|
|
|
|
uint16 y2 = readScript16bits();
|
2013-11-18 16:19:21 +00:00
|
|
|
// shouldn't be uses
|
|
|
|
error("O_ADDWALKAREA x1 %d, y1 %d, x2 %d, y2 %d", x1, y1, x2, y2);
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_REMWALKAREA() {
|
|
|
|
uint16 x1 = readScript16bits();
|
|
|
|
uint16 y1 = readScript16bits();
|
|
|
|
uint16 x2 = readScript16bits();
|
|
|
|
uint16 y2 = readScript16bits();
|
2013-11-18 16:19:21 +00:00
|
|
|
|
|
|
|
// shouldn't be uses
|
|
|
|
error("O_REMWALKAREA x1 %d, y1 %d, x2 %d, y2 %d", x1, y1, x2, y2);
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_RESTOREWALKAREA() {
|
|
|
|
debugScript("O_RESTOREWALKAREA");
|
|
|
|
}
|
2013-10-22 01:05:24 +01:00
|
|
|
|
|
|
|
void Script::O_WAITFRAME() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_WAITFRAME");
|
|
|
|
_opcodeNF = true;
|
2013-10-22 01:05:24 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_SETFRAME() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 anim = readScriptValue();
|
|
|
|
uint16 frame = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_SETFRAME anim %d, frame %d", anim, frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_RUNACTION() {
|
2013-11-18 16:19:21 +00:00
|
|
|
// It's empty in original and never used in script
|
|
|
|
// it's better to report error
|
|
|
|
error("O_RUNACTION");
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_COMPAREHI() {
|
2013-11-18 16:19:21 +00:00
|
|
|
Flags::Id flag = readScriptFlagId();
|
|
|
|
uint16 value = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
|
|
|
|
debugScript("O_COMPAREHI flag %d, value %d", flag, value);
|
2013-11-18 16:19:21 +00:00
|
|
|
_result = value < getFlagValue(flag);
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_COMPARELO() {
|
2013-11-18 16:19:21 +00:00
|
|
|
Flags::Id flag = readScriptFlagId();
|
|
|
|
uint16 value = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
|
|
|
|
debugScript("O_COMPARELO flag %d, value %d", flag, value);
|
2013-11-18 16:19:21 +00:00
|
|
|
_result = value > getFlagValue(flag);
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_PRELOADSET() {
|
2013-11-18 16:19:21 +00:00
|
|
|
// not used in script
|
2013-11-04 16:07:19 +00:00
|
|
|
int32 offset = readScript32bits();
|
|
|
|
debugScript("O_PRELOADSET offset %04x", offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_FREEPRELOAD() {
|
2013-11-18 16:19:21 +00:00
|
|
|
// not used in script
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_FREEPRELOAD");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_CHECKINV() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 hero = readScriptValue();
|
|
|
|
uint16 item = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_CHECKINV hero %d, item %d", hero, item);
|
2013-11-18 16:19:21 +00:00
|
|
|
// checks if item is in heros inventory
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_TALKHERO() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 hero = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_TALKHERO hero %d", hero);
|
|
|
|
}
|
2013-10-15 00:10:29 +01:00
|
|
|
|
|
|
|
void Script::O_WAITTEXT() {
|
2013-11-05 21:57:10 +00:00
|
|
|
uint16 slot = readScriptValue();
|
2013-11-02 01:29:26 +00:00
|
|
|
Text &text = _vm->_textSlots[slot];
|
|
|
|
if (text._time) {
|
|
|
|
_opcodeNF = 1;
|
|
|
|
_currentInstruction -= 4;
|
|
|
|
}
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_SETHEROANIM() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 hero = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
int32 offset = readScript32bits();
|
|
|
|
debugScript("O_SETHEROANIM hero %d, offset %d", hero, offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_WAITHEROANIM() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 hero = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
|
|
|
|
debugScript("O_WAITHEROANIM hero %d", hero);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_GETHERODATA() {
|
|
|
|
uint16 flag = readScript16bits();
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 hero = readScriptValue();
|
|
|
|
uint16 heroOffset = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_GETHERODATA flag %d, hero %d, heroOffset %d", flag, hero, heroOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_GETMOUSEBUTTON() {
|
|
|
|
debugScript("O_GETMOUSEBUTTON");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_CHANGEFRAMES() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 anim = readScriptValue();
|
|
|
|
uint16 frame = readScriptValue();
|
|
|
|
uint16 lastFrame = readScriptValue();
|
|
|
|
uint16 loopFrame = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
|
2013-11-18 16:19:21 +00:00
|
|
|
debugScript(
|
|
|
|
"O_CHANGFRAMES anim %d, fr1 %d, fr2 %d, fr3 %d",
|
|
|
|
anim,
|
|
|
|
frame,
|
|
|
|
lastFrame,
|
|
|
|
loopFrame);
|
2013-11-04 16:07:19 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_CHANGEBACKFRAMES() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 anim = readScriptValue();
|
|
|
|
uint16 frame = readScriptValue();
|
|
|
|
uint16 lastFrame = readScriptValue();
|
|
|
|
uint16 loopFrame = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
|
2013-11-18 16:19:21 +00:00
|
|
|
debugScript(
|
|
|
|
"O_CHANGEBACKFRAMES anim %d, fr1 %d, fr2 %d, fr3 %d",
|
|
|
|
anim,
|
|
|
|
frame,
|
|
|
|
lastFrame,
|
|
|
|
loopFrame);
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_GETBACKANIMDATA() {
|
|
|
|
uint16 flag = readScript16bits();
|
|
|
|
uint16 anim = readScript16bits();
|
|
|
|
uint16 animOffset = readScript16bits();
|
|
|
|
debugScript("O_GETBACKANIMDATA flag %d, anim %d, animOffset %d", flag, anim, animOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_GETANIMDATA() {
|
|
|
|
uint16 flag = readScript16bits();
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 anim = readScriptValue();
|
|
|
|
uint16 animOffset = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_GETANIMDATA flag %d, anim %d, animOffset %d", flag, anim, animOffset);
|
2013-11-18 16:19:21 +00:00
|
|
|
// Gets value of anim data
|
|
|
|
// use anim offset as attribute id not an offset
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
2013-10-15 00:10:29 +01:00
|
|
|
void Script::O_SETBGCODE() {
|
2013-11-05 18:45:40 +00:00
|
|
|
int32 offset = readScript32bits();
|
|
|
|
_bgOpcodePC = _currentInstruction + offset;
|
|
|
|
debugScript("O_SETBGCODE next %08x, offset %08x", _bgOpcodePC, offset);
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_SETBACKFRAME() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 anim = readScriptValue();
|
|
|
|
uint16 frame = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
|
|
|
|
debugScript("O_SETBACKFRAME anim %d, frame %d", anim, frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_GETRND() {
|
2013-11-18 16:19:21 +00:00
|
|
|
Flags::Id flag = readScriptFlagId();
|
2013-11-04 16:07:19 +00:00
|
|
|
uint16 rndSeed = readScript16bits();
|
|
|
|
debugScript("O_GETRND flag %d, rndSeed %d", flag, rndSeed);
|
2013-11-18 16:19:21 +00:00
|
|
|
// puts and random value as flag value
|
|
|
|
// fairly random value ;)
|
|
|
|
// setFlagValue(flag, 4);
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_TALKBACKANIM() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 animSlot = readScriptValue();
|
|
|
|
uint16 slot = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_TALKBACKANIM animSlot %d, slot %d", animSlot, slot);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_LOADPATH() {
|
|
|
|
int32 offset = readScript32bits();
|
|
|
|
debugScript("O_LOADPATH offset %d", offset);
|
2013-11-18 16:19:21 +00:00
|
|
|
// _currentInstruction + offset path file name ptr
|
|
|
|
// free path bitmap
|
|
|
|
// load packet path bitmap and puts in Sala
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_GETCHAR() {
|
2013-11-05 21:57:10 +00:00
|
|
|
Flags::Id flagId = readScriptFlagId();
|
2013-10-30 02:28:07 +00:00
|
|
|
|
2013-11-05 21:57:10 +00:00
|
|
|
setFlagValue(flagId, *_string);
|
2013-10-30 02:28:07 +00:00
|
|
|
|
2013-11-18 16:19:21 +00:00
|
|
|
debugScript(
|
|
|
|
"O_GETCHAR %04X (%s) %02x",
|
|
|
|
flagId,
|
|
|
|
Flags::getFlagName(flagId),
|
|
|
|
getFlagValue(flagId));
|
2013-11-02 01:29:26 +00:00
|
|
|
|
2013-11-02 02:02:53 +00:00
|
|
|
++_string;
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_SETDFLAG() {
|
|
|
|
uint16 flag = readScript16bits();
|
|
|
|
int32 offset = readScript32bits();
|
|
|
|
debugScript("O_SETDFLAG flag %d, offset %04x", flag, offset);
|
2013-11-18 16:19:21 +00:00
|
|
|
// run this through debugger looks strange
|
|
|
|
// it looks like this one store two 16 bit value in one go
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_CALLDFLAG() {
|
|
|
|
uint16 flag = readScript16bits();
|
|
|
|
debugScript("O_CALLDFLAG flag %d", flag);
|
2013-11-18 16:19:21 +00:00
|
|
|
// it seems that some flags are 32 bit long
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
2013-10-30 02:28:07 +00:00
|
|
|
|
|
|
|
void Script::O_PRINTAT() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slot = readScriptValue();
|
|
|
|
uint16 fr1 = readScriptValue();
|
|
|
|
uint16 fr2 = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
|
|
|
|
debugScript("O_PRINTAT slot %d, fr1 %d, fr2 %d", slot, fr1, fr2);
|
|
|
|
|
2013-11-05 21:57:10 +00:00
|
|
|
uint8 color = getFlagValue(Flags::KOLOR);
|
2013-11-02 01:29:26 +00:00
|
|
|
|
|
|
|
_vm->printAt(slot, color, (const char *)_string, fr1, fr2);
|
2013-10-30 02:28:07 +00:00
|
|
|
|
|
|
|
while (*_string) {
|
|
|
|
++_string;
|
|
|
|
}
|
|
|
|
++_string;
|
|
|
|
}
|
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_ZOOMIN() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slot = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_ZOOMIN slot %04d", slot);
|
|
|
|
}
|
2013-11-02 15:28:56 +00:00
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_ZOOMOUT() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slot = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_ZOOMOUT slot %d", slot);
|
|
|
|
}
|
2013-11-02 15:28:56 +00:00
|
|
|
|
2013-11-04 11:28:10 +00:00
|
|
|
void Script::O_SETSTRINGOFFSET() {
|
2013-11-04 16:07:19 +00:00
|
|
|
int32 offset = readScript32bits();
|
|
|
|
debugScript("O_SETSTRINGOFFSET offset %04x", offset);
|
2013-11-18 16:19:21 +00:00
|
|
|
// _currentString = ""
|
|
|
|
// _string = (const char *)_currentInstruction + offset
|
2013-11-04 11:28:10 +00:00
|
|
|
}
|
2013-11-02 15:28:56 +00:00
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_GETOBJDATA() {
|
2013-11-18 16:19:21 +00:00
|
|
|
Flags::Id flag = readScriptFlagId();
|
|
|
|
uint16 obj = readScriptValue();
|
|
|
|
int16 objOffset = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_GETOBJDATA flag %d, obj %d, objOffset %d", flag, obj, objOffset);
|
|
|
|
}
|
2013-11-02 15:28:56 +00:00
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_SETOBJDATA() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 obj = readScriptValue();
|
|
|
|
int16 objOffset = readScriptValue();
|
|
|
|
uint16 value = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_SETOBJDATA obj %d, objOffset %d, value %d", obj, objOffset, value);
|
|
|
|
}
|
2013-11-02 15:28:56 +00:00
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_SWAPOBJECTS() {
|
|
|
|
uint16 obj1 = readScript16bits();
|
|
|
|
uint16 obj2 = readScript16bits();
|
|
|
|
debugScript("O_SWAPOBJECTS obj1 %d, obj2 %d", obj1, obj2);
|
|
|
|
}
|
2013-11-02 15:28:56 +00:00
|
|
|
|
2013-11-04 11:28:10 +00:00
|
|
|
void Script::O_CHANGEHEROSET() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 hero = readScriptValue();
|
|
|
|
uint16 heroSet = readScriptValue();
|
2013-11-04 11:28:10 +00:00
|
|
|
debugScript("O_CHANGEHEROSET hero %d, heroSet %d", hero, heroSet);
|
|
|
|
}
|
2013-11-02 15:28:56 +00:00
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_ADDSTRING() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 value = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_ADDSTRING value %d", value);
|
2013-11-18 16:19:21 +00:00
|
|
|
// _string += value
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
2013-11-02 15:28:56 +00:00
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_SUBSTRING() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 value = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_SUBSTRING value %d", value);
|
2013-11-18 16:19:21 +00:00
|
|
|
// _string -= value
|
2013-11-04 16:07:19 +00:00
|
|
|
}
|
2013-11-02 15:28:56 +00:00
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_INITDIALOG() {
|
|
|
|
debugScript("O_INITDIALOG");
|
|
|
|
}
|
2013-11-02 15:28:56 +00:00
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_ENABLEDIALOGOPT() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 opt = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_ENABLEDIALOGOPT opt %d", opt);
|
|
|
|
}
|
2013-11-02 15:28:56 +00:00
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_DISABLEDIALOGOPT() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 opt = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_DISABLEDIALOGOPT opt %d", opt);
|
|
|
|
}
|
2013-11-02 15:28:56 +00:00
|
|
|
|
2013-11-04 16:07:19 +00:00
|
|
|
void Script::O_SHOWDIALOGBOX() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 box = readScriptValue();
|
2013-11-04 16:07:19 +00:00
|
|
|
debugScript("O_SHOWDIALOGBOX box %d", box);
|
|
|
|
}
|
2013-10-15 00:10:29 +01:00
|
|
|
|
|
|
|
void Script::O_STOPSAMPLE() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slot = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_STOPSAMPLE slot %d", slot);
|
2013-11-05 22:15:55 +00:00
|
|
|
_vm->stopSample(slot);
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-24 01:01:55 +01:00
|
|
|
void Script::O_BACKANIMRANGE() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slotId = readScriptValue();
|
|
|
|
uint16 animId = readScriptValue();
|
|
|
|
uint16 low = readScriptValue();
|
|
|
|
uint16 high = readScriptValue();
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_BACKANIMRANGE slotId %d, animId %d, low %d, high %d", slotId, animId, low, high);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_CLEARPATH() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_CLEARPATH");
|
2013-11-18 16:19:21 +00:00
|
|
|
// Fill Sala with 255
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_SETPATH() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_SETPATH");
|
2013-11-18 16:19:21 +00:00
|
|
|
// CopyPath
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_GETHEROX() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 heroId = readScriptValue();
|
2013-11-05 21:57:10 +00:00
|
|
|
Flags::Id flagId = readScriptFlagId();
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_GETHEROX heroId %d, flagId %d", heroId, flagId);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_GETHEROY() {
|
2013-10-30 02:28:07 +00:00
|
|
|
uint16 heroId = readScript16bits();
|
2013-11-05 21:57:10 +00:00
|
|
|
Flags::Id flagId = readScriptFlagId();
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_GETHEROY heroId %d, flagId %d", heroId, flagId);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_GETHEROD() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 heroId = readScriptValue();
|
2013-11-05 21:57:10 +00:00
|
|
|
Flags::Id flagId = readScriptFlagId();
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_GETHEROD heroId %d, flagId %d", heroId, flagId);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_PUSHSTRING() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_PUSHSTRING");
|
2013-11-18 16:19:21 +00:00
|
|
|
// push on the stack
|
|
|
|
// _currentString
|
|
|
|
// _dialogData
|
|
|
|
// _string
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_POPSTRING() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_POPSTRING");
|
2013-11-18 16:19:21 +00:00
|
|
|
// pop from the stack
|
|
|
|
// _currentString
|
|
|
|
// _dialogData
|
|
|
|
// _string
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_SETFGCODE() {
|
2013-10-30 02:28:07 +00:00
|
|
|
int32 offset = readScript32bits();
|
2013-11-04 11:28:10 +00:00
|
|
|
_fgOpcodePC = _currentInstruction + offset;
|
2013-11-05 18:45:40 +00:00
|
|
|
|
|
|
|
debugScript("O_SETFGCODE next %08x, offset %08x", _fgOpcodePC, offset);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_STOPHERO() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 heroId = readScriptValue();
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_STOPHERO heroId %d", heroId);
|
2013-11-18 16:19:21 +00:00
|
|
|
|
|
|
|
// clear move steps for hero
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_ANIMUPDATEOFF() {
|
2013-10-30 02:28:07 +00:00
|
|
|
uint16 slotId = readScript16bits();
|
|
|
|
debugScript("O_ANIMUPDATEOFF slotId %d", slotId);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_ANIMUPDATEON() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 slotId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_ANIMUPDATEON slotId %d", slotId);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
2013-10-15 00:10:29 +01:00
|
|
|
|
|
|
|
void Script::O_FREECURSOR() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_FREECURSOR");
|
2013-11-18 16:19:21 +00:00
|
|
|
// Change cursor to 0
|
|
|
|
// free inv cursor 1
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-24 01:01:55 +01:00
|
|
|
void Script::O_ADDINVQUIET() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 heroId = readScriptValue();
|
|
|
|
uint16 itemId = readScriptValue();
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_ADDINVQUIET heorId %d, itemId %d", heroId, itemId);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_RUNHERO() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 heroId = readScriptValue();
|
|
|
|
uint16 x = readScriptValue();
|
|
|
|
uint16 y = readScriptValue();
|
|
|
|
uint16 dir = readScriptValue();
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_RUNHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_SETBACKANIMDATA() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 animId = readScriptValue();
|
|
|
|
uint16 animOffset = readScriptValue();
|
|
|
|
uint16 wart = readScriptValue();
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_SETBACKANIMDATA animId %d, animOffset %d, wart %d", animId, animOffset, wart);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
2013-10-22 01:05:24 +01:00
|
|
|
|
|
|
|
void Script::O_VIEWFLC() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 animNr = readScriptValue();
|
2013-11-05 18:45:40 +00:00
|
|
|
debugScript("O_VIEWFLC animNr %d", animNr);
|
2013-10-30 02:28:07 +00:00
|
|
|
_vm->loadAnim(animNr, false);
|
2013-10-22 01:05:24 +01:00
|
|
|
}
|
|
|
|
|
2013-10-24 01:01:55 +01:00
|
|
|
void Script::O_CHECKFLCFRAME() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 frameNr = readScriptValue();
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_CHECKFLCFRAME frame number %d", frameNr);
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
const Video::FlicDecoder &flicPlayer = _vm->_flicPlayer;
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-11-18 16:19:21 +00:00
|
|
|
if (flicPlayer.getCurFrame() != frameNr) {
|
2013-10-30 02:28:07 +00:00
|
|
|
// Move instruction pointer before current instruciton
|
|
|
|
// must do this check once again till it's false
|
|
|
|
_currentInstruction -= 2;
|
|
|
|
_opcodeNF = 1;
|
|
|
|
}
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_CHECKFLCEND() {
|
|
|
|
|
2013-11-02 01:29:26 +00:00
|
|
|
//debugScript("O_CHECKFLCEND");
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
const Video::FlicDecoder &flicPlayer = _vm->_flicPlayer;
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
//debug("frameCount %d, currentFrame %d", flicPlayer.getFrameCount(), flicPlayer.getCurFrame());
|
2013-10-24 01:01:55 +01:00
|
|
|
|
2013-11-18 16:19:21 +00:00
|
|
|
if (flicPlayer.getFrameCount() - flicPlayer.getCurFrame() > 1) {
|
2013-10-30 02:28:07 +00:00
|
|
|
// Move instruction pointer before current instruciton
|
|
|
|
// must do this check once again till it's false
|
|
|
|
_currentInstruction -= 2;
|
|
|
|
_opcodeNF = 1;
|
|
|
|
}
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_FREEFLC() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_FREEFLC");
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
2013-10-22 01:05:24 +01:00
|
|
|
|
2013-10-24 01:01:55 +01:00
|
|
|
void Script::O_TALKHEROSTOP() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 heroId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_TALKHEROSTOP %d", heroId);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
2013-10-22 01:05:24 +01:00
|
|
|
|
2013-10-24 01:01:55 +01:00
|
|
|
void Script::O_HEROCOLOR() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 heroId = readScriptValue();
|
|
|
|
uint16 kolorr = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_HEROCOLOR heroId %d, kolorr %d", heroId, kolorr);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_GRABMAPA() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_GRABMAPA");
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_ENABLENAK() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 nakId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_ENABLENAK nakId %d", nakId);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_DISABLENAK() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 nakId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_DISABLENAK nakId %d", nakId);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_GETMOBNAME() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 war = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_GETMOBNAME war %d", war);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_SWAPINVENTORY() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 heroId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_SWAPINVENTORY heroId %d", heroId);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_CLEARINVENTORY() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 heroId = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_CLEARINVENTORY heroId %d", heroId);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
2013-10-15 00:10:29 +01:00
|
|
|
|
|
|
|
void Script::O_SKIPTEXT() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_SKIPTEXT");
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-11-18 16:19:21 +00:00
|
|
|
void Script::SetVoice(uint32 sampleSlot) {
|
|
|
|
// TODO: use sample slot
|
|
|
|
uint16 slot = readScriptValue();
|
2013-11-05 22:15:55 +00:00
|
|
|
_vm->loadVoice(
|
|
|
|
slot,
|
|
|
|
Common::String::format(
|
|
|
|
"%03d-%02d.WAV",
|
|
|
|
_currentString,
|
|
|
|
getFlagValue(Flags::VOICE_H_LINE)
|
|
|
|
)
|
|
|
|
);
|
2013-10-15 00:10:29 +01:00
|
|
|
}
|
|
|
|
|
2013-10-24 01:01:55 +01:00
|
|
|
void Script::O_SETVOICEH() {
|
2013-11-18 16:19:21 +00:00
|
|
|
static const uint32 VOICE_H_SLOT = 28;
|
|
|
|
SetVoice(VOICE_H_SLOT);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-24 01:01:55 +01:00
|
|
|
void Script::O_SETVOICEA() {
|
2013-11-18 16:19:21 +00:00
|
|
|
static const uint32 VOICE_A_SLOT = 29;
|
|
|
|
SetVoice(VOICE_A_SLOT);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-24 01:01:55 +01:00
|
|
|
void Script::O_SETVOICEB() {
|
2013-11-18 16:19:21 +00:00
|
|
|
static const uint32 VOICE_B_SLOT = 30;
|
|
|
|
SetVoice(VOICE_B_SLOT);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-24 01:01:55 +01:00
|
|
|
void Script::O_SETVOICEC() {
|
2013-11-18 16:19:21 +00:00
|
|
|
static const uint32 VOICE_C_SLOT = 31;
|
|
|
|
SetVoice(VOICE_C_SLOT);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_SETVOICED() {
|
|
|
|
static const uint32 VOICE_D_SLOT = 32;
|
|
|
|
SetVoice(VOICE_D_SLOT);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-24 01:01:55 +01:00
|
|
|
void Script::O_VIEWFLCLOOP() {
|
2013-11-05 21:57:10 +00:00
|
|
|
uint16 value = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_VIEWFLCLOOP animId %d", value);
|
|
|
|
|
|
|
|
_vm->loadAnim(value, true);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
2013-10-24 01:01:55 +01:00
|
|
|
void Script::O_FLCSPEED() {
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 speed = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_FLCSPEED speed %d", speed);
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
|
|
|
void Script::O_OPENINVENTORY() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_OPENINVENTORY");
|
|
|
|
_opcodeNF = 1;
|
2013-11-18 16:19:21 +00:00
|
|
|
// _showInventoryFlag = true
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_KRZYWA() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_KRZYWA");
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::O_GETKRZYWA() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_GETKRZYWA");
|
2013-11-18 16:19:21 +00:00
|
|
|
// setFlagValue(Flags::TORX1, krzywa[_krzywaIndex++])
|
|
|
|
// setFlagValue(Flags::TORY1, krzywa[_krzywaIndex++])
|
|
|
|
// Check _krzywaIndex
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
|
|
|
|
2013-10-24 01:01:55 +01:00
|
|
|
void Script::O_GETMOB() {
|
2013-11-05 21:57:10 +00:00
|
|
|
Flags::Id flagId = readScriptFlagId();
|
2013-11-18 16:19:21 +00:00
|
|
|
uint16 mx = readScriptValue();
|
|
|
|
uint16 my = readScriptValue();
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_GETMOB flagId %d, mx %d, my %d", flagId, mx, my);
|
2013-11-18 16:19:21 +00:00
|
|
|
// check if current mob pos = (mx, my)
|
2013-10-24 01:01:55 +01:00
|
|
|
}
|
2013-10-15 23:21:00 +01:00
|
|
|
|
|
|
|
void Script::O_INPUTLINE() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_INPUTLINE");
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Script::O_BREAK_POINT() {
|
2013-10-30 02:28:07 +00:00
|
|
|
debugScript("O_BREAK_POINT");
|
2013-10-15 23:21:00 +01:00
|
|
|
}
|
2013-10-14 02:31:26 +01:00
|
|
|
|
|
|
|
Script::OpcodeFunc Script::_opcodes[NUM_OPCODES] = {
|
2013-10-30 02:28:07 +00:00
|
|
|
&Script::O_WAITFOREVER,
|
|
|
|
&Script::O_BLACKPALETTE,
|
|
|
|
&Script::O_SETUPPALETTE,
|
|
|
|
&Script::O_INITROOM,
|
|
|
|
&Script::O_SETSAMPLE,
|
|
|
|
&Script::O_FREESAMPLE,
|
|
|
|
&Script::O_PLAYSAMPLE,
|
|
|
|
&Script::O_PUTOBJECT,
|
|
|
|
&Script::O_REMOBJECT,
|
|
|
|
&Script::O_SHOWANIM,
|
|
|
|
&Script::O_CHECKANIMEND,
|
|
|
|
&Script::O_FREEANIM,
|
|
|
|
&Script::O_CHECKANIMFRAME,
|
|
|
|
&Script::O_PUTBACKANIM,
|
|
|
|
&Script::O_REMBACKANIM,
|
|
|
|
&Script::O_CHECKBACKANIMFRAME,
|
|
|
|
&Script::O_FREEALLSAMPLES,
|
|
|
|
&Script::O_SETMUSIC,
|
|
|
|
&Script::O_STOPMUSIC,
|
|
|
|
&Script::O__WAIT,
|
|
|
|
&Script::O_UPDATEOFF,
|
|
|
|
&Script::O_UPDATEON,
|
|
|
|
&Script::O_UPDATE ,
|
|
|
|
&Script::O_CLS,
|
|
|
|
&Script::O__CALL,
|
|
|
|
&Script::O_RETURN,
|
|
|
|
&Script::O_GO,
|
|
|
|
&Script::O_BACKANIMUPDATEOFF,
|
|
|
|
&Script::O_BACKANIMUPDATEON,
|
|
|
|
&Script::O_CHANGECURSOR,
|
|
|
|
&Script::O_CHANGEANIMTYPE,
|
|
|
|
&Script::O__SETFLAG,
|
|
|
|
&Script::O_COMPARE,
|
|
|
|
&Script::O_JUMPZ,
|
|
|
|
&Script::O_JUMPNZ,
|
|
|
|
&Script::O_EXIT,
|
|
|
|
&Script::O_ADDFLAG,
|
|
|
|
&Script::O_TALKANIM,
|
|
|
|
&Script::O_SUBFLAG,
|
|
|
|
&Script::O_SETSTRING,
|
|
|
|
&Script::O_ANDFLAG,
|
|
|
|
&Script::O_GETMOBDATA,
|
|
|
|
&Script::O_ORFLAG,
|
|
|
|
&Script::O_SETMOBDATA,
|
|
|
|
&Script::O_XORFLAG,
|
|
|
|
&Script::O_GETMOBTEXT,
|
|
|
|
&Script::O_MOVEHERO,
|
|
|
|
&Script::O_WALKHERO,
|
|
|
|
&Script::O_SETHERO,
|
|
|
|
&Script::O_HEROOFF,
|
|
|
|
&Script::O_HEROON,
|
|
|
|
&Script::O_CLSTEXT,
|
|
|
|
&Script::O_CALLTABLE,
|
|
|
|
&Script::O_CHANGEMOB,
|
|
|
|
&Script::O_ADDINV,
|
|
|
|
&Script::O_REMINV,
|
|
|
|
&Script::O_REPINV,
|
|
|
|
&Script::O_OBSOLETE_GETACTION,
|
|
|
|
&Script::O_ADDWALKAREA,
|
|
|
|
&Script::O_REMWALKAREA,
|
|
|
|
&Script::O_RESTOREWALKAREA,
|
|
|
|
&Script::O_WAITFRAME,
|
|
|
|
&Script::O_SETFRAME,
|
|
|
|
&Script::O_RUNACTION,
|
|
|
|
&Script::O_COMPAREHI,
|
|
|
|
&Script::O_COMPARELO,
|
|
|
|
&Script::O_PRELOADSET,
|
|
|
|
&Script::O_FREEPRELOAD,
|
|
|
|
&Script::O_CHECKINV,
|
|
|
|
&Script::O_TALKHERO,
|
|
|
|
&Script::O_WAITTEXT,
|
|
|
|
&Script::O_SETHEROANIM,
|
|
|
|
&Script::O_WAITHEROANIM,
|
|
|
|
&Script::O_GETHERODATA,
|
|
|
|
&Script::O_GETMOUSEBUTTON,
|
|
|
|
&Script::O_CHANGEFRAMES,
|
|
|
|
&Script::O_CHANGEBACKFRAMES,
|
|
|
|
&Script::O_GETBACKANIMDATA,
|
|
|
|
&Script::O_GETANIMDATA,
|
|
|
|
&Script::O_SETBGCODE,
|
|
|
|
&Script::O_SETBACKFRAME,
|
|
|
|
&Script::O_GETRND,
|
|
|
|
&Script::O_TALKBACKANIM,
|
|
|
|
&Script::O_LOADPATH,
|
|
|
|
&Script::O_GETCHAR,
|
|
|
|
&Script::O_SETDFLAG,
|
|
|
|
&Script::O_CALLDFLAG,
|
|
|
|
&Script::O_PRINTAT,
|
|
|
|
&Script::O_ZOOMIN,
|
|
|
|
&Script::O_ZOOMOUT,
|
|
|
|
&Script::O_SETSTRINGOFFSET,
|
|
|
|
&Script::O_GETOBJDATA,
|
|
|
|
&Script::O_SETOBJDATA,
|
|
|
|
&Script::O_SWAPOBJECTS,
|
|
|
|
&Script::O_CHANGEHEROSET,
|
|
|
|
&Script::O_ADDSTRING,
|
|
|
|
&Script::O_SUBSTRING,
|
|
|
|
&Script::O_INITDIALOG,
|
|
|
|
&Script::O_ENABLEDIALOGOPT,
|
|
|
|
&Script::O_DISABLEDIALOGOPT,
|
|
|
|
&Script::O_SHOWDIALOGBOX,
|
|
|
|
&Script::O_STOPSAMPLE,
|
|
|
|
&Script::O_BACKANIMRANGE,
|
|
|
|
&Script::O_CLEARPATH,
|
|
|
|
&Script::O_SETPATH,
|
|
|
|
&Script::O_GETHEROX,
|
|
|
|
&Script::O_GETHEROY,
|
|
|
|
&Script::O_GETHEROD,
|
|
|
|
&Script::O_PUSHSTRING,
|
|
|
|
&Script::O_POPSTRING,
|
|
|
|
&Script::O_SETFGCODE,
|
|
|
|
&Script::O_STOPHERO,
|
|
|
|
&Script::O_ANIMUPDATEOFF,
|
|
|
|
&Script::O_ANIMUPDATEON,
|
|
|
|
&Script::O_FREECURSOR,
|
|
|
|
&Script::O_ADDINVQUIET,
|
|
|
|
&Script::O_RUNHERO,
|
|
|
|
&Script::O_SETBACKANIMDATA,
|
|
|
|
&Script::O_VIEWFLC,
|
|
|
|
&Script::O_CHECKFLCFRAME,
|
|
|
|
&Script::O_CHECKFLCEND,
|
|
|
|
&Script::O_FREEFLC,
|
|
|
|
&Script::O_TALKHEROSTOP,
|
|
|
|
&Script::O_HEROCOLOR,
|
|
|
|
&Script::O_GRABMAPA,
|
|
|
|
&Script::O_ENABLENAK,
|
|
|
|
&Script::O_DISABLENAK,
|
|
|
|
&Script::O_GETMOBNAME,
|
|
|
|
&Script::O_SWAPINVENTORY,
|
|
|
|
&Script::O_CLEARINVENTORY,
|
|
|
|
&Script::O_SKIPTEXT,
|
|
|
|
&Script::O_SETVOICEH,
|
|
|
|
&Script::O_SETVOICEA,
|
|
|
|
&Script::O_SETVOICEB,
|
|
|
|
&Script::O_SETVOICEC,
|
|
|
|
&Script::O_VIEWFLCLOOP,
|
|
|
|
&Script::O_FLCSPEED,
|
|
|
|
&Script::O_OPENINVENTORY,
|
|
|
|
&Script::O_KRZYWA,
|
|
|
|
&Script::O_GETKRZYWA,
|
|
|
|
&Script::O_GETMOB,
|
|
|
|
&Script::O_INPUTLINE,
|
|
|
|
&Script::O_SETVOICED,
|
|
|
|
&Script::O_BREAK_POINT,
|
2013-10-14 02:31:26 +01:00
|
|
|
};
|
|
|
|
|
2013-10-13 22:34:26 +01:00
|
|
|
}
|
|
|
|
|
2013-10-30 02:28:07 +00:00
|
|
|
/* vim: set tabstop=4 noexpandtab: */
|