]> git.localhorst.tv Git - l2e.git/blob - src/common/ScriptRunner.h
handle compare/jump instructions in script assembler
[l2e.git] / src / common / ScriptRunner.h
1 /*
2  * ScriptRunner.h
3  *
4  *  Created on: Oct 13, 2012
5  *      Author: holy
6  */
7
8 #ifndef COMMON_SCRIPTRUNNER_H_
9 #define COMMON_SCRIPTRUNNER_H_
10
11 #include "fwd.h"
12 #include "../geometry/Vector.h"
13
14 #include <SDL.h>
15
16 namespace common {
17
18 class ScriptRunner {
19
20 public:
21         ScriptRunner();
22         ~ScriptRunner();
23
24 public:
25         void Run(ScriptHost &, const Script &);
26         bool Running() const;
27
28         void *Address0() const { return address0; }
29         void *Address1() const { return address1; }
30         int Integer0() const { return integer0; }
31         int Integer1() const { return integer1; }
32         const geometry::Vector<int> &Vector0() const { return vector0; }
33         const geometry::Vector<int> &Vector1() const { return vector1; }
34
35 private:
36         void Reset();
37         void Exec(unsigned char code);
38
39         void *PopAddress();
40         int PopInt();
41         const geometry::Vector<int> &PopVector();
42
43         void Compare(int, int);
44
45         enum CompareFlags {
46                 COMPARE_EQUAL = 0,
47                 COMPARE_LESS = 1,
48                 COMPARE_GREATER = 2,
49         };
50
51 private:
52         ScriptHost *host;
53         const Script *script;
54         int cursor;
55
56         void *address0;
57         void *address1;
58         int integer0;
59         int integer1;
60         geometry::Vector<int> vector0;
61         geometry::Vector<int> vector1;
62
63         Uint8 compare;
64
65 };
66
67 }
68
69 #endif /* COMMON_SCRIPTRUNNER_H_ */