+ int nr;
+ int anim_nr;
+ int mode_nr;
+
+ int graphic;
+ struct GraphicInfo graphic_info;
+ struct GraphicInfo control_info;
+
+ int viewport_x;
+ int viewport_y;
+ int viewport_width;
+ int viewport_height;
+
+ int x, y;
+ int step_xoffset, step_yoffset;
+
+ unsigned int initial_anim_sync_frame;
+ unsigned int step_delay, step_delay_value;
+
+ int init_delay_counter;
+ int anim_delay_counter;
+ int post_delay_counter;
+
+ int drawing_stage;
+
+ int state;
+ int last_anim_status;
+};
+
+struct GlobalAnimMainControlInfo
+{
+ struct GlobalAnimPartControlInfo base;
+ struct GlobalAnimPartControlInfo part[NUM_GLOBAL_ANIM_PARTS_AND_TOONS];
+
+ int nr;
+ int mode_nr;
+
+ struct GraphicInfo control_info;
+
+ int num_parts;
+ int part_counter;
+ int active_part_nr;
+
+ boolean has_base;
+
+ int init_delay_counter;
+
+ int state;
+};
+
+struct GlobalAnimControlInfo
+{
+ struct GlobalAnimMainControlInfo anim[NUM_GLOBAL_ANIMS_AND_TOONS];
+
+ int nr;
+ int num_anims;
+};
+
+struct GameModeAnimClass
+{
+ int game_mode;
+ int class;
+} game_mode_anim_classes_list[] =
+{
+ { GAME_MODE_LEVELS, ANIM_CLASS_TOONS | ANIM_CLASS_MENU | ANIM_CLASS_SUBMENU },
+ { GAME_MODE_LEVELNR,ANIM_CLASS_TOONS | ANIM_CLASS_MENU | ANIM_CLASS_SUBMENU },
+ { GAME_MODE_INFO, ANIM_CLASS_TOONS | ANIM_CLASS_MENU | ANIM_CLASS_SUBMENU },
+ { GAME_MODE_SETUP, ANIM_CLASS_TOONS | ANIM_CLASS_MENU | ANIM_CLASS_SUBMENU },
+ { GAME_MODE_MAIN, ANIM_CLASS_TOONS | ANIM_CLASS_MENU },
+ { GAME_MODE_SCORES, ANIM_CLASS_TOONS },
+
+ { -1, -1 }
+};
+
+struct AnimClassGameMode
+{
+ int class_bit;
+ int game_mode;
+} anim_class_game_modes_list[] =
+{
+ { ANIM_CLASS_BIT_SUBMENU, GAME_MODE_PSEUDO_SUBMENU },
+ { ANIM_CLASS_BIT_MENU, GAME_MODE_PSEUDO_MENU },
+ { ANIM_CLASS_BIT_TOONS, GAME_MODE_PSEUDO_TOONS },
+
+ { -1, -1 }
+};
+
+/* forward declaration for internal use */
+static void HandleGlobalAnim(int, int);
+static void DoAnimationExt(void);
+
+static struct GlobalAnimControlInfo global_anim_ctrl[NUM_GAME_MODES];
+static struct ToonInfo toons[MAX_NUM_TOONS];
+
+static unsigned int anim_sync_frame = 0;
+static unsigned int anim_sync_frame_delay = 0;
+static unsigned int anim_sync_frame_delay_value = GAME_FRAME_DELAY;
+
+static int game_mode_anim_classes[NUM_GAME_MODES];
+static int anim_class_game_modes[NUM_ANIM_CLASSES];
+
+static int anim_status_last = GAME_MODE_DEFAULT;
+static int anim_classes_last = ANIM_CLASS_NONE;
+
+
+static int getGlobalAnimationPart(struct GlobalAnimMainControlInfo *anim)
+{
+ struct GraphicInfo *c = &anim->control_info;
+ int last_anim_random_frame = gfx.anim_random_frame;
+ int part_nr;
+
+ gfx.anim_random_frame = -1; // (use simple, ad-hoc random numbers)
+
+ part_nr = getAnimationFrame(anim->num_parts, 1,
+ c->anim_mode, c->anim_start_frame,
+ anim->part_counter);
+
+ gfx.anim_random_frame = last_anim_random_frame;
+
+ return part_nr;
+}
+
+static void PrepareBackbuffer()
+{
+ if (game_status != GAME_MODE_PLAYING)
+ return;
+
+ BlitScreenToBitmap(backbuffer);
+}
+
+boolean ToonNeedsRedraw()
+{
+ return TRUE;
+}
+
+void InitToons()
+{
+ int num_toons = MAX_NUM_TOONS;
+ int i;
+
+ if (global.num_toons >= 0 && global.num_toons < MAX_NUM_TOONS)
+ num_toons = global.num_toons;
+
+ for (i = 0; i < num_toons; i++)