2010-07-05 11:15:49 +00:00
|
|
|
|
|
|
|
#include "miscextensions.hpp"
|
|
|
|
|
|
|
|
#include <components/compiler/extensions.hpp>
|
|
|
|
|
|
|
|
#include <components/interpreter/interpreter.hpp>
|
|
|
|
#include <components/interpreter/runtime.hpp>
|
|
|
|
#include <components/interpreter/opcodes.hpp>
|
|
|
|
|
2010-07-06 08:25:42 +00:00
|
|
|
#include "interpretercontext.hpp"
|
|
|
|
|
2010-07-05 11:15:49 +00:00
|
|
|
namespace MWScript
|
|
|
|
{
|
|
|
|
namespace Misc
|
|
|
|
{
|
|
|
|
class OpXBox : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-05 11:15:49 +00:00
|
|
|
virtual void execute (Interpreter::Runtime& runtime)
|
|
|
|
{
|
|
|
|
runtime.push (0);
|
2010-08-03 20:43:53 +00:00
|
|
|
}
|
2010-07-05 11:15:49 +00:00
|
|
|
};
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-06 08:25:42 +00:00
|
|
|
class OpOnActivate : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-06 08:25:42 +00:00
|
|
|
virtual void execute (Interpreter::Runtime& runtime)
|
|
|
|
{
|
2010-08-03 20:43:53 +00:00
|
|
|
InterpreterContext& context =
|
|
|
|
static_cast<InterpreterContext&> (runtime.getContext());
|
|
|
|
|
|
|
|
MWWorld::Ptr ptr = context.getReference();
|
|
|
|
|
|
|
|
runtime.push (context.hasBeenActivated (ptr));
|
|
|
|
}
|
2010-07-06 08:25:42 +00:00
|
|
|
};
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-08-05 13:52:07 +00:00
|
|
|
class OpActivate : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual void execute (Interpreter::Runtime& runtime)
|
|
|
|
{
|
|
|
|
InterpreterContext& context =
|
|
|
|
static_cast<InterpreterContext&> (runtime.getContext());
|
|
|
|
|
|
|
|
MWWorld::Ptr ptr = context.getReference();
|
|
|
|
|
|
|
|
context.executeActivation();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-07-05 11:15:49 +00:00
|
|
|
const int opcodeXBox = 0x200000c;
|
2010-08-03 20:43:53 +00:00
|
|
|
const int opcodeOnActivate = 0x200000d;
|
2010-08-05 13:52:07 +00:00
|
|
|
const int opcodeActivate = 0x2000075;
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-05 11:15:49 +00:00
|
|
|
void registerExtensions (Compiler::Extensions& extensions)
|
|
|
|
{
|
|
|
|
extensions.registerFunction ("xbox", 'l', "", opcodeXBox);
|
2010-07-06 08:25:42 +00:00
|
|
|
extensions.registerFunction ("onactivate", 'l', "", opcodeOnActivate);
|
2010-08-05 13:52:07 +00:00
|
|
|
extensions.registerInstruction ("activate", "", opcodeActivate);
|
2010-07-05 11:15:49 +00:00
|
|
|
}
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-05 11:15:49 +00:00
|
|
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
|
|
|
{
|
|
|
|
interpreter.installSegment5 (opcodeXBox, new OpXBox);
|
2010-07-06 08:25:42 +00:00
|
|
|
interpreter.installSegment5 (opcodeOnActivate, new OpOnActivate);
|
2010-08-05 13:52:07 +00:00
|
|
|
interpreter.installSegment5 (opcodeActivate, new OpActivate);
|
2010-08-03 20:43:53 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-05 11:15:49 +00:00
|
|
|
}
|