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"
22 // values for global toon animation definition
23 #define NUM_GLOBAL_TOON_ANIMS 1
24 #define NUM_GLOBAL_TOON_PARTS MAX_NUM_TOONS
26 // values for global animation definition (including toons)
27 #define NUM_GLOBAL_ANIMS_AND_TOONS (NUM_GLOBAL_ANIMS + \
28 NUM_GLOBAL_TOON_ANIMS)
29 #define NUM_GLOBAL_ANIM_PARTS_AND_TOONS MAX(NUM_GLOBAL_ANIM_PARTS_ALL, \
30 NUM_GLOBAL_TOON_PARTS)
32 #define ANIM_CLASS_BIT_TITLE_INITIAL 0
33 #define ANIM_CLASS_BIT_TITLE 1
34 #define ANIM_CLASS_BIT_MAIN 2
35 #define ANIM_CLASS_BIT_SCORES 3
36 #define ANIM_CLASS_BIT_SUBMENU 4
37 #define ANIM_CLASS_BIT_MENU 5
38 #define ANIM_CLASS_BIT_TOONS 6
39 #define ANIM_CLASS_BIT_NO_TITLE 7
41 #define NUM_ANIM_CLASSES 8
43 #define ANIM_CLASS_NONE 0
44 #define ANIM_CLASS_TITLE_INITIAL (1 << ANIM_CLASS_BIT_TITLE_INITIAL)
45 #define ANIM_CLASS_TITLE (1 << ANIM_CLASS_BIT_TITLE)
46 #define ANIM_CLASS_MAIN (1 << ANIM_CLASS_BIT_MAIN)
47 #define ANIM_CLASS_SCORES (1 << ANIM_CLASS_BIT_SCORES)
48 #define ANIM_CLASS_SUBMENU (1 << ANIM_CLASS_BIT_SUBMENU)
49 #define ANIM_CLASS_MENU (1 << ANIM_CLASS_BIT_MENU)
50 #define ANIM_CLASS_TOONS (1 << ANIM_CLASS_BIT_TOONS)
51 #define ANIM_CLASS_NO_TITLE (1 << ANIM_CLASS_BIT_NO_TITLE)
53 #define ANIM_CLASS_TOONS_SCORES (ANIM_CLASS_TOONS | \
57 #define ANIM_CLASS_TOONS_MENU_MAIN (ANIM_CLASS_TOONS | \
62 #define ANIM_CLASS_TOONS_MENU_SUBMENU (ANIM_CLASS_TOONS | \
64 ANIM_CLASS_SUBMENU | \
67 // values for global animation states
68 #define ANIM_STATE_INACTIVE 0
69 #define ANIM_STATE_RESTART (1 << 0)
70 #define ANIM_STATE_WAITING (1 << 1)
71 #define ANIM_STATE_RUNNING (1 << 2)
73 // values for global animation control
74 #define ANIM_NO_ACTION 0
76 #define ANIM_CONTINUE 2
80 struct GlobalAnimPartControlInfo
82 int old_nr; // position before mapping animation parts linearly
83 int old_anim_nr; // position before mapping animations linearly
89 boolean is_base; // animation part is base/main/default animation part
95 struct GraphicInfo graphic_info;
96 struct GraphicInfo control_info;
104 int step_xoffset, step_yoffset;
106 unsigned int initial_anim_sync_frame;
107 unsigned int step_delay, step_delay_value;
109 int init_delay_counter;
110 int anim_delay_counter;
111 int post_delay_counter;
113 boolean init_event_state;
114 boolean anim_event_state;
122 int last_anim_status;
125 struct GlobalAnimMainControlInfo
127 struct GlobalAnimPartControlInfo base;
128 struct GlobalAnimPartControlInfo part[NUM_GLOBAL_ANIM_PARTS_AND_TOONS];
133 struct GraphicInfo control_info;
135 int num_parts; // number of animation parts, but without base part
136 int num_parts_all; // number of animation parts, including base part
140 boolean has_base; // animation has base/main/default animation part
144 int init_delay_counter;
148 int last_state, last_active_part_nr;
151 struct GlobalAnimControlInfo
153 struct GlobalAnimMainControlInfo anim[NUM_GLOBAL_ANIMS_AND_TOONS];
159 struct GameModeAnimClass
163 } game_mode_anim_classes_list[] =
165 { GAME_MODE_TITLE_INITIAL_1, ANIM_CLASS_TITLE_INITIAL },
166 { GAME_MODE_TITLE_INITIAL_2, ANIM_CLASS_TITLE_INITIAL },
167 { GAME_MODE_TITLE_INITIAL_3, ANIM_CLASS_TITLE_INITIAL },
168 { GAME_MODE_TITLE_INITIAL_4, ANIM_CLASS_TITLE_INITIAL },
169 { GAME_MODE_TITLE_INITIAL_5, ANIM_CLASS_TITLE_INITIAL },
170 { GAME_MODE_TITLE_1, ANIM_CLASS_TITLE },
171 { GAME_MODE_TITLE_2, ANIM_CLASS_TITLE },
172 { GAME_MODE_TITLE_3, ANIM_CLASS_TITLE },
173 { GAME_MODE_TITLE_4, ANIM_CLASS_TITLE },
174 { GAME_MODE_TITLE_5, ANIM_CLASS_TITLE },
175 { GAME_MODE_LEVELS, ANIM_CLASS_TOONS_MENU_SUBMENU },
176 { GAME_MODE_LEVELNR, ANIM_CLASS_TOONS_MENU_SUBMENU },
177 { GAME_MODE_INFO, ANIM_CLASS_TOONS_MENU_SUBMENU },
178 { GAME_MODE_SETUP, ANIM_CLASS_TOONS_MENU_SUBMENU },
179 { GAME_MODE_PSEUDO_MAINONLY, ANIM_CLASS_TOONS_MENU_MAIN },
180 { GAME_MODE_PSEUDO_TYPENAME, ANIM_CLASS_TOONS_MENU_MAIN },
181 { GAME_MODE_PSEUDO_SCORESOLD, ANIM_CLASS_TOONS_SCORES },
182 { GAME_MODE_PSEUDO_SCORESNEW, ANIM_CLASS_TOONS_SCORES },
183 { GAME_MODE_EDITOR, ANIM_CLASS_NO_TITLE },
184 { GAME_MODE_PLAYING, ANIM_CLASS_NO_TITLE },
189 struct AnimClassGameMode
193 } anim_class_game_modes_list[] =
195 { ANIM_CLASS_BIT_TITLE_INITIAL, GAME_MODE_TITLE_INITIAL },
196 { ANIM_CLASS_BIT_TITLE, GAME_MODE_TITLE },
197 { ANIM_CLASS_BIT_MAIN, GAME_MODE_MAIN },
198 { ANIM_CLASS_BIT_SCORES, GAME_MODE_SCORES },
199 { ANIM_CLASS_BIT_SUBMENU, GAME_MODE_PSEUDO_SUBMENU },
200 { ANIM_CLASS_BIT_MENU, GAME_MODE_PSEUDO_MENU },
201 { ANIM_CLASS_BIT_TOONS, GAME_MODE_PSEUDO_TOONS },
202 { ANIM_CLASS_BIT_NO_TITLE, GAME_MODE_PSEUDO_NO_TITLE },
207 // forward declaration for internal use
208 static void HandleGlobalAnim(int, int);
209 static void DoAnimationExt(void);
210 static void ResetGlobalAnim_Clickable(void);
211 static void ResetGlobalAnim_Clicked(void);
213 static struct GlobalAnimControlInfo global_anim_ctrl[NUM_GAME_MODES];
215 static unsigned int anim_sync_frame = 0;
217 static int game_mode_anim_classes[NUM_GAME_MODES];
218 static int anim_class_game_modes[NUM_ANIM_CLASSES];
220 static int anim_status_last_before_fading = GAME_MODE_DEFAULT;
221 static int anim_status_last = GAME_MODE_DEFAULT;
222 static int anim_classes_last = ANIM_CLASS_NONE;
224 static boolean drawing_to_fading_buffer = FALSE;
227 // ============================================================================
228 // generic animation frame calculation
229 // ============================================================================
231 int getAnimationFrame(int num_frames, int delay, int mode, int start_frame,
236 sync_frame += start_frame * delay;
238 if (mode & ANIM_LOOP) // looping animation
240 frame = (sync_frame % (delay * num_frames)) / delay;
242 else if (mode & ANIM_LINEAR) // linear (non-looping) animation
244 frame = sync_frame / delay;
246 if (frame > num_frames - 1)
247 frame = num_frames - 1;
249 else if (mode & ANIM_PINGPONG) // oscillate (border frames once)
251 int max_anim_frames = (num_frames > 1 ? 2 * num_frames - 2 : 1);
253 frame = (sync_frame % (delay * max_anim_frames)) / delay;
254 frame = (frame < num_frames ? frame : max_anim_frames - frame);
256 else if (mode & ANIM_PINGPONG2) // oscillate (border frames twice)
258 int max_anim_frames = 2 * num_frames;
260 frame = (sync_frame % (delay * max_anim_frames)) / delay;
261 frame = (frame < num_frames ? frame : max_anim_frames - frame - 1);
263 else if (mode & ANIM_RANDOM) // play frames in random order
265 // note: expect different frames for the same delay cycle!
267 if (gfx.anim_random_frame < 0)
268 frame = GetSimpleRandom(num_frames);
270 frame = gfx.anim_random_frame % num_frames;
272 else if (mode & (ANIM_CE_VALUE | ANIM_CE_SCORE | ANIM_CE_DELAY))
274 frame = sync_frame % num_frames;
277 if (mode & ANIM_REVERSE) // use reverse animation direction
278 frame = num_frames - frame - 1;
284 // ============================================================================
285 // global animation functions
286 // ============================================================================
288 static int getGlobalAnimationPart(struct GlobalAnimMainControlInfo *anim)
290 struct GraphicInfo *c = &anim->control_info;
291 int last_anim_random_frame = gfx.anim_random_frame;
294 gfx.anim_random_frame = -1; // (use simple, ad-hoc random numbers)
296 part_nr = getAnimationFrame(anim->num_parts, 1,
297 c->anim_mode, c->anim_start_frame,
300 gfx.anim_random_frame = last_anim_random_frame;
305 static int compareGlobalAnimPartControlInfo(const void *obj1, const void *obj2)
307 const struct GlobalAnimPartControlInfo *o1 =
308 (struct GlobalAnimPartControlInfo *)obj1;
309 const struct GlobalAnimPartControlInfo *o2 =
310 (struct GlobalAnimPartControlInfo *)obj2;
313 if (o1->control_info.draw_order != o2->control_info.draw_order)
314 compare_result = o1->control_info.draw_order - o2->control_info.draw_order;
316 compare_result = o1->nr - o2->nr;
318 return compare_result;
321 static int compareGlobalAnimMainControlInfo(const void *obj1, const void *obj2)
323 const struct GlobalAnimMainControlInfo *o1 =
324 (struct GlobalAnimMainControlInfo *)obj1;
325 const struct GlobalAnimMainControlInfo *o2 =
326 (struct GlobalAnimMainControlInfo *)obj2;
329 if (o1->control_info.draw_order != o2->control_info.draw_order)
330 compare_result = o1->control_info.draw_order - o2->control_info.draw_order;
332 compare_result = o1->nr - o2->nr;
334 return compare_result;
337 static void InitToonControls(void)
339 int mode_nr_toons = GAME_MODE_PSEUDO_TOONS;
340 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr_toons];
341 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[ctrl->num_anims];
342 int mode_nr, anim_nr, part_nr;
343 int control = IMG_INTERNAL_GLOBAL_TOON_DEFAULT;
344 int num_toons = MAX_NUM_TOONS;
347 if (global.num_toons >= 0 && global.num_toons < MAX_NUM_TOONS)
348 num_toons = global.num_toons;
350 mode_nr = mode_nr_toons;
351 anim_nr = ctrl->num_anims;
354 anim->mode_nr = mode_nr;
355 anim->control_info = graphic_info[control];
358 anim->num_parts_all = 0;
359 anim->part_counter = 0;
360 anim->active_part_nr = 0;
362 anim->has_base = FALSE;
364 anim->last_x = POS_OFFSCREEN;
365 anim->last_y = POS_OFFSCREEN;
367 anim->init_delay_counter = 0;
369 anim->state = ANIM_STATE_INACTIVE;
373 for (i = 0; i < num_toons; i++)
375 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
376 int sound = SND_UNDEFINED;
377 int music = MUS_UNDEFINED;
378 int graphic = IMG_TOON_1 + i;
379 int control = graphic;
382 part->anim_nr = anim_nr;
383 part->mode_nr = mode_nr;
385 part->is_base = FALSE;
389 part->graphic = graphic;
391 part->graphic_info = graphic_info[graphic];
392 part->control_info = graphic_info[control];
394 part->graphic_info.anim_delay *= part->graphic_info.step_delay;
396 part->control_info.init_delay_fixed = 0;
397 part->control_info.init_delay_random = 150;
399 part->control_info.x = ARG_UNDEFINED_VALUE;
400 part->control_info.y = ARG_UNDEFINED_VALUE;
402 part->initial_anim_sync_frame = 0;
404 part->step_delay = 0;
405 part->step_delay_value = graphic_info[control].step_delay;
407 part->state = ANIM_STATE_INACTIVE;
408 part->last_anim_status = -1;
411 anim->num_parts_all++;
419 static void InitGlobalAnimControls(void)
422 int mode_nr, anim_nr, part_nr;
423 int sound, music, graphic, control;
427 for (m = 0; m < NUM_GAME_MODES; m++)
431 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr];
438 for (a = 0; a < NUM_GLOBAL_ANIMS; a++)
440 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[anim_nr];
441 int ctrl_id = GLOBAL_ANIM_ID_CONTROL_FIRST + a;
443 control = global_anim_info[ctrl_id].graphic[GLOBAL_ANIM_ID_PART_BASE][m];
445 // if no base animation parameters defined, use default values
446 if (control == IMG_UNDEFINED)
447 control = IMG_INTERNAL_GLOBAL_ANIM_DEFAULT;
450 anim->mode_nr = mode_nr;
451 anim->control_info = graphic_info[control];
454 anim->num_parts_all = 0;
455 anim->part_counter = 0;
456 anim->active_part_nr = 0;
458 anim->has_base = FALSE;
460 anim->last_x = POS_OFFSCREEN;
461 anim->last_y = POS_OFFSCREEN;
463 anim->init_delay_counter = 0;
465 anim->state = ANIM_STATE_INACTIVE;
469 for (p = 0; p < NUM_GLOBAL_ANIM_PARTS_ALL; p++)
471 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
473 sound = global_anim_info[a].sound[p][m];
474 music = global_anim_info[a].music[p][m];
475 graphic = global_anim_info[a].graphic[p][m];
476 control = global_anim_info[ctrl_id].graphic[p][m];
478 if (graphic == IMG_UNDEFINED || graphic_info[graphic].bitmap == NULL ||
479 control == IMG_UNDEFINED)
483 printf("::: mode == %d, anim = %d, part = %d [%d, %d, %d] [%d]\n",
484 m, a, p, mode_nr, anim_nr, part_nr, control);
488 printf("::: mode == %d, anim = %d, part = %d [%d, %d, %d] [%d]\n",
489 m, a, p, mode_nr, anim_nr, part_nr, sound);
493 part->old_anim_nr = a;
496 part->anim_nr = anim_nr;
497 part->mode_nr = mode_nr;
501 part->graphic = graphic;
503 part->graphic_info = graphic_info[graphic];
504 part->control_info = graphic_info[control];
506 part->initial_anim_sync_frame = 0;
508 part->step_delay = 0;
509 part->step_delay_value = graphic_info[control].step_delay;
511 part->state = ANIM_STATE_INACTIVE;
512 part->last_anim_status = -1;
514 anim->num_parts_all++;
516 if (p < GLOBAL_ANIM_ID_PART_BASE)
518 part->is_base = FALSE;
525 part->is_base = TRUE;
528 anim->has_base = TRUE;
532 if (anim->num_parts > 0 || anim->has_base)
542 // sort all animations according to draw_order and animation number
543 for (m = 0; m < NUM_GAME_MODES; m++)
545 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[m];
547 // sort all main animations for this game mode
548 qsort(ctrl->anim, ctrl->num_anims,
549 sizeof(struct GlobalAnimMainControlInfo),
550 compareGlobalAnimMainControlInfo);
552 for (a = 0; a < ctrl->num_anims; a++)
554 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[a];
556 // sort all animation parts for this main animation
557 qsort(anim->part, anim->num_parts,
558 sizeof(struct GlobalAnimPartControlInfo),
559 compareGlobalAnimPartControlInfo);
563 for (i = 0; i < NUM_GAME_MODES; i++)
564 game_mode_anim_classes[i] = ANIM_CLASS_NONE;
565 for (i = 0; game_mode_anim_classes_list[i].game_mode != -1; i++)
566 game_mode_anim_classes[game_mode_anim_classes_list[i].game_mode] =
567 game_mode_anim_classes_list[i].class;
569 for (i = 0; i < NUM_ANIM_CLASSES; i++)
570 anim_class_game_modes[i] = GAME_MODE_DEFAULT;
571 for (i = 0; anim_class_game_modes_list[i].game_mode != -1; i++)
572 anim_class_game_modes[anim_class_game_modes_list[i].class_bit] =
573 anim_class_game_modes_list[i].game_mode;
575 anim_status_last_before_fading = GAME_MODE_LOADING;
576 anim_status_last = GAME_MODE_LOADING;
577 anim_classes_last = ANIM_CLASS_NONE;
580 void InitGlobalAnimations(void)
582 InitGlobalAnimControls();
585 static void DrawGlobalAnimationsExt(int drawing_target, int drawing_stage)
587 Bitmap *fade_bitmap =
588 (drawing_target == DRAW_TO_FADE_SOURCE ? gfx.fade_bitmap_source :
589 drawing_target == DRAW_TO_FADE_TARGET ? gfx.fade_bitmap_target : NULL);
590 int game_mode_anim_action[NUM_GAME_MODES];
596 if (drawing_stage == DRAW_GLOBAL_ANIM_STAGE_1 &&
597 drawing_target == DRAW_TO_SCREEN)
600 // always start with reliable default values (no animation actions)
601 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
602 game_mode_anim_action[mode_nr] = ANIM_NO_ACTION;
604 if (global.anim_status != anim_status_last)
606 boolean before_fading = (global.anim_status == GAME_MODE_PSEUDO_FADING);
607 boolean after_fading = (anim_status_last == GAME_MODE_PSEUDO_FADING);
608 int anim_classes_next = game_mode_anim_classes[global.anim_status_next];
611 if (drawing_target == DRAW_TO_FADE_TARGET)
614 // special case: changing from/to this screen is done without fading
615 if (global.anim_status == GAME_MODE_PSEUDO_TYPENAME ||
616 anim_status_last == GAME_MODE_PSEUDO_TYPENAME)
619 // ---------- part 1 ------------------------------------------------------
620 // start or stop global animations by change of game mode
621 // (special handling of animations for "current screen" and "all screens")
623 if (global.anim_status_next != anim_status_last_before_fading)
625 // stop animations for last screen before fading to new screen
626 game_mode_anim_action[anim_status_last] = ANIM_STOP;
628 // start animations for current screen after fading to new screen
629 game_mode_anim_action[global.anim_status] = ANIM_START;
632 // start animations for all screens after loading new artwork set
633 if (anim_status_last == GAME_MODE_LOADING)
634 game_mode_anim_action[GAME_MODE_DEFAULT] = ANIM_START;
636 // ---------- part 2 ------------------------------------------------------
637 // start or stop global animations by change of animation class
638 // (generic handling of animations for "class of screens")
640 for (i = 0; i < NUM_ANIM_CLASSES; i++)
642 int anim_class_check = (1 << i);
643 int anim_class_game_mode = anim_class_game_modes[i];
644 int anim_class_last = anim_classes_last & anim_class_check;
645 int anim_class_next = anim_classes_next & anim_class_check;
647 // stop animations for changed screen class before fading to new screen
648 if (before_fading && anim_class_last && !anim_class_next)
649 game_mode_anim_action[anim_class_game_mode] = ANIM_STOP;
651 // start animations for changed screen class after fading to new screen
652 if (after_fading && !anim_class_last && anim_class_next)
653 game_mode_anim_action[anim_class_game_mode] = ANIM_START;
656 if (drawing_target == DRAW_TO_SCREEN)
660 anim_classes_last = anim_classes_next;
661 anim_status_last_before_fading = global.anim_status;
664 anim_status_last = global.anim_status;
666 // start or stop animations determined to be started or stopped above
667 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
668 if (game_mode_anim_action[mode_nr] != ANIM_NO_ACTION)
669 HandleGlobalAnim(game_mode_anim_action[mode_nr], mode_nr);
671 else if (drawing_target == DRAW_TO_FADE_TARGET)
673 drawing_to_fading_buffer = TRUE;
675 // start animations determined to be (temporary) started above
676 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
677 if (game_mode_anim_action[mode_nr] == ANIM_START)
678 HandleGlobalAnim(ANIM_START, mode_nr);
682 if (global.anim_status == GAME_MODE_LOADING)
685 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
687 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr];
690 // when preparing source fading buffer, only draw animations to be stopped
691 if (drawing_target == DRAW_TO_FADE_SOURCE &&
692 game_mode_anim_action[mode_nr] != ANIM_STOP)
695 // when preparing target fading buffer, only draw animations to be started
696 if (drawing_target == DRAW_TO_FADE_TARGET &&
697 game_mode_anim_action[mode_nr] != ANIM_START)
701 if (mode_nr != GFX_SPECIAL_ARG_DEFAULT &&
702 mode_nr != game_status)
706 for (anim_nr = 0; anim_nr < ctrl->num_anims; anim_nr++)
708 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[anim_nr];
709 struct GraphicInfo *c = &anim->control_info;
710 int part_first, part_last;
713 if (!(anim->state & ANIM_STATE_RUNNING))
716 part_first = part_last = anim->active_part_nr;
718 if (c->anim_mode & ANIM_ALL || anim->num_parts == 0)
720 int num_parts = anim->num_parts + (anim->has_base ? 1 : 0);
723 part_last = num_parts - 1;
726 for (part_nr = part_first; part_nr <= part_last; part_nr++)
728 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
729 struct GraphicInfo *g = &part->graphic_info;
732 int width = g->width;
733 int height = g->height;
740 void (*blit_bitmap)(Bitmap *, Bitmap *, int, int, int, int, int, int) =
741 (g->draw_masked ? BlitBitmapMasked : BlitBitmap);
742 void (*blit_screen)(Bitmap *, int, int, int, int, int, int) =
743 (g->draw_masked ? BlitToScreenMasked : BlitToScreen);
745 if (!(part->state & ANIM_STATE_RUNNING))
748 if (part->drawing_stage != drawing_stage)
757 else if (part->x > part->viewport_width - g->width)
758 width -= (part->x - (part->viewport_width - g->width));
766 else if (part->y > part->viewport_height - g->height)
767 height -= (part->y - (part->viewport_height - g->height));
769 if (width <= 0 || height <= 0)
772 dst_x += part->viewport_x;
773 dst_y += part->viewport_y;
775 sync_frame = anim_sync_frame - part->initial_anim_sync_frame;
776 frame = getAnimationFrame(g->anim_frames, g->anim_delay,
777 g->anim_mode, g->anim_start_frame,
780 getFixedGraphicSource(part->graphic, frame, &src_bitmap,
786 if (drawing_target == DRAW_TO_SCREEN)
787 blit_screen(src_bitmap, src_x, src_y, width, height,
790 blit_bitmap(src_bitmap, fade_bitmap, src_x, src_y, width, height,
796 if (drawing_target == DRAW_TO_FADE_TARGET)
798 // stop animations determined to be (temporary) started above
799 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
800 if (game_mode_anim_action[mode_nr] == ANIM_START)
801 HandleGlobalAnim(ANIM_STOP, mode_nr);
803 drawing_to_fading_buffer = FALSE;
807 void DrawGlobalAnimations(int drawing_target, int drawing_stage)
809 if (drawing_stage == DRAW_GLOBAL_ANIM_STAGE_1)
810 ResetGlobalAnim_Clickable();
812 DrawGlobalAnimationsExt(drawing_target, drawing_stage);
814 if (drawing_stage == DRAW_GLOBAL_ANIM_STAGE_2)
815 ResetGlobalAnim_Clicked();
818 static boolean SetGlobalAnimPart_Viewport(struct GlobalAnimPartControlInfo *part)
824 boolean changed = FALSE;
826 if (part->last_anim_status == global.anim_status)
829 part->last_anim_status = global.anim_status;
831 part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_1;
833 if (part->control_info.class == get_hash_from_key("window") ||
834 part->control_info.class == get_hash_from_key("border"))
838 viewport_width = WIN_XSIZE;
839 viewport_height = WIN_YSIZE;
841 part->drawing_stage = DRAW_GLOBAL_ANIM_STAGE_2;
843 else if (part->control_info.class == get_hash_from_key("door_1"))
847 viewport_width = DXSIZE;
848 viewport_height = DYSIZE;
850 else if (part->control_info.class == get_hash_from_key("door_2"))
854 viewport_width = VXSIZE;
855 viewport_height = VYSIZE;
857 else // default: "playfield"
859 viewport_x = REAL_SX;
860 viewport_y = REAL_SY;
861 viewport_width = FULL_SXSIZE;
862 viewport_height = FULL_SYSIZE;
865 if (viewport_x != part->viewport_x ||
866 viewport_y != part->viewport_y ||
867 viewport_width != part->viewport_width ||
868 viewport_height != part->viewport_height)
870 part->viewport_x = viewport_x;
871 part->viewport_y = viewport_y;
872 part->viewport_width = viewport_width;
873 part->viewport_height = viewport_height;
881 static void PlayGlobalAnimSound(struct GlobalAnimPartControlInfo *part)
883 int sound = part->sound;
885 if (sound == SND_UNDEFINED)
888 if ((!setup.sound_simple && !IS_LOOP_SOUND(sound)) ||
889 (!setup.sound_loops && IS_LOOP_SOUND(sound)))
892 // !!! TODO: ADD STEREO POSITION FOR MOVING ANIMATIONS !!!
893 if (IS_LOOP_SOUND(sound))
894 PlaySoundLoop(sound);
899 printf("::: PLAY SOUND %d.%d.%d: %d\n",
900 part->anim_nr, part->nr, part->mode_nr, sound);
904 static void StopGlobalAnimSound(struct GlobalAnimPartControlInfo *part)
906 int sound = part->sound;
908 if (sound == SND_UNDEFINED)
914 printf("::: STOP SOUND %d.%d.%d: %d\n",
915 part->anim_nr, part->nr, part->mode_nr, sound);
919 static void PlayGlobalAnimMusic(struct GlobalAnimPartControlInfo *part)
921 int music = part->music;
923 if (music == MUS_UNDEFINED)
926 if (!setup.sound_music)
929 if (IS_LOOP_MUSIC(music))
930 PlayMusicLoop(music);
935 printf("::: PLAY MUSIC %d.%d.%d: %d\n",
936 part->anim_nr, part->nr, part->mode_nr, music);
940 static void StopGlobalAnimMusic(struct GlobalAnimPartControlInfo *part)
942 int music = part->music;
944 if (music == MUS_UNDEFINED)
950 printf("::: STOP MUSIC %d.%d.%d: %d\n",
951 part->anim_nr, part->nr, part->mode_nr, music);
955 static void PlayGlobalAnimSoundAndMusic(struct GlobalAnimPartControlInfo *part)
957 // when drawing animations to fading buffer, do not play sounds or music
958 if (drawing_to_fading_buffer)
961 PlayGlobalAnimSound(part);
962 PlayGlobalAnimMusic(part);
965 static void StopGlobalAnimSoundAndMusic(struct GlobalAnimPartControlInfo *part)
967 StopGlobalAnimSound(part);
968 StopGlobalAnimMusic(part);
971 static void PlayGlobalAnimSoundIfLoop(struct GlobalAnimPartControlInfo *part)
973 // when drawing animations to fading buffer, do not play sounds
974 if (drawing_to_fading_buffer)
977 // loop sounds only expire when playing
978 if (game_status != GAME_MODE_PLAYING)
981 // check if any sound is defined for this animation part
982 if (part->sound == SND_UNDEFINED)
985 // normal (non-loop) sounds do not expire when playing
986 if (!IS_LOOP_SOUND(part->sound))
989 // prevent expiring loop sounds when playing
990 PlayGlobalAnimSound(part);
993 static boolean isClickablePart(struct GlobalAnimPartControlInfo *part, int mask)
995 struct GraphicInfo *c = &part->control_info;
996 int trigger_mask = ANIM_EVENT_ANIM_MASK | ANIM_EVENT_PART_MASK;
997 int mask_anim_only = mask & ANIM_EVENT_ANIM_MASK;
998 int init_event = GetGlobalAnimEventValue(c->init_event, 0);
999 int anim_event = GetGlobalAnimEventValue(c->anim_event, 0);
1001 if (mask & ANIM_EVENT_ANY)
1002 return (init_event & ANIM_EVENT_ANY ||
1003 anim_event & ANIM_EVENT_ANY);
1004 else if (mask & ANIM_EVENT_SELF)
1005 return (init_event & ANIM_EVENT_SELF ||
1006 anim_event & ANIM_EVENT_SELF);
1008 return ((init_event & trigger_mask) == mask ||
1009 (anim_event & trigger_mask) == mask ||
1010 (init_event & trigger_mask) == mask_anim_only ||
1011 (anim_event & trigger_mask) == mask_anim_only);
1014 static boolean isClickedPart(struct GlobalAnimPartControlInfo *part,
1015 int mx, int my, boolean clicked)
1017 struct GraphicInfo *g = &part->graphic_info;
1018 int part_x = part->viewport_x + part->x;
1019 int part_y = part->viewport_y + part->y;
1020 int part_width = g->width;
1021 int part_height = g->height;
1023 // check if mouse click was detected at all
1027 // check if mouse click is inside the animation part's viewport
1028 if (mx < part->viewport_x ||
1029 mx >= part->viewport_x + part->viewport_width ||
1030 my < part->viewport_y ||
1031 my >= part->viewport_y + part->viewport_height)
1034 // check if mouse click is inside the animation part's graphic
1036 mx >= part_x + part_width ||
1038 my >= part_y + part_height)
1044 static boolean clickConsumed(struct GlobalAnimPartControlInfo *part)
1046 return (part->control_info.style & STYLE_PASSTHROUGH ? FALSE : TRUE);
1049 static int HandleGlobalAnim_Part(struct GlobalAnimPartControlInfo *part,
1052 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[part->mode_nr];
1053 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[part->anim_nr];
1054 struct GraphicInfo *g = &part->graphic_info;
1055 struct GraphicInfo *c = &part->control_info;
1056 boolean viewport_changed = SetGlobalAnimPart_Viewport(part);
1058 if (viewport_changed)
1059 state |= ANIM_STATE_RESTART;
1061 if (state & ANIM_STATE_RESTART)
1063 // when drawing animations to fading buffer, only start fixed animations
1064 if (drawing_to_fading_buffer && (c->x == ARG_UNDEFINED_VALUE ||
1065 c->y == ARG_UNDEFINED_VALUE))
1066 return ANIM_STATE_INACTIVE;
1068 ResetDelayCounterExt(&part->step_delay, anim_sync_frame);
1070 part->init_delay_counter =
1071 (c->init_delay_fixed + GetSimpleRandom(c->init_delay_random));
1073 part->anim_delay_counter =
1074 (c->anim_delay_fixed + GetSimpleRandom(c->anim_delay_random));
1076 part->init_event_state = (c->init_event != ANIM_EVENT_UNDEFINED);
1077 part->anim_event_state = (c->anim_event != ANIM_EVENT_UNDEFINED);
1079 part->initial_anim_sync_frame =
1080 (g->anim_global_sync ? 0 : anim_sync_frame + part->init_delay_counter);
1082 if (c->direction & MV_HORIZONTAL)
1084 int pos_bottom = part->viewport_height - g->height;
1086 if (c->position == POS_TOP)
1088 else if (c->position == POS_UPPER)
1089 part->y = GetSimpleRandom(pos_bottom / 2);
1090 else if (c->position == POS_MIDDLE)
1091 part->y = pos_bottom / 2;
1092 else if (c->position == POS_LOWER)
1093 part->y = pos_bottom / 2 + GetSimpleRandom(pos_bottom / 2);
1094 else if (c->position == POS_BOTTOM)
1095 part->y = pos_bottom;
1097 part->y = GetSimpleRandom(pos_bottom);
1099 if (c->direction == MV_RIGHT)
1101 part->step_xoffset = c->step_offset;
1102 part->x = -g->width + part->step_xoffset;
1106 part->step_xoffset = -c->step_offset;
1107 part->x = part->viewport_width + part->step_xoffset;
1110 part->step_yoffset = 0;
1112 else if (c->direction & MV_VERTICAL)
1114 int pos_right = part->viewport_width - g->width;
1116 if (c->position == POS_LEFT)
1118 else if (c->position == POS_RIGHT)
1119 part->x = pos_right;
1121 part->x = GetSimpleRandom(pos_right);
1123 if (c->direction == MV_DOWN)
1125 part->step_yoffset = c->step_offset;
1126 part->y = -g->height + part->step_yoffset;
1130 part->step_yoffset = -c->step_offset;
1131 part->y = part->viewport_height + part->step_yoffset;
1134 part->step_xoffset = 0;
1141 part->step_xoffset = 0;
1142 part->step_yoffset = 0;
1145 if (c->x != ARG_UNDEFINED_VALUE)
1147 if (c->y != ARG_UNDEFINED_VALUE)
1150 if (c->position == POS_LAST &&
1151 anim->last_x > -g->width && anim->last_x < part->viewport_width &&
1152 anim->last_y > -g->height && anim->last_y < part->viewport_height)
1154 part->x = anim->last_x;
1155 part->y = anim->last_y;
1158 if (c->step_xoffset != ARG_UNDEFINED_VALUE)
1159 part->step_xoffset = c->step_xoffset;
1160 if (c->step_yoffset != ARG_UNDEFINED_VALUE)
1161 part->step_yoffset = c->step_yoffset;
1163 if (part->init_delay_counter == 0 &&
1164 !part->init_event_state)
1165 PlayGlobalAnimSoundAndMusic(part);
1168 if (part->clicked &&
1169 part->init_event_state)
1171 if (part->initial_anim_sync_frame > 0)
1172 part->initial_anim_sync_frame -= part->init_delay_counter - 1;
1174 part->init_delay_counter = 1;
1175 part->init_event_state = FALSE;
1177 part->clicked = FALSE;
1180 if (part->clicked &&
1181 part->anim_event_state)
1183 part->anim_delay_counter = 1;
1184 part->anim_event_state = FALSE;
1186 part->clicked = FALSE;
1189 if (part->init_delay_counter > 0)
1191 part->init_delay_counter--;
1193 if (part->init_delay_counter == 0)
1195 part->init_event_state = FALSE;
1197 PlayGlobalAnimSoundAndMusic(part);
1200 return ANIM_STATE_WAITING;
1203 if (part->init_event_state)
1204 return ANIM_STATE_WAITING;
1206 // animation part is now running/visible and therefore clickable
1207 part->clickable = TRUE;
1209 // check if moving animation has left the visible screen area
1210 if ((part->x <= -g->width && part->step_xoffset <= 0) ||
1211 (part->x >= part->viewport_width && part->step_xoffset >= 0) ||
1212 (part->y <= -g->height && part->step_yoffset <= 0) ||
1213 (part->y >= part->viewport_height && part->step_yoffset >= 0))
1215 // do not wait for "anim" events for off-screen animations
1216 part->anim_event_state = FALSE;
1218 // do not stop animation before "anim" or "post" counter are finished
1219 if (part->anim_delay_counter == 0 &&
1220 part->post_delay_counter == 0)
1222 StopGlobalAnimSoundAndMusic(part);
1224 part->post_delay_counter =
1225 (c->post_delay_fixed + GetSimpleRandom(c->post_delay_random));
1227 if (part->post_delay_counter > 0)
1228 return ANIM_STATE_RUNNING;
1230 // drawing last frame not needed here -- animation not visible anymore
1231 return ANIM_STATE_RESTART;
1235 if (part->anim_delay_counter > 0)
1237 part->anim_delay_counter--;
1239 if (part->anim_delay_counter == 0)
1241 part->anim_event_state = FALSE;
1243 StopGlobalAnimSoundAndMusic(part);
1245 part->post_delay_counter =
1246 (c->post_delay_fixed + GetSimpleRandom(c->post_delay_random));
1248 if (part->post_delay_counter > 0)
1249 return ANIM_STATE_RUNNING;
1251 // additional state "RUNNING" required to not skip drawing last frame
1252 return ANIM_STATE_RESTART | ANIM_STATE_RUNNING;
1256 if (part->post_delay_counter > 0)
1258 part->post_delay_counter--;
1260 if (part->post_delay_counter == 0)
1261 return ANIM_STATE_RESTART;
1263 return ANIM_STATE_WAITING;
1266 // special case to prevent expiring loop sounds when playing
1267 PlayGlobalAnimSoundIfLoop(part);
1269 if (!DelayReachedExt(&part->step_delay, part->step_delay_value,
1271 return ANIM_STATE_RUNNING;
1275 static unsigned int last_counter = -1;
1276 unsigned int counter = Counter();
1278 printf("::: NEXT ANIM PART [%d, %d]\n",
1279 anim_sync_frame, counter - last_counter);
1281 last_counter = counter;
1285 part->x += part->step_xoffset;
1286 part->y += part->step_yoffset;
1288 anim->last_x = part->x;
1289 anim->last_y = part->y;
1291 return ANIM_STATE_RUNNING;
1294 static void HandleGlobalAnim_Main(struct GlobalAnimMainControlInfo *anim,
1297 struct GlobalAnimPartControlInfo *part;
1298 struct GraphicInfo *c = &anim->control_info;
1299 int num_parts = anim->num_parts + (anim->has_base ? 1 : 0);
1300 int state, active_part_nr;
1304 printf("::: HandleGlobalAnim_Main: %d, %d => %d\n",
1305 anim->mode_nr, anim->nr, anim->num_parts);
1306 printf("::: %d, %d, %d\n", global.num_toons, setup.toons, num_toons);
1310 printf("::: %s(%d): %d, %d, %d [%d]\n",
1311 (action == ANIM_START ? "ANIM_START" :
1312 action == ANIM_CONTINUE ? "ANIM_CONTINUE" :
1313 action == ANIM_STOP ? "ANIM_STOP" : "(should not happen)"),
1315 anim->state & ANIM_STATE_RESTART,
1316 anim->state & ANIM_STATE_WAITING,
1317 anim->state & ANIM_STATE_RUNNING,
1324 anim->state = anim->last_state = ANIM_STATE_RESTART;
1325 anim->active_part_nr = anim->last_active_part_nr = 0;
1326 anim->part_counter = 0;
1331 if (anim->state == ANIM_STATE_INACTIVE)
1334 anim->state = anim->last_state;
1335 anim->active_part_nr = anim->last_active_part_nr;
1340 anim->state = ANIM_STATE_INACTIVE;
1342 for (i = 0; i < num_parts; i++)
1343 StopGlobalAnimSoundAndMusic(&anim->part[i]);
1351 if (c->anim_mode & ANIM_ALL || anim->num_parts == 0)
1354 printf("::: HandleGlobalAnim_Main: %d, %d => %d\n",
1355 anim->mode_nr, anim->nr, num_parts);
1358 for (i = 0; i < num_parts; i++)
1360 part = &anim->part[i];
1365 anim->state = ANIM_STATE_RUNNING;
1366 part->state = ANIM_STATE_RESTART;
1371 if (part->state == ANIM_STATE_INACTIVE)
1377 part->state = ANIM_STATE_INACTIVE;
1385 part->state = HandleGlobalAnim_Part(part, part->state);
1387 // when animation mode is "once", stop after animation was played once
1388 if (c->anim_mode & ANIM_ONCE &&
1389 part->state & ANIM_STATE_RESTART)
1390 part->state = ANIM_STATE_INACTIVE;
1393 anim->last_state = anim->state;
1394 anim->last_active_part_nr = anim->active_part_nr;
1399 if (anim->state & ANIM_STATE_RESTART) // directly after restart
1400 anim->active_part_nr = getGlobalAnimationPart(anim);
1402 part = &anim->part[anim->active_part_nr];
1404 // first set all animation parts to "inactive", ...
1405 for (i = 0; i < num_parts; i++)
1406 anim->part[i].state = ANIM_STATE_INACTIVE;
1408 // ... then set current animation parts to "running"
1409 part->state = ANIM_STATE_RUNNING;
1411 anim->state = HandleGlobalAnim_Part(part, anim->state);
1413 if (anim->state & ANIM_STATE_RESTART)
1414 anim->part_counter++;
1416 // when animation mode is "once", stop after all animations were played once
1417 if (c->anim_mode & ANIM_ONCE &&
1418 anim->part_counter == anim->num_parts)
1419 anim->state = ANIM_STATE_INACTIVE;
1421 state = anim->state;
1422 active_part_nr = anim->active_part_nr;
1424 // while the animation parts are pausing (waiting or inactive), play the base
1425 // (main) animation; this corresponds to the "boring player animation" logic
1426 // (!!! KLUDGE WARNING: I THINK THIS IS A MESS THAT SHOULD BE CLEANED UP !!!)
1429 if (anim->state == ANIM_STATE_WAITING ||
1430 anim->state == ANIM_STATE_INACTIVE)
1432 anim->active_part_nr = anim->num_parts; // part nr of base animation
1433 part = &anim->part[anim->active_part_nr];
1435 if (anim->state != anim->last_state)
1436 part->state = ANIM_STATE_RESTART;
1438 anim->state = ANIM_STATE_RUNNING;
1439 part->state = HandleGlobalAnim_Part(part, part->state);
1443 anim->last_state = state;
1444 anim->last_active_part_nr = active_part_nr;
1447 static void HandleGlobalAnim_Mode(struct GlobalAnimControlInfo *ctrl, int action)
1452 printf("::: HandleGlobalAnim_Mode: %d => %d\n",
1453 ctrl->nr, ctrl->num_anims);
1456 for (i = 0; i < ctrl->num_anims; i++)
1457 HandleGlobalAnim_Main(&ctrl->anim[i], action);
1460 static void HandleGlobalAnim(int action, int game_mode)
1463 printf("::: HandleGlobalAnim [mode == %d]\n", game_status);
1466 HandleGlobalAnim_Mode(&global_anim_ctrl[game_mode], action);
1469 static void DoAnimationExt(void)
1474 printf("::: DoAnimation [%d, %d]\n", anim_sync_frame, Counter());
1477 // global animations now synchronized with frame delay of screen update
1480 for (i = 0; i < NUM_GAME_MODES; i++)
1481 HandleGlobalAnim(ANIM_CONTINUE, i);
1484 // force screen redraw in next frame to continue drawing global animations
1485 redraw_mask = REDRAW_ALL;
1489 static boolean DoGlobalAnim_EventAction(struct GlobalAnimPartControlInfo *part)
1491 int anim_event_action = part->control_info.anim_event_action;
1493 if (anim_event_action == -1)
1496 boolean action_executed = (DoGadgetAction(anim_event_action) ||
1497 DoScreenAction(anim_event_action) ||
1498 DoKeysymAction(anim_event_action));
1500 // check if further actions are allowed to be executed
1501 if (part->control_info.style & STYLE_MULTIPLE_ACTIONS)
1504 return action_executed;
1507 static void InitGlobalAnim_Clickable(void)
1511 for (mode_nr = 0; mode_nr < NUM_GAME_MODES; mode_nr++)
1513 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr];
1516 for (anim_nr = 0; anim_nr < ctrl->num_anims; anim_nr++)
1518 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[anim_nr];
1521 for (part_nr = 0; part_nr < anim->num_parts_all; part_nr++)
1523 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
1525 part->clickable = FALSE;
1531 static boolean InitGlobalAnim_Clicked(int mx, int my, boolean clicked)
1533 boolean anything_clicked = FALSE;
1534 boolean any_part_clicked = FALSE;
1535 boolean any_event_action = FALSE;
1538 // check game modes in reverse draw order (to stop when clicked)
1539 for (mode_nr = NUM_GAME_MODES - 1; mode_nr >= 0; mode_nr--)
1541 struct GlobalAnimControlInfo *ctrl = &global_anim_ctrl[mode_nr];
1544 // check animations in reverse draw order (to stop when clicked)
1545 for (anim_nr = ctrl->num_anims - 1; anim_nr >= 0; anim_nr--)
1547 struct GlobalAnimMainControlInfo *anim = &ctrl->anim[anim_nr];
1550 // check animation parts in reverse draw order (to stop when clicked)
1551 for (part_nr = anim->num_parts_all - 1; part_nr >= 0; part_nr--)
1553 struct GlobalAnimPartControlInfo *part = &anim->part[part_nr];
1557 part->clicked = FALSE;
1562 if (!part->clickable)
1565 if (part->state != ANIM_STATE_RUNNING)
1568 // always handle "any" click events (clicking anywhere on screen) ...
1569 if (isClickablePart(part, ANIM_EVENT_ANY))
1571 part->clicked = TRUE;
1572 anything_clicked = clickConsumed(part);
1575 // ... but only handle the first (topmost) clickable animation
1576 if (any_part_clicked)
1579 if (isClickedPart(part, mx, my, clicked))
1582 printf("::: %d.%d CLICKED [%d]\n", anim_nr, part_nr,
1583 part->control_info.anim_event_action);
1586 // after executing event action, ignore any further actions
1587 if (!any_event_action && DoGlobalAnim_EventAction(part))
1588 any_event_action = TRUE;
1590 // determine if mouse clicks should be blocked from other animations
1591 any_part_clicked = clickConsumed(part);
1593 if (isClickablePart(part, ANIM_EVENT_SELF))
1595 part->clicked = TRUE;
1596 anything_clicked = clickConsumed(part);
1599 // check if this click is defined to trigger other animations
1600 int gic_anim_nr = part->old_anim_nr + 1; // X as in "anim_X"
1601 int gic_part_nr = part->old_nr + 1; // Y as in "part_Y"
1602 int mask = gic_anim_nr << ANIM_EVENT_ANIM_BIT;
1605 mask |= gic_part_nr << ANIM_EVENT_PART_BIT;
1609 for (anim2_nr = 0; anim2_nr < ctrl->num_anims; anim2_nr++)
1611 struct GlobalAnimMainControlInfo *anim2 = &ctrl->anim[anim2_nr];
1614 for (part2_nr = 0; part2_nr < anim2->num_parts_all; part2_nr++)
1616 struct GlobalAnimPartControlInfo *part2 = &anim2->part[part2_nr];
1618 if (part2->state != ANIM_STATE_RUNNING)
1621 if (isClickablePart(part2, mask))
1623 part2->clicked = TRUE;
1624 anything_clicked = clickConsumed(part); // click was on "part"!
1627 printf("::: %d.%d TRIGGER CLICKED [%d]\n", anim2_nr, part2_nr,
1628 part2->control_info.anim_event_action);
1631 // after executing event action, ignore any further actions
1632 if (!any_event_action && DoGlobalAnim_EventAction(part2))
1633 any_event_action = TRUE;
1637 struct GraphicInfo *c = &part2->control_info;
1639 printf("::: - %d.%d: 0x%08x, 0x%08x [0x%08x]",
1640 anim2_nr, part2_nr, c->init_event, c->anim_event, mask);
1642 if (isClickablePart(part2, mask))
1643 printf(" <--- TRIGGERED BY %d.%d",
1655 return (anything_clicked || any_event_action);
1658 static void ResetGlobalAnim_Clickable(void)
1660 InitGlobalAnim_Clickable();
1663 static void ResetGlobalAnim_Clicked(void)
1665 InitGlobalAnim_Clicked(-1, -1, FALSE);
1668 boolean HandleGlobalAnimClicks(int mx, int my, int button)
1670 static boolean click_consumed = FALSE;
1671 static int last_button = 0;
1672 boolean press_event;
1673 boolean release_event;
1674 boolean click_consumed_current = click_consumed;
1676 // check if button state has changed since last invocation
1677 press_event = (button != 0 && last_button == 0);
1678 release_event = (button == 0 && last_button != 0);
1679 last_button = button;
1683 click_consumed = InitGlobalAnim_Clicked(mx, my, TRUE);
1684 click_consumed_current = click_consumed;
1688 click_consumed = FALSE;
1690 return click_consumed_current;