DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
runscript.hpp
1#pragma once
2
3#include "common.h"
4
8// clang-format off
9enum RS_OPCODE {
10 RS_OP_LOAD = 1,
11 RS_OP_LOAD_ADDR = 2,
12 RS_OP_PUSH_CONST = 3,
13 RS_OP_POP = 4,
14 RS_OP_STORE = 5,
15 RS_OP_ADD = 6,
16 RS_OP_SUB = 7,
17 RS_OP_MUL = 8,
18 RS_OP_DIV = 9,
19 RS_OP_MOD = 10,
20 RS_OP_NEG = 11,
21 RS_OP_ITOF = 12,
22 RS_OP_FTOI = 13,
23 RS_OP_CMP = 14,
24 RS_OP_RET = 15,
25 RS_OP_JMP = 16,
26 RS_OP_JMP_FALSE = 17,
27 RS_OP_JMP_TRUE = 18,
28 RS_OP_CALL = 19,
29 RS_OP_PRINT = 20,
30 RS_OP_EXT = 21,
31 RS_OP_WAIT = 23,
32 RS_OP_AND = 24,
33 RS_OP_OR = 25,
34 RS_OP_NOT = 26,
35 RS_OP_END = 27,
36 RS_OP_SKIP_END = 28,
37 RS_OP_SIN = 29,
38 RS_OP_COS = 30,
39};
40
41// clang-format on
42
46// clang-format off
47enum RS_ADDR_MODE {
48 RS_ADDR_LOCAL = 1,
49 RS_ADDR_LOCAL_INDEX = 2,
50 RS_ADDR_POINTER_INDEX = 4,
51 RS_ADDR_LOCAL_FLOAT = 8,
52 RS_ADDR_LOCAL_INDEX_FLOAT = 16,
53 RS_ADDR_POINTER_INDEX_FLOAT = 32,
54};
55
56// clang-format on
57
61// clang-format off
62enum RS_COMPARE {
63 RS_CMP_EQ = 40,
64 RS_CMP_NE = 41,
65 RS_CMP_LT = 42,
66 RS_CMP_LE = 43,
67 RS_CMP_GT = 44,
68 RS_CMP_GE = 45,
69};
70
71// clang-format on
72
77 int type;
79 union {
80 int i;
81 float f;
82 char *s;
84 };
85};
86
87enum {
88 RS_INT = 0,
89 RS_FLOAT = 1,
90 RS_STR = 2,
91 RS_PTR = 3
92};
93
97struct vmcode_t {
98 int op;
99 int arg1;
100 int arg2;
101};
102
106struct funcdata {
107 int addr;
108 char *name;
109 int local;
110 int arg;
111};
112
121
126 int no;
127 int func;
128};
129
134 int unk_0;
135 int main;
136 int code;
137 int prog;
139};
140
145public:
147 int (**ext_func_table)(RS_STACKDATA *, int);
159 int end;
162 char *code;
163 int result;
168 int IsEnd() { return end; }
169
177 CRunScript();
178
187 void check_stack();
188
197 void push(RS_STACKDATA value);
198
207 void push_int(int value);
208
217 void push_str(char *string);
218
227 void push_ptr(RS_STACKDATA *pointer);
228
237 void push_float(float value);
238
248
257 vmcode_t *call_func(funcdata *callee, vmcode_t *return_pc);
258
268
277 void ext(RS_STACKDATA *args, int argc);
278
288
298
307 void ext_func(int (**table)(RS_STACKDATA *, int), int count);
308
317 void resume();
318
327 int run(int no);
328
337 int check_program(int no);
338
347 void skip();
348
357 void exe(vmcode_t *entry);
358};
vmcode_t * ret_func()
RS_STACKDATA * sp
void skip()
void ext(RS_STACKDATA *args, int argc)
RS_STACKDATA * stack_end
vmcode_t * call_func(funcdata *callee, vmcode_t *return_pc)
void exe(vmcode_t *entry)
funcdata * func
RS_CALLDATA * call
RS_CALLDATA * call_end
RS_STACKDATA * stack
void check_stack()
Definition runscript.cpp:71
void reload(RS_PROG_HEADER *prog)
RS_STACKDATA pop()
RS_PROG_HEADER * prog
RS_STACKDATA * frame
void resume()
void push_ptr(RS_STACKDATA *pointer)
Definition runscript.cpp:94
int run(int no)
int check_program(int no)
vmcode_t * pc
RS_CALLDATA * call_sp
void push_int(int value)
Definition runscript.cpp:82
int(** ext_func_table)(RS_STACKDATA *, int)
void push_float(float value)
char * code
void load(RS_PROG_HEADER *prog, RS_STACKDATA *stack, int stack_num, RS_CALLDATA *call, int call_num)
void push(RS_STACKDATA value)
Definition runscript.cpp:77
void push_str(char *string)
Definition runscript.cpp:88
RS_STACKDATA * frame
vmcode_t * ret
funcdata * func
RS_STACKDATA * p
Definition runscript.hpp:83
char * name