ScummVM API documentation
script.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 CHAMBER_SCRIPT_H
23#define CHAMBER_SCRIPT_H
24
25#include "chamber/common.h"
26#include "chamber/room.h"
27
28namespace Chamber {
29
30enum ScriptPools {
31 kScrPool0_WordVars0,
32 kScrPool1_WordVars1,
33 kScrPool2_ByteVars,
34 kScrPool3_CurrentItem,
35 kScrPool4_ZoneSpots,
36 kScrPool5_Persons,
37 kScrPool6_Inventory,
38 kScrPool7_Zapstiks,
39 kScrPool8_CurrentPers,
40 kScrPools_MAX
41};
42
43/*Byte-packed, members accessed from script code by hardcoded offsets*/
44typedef struct script_byte_vars_t {
45 byte zone_index; /* 0 */
46 byte zone_room; /* 1 */
47 byte last_door; /* 2 */
48 byte cur_spot_idx; /* 3 */
49 byte the_wall_phase; /* 4 */
50 byte prev_zone_index; /* 5 */
51 byte bvar_06; /* 6 */
52 byte bvar_07; /* 7 */
53 byte bvar_08; /* 8 */
54 byte bvar_09; /* 9 */
55 byte bvar_0A; /* A */
56 byte bvar_0B; /* B */
57 byte zone_area; /* C */
58 byte dead_flag; /* D */
59 volatile byte timer_ticks; /* E */
60 byte gauss_phase; /* F */
61
62 byte bvar_10; /* 10 */
63 byte rand_value; /* 11 */
64 byte load_flag; /* 12 */
65 byte spot_m; /* 13 */
66 byte spot_v; /* 14 */
67 byte bvar_15; /* 15 */
68 byte bvar_16; /* 16 */
69 byte bvar_17; /* 17 */
70 byte bvar_18; /* 18 */
71 byte bvar_19; /* 19 */
72 byte bvar_1A; /* 1A */
73 byte bvar_1B; /* 1B */
74 byte bvar_1C; /* 1C */
75 byte bvar_1D; /* 1D */
76 byte bvar_1E; /* 1E */
77 byte bvar_1F; /* 1F */
78
79 byte cur_pers; /* 20 */
80 byte used_commands; /* 21 */
81 byte tries_left; /* 22 */
82 byte inv_item_index; /* 23 */
83 byte bvar_24; /* 24 */
84 byte bvar_25; /* 25 */
85 byte bvar_26; /* 26 */
86 byte bvar_27; /* 27 */
87 byte bvar_28; /* 28 */
88 byte bvar_29; /* 29 */
89 byte bvar_2A; /* 2A */
90 byte hands; /* 2B */
91 byte check_used_commands; /* 2C */
92 byte bvar_2D; /* 2D */
93 byte palette_index; /* 2E */
94 byte bvar_2F; /* 2F */
95
96 byte bvar_30; /* 30 */
97 byte zapstiks_owned; /* 31 */
98 byte bvar_32; /* 32 */
99 byte bvar_33; /* 33 */
100 byte bvar_34; /* 34 */
101 byte skulls_submitted; /* 35 */
102 byte bvar_36; /* 36 */
103 byte bvar_37; /* 37 */
104 byte zone_area_copy; /* 38 */
105 byte aspirant_flags; /* 39 */
106 byte aspirant_pers_ofs;/* 3A */
107 byte steals_count; /* 3B */
108 byte fight_status; /* 3C */
109 byte extreme_violence; /* 3D */
110 byte trade_accepted; /* 3E */
111 byte bvar_3F; /* 3F */
112
113 byte bvar_40; /* 40 */
114 byte bvar_41; /* 41 */
115 byte bvar_42; /* 42 */
116 byte bvar_43; /* 43 */
117 byte dirty_rect_kind; /* 44 */
118 byte bvar_45; /* 45 */
119 byte bvar_46; /* 46 */
120 byte game_paused; /* 47 */
121 byte skull_trader_status;/* 48 */
122 byte cur_spot_flags; /* 49 */
123 byte bvar_4A; /* 4A */
124 byte bvar_4B; /* 4B */
125 byte bvar_4C; /* 4C */
126 byte bvar_4D; /* 4D */
127 byte bvar_4E; /* 4E */
128 byte bvar_4F; /* 4F */
129
130 byte bvar_50; /* 50 */
131 byte bvar_51; /* 51 */
132 byte bvar_52; /* 52 */
133 byte bvar_53; /* 53 */
134 byte bvar_54; /* 54 */
135 byte bvar_55; /* 55 */
136 byte bvar_56; /* 56 */
137 byte need_draw_spots; /* 57 */
138 byte bvar_58; /* 58 */
139 byte bvar_59; /* 59 */
140 byte psy_energy; /* 5A */
141 byte bvar_5B; /* 5B */
142 byte bvar_5C; /* 5C */
143 byte bvar_5D; /* 5D */
144 byte bvar_5E; /* 5E */
145 byte bvar_5F; /* 5F */
146
147 byte bvar_60; /* 60 */
148 byte bvar_61; /* 61 */
149 byte bvar_62; /* 62 */
150 byte bvar_63; /* 63 */
151 byte bvar_64; /* 64 */
152 byte bvar_65; /* 65 */
153 byte bvar_66; /* 66 */
154 byte bvar_67; /* 67 */
155 byte zapstik_stolen; /* 68 */
156 byte bvar_69; /* 69 */
157 byte bvar_6A; /* 6A */
158 byte bvar_6B; /* 6B */
159 byte bvar_6C; /* 6C */
160 byte bvar_6D[4]; /* 6D */
162
163/*2-byte long vars, in BIG-endian order*/
164typedef struct script_word_vars_t {
165 uint16 psi_cmds[6]; /* 0 */
166 uint16 wvar_0C; /* C */
167 uint16 wvar_0E; /* E */
168 uint16 timer_ticks2; /* 10 */
169 uint16 zone_obj_cmds[15 * 5]; /* 12 */
170 uint16 next_aspirant_cmd; /* A8 */
171 uint16 wvar_AA; /* AA */
172 uint16 wvar_AC; /* AC */
173 uint16 wvar_AE; /* AE */
174 uint16 wvar_B0; /* B0 */
175 uint16 wvar_B2; /* B2 */
176 uint16 wvar_B4; /* B4 */
177 uint16 next_protozorqs_cmd; /* B6 */
178 uint16 wvar_B8; /* B8 */
180
181extern void *script_vars[kScrPools_MAX];
182extern script_word_vars_t script_word_vars;
183extern script_byte_vars_t script_byte_vars;
184
185/*Don't trade this item*/
186#define ITEMFLG_DONTWANT 1
187#define ITEMFLG_04 0x04
188#define ITEMFLG_08 0x08
189/*Skull Trader's item*/
190#define ITEMFLG_TRADER 0x10
191/*Aspirant's item*/
192#define ITEMFLG_ASPIR 0x20
193/*In a room?*/
194#define ITEMFLG_ROOM 0x40
195/*In pocket?*/
196#define ITEMFLG_OWNED 0x80
197
198/*TODO: manipulated from script, do not change*/
199#include "common/pack-start.h"
200typedef struct item_t {
201 byte flags;
202 byte area; /*item location*/
203 byte sprite; /*item sprite index*/
204 byte name; /*item name index (relative)*/
205 uint16 command; /*TODO: warning! in native format, check if never accessed from scripts*/
206} item_t;
207#include "common/pack-end.h"
208
209#define MAX_INV_ITEMS 63
210extern item_t inventory_items[MAX_INV_ITEMS];
211
212#define PERS_MAX 41
213extern pers_t pers_list[PERS_MAX];
214
215extern byte *script_stack[5 * 2];
216extern byte **script_stack_ptr;
217
218extern pers_t *vort_ptr;
219
220#define SPECIAL_COMMANDS_MAX 20
221extern uint16 menu_commands_12[SPECIAL_COMMANDS_MAX];
222extern uint16 menu_commands_22[SPECIAL_COMMANDS_MAX];
223extern uint16 menu_commands_24[SPECIAL_COMMANDS_MAX];
224extern uint16 menu_commands_23[SPECIAL_COMMANDS_MAX];
225
226extern uint16 fight_pers_ofs;
227
228extern byte wait_delta;
229
230extern byte rand_seed;
231byte getRand(void);
232uint16 getRandW(void);
233
234extern uint16 the_command;
235
236byte *getScriptSubroutine(uint16 index);
237
238uint16 runCommand(void);
239uint16 runCommandKeepSp(void);
240
241uint16 Swap16(uint16 x);
242
243void initScriptVars();
244
245} // End of namespace Chamber
246
247#endif
Definition: script.h:200
Definition: room.h:58
Definition: script.h:44
Definition: script.h:164