ScummVM API documentation
anim.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_ANIM_H
23 #define MADS_CORE_ANIM_H
24 
25 #include "audio/audiostream.h"
26 #include "common/stream.h"
27 #include "mads/core/general.h"
28 #include "mads/core/font.h"
29 #include "mads/core/image.h"
30 #include "mads/core/room.h"
31 #include "mads/core/sprite.h"
32 #include "mads/core/tile.h"
33 
34 namespace MADS {
35 
36 /* Flags to be passed to anim_load(). Note that all PAL_MAP... flags */
37 /* can be passed through as well. */
38 
39 #define ANIM_LOAD_TRANSLATE 0x0001 /* Translate to 16 colors */
40 #define ANIM_LOAD_BACKGROUND 0x0100 /* Load background picture */
41 #define ANIM_LOAD_BACK_ONLY 0x0200 /* Load background only */
42 #define ANIM_INTERFACE 0x4000
43 
44 /* these are mapped to misc[] in the AnimFile structure below */
45 
46 #define depth_coded misc[0]
47 #define misc_any_packed misc[1]
48 #define misc_packed_series misc[2]
49 #define misc_peel_x misc[3]
50 #define misc_peel_y misc[4]
51 #define misc_peel_rate misc[5]
52 #define misc_slow_fade misc[6]
53 
54 #define misc_no_catchup misc[7]
55 
56 #define seg_misc_coordinate_style misc[0]
57 #define seg_misc_displace_x misc[1]
58 #define seg_misc_displace_y misc[2]
59 
60 #define seg_misc_disp_good_1 misc[3] /* holds magic number (problem w/ uninitialized data) */
61 #define seg_misc_disp_good_2 misc[4]
62 #define SEG_MAGIC_1 0x1234
63 #define SEG_MAGIC_2 0x5678
64 
65 #define seg_misc_accel_x misc[5]
66 #define seg_misc_accel_y misc[6]
67 
68 #define seg_misc_special_scale misc[7]
69 
70 #define SEG_SPECIAL_SCALE_UP 0x8000
71 #define SEG_SPECIAL_SCALE_DOWN 0x4000
72 #define SEG_SPECIAL_SCALE_MASK 0xf000
73 
74 #define AA_MAX_SERIES 50 /* Maximum # of series */
75 #define AA_MAX_SEGMENTS 25 /* Maximum # of segments */
76 #define AA_MAX_FRAMES 500 /* Maximum # of frames */
77 #define AA_MAX_IMAGES 500 /* Maximum # of images */
78 #define AA_MAX_SPEECH 25 /* Maximum # of speech queues */
79 
80 #define AA_MAX_IMAGES_PER_FRAME 250 /* Maximum images in one frame */
81 
82 #define AA_MAX_SPAWNED 2 /* Maximum # of spawns in random */
83 
84 #define AA_MAX_CHANGES 100 /* Maximum # of speech changes */
85 
86 
87 #define AA_ROOM 1 /* Use MADS room as background */
88 #define AA_FULLSIZE 2 /* Use MADS full screen room */
89 #define AA_BLACKSCREEN 3 /* Black screen background */
90 #define AA_INTERFACE 4 /* Use MADS interface screen */
91 
92 
93 #define AA_DONTCARE -1
94 
95 #define AA_LINEAR 1 /* loop_mode settings */
96 #define AA_PINGPONG 2
97 #define AA_STAMP 9 /* FOR KERNEL SEQUENCES ONLY */
98 
99 #define AA_ONCE 1 /* repeat_mode settings */
100 #define AA_MULTIPLE 2
101 
102 #define AA_ROOMBASED -1 /* depth/scale settings */
103 #define AA_MANUAL -2
104 
105 #define AA_ABSOLUTEFRAME 1 /* framing settings */
106 #define AA_DELTAFIRST 2
107 #define AA_DELTALAST 3
108 #define AA_ABSOLUTEFIRST 4
109 #define AA_ABSOLUTELAST 5
110 #define AA_RANDOMACCESS 6
111 
112 #define AA_NOTHING 0 /* No timing marks */
113 #define AA_MARK 0x8000 /* Timing MARK portion */
114 #define AA_TIMING 0x7fff /* Timing TICKS portion */
115 
116 #define AA_LOAD_SOUND 0x8000 /* Load sound file */
117 #define AA_LOAD_SPEECH 0x4000 /* Load speech file */
118 #define AA_LOAD_FONT 0x2000 /* Load font file */
119 
120 #define AA_NO_SPEECH (-1) /* No speech queue */
121 
122 #define AA_SPEECH 0x8000 /* Use speech always */
123 #define AA_TEXT 0x4000 /* Use text always */
124 #define AA_SPEECH_XOR_TEXT 0x2000 /* Use speech or text */
125 #define AA_SPEECH_AND_TEXT 0x1000 /* Use speech and text */
126 #define AA_SPEECH_NOR_TEXT 0x0800 /* Use neither */
127 
128 #define AA_ABORTABLE 0x8000 /* Segment can be aborted */
129 #define AA_CONVENTIONAL 0x4000 /* Segment uses conventional memory */
130 #define AA_PRELOAD 0x2000 /* Segment preloads (conv. only) */
131 
132 
133 #define AA_ERR_OPENFILE -128
134 #define AA_ERR_WRITEFILE -129
135 #define AA_ERR_READFILE -130
136 #define AA_ERR_NOMOREMEMORY -131
137 #define AA_ERR_MAKEDIALOG -132
138 #define AA_ERR_TOOMANYIMAGES -133
139 #define AA_ERR_TOOMANYFRAMES -134
140 #define AA_ERR_TOOMANYSEGMENTS -135
141 #define AA_ERR_TOOMANYSPEECH -136
142 #define AA_ERR_NODAMNFONT -137
143 #define AA_ERR_BADDEFINITION -138
144 #define AA_ERR_OLDDEFINITION -139
145 
146 
147 #define IMAGE_UNSCALED 0xff
148 
149 #define IMAGE_UPDATE_READY 0x40 /* Ready for live screen */
150 
151 #define IMAGE_UPDATE 1 /* Image needs redraw */
152 #define IMAGE_STATIC 0 /* Image remains on screen */
153 #define IMAGE_ERASE -1 /* Image erased & removed */
154 #define IMAGE_REFRESH -2 /* Full buffer refresh */
155 #define IMAGE_OVERPRINT -3 /* Interface overprint */
156 #define IMAGE_DELTA -4 /* Image drawn to scr_orig */
157 #define IMAGE_FULLUPDATE -5 /* Interface area erasure */
158 
159 #define IMAGE_UPDATE_ONLY -20 /* Update live screen only */
160 
161 
162 struct SegmentBuf {
163  int seg_id;
164 
165  char name[32];
166 
167  int series_id;
168  int mirror_series;
169  int start_sprite;
170  int end_sprite;
171  int sprite_loop_mode;
172  int sprite_repeat_mode;
173  double loop_direction;
174 
175  int framing;
176  int first_frame;
177  int last_frame;
178 
179  byte depth_mode;
180  byte low_level_change;
181 
182  int scale_mode;
183  int front_y, back_y;
184  int front_scale, back_scale;
185 
186  int probability;
187 
188  byte spawn[AA_MAX_SPAWNED];
189  int spawn_frame[AA_MAX_SPAWNED];
190  byte sound;
191  int sound_frame;
192 
193  int start_x, start_y;
194  int end_x, end_y;
195 
196  double delta_x, delta_y;
197 
198  int auto_locating;
199 
200  int speech;
201 
202  int16 misc[10];
203 
204  int num_sprite_changes;
205  word sprite_change_frame[AA_MAX_CHANGES];
206  word sprite_change_target[AA_MAX_CHANGES];
207 };
208 
209 typedef SegmentBuf Segment;
210 typedef Segment *SegmentPtr;
211 
212 
213 #define zone_low spawn_frame[0]
214 #define zone_high spawn_frame[1]
215 
216 
217 struct ImageEditBuf {
218  int frame_id;
219  byte segment_id;
220 
221  byte series_id;
222  int sprite_id;
223  int x, y;
224  byte depth;
225  byte scale;
226 };
227 
228 typedef ImageEditBuf ImageEdit;
229 typedef ImageEdit *ImageEditPtr;
230 
231 struct ImageInter {
232  int16 flags;
233  byte segment_id;
234  byte series_id;
235  byte sprite_id;
236  // byte padding
237  int16 x;
238  byte y;
239  // byte padding
240 
241  static constexpr size_t SIZE = 2 + 1 + 1 + 1 + 1 + 2 + 1 + 1;
242  void load(Common::SeekableReadStream *src);
243 };
244 typedef ImageInter *ImageInterPtr;
245 
246 
247 struct MessageBuf {
248  char active;
249  char spacing;
250  char macintosh_font;
251  int x, y;
252  int xs, ys;
253  int status;
254  int main_color;
255  FontPtr font;
256  char *text;
257 };
258 
259 typedef MessageBuf Message;
260 typedef Message *MessagePtr;
261 
262 
263 
264 struct FrameEditBuf {
265  byte sound;
266  word ticks;
267  word timing;
268  word view_x;
269  word view_y;
270  int8 yank_x;
271  int8 yank_y;
272 };
273 
274 typedef FrameEditBuf FrameEdit;
275 typedef FrameEdit *FrameEditPtr;
276 
277 
278 struct Frame {
279  byte sound; /* what sound cue to play */
280  int8 speech; /* what speech record to activate */
281  word ticks; /* how many ticks for this frame (before? after?) */
282  word view_x; /* where the pan set currently */
283  word view_y;
284  int8 yank_x; /* for backgrounds which wrap around, like starfields */
285  int8 yank_y;
286 
287  static constexpr size_t SIZE = 1 + 1 + 2 + 2 + 2 + 1 + 1;
288  void load(Common::SeekableReadStream *src);
289 };
290 typedef Frame *FramePtr;
291 
292 
293 struct SegmentInter {
294  int16 probability;
295  int16 num_images;
296  int16 first_image;
297  int16 last_image;
298  int16 counter;
299  byte spawn[AA_MAX_SPAWNED];
300  int16 spawn_frame[AA_MAX_SPAWNED];
301  byte sound;
302  //byte padding;
303  int16 sound_frame;
304 
305  static constexpr size_t SIZE = 5 * 2 + AA_MAX_SPAWNED + AA_MAX_SPAWNED * 2 + 2 + 2;
306  void load(Common::SeekableReadStream *src);
307 };
309 
310 
311 struct Speech {
312  int16 resource_id; /* Speech segment id in resource file */
313  char text[60]; /* Text to be displayed */
314  byte misc[3]; /* 3 extra bonus bytes */
315  byte sound; /* Sound to be used */
316  int16 x, y; /* Text coordinates */
317  uint16 display_condition; /* Condition for display */
318  RGBcolor color[2]; /* Colors for text display */
319  word flags; /* Segment flags */
320  int16 speech_loops; /* Loops if speech active */
321  int16 non_speech_loops; /* Loops if speech inactive */
322  int16 segment_to_loop; /* Segment ID to be looped */
323  int16 first_frame; /* First frame of segment */
324  int16 last_frame; /* Last frame of segment */
325  int16 first_image; /* First image number */
326 
327  static constexpr size_t SIZE = 2 + 60 + 3 + 1 + 4 + 2 + 2 + 2 + 2 * RGBcolor::SIZE + 7 * 2;
328  void load(Common::SeekableReadStream *src);
329 };
330 
331 typedef Speech *SpeechPtr;
332 
333 /* daa file header */
334 
335 struct AnimDefBuf {
336  int num_series;
337  int num_segments;
338  int num_frames;
339  int num_images;
340  int num_speech;
341 
342  int timing_mode;
343 
344  int misc[10];
345 
346  word load_flags;
347  int font_auto_spacing;
348 
349  int background_type;
350  int background_xs;
351  int background_ys;
352  int background_room;
353  char background_name[80];
354 
355  char sound_file_name[80];
356 
357  char name[80];
358  char desc[80];
359 
360  char series_name[AA_MAX_SERIES][80];
361 
362  char background_depth[80];
363 
364  char speech_file[80];
365  char font_file[80];
366 };
367 
368 
369 typedef AnimDefBuf AnimDef;
370 typedef AnimDef *AnimDefPtr;
371 
372 /* aa file header */
373 
374 struct AnimFile {
375  uint16 num_series;
376  uint16 num_frames;
377  uint16 num_images;
378  uint16 num_speech;
379  word load_flags;
380  uint16 font_auto_spacing;
381  uint16 background_type; /* black, or room, or whatever */
382  uint16 background_room; /* room number to load */
383  int16 misc[10]; /* see MISC_ defines above */
384  char background_name[13]; /* if needed */
385  char series_name[AA_MAX_SERIES][13]; /* filenames for all your series */
386  char sound_file_name[13];
387  char background_depth[13];
388  char speech_file[13];
389  char font_file[13];
390 
391  static constexpr size_t SIZE = (8 * 2) + (10 * 2) + 13 +
392  (AA_MAX_SERIES * 13) + 13 + 13 + 13 + 13 +
393  1; // structure padding
394  void load(Common::SeekableReadStream *src);
395 };
396 
397 /* runtime memory image for an animation */
398 
399 struct Anim : public AnimFile {
400  FontPtr font;
401  SpeechPtr speech;
402 
403  ImagePtr image; /* to the array of images */
404  FramePtr frame; /* to the array of frames */
405  SeriesPtr series[AA_MAX_SERIES]; /* pointers to series */
406 
407  int series_id[AA_MAX_SERIES];
408 };
409 typedef Anim *AnimPtr;
410 
411 /* the interface version of the above */
412 
413 struct AnimInter : public AnimFile {
414  FontPtr font;
415  SpeechPtr speech;
416 
417  ImageInterPtr image;
418  SegmentInterPtr segment;
419  SeriesPtr series[AA_MAX_SERIES];
420 
421  int series_id[AA_MAX_SERIES];
422 };
423 typedef AnimInter *AnimInterPtr;
424 
425 
426 extern int anim_error;
427 
428 int anim_load_background(AnimFile *anim_in,
429  Buffer *this_orig,
430  Buffer *this_depth,
431  TileMapHeader *picture_map,
432  TileMapHeader *depth_map,
433  TileResource *picture_resource,
434  TileResource *depth_resource,
435  RoomPtr *roomPtr,
436  CycleListPtr cycle_list,
437  int load_flags, int star_search);
438 
439 
440 void anim_unload(AnimPtr anim);
441 
442 AnimPtr anim_load(const char *file_name,
443  Buffer *orig, Buffer *depth,
444  TileMapHeader *picture_map,
445  TileMapHeader *depth_map,
446  TileResource *picture_resource,
447  TileResource *depth_resource,
448  RoomPtr *roomPtr, CycleListPtr cycle_list,
449  int load_flags);
450 
451 int anim_get_sound_info(const char *file_name, char *sound_file_buffer,
452  int *sound_load_flag);
453 
454 int anim_get_header_info(char *file_name,
455  AnimFile *anim_in);
456 
457 
458 int anim_himem_preload(char *name, int level);
459 
460 extern void init_anim();
461 
462 } // namespace MADS
463 
464 #endif
Definition: font.h:33
Definition: general.h:42
Definition: anim.h:264
Definition: image.h:29
Definition: anim.h:162
Definition: general.h:57
Definition: anim.h:231
Definition: stream.h:745
Definition: anim.h:399
Definition: anim.h:413
Definition: tile.h:62
Definition: sprite.h:244
Definition: anim.h:293
Definition: anim.h:278
Definition: anim.h:335
Definition: room.h:210
Definition: anim_timer.h:27
Definition: anim.h:247
Definition: anim.h:311
Definition: anim.h:374
Definition: color.h:106
Definition: tile.h:41
Definition: anim.h:217