]> git.localhorst.tv Git - l2e.git/blob - src/common/ScriptRunner.h
renamed namespace geometry -> math
[l2e.git] / src / common / ScriptRunner.h
1 #ifndef COMMON_SCRIPTRUNNER_H_
2 #define COMMON_SCRIPTRUNNER_H_
3
4 #include "fwd.h"
5 #include "Script.h"
6 #include "../math/Vector.h"
7
8 #include <SDL.h>
9
10 namespace common {
11
12 class ScriptRunner {
13
14 public:
15         ScriptRunner();
16         ~ScriptRunner();
17
18 public:
19         void Run(ScriptHost &, const Script &);
20         bool Running() const;
21
22         void *AddressRegister(int n) const { return address[n]; }
23         int IntegerRegister(int n) const { return integer[n]; }
24         const math::Vector<int> &VectorRegister(int n) const { return vector[n]; }
25
26 private:
27         void Reset();
28         void Exec(Script::Code code);
29
30         void *PopAddress();
31         Script::Code PopCode();
32         int PopInt();
33         const math::Vector<int> &PopVector();
34
35         void Compare(int, int);
36
37         enum CompareFlags {
38                 COMPARE_EQUAL = 0,
39                 COMPARE_LESS = 1,
40                 COMPARE_GREATER = 2,
41         };
42
43 private:
44         ScriptHost *host;
45         const Script *script;
46         int cursor;
47
48         static const int numRegisters = 7;
49         void *address[numRegisters];
50         int integer[numRegisters];
51         math::Vector<int> vector[numRegisters];
52
53         Uint8 compare;
54
55 };
56
57 }
58
59 #endif /* COMMON_SCRIPTRUNNER_H_ */