File: opcodes.h

package info (click to toggle)
exult 1.12.0-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 43,608 kB
  • sloc: cpp: 169,917; xml: 7,400; yacc: 2,850; makefile: 2,419; java: 1,901; ansic: 1,654; lex: 673; sh: 539; objc: 416
file content (150 lines) | stat: -rw-r--r-- 5,209 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/**
 ** Opcodes.h - Opcode definitions for Usecode.
 **
 ** Written: 1/1/01 - JSF
 **/

/*
 *  Copyright (C) 2001-2022  The Exult Team
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef INCL_OPCODES
#define INCL_OPCODES 1

enum UsecodeOps {
	UC_INVALID     = -1,
	UC_EXTOPCODE   = 0x80,
	UC_LOOPTOP     = 0x02,
	UC_CONVERSE    = 0x04,
	UC_JNE         = 0x05,
	UC_JMP         = 0x06,
	UC_CMPS        = 0x07,
	UC_ADD         = 0x09,
	UC_SUB         = 0x0a,
	UC_DIV         = 0x0b,
	UC_MUL         = 0x0c,
	UC_MOD         = 0x0d,
	UC_AND         = 0x0e,
	UC_OR          = 0x0f,
	UC_NOT         = 0x10,
	UC_POP         = 0x12,
	UC_PUSHTRUE    = 0x13,
	UC_PUSHFALSE   = 0x14,
	UC_CMPGT       = 0x16,
	UC_CMPLT       = 0x17,
	UC_CMPGE       = 0x18,
	UC_CMPLE       = 0x19,
	UC_CMPNE       = 0x1a,
	UC_ADDSI       = 0x1c,
	UC_PUSHS       = 0x1d,
	UC_ARRC        = 0x1e,
	UC_PUSHI       = 0x1f,
	UC_PUSH        = 0x21,
	UC_CMPEQ       = 0x22,
	UC_CALL        = 0x24,
	UC_RET         = 0x25,    // No return value.
	UC_AIDX        = 0x26,
	UC_RET2        = 0x2c,    // Identical to UC_RET; UCC never emits this.
	UC_RETV        = 0x2d,    // Returns value from stack.
	UC_LOOP        = 0x2e,
	UC_ADDSV       = 0x2f,
	UC_IN          = 0x30,
	UC_DEFAULT     = 0x31,    // Conversation default.
	UC_RETZ        = 0x32,    // Returns zero.
	UC_SAY         = 0x33,
	UC_CALLIS      = 0x38,
	UC_CALLI       = 0x39,
	UC_PUSHITEMREF = 0x3e,
	UC_ABRT        = 0x3f,
	UC_THROW = 0xbf,    // Like abrt, but accepts an expression to be sent up.
	UC_CONVERSELOC = 0x40,    // CONVERSE jmps here.
	UC_PUSHF       = 0x42,    // PUSH global flag.
	UC_POPF        = 0x43,    // POP global flag.
	UC_PUSHB       = 0x44,    // Push byte that follows.
	UC_POPARR      = 0x46,    // Pop into array elem.
	UC_CALLE       = 0x47,
	UC_PUSHEVENTID = 0x48,
	UC_ARRA        = 0x4a,
	UC_POPEVENTID  = 0x4b,
	UC_DBGLINE     = 0x4c,    // SI debug opcode; UCC never emits this.
	UC_DBGFUNC     = 0x4d,    // SI debug opcode; UCC never emits this.
	// Added for Exult:
	UC_PUSHSTATIC = 0x50,    // Push static.
	UC_POPSTATIC  = 0x51,    // Pop static.
	UC_CALLO      = 0x52,    // Call original.
	UC_CALLIND    = 0x53,    // Call indirect.  Addr. on stack.
	UC_PUSHTHV    = 0x54,    // Push this->var.
	UC_POPTHV     = 0x55,    // Pop this->var.
	UC_CALLM      = 0x56,    // Call method (index is param, class on stack).
	UC_CALLMS     = 0x57,    // Call method (index is param, and so is vtable).
	UC_CLSCREATE  = 0x58,    // Create class instance.
	UC_CLASSDEL   = 0x59,    // Delete class instance.
	UC_AIDXS      = 0x5a,    // Pop static array elem.
	UC_POPARRS    = 0x5b,    // Pop into static array elem.
	UC_LOOPTOPS   = 0x5c,    // Loop with static array
	UC_AIDXTHV    = 0x5d,    // Pop this->var array elem.
	UC_POPARRTHV  = 0x5e,    // Pop this->var array elem.
	UC_LOOPTOPTHV = 0x5f,    // Loop with this->var array.
	UC_PUSHCHOICE = 0x60,    // Pushes last selected user choice.
	UC_TRYSTART   = 0x61,    // TRY/CATCH block start.
	UC_TRYEND     = 0x62,    // TRY/CATCH block end.
	UC_PUSHFVAR   = 0xc2,    // PUSH global flag using stack value.
	UC_POPFVAR    = 0xc3,    // POP global flag using stack value.
	UC_CALLINDEX_OLD = 0xd3,    // Call indirect; UCC never emits this.
	UC_CALLINDEX = 0xd4,    // Call indirect.  Addr. on stack. with arguments

	// 32-bit usecode
	UC_LOOPTOP32  = 0x82,
	UC_CONVERSE32 = 0x84,
	UC_JNE32      = 0x85,
	UC_JMP32      = 0x86,
	UC_CMPS32     = 0x87,
	UC_ADDSI32    = 0x9c,
	UC_PUSHS32    = 0x9d,
	UC_PUSHI32    = 0x9f,
	UC_CALL32     = 0xa4,
	UC_LOOP32     = 0xae,    // 32-bit version of UC_LOOP; UCC never emits this.
	UC_DEFAULT32  = 0xb1,    // 32-bit version of conversation default opcode.
	UC_CALLE32    = 0xc7,
	UC_DBGFUNC32  = 0xcd,      // 32-bit version of SI debug opcode; UCC never
							   // emits this.
	UC_LOOPTOPS32   = 0xdc,    // 32-bit loop with static array.
	UC_LOOPTOPTHV32 = 0xdf,    // 32-bit loop with this->var array.
	UC_TRYSTART32   = 0xe1     // TRY/CATCH block, 32-bit version.
};

inline UsecodeOps& operator|=(UsecodeOps& lhs, int rhs) {
	lhs = static_cast<UsecodeOps>(static_cast<int>(lhs) | rhs);
	return lhs;
}

inline UsecodeOps& operator&=(UsecodeOps& lhs, int rhs) {
	lhs = static_cast<UsecodeOps>(static_cast<int>(lhs) & rhs);
	return lhs;
}

inline UsecodeOps operator|(const UsecodeOps& lhs, int rhs) {
	UsecodeOps ret = lhs;
	return ret |= rhs;
}

inline UsecodeOps operator&(const UsecodeOps& lhs, int rhs) {
	UsecodeOps ret = lhs;
	return ret &= rhs;
}

#endif