ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cc_internal.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 #ifndef AGS_SHARED_SCRIPT_CC_INTERNAL_H
23 #define AGS_SHARED_SCRIPT_CC_INTERNAL_H
24 
25 namespace AGS3 {
26 
27 #define SCOM_VERSION 90
28 #define SCOM_VERSIONSTR "0.90"
29 
30 // virtual CPU registers
31 #define SREG_SP 1 // stack pointer
32 #define SREG_MAR 2 // memory address register
33 #define SREG_AX 3 // general purpose
34 #define SREG_BX 4
35 #define SREG_CX 5
36 #define SREG_OP 6 // object pointer for member func calls
37 #define SREG_DX 7
38 #define CC_NUM_REGISTERS 8
39 
40 // virtual CPU commands
41 #define SCMD_ADD 1 // reg1 += arg2
42 #define SCMD_SUB 2 // reg1 -= arg2
43 #define SCMD_REGTOREG 3 // reg2 = reg1
44 #define SCMD_WRITELIT 4 // m[MAR] = arg2 (copy arg1 bytes)
45 #define SCMD_RET 5 // return from subroutine
46 #define SCMD_LITTOREG 6 // set reg1 to literal value arg2
47 #define SCMD_MEMREAD 7 // reg1 = m[MAR]
48 #define SCMD_MEMWRITE 8 // m[MAR] = reg1
49 #define SCMD_MULREG 9 // reg1 *= reg2
50 #define SCMD_DIVREG 10 // reg1 /= reg2
51 #define SCMD_ADDREG 11 // reg1 += reg2
52 #define SCMD_SUBREG 12 // reg1 -= reg2
53 #define SCMD_BITAND 13 // bitwise reg1 & reg2
54 #define SCMD_BITOR 14 // bitwise reg1 | reg2
55 #define SCMD_ISEQUAL 15 // reg1 == reg2 reg1=1 if true, =0 if not
56 #define SCMD_NOTEQUAL 16 // reg1 != reg2
57 #define SCMD_GREATER 17 // reg1 > reg2
58 #define SCMD_LESSTHAN 18 // reg1 < reg2
59 #define SCMD_GTE 19 // reg1 >= reg2
60 #define SCMD_LTE 20 // reg1 <= reg2
61 #define SCMD_AND 21 // (reg1!=0) && (reg2!=0) -> reg1
62 #define SCMD_OR 22 // (reg1!=0) || (reg2!=0) -> reg1
63 #define SCMD_CALL 23 // jump to subroutine at reg1
64 #define SCMD_MEMREADB 24 // reg1 = m[MAR] (1 byte)
65 #define SCMD_MEMREADW 25 // reg1 = m[MAR] (2 bytes)
66 #define SCMD_MEMWRITEB 26 // m[MAR] = reg1 (1 byte)
67 #define SCMD_MEMWRITEW 27 // m[MAR] = reg1 (2 bytes)
68 #define SCMD_JZ 28 // jump if ax==0 to arg1
69 #define SCMD_PUSHREG 29 // m[sp]=reg1; sp++
70 #define SCMD_POPREG 30 // sp--; reg1=m[sp]
71 #define SCMD_JMP 31 // jump to arg1
72 #define SCMD_MUL 32 // reg1 *= arg2
73 #define SCMD_CALLEXT 33 // call external (imported) function reg1
74 #define SCMD_PUSHREAL 34 // push reg1 onto real stack
75 #define SCMD_SUBREALSTACK 35 // decrement stack ptr by literal
76 #define SCMD_LINENUM 36 // debug info - source code line number
77 #define SCMD_CALLAS 37 // call external script function
78 #define SCMD_THISBASE 38 // current relative address
79 #define SCMD_NUMFUNCARGS 39 // number of arguments for ext func call
80 #define SCMD_MODREG 40 // reg1 %= reg2
81 #define SCMD_XORREG 41 // reg1 ^= reg2
82 #define SCMD_NOTREG 42 // reg1 = !reg1
83 #define SCMD_SHIFTLEFT 43 // reg1 = reg1 << reg2
84 #define SCMD_SHIFTRIGHT 44 // reg1 = reg1 >> reg2
85 #define SCMD_CALLOBJ 45 // next call is member function of reg1
86 #define SCMD_CHECKBOUNDS 46 // check reg1 is between 0 and arg2
87 #define SCMD_MEMWRITEPTR 47 // m[MAR] = reg1 (adjust ptr addr)
88 #define SCMD_MEMREADPTR 48 // reg1 = m[MAR] (adjust ptr addr)
89 #define SCMD_MEMZEROPTR 49 // m[MAR] = 0 (blank ptr)
90 #define SCMD_MEMINITPTR 50 // m[MAR] = reg1 (but don't free old one)
91 #define SCMD_LOADSPOFFS 51 // MAR = SP - arg1 (optimization for local var access)
92 #define SCMD_CHECKNULL 52 // error if MAR==0
93 #define SCMD_FADD 53 // reg1 += arg2 (float,int)
94 #define SCMD_FSUB 54 // reg1 -= arg2 (float,int)
95 #define SCMD_FMULREG 55 // reg1 *= reg2 (float)
96 #define SCMD_FDIVREG 56 // reg1 /= reg2 (float)
97 #define SCMD_FADDREG 57 // reg1 += reg2 (float)
98 #define SCMD_FSUBREG 58 // reg1 -= reg2 (float)
99 #define SCMD_FGREATER 59 // reg1 > reg2 (float)
100 #define SCMD_FLESSTHAN 60 // reg1 < reg2 (float)
101 #define SCMD_FGTE 61 // reg1 >= reg2 (float)
102 #define SCMD_FLTE 62 // reg1 <= reg2 (float)
103 #define SCMD_ZEROMEMORY 63 // m[MAR]..m[MAR+(arg1-1)] = 0
104 #define SCMD_CREATESTRING 64 // reg1 = new String(reg1)
105 #define SCMD_STRINGSEQUAL 65 // (char*)reg1 == (char*)reg2 reg1=1 if true, =0 if not
106 #define SCMD_STRINGSNOTEQ 66 // (char*)reg1 != (char*)reg2
107 #define SCMD_CHECKNULLREG 67 // error if reg1 == NULL
108 #define SCMD_LOOPCHECKOFF 68 // no loop checking for this function
109 #define SCMD_MEMZEROPTRND 69 // m[MAR] = 0 (blank ptr, no dispose if = ax)
110 #define SCMD_JNZ 70 // jump to arg1 if ax!=0
111 #define SCMD_DYNAMICBOUNDS 71 // check reg1 is between 0 and m[MAR-4]
112 #define SCMD_NEWARRAY 72 // reg1 = new array of reg1 elements, each of size arg2 (arg3=managed type?)
113 #define SCMD_NEWUSEROBJECT 73 // reg1 = new user object of arg1 size
114 
115 #define CC_NUM_SCCMDS 74
116 #define MAX_SCMD_ARGS 3 // maximal possible number of arguments
117 
118 #define EXPORT_FUNCTION 1
119 #define EXPORT_DATA 2
120 
121 #define FIXUP_NOFIXUP 0 // no-op
122 #define FIXUP_GLOBALDATA 1 // code[fixup] += &globaldata[0]
123 #define FIXUP_FUNCTION 2 // code[fixup] += &code[0]
124 #define FIXUP_STRING 3 // code[fixup] += &strings[0]
125 #define FIXUP_IMPORT 4 // code[fixup] = &imported_thing[code[fixup]]
126 #define FIXUP_DATADATA 5 // globaldata[fixup] += &globaldata[0]
127 #define FIXUP_STACK 6 // code[fixup] += &stack[0]
128 
129 // Script file signature
130 #define ENDFILESIG 0xbeefcafe
131 
132 } // namespace AGS3
133 
134 #endif
Definition: ags.h:40