ScummVM API documentation
instruction.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 // Based on Phantasma code by Thomas Harte (2013),
23 // available at https://github.com/TomHarte/Phantasma/ (MIT)
24 
25 #ifndef FREESCAPE_INSTRUCTION_H
26 #define FREESCAPE_INSTRUCTION_H
27 
28 #include "common/array.h"
29 #include "common/str.h"
30 #include "freescape/language/token.h"
31 
32 namespace Freescape {
33 
34 enum {
35  kConditionalShot = 1 << 0,
36  kConditionalTimeout = 1 << 1,
37  kConditionalCollided = 1 << 2,
38  kConditionalActivated = 1 << 3,
39  kConditionalSensed = 1 << 4,
40  kConditionalFallen = 1 << 5,
41  kConditionalCrushed = 1 << 6,
42 };
43 
44 class FCLInstruction;
45 typedef Common::Array<FCLInstruction> FCLInstructionVector;
46 
47 FCLInstructionVector *duplicateCondition(const FCLInstructionVector *condition);
48 
50 public:
52  FCLInstruction(Token::Type type);
53  void setSource(int32 source, Token::Type type = Token::CONSTANT);
54  void setAdditional(int32 additional, Token::Type type = Token::CONSTANT);
55  void setDestination(int32 destination, Token::Type type = Token::CONSTANT);
56 
57  Token::Type getType() const;
58 
59  void setBranches(FCLInstructionVector *thenBranch, FCLInstructionVector *elseBranch);
60 
61  FCLInstruction duplicate() const;
62 
63  // Source/destination: arithmetic uses (variable, value); GOTO uses (area, entrance).
64  // Object commands use (object) or (area, object).
65  int32 _source;
66  int32 _additional;
67  int32 _destination;
68  // Kit decoders mark omitted operands as UNKNOWN.
69  Token::Type _sourceType;
70  Token::Type _additionalType;
71  Token::Type _destinationType;
72  Common::String _text;
73 
74  FCLInstructionVector *_thenInstructions;
75  FCLInstructionVector *_elseInstructions;
76 
77 private:
78  Token::Type _type;
79 };
80 
81 } // End of namespace Freescape
82 
83 #endif // FREESCAPE_INSTRUCTION_H
Definition: str.h:59
Definition: area.h:36
Definition: instruction.h:49