25 #ifndef AURORA_NWSCRIPT_NCSFILE_H 26 #define AURORA_NWSCRIPT_NCSFILE_H 44 class SeekableReadStream;
51 class NCSStack :
public std::vector<Variable> {
83 #define DECLARE_OPCODE(x) void x(InstructionType type) 259 #undef DECLARE_OPCODE 265 #endif // AURORA_NWSCRIPT_NCSFILE_H
VariableContainer & getEnvironment()
Return the script's environment variables.
void o_retn(InstructionType type)
RETN: return from a subroutine call.
ObjectReference _triggerer
void o_ushright(InstructionType type)
USHRIGHT: shift the top-most stack element to the right (>>).
void o_writearray(InstructionType type)
WRITEARRAY: write the value of an array element on the stack.
void o_leq(InstructionType type)
LEQ: compare the top-most stack elements, less-or-equal (<=).
void reset()
Reset the script for another execution.
void o_destruct(InstructionType type)
DESTRUCT: remove elements from the stack.
A class holding an UTF-8 string.
void o_getref(InstructionType type)
GETREF: push the reference to a stack element onto the stack.
void o_incsp(InstructionType type)
INCSP: increment the value of a stack element (++).
void o_decsp(InstructionType type)
DECSP: decrement the value of a stack element (–).
void setBasePtr(int32 pos)
Variable & getRelSP(int32 pos)
void o_movsp(InstructionType type)
MOVSP: pop elements off the stack.
void o_comp(InstructionType type)
COMP: calculate the 1-complement of the top-most stack element (~).
bool executeStep()
Execute one script step.
#define DECLARE_OPCODE(x)
void o_lt(InstructionType type)
LT: compare the top-most stack elements, less (<).
void o_rsadd(InstructionType type)
RSADD: push an empty variable onto the stack.
An NCS, BioWare's NWN Compile Script.
void o_jsr(InstructionType type)
JSR: call a subroutine.
A simple scoped smart pointer template.
const Variable & execute(const ObjectReference owner=ObjectReference(), const ObjectReference triggerer=ObjectReference())
void o_excor(InstructionType type)
EXCOR: perform a bit-wise exclusive OR (^).
void o_cptopbp(InstructionType type)
CPTOPBP: push a copy of a base-pointer stack element on top of the stack.
Variable & getRelBP(int32 pos)
Common::ScopedPtr< Common::SeekableReadStream > _script
const Variable & run(Object *owner=0, Object *triggerer=0)
Run the current script, from start to finish.
void o_savebp(InstructionType type)
SAVEBP: set the value of the base-pointer.
void o_restorebp(InstructionType type)
RESTOREBP: restore the value of the base-pointer to a prior value.
void o_storestate(InstructionType type)
STORESTATE: create a functor of a subroutine with the current stack.
Base for BioWare's Aurora engine files.
void o_eq(InstructionType type)
EQ: compare the top-most stack elements for equality (==).
void o_add(InstructionType type)
ADD: add the top-most stack elements (+).
void o_jnz(InstructionType type)
JNZ: jump conditionally if the top-most stack element is not 0.
void o_neq(InstructionType type)
NEQ: compare the top-most stack elements for inequality (!=).
void o_sub(InstructionType type)
SUB: subtract the top-most stack elements (-).
Low-level type definitions to handle fixed width types portably.
void o_storestateall(InstructionType type)
STORESTATEALL: unused, obsolete opcode.
void o_readarray(InstructionType type)
READARRAY: push the value of an array element onto of the stack.
void(NCSFile::* OpcodeProc)(InstructionType type)
void o_const(InstructionType type)
CONST: push a constant (predetermined value) variable onto the stack.
std::stack< uint32 > _returnOffsets
void setStackPtr(int32 pos)
void setRelSP(int32 pos, const Variable &obj)
void o_logor(InstructionType type)
LOGOR: perform a logical boolean OR (||).
void o_mul(InstructionType type)
MUL: multiply the top-most stack elements (*).
void o_getrefarray(InstructionType type)
GETREFARRAY: push the reference to an array element onto the stack.
An NWScript variable container.
void o_neg(InstructionType type)
NEQ: negate the top-most stack element (unary -).
static ScriptState getEmptyState()
void o_cpdownsp(InstructionType type)
CPDOWNSP: copy a value into an existing stack element.
void callEngine(Aurora::NWScript::FunctionContext &ctx, uint32 function, uint8 argCount)
Helper function for o_action(), doing the actual engine function calling.
Basic type definitions to handle files used in BioWare's Aurora engine.
void o_div(InstructionType type)
DIV: divide the top-most stack elements (/).
void push(const Variable &obj)
void o_action(InstructionType type)
ACTION: call a game-specific engine function.
Reference to an NWScript object.
void o_nop(InstructionType type)
NOP: no operation.
void o_cptopsp(InstructionType type)
CPTOPSP: push a copy of a stack element on top of the stack.
void o_logand(InstructionType type)
LOGAND: perform a logical boolean AND (&&).
void o_mod(InstructionType type)
MOD: calculate the remainder (modulo) of an integer division (%).
NCSFile(Common::SeekableReadStream *ncs)
Base class for most files found in games using BioWare's Aurora engine.
void o_jz(InstructionType type)
JZ: jump conditionally if the top-most stack element is 0.
void o_cpdownbp(InstructionType type)
CPDOWNBP: copy a value into an existing base-pointer stack element.
void o_not(InstructionType type)
NOT: boolean-negate the top-most stack element (!).
void setRelBP(int32 pos, const Variable &obj)
void o_incbp(InstructionType type)
INCBP: increment the value of a base-pointer stack element (++).
const Common::UString & getName() const
void o_gt(InstructionType type)
GT: compare the top-most stack elements, greater (>).
void o_shright(InstructionType type)
SHRIGHT: signed-shift the top-most stack element to the right (>>>).
void o_decbp(InstructionType type)
DECBP: decrement the value of a base-pointer stack element (–).
void o_booland(InstructionType type)
BOOLAND: perform a bit-wise AND (&).
void o_jmp(InstructionType type)
JMP: jump directly to a different script offset.
void o_incor(InstructionType type)
INCOR: perform a bit-wise inclusive OR (|).
Interface for a seekable & readable data stream.
void o_geq(InstructionType type)
GEQ: compare the top-most stack elements, greater-or-equal (>=).
void o_shleft(InstructionType type)
SHLEFT: shift the top-most stack element to the left (<<).
void setEnvironment(const VariableContainer &env)
Overwrite the environment.