2010-07-03 13:04:00 +00:00
|
|
|
|
|
|
|
#include "extensions.hpp"
|
|
|
|
|
|
|
|
#include <components/compiler/extensions.hpp>
|
|
|
|
|
|
|
|
#include <components/interpreter/interpreter.hpp>
|
|
|
|
#include <components/interpreter/runtime.hpp>
|
|
|
|
#include <components/interpreter/opcodes.hpp>
|
|
|
|
|
|
|
|
#include "../mwscript/interpretercontext.hpp"
|
|
|
|
|
2010-07-03 13:41:20 +00:00
|
|
|
#include "../mwworld/world.hpp"
|
2010-07-03 13:04:00 +00:00
|
|
|
|
2010-07-03 13:17:02 +00:00
|
|
|
#include "soundmanager.hpp"
|
|
|
|
|
2010-07-03 13:04:00 +00:00
|
|
|
namespace MWSound
|
|
|
|
{
|
|
|
|
namespace Script
|
|
|
|
{
|
|
|
|
class OpSayDone : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual void execute (Interpreter::Runtime& runtime)
|
|
|
|
{
|
|
|
|
MWScript::InterpreterContext& context
|
|
|
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
|
|
|
2010-07-03 13:17:02 +00:00
|
|
|
runtime.push (context.getSoundManager().sayDone ("", context));
|
2010-07-03 13:04:00 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class OpGetSoundPlaying : public Interpreter::Opcode0
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual void execute (Interpreter::Runtime& runtime)
|
|
|
|
{
|
|
|
|
MWScript::InterpreterContext& context
|
|
|
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
|
|
|
|
|
|
int index = runtime[0];
|
|
|
|
runtime.pop();
|
|
|
|
|
2010-07-03 13:17:02 +00:00
|
|
|
runtime.push (context.getSoundManager().getSoundPlaying (
|
2010-07-03 13:04:00 +00:00
|
|
|
"", runtime.getStringLiteral (index), context));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const int opcodeSay = 0x2000001;
|
|
|
|
const int opcodeSayDone = 0x2000002;
|
|
|
|
const int opcodeStreamMusic = 0x2000003;
|
|
|
|
const int opcodePlaySound = 0x2000004;
|
|
|
|
const int opcodePlaySoundVP = 0x2000005;
|
|
|
|
const int opcodePlaySound3D = 0x2000006;
|
|
|
|
const int opcodePlaySound3DVP = 0x2000007;
|
|
|
|
const int opcodeStopSound = 0x2000008;
|
|
|
|
const int opcodeGetSoundPlaying = 0x2000009;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO opcodeSay, opcodeStreamMusic, opcodePlaySound, opcodePlaySoundVP,
|
|
|
|
// opcodePlaySound, opcodePlaySound, opcodeStopSound
|
|
|
|
|
|
|
|
void registerExtensions (Compiler::Extensions& extensions)
|
|
|
|
{
|
|
|
|
extensions.registerFunction ("saydone", 'l', "", Script::opcodeSayDone);
|
|
|
|
|
|
|
|
extensions.registerFunction ("getsoundplaying", 'l', "S", Script::opcodeGetSoundPlaying);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
|
|
|
{
|
|
|
|
interpreter.installSegment5 (Script::opcodeSayDone, new Script::OpSayDone);
|
|
|
|
|
|
|
|
interpreter.installSegment5 (Script::opcodeGetSoundPlaying, new Script::OpGetSoundPlaying);
|
|
|
|
}
|
|
|
|
}
|