2009-09-19 09:53:43 +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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "asylum/actionlist.h"
|
2009-09-29 23:33:48 +00:00
|
|
|
#include "asylum/config.h"
|
2009-09-19 09:53:43 +00:00
|
|
|
|
|
|
|
namespace Asylum {
|
|
|
|
|
2009-09-19 13:31:00 +00:00
|
|
|
ActionList::ActionList(Common::SeekableReadStream *stream, Scene *scene)
|
2009-09-21 19:11:49 +00:00
|
|
|
: _scene(scene) {
|
2009-09-19 12:24:53 +00:00
|
|
|
load(stream);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
currentLine = 0;
|
|
|
|
currentLoops = 0;
|
|
|
|
processing = false;
|
|
|
|
delayedSceneIndex = -1;
|
|
|
|
delayedVideoIndex = -1;
|
|
|
|
allowInput = true;
|
2009-11-27 12:22:37 +00:00
|
|
|
_actionFlag = false;
|
2009-11-27 14:36:27 +00:00
|
|
|
resetQueue();
|
2009-09-19 09:53:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ActionList::~ActionList() {
|
|
|
|
entries.clear();
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
typedef int AsylumFunc(Script *script, ScriptEntry *cmd, Scene *scn);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
struct AsylumFunction {
|
|
|
|
const char *name;
|
|
|
|
AsylumFunc *function;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAPFUNC(name, func) {name, func}
|
|
|
|
|
2009-11-11 09:51:36 +00:00
|
|
|
// TODO I don't know that we're clearing this out
|
|
|
|
// when the engine is disposed. Need to look into this
|
|
|
|
// as a possible memory leak.
|
2009-09-19 18:37:19 +00:00
|
|
|
static const AsylumFunction function_map[] = {
|
2009-09-19 13:31:00 +00:00
|
|
|
/*0x00*/ MAPFUNC("kReturn0", kReturn0),
|
|
|
|
/*0x01*/ MAPFUNC("kSetGameFlag", kSetGameFlag),
|
|
|
|
/*0x02*/ MAPFUNC("kClearGameFlag", kClearGameFlag),
|
|
|
|
/*0x03*/ MAPFUNC("kToggleGameFlag", kToggleGameFlag),
|
|
|
|
/*0x04*/ MAPFUNC("kJumpIfGameFlag", kJumpIfGameFlag),
|
|
|
|
/*0x05*/ MAPFUNC("kHideCursor", kHideCursor),
|
|
|
|
/*0x06*/ MAPFUNC("kShowCursor", kShowCursor),
|
|
|
|
/*0x07*/ MAPFUNC("kPlayAnimation", kPlayAnimation),
|
|
|
|
/*0x08*/ MAPFUNC("kMoveScenePosition", kMoveScenePosition),
|
|
|
|
/*0x09*/ MAPFUNC("kHideActor", kHideActor),
|
|
|
|
/*0x0A*/ MAPFUNC("kShowActor", kShowActor),
|
|
|
|
/*0x0B*/ MAPFUNC("kSetActorStats", kSetActorStats),
|
|
|
|
/*0x0C*/ MAPFUNC("kSetSceneMotionStat", kSetSceneMotionStat),
|
|
|
|
/*0x0D*/ MAPFUNC("kDisableActor", kDisableActor),
|
|
|
|
/*0x0E*/ MAPFUNC("kEnableActor", kEnableActor),
|
|
|
|
/*0x0F*/ MAPFUNC("kEnableBarriers", kEnableBarriers),
|
|
|
|
/*0x10*/ MAPFUNC("kReturn", kReturn),
|
|
|
|
/*0x11*/ MAPFUNC("kDestroyBarrier", kDestroyBarrier),
|
|
|
|
/*0x12*/ MAPFUNC("k_unk12_JMP_WALK_ACTOR", k_unk12_JMP_WALK_ACTOR),
|
|
|
|
/*0x13*/ MAPFUNC("k_unk13_JMP_WALK_ACTOR", k_unk13_JMP_WALK_ACTOR),
|
|
|
|
/*0x14*/ MAPFUNC("k_unk14_JMP_WALK_ACTOR", k_unk14_JMP_WALK_ACTOR),
|
|
|
|
/*0x15*/ MAPFUNC("k_unk15", k_unk15),
|
|
|
|
/*0x16*/ MAPFUNC("kResetAnimation", kResetAnimation),
|
|
|
|
/*0x17*/ MAPFUNC("kClearFlag1Bit0", kClearFlag1Bit0),
|
|
|
|
/*0x18*/ MAPFUNC("k_unk18_PLAY_SND", k_unk18_PLAY_SND),
|
|
|
|
/*0x19*/ MAPFUNC("kJumpIfFlag2Bit0", kJumpIfFlag2Bit0),
|
|
|
|
/*0x1A*/ MAPFUNC("kSetFlag2Bit0", kSetFlag2Bit0),
|
|
|
|
/*0x1B*/ MAPFUNC("kClearFlag2Bit0", kClearFlag2Bit0),
|
|
|
|
/*0x1C*/ MAPFUNC("kJumpIfFlag2Bit2", kJumpIfFlag2Bit2),
|
|
|
|
/*0x1D*/ MAPFUNC("kSetFlag2Bit2", kSetFlag2Bit2),
|
|
|
|
/*0x1E*/ MAPFUNC("kClearFlag2Bit2", kClearFlag2Bit2),
|
|
|
|
/*0x1F*/ MAPFUNC("kJumpIfFlag2Bit1", kJumpIfFlag2Bit1),
|
|
|
|
/*0x20*/ MAPFUNC("kSetFlag2Bit1", kSetFlag2Bit1),
|
|
|
|
/*0x21*/ MAPFUNC("kClearFlag2Bit1", kClearFlag2Bit1),
|
|
|
|
/*0x22*/ MAPFUNC("k_unk22", k_unk22),
|
|
|
|
/*0x23*/ MAPFUNC("k_unk23", k_unk23),
|
|
|
|
/*0x24*/ MAPFUNC("k_unk24", k_unk24),
|
|
|
|
/*0x25*/ MAPFUNC("kRunEncounter", kRunEncounter),
|
|
|
|
/*0x26*/ MAPFUNC("kJumpIfFlag2Bit4", kJumpIfFlag2Bit4),
|
|
|
|
/*0x27*/ MAPFUNC("kSetFlag2Bit4", kSetFlag2Bit4),
|
|
|
|
/*0x28*/ MAPFUNC("kClearFlag2Bit4", kClearFlag2Bit4),
|
|
|
|
/*0x29*/ MAPFUNC("kSetActorField638", kSetActorField638),
|
|
|
|
/*0x2A*/ MAPFUNC("kJumpIfActorField638", kJumpIfActorField638),
|
|
|
|
/*0x2B*/ MAPFUNC("kChangeScene", kChangeScene),
|
|
|
|
/*0x2C*/ MAPFUNC("k_unk2C_ActorSub", k_unk2C_ActorSub),
|
|
|
|
/*0x2D*/ MAPFUNC("kPlayMovie", kPlayMovie),
|
|
|
|
/*0x2E*/ MAPFUNC("kStopAllBarriersSounds", kStopAllBarriersSounds),
|
2009-11-27 02:02:00 +00:00
|
|
|
/*0x2F*/ MAPFUNC("kSetActionFlag", kSetActionFlag),
|
|
|
|
/*0x30*/ MAPFUNC("kClearActionFlag", kClearActionFlag),
|
2009-09-19 13:31:00 +00:00
|
|
|
/*0x31*/ MAPFUNC("kResetSceneRect", kResetSceneRect),
|
|
|
|
/*0x32*/ MAPFUNC("kChangeMusicById", kChangeMusicById),
|
|
|
|
/*0x33*/ MAPFUNC("kStopMusic", kStopMusic),
|
|
|
|
/*0x34*/ MAPFUNC("k_unk34_Status", k_unk34_Status),
|
|
|
|
/*0x35*/ MAPFUNC("k_unk35", k_unk35),
|
|
|
|
/*0x36*/ MAPFUNC("k_unk36", k_unk36),
|
|
|
|
/*0x37*/ MAPFUNC("kRunBlowUpPuzzle", kRunBlowUpPuzzle),
|
|
|
|
/*0x38*/ MAPFUNC("kJumpIfFlag2Bit3", kJumpIfFlag2Bit3),
|
|
|
|
/*0x39*/ MAPFUNC("kSetFlag2Bit3", kSetFlag2Bit3),
|
|
|
|
/*0x3A*/ MAPFUNC("kClearFlag2Bit3", kClearFlag2Bit3),
|
|
|
|
/*0x3B*/ MAPFUNC("k_unk3B_PALETTE_MOD", k_unk3B_PALETTE_MOD),
|
|
|
|
/*0x3C*/ MAPFUNC("k_unk3C_CMP_VAL", k_unk3C_CMP_VAL),
|
|
|
|
/*0x3D*/ MAPFUNC("kWaitUntilFramePlayed", kWaitUntilFramePlayed),
|
|
|
|
/*0x3E*/ MAPFUNC("kUpdateWideScreen", kUpdateWideScreen),
|
|
|
|
/*0x3F*/ MAPFUNC("k_unk3F", k_unk3F),
|
|
|
|
/*0x40*/ MAPFUNC("k_unk40_SOUND", k_unk40_SOUND),
|
|
|
|
/*0x41*/ MAPFUNC("kPlaySpeech", kPlaySpeech),
|
|
|
|
/*0x42*/ MAPFUNC("k_unk42", k_unk42),
|
|
|
|
/*0x43*/ MAPFUNC("k_unk43", k_unk43),
|
|
|
|
/*0x44*/ MAPFUNC("kPaletteFade", kPaletteFade),
|
|
|
|
/*0x45*/ MAPFUNC("kStartPaletteFadeThread", kStartPaletteFadeThread),
|
|
|
|
/*0x46*/ MAPFUNC("k_unk46", k_unk46),
|
|
|
|
/*0x47*/ MAPFUNC("kActorFaceObject", kActorFaceObject),
|
|
|
|
/*0x48*/ MAPFUNC("k_unk48_MATTE_01", k_unk48_MATTE_01),
|
|
|
|
/*0x49*/ MAPFUNC("k_unk49_MATTE_90", k_unk49_MATTE_90),
|
|
|
|
/*0x4A*/ MAPFUNC("kJumpIfSoundPlaying", kJumpIfSoundPlaying),
|
|
|
|
/*0x4B*/ MAPFUNC("kChangePlayerCharacterIndex", kChangePlayerCharacterIndex),
|
|
|
|
/*0x4C*/ MAPFUNC("kChangeActorField40", kChangeActorField40),
|
|
|
|
/*0x4D*/ MAPFUNC("kStopSound", kStopSound),
|
|
|
|
/*0x4E*/ MAPFUNC("k_unk4E_RANDOM_COMMAND", k_unk4E_RANDOM_COMMAND),
|
|
|
|
/*0x4F*/ MAPFUNC("kClearScreen", kClearScreen),
|
|
|
|
/*0x50*/ MAPFUNC("kQuit", kQuit),
|
|
|
|
/*0x51*/ MAPFUNC("kJumpBarrierFrame", kJumpBarrierFrame),
|
|
|
|
/*0x52*/ MAPFUNC("k_unk52", k_unk52),
|
|
|
|
/*0x53*/ MAPFUNC("k_unk53", k_unk53),
|
|
|
|
/*0x54*/ MAPFUNC("k_unk54_SET_ACTIONLIST_6EC", k_unk54_SET_ACTIONLIST_6EC),
|
|
|
|
/*0x55*/ MAPFUNC("k_unk55", k_unk55),
|
|
|
|
/*0x56*/ MAPFUNC("k_unk56", k_unk56),
|
|
|
|
/*0x57*/ MAPFUNC("kSetResourcePalette", kSetResourcePalette),
|
|
|
|
/*0x58*/ MAPFUNC("kSetBarrierFrameIdxFlaged", kSetBarrierFrameIdxFlaged),
|
|
|
|
/*0x59*/ MAPFUNC("k_unk59", k_unk59),
|
|
|
|
/*0x5A*/ MAPFUNC("k_unk5A", k_unk5A),
|
|
|
|
/*0x5B*/ MAPFUNC("k_unk5B", k_unk5B),
|
|
|
|
/*0x5C*/ MAPFUNC("k_unk5C", k_unk5C),
|
|
|
|
/*0x5D*/ MAPFUNC("k_unk5D", k_unk5D),
|
|
|
|
/*0x5E*/ MAPFUNC("k_unk5E", k_unk5E),
|
|
|
|
/*0x5F*/ MAPFUNC("kSetBarrierLastFrameIdx", kSetBarrierLastFrameIdx),
|
|
|
|
/*0x60*/ MAPFUNC("k_unk60_SET_OR_CLR_ACTIONAREA_FLAG", k_unk60_SET_OR_CLR_ACTIONAREA_FLAG),
|
|
|
|
/*0x61*/ MAPFUNC("k_unk61", k_unk61),
|
|
|
|
/*0x62*/ MAPFUNC("k_unk62_SHOW_OPTIONS_SCREEN", k_unk62_SHOW_OPTIONS_SCREEN),
|
|
|
|
/*0x63*/ MAPFUNC("k_unk63", k_unk63)
|
|
|
|
};
|
|
|
|
|
2009-09-19 18:37:19 +00:00
|
|
|
#undef MAPFUNC
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
/*
|
2009-09-19 13:31:00 +00:00
|
|
|
void ActionList::setScriptByIndex(uint32 index) {
|
|
|
|
currentLine = 0;
|
|
|
|
_currentScript = &entries[index]; // TODO assert if out of bounds
|
|
|
|
|
2009-09-19 18:46:00 +00:00
|
|
|
if (Common::isDebugChannelEnabled(kDebugLevelScripts)) {
|
2009-09-19 13:31:00 +00:00
|
|
|
for (uint8 i = 0; i < _currentScript->commands[0].numLines; i++) {
|
|
|
|
debugC(kDebugLevelScripts,
|
2009-09-21 19:11:49 +00:00
|
|
|
"Line: %02d/%02d :: 0x%02X (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
|
|
|
|
i,
|
|
|
|
_currentScript->commands[0].numLines - 1,
|
|
|
|
_currentScript->commands[i].opcode,
|
|
|
|
_currentScript->commands[i].param1,
|
|
|
|
_currentScript->commands[i].param2,
|
|
|
|
_currentScript->commands[i].param3,
|
|
|
|
_currentScript->commands[i].param4,
|
|
|
|
_currentScript->commands[i].param5,
|
|
|
|
_currentScript->commands[i].param6,
|
|
|
|
_currentScript->commands[i].param7,
|
|
|
|
_currentScript->commands[i].param8,
|
|
|
|
_currentScript->commands[i].param9);
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
*/
|
2009-09-19 13:31:00 +00:00
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
void ActionList::resetQueue() {
|
|
|
|
memset(&_scripts, 0, sizeof(ScriptQueue));
|
2009-11-27 12:22:37 +00:00
|
|
|
for (int i = 0; i < 10; i++)
|
2009-11-27 14:36:27 +00:00
|
|
|
_scripts.entries[i].actionListIndex = -1;
|
2009-11-27 12:22:37 +00:00
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
void ActionList::queueScript(int actionIndex, int actorIndex) {
|
2009-11-27 12:22:37 +00:00
|
|
|
// TODO properly define what actionFlag is actually for.
|
|
|
|
// It appears to remain false 99% of the time, so I'm guessing
|
|
|
|
// it's a "skip processing" flag.
|
|
|
|
if (!_actionFlag) {
|
|
|
|
int i;
|
|
|
|
// iterate through the availble entry slots to determine
|
|
|
|
// the next available slot
|
|
|
|
for (i = 1; i < 10; i++) {
|
2009-11-27 14:36:27 +00:00
|
|
|
if (_scripts.entries[i].actionListIndex == -1)
|
2009-11-27 12:22:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
_scene->actions()->entries[actionIndex].counter = 0;
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
_scripts.entries[i].field_10 = 0;
|
|
|
|
_scripts.entries[i].field_C = 0;
|
2009-11-27 12:22:37 +00:00
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
if (_scripts.count) {
|
|
|
|
_scripts.entries[_scripts.field_CC].field_C = i ;
|
|
|
|
_scripts.entries[0].field_10 = _scripts.field_CC;
|
2009-11-27 12:22:37 +00:00
|
|
|
} else {
|
2009-11-27 14:36:27 +00:00
|
|
|
_scripts.count = i;
|
2009-11-27 12:22:37 +00:00
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
_scripts.field_CC = i;
|
|
|
|
_scripts.entries[0].actionListIndex = actionIndex;
|
|
|
|
_scripts.entries[0].actionListItemIndex = 0;
|
|
|
|
_scripts.entries[0].actorIndex = actorIndex;
|
2009-11-27 12:22:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
void ActionList::updateQueue(int queueIndex) {
|
|
|
|
if (_scripts.count == _scripts.field_CC) {
|
|
|
|
_scripts.field_CC = 0;
|
|
|
|
_scripts.count = 0;
|
|
|
|
_scripts.entries[queueIndex].actionListIndex = -1;
|
|
|
|
} else {
|
|
|
|
if (_scripts.count == queueIndex) {
|
|
|
|
_scripts.count = _scripts.entries[queueIndex].field_C;
|
|
|
|
_scripts.entries[queueIndex].field_10 = 0;
|
|
|
|
_scripts.entries[queueIndex].actionListIndex = -1;
|
|
|
|
} else {
|
|
|
|
if (_scripts.field_CC == queueIndex) {
|
|
|
|
_scripts.field_CC = _scripts.entries[queueIndex].field_10;
|
|
|
|
_scripts.entries[queueIndex].field_C = 0;
|
|
|
|
_scripts.entries[queueIndex].actionListIndex = -1;
|
|
|
|
} else {
|
|
|
|
int tmp10 = _scripts.entries[queueIndex].field_10;
|
|
|
|
int tmpC = _scripts.entries[queueIndex].field_C;
|
|
|
|
_scripts.entries[tmp10].field_C = _scripts.entries[queueIndex].field_C;
|
|
|
|
_scripts.entries[tmpC].field_10 = _scripts.entries[queueIndex].field_10;
|
|
|
|
_scripts.entries[queueIndex].actionListIndex = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionList::processActionListSub02(Script* script, ScriptEntry *command, int a4) {
|
2009-09-24 02:55:02 +00:00
|
|
|
//int v4 = 0;
|
2009-09-19 13:31:00 +00:00
|
|
|
int result;
|
|
|
|
int barrierIdx = 0;
|
|
|
|
if (a4) {
|
|
|
|
if (a4 == 1) {
|
|
|
|
;
|
|
|
|
} else {
|
|
|
|
result = a4 - 2;
|
|
|
|
int v8 = command->param4;
|
|
|
|
|
|
|
|
for (int i = 7; i > 0; i--) {
|
|
|
|
barrierIdx = _scene->worldstats()->getBarrierIndexById(v8);
|
|
|
|
if (barrierIdx >= 0)
|
|
|
|
_scene->worldstats()->barriers[barrierIdx].field_67C = 0;
|
|
|
|
v8 += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO
|
|
|
|
switch (_scene->getSceneIndex()) {
|
|
|
|
case 7:
|
|
|
|
warning("Scene 7 / v4 != 0 Not Implemented");
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
warning("Scene 6 / v4 != 0 Not Implemented");
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
warning("Scene 8 / v4 != 0 Not Implemented");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
warning("Scene 3 / v4 != 0 Not Implemented");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
warning("Scene 4 / v4 != 0 Not Implemented");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int v13 = command->param4;
|
|
|
|
int v4 = script->counter / command->param2 + 4;
|
|
|
|
for (int i = 7; i > 0; i--) {
|
2009-09-21 19:11:49 +00:00
|
|
|
barrierIdx = _scene->worldstats()->getBarrierIndexById(v13);
|
|
|
|
if (barrierIdx >= 0)
|
|
|
|
_scene->worldstats()->barriers[barrierIdx].field_67C = v4;
|
|
|
|
v13 += 4;
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
|
|
|
// TODO
|
|
|
|
switch (_scene->getSceneIndex()) {
|
|
|
|
case 7:
|
|
|
|
warning("Scene 7 / v4 = 0 Not Implemented");
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
warning("Scene 6 / v4 = 0 Not Implemented");
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
warning("Scene 8 / v4 = 0 Not Implemented");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
warning("Scene 3 / v4 = 0 Not Implemented");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
warning("Scene 4 / v4 = 0 Not Implemented");
|
|
|
|
break;
|
|
|
|
default:
|
2009-09-21 19:11:49 +00:00
|
|
|
return;
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionList::enableActorSub(int actorIndex, int condition) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int ActionList::process() {
|
|
|
|
done = false;
|
|
|
|
waitCycle = false;
|
|
|
|
lineIncrement = 1;
|
|
|
|
processing = true;
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
while (_scripts.count) {
|
|
|
|
Script *currentScript = &entries[_scripts.entries[_scripts.count - 1].actionListIndex];
|
|
|
|
currentLine = 0;
|
2009-09-19 13:31:00 +00:00
|
|
|
while (!done && !waitCycle) {
|
2009-11-22 21:15:09 +00:00
|
|
|
lineIncrement = 0; //Reset line increment value
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
if (currentLoops > 1000) {
|
|
|
|
//TODO - processActionLists has run too many iterations
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
ScriptEntry *currentCommand = ¤tScript->commands[currentLine];
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
uint32 opcode = currentCommand->opcode;
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
debugC(kDebugLevelScripts, "%s (0x%02d)", function_map[opcode].name, opcode);
|
|
|
|
|
2009-09-19 13:31:00 +00:00
|
|
|
// Execute command from function mapping
|
2009-11-27 14:36:27 +00:00
|
|
|
int cmdRet = function_map[opcode].function(currentScript, currentCommand, _scene);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
// Check function return
|
|
|
|
if (cmdRet == -1)
|
|
|
|
warning("Incomplete opcode %s (0x%02X) in Scene %d Line %d",
|
2009-09-21 19:11:49 +00:00
|
|
|
function_map[opcode].name,
|
|
|
|
currentCommand->opcode,
|
|
|
|
_scene->getSceneIndex(),
|
|
|
|
currentLine);
|
2009-09-19 13:31:00 +00:00
|
|
|
if (cmdRet == -2)
|
|
|
|
warning("Unhandled opcode %s (0x%02X) in Scene %d Line %d",
|
2009-09-21 19:11:49 +00:00
|
|
|
function_map[opcode].name,
|
|
|
|
currentCommand->opcode,
|
|
|
|
_scene->getSceneIndex(),
|
|
|
|
currentLine);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
2009-11-11 11:12:08 +00:00
|
|
|
if (cmdRet == -3)
|
|
|
|
warning("Flagged (see implemenation comments) opcode %s (0x%02X) in Scene %d Line %d",
|
|
|
|
function_map[opcode].name,
|
|
|
|
currentCommand->opcode,
|
|
|
|
_scene->getSceneIndex(),
|
|
|
|
currentLine);
|
2009-11-22 21:15:09 +00:00
|
|
|
|
|
|
|
if (!lineIncrement) {
|
|
|
|
currentLine ++;
|
|
|
|
currentLoops++;
|
|
|
|
}
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
} // end while
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
updateQueue(_scripts.count);
|
|
|
|
|
2009-09-19 13:31:00 +00:00
|
|
|
if (done) {
|
2009-11-27 14:36:27 +00:00
|
|
|
currentLine = 0;
|
|
|
|
currentLoops = 0;
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
// XXX
|
|
|
|
// gameFlag 183 is the same as the
|
|
|
|
// processing flag, but is not being used
|
|
|
|
_scene->vm()->clearGameFlag(183);
|
2009-09-19 13:31:00 +00:00
|
|
|
processing = false;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-09-19 12:24:53 +00:00
|
|
|
void ActionList::load(Common::SeekableReadStream *stream) {
|
|
|
|
size = stream->readUint32LE();
|
|
|
|
numEntries = stream->readUint32LE();
|
|
|
|
|
|
|
|
for (uint32 a = 0; a < numEntries; a++) {
|
2009-11-27 14:36:27 +00:00
|
|
|
Script action;
|
|
|
|
memset(&action, 0, sizeof(Script));
|
2009-09-19 12:24:53 +00:00
|
|
|
|
|
|
|
for (uint32 c = 0; c < MAX_ACTION_COMMANDS; c++) {
|
2009-11-27 14:36:27 +00:00
|
|
|
ScriptEntry command;
|
|
|
|
memset(&command, 0, sizeof(ScriptEntry));
|
2009-09-19 12:24:53 +00:00
|
|
|
|
|
|
|
command.numLines = stream->readUint32LE();
|
2009-11-11 09:56:14 +00:00
|
|
|
command.opcode = stream->readUint32LE();
|
|
|
|
command.param1 = stream->readSint32LE();
|
|
|
|
command.param2 = stream->readSint32LE();
|
|
|
|
command.param3 = stream->readSint32LE();
|
|
|
|
command.param4 = stream->readSint32LE();
|
|
|
|
command.param5 = stream->readSint32LE();
|
|
|
|
command.param6 = stream->readSint32LE();
|
|
|
|
command.param7 = stream->readSint32LE();
|
|
|
|
command.param8 = stream->readSint32LE();
|
|
|
|
command.param9 = stream->readSint32LE();
|
2009-09-19 12:24:53 +00:00
|
|
|
|
|
|
|
action.commands[c] = command;
|
|
|
|
}
|
|
|
|
|
|
|
|
action.field_1BAC = stream->readUint32LE();
|
|
|
|
action.field_1BB0 = stream->readUint32LE();
|
|
|
|
action.counter = stream->readUint32LE();
|
|
|
|
|
|
|
|
entries.push_back(action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-19 13:31:00 +00:00
|
|
|
/* Opcode Functions */
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kReturn0(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
scn->actions()->done = true;
|
|
|
|
scn->actions()->lineIncrement = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kSetGameFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
int flagNum = cmd->param1;
|
|
|
|
|
|
|
|
if (flagNum >= 0)
|
2009-09-19 14:25:43 +00:00
|
|
|
scn->vm()->setGameFlag(flagNum);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kClearGameFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
int flagNum = cmd->param1;
|
|
|
|
|
|
|
|
if (flagNum >= 0)
|
2009-09-19 14:25:43 +00:00
|
|
|
scn->vm()->clearGameFlag(flagNum);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kToggleGameFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
int flagNum = cmd->param1;
|
|
|
|
|
|
|
|
if (flagNum >= 0)
|
2009-09-19 14:25:43 +00:00
|
|
|
scn->vm()->toggleGameFlag(flagNum);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kJumpIfGameFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
int flagNum = cmd->param1;
|
|
|
|
|
|
|
|
if (flagNum) {
|
2009-09-19 14:25:43 +00:00
|
|
|
bool doJump = scn->vm()->isGameFlagSet(flagNum);
|
2009-09-19 13:31:00 +00:00
|
|
|
if (cmd->param2)
|
2009-09-19 14:25:43 +00:00
|
|
|
doJump = scn->vm()->isGameFlagNotSet(flagNum);
|
2009-09-19 13:31:00 +00:00
|
|
|
if (doJump)
|
|
|
|
scn->actions()->currentLine = cmd->param3;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kHideCursor(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
scn->getCursor()->hide();
|
|
|
|
scn->actions()->allowInput = false;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kShowCursor(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
scn->getCursor()->show();
|
|
|
|
scn->actions()->allowInput = true;
|
|
|
|
|
|
|
|
// TODO clear_flag_01()
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kPlayAnimation(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:59:29 +00:00
|
|
|
int barrierId = cmd->param1;
|
|
|
|
int barrierIndex = scn->worldstats()->getBarrierIndexById(barrierId);
|
|
|
|
Barrier *barrier = scn->worldstats()->getBarrierByIndex(barrierIndex);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
if (cmd->param2 == 2) {
|
2009-09-19 13:59:29 +00:00
|
|
|
if (!barrier->checkFlags()) {
|
2009-09-19 13:31:00 +00:00
|
|
|
cmd->param2 = 1;
|
|
|
|
}
|
|
|
|
scn->actions()->lineIncrement = 1;
|
|
|
|
} else {
|
2009-11-22 20:03:44 +00:00
|
|
|
if (cmd->param4) {
|
2009-09-19 13:31:00 +00:00
|
|
|
barrier->flags &= 0xFFFEF1C7;
|
2009-11-21 22:56:38 +00:00
|
|
|
barrier->flags |= 0x20;
|
2009-09-19 13:31:00 +00:00
|
|
|
} else if (cmd->param3) {
|
|
|
|
barrier->flags &= 0xFFFEF1C7;
|
|
|
|
barrier->flags |= 0x10000;
|
|
|
|
} else {
|
|
|
|
barrier->flags &= 0x10000;
|
2009-09-21 19:11:49 +00:00
|
|
|
if (barrier->flags == 0) {
|
2009-09-19 13:31:00 +00:00
|
|
|
barrier->flags &= 0x10E38;
|
2009-09-21 19:11:49 +00:00
|
|
|
if (barrier->flags == 0) {
|
2009-09-19 13:31:00 +00:00
|
|
|
barrier->flags |= 8;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
barrier->flags |= 8;
|
|
|
|
barrier->flags &= 0xFFFEFFFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-19 13:59:29 +00:00
|
|
|
barrier->setNextFrame(barrier->flags);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
2009-09-21 19:11:49 +00:00
|
|
|
if (barrier->field_688 == 1) {
|
2009-09-19 13:31:00 +00:00
|
|
|
// TODO: get barrier position
|
|
|
|
}
|
|
|
|
|
2009-09-21 19:11:49 +00:00
|
|
|
if (cmd->param2) {
|
2009-09-19 13:31:00 +00:00
|
|
|
cmd->param2 = 2;
|
|
|
|
scn->actions()->lineIncrement = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kMoveScenePosition(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
WorldStats *ws = scn->worldstats();
|
|
|
|
Common::Rect *sr = &ws->sceneRects[ws->sceneRectIdx];
|
|
|
|
|
|
|
|
if (cmd->param3 < 1) {
|
|
|
|
ws->xLeft = cmd->param1;
|
|
|
|
ws->yTop = cmd->param2;
|
|
|
|
ws->motionStatus = 3;
|
|
|
|
} else if (!cmd->param4) {
|
|
|
|
ws->motionStatus = 5;
|
|
|
|
ws->targetX = cmd->param1;
|
|
|
|
ws->targetY = cmd->param2;
|
|
|
|
ws->field_A0 = cmd->param3;
|
|
|
|
|
|
|
|
if (ws->targetX < (uint32)sr->left)
|
|
|
|
ws->targetX = sr->left;
|
|
|
|
if (ws->targetY < (uint32)sr->top)
|
|
|
|
ws->targetY = sr->top;
|
|
|
|
if (ws->targetX + 640 > (uint32)sr->right)
|
|
|
|
ws->targetX = sr->right - 640;
|
|
|
|
if (ws->targetY + 480 > (uint32)sr->bottom)
|
|
|
|
ws->targetY = sr->bottom - 480;
|
|
|
|
|
|
|
|
// TODO: reverse asm block
|
|
|
|
|
|
|
|
} else if (cmd->param5) {
|
|
|
|
if (ws->motionStatus == 2)
|
|
|
|
scn->actions()->lineIncrement = 1;
|
|
|
|
else
|
|
|
|
cmd->param5 = 0;
|
|
|
|
} else {
|
|
|
|
cmd->param5 = 1;
|
|
|
|
ws->motionStatus = 2;
|
|
|
|
ws->targetX = cmd->param1;
|
|
|
|
ws->targetY = cmd->param2;
|
|
|
|
ws->field_A0 = cmd->param3;
|
|
|
|
|
|
|
|
if (ws->targetX + 640 > ws->width)
|
|
|
|
ws->targetX = ws->width - 640;
|
|
|
|
if (ws->targetX < (uint32)sr->left)
|
|
|
|
ws->targetX = sr->left;
|
|
|
|
if (ws->targetY < (uint32)sr->top)
|
|
|
|
ws->targetY = sr->top;
|
|
|
|
if (ws->targetX + 640 > (uint32)sr->right)
|
|
|
|
ws->targetX = sr->right - 640;
|
|
|
|
if (ws->targetY + 480 > (uint32)sr->bottom)
|
|
|
|
ws->targetY = sr->bottom - 480;
|
|
|
|
|
|
|
|
// TODO: reverse asm block
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kHideActor(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-11-11 11:12:08 +00:00
|
|
|
Actor *actor = 0;
|
2009-09-19 13:31:00 +00:00
|
|
|
|
2009-11-11 11:12:08 +00:00
|
|
|
// TODO better default actor handling
|
2009-09-19 13:31:00 +00:00
|
|
|
if (cmd->param1 == -1)
|
2009-11-11 11:12:08 +00:00
|
|
|
actor = scn->getActor();
|
2009-09-19 13:31:00 +00:00
|
|
|
else
|
2009-11-11 11:12:08 +00:00
|
|
|
actor = &scn->worldstats()->actors[cmd->param1];
|
2009-09-19 13:31:00 +00:00
|
|
|
|
2009-11-11 11:12:08 +00:00
|
|
|
actor->visible(false);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
2009-11-11 11:12:08 +00:00
|
|
|
return -3;
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kShowActor(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-11-11 11:12:08 +00:00
|
|
|
Actor *actor = 0;
|
2009-09-19 13:31:00 +00:00
|
|
|
|
2009-11-11 11:12:08 +00:00
|
|
|
// TODO revisit when actor selection is cleaned up
|
2009-09-19 13:31:00 +00:00
|
|
|
if (cmd->param1 == -1)
|
2009-11-11 11:12:08 +00:00
|
|
|
actor = scn->getActor();
|
2009-09-19 13:31:00 +00:00
|
|
|
else
|
2009-11-11 11:12:08 +00:00
|
|
|
actor = &scn->worldstats()->actors[cmd->param1];
|
2009-09-19 13:31:00 +00:00
|
|
|
|
2009-11-11 11:12:08 +00:00
|
|
|
actor->visible(true);
|
2009-11-17 02:00:35 +00:00
|
|
|
// TODO character_sub_401320
|
|
|
|
actor->tickValue1 = scn->vm()->getTick();
|
2009-09-19 13:31:00 +00:00
|
|
|
|
2009-11-17 02:00:35 +00:00
|
|
|
return -2;
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kSetActorStats(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-24 02:55:02 +00:00
|
|
|
//WorldStats *ws = scn->worldstats();
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
// TODO
|
|
|
|
// param1 == actorIndex. Implement when we've got more than one actor
|
|
|
|
|
|
|
|
// TODO This needs to be depreciated, but it's setting the actor's x/y
|
|
|
|
// and bounding rect top/left.
|
|
|
|
// This needs to be rolled into the proper place
|
2009-09-21 19:11:49 +00:00
|
|
|
scn->getActor()->setPosition(cmd->param2, cmd->param3);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
scn->getActor()->setPosition_40A260(cmd->param2, cmd->param3, cmd->param4, cmd->param5);
|
|
|
|
|
|
|
|
// XXX Returning -1 since the setPosition logic isn't fully implemented
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kSetSceneMotionStat(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
scn->worldstats()->motionStatus = cmd->param1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kDisableActor(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-11-11 10:49:52 +00:00
|
|
|
int actorIndex = cmd->param1;
|
2009-09-19 13:31:00 +00:00
|
|
|
|
2009-11-11 10:49:52 +00:00
|
|
|
if (actorIndex == -1)
|
2009-11-24 11:00:45 +00:00
|
|
|
actorIndex = scn->getActorIndex();
|
2009-11-11 09:51:36 +00:00
|
|
|
|
2009-11-24 11:00:45 +00:00
|
|
|
scn->updateActorDirection(actorIndex, 5);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
2009-11-24 11:00:45 +00:00
|
|
|
return 0;
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kEnableActor(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
int actorIndex = 0;
|
|
|
|
|
|
|
|
if (cmd->param1 == -1)
|
|
|
|
;//actorIndex = scn->getWorldStats()->playerActor;
|
|
|
|
else
|
|
|
|
actorIndex = cmd->param1;
|
|
|
|
|
2009-09-20 16:48:04 +00:00
|
|
|
if (scn->worldstats()->actors[actorIndex].updateType == 5)
|
2009-09-19 13:31:00 +00:00
|
|
|
scn->actions()->enableActorSub(actorIndex, 4);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
int barIdx = scn->worldstats()->getBarrierIndexById(cmd->param1);
|
|
|
|
uint32 sndIdx = cmd->param3;
|
|
|
|
uint32 v59 = cmd->param2;
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
if (!script->counter && scn->getSceneIndex() != 13 && sndIdx != 0) {
|
2009-09-24 02:27:38 +00:00
|
|
|
// FIXME: I really don't understand what (sndIdx != 0) & 5 is supposed to be doing here,
|
|
|
|
// but this is effectively trying to do a boolean AND operation on a boolean variable
|
|
|
|
// which is odd, and wrong. Changing it to (sndIdx & 5), for now
|
|
|
|
//scn->vm()->sound()->playSound(((sndIdx != 0) & 5) + 0x80120001,
|
2009-09-29 23:33:48 +00:00
|
|
|
scn->vm()->sound()->playSound((sndIdx & 5) + 0x80120001, false, Config.sfxVolume, 0);
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
if (script->counter >= 3 * v59 - 1) {
|
|
|
|
script->counter = 0;
|
2009-09-19 13:31:00 +00:00
|
|
|
scn->worldstats()->barriers[barIdx].field_67C = 0;
|
2009-11-27 14:36:27 +00:00
|
|
|
scn->actions()->processActionListSub02(script, cmd, 2);
|
2009-09-19 13:31:00 +00:00
|
|
|
scn->actions()->currentLoops = 1; // v4 = 1;
|
|
|
|
} else {
|
|
|
|
int v64;
|
2009-11-27 14:36:27 +00:00
|
|
|
int v62 = script->counter + 1;
|
|
|
|
script->counter = v62;
|
2009-09-19 13:31:00 +00:00
|
|
|
if (sndIdx) {
|
2009-09-21 19:11:49 +00:00
|
|
|
v64 = 1;
|
|
|
|
int v170 = 3 - v62 / v59;
|
|
|
|
scn->worldstats()->barriers[barIdx].field_67C = v170;
|
2009-09-19 13:31:00 +00:00
|
|
|
} else {
|
2009-09-21 19:11:49 +00:00
|
|
|
v64 = 0;
|
|
|
|
scn->worldstats()->barriers[barIdx].field_67C = v62 / v59 + 1;
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
scn->actions()->processActionListSub02(script, cmd, v64);
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kReturn(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
scn->actions()->done = true;
|
|
|
|
scn->actions()->lineIncrement = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kDestroyBarrier(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
|
|
|
|
|
|
|
|
if (barrier) {
|
|
|
|
barrier->flags &= 0xFFFFFFFE;
|
|
|
|
barrier->flags |= 0x20000;
|
2009-09-19 17:43:35 +00:00
|
|
|
scn->vm()->screen()->deleteGraphicFromQueue(barrier->resId);
|
2009-09-19 13:31:00 +00:00
|
|
|
} else
|
|
|
|
debugC(kDebugLevelScripts,
|
2009-09-21 19:11:49 +00:00
|
|
|
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
|
|
|
|
cmd->param1,
|
|
|
|
scn->getSceneIndex(),
|
|
|
|
scn->actions()->currentLine);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk12_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk13_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk14_JMP_WALK_ACTOR(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk15(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kResetAnimation(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
|
|
|
|
|
|
|
|
if ((barrier->flags & 0x10000) == 0)
|
|
|
|
barrier->frameIdx = 0;
|
|
|
|
else
|
|
|
|
barrier->frameIdx = barrier->frameCount - 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kClearFlag1Bit0(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
|
|
|
|
|
|
|
|
barrier->flags &= 0xFFFFFFFE;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk18_PLAY_SND(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kJumpIfFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
int targetType = cmd->param2;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// TODO targetType == 7 is trying to access an out of bounds actor
|
|
|
|
// look at the disassembly again
|
|
|
|
|
|
|
|
if (targetType <= 0)
|
|
|
|
scn->actions()->done = (scn->worldstats()->getBarrierById(cmd->param1)->flags2 & 1) == 0;
|
|
|
|
else
|
|
|
|
if (targetType == 1) // v4 == 1, so 1
|
|
|
|
scn->actions()->done = (scn->worldstats()->getActionAreaById(cmd->param1)->actionType & 1) == 0;
|
|
|
|
else
|
|
|
|
scn->actions()->done = (scn->worldstats()->actors[cmd->param1].flags2 & 1) == 0;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kSetFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
int targetType = cmd->param2;
|
|
|
|
|
|
|
|
if (targetType == 2)
|
|
|
|
scn->worldstats()->actors[cmd->param1].flags2 |= 1;
|
|
|
|
else
|
|
|
|
if (targetType == 1)
|
|
|
|
scn->worldstats()->getActionAreaById(cmd->param1)->actionType |= 1;
|
|
|
|
else
|
|
|
|
scn->worldstats()->getBarrierById(cmd->param1)->flags2 |= 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kClearFlag2Bit0(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kJumpIfFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kSetFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kClearFlag2Bit2(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kJumpIfFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kSetFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kClearFlag2Bit1(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk22(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk23(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk24(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kRunEncounter(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kJumpIfFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kSetFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kClearFlag2Bit4(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kSetActorField638(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kJumpIfActorField638(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kChangeScene(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
scn->actions()->delayedSceneIndex = cmd->param1 + 4;
|
|
|
|
debug(kDebugLevelScripts,
|
2009-09-21 19:11:49 +00:00
|
|
|
"Queueing Scene Change to scene %d...",
|
|
|
|
scn->actions()->delayedSceneIndex);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk2C_ActorSub(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kPlayMovie(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
// TODO: add missing code here
|
|
|
|
scn->actions()->delayedVideoIndex = cmd->param1;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kStopAllBarriersSounds(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
// TODO: do this for all barriers that have sfx playing
|
2009-09-20 21:10:43 +00:00
|
|
|
scn->vm()->sound()->stopAllSounds();
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kSetActionFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-11-27 12:22:37 +00:00
|
|
|
scn->actions()->setActionFlag(true);
|
2009-11-27 02:02:00 +00:00
|
|
|
return 0;
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kClearActionFlag(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-11-27 12:22:37 +00:00
|
|
|
scn->actions()->setActionFlag(false);
|
2009-11-27 02:02:00 +00:00
|
|
|
return 0;
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kResetSceneRect(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kChangeMusicById(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kStopMusic(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 14:51:42 +00:00
|
|
|
scn->vm()->sound()->stopMusic();
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk34_Status(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
if (cmd->param1 >= 2) {
|
|
|
|
cmd->param1 = 0;
|
|
|
|
} else {
|
|
|
|
cmd->param1++;
|
|
|
|
scn->actions()->lineIncrement = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk35(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk36(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kRunBlowUpPuzzle(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
// FIXME: improve this to call other blowUpPuzzles than VCR
|
|
|
|
//int puzzleIdx = cmd->param1;
|
|
|
|
|
2009-09-19 14:39:02 +00:00
|
|
|
scn->setBlowUpPuzzle(new BlowUpPuzzleVCR(scn));
|
2009-09-19 13:31:00 +00:00
|
|
|
scn->getBlowUpPuzzle()->openBlowUp();
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kJumpIfFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kSetFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kClearFlag2Bit3(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk3B_PALETTE_MOD(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk3C_CMP_VAL(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
if (cmd->param1) {
|
|
|
|
if (cmd->param2 >= cmd->param1) {
|
|
|
|
cmd->param2 = 0;
|
|
|
|
} else {
|
|
|
|
cmd->param2++;
|
|
|
|
scn->actions()->lineIncrement = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kWaitUntilFramePlayed(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
|
|
|
|
|
|
|
|
if (barrier) {
|
2009-11-22 21:15:09 +00:00
|
|
|
uint32 frameNum = cmd->param2;
|
2009-09-21 19:11:49 +00:00
|
|
|
if (cmd->param2 == -1)
|
|
|
|
frameNum = barrier->frameCount - 1;
|
|
|
|
|
2009-11-22 21:15:09 +00:00
|
|
|
if (barrier->frameIdx != frameNum) {
|
|
|
|
scn->actions()->lineIncrement = 1;
|
2009-09-21 19:11:49 +00:00
|
|
|
scn->actions()->waitCycle = true;
|
|
|
|
}
|
2009-09-19 13:31:00 +00:00
|
|
|
} else
|
|
|
|
debugC(kDebugLevelScripts,
|
2009-09-21 19:11:49 +00:00
|
|
|
"Requested invalid object ID:0x%02X in Scene %d Line %d.",
|
|
|
|
cmd->param1,
|
|
|
|
scn->getSceneIndex(),
|
|
|
|
scn->actions()->currentLine);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kUpdateWideScreen(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
int barSize = cmd->param1;
|
|
|
|
|
|
|
|
if (barSize >= 22) {
|
|
|
|
cmd->param1 = 0;
|
|
|
|
} else {
|
2009-09-19 17:43:35 +00:00
|
|
|
scn->vm()->screen()->drawWideScreen(4 * barSize);
|
2009-09-19 13:31:00 +00:00
|
|
|
cmd->param1++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk3F(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk40_SOUND(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kPlaySpeech(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-21 19:11:49 +00:00
|
|
|
//TODO - Add support for other param options
|
2009-09-19 13:31:00 +00:00
|
|
|
uint32 sndIdx = cmd->param1;
|
|
|
|
|
|
|
|
if ((int)sndIdx >= 0) {
|
2009-11-22 20:03:44 +00:00
|
|
|
if (cmd->param4 != 2) {
|
|
|
|
uint32 resIdx = scn->speech()->play(sndIdx);
|
|
|
|
cmd->param5 = resIdx;
|
|
|
|
|
|
|
|
if (cmd->param2) {
|
|
|
|
scn->vm()->setGameFlag(183);
|
|
|
|
cmd->param4 = 2;
|
|
|
|
if (cmd->param6) {
|
|
|
|
// TODO: set flag 01
|
|
|
|
}
|
|
|
|
scn->actions()->lineIncrement = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd->param3) {
|
|
|
|
if (!cmd->param6) {
|
|
|
|
scn->vm()->setGameFlag(219);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scn->vm()->sound()->isPlaying(cmd->param5)) {
|
|
|
|
scn->actions()->lineIncrement = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
scn->vm()->clearGameFlag(183);
|
|
|
|
cmd->param4 = 0;
|
|
|
|
|
|
|
|
if (cmd->param3) {
|
|
|
|
if (cmd->param6) {
|
|
|
|
// TODO: clear flag 01
|
|
|
|
}
|
|
|
|
scn->vm()->clearGameFlag(219);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cmd->param6) {
|
|
|
|
cmd->param6 = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: clear flag 01
|
2009-09-19 13:31:00 +00:00
|
|
|
} else
|
|
|
|
debugC(kDebugLevelScripts,
|
2009-09-21 19:11:49 +00:00
|
|
|
"Requested invalid sound ID:0x%02X in Scene %d Line %d.",
|
|
|
|
cmd->param1,
|
|
|
|
scn->getSceneIndex(),
|
|
|
|
scn->actions()->currentLine);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
2009-11-22 20:03:44 +00:00
|
|
|
return 0;
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk42(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk43(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kPaletteFade(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kStartPaletteFadeThread(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk46(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kActorFaceObject(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
// XXX
|
|
|
|
// Dropping param1, since it's the character index
|
|
|
|
// Investigate further if/when we have a scene with
|
|
|
|
// multiple characters in the actor[] array
|
|
|
|
scn->getActor()->faceTarget(cmd->param2, cmd->param3);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk48_MATTE_01(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk49_MATTE_90(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kJumpIfSoundPlaying(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int kChangePlayerCharacterIndex(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kChangeActorField40(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
// TODO: figure out what is this field and what values are set
|
|
|
|
int actorIdx = cmd->param1;
|
|
|
|
int fieldType = cmd->param2;
|
|
|
|
|
|
|
|
if (fieldType) {
|
2009-09-20 16:48:04 +00:00
|
|
|
if (scn->worldstats()->actors[actorIdx].updateType < 11)
|
|
|
|
scn->worldstats()->actors[actorIdx].updateType = 14;
|
2009-09-19 13:31:00 +00:00
|
|
|
} else {
|
2009-09-20 16:48:04 +00:00
|
|
|
scn->worldstats()->actors[actorIdx].updateType = 4;
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kStopSound(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk4E_RANDOM_COMMAND(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kClearScreen(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
if (cmd->param1)
|
2009-09-19 17:43:35 +00:00
|
|
|
scn->vm()->screen()->clearScreen();
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kQuit(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kJumpBarrierFrame(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
|
2009-11-11 11:12:08 +00:00
|
|
|
int idx = (int)barrier->frameIdx;
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
if (cmd->param2 == -1)
|
|
|
|
cmd->param2 = barrier->frameCount - 1;
|
|
|
|
|
2009-11-11 11:12:08 +00:00
|
|
|
if (cmd->param3 && cmd->param2 == idx) {
|
2009-09-19 13:31:00 +00:00
|
|
|
//break;
|
2009-11-11 11:12:08 +00:00
|
|
|
} else if (cmd->param4 && cmd->param2 < idx) {
|
2009-09-19 13:31:00 +00:00
|
|
|
//break;
|
2009-11-11 11:12:08 +00:00
|
|
|
} else if (cmd->param5 && cmd->param2 > idx) {
|
2009-09-19 13:31:00 +00:00
|
|
|
//break;
|
2009-11-11 11:12:08 +00:00
|
|
|
} else if (cmd->param6 && cmd->param2 <= idx) {
|
2009-09-19 13:31:00 +00:00
|
|
|
//break;
|
2009-11-11 11:12:08 +00:00
|
|
|
} else if (cmd->param7 && cmd->param2 >= idx) {
|
2009-09-19 13:31:00 +00:00
|
|
|
//break;
|
2009-11-11 11:12:08 +00:00
|
|
|
} else if (cmd->param8 && cmd->param2 != idx) {
|
2009-09-19 13:31:00 +00:00
|
|
|
//break;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
ScriptEntry *nextCmd = &script->commands[cmd->param9];
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
// 0x10 == kReturn
|
|
|
|
if (nextCmd->opcode != 0x10 && nextCmd->opcode)
|
|
|
|
scn->actions()->done = true;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk52(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk53(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk54_SET_ACTIONLIST_6EC(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
if (cmd->param2)
|
2009-11-27 14:36:27 +00:00
|
|
|
script->field_1BB0 = rand() % cmd->param1;
|
2009-09-19 13:31:00 +00:00
|
|
|
else
|
2009-11-27 14:36:27 +00:00
|
|
|
script->field_1BB0 = cmd->param1;
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk55(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
// TODO
|
|
|
|
/*
|
|
|
|
if (!cmd->param2) {
|
2009-11-27 14:36:27 +00:00
|
|
|
if (cmd->param3 && script->field_1BB0 < cmd->param1)
|
2009-09-19 13:31:00 +00:00
|
|
|
//break;
|
2009-11-27 14:36:27 +00:00
|
|
|
else if (cmd->param4 && script->field_1BB0 > cmd->param1)
|
2009-09-19 13:31:00 +00:00
|
|
|
//break;
|
2009-11-27 14:36:27 +00:00
|
|
|
else if (cmd->param5 && script->field_1BB0 <= cmd->param1)
|
2009-09-19 13:31:00 +00:00
|
|
|
//break;
|
2009-11-27 14:36:27 +00:00
|
|
|
else if (cmd->param6 && script->field_1BB0 >= cmd->param1)
|
2009-09-19 13:31:00 +00:00
|
|
|
//break;
|
2009-11-27 14:36:27 +00:00
|
|
|
else if (cmd->param7 && script->field_1BB0 != cmd->param1)
|
2009-09-19 13:31:00 +00:00
|
|
|
//break;
|
2009-11-27 14:36:27 +00:00
|
|
|
} else if(script->field_1BB0 == cmd->param1) {
|
2009-09-19 13:31:00 +00:00
|
|
|
//break;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
ScriptEntry *nextCmd = &script->commands[cmd->param8];
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
if (nextCmd->opcode != 0x10 && nextCmd->opcode)
|
|
|
|
scn->actions()->done = true;
|
|
|
|
else
|
|
|
|
scn->actions()->lineIncrement = cmd->param8;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk56(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kSetResourcePalette(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
if (cmd->param1 > 0)
|
2009-09-19 17:43:35 +00:00
|
|
|
scn->vm()->screen()->setPalette(scn->getResourcePack(), scn->worldstats()->grResId[cmd->param1]);
|
2009-09-19 13:31:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kSetBarrierFrameIdxFlaged(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
|
|
|
|
|
|
|
|
if (cmd->param3)
|
|
|
|
barrier->flags = 1 | barrier->flags;
|
|
|
|
else
|
|
|
|
barrier->flags = barrier->flags & 0xFFFFFFFE;
|
|
|
|
|
|
|
|
barrier->frameIdx = cmd->param2;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk59(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-21 19:11:49 +00:00
|
|
|
return -2;
|
2009-09-19 13:31:00 +00:00
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk5A(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk5B(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk5C(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk5D(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk5E(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int kSetBarrierLastFrameIdx(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1);
|
|
|
|
|
|
|
|
if (barrier->frameIdx == barrier->frameCount - 1) {
|
|
|
|
scn->actions()->lineIncrement = 0;
|
|
|
|
barrier->flags &= 0xFFFEF1C7;
|
|
|
|
} else {
|
|
|
|
scn->actions()->lineIncrement = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk60_SET_OR_CLR_ACTIONAREA_FLAG(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk61(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
if (cmd->param2) {
|
|
|
|
if (scn->worldstats()->field_E860C == -1) {
|
|
|
|
scn->actions()->lineIncrement = 0;
|
|
|
|
cmd->param2 = 0;
|
|
|
|
} else {
|
|
|
|
scn->actions()->lineIncrement = 1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// TODO: do something for scene number 9
|
|
|
|
cmd->param2 = 1;
|
|
|
|
scn->actions()->lineIncrement = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk62_SHOW_OPTIONS_SCREEN(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
int k_unk63(Script *script, ScriptEntry *cmd, Scene *scn) {
|
2009-09-19 13:31:00 +00:00
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
2009-09-19 09:53:43 +00:00
|
|
|
} // end of namespace Asylum
|