ScummVM API documentation
room.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 MADS_CORE_ROOM_H
23 #define MADS_CORE_ROOM_H
24 
25 #include "common/stream.h"
26 #include "mads/core/general.h"
27 #include "mads/core/vocab.h"
28 #include "mads/core/color.h"
29 #include "mads/core/image.h"
30 #include "mads/core/loader.h"
31 #include "mads/core/tile.h"
32 
33 namespace MADS {
34 
35 #define room_file_version "4.01"
36 #define pict_file_version "4.01"
37 
38 /* Flags to be passed to room_load(). Note that any of the PAL_MAP... */
39 /* flags can be passed to this routine as well. */
40 
41 #define ROOM_LOAD_TRANSLATE 0x0001 /* Translate to 16 colors */
42 #define ROOM_LOAD_HARD_SHADOW 0x0010 /* Load hard shadow */
43 
44 #define ROOM_MAX_VARIANTS 10
45 #define ROOM_MAX_HOTSPOTS 40
46 #define ROOM_MAX_RAILS 20
47 
48 #define ROOM_MAX_SERIES 10
49 #define ROOM_MAX_IMAGES 50
50 
51 #define ROOM_FORMAT_NORMAL 1
52 #define ROOM_FORMAT_PANNING 2
53 
54 #define ROOM_PICTURE 0
55 #define ROOM_WALK 1
56 #define ROOM_DEPTH 2
57 #define ROOM_SPECIAL 3
58 
59 #define ROOM_DEFAULT_ATTRIBUTE 0x0f
60 
61 #define LEGALITY_MASK 0xc000
62 #define WEIGHT_MASK 0x3fff
63 
64 #define LEGAL 0x8000
65 #define ILLEGAL 0x4000
66 #define TOTALLY_ILLEGAL 0x0000
67 
68 #define WALK_DIRECT -1 /* Walk to clicked point */
69  /* (but only for default) */
70 #define WALK_NONE -2 /* Don't walk at all */
71 #define WALK_DIRECT_2 -3 /* Walk to clicked, always */
72 
73 #define artwork_file series_name[ROOM_MAX_SERIES-1]
74 
75 
76 /* Develop-time structure for hotspots (.HOT files) */
77 
78 struct HotSpotEdit {
79  int ul_x, ul_y, lr_x, lr_y; /* Hotspot screen coordinates */
80  int feet_x, feet_y; /* Walk-to target for player */
81  byte facing; /* Direction player should face */
82  byte prep; /* Preposition */
83  byte cursor_number; /* Mouse cursor number */
84  byte syntax; /* Word syntax */
85  char vocab[VC_MAXWORDLEN + 1]; /* Vocabulary name of hotspot */
86  char verb[VC_MAXWORDLEN + 1]; /* Vocabulary default verb name */
87 };
88 
89 typedef HotSpotEdit *HotEditPtr;
90 
91 
92 /* Run-time structure for hotspots (.HH files) */
93 
94 struct HotSpot {
95  int16 ul_x, ul_y, lr_x, lr_y; /* Hotspot screen coordinates */
96  int16 feet_x, feet_y; /* Walk-to target for player */
97  byte facing; /* Direction player should face */
98  byte prep; /* Preposition */
99  byte active; /* Flag if hotspot is active */
100  byte cursor_number; /* Mouse cursor number */
101  byte syntax; /* Syntax */
102  //-- padding byte--
103  int16 vocab; /* Vocabulary id of hotspot name */
104  int16 verb; /* Vocabulary id of default verb */
105 
106  static constexpr size_t SIZE = 6 * 2 + (5 * 1) + 1 + 2 + 2;
107  void load(Common::SeekableReadStream *src, bool isRexNebular);
108 };
109 
110 typedef HotSpot *HotPtr;
111 
112 
113 /* "Rail" nodes for smart walk */
114 
115 struct Rail {
116  int16 x, y; /* Screen location of node */
117  word weight[ROOM_MAX_RAILS + 2]; /* Distance to other nodes in room */
118 
119  static constexpr size_t SIZE = 2 + 2 + 2 * (ROOM_MAX_RAILS + 2);
120  void load(Common::SeekableReadStream *src);
121 };
122 
123 typedef Rail *RailPtr;
124 
125 
126 /* Room artwork definition structure (.ART files) */
127 
128 struct RoomArt {
129  int16 xs; /* Size of picture (follows this... */
130  int16 ys; /* ...structure in the .ART file) */
131  ColorList color_list; /* List of colors used in picture */
132  CycleList cycle_list; /* List of color cycling ranges */
133 
134  static constexpr int SIZE = 2 + 2 + ColorList::SIZE + CycleList::SIZE;
135  void load(Common::SeekableReadStream *src);
136 };
137 typedef RoomArt *RoomArtPtr;
138 
139 
140 /* Room picture definition structure (.PCT files) */
141 
142 struct RoomPict {
143  int id; /* Room id */
144  int picture_id; /* Room picture id */
145  int format; /* Attribute format*/
146  int xs, ys; /* Size */
147 
148  int misc[10]; /* padding */
149 
150  int num_variants; /* # of variants */
151  char variant_desc[ROOM_MAX_VARIANTS][64]; /* descriptions */
152 
153  int num_series;
154  int num_images;
155  char series_name[ROOM_MAX_SERIES][64]; /* # of series */
156  Image image_list[ROOM_MAX_IMAGES]; /* # of images */
157 
158  int num_translated; /* Number of colors translated to 16 */
159  ColorList color_list; /* Room's color list */
160 
161  CycleList cycle_list; /* Room's color cycling information */
162 };
163 
164 typedef RoomPict RoomPictPtr;
165 
166 
167 /* Room definition structure (.DEF files) */
168 
169 struct RoomDef {
170  char picture_base[80]; /* Picture base */
171 
172  int misc[10]; /* Room padding */
173 
174  int num_hotspots; /* # of hotspots */
175  HotSpotEdit hotspot[ROOM_MAX_HOTSPOTS]; /* definitions */
176 
177  int front_y, back_y; /* Player scaling baselines */
178  int front_scale, back_scale;/* Player scaling factors */
179 
180  int depth_table[16]; /* Player sprite depth table */
181 
182  int num_rails; /* # of rails */
183  Rail rail[ROOM_MAX_RAILS + 2];/* Smart walk rails */
184 
185  ShadowList shadow; /* Shadow list */
186 };
187 
188 struct RoomFile {
189  char picture_base[80]; /* Picture base name */
190  uint16 misc[10]; /* Padding for future updates */
191  uint16 num_variants; /* Number of attribute variants */
192  uint16 num_hotspots; /* Number of hot spots */
193  uint16 num_rails; /* Number of rail nodes */
194  uint16 front_y, back_y; /* Player scaling baselines */
195  uint16 front_scale, back_scale; /* Player scaling factors */
196  uint16 depth_table[16]; /* Player depth table */
197  Rail rail[ROOM_MAX_RAILS]; /* Rail nodes for room */
198 
199  ShadowList shadow; /* Shadow list */
200 
201  static constexpr size_t SIZE = 80 + (2 * 10) + 2 + 2 + 2 + (2 + 2) + (2 + 2) + 2 * 16 +
202  (Rail::SIZE * ROOM_MAX_RAILS) + ShadowList::SIZE;
203  void load(Common::SeekableReadStream *src);
204 };
205 
206 
207 
208 /* Run-time room definition structure (in memory) */
209 
210 struct Room {
211  int16 room_id; /* Room id (only in Rex Nebular) */
212  byte format; /* Room format (only in Rex Nebular) */
213  int16 xs, ys; /* X and Y size of room picture */
214 
215  uint16 misc[10]; /* Padding for future updates */
216  uint16 num_variants; /* Number of attribute variants */
217  uint16 num_hotspots; /* Number of hotspots */
218  uint16 num_rails; /* Number of rail nodes */
219  int16 front_y, back_y; /* Player scaling baselines */
220  int16 front_scale, back_scale; /* Player scaling factors */
221  uint16 depth_table[16]; /* Player depth table */
222 
223  int16 color_handle; /* Background color handle */
224  int16 variant_loaded; /* Current attribute variant */
225 
226  CycleList cycle_list; /* Active color cycling ranges */
227 
228  Rail rail[1]; /* Rail nodes begin here... */
229 };
230 typedef Room *RoomPtr;
231 
232 extern RoomDef roomdef;
233 extern int room_load_error;
234 
235 extern byte room_loaded_depth;
236 extern byte room_loaded_walk;
237 extern byte room_loaded_special;
238 
243 extern int room_read_def(int room_code, char *room_file, char *picture_base, int mads_mode);
244 extern int room_write_def(int room_code, const char *room_file, int mads_mode);
245 extern RoomPtr room_load(int id, int variant, const char *base_path,
246  Buffer *picture, Buffer *depth, Buffer *walk, Buffer *special,
247  TileMapHeader *picture_map, TileMapHeader *depth_map,
248  TileResource *picture_resource, TileResource *depth_resource,
249  int picture_ems_handle, int depth_ems_handle, int load_flags);
250 extern void room_unload(RoomPtr room, Buffer *picture, Buffer *depth, Buffer *walk,
251  Buffer *special, TileMapHeader *picture_map, TileMapHeader *depth_map);
252 
256 extern int room_load_variant(int id, int variant, const char *base_path, RoomPtr room,
257  Buffer *depth, Buffer *walk, Buffer *special, TileMapHeader *depth_map,
258  TileResource *depth_resource, int depth_ems_handle);
259 extern void room_dump_attribute(Buffer *depth, Buffer *walk, Buffer *special,
260  TileMapHeader *depth_map);
261 extern HotPtr room_load_hotspots(int id, int *num_spots);
262 
268 extern int room_read_pict(int room_code, const char *room_file, int mads_mode);
269 extern int room_write_pict(int room_code, const char *room_file, int mads_mode);
270 extern void room_file_name(char *target, const char *suffix, int code,
271  char *main_name, int mads_mode);
272 extern void room_himem_preload(int room, int level);
273 extern RoomPtr room_dummy_init(int xs, int ys);
274 extern int room_picture_load(int room_id, Buffer *picture, int load_flags);
275 extern void room_resolve_base(char *base, char *file, int id, const char *base_path);
276 extern int room_invert();
277 
278 extern void init_room();
279 
280 } // namespace MADS
281 
282 #endif
Definition: general.h:57
Definition: stream.h:745
Definition: tile.h:62
Definition: room.h:115
Definition: color.h:78
Definition: room.h:188
Definition: room.h:78
Definition: room.h:94
Definition: room.h:169
Definition: room.h:210
Definition: room.h:142
Definition: anim_timer.h:27
Definition: movie_decoder.h:32
Definition: color.h:106
Definition: tile.h:41
Definition: room.h:128
Definition: color.h:125