1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
12 #include "libgame/libgame.h"
21 // values for global toon animation definition
22 #define NUM_GLOBAL_TOON_ANIMS 1
23 #define NUM_GLOBAL_TOON_PARTS MAX_NUM_TOONS
25 // values for global animation definition (including toons)
26 #define NUM_GLOBAL_ANIMS_AND_TOONS (NUM_GLOBAL_ANIMS + \
27 NUM_GLOBAL_TOON_ANIMS)
28 #define NUM_GLOBAL_ANIM_PARTS_AND_TOONS MAX(NUM_GLOBAL_ANIM_PARTS_ALL, \
29 NUM_GLOBAL_TOON_PARTS)
31 #define ANIM_CLASS_BIT_TITLE_INITIAL 0
32 #define ANIM_CLASS_BIT_TITLE 1
33 #define ANIM_CLASS_BIT_MAIN 2
34 #define ANIM_CLASS_BIT_SCORES 3
35 #define ANIM_CLASS_BIT_SUBMENU 4
36 #define ANIM_CLASS_BIT_MENU 5
37 #define ANIM_CLASS_BIT_TOONS 6
38 #define ANIM_CLASS_BIT_NO_TITLE 7
40 #define NUM_ANIM_CLASSES 8
42 #define ANIM_CLASS_NONE 0
43 #define ANIM_CLASS_TITLE_INITIAL (1 << ANIM_CLASS_BIT_TITLE_INITIAL)
44 #define ANIM_CLASS_TITLE (1 << ANIM_CLASS_BIT_TITLE)
45 #define ANIM_CLASS_MAIN (1 << ANIM_CLASS_BIT_MAIN)
46 #define ANIM_CLASS_SCORES (1 << ANIM_CLASS_BIT_SCORES)
47 #define ANIM_CLASS_SUBMENU (1 << ANIM_CLASS_BIT_SUBMENU)
48 #define ANIM_CLASS_MENU (1 << ANIM_CLASS_BIT_MENU)
49 #define ANIM_CLASS_TOONS (1 << ANIM_CLASS_BIT_TOONS)
50 #define ANIM_CLASS_NO_TITLE (1 << ANIM_CLASS_BIT_NO_TITLE)
52 #define ANIM_CLASS_TOONS_SCORES (ANIM_CLASS_TOONS | \
56 #define ANIM_CLASS_TOONS_MENU_MAIN (ANIM_CLASS_TOONS | \
61 #define ANIM_CLASS_TOONS_MENU_SUBMENU (ANIM_CLASS_TOONS | \
63 ANIM_CLASS_SUBMENU | \
66 // values for global animation states
67 #define ANIM_STATE_INACTIVE 0
68 #define ANIM_STATE_RESTART (1 << 0)
69 #define ANIM_STATE_WAITING (1 << 1)
70 #define ANIM_STATE_RUNNING (1 << 2)
72 // values for global animation control
73 #define ANIM_NO_ACTION 0
75 #define ANIM_CONTINUE 2
79 struct GlobalAnimPartControlInfo
81 int old_nr; // position before mapping animation parts linearly
82 int old_anim_nr; // position before mapping animations linearly
88 boolean is_base; // animation part is base/main/default animation part
94 struct GraphicInfo graphic_info;
95 struct GraphicInfo control_info;
103 int step_xoffset, step_yoffset;
105 unsigned int initial_anim_sync_frame;
106 unsigned int step_delay, step_delay_value;
108 int init_delay_counter;
109 int anim_delay_counter;
110 int post_delay_counter;
112 boolean init_event_state;
113 boolean anim_event_state;
121 int last_anim_status;
124 struct GlobalAnimMainControlInfo
126 struct GlobalAnimPartControlInfo base;
127 struct GlobalAnimPartControlInfo part[NUM_GLOBAL_ANIM_PARTS_AND_TOONS];
132 struct GraphicInfo control_info;
134 int num_parts; // number of animation parts, but without base part
135 int num_parts_all; // number of animation parts, including base part
139 boolean has_base; // animation has base/main/default animation part
143 int init_delay_counter;
147 int last_state, last_active_part_nr;
150 struct GlobalAnimControlInfo
152 struct GlobalAnimMainControlInfo anim[NUM_GLOBAL_ANIMS_AND_TOONS];
158 struct GameModeAnimClass
162 } game_mode_anim_classes_list[] =
164 { GAME_MODE_TITLE_INITIAL_1, ANIM_CLASS_TITLE_INITIAL },
165 { GAME_MODE_TITLE_INITIAL_2, ANIM_CLASS_TITLE_INITIAL },
166 { GAME_MODE_TITLE_INITIAL_3, ANIM_CLASS_TITLE_INITIAL },
167 { GAME_MODE_TITLE_INITIAL_4, ANIM_CLASS_TITLE_INITIAL },
168 { GAME_MODE_TITLE_INITIAL_5, ANIM_CLASS_TITLE_INITIAL },
169 { GAME_MODE_TITLE_1, ANIM_CLASS_TITLE },
170 { GAME_MODE_TITLE_2, ANIM_CLASS_TITLE },
171 { GAME_MODE_TITLE_3, ANIM_CLASS_TITLE },
172 { GAME_MODE_TITLE_4, ANIM_CLASS_TITLE },
173 { GAME_MODE_TITLE_5, ANIM_CLASS_TITLE },
174 { GAME_MODE_LEVELS, ANIM_CLASS_TOONS_MENU_SUBMENU },
175 { GAME_MODE_LEVELNR, ANIM_CLASS_TOONS_MENU_SUBMENU },
176 { GAME_MODE_INFO, ANIM_CLASS_TOONS_MENU_SUBMENU },
177 { GAME_MODE_SETUP, ANIM_CLASS_TOONS_MENU_SUBMENU },
178 { GAME_MODE_PSEUDO_MAINONLY, ANIM_CLASS_TOONS_MENU_MAIN },
179 { GAME_MODE_PSEUDO_TYPENAME, ANIM_CLASS_TOONS_MENU_MAIN },
180 { GAME_MODE_PSEUDO_SCORESOLD, ANIM_CLASS_TOONS_SCORES },
181 { GAME_MODE_PSEUDO_SCORESNEW, ANIM_CLASS_TOONS_SCORES },
182 { GAME_MODE_EDITOR, ANIM_CLASS_NO_TITLE },
183 { GAME_MODE_PLAYING, ANIM_CLASS_NO_TITLE },
188 struct AnimClassGameMode
192 } anim_class_game_modes_list[] =
194 { ANIM_CLASS_BIT_TITLE_INITIAL, GAME_MODE_TITLE_INITIAL },
195 { ANIM_CLASS_BIT_TITLE, GAME_MODE_TITLE },
196 { ANIM_CLASS_BIT_MAIN, GAME_MODE_MAIN },
197 { ANIM_CLASS_BIT_SCORES, GAME_MODE_SCORES },
198 { ANIM_CLASS_BIT_SUBMENU, GAME_MODE_PSEUDO_SUBMENU },
199 { ANIM_CLASS_BIT_MENU, GAME_MODE_PSEUDO_MENU },
200 { ANIM_CLASS_BIT_TOONS, GAME_MODE_PSEUDO_TOONS },
201 { ANIM_CLASS_BIT_NO_TITLE, GAME_MODE_PSEUDO_NO_TITLE },
206 // forward declaration for internal use
207 static void HandleGlobalAnim(int, int);
208 static void DoAnimationExt(void);
209 static void ResetGlobalAnim_Clickable(void);
210 static void ResetGlobalAnim_Clicked(void);
212 static struct GlobalAnimControlInfo global_anim_ctrl[NUM_GAME_MODES];
214 static unsigned int anim_sync_frame = 0;
216 static int game_mode_anim_classes[NUM_GAME_MODES];
217 static int anim_class_game_modes[NUM_ANIM_CLASSES];
219 static int anim_status_last_before_fading = GAME_MODE_DEFAULT;
220 static int anim_status_last = GAME_MODE_DEFAULT;
221 static int anim_classes_last = ANIM_CLASS_NONE;
223 static boolean drawing_to_fading_buffer = FALSE;
226 // ============================================================================
227 // generic animation frame calculation
228 // ============================================================================
230 int getAnimationFrame(int num_frames, int delay, int mode, int start_frame,
235 sync_frame += start_frame * delay;
237 if (mode & ANIM_LOOP) // looping animation
239 frame = (sync_frame % (delay * num_frames)) / delay;
241 else if (mode & ANIM_LINEAR) // linear (non-looping) animation
243 frame = sync_frame / delay;
245 if (frame > num_frames - 1)
246 frame = num_frames - 1;
248 else if (mode & ANIM_PINGPONG) // oscillate (border frames once)
250 int max_anim_frames = (num_frames > 1 ? 2 * num_frames - 2 : 1);
252 frame = (sync_frame % (delay * max_anim_frames)) / delay;
253 frame = (frame < num_frames ? frame : max_anim_frames - frame);
255 else if (mode & ANIM_PINGPONG2) // oscillate (border frames twice)
257 int max_anim_frames = 2 * num_frames;
259 frame = (sync_frame % (delay * max_anim_frames)) / delay;
260 frame = (frame < num_frames ? frame : max_anim_frames - frame - 1);
262 else if (mode & ANIM_RANDOM) // play frames in random order
264 // note: expect different frames for the same delay cycle!
266 if (gfx.anim_random_frame < 0)
267 frame = GetSimpleRandom(num_frames);
269 frame = gfx.anim_random_frame % num_frames;
271 else if (mode & (ANIM_CE_VALUE | ANIM_CE_SCORE | ANIM_CE_DELAY))
273 frame = sync_frame % num_frames;
276 if (mode & ANIM_REVERSE) // use reverse animation direction
277 frame = num_frames - frame - 1;
283 // ============================================================================
284 // global animation functions
285 // ============================================================================
287 static int getGlobalAnimationPart(struct GlobalAnimMainControlInfo *anim)
289 struct GraphicInfo *c = &anim->control_info;
290 int last_anim_random_frame = gfx.anim_random_frame;
293 gfx.anim_random_frame = -1; // (use simple, ad-hoc random numbers)
295 part_nr = getAnimationFrame(anim->num_parts, 1,
296 c->anim_mode, c->anim_start_frame,
299 gfx.anim_random_frame = last_anim_random_frame;
304 static int compareGlobalAnimPartControlInfo(const void *obj1, const void *obj2)
306 const struct GlobalAnimPartControlInfo *o1 =
307 (struct GlobalAnimPartControlInfo *)obj1;
308 const struct GlobalAnimPartControlInfo *o2 =
309 (struct GlobalAnimPartControlInfo *)obj2;
312 if (o1->control_info.draw_order != o2->control_info.draw_order)
313 compare_result = o1->control_info.draw_order - o2->control_info.draw_order;
315 compare_result = o1->nr - o2->nr;
317 return compare_result;
320 static int compareGlobalAnimMainControlInfo(const void *obj1, const void *obj2)
322 const struct GlobalAnimMainControlInfo *o1 =
323 (struct GlobalAnimMainControlInfo *)obj1;
324 const struct GlobalAnimMainControlInfo *o2 =
325 (struct GlobalAnimMainControlInfo *)obj2;
328 if (o1->control_info.draw_order != o2->control_info.draw_order)
329 compare_result = o1->control_info.draw_order - o2->control_info.draw_order;
331 compare_result = o1->nr - o2->nr;
333 return compare_result;
336 static void InitToonControls(void)
338 int mode_nr_toons = GAME_MODE_PSEUDO_TOONS;
339 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr_toons];
340 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[ctrl->num_anims];
341 int mode_nr, anim_nr, part_nr;
342 int control = IMG_INTERNAL_GLOBAL_TOON_DEFAULT;
343 int num_toons = MAX_NUM_TOONS;
346 if (global.num_toons >= 0 && global.num_toons < MAX_NUM_TOONS)
347 num_toons = global.num_toons;
349 mode_nr = mode_nr_toons;
350 anim_nr = ctrl->num_anims;
353 anim->mode_nr = mode_nr;
354 anim->control_info = graphic_info[control];
357 anim->num_parts_all = 0;
358 anim->part_counter = 0;
359 anim->active_part_nr = 0;
361 anim->has_base = FALSE;
363 anim->last_x = POS_OFFSCREEN;
364 anim->last_y = POS_OFFSCREEN;
366 anim->init_delay_counter = 0;
368 anim->state = ANIM_STATE_INACTIVE;
372 for (i = 0; i < num_toons; i++)
374 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
375 int sound = SND_UNDEFINED;
376 int music = MUS_UNDEFINED;
377 int graphic = IMG_TOON_1 + i;
378 int control = graphic;
381 part->anim_nr = anim_nr;
382 part->mode_nr = mode_nr;
384 part->is_base = FALSE;
388 part->graphic = graphic;
390 part->graphic_info = graphic_info[graphic];
391 part->control_info = graphic_info[control];
393 part->graphic_info.anim_delay *= part->graphic_info.step_delay;
395 part->control_info.init_delay_fixed = 0;
396 part->control_info.init_delay_random = 150;
398 part->control_info.x = ARG_UNDEFINED_VALUE;
399 part->control_info.y = ARG_UNDEFINED_VALUE;
401 part->initial_anim_sync_frame = 0;
403 part->step_delay = 0;
404 part->step_delay_value = graphic_info[control].step_delay;
406 part->state = ANIM_STATE_INACTIVE;
407 part->last_anim_status = -1;
410 anim->num_parts_all++;
418 static void InitGlobalAnimControls(void)
421 int mode_nr, anim_nr, part_nr;
422 int sound, music, graphic, control;
426 for (m = 0; m < NUM_GAME_MODES; m++)
430 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr];
437 for (a = 0; a < NUM_GLOBAL_ANIMS; a++)
439 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[anim_nr];
440 int ctrl_id = GLOBAL_ANIM_ID_CONTROL_FIRST + a;
442 control = global_anim_info[ctrl_id].graphic[GLOBAL_ANIM_ID_PART_BASE][m];
444 // if no base animation parameters defined, use default values
445 if (control == IMG_UNDEFINED)
446 control = IMG_INTERNAL_GLOBAL_ANIM_DEFAULT;
449 anim->mode_nr = mode_nr;
450 anim->control_info = graphic_info[control];
453 anim->num_parts_all = 0;
454 anim->part_counter = 0;
455 anim->active_part_nr = 0;
457 anim->has_base = FALSE;
459 anim->last_x = POS_OFFSCREEN;
460 anim->last_y = POS_OFFSCREEN;
462 anim->init_delay_counter = 0;
464 anim->state = ANIM_STATE_INACTIVE;
468 for (p = 0; p < NUM_GLOBAL_ANIM_PARTS_ALL; p++)
470 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
472 sound = global_anim_info[a].sound[p][m];
473 music = global_anim_info[a].music[p][m];
474 graphic = global_anim_info[a].graphic[p][m];
475 control = global_anim_info[ctrl_id].graphic[p][m];
477 if (graphic == IMG_UNDEFINED || graphic_info[graphic].bitmap == NULL ||
478 control == IMG_UNDEFINED)
482 printf("::: mode == %d, anim = %d, part = %d [%d, %d, %d] [%d]\n",
483 m, a, p, mode_nr, anim_nr, part_nr, control);
487 printf("::: mode == %d, anim = %d, part = %d [%d, %d, %d] [%d]\n",
488 m, a, p, mode_nr, anim_nr, part_nr, sound);
492 part->old_anim_nr = a;
495 part->anim_nr = anim_nr;
496 part->mode_nr = mode_nr;
500 part->graphic = graphic;
502 part->graphic_info = graphic_info[graphic];
503 part->control_info = graphic_info[control];
505 part->initial_anim_sync_frame = 0;
507 part->step_delay = 0;
508 part->step_delay_value = graphic_info[control].step_delay;
510 part->state = ANIM_STATE_INACTIVE;
511 part->last_anim_status = -1;
513 anim->num_parts_all++;
515 if (p < GLOBAL_ANIM_ID_PART_BASE)
517 part->is_base = FALSE;
524 part->is_base = TRUE;
527 anim->has_base = TRUE;
531 if (anim->num_parts > 0 || anim->has_base)
541 // sort all animations according to draw_order and animation number
542 for (m = 0; m < NUM_GAME_MODES; m++)
544 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[m];
546 // sort all main animations for this game mode
547 qsort(ctrl->anim, ctrl->num_anims,
548 sizeof(struct GlobalAnimMainControlInfo),
549 compareGlobalAnimMainControlInfo);
551 for (a = 0; a < ctrl->num_anims; a++)
553 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[a];
555 // sort all animation parts for this main animation
556 qsort(anim->part, anim->num_parts,
557 sizeof(struct GlobalAnimPartControlInfo),
558 compareGlobalAnimPartControlInfo);
562 for (i = 0; i < NUM_GAME_MODES; i++)
563 game_mode_anim_classes[i] = ANIM_CLASS_NONE;
564 for (i = 0; game_mode_anim_classes_list[i].game_mode != -1; i++)
565 game_mode_anim_classes[game_mode_anim_classes_list[i].game_mode] =
566 game_mode_anim_classes_list[i].class;
568 for (i = 0; i < NUM_ANIM_CLASSES; i++)
569 anim_class_game_modes[i] = GAME_MODE_DEFAULT;
570 for (i = 0; anim_class_game_modes_list[i].game_mode != -1; i++)
571 anim_class_game_modes[anim_class_game_modes_list[i].class_bit] =
572 anim_class_game_modes_list[i].game_mode;
574 anim_status_last_before_fading = GAME_MODE_LOADING;
575 anim_status_last = GAME_MODE_LOADING;
576 anim_classes_last = ANIM_CLASS_NONE;
579 void InitGlobalAnimations(void)
581 InitGlobalAnimControls();
584 static void DrawGlobalAnimationsExt(int drawing_target, int drawing_stage)
586 Bitmap *fade_bitmap =
587 (drawing_target == DRAW_TO_FADE_SOURCE ? gfx.fade_bitmap_source :
588 drawing_target == DRAW_TO_FADE_TARGET ? gfx.fade_bitmap_target : NULL);
589 int game_mode_anim_action[NUM_GAME_MODES];
595 if (drawing_stage == DRAW_GLOBAL_ANIM_STAGE_1 &&
596 drawing_target == DRAW_TO_SCREEN)
599 // always start with reliable default values (no animation actions)
600 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
601 game_mode_anim_action[mode_nr] = ANIM_NO_ACTION;
603 if (global.anim_status != anim_status_last)
605 boolean before_fading = (global.anim_status == GAME_MODE_PSEUDO_FADING);
606 boolean after_fading = (anim_status_last == GAME_MODE_PSEUDO_FADING);
607 int anim_classes_next = game_mode_anim_classes[global.anim_status_next];
610 if (drawing_target == DRAW_TO_FADE_TARGET)
613 // special case: changing from/to this screen is done without fading
614 if (global.anim_status == GAME_MODE_PSEUDO_TYPENAME ||
615 anim_status_last == GAME_MODE_PSEUDO_TYPENAME)
618 // ---------- part 1 ------------------------------------------------------
619 // start or stop global animations by change of game mode
620 // (special handling of animations for "current screen" and "all screens")
622 if (global.anim_status_next != anim_status_last_before_fading)
624 // stop animations for last screen before fading to new screen
625 game_mode_anim_action[anim_status_last] = ANIM_STOP;
627 // start animations for current screen after fading to new screen
628 game_mode_anim_action[global.anim_status] = ANIM_START;
631 // start animations for all screens after loading new artwork set
632 if (anim_status_last == GAME_MODE_LOADING)
633 game_mode_anim_action[GAME_MODE_DEFAULT] = ANIM_START;
635 // ---------- part 2 ------------------------------------------------------
636 // start or stop global animations by change of animation class
637 // (generic handling of animations for "class of screens")
639 for (i = 0; i < NUM_ANIM_CLASSES; i++)
641 int anim_class_check = (1 << i);
642 int anim_class_game_mode = anim_class_game_modes[i];
643 int anim_class_last = anim_classes_last & anim_class_check;
644 int anim_class_next = anim_classes_next & anim_class_check;
646 // stop animations for changed screen class before fading to new screen
647 if (before_fading && anim_class_last && !anim_class_next)
648 game_mode_anim_action[anim_class_game_mode] = ANIM_STOP;
650 // start animations for changed screen class after fading to new screen
651 if (after_fading && !anim_class_last && anim_class_next)
652 game_mode_anim_action[anim_class_game_mode] = ANIM_START;
655 if (drawing_target == DRAW_TO_SCREEN)
659 anim_classes_last = anim_classes_next;
660 anim_status_last_before_fading = global.anim_status;
663 anim_status_last = global.anim_status;
665 // start or stop animations determined to be started or stopped above
666 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
667 if (game_mode_anim_action[mode_nr] != ANIM_NO_ACTION)
668 HandleGlobalAnim(game_mode_anim_action[mode_nr], mode_nr);
670 else if (drawing_target == DRAW_TO_FADE_TARGET)
672 drawing_to_fading_buffer = TRUE;
674 // start animations determined to be (temporary) started above
675 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
676 if (game_mode_anim_action[mode_nr] == ANIM_START)
677 HandleGlobalAnim(ANIM_START, mode_nr);
681 if (global.anim_status == GAME_MODE_LOADING)
684 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
686 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr];
689 // when preparing source fading buffer, only draw animations to be stopped
690 if (drawing_target == DRAW_TO_FADE_SOURCE &&
691 game_mode_anim_action[mode_nr] != ANIM_STOP)
694 // when preparing target fading buffer, only draw animations to be started
695 if (drawing_target == DRAW_TO_FADE_TARGET &&
696 game_mode_anim_action[mode_nr] != ANIM_START)
700 if (mode_nr != GFX_SPECIAL_ARG_DEFAULT &&
701 mode_nr != game_status)
705 for (anim_nr = 0; anim_nr < ctrl->num_anims; anim_nr++)
707 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[anim_nr];
708 struct GraphicInfo *c = &anim->control_info;
709 int part_first, part_last;
712 if (!(anim->state & ANIM_STATE_RUNNING))
715 part_first = part_last = anim->active_part_nr;
717 if (c->anim_mode & ANIM_ALL || anim->num_parts == 0)
719 int num_parts = anim->num_parts + (anim->has_base ? 1 : 0);
722 part_last = num_parts - 1;
725 for (part_nr = part_first; part_nr <= part_last; part_nr++)
727 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
728 struct GraphicInfo *g = &part->graphic_info;
731 int width = g->width;
732 int height = g->height;
739 void (*blit_bitmap)(Bitmap *, Bitmap *, int, int, int, int, int, int) =
740 (g->draw_masked ? BlitBitmapMasked : BlitBitmap);
741 void (*blit_screen)(Bitmap *, int, int, int, int, int, int) =
742 (g->draw_masked ? BlitToScreenMasked : BlitToScreen);
744 if (!(part->state & ANIM_STATE_RUNNING))
747 if (part->drawing_stage != drawing_stage)
756 else if (part->x > part->viewport_width - g->width)
757 width -= (part->x - (part->viewport_width - g->width));
765 else if (part->y > part->viewport_height - g->height)
766 height -= (part->y - (part->viewport_height - g->height));
768 if (width <= 0 || height <= 0)
771 dst_x += part->viewport_x;
772 dst_y += part->viewport_y;
774 sync_frame = anim_sync_frame - part->initial_anim_sync_frame;
775 frame = getAnimationFrame(g->anim_frames, g->anim_delay,
776 g->anim_mode, g->anim_start_frame,
779 getFixedGraphicSource(part->graphic, frame, &src_bitmap,
785 if (drawing_target == DRAW_TO_SCREEN)
786 blit_screen(src_bitmap, src_x, src_y, width, height,
789 blit_bitmap(src_bitmap, fade_bitmap, src_x, src_y, width, height,
795 if (drawing_target == DRAW_TO_FADE_TARGET)
797 // stop animations determined to be (temporary) started above
798 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
799 if (game_mode_anim_action[mode_nr] == ANIM_START)
800 HandleGlobalAnim(ANIM_STOP, mode_nr);
802 drawing_to_fading_buffer = FALSE;
806 void DrawGlobalAnimations(int drawing_target, int drawing_stage)
808 if (drawing_stage == DRAW_GLOBAL_ANIM_STAGE_1)
809 ResetGlobalAnim_Clickable();
811 DrawGlobalAnimationsExt(drawing_target, drawing_stage);
813 if (drawing_stage == DRAW_GLOBAL_ANIM_STAGE_2)
814 ResetGlobalAnim_Clicked();
817 static boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part)
823 boolean changed = FALSE;
825 if (part->last_anim_status == global.anim_status)
828 part->last_anim_status = global.anim_status;
830 part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_1;
832 if (part->control_info.class == get_hash_from_key("window") ||
833 part->control_info.class == get_hash_from_key("border"))
837 viewport_width = WIN_XSIZE;
838 viewport_height = WIN_YSIZE;
840 part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_2;
842 else if (part->control_info.class == get_hash_from_key("door_1"))
846 viewport_width = DXSIZE;
847 viewport_height = DYSIZE;
849 else if (part->control_info.class == get_hash_from_key("door_2"))
853 viewport_width = VXSIZE;
854 viewport_height = VYSIZE;
856 else // default: "playfield"
858 viewport_x = REAL_SX;
859 viewport_y = REAL_SY;
860 viewport_width = FULL_SXSIZE;
861 viewport_height = FULL_SYSIZE;
864 if (viewport_x != part->viewport_x ||
865 viewport_y != part->viewport_y ||
866 viewport_width != part->viewport_width ||
867 viewport_height != part->viewport_height)
869 part->viewport_x = viewport_x;
870 part->viewport_y = viewport_y;
871 part->viewport_width = viewport_width;
872 part->viewport_height = viewport_height;
880 static void PlayGlobalAnimSound(struct GlobalAnimPartControlInfo *part)
882 int sound = part->sound;
884 if (sound == SND_UNDEFINED)
887 if ((!setup.sound_simple && !IS_LOOP_SOUND(sound)) ||
888 (!setup.sound_loops && IS_LOOP_SOUND(sound)))
891 // !!! TODO: ADD STEREO POSITION FOR MOVING ANIMATIONS !!!
892 if (IS_LOOP_SOUND(sound))
893 PlaySoundLoop(sound);
898 printf("::: PLAY SOUND %d.%d.%d: %d\n",
899 part->anim_nr, part->nr, part->mode_nr, sound);
903 static void StopGlobalAnimSound(struct GlobalAnimPartControlInfo *part)
905 int sound = part->sound;
907 if (sound == SND_UNDEFINED)
913 printf("::: STOP SOUND %d.%d.%d: %d\n",
914 part->anim_nr, part->nr, part->mode_nr, sound);
918 static void PlayGlobalAnimMusic(struct GlobalAnimPartControlInfo *part)
920 int music = part->music;
922 if (music == MUS_UNDEFINED)
925 if (!setup.sound_music)
928 if (IS_LOOP_MUSIC(music))
929 PlayMusicLoop(music);
934 printf("::: PLAY MUSIC %d.%d.%d: %d\n",
935 part->anim_nr, part->nr, part->mode_nr, music);
939 static void StopGlobalAnimMusic(struct GlobalAnimPartControlInfo *part)
941 int music = part->music;
943 if (music == MUS_UNDEFINED)
949 printf("::: STOP MUSIC %d.%d.%d: %d\n",
950 part->anim_nr, part->nr, part->mode_nr, music);
954 static void PlayGlobalAnimSoundAndMusic(struct GlobalAnimPartControlInfo *part)
956 // when drawing animations to fading buffer, do not play sounds or music
957 if (drawing_to_fading_buffer)
960 PlayGlobalAnimSound(part);
961 PlayGlobalAnimMusic(part);
964 static void StopGlobalAnimSoundAndMusic(struct GlobalAnimPartControlInfo *part)
966 StopGlobalAnimSound(part);
967 StopGlobalAnimMusic(part);
970 static void PlayGlobalAnimSoundIfLoop(struct GlobalAnimPartControlInfo *part)
972 // when drawing animations to fading buffer, do not play sounds
973 if (drawing_to_fading_buffer)
976 // loop sounds only expire when playing
977 if (game_status != GAME_MODE_PLAYING)
980 // check if any sound is defined for this animation part
981 if (part->sound == SND_UNDEFINED)
984 // normal (non-loop) sounds do not expire when playing
985 if (!IS_LOOP_SOUND(part->sound))
988 // prevent expiring loop sounds when playing
989 PlayGlobalAnimSound(part);
992 static boolean isClickablePart(struct GlobalAnimPartControlInfo *part, int mask)
994 struct GraphicInfo *c = &part->control_info;
995 int trigger_mask = ANIM_EVENT_ANIM_MASK | ANIM_EVENT_PART_MASK;
996 int mask_anim_only = mask & ANIM_EVENT_ANIM_MASK;
998 if (mask & ANIM_EVENT_ANY)
999 return (c->init_event & ANIM_EVENT_ANY ||
1000 c->anim_event & ANIM_EVENT_ANY);
1001 else if (mask & ANIM_EVENT_SELF)
1002 return (c->init_event & ANIM_EVENT_SELF ||
1003 c->anim_event & ANIM_EVENT_SELF);
1005 return ((c->init_event & trigger_mask) == mask ||
1006 (c->anim_event & trigger_mask) == mask ||
1007 (c->init_event & trigger_mask) == mask_anim_only ||
1008 (c->anim_event & trigger_mask) == mask_anim_only);
1011 static boolean isClickedPart(struct GlobalAnimPartControlInfo *part,
1012 int mx, int my, boolean clicked)
1014 struct GraphicInfo *g = &part->graphic_info;
1015 int part_x = part->viewport_x + part->x;
1016 int part_y = part->viewport_y + part->y;
1017 int part_width = g->width;
1018 int part_height = g->height;
1020 // check if mouse click was detected at all
1024 // check if mouse click is inside the animation part's viewport
1025 if (mx < part->viewport_x ||
1026 mx >= part->viewport_x + part->viewport_width ||
1027 my < part->viewport_y ||
1028 my >= part->viewport_y + part->viewport_height)
1031 // check if mouse click is inside the animation part's graphic
1033 mx >= part_x + part_width ||
1035 my >= part_y + part_height)
1041 static boolean clickConsumed(struct GlobalAnimPartControlInfo *part)
1043 return (part->control_info.style & STYLE_PASSTHROUGH ? FALSE : TRUE);
1046 static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part,
1049 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[part->mode_nr];
1050 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[part->anim_nr];
1051 struct GraphicInfo *g = &part->graphic_info;
1052 struct GraphicInfo *c = &part->control_info;
1053 boolean viewport_changed = SetGlobalAnimPart_Viewport(part);
1055 if (viewport_changed)
1056 state |= ANIM_STATE_RESTART;
1058 if (state & ANIM_STATE_RESTART)
1060 // when drawing animations to fading buffer, only start fixed animations
1061 if (drawing_to_fading_buffer && (c->x == ARG_UNDEFINED_VALUE ||
1062 c->y == ARG_UNDEFINED_VALUE))
1063 return ANIM_STATE_INACTIVE;
1065 ResetDelayCounterExt(&part->step_delay, anim_sync_frame);
1067 part->init_delay_counter =
1068 (c->init_delay_fixed + GetSimpleRandom(c->init_delay_random));
1070 part->anim_delay_counter =
1071 (c->anim_delay_fixed + GetSimpleRandom(c->anim_delay_random));
1073 part->init_event_state = c->init_event;
1074 part->anim_event_state = c->anim_event;
1076 part->initial_anim_sync_frame =
1077 (g->anim_global_sync ? 0 : anim_sync_frame + part->init_delay_counter);
1079 if (c->direction & MV_HORIZONTAL)
1081 int pos_bottom = part->viewport_height - g->height;
1083 if (c->position == POS_TOP)
1085 else if (c->position == POS_UPPER)
1086 part->y = GetSimpleRandom(pos_bottom / 2);
1087 else if (c->position == POS_MIDDLE)
1088 part->y = pos_bottom / 2;
1089 else if (c->position == POS_LOWER)
1090 part->y = pos_bottom / 2 + GetSimpleRandom(pos_bottom / 2);
1091 else if (c->position == POS_BOTTOM)
1092 part->y = pos_bottom;
1094 part->y = GetSimpleRandom(pos_bottom);
1096 if (c->direction == MV_RIGHT)
1098 part->step_xoffset = c->step_offset;
1099 part->x = -g->width + part->step_xoffset;
1103 part->step_xoffset = -c->step_offset;
1104 part->x = part->viewport_width + part->step_xoffset;
1107 part->step_yoffset = 0;
1109 else if (c->direction & MV_VERTICAL)
1111 int pos_right = part->viewport_width - g->width;
1113 if (c->position == POS_LEFT)
1115 else if (c->position == POS_RIGHT)
1116 part->x = pos_right;
1118 part->x = GetSimpleRandom(pos_right);
1120 if (c->direction == MV_DOWN)
1122 part->step_yoffset = c->step_offset;
1123 part->y = -g->height + part->step_yoffset;
1127 part->step_yoffset = -c->step_offset;
1128 part->y = part->viewport_height + part->step_yoffset;
1131 part->step_xoffset = 0;
1138 part->step_xoffset = 0;
1139 part->step_yoffset = 0;
1142 if (c->x != ARG_UNDEFINED_VALUE)
1144 if (c->y != ARG_UNDEFINED_VALUE)
1147 if (c->position == POS_LAST &&
1148 anim->last_x > -g->width && anim->last_x < part->viewport_width &&
1149 anim->last_y > -g->height && anim->last_y < part->viewport_height)
1151 part->x = anim->last_x;
1152 part->y = anim->last_y;
1155 if (c->step_xoffset != ARG_UNDEFINED_VALUE)
1156 part->step_xoffset = c->step_xoffset;
1157 if (c->step_yoffset != ARG_UNDEFINED_VALUE)
1158 part->step_yoffset = c->step_yoffset;
1160 if (part->init_delay_counter == 0 &&
1161 part->init_event_state == ANIM_EVENT_NONE)
1162 PlayGlobalAnimSoundAndMusic(part);
1165 if (part->clicked &&
1166 part->init_event_state != ANIM_EVENT_NONE)
1168 if (part->initial_anim_sync_frame > 0)
1169 part->initial_anim_sync_frame -= part->init_delay_counter - 1;
1171 part->init_delay_counter = 1;
1172 part->init_event_state = ANIM_EVENT_NONE;
1174 part->clicked = FALSE;
1177 if (part->clicked &&
1178 part->anim_event_state != ANIM_EVENT_NONE)
1180 part->anim_delay_counter = 1;
1181 part->anim_event_state = ANIM_EVENT_NONE;
1183 part->clicked = FALSE;
1186 if (part->init_delay_counter > 0)
1188 part->init_delay_counter--;
1190 if (part->init_delay_counter == 0)
1192 part->init_event_state = ANIM_EVENT_NONE;
1194 PlayGlobalAnimSoundAndMusic(part);
1197 return ANIM_STATE_WAITING;
1200 if (part->init_event_state != ANIM_EVENT_NONE)
1201 return ANIM_STATE_WAITING;
1203 // animation part is now running/visible and therefore clickable
1204 part->clickable = TRUE;
1206 // check if moving animation has left the visible screen area
1207 if ((part->x <= -g->width && part->step_xoffset <= 0) ||
1208 (part->x >= part->viewport_width && part->step_xoffset >= 0) ||
1209 (part->y <= -g->height && part->step_yoffset <= 0) ||
1210 (part->y >= part->viewport_height && part->step_yoffset >= 0))
1212 // do not wait for "anim" events for off-screen animations
1213 part->anim_event_state = ANIM_EVENT_NONE;
1215 // do not stop animation before "anim" or "post" counter are finished
1216 if (part->anim_delay_counter == 0 &&
1217 part->post_delay_counter == 0)
1219 StopGlobalAnimSoundAndMusic(part);
1221 part->post_delay_counter =
1222 (c->post_delay_fixed + GetSimpleRandom(c->post_delay_random));
1224 if (part->post_delay_counter > 0)
1225 return ANIM_STATE_RUNNING;
1227 // drawing last frame not needed here -- animation not visible anymore
1228 return ANIM_STATE_RESTART;
1232 if (part->anim_delay_counter > 0)
1234 part->anim_delay_counter--;
1236 if (part->anim_delay_counter == 0)
1238 part->anim_event_state = ANIM_EVENT_NONE;
1240 StopGlobalAnimSoundAndMusic(part);
1242 part->post_delay_counter =
1243 (c->post_delay_fixed + GetSimpleRandom(c->post_delay_random));
1245 if (part->post_delay_counter > 0)
1246 return ANIM_STATE_RUNNING;
1248 // additional state "RUNNING" required to not skip drawing last frame
1249 return ANIM_STATE_RESTART | ANIM_STATE_RUNNING;
1253 if (part->post_delay_counter > 0)
1255 part->post_delay_counter--;
1257 if (part->post_delay_counter == 0)
1258 return ANIM_STATE_RESTART;
1260 return ANIM_STATE_WAITING;
1263 // special case to prevent expiring loop sounds when playing
1264 PlayGlobalAnimSoundIfLoop(part);
1266 if (!DelayReachedExt(&part->step_delay, part->step_delay_value,
1268 return ANIM_STATE_RUNNING;
1272 static unsigned int last_counter = -1;
1273 unsigned int counter = Counter();
1275 printf("::: NEXT ANIM PART [%d, %d]\n",
1276 anim_sync_frame, counter - last_counter);
1278 last_counter = counter;
1282 part->x += part->step_xoffset;
1283 part->y += part->step_yoffset;
1285 anim->last_x = part->x;
1286 anim->last_y = part->y;
1288 return ANIM_STATE_RUNNING;
1291 static void HandleGlobalAnim_Main(struct GlobalAnimMainControlInfo *anim,
1294 struct GlobalAnimPartControlInfo *part;
1295 struct GraphicInfo *c = &anim->control_info;
1296 int num_parts = anim->num_parts + (anim->has_base ? 1 : 0);
1297 int state, active_part_nr;
1301 printf("::: HandleGlobalAnim_Main: %d, %d => %d\n",
1302 anim->mode_nr, anim->nr, anim->num_parts);
1303 printf("::: %d, %d, %d\n", global.num_toons, setup.toons, num_toons);
1307 printf("::: %s(%d): %d, %d, %d [%d]\n",
1308 (action == ANIM_START ? "ANIM_START" :
1309 action == ANIM_CONTINUE ? "ANIM_CONTINUE" :
1310 action == ANIM_STOP ? "ANIM_STOP" : "(should not happen)"),
1312 anim->state & ANIM_STATE_RESTART,
1313 anim->state & ANIM_STATE_WAITING,
1314 anim->state & ANIM_STATE_RUNNING,
1321 anim->state = anim->last_state = ANIM_STATE_RESTART;
1322 anim->active_part_nr = anim->last_active_part_nr = 0;
1323 anim->part_counter = 0;
1328 if (anim->state == ANIM_STATE_INACTIVE)
1331 anim->state = anim->last_state;
1332 anim->active_part_nr = anim->last_active_part_nr;
1337 anim->state = ANIM_STATE_INACTIVE;
1339 for (i = 0; i < num_parts; i++)
1340 StopGlobalAnimSoundAndMusic(&anim->part[i]);
1348 if (c->anim_mode & ANIM_ALL || anim->num_parts == 0)
1351 printf("::: HandleGlobalAnim_Main: %d, %d => %d\n",
1352 anim->mode_nr, anim->nr, num_parts);
1355 for (i = 0; i < num_parts; i++)
1357 part = &anim->part[i];
1362 anim->state = ANIM_STATE_RUNNING;
1363 part->state = ANIM_STATE_RESTART;
1368 if (part->state == ANIM_STATE_INACTIVE)
1374 part->state = ANIM_STATE_INACTIVE;
1382 part->state = HandleGlobalAnim_Part(part, part->state);
1384 // when animation mode is "once", stop after animation was played once
1385 if (c->anim_mode & ANIM_ONCE &&
1386 part->state & ANIM_STATE_RESTART)
1387 part->state = ANIM_STATE_INACTIVE;
1390 anim->last_state = anim->state;
1391 anim->last_active_part_nr = anim->active_part_nr;
1396 if (anim->state & ANIM_STATE_RESTART) // directly after restart
1397 anim->active_part_nr = getGlobalAnimationPart(anim);
1399 part = &anim->part[anim->active_part_nr];
1401 // first set all animation parts to "inactive", ...
1402 for (i = 0; i < num_parts; i++)
1403 anim->part[i].state = ANIM_STATE_INACTIVE;
1405 // ... then set current animation parts to "running"
1406 part->state = ANIM_STATE_RUNNING;
1408 anim->state = HandleGlobalAnim_Part(part, anim->state);
1410 if (anim->state & ANIM_STATE_RESTART)
1411 anim->part_counter++;
1413 // when animation mode is "once", stop after all animations were played once
1414 if (c->anim_mode & ANIM_ONCE &&
1415 anim->part_counter == anim->num_parts)
1416 anim->state = ANIM_STATE_INACTIVE;
1418 state = anim->state;
1419 active_part_nr = anim->active_part_nr;
1421 // while the animation parts are pausing (waiting or inactive), play the base
1422 // (main) animation; this corresponds to the "boring player animation" logic
1423 // (!!! KLUDGE WARNING: I THINK THIS IS A MESS THAT SHOULD BE CLEANED UP !!!)
1426 if (anim->state == ANIM_STATE_WAITING ||
1427 anim->state == ANIM_STATE_INACTIVE)
1429 anim->active_part_nr = anim->num_parts; // part nr of base animation
1430 part = &anim->part[anim->active_part_nr];
1432 if (anim->state != anim->last_state)
1433 part->state = ANIM_STATE_RESTART;
1435 anim->state = ANIM_STATE_RUNNING;
1436 part->state = HandleGlobalAnim_Part(part, part->state);
1440 anim->last_state = state;
1441 anim->last_active_part_nr = active_part_nr;
1444 static void HandleGlobalAnim_Mode(struct GlobalAnimControlInfo *ctrl, int action)
1449 printf("::: HandleGlobalAnim_Mode: %d => %d\n",
1450 ctrl->nr, ctrl->num_anims);
1453 for (i = 0; i < ctrl->num_anims; i++)
1454 HandleGlobalAnim_Main(&ctrl->anim[i], action);
1457 static void HandleGlobalAnim(int action, int game_mode)
1460 printf("::: HandleGlobalAnim [mode == %d]\n", game_status);
1463 HandleGlobalAnim_Mode(&global_anim_ctrl[game_mode], action);
1466 static void DoAnimationExt(void)
1471 printf("::: DoAnimation [%d, %d]\n", anim_sync_frame, Counter());
1474 // global animations now synchronized with frame delay of screen update
1477 for (i = 0; i < NUM_GAME_MODES; i++)
1478 HandleGlobalAnim(ANIM_CONTINUE, i);
1481 // force screen redraw in next frame to continue drawing global animations
1482 redraw_mask = REDRAW_ALL;
1486 static boolean DoGlobalAnim_EventAction(struct GlobalAnimPartControlInfo *part)
1488 int anim_event_action = part->control_info.anim_event_action;
1490 if (anim_event_action == -1)
1493 boolean action_executed = (DoGadgetAction(anim_event_action) ||
1494 DoScreenAction(anim_event_action) ||
1495 DoKeysymAction(anim_event_action));
1497 // check if further actions are allowed to be executed
1498 if (part->control_info.style & STYLE_MULTIPLE_ACTIONS)
1501 return action_executed;
1504 static void InitGlobalAnim_Clickable(void)
1508 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
1510 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr];
1513 for (anim_nr = 0; anim_nr < ctrl->num_anims; anim_nr++)
1515 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[anim_nr];
1518 for (part_nr = 0; part_nr < anim->num_parts_all; part_nr++)
1520 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
1522 part->clickable = FALSE;
1528 static boolean InitGlobalAnim_Clicked(int mx, int my, boolean clicked)
1530 boolean anything_clicked = FALSE;
1531 boolean any_part_clicked = FALSE;
1532 boolean any_event_action = FALSE;
1535 // check game modes in reverse draw order (to stop when clicked)
1536 for (mode_nr = NUM_GAME_MODES - 1; mode_nr >= 0; mode_nr--)
1538 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr];
1541 // check animations in reverse draw order (to stop when clicked)
1542 for (anim_nr = ctrl->num_anims - 1; anim_nr >= 0; anim_nr--)
1544 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[anim_nr];
1547 // check animation parts in reverse draw order (to stop when clicked)
1548 for (part_nr = anim->num_parts_all - 1; part_nr >= 0; part_nr--)
1550 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
1554 part->clicked = FALSE;
1559 if (!part->clickable)
1562 if (part->state != ANIM_STATE_RUNNING)
1565 // always handle "any" click events (clicking anywhere on screen) ...
1566 if (isClickablePart(part, ANIM_EVENT_ANY))
1568 part->clicked = TRUE;
1569 anything_clicked = clickConsumed(part);
1572 // ... but only handle the first (topmost) clickable animation
1573 if (any_part_clicked)
1576 if (isClickedPart(part, mx, my, clicked))
1579 printf("::: %d.%d CLICKED [%d]\n", anim_nr, part_nr,
1580 part->control_info.anim_event_action);
1583 // after executing event action, ignore any further actions
1584 if (!any_event_action && DoGlobalAnim_EventAction(part))
1585 any_event_action = TRUE;
1587 // determine if mouse clicks should be blocked from other animations
1588 any_part_clicked = clickConsumed(part);
1590 if (isClickablePart(part, ANIM_EVENT_SELF))
1592 part->clicked = TRUE;
1593 anything_clicked = clickConsumed(part);
1596 // check if this click is defined to trigger other animations
1597 int gic_anim_nr = part->old_anim_nr + 1; // X as in "anim_X"
1598 int gic_part_nr = part->old_nr + 1; // Y as in "part_Y"
1599 int mask = gic_anim_nr << ANIM_EVENT_ANIM_BIT;
1602 mask |= gic_part_nr << ANIM_EVENT_PART_BIT;
1606 for (anim2_nr = 0; anim2_nr < ctrl->num_anims; anim2_nr++)
1608 struct GlobalAnimMainControlInfo *anim2 = &ctrl->anim[anim2_nr];
1611 for (part2_nr = 0; part2_nr < anim2->num_parts_all; part2_nr++)
1613 struct GlobalAnimPartControlInfo *part2 = &anim2->part[part2_nr];
1615 if (part2->state != ANIM_STATE_RUNNING)
1618 if (isClickablePart(part2, mask))
1620 part2->clicked = TRUE;
1621 anything_clicked = clickConsumed(part); // click was on "part"!
1624 printf("::: %d.%d TRIGGER CLICKED [%d]\n", anim2_nr, part2_nr,
1625 part2->control_info.anim_event_action);
1628 // after executing event action, ignore any further actions
1629 if (!any_event_action && DoGlobalAnim_EventAction(part2))
1630 any_event_action = TRUE;
1634 struct GraphicInfo *c = &part2->control_info;
1636 printf("::: - %d.%d: 0x%08x, 0x%08x [0x%08x]",
1637 anim2_nr, part2_nr, c->init_event, c->anim_event, mask);
1639 if (isClickablePart(part2, mask))
1640 printf(" <--- TRIGGERED BY %d.%d",
1652 return (anything_clicked || any_event_action);
1655 static void ResetGlobalAnim_Clickable(void)
1657 InitGlobalAnim_Clickable();
1660 static void ResetGlobalAnim_Clicked(void)
1662 InitGlobalAnim_Clicked(-1, -1, FALSE);
1665 boolean HandleGlobalAnimClicks(int mx, int my, int button)
1667 static boolean click_consumed = FALSE;
1668 static int last_button = 0;
1669 boolean press_event;
1670 boolean release_event;
1671 boolean click_consumed_current = click_consumed;
1673 // check if button state has changed since last invocation
1674 press_event = (button != 0 && last_button == 0);
1675 release_event = (button == 0 && last_button != 0);
1676 last_button = button;
1680 click_consumed = InitGlobalAnim_Clicked(mx, my, TRUE);
1681 click_consumed_current = click_consumed;
1685 click_consumed = FALSE;
1687 return click_consumed_current;