xoreos
0.0.5
|
An NCS, BioWare's NWN Compile Script. More...
#include <ncsfile.h>
Classes | |
struct | Opcode |
Public Member Functions | |
NCSFile (Common::SeekableReadStream *ncs) | |
NCSFile (const Common::UString &ncs) | |
~NCSFile () | |
const Common::UString & | getName () const |
VariableContainer & | getEnvironment () |
Return the script's environment variables. More... | |
void | setEnvironment (const VariableContainer &env) |
Overwrite the environment. More... | |
const Variable & | run (Object *owner=0, Object *triggerer=0) |
Run the current script, from start to finish. More... | |
const Variable & | run (const ObjectReference owner=ObjectReference(), const ObjectReference triggerer=ObjectReference()) |
const Variable & | run (const ScriptState &state, Object *owner=0, Object *triggerer=0) |
Run the current script, from this state to finish. More... | |
const Variable & | run (const ScriptState &state, const ObjectReference owner=ObjectReference(), const ObjectReference triggerer=ObjectReference()) |
Public Member Functions inherited from Aurora::AuroraFile | |
AuroraFile () | |
void | clear () |
uint32 | getID () const |
Return the file's ID. More... | |
uint32 | getVersion () const |
Return the file's version. More... | |
bool | isUTF16LE () const |
Were the ID and version encoded in little-endian UTF-16 in the file? More... | |
Static Public Member Functions | |
static ScriptState | getEmptyState () |
Static Public Member Functions inherited from Aurora::AuroraFile | |
static void | readHeader (Common::ReadStream &stream, uint32 &id, uint32 &version, bool &utf16le) |
Read the header out of a stream. More... | |
static void | readHeader (Common::ReadStream &stream, uint32 &id, uint32 &version) |
Read the ID and version out of a stream. More... | |
static uint32 | readHeaderID (Common::ReadStream &stream) |
Read the ID out of a stream. More... | |
Private Member Functions | |
void | setupOpcodes () |
void | load () |
void | reset () |
Reset the script for another execution. More... | |
const Variable & | execute (const ObjectReference owner=ObjectReference(), const ObjectReference triggerer=ObjectReference()) |
bool | executeStep () |
Execute one script step. More... | |
void | decompile () |
void | callEngine (Aurora::NWScript::FunctionContext &ctx, uint32 function, uint8 argCount) |
Helper function for o_action(), doing the actual engine function calling. More... | |
void | o_nop (InstructionType type) |
NOP: no operation. More... | |
void | o_cpdownsp (InstructionType type) |
CPDOWNSP: copy a value into an existing stack element. More... | |
void | o_rsadd (InstructionType type) |
RSADD: push an empty variable onto the stack. More... | |
void | o_cptopsp (InstructionType type) |
CPTOPSP: push a copy of a stack element on top of the stack. More... | |
void | o_const (InstructionType type) |
CONST: push a constant (predetermined value) variable onto the stack. More... | |
void | o_action (InstructionType type) |
ACTION: call a game-specific engine function. More... | |
void | o_logand (InstructionType type) |
LOGAND: perform a logical boolean AND (&&). More... | |
void | o_logor (InstructionType type) |
LOGOR: perform a logical boolean OR (||). More... | |
void | o_incor (InstructionType type) |
INCOR: perform a bit-wise inclusive OR (|). More... | |
void | o_excor (InstructionType type) |
EXCOR: perform a bit-wise exclusive OR (^). More... | |
void | o_booland (InstructionType type) |
BOOLAND: perform a bit-wise AND (&). More... | |
void | o_eq (InstructionType type) |
EQ: compare the top-most stack elements for equality (==). More... | |
void | o_neq (InstructionType type) |
NEQ: compare the top-most stack elements for inequality (!=). More... | |
void | o_geq (InstructionType type) |
GEQ: compare the top-most stack elements, greater-or-equal (>=). More... | |
void | o_gt (InstructionType type) |
GT: compare the top-most stack elements, greater (>). More... | |
void | o_lt (InstructionType type) |
LT: compare the top-most stack elements, less (<). More... | |
void | o_leq (InstructionType type) |
LEQ: compare the top-most stack elements, less-or-equal (<=). More... | |
void | o_shleft (InstructionType type) |
SHLEFT: shift the top-most stack element to the left (<<). More... | |
void | o_shright (InstructionType type) |
SHRIGHT: signed-shift the top-most stack element to the right (>>>). More... | |
void | o_ushright (InstructionType type) |
USHRIGHT: shift the top-most stack element to the right (>>). More... | |
void | o_add (InstructionType type) |
ADD: add the top-most stack elements (+). More... | |
void | o_sub (InstructionType type) |
SUB: subtract the top-most stack elements (-). More... | |
void | o_mul (InstructionType type) |
MUL: multiply the top-most stack elements (*). More... | |
void | o_div (InstructionType type) |
DIV: divide the top-most stack elements (/). More... | |
void | o_mod (InstructionType type) |
MOD: calculate the remainder (modulo) of an integer division (%). More... | |
void | o_neg (InstructionType type) |
NEQ: negate the top-most stack element (unary -). More... | |
void | o_comp (InstructionType type) |
COMP: calculate the 1-complement of the top-most stack element (~). More... | |
void | o_movsp (InstructionType type) |
MOVSP: pop elements off the stack. More... | |
void | o_storestateall (InstructionType type) |
STORESTATEALL: unused, obsolete opcode. More... | |
void | o_jmp (InstructionType type) |
JMP: jump directly to a different script offset. More... | |
void | o_jsr (InstructionType type) |
JSR: call a subroutine. More... | |
void | o_jz (InstructionType type) |
JZ: jump conditionally if the top-most stack element is 0. More... | |
void | o_retn (InstructionType type) |
RETN: return from a subroutine call. More... | |
void | o_destruct (InstructionType type) |
DESTRUCT: remove elements from the stack. More... | |
void | o_not (InstructionType type) |
NOT: boolean-negate the top-most stack element (!). More... | |
void | o_decsp (InstructionType type) |
DECSP: decrement the value of a stack element (–). More... | |
void | o_incsp (InstructionType type) |
INCSP: increment the value of a stack element (++). More... | |
void | o_jnz (InstructionType type) |
JNZ: jump conditionally if the top-most stack element is not 0. More... | |
void | o_cpdownbp (InstructionType type) |
CPDOWNBP: copy a value into an existing base-pointer stack element. More... | |
void | o_cptopbp (InstructionType type) |
CPTOPBP: push a copy of a base-pointer stack element on top of the stack. More... | |
void | o_decbp (InstructionType type) |
DECBP: decrement the value of a base-pointer stack element (–). More... | |
void | o_incbp (InstructionType type) |
INCBP: increment the value of a base-pointer stack element (++). More... | |
void | o_savebp (InstructionType type) |
SAVEBP: set the value of the base-pointer. More... | |
void | o_restorebp (InstructionType type) |
RESTOREBP: restore the value of the base-pointer to a prior value. More... | |
void | o_storestate (InstructionType type) |
STORESTATE: create a functor of a subroutine with the current stack. More... | |
void | o_writearray (InstructionType type) |
WRITEARRAY: write the value of an array element on the stack. More... | |
void | o_readarray (InstructionType type) |
READARRAY: push the value of an array element onto of the stack. More... | |
void | o_getref (InstructionType type) |
GETREF: push the reference to a stack element onto the stack. More... | |
void | o_getrefarray (InstructionType type) |
GETREFARRAY: push the reference to an array element onto the stack. More... | |
Private Attributes | |
Common::UString | _name |
NCSStack | _stack |
Common::ScopedPtr< Common::SeekableReadStream > | _script |
Variable | _return |
ObjectReference | _owner |
ObjectReference | _triggerer |
VariableContainer | _env |
std::stack< uint32 > | _returnOffsets |
Variable | _storedState |
const Opcode * | _opcodes |
size_t | _opcodeListSize |
Additional Inherited Members | |
Protected Member Functions inherited from Aurora::AuroraFile | |
void | readHeader (Common::ReadStream &stream) |
Static Protected Member Functions inherited from Aurora::AuroraFile | |
static uint32 | convertUTF16LE (uint32 x1, uint32 x2) |
Protected Attributes inherited from Aurora::AuroraFile | |
uint32 | _id |
The file's ID. More... | |
uint32 | _version |
The file's version. More... | |
bool | _utf16le |
The file's ID and version are in little-endian UTF-16. More... | |
|
private |
|
private |
Aurora::NWScript::NCSFile::NCSFile | ( | Common::SeekableReadStream * | ncs | ) |
Definition at line 277 of file ncsfile.cpp.
References _script, and load().
Aurora::NWScript::NCSFile::NCSFile | ( | const Common::UString & | ncs | ) |
Definition at line 283 of file ncsfile.cpp.
References _script, Common::UString::c_str(), Aurora::kFileTypeNCS, load(), Common::ScopedPtrBase< T, Deallocator >::reset(), and ResMan.
Aurora::NWScript::NCSFile::~NCSFile | ( | ) |
Definition at line 291 of file ncsfile.cpp.
|
private |
Helper function for o_action(), doing the actual engine function calling.
Definition at line 529 of file ncsfile.cpp.
References _owner, _stack, _storedState, _triggerer, Common::UString::c_str(), debugC(), FunctionMan, Aurora::NWScript::Variable::getFloat(), Aurora::NWScript::FunctionContext::getName(), Aurora::NWScript::FunctionContext::getParamMax(), Aurora::NWScript::FunctionContext::getParamMin(), Aurora::NWScript::FunctionContext::getParams(), Aurora::NWScript::FunctionContext::getReturn(), Aurora::NWScript::Variable::getScriptState(), Aurora::NWScript::Variable::getType(), Aurora::NWScript::Variable::getVector(), Common::kDebugScripts, Aurora::NWScript::kTypeAny, Aurora::NWScript::kTypeArray, Aurora::NWScript::kTypeEngineType, Aurora::NWScript::kTypeFloat, Aurora::NWScript::kTypeInt, Aurora::NWScript::kTypeObject, Aurora::NWScript::kTypeReference, Aurora::NWScript::kTypeScriptState, Aurora::NWScript::kTypeString, Aurora::NWScript::kTypeVector, Aurora::NWScript::kTypeVoid, Aurora::NWScript::NCSStack::pop(), Aurora::NWScript::NCSStack::push(), Aurora::NWScript::FunctionContext::setCaller(), Aurora::NWScript::FunctionContext::setCurrentScript(), Aurora::NWScript::FunctionContext::setParamsSpecified(), Aurora::NWScript::FunctionContext::setTriggerer(), Aurora::NWScript::Variable::setType(), Aurora::NWScript::Variable::setVector(), and Aurora::NWScript::NCSStack::top().
Referenced by o_action().
|
private |
Definition at line 428 of file ncsfile.cpp.
References _script.
|
private |
Definition at line 384 of file ncsfile.cpp.
References _name, _owner, _return, _stack, _triggerer, Common::UString::c_str(), debugC(), Aurora::NWScript::NCSStack::empty(), executeStep(), Aurora::NWScript::Variable::getInt(), Aurora::NWScript::Variable::getType(), Common::kDebugScripts, Aurora::NWScript::kTypeInt, and Aurora::NWScript::NCSStack::top().
Referenced by run().
|
private |
Execute one script step.
Definition at line 404 of file ncsfile.cpp.
References _opcodeListSize, _opcodes, _returnOffsets, _script, _stack, debugC(), Common::kDebugScripts, Aurora::NWScript::NCSStack::print(), and Aurora::NWScript::NCSFile::Opcode::proc.
Referenced by execute().
|
static |
Definition at line 306 of file ncsfile.cpp.
References Aurora::NWScript::ScriptState::offset.
Referenced by run(), Engines::Witcher::ScriptContainer::runScript(), Engines::Jade::ScriptContainer::runScript(), Engines::NWN::ScriptContainer::runScript(), Engines::NWN2::ScriptContainer::runScript(), Engines::KotOR::ScriptContainer::runScript(), Engines::KotOR2::ScriptContainer::runScript(), Engines::DragonAge::ScriptContainer::runScript(), and Engines::DragonAge2::ScriptContainer::runScript().
VariableContainer & Aurora::NWScript::NCSFile::getEnvironment | ( | ) |
Return the script's environment variables.
Environment variables can be set by script engine functions and will persist for the whole run of the script. Similar to an environment in a UNIX shell, if the script spawns off a second script, that child script will inherit the environment of its parent script.
Definition at line 298 of file ncsfile.cpp.
References _env.
Referenced by Aurora::NWScript::FunctionContext::getCurrentEnvironment(), Engines::DragonAge2::ScriptContainer::runScript(), and Engines::DragonAge::ScriptContainer::runScript().
const Common::UString & Aurora::NWScript::NCSFile::getName | ( | ) | const |
Definition at line 294 of file ncsfile.cpp.
References _name.
Referenced by Engines::DragonAge::Functions::getCurrentScriptName(), Engines::DragonAge2::Functions::getCurrentScriptName(), Engines::DragonAge2::Functions::getCurrentScriptResource(), Engines::DragonAge::Functions::getCurrentScriptResource(), and Aurora::NWScript::FunctionContext::getScriptName().
|
private |
Definition at line 314 of file ncsfile.cpp.
References Aurora::AuroraFile::_id, _script, Aurora::AuroraFile::_version, kNCSTag, Aurora::kVersion10, Aurora::AuroraFile::readHeader(), reset(), setupOpcodes(), and warning().
Referenced by NCSFile().
|
private |
ACTION: call a game-specific engine function.
Definition at line 625 of file ncsfile.cpp.
References _script, Common::StackException::add(), Common::UString::c_str(), callEngine(), FunctionMan, Aurora::NWScript::FunctionContext::getName(), and kInstTypeNone.
Referenced by setupOpcodes().
|
private |
ADD: add the top-most stack elements (+).
Definition at line 1088 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getFloat(), Aurora::NWScript::Variable::getInt(), Aurora::NWScript::Variable::getString(), kInstTypeFloatFloat, kInstTypeFloatInt, kInstTypeIntFloat, kInstTypeIntInt, kInstTypeStringString, kInstTypeVectorVector, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
BOOLAND: perform a bit-wise AND (&).
Definition at line 684 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getInt(), kInstTypeIntInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
COMP: calculate the 1-complement of the top-most stack element (~).
Definition at line 926 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getInt(), kInstTypeInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
CONST: push a constant (predetermined value) variable onto the stack.
Definition at line 482 of file ncsfile.cpp.
References _owner, _script, _stack, Common::kEncodingASCII, kInstTypeFloat, kInstTypeInt, kInstTypeObject, kInstTypeResource, kInstTypeString, kScriptObjectInvalid, kScriptObjectInvalid2, kScriptObjectSelf, kScriptObjectTypeInvalid, Aurora::NWScript::NCSStack::push(), and Common::readStringFixed().
Referenced by setupOpcodes().
|
private |
CPDOWNBP: copy a value into an existing base-pointer stack element.
Used to write into a global variable.
Definition at line 1423 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::NCSStack::getRelSP(), kInstTypeDirect, and Aurora::NWScript::NCSStack::setRelBP().
Referenced by setupOpcodes().
|
private |
CPDOWNSP: copy a value into an existing stack element.
Definition at line 1049 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::NCSStack::getRelSP(), kInstTypeDirect, and Aurora::NWScript::NCSStack::setRelSP().
Referenced by setupOpcodes().
|
private |
CPTOPBP: push a copy of a base-pointer stack element on top of the stack.
Used to read from a global variable.
Definition at line 1447 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::NCSStack::getRelBP(), kInstTypeDirect, and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
CPTOPSP: push a copy of a stack element on top of the stack.
Definition at line 1070 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::NCSStack::getRelSP(), kInstTypeDirect, and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
DECBP: decrement the value of a base-pointer stack element (–).
Definition at line 1001 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::Variable::getInt(), Aurora::NWScript::NCSStack::getRelBP(), kInstTypeInt, and Aurora::NWScript::NCSStack::setRelBP().
Referenced by setupOpcodes().
|
private |
DECSP: decrement the value of a stack element (–).
Definition at line 970 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::Variable::getInt(), Aurora::NWScript::NCSStack::getRelSP(), kInstTypeInt, and Aurora::NWScript::NCSStack::setRelSP().
Referenced by setupOpcodes().
|
private |
DESTRUCT: remove elements from the stack.
Used to isolate struct elements.
Definition at line 1389 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::NCSStack::pop(), Aurora::NWScript::NCSStack::push(), and Aurora::NWScript::NCSStack::top().
Referenced by setupOpcodes().
|
private |
DIV: divide the top-most stack elements (/).
Definition at line 1268 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getFloat(), Aurora::NWScript::Variable::getInt(), INT32_MIN, kInstTypeFloatFloat, kInstTypeFloatInt, kInstTypeFloatVector, kInstTypeIntFloat, kInstTypeIntInt, kInstTypeVectorFloat, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
EQ: compare the top-most stack elements for equality (==).
Definition at line 694 of file ncsfile.cpp.
References _script, _stack, kInstTypeStructStruct, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
EXCOR: perform a bit-wise exclusive OR (^).
Definition at line 674 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getInt(), kInstTypeIntInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
GEQ: compare the top-most stack elements, greater-or-equal (>=).
Definition at line 752 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getFloat(), Aurora::NWScript::Variable::getInt(), kInstTypeFloatFloat, kInstTypeIntInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
GETREF: push the reference to a stack element onto the stack.
Creates a reference to a variable, usually an engine type like Event or Effect, so that it can be modified by an engine function directly, without having to create a modified copy. Added with Dragon Age II.
The offset to the variable to create a reference to is passed as a direct argument to the instruction.
Definition at line 1573 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::NCSStack::getRelSP(), kInstTypeDirect, Aurora::NWScript::kTypeReference, Aurora::NWScript::NCSStack::push(), Aurora::NWScript::Variable::setReference(), and Aurora::NWScript::NCSStack::top().
Referenced by setupOpcodes().
|
private |
GETREFARRAY: push the reference to an array element onto the stack.
Like GETREF, this creates a reference to a variable, usually an engine type like Event or Effect, so that it can be modified by an engine function directly, without having to create a modified copy. GETREFARRAY, however, create a reference to a variable held inside a dynamic array variable. Added with Dragon Age II.
The index of the array is at the top-most stack position; the offset to the array variable is passed as a direct argument to the instruction.
The index is popped off the stack, and the reference to the variable inside the array is pushed on top.
Definition at line 1604 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::Variable::getArray(), Aurora::NWScript::Variable::getInt(), Aurora::NWScript::NCSStack::getRelSP(), kInstTypeDirect, Aurora::NWScript::kTypeReference, Aurora::NWScript::NCSStack::pop(), Aurora::NWScript::NCSStack::push(), Aurora::NWScript::Variable::setReference(), and Aurora::NWScript::NCSStack::top().
Referenced by setupOpcodes().
|
private |
GT: compare the top-most stack elements, greater (>).
Definition at line 776 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getFloat(), Aurora::NWScript::Variable::getInt(), kInstTypeFloatFloat, kInstTypeIntInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
INCBP: increment the value of a base-pointer stack element (++).
Definition at line 1011 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::Variable::getInt(), Aurora::NWScript::NCSStack::getRelBP(), kInstTypeInt, and Aurora::NWScript::NCSStack::setRelBP().
Referenced by setupOpcodes().
|
private |
INCOR: perform a bit-wise inclusive OR (|).
Definition at line 664 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getInt(), kInstTypeIntInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
INCSP: increment the value of a stack element (++).
Definition at line 980 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::Variable::getInt(), Aurora::NWScript::NCSStack::getRelSP(), kInstTypeInt, and Aurora::NWScript::NCSStack::setRelSP().
Referenced by setupOpcodes().
|
private |
JMP: jump directly to a different script offset.
Definition at line 942 of file ncsfile.cpp.
References _script, and kInstTypeNone.
Referenced by setupOpcodes().
|
private |
JNZ: jump conditionally if the top-most stack element is not 0.
Definition at line 990 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::Variable::getInt(), kInstTypeNone, and Aurora::NWScript::NCSStack::pop().
Referenced by setupOpcodes().
|
private |
JSR: call a subroutine.
Definition at line 1362 of file ncsfile.cpp.
References _returnOffsets, _script, and kInstTypeNone.
Referenced by setupOpcodes().
|
private |
JZ: jump conditionally if the top-most stack element is 0.
Definition at line 951 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::Variable::getInt(), kInstTypeNone, and Aurora::NWScript::NCSStack::pop().
Referenced by setupOpcodes().
|
private |
LEQ: compare the top-most stack elements, less-or-equal (<=).
Definition at line 824 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getFloat(), Aurora::NWScript::Variable::getInt(), kInstTypeFloatFloat, kInstTypeIntInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
LOGAND: perform a logical boolean AND (&&).
Definition at line 644 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getInt(), kInstTypeIntInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
LOGOR: perform a logical boolean OR (||).
Definition at line 654 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getInt(), kInstTypeIntInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
LT: compare the top-most stack elements, less (<).
Definition at line 800 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getFloat(), Aurora::NWScript::Variable::getInt(), kInstTypeFloatFloat, kInstTypeIntInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
MOD: calculate the remainder (modulo) of an integer division (%).
Definition at line 894 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getInt(), kInstTypeIntInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
MOVSP: pop elements off the stack.
Definition at line 934 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::NCSStack::getStackPtr(), kInstTypeNone, and Aurora::NWScript::NCSStack::setStackPtr().
Referenced by setupOpcodes().
|
private |
MUL: multiply the top-most stack elements (*).
Definition at line 1204 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getFloat(), Aurora::NWScript::Variable::getInt(), kInstTypeFloatFloat, kInstTypeFloatInt, kInstTypeFloatVector, kInstTypeIntFloat, kInstTypeIntInt, kInstTypeVectorFloat, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
NEQ: negate the top-most stack element (unary -).
Definition at line 910 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getFloat(), Aurora::NWScript::Variable::getInt(), kInstTypeFloat, kInstTypeInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
NEQ: compare the top-most stack elements for inequality (!=).
Definition at line 723 of file ncsfile.cpp.
References _script, _stack, kInstTypeStructStruct, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
NOP: no operation.
Definition at line 1044 of file ncsfile.cpp.
Referenced by setupOpcodes().
|
private |
NOT: boolean-negate the top-most stack element (!).
Definition at line 962 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getInt(), kInstTypeInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
READARRAY: push the value of an array element onto of the stack.
Reads out of the dynamic array variables types added with Dragon Age: Origins.
The index of the array to read is at the top-most stack position; the offset to the array variable is passed as a direct argument to the instruction.
The index is popped off the stack, and the value read out of the array is pushed on top.
Definition at line 1541 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::Variable::getArray(), Aurora::NWScript::Variable::getInt(), Aurora::NWScript::NCSStack::getRelSP(), kInstTypeDirect, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
RESTOREBP: restore the value of the base-pointer to a prior value.
Destroy the global variables anchor point after use.
Definition at line 1036 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getInt(), kInstTypeNone, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::setBasePtr().
Referenced by setupOpcodes().
|
private |
RETN: return from a subroutine call.
Definition at line 1375 of file ncsfile.cpp.
References _returnOffsets, and _script.
Referenced by setupOpcodes().
|
private |
RSADD: push an empty variable onto the stack.
Definition at line 440 of file ncsfile.cpp.
References _stack, kInstTypeEngineType0, kInstTypeEngineType0Array, kInstTypeEngineType1, kInstTypeEngineType1Array, kInstTypeEngineType2, kInstTypeEngineType2Array, kInstTypeEngineType3, kInstTypeEngineType3Array, kInstTypeEngineType4, kInstTypeEngineType4Array, kInstTypeEngineType5, kInstTypeEngineType5Array, kInstTypeFloat, kInstTypeFloatArray, kInstTypeInt, kInstTypeIntArray, kInstTypeObject, kInstTypeObjectArray, kInstTypeResource, kInstTypeResourceArray, kInstTypeString, kInstTypeStringArray, Aurora::NWScript::kTypeArray, Aurora::NWScript::kTypeEngineType, Aurora::NWScript::kTypeFloat, Aurora::NWScript::kTypeInt, Aurora::NWScript::kTypeObject, Aurora::NWScript::kTypeString, and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
SAVEBP: set the value of the base-pointer.
Used to create an anchor point to access global variables.
Definition at line 1024 of file ncsfile.cpp.
References _stack, Aurora::NWScript::NCSStack::getBasePtr(), Aurora::NWScript::NCSStack::getStackPtr(), kInstTypeNone, Aurora::NWScript::NCSStack::push(), and Aurora::NWScript::NCSStack::setBasePtr().
Referenced by setupOpcodes().
|
private |
SHLEFT: shift the top-most stack element to the left (<<).
Definition at line 848 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getInt(), kInstTypeIntInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
SHRIGHT: signed-shift the top-most stack element to the right (>>>).
Definition at line 858 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getInt(), kInstTypeIntInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
STORESTATE: create a functor of a subroutine with the current stack.
Used to create the "action" variables when calling an engine function that assigns a function to an object, or delays a function, or similar.
Definition at line 1470 of file ncsfile.cpp.
References _script, _stack, _storedState, Aurora::NWScript::NCSStack::getRelBP(), Aurora::NWScript::NCSStack::getRelSP(), Aurora::NWScript::Variable::getScriptState(), Aurora::NWScript::ScriptState::globals, Aurora::NWScript::kTypeScriptState, Aurora::NWScript::ScriptState::locals, Aurora::NWScript::ScriptState::offset, and Aurora::NWScript::Variable::setType().
Referenced by setupOpcodes().
|
private |
STORESTATEALL: unused, obsolete opcode.
Hopefully.
Definition at line 1353 of file ncsfile.cpp.
References warning().
Referenced by setupOpcodes().
|
private |
SUB: subtract the top-most stack elements (-).
Definition at line 1150 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getFloat(), Aurora::NWScript::Variable::getInt(), kInstTypeFloatFloat, kInstTypeFloatInt, kInstTypeIntFloat, kInstTypeIntInt, kInstTypeVectorVector, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
USHRIGHT: shift the top-most stack element to the right (>>).
Definition at line 879 of file ncsfile.cpp.
References _stack, Aurora::NWScript::Variable::getInt(), kInstTypeIntInt, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::push().
Referenced by setupOpcodes().
|
private |
WRITEARRAY: write the value of an array element on the stack.
Writes into the dynamic array variables types added with Dragon Age: Origins.
The index of the array to write and the value to write are at the top-most stack position; the offset to the array variable is passed as a direct argument to the instruction.
The index is popped off the stack, but the value written remains.
Definition at line 1506 of file ncsfile.cpp.
References _script, _stack, Aurora::NWScript::Variable::getArray(), Aurora::NWScript::Variable::getInt(), Aurora::NWScript::NCSStack::getRelSP(), Aurora::NWScript::Variable::getType(), Aurora::NWScript::Variable::growArray(), kInstTypeDirect, Aurora::NWScript::NCSStack::pop(), and Aurora::NWScript::NCSStack::top().
Referenced by setupOpcodes().
|
private |
Reset the script for another execution.
Definition at line 338 of file ncsfile.cpp.
References _return, _returnOffsets, _script, _stack, _storedState, Aurora::NWScript::kTypeVoid, Aurora::NWScript::NCSStack::reset(), and Aurora::NWScript::Variable::setType().
Referenced by load(), and run().
Run the current script, from start to finish.
Definition at line 350 of file ncsfile.cpp.
References getEmptyState().
Referenced by Engines::Witcher::Functions::executeScript(), Engines::Jade::Functions::executeScript(), Engines::NWN::Functions::executeScript(), Engines::NWN2::Functions::executeScript(), run(), Engines::Witcher::ScriptContainer::runScript(), Engines::NWN::ScriptContainer::runScript(), Engines::NWN2::ScriptContainer::runScript(), Engines::KotOR2::ScriptContainer::runScript(), Engines::Jade::ScriptContainer::runScript(), Engines::KotOR::ScriptContainer::runScript(), Engines::DragonAge2::ScriptContainer::runScript(), Engines::DragonAge::ScriptContainer::runScript(), and Aurora::DLGFile::runScript().
const Variable & Aurora::NWScript::NCSFile::run | ( | const ObjectReference | owner = ObjectReference() , |
const ObjectReference | triggerer = ObjectReference() |
||
) |
Definition at line 354 of file ncsfile.cpp.
References getEmptyState(), and run().
const Variable & Aurora::NWScript::NCSFile::run | ( | const ScriptState & | state, |
Object * | owner = 0 , |
||
Object * | triggerer = 0 |
||
) |
Run the current script, from this state to finish.
Definition at line 358 of file ncsfile.cpp.
References run().
const Variable & Aurora::NWScript::NCSFile::run | ( | const ScriptState & | state, |
const ObjectReference | owner = ObjectReference() , |
||
const ObjectReference | triggerer = ObjectReference() |
||
) |
Definition at line 362 of file ncsfile.cpp.
References _name, _script, _stack, Common::UString::c_str(), debugC(), execute(), Aurora::NWScript::NCSStack::getStackPtr(), Aurora::NWScript::ScriptState::globals, Common::kDebugScripts, Aurora::NWScript::ScriptState::locals, Aurora::NWScript::ScriptState::offset, Aurora::NWScript::NCSStack::push(), reset(), and Aurora::NWScript::NCSStack::setBasePtr().
void Aurora::NWScript::NCSFile::setEnvironment | ( | const VariableContainer & | env | ) |
Overwrite the environment.
Definition at line 302 of file ncsfile.cpp.
References _env.
Referenced by Engines::Witcher::Functions::executeScript(), Engines::NWN::Functions::executeScript(), and Engines::NWN2::Functions::executeScript().
|
private |
Definition at line 194 of file ncsfile.cpp.
References _opcodeListSize, _opcodes, ARRAYSIZE, o_action(), o_add(), o_booland(), o_comp(), o_const(), o_cpdownbp(), o_cpdownsp(), o_cptopbp(), o_cptopsp(), o_decbp(), o_decsp(), o_destruct(), o_div(), o_eq(), o_excor(), o_geq(), o_getref(), o_getrefarray(), o_gt(), o_incbp(), o_incor(), o_incsp(), o_jmp(), o_jnz(), o_jsr(), o_jz(), o_leq(), o_logand(), o_logor(), o_lt(), o_mod(), o_movsp(), o_mul(), o_neg(), o_neq(), o_nop(), o_not(), o_readarray(), o_restorebp(), o_retn(), o_rsadd(), o_savebp(), o_shleft(), o_shright(), o_storestate(), o_storestateall(), o_sub(), o_ushright(), o_writearray(), OPCODE, and OPCODE0.
Referenced by load().
|
private |
Definition at line 177 of file ncsfile.h.
Referenced by getEnvironment(), and setEnvironment().
|
private |
|
private |
Definition at line 189 of file ncsfile.h.
Referenced by executeStep(), and setupOpcodes().
|
private |
Definition at line 188 of file ncsfile.h.
Referenced by executeStep(), and setupOpcodes().
|
private |
Definition at line 174 of file ncsfile.h.
Referenced by callEngine(), execute(), and o_const().
|
private |
|
private |
|
private |
Definition at line 170 of file ncsfile.h.
Referenced by decompile(), executeStep(), load(), NCSFile(), o_action(), o_const(), o_cpdownbp(), o_cpdownsp(), o_cptopbp(), o_cptopsp(), o_decbp(), o_decsp(), o_destruct(), o_eq(), o_getref(), o_getrefarray(), o_incbp(), o_incsp(), o_jmp(), o_jnz(), o_jsr(), o_jz(), o_movsp(), o_neq(), o_readarray(), o_retn(), o_storestate(), o_writearray(), reset(), and run().
|
private |
Definition at line 169 of file ncsfile.h.
Referenced by callEngine(), execute(), executeStep(), o_add(), o_booland(), o_comp(), o_const(), o_cpdownbp(), o_cpdownsp(), o_cptopbp(), o_cptopsp(), o_decbp(), o_decsp(), o_destruct(), o_div(), o_eq(), o_excor(), o_geq(), o_getref(), o_getrefarray(), o_gt(), o_incbp(), o_incor(), o_incsp(), o_jnz(), o_jz(), o_leq(), o_logand(), o_logor(), o_lt(), o_mod(), o_movsp(), o_mul(), o_neg(), o_neq(), o_not(), o_readarray(), o_restorebp(), o_rsadd(), o_savebp(), o_shleft(), o_shright(), o_storestate(), o_sub(), o_ushright(), o_writearray(), reset(), and run().
|
private |
Definition at line 181 of file ncsfile.h.
Referenced by callEngine(), o_storestate(), and reset().
|
private |
Definition at line 175 of file ncsfile.h.
Referenced by callEngine(), and execute().