+ {
+ if (direction < 0)
+ for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
+ element_info[element].direction_graphic[action][dir] = -1;
+
+ if (direction > -1)
+ element_info[element].direction_graphic[action][direction] = graphic;
+ else
+ element_info[element].graphic[action] = graphic;
+ }
+ }
+
+ /* now copy all graphics that are defined to be cloned from other graphics */
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ {
+ int graphic = element_info[i].graphic[ACTION_DEFAULT];
+ int crumbled_like, diggable_like;
+
+ if (graphic == -1)
+ continue;
+
+ crumbled_like = graphic_info[graphic].crumbled_like;
+ diggable_like = graphic_info[graphic].diggable_like;
+
+ if (crumbled_like != -1 && element_info[i].crumbled[ACTION_DEFAULT] == -1)
+ {
+ for (act = 0; act < NUM_ACTIONS; act++)
+ element_info[i].crumbled[act] =
+ element_info[crumbled_like].crumbled[act];
+ for (act = 0; act < NUM_ACTIONS; act++)
+ for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
+ element_info[i].direction_crumbled[act][dir] =
+ element_info[crumbled_like].direction_crumbled[act][dir];
+ }
+
+ if (diggable_like != -1 && element_info[i].graphic[ACTION_DIGGING] == -1)
+ {
+ element_info[i].graphic[ACTION_DIGGING] =
+ element_info[diggable_like].graphic[ACTION_DIGGING];
+ for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
+ element_info[i].direction_graphic[ACTION_DIGGING][dir] =
+ element_info[diggable_like].direction_graphic[ACTION_DIGGING][dir];
+ }
+ }
+
+#if 1
+ /* set hardcoded definitions for some runtime elements without graphic */
+ element_info[EL_AMOEBA_TO_DIAMOND].graphic[ACTION_DEFAULT] = IMG_AMOEBA_DEAD;
+#endif
+
+#if 1
+ /* set hardcoded definitions for some internal elements without graphic */
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ {
+ if (IS_EDITOR_CASCADE_INACTIVE(i))
+ element_info[i].graphic[ACTION_DEFAULT] = IMG_EDITOR_CASCADE_LIST;
+ else if (IS_EDITOR_CASCADE_ACTIVE(i))
+ element_info[i].graphic[ACTION_DEFAULT] = IMG_EDITOR_CASCADE_LIST_ACTIVE;
+ }
+#endif
+
+ /* now set all undefined/invalid graphics to -1 to set to default after it */
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ {
+ for (act = 0; act < NUM_ACTIONS; act++)
+ {
+ int graphic;
+
+ graphic = element_info[i].graphic[act];
+ if (graphic > 0 && graphic_info[graphic].bitmap == NULL)
+ element_info[i].graphic[act] = -1;
+
+ graphic = element_info[i].crumbled[act];
+ if (graphic > 0 && graphic_info[graphic].bitmap == NULL)
+ element_info[i].crumbled[act] = -1;
+
+ for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
+ {
+ graphic = element_info[i].direction_graphic[act][dir];
+ if (graphic > 0 && graphic_info[graphic].bitmap == NULL)
+ element_info[i].direction_graphic[act][dir] = -1;
+
+ graphic = element_info[i].direction_crumbled[act][dir];
+ if (graphic > 0 && graphic_info[graphic].bitmap == NULL)
+ element_info[i].direction_crumbled[act][dir] = -1;
+ }
+ }
+ }
+
+ UPDATE_BUSY_STATE();
+
+ /* adjust graphics with 2nd tile for movement according to direction
+ (do this before correcting '-1' values to minimize calculations) */
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ {
+ for (act = 0; act < NUM_ACTIONS; act++)
+ {
+ for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
+ {
+ int graphic = element_info[i].direction_graphic[act][dir];
+ int move_dir = (act == ACTION_FALLING ? MV_BIT_DOWN : dir);
+
+ if (act == ACTION_FALLING) /* special case */
+ graphic = element_info[i].graphic[act];
+
+ if (graphic != -1 &&
+ graphic_info[graphic].double_movement &&
+ graphic_info[graphic].swap_double_tiles != 0)
+ {
+ struct GraphicInfo *g = &graphic_info[graphic];
+ int src_x_front = g->src_x;
+ int src_y_front = g->src_y;
+ int src_x_back = g->src_x + g->offset2_x;
+ int src_y_back = g->src_y + g->offset2_y;
+ boolean frames_are_ordered_diagonally = (g->offset_x != 0 &&
+ g->offset_y != 0);
+ boolean front_is_left_or_upper = (src_x_front < src_x_back ||
+ src_y_front < src_y_back);
+ boolean swap_movement_tiles_always = (g->swap_double_tiles == 1);
+ boolean swap_movement_tiles_autodetected =
+ (!frames_are_ordered_diagonally &&
+ ((move_dir == MV_BIT_LEFT && !front_is_left_or_upper) ||
+ (move_dir == MV_BIT_UP && !front_is_left_or_upper) ||
+ (move_dir == MV_BIT_RIGHT && front_is_left_or_upper) ||
+ (move_dir == MV_BIT_DOWN && front_is_left_or_upper)));
+ Bitmap *dummy;
+
+ /* swap frontside and backside graphic tile coordinates, if needed */
+ if (swap_movement_tiles_always || swap_movement_tiles_autodetected)
+ {
+ /* get current (wrong) backside tile coordinates */
+ getGraphicSourceExt(graphic, 0, &dummy, &src_x_back, &src_y_back,
+ TRUE);
+
+ /* set frontside tile coordinates to backside tile coordinates */
+ g->src_x = src_x_back;
+ g->src_y = src_y_back;
+
+ /* invert tile offset to point to new backside tile coordinates */
+ g->offset2_x *= -1;
+ g->offset2_y *= -1;
+
+ /* do not swap front and backside tiles again after correction */
+ g->swap_double_tiles = 0;
+ }
+ }
+ }
+ }
+ }
+
+ UPDATE_BUSY_STATE();
+
+ /* now set all '-1' values to element specific default values */
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ {
+ int default_graphic = element_info[i].graphic[ACTION_DEFAULT];
+ int default_crumbled = element_info[i].crumbled[ACTION_DEFAULT];
+ int default_direction_graphic[NUM_DIRECTIONS_FULL];
+ int default_direction_crumbled[NUM_DIRECTIONS_FULL];
+
+ if (default_graphic == -1)
+ default_graphic = IMG_UNKNOWN;
+#if 1
+ if (default_crumbled == -1)
+ default_crumbled = default_graphic;
+#else
+ /* !!! THIS LOOKS CRAPPY FOR SAND ETC. WITHOUT CRUMBLED GRAPHICS !!! */
+ if (default_crumbled == -1)
+ default_crumbled = IMG_EMPTY;
+#endif
+
+ for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
+ {
+ default_direction_graphic[dir] =
+ element_info[i].direction_graphic[ACTION_DEFAULT][dir];
+ default_direction_crumbled[dir] =
+ element_info[i].direction_crumbled[ACTION_DEFAULT][dir];
+
+ if (default_direction_graphic[dir] == -1)
+ default_direction_graphic[dir] = default_graphic;
+#if 1
+ if (default_direction_crumbled[dir] == -1)
+ default_direction_crumbled[dir] = default_direction_graphic[dir];
+#else
+ /* !!! THIS LOOKS CRAPPY FOR SAND ETC. WITHOUT CRUMBLED GRAPHICS !!! */
+ if (default_direction_crumbled[dir] == -1)
+ default_direction_crumbled[dir] = default_crumbled;
+#endif
+ }
+
+ for (act = 0; act < NUM_ACTIONS; act++)
+ {
+ boolean act_remove = ((IS_DIGGABLE(i) && act == ACTION_DIGGING) ||
+ (IS_SNAPPABLE(i) && act == ACTION_SNAPPING) ||
+ (IS_COLLECTIBLE(i) && act == ACTION_COLLECTING));
+ boolean act_turning = (act == ACTION_TURNING_FROM_LEFT ||
+ act == ACTION_TURNING_FROM_RIGHT ||
+ act == ACTION_TURNING_FROM_UP ||
+ act == ACTION_TURNING_FROM_DOWN);
+
+ /* generic default action graphic (defined by "[default]" directive) */
+ int default_action_graphic = element_info[EL_DEFAULT].graphic[act];
+ int default_action_crumbled = element_info[EL_DEFAULT].crumbled[act];
+ int default_remove_graphic = IMG_EMPTY;
+
+ if (act_remove && default_action_graphic != -1)
+ default_remove_graphic = default_action_graphic;
+
+ /* look for special default action graphic (classic game specific) */
+ if (IS_BD_ELEMENT(i) && element_info[EL_BD_DEFAULT].graphic[act] != -1)
+ default_action_graphic = element_info[EL_BD_DEFAULT].graphic[act];
+ if (IS_SP_ELEMENT(i) && element_info[EL_SP_DEFAULT].graphic[act] != -1)
+ default_action_graphic = element_info[EL_SP_DEFAULT].graphic[act];
+ if (IS_SB_ELEMENT(i) && element_info[EL_SB_DEFAULT].graphic[act] != -1)
+ default_action_graphic = element_info[EL_SB_DEFAULT].graphic[act];
+
+ if (IS_BD_ELEMENT(i) && element_info[EL_BD_DEFAULT].crumbled[act] != -1)
+ default_action_crumbled = element_info[EL_BD_DEFAULT].crumbled[act];
+ if (IS_SP_ELEMENT(i) && element_info[EL_SP_DEFAULT].crumbled[act] != -1)
+ default_action_crumbled = element_info[EL_SP_DEFAULT].crumbled[act];
+ if (IS_SB_ELEMENT(i) && element_info[EL_SB_DEFAULT].crumbled[act] != -1)
+ default_action_crumbled = element_info[EL_SB_DEFAULT].crumbled[act];
+
+#if 1
+ /* !!! needed because EL_EMPTY_SPACE treated as IS_SP_ELEMENT !!! */
+ /* !!! make this better !!! */
+ if (i == EL_EMPTY_SPACE)
+ {
+ default_action_graphic = element_info[EL_DEFAULT].graphic[act];
+ default_action_crumbled = element_info[EL_DEFAULT].crumbled[act];
+ }
+#endif
+
+ if (default_action_graphic == -1)
+ default_action_graphic = default_graphic;
+#if 1
+ if (default_action_crumbled == -1)
+ default_action_crumbled = default_action_graphic;
+#else
+ /* !!! THIS LOOKS CRAPPY FOR SAND ETC. WITHOUT CRUMBLED GRAPHICS !!! */
+ if (default_action_crumbled == -1)
+ default_action_crumbled = default_crumbled;
+#endif
+
+ for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
+ {
+ /* use action graphic as the default direction graphic, if undefined */
+ int default_action_direction_graphic = element_info[i].graphic[act];
+ int default_action_direction_crumbled = element_info[i].crumbled[act];
+
+ /* no graphic for current action -- use default direction graphic */
+ if (default_action_direction_graphic == -1)
+ default_action_direction_graphic =
+ (act_remove ? default_remove_graphic :
+ act_turning ?
+ element_info[i].direction_graphic[ACTION_TURNING][dir] :
+ default_action_graphic != default_graphic ?
+ default_action_graphic :
+ default_direction_graphic[dir]);
+
+ if (element_info[i].direction_graphic[act][dir] == -1)
+ element_info[i].direction_graphic[act][dir] =
+ default_action_direction_graphic;
+
+#if 1
+ if (default_action_direction_crumbled == -1)
+ default_action_direction_crumbled =
+ element_info[i].direction_graphic[act][dir];
+#else
+ if (default_action_direction_crumbled == -1)
+ default_action_direction_crumbled =
+ (act_remove ? default_remove_graphic :
+ act_turning ?
+ element_info[i].direction_crumbled[ACTION_TURNING][dir] :
+ default_action_crumbled != default_crumbled ?
+ default_action_crumbled :
+ default_direction_crumbled[dir]);
+#endif
+
+ if (element_info[i].direction_crumbled[act][dir] == -1)
+ element_info[i].direction_crumbled[act][dir] =
+ default_action_direction_crumbled;
+ }
+
+ /* no graphic for this specific action -- use default action graphic */
+ if (element_info[i].graphic[act] == -1)
+ element_info[i].graphic[act] =
+ (act_remove ? default_remove_graphic :
+ act_turning ? element_info[i].graphic[ACTION_TURNING] :
+ default_action_graphic);
+#if 1
+ if (element_info[i].crumbled[act] == -1)
+ element_info[i].crumbled[act] = element_info[i].graphic[act];
+#else
+ if (element_info[i].crumbled[act] == -1)
+ element_info[i].crumbled[act] =
+ (act_remove ? default_remove_graphic :
+ act_turning ? element_info[i].crumbled[ACTION_TURNING] :
+ default_action_crumbled);
+#endif
+ }
+ }
+
+ UPDATE_BUSY_STATE();
+
+#if 0
+ /* !!! THIS ALSO CLEARS SPECIAL FLAGS (AND IS NOT NEEDED ANYWAY) !!! */
+ /* set animation mode to "none" for each graphic with only 1 frame */
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ {
+ for (act = 0; act < NUM_ACTIONS; act++)
+ {
+ int graphic = element_info[i].graphic[act];
+ int crumbled = element_info[i].crumbled[act];
+
+ if (graphic_info[graphic].anim_frames == 1)
+ graphic_info[graphic].anim_mode = ANIM_NONE;
+ if (graphic_info[crumbled].anim_frames == 1)
+ graphic_info[crumbled].anim_mode = ANIM_NONE;
+
+ for (dir = 0; dir < NUM_DIRECTIONS_FULL; dir++)
+ {
+ graphic = element_info[i].direction_graphic[act][dir];
+ crumbled = element_info[i].direction_crumbled[act][dir];
+
+ if (graphic_info[graphic].anim_frames == 1)
+ graphic_info[graphic].anim_mode = ANIM_NONE;
+ if (graphic_info[crumbled].anim_frames == 1)
+ graphic_info[crumbled].anim_mode = ANIM_NONE;
+ }
+ }
+ }
+#endif
+
+#if 0
+#if DEBUG
+ if (options.verbose)
+ {
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ if (element_info[i].graphic[ACTION_DEFAULT] == IMG_UNKNOWN &&
+ i != EL_UNKNOWN)
+ Error(ERR_INFO, "warning: no graphic for element '%s' (%d)",
+ element_info[i].token_name, i);
+ }
+#endif
+#endif
+}
+
+void InitElementSpecialGraphicInfo()
+{
+ struct PropertyMapping *property_mapping = getImageListPropertyMapping();
+ int num_property_mappings = getImageListPropertyMappingSize();
+ int i, j;
+
+ /* always start with reliable default values */
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ for (j = 0; j < NUM_SPECIAL_GFX_ARGS; j++)
+ element_info[i].special_graphic[j] =
+ element_info[i].graphic[ACTION_DEFAULT];
+
+ /* initialize special element/graphic mapping from static configuration */
+ for (i = 0; element_to_special_graphic[i].element > -1; i++)
+ {
+ int element = element_to_special_graphic[i].element;
+ int special = element_to_special_graphic[i].special;
+ int graphic = element_to_special_graphic[i].graphic;
+ int base_graphic = el2baseimg(element);
+ boolean base_redefined =
+ getImageListEntryFromImageID(base_graphic)->redefined;
+ boolean special_redefined =
+ getImageListEntryFromImageID(graphic)->redefined;
+
+#if 0
+ if ((element == EL_EM_DYNAMITE ||
+ element == EL_EM_DYNAMITE_ACTIVE) &&
+ (special == GFX_SPECIAL_ARG_EDITOR ||
+ special == GFX_SPECIAL_ARG_PANEL))
+ printf("::: SPECIAL STATIC: %d, %d -> %d\n",
+ element, special, graphic);
+#endif
+
+ /* if the base graphic ("emerald", for example) has been redefined,
+ but not the special graphic ("emerald.EDITOR", for example), do not
+ use an existing (in this case considered obsolete) special graphic
+ anymore, but use the automatically created (down-scaled) graphic */
+ if (base_redefined && !special_redefined)
+ continue;
+
+ element_info[element].special_graphic[special] = graphic;
+ }
+
+ /* initialize special element/graphic mapping from dynamic configuration */
+ for (i = 0; i < num_property_mappings; i++)
+ {
+ int element = property_mapping[i].base_index;
+ int action = property_mapping[i].ext1_index;
+ int direction = property_mapping[i].ext2_index;
+ int special = property_mapping[i].ext3_index;
+ int graphic = property_mapping[i].artwork_index;
+
+#if 0
+ if ((element == EL_EM_DYNAMITE ||
+ element == EL_EM_DYNAMITE_ACTIVE ||
+ element == EL_CONVEYOR_BELT_1_MIDDLE ||
+ element == EL_CONVEYOR_BELT_1_MIDDLE_ACTIVE) &&
+ (special == GFX_SPECIAL_ARG_EDITOR ||
+ special == GFX_SPECIAL_ARG_PANEL))
+ printf("::: SPECIAL DYNAMIC: %d, %d -> %d [%d]\n",
+ element, special, graphic, property_mapping[i].ext1_index);
+#endif
+
+#if 0
+ if (element == EL_CONVEYOR_BELT_1_MIDDLE &&
+ action == ACTION_ACTIVE)
+ {
+ element = EL_CONVEYOR_BELT_1_MIDDLE_ACTIVE;
+ action = -1;
+ }
+#endif
+
+#if 0
+ if (element == EL_MAGIC_WALL &&
+ action == ACTION_ACTIVE)
+ {
+ element = EL_MAGIC_WALL_ACTIVE;
+ action = -1;
+ }
+#endif
+
+#if 1
+ /* for action ".active", replace element with active element, if exists */
+ if (action == ACTION_ACTIVE && element != ELEMENT_ACTIVE(element))
+ {
+ element = ELEMENT_ACTIVE(element);
+ action = -1;
+ }
+#endif
+
+ if (element >= MAX_NUM_ELEMENTS)
+ continue;
+
+ /* do not change special graphic if action or direction was specified */
+ if (action != -1 || direction != -1)
+ continue;
+
+ if (IS_SPECIAL_GFX_ARG(special))
+ element_info[element].special_graphic[special] = graphic;
+ }
+
+ /* now set all undefined/invalid graphics to default */
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ for (j = 0; j < NUM_SPECIAL_GFX_ARGS; j++)
+ if (graphic_info[element_info[i].special_graphic[j]].bitmap == NULL)
+ element_info[i].special_graphic[j] =
+ element_info[i].graphic[ACTION_DEFAULT];
+}
+
+static int get_graphic_parameter_value(char *value_raw, char *suffix, int type)
+{
+ if (type != TYPE_ELEMENT && type != TYPE_GRAPHIC)
+ return get_parameter_value(value_raw, suffix, type);
+
+ if (strEqual(value_raw, ARG_UNDEFINED))
+ return ARG_UNDEFINED_VALUE;
+
+#if 1
+ if (type == TYPE_ELEMENT)
+ {
+ char *value = getHashEntry(element_token_hash, value_raw);
+
+ return (value != NULL ? atoi(value) : EL_UNDEFINED);
+ }
+ else if (type == TYPE_GRAPHIC)
+ {
+ char *value = getHashEntry(graphic_token_hash, value_raw);
+
+ return (value != NULL ? atoi(value) : IMG_UNDEFINED);
+ }
+
+#else
+
+ int i;
+ int x = 0;
+
+ /* !!! THIS IS BUGGY !!! NOT SURE IF YOU GET ELEMENT ID OR GRAPHIC ID !!! */
+ /* !!! (possible reason why ".clone_from" with elements doesn't work) !!! */
+
+ /* !!! OPTIMIZE THIS BY USING HASH !!! */
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ if (strEqual(element_info[i].token_name, value_raw))
+ return i;
+
+ /* !!! OPTIMIZE THIS BY USING HASH !!! */
+ for (i = 0; image_config[i].token != NULL; i++)
+ {
+ int len_config_value = strlen(image_config[i].value);
+
+ if (!strEqual(&image_config[i].value[len_config_value - 4], ".pcx") &&
+ !strEqual(&image_config[i].value[len_config_value - 4], ".wav") &&
+ !strEqual(image_config[i].value, UNDEFINED_FILENAME))
+ continue;
+
+ if (strEqual(image_config[i].token, value_raw))
+ return x;
+
+ x++;
+ }
+#endif
+
+ return -1;
+}
+
+static int get_scaled_graphic_width(int graphic)
+{
+ int original_width = getOriginalImageWidthFromImageID(graphic);
+ int scale_up_factor = graphic_info[graphic].scale_up_factor;
+
+ return original_width * scale_up_factor;
+}
+
+static int get_scaled_graphic_height(int graphic)
+{
+ int original_height = getOriginalImageHeightFromImageID(graphic);
+ int scale_up_factor = graphic_info[graphic].scale_up_factor;
+
+ return original_height * scale_up_factor;
+}
+
+static void set_graphic_parameters_ext(int graphic, int *parameter,
+ Bitmap *src_bitmap)
+{
+ struct GraphicInfo *g = &graphic_info[graphic];
+ int anim_frames_per_row = 1, anim_frames_per_col = 1;
+ int anim_frames_per_line = 1;
+
+ /* always start with reliable default values */
+ g->src_image_width = 0;
+ g->src_image_height = 0;
+ g->src_x = 0;
+ g->src_y = 0;
+ g->width = TILEX; /* default for element graphics */
+ g->height = TILEY; /* default for element graphics */
+ g->offset_x = 0; /* one or both of these values ... */
+ g->offset_y = 0; /* ... will be corrected later */
+ g->offset2_x = 0; /* one or both of these values ... */
+ g->offset2_y = 0; /* ... will be corrected later */
+ g->swap_double_tiles = -1; /* auto-detect tile swapping */
+ g->crumbled_like = -1; /* do not use clone element */
+ g->diggable_like = -1; /* do not use clone element */
+ g->border_size = TILEX / 8; /* "CRUMBLED" border size */
+ g->scale_up_factor = 1; /* default: no scaling up */
+ g->clone_from = -1; /* do not use clone graphic */
+ g->anim_delay_fixed = 0;
+ g->anim_delay_random = 0;
+ g->post_delay_fixed = 0;
+ g->post_delay_random = 0;
+ g->fade_mode = FADE_MODE_DEFAULT;
+ g->fade_delay = -1;
+ g->post_delay = -1;
+ g->auto_delay = -1;
+ g->align = ALIGN_CENTER; /* default for title screens */
+ g->valign = VALIGN_MIDDLE; /* default for title screens */
+ g->sort_priority = 0; /* default for title screens */
+
+ g->bitmap = src_bitmap;
+
+#if 1
+ /* optional zoom factor for scaling up the image to a larger size */
+ if (parameter[GFX_ARG_SCALE_UP_FACTOR] != ARG_UNDEFINED_VALUE)
+ g->scale_up_factor = parameter[GFX_ARG_SCALE_UP_FACTOR];
+ if (g->scale_up_factor < 1)
+ g->scale_up_factor = 1; /* no scaling */
+#endif
+
+#if 1
+ if (g->use_image_size)
+ {
+ /* set new default bitmap size (with scaling, but without small images) */
+ g->width = get_scaled_graphic_width(graphic);
+ g->height = get_scaled_graphic_height(graphic);
+ }
+#endif
+
+ /* optional x and y tile position of animation frame sequence */
+ if (parameter[GFX_ARG_XPOS] != ARG_UNDEFINED_VALUE)
+ g->src_x = parameter[GFX_ARG_XPOS] * TILEX;
+ if (parameter[GFX_ARG_YPOS] != ARG_UNDEFINED_VALUE)
+ g->src_y = parameter[GFX_ARG_YPOS] * TILEY;
+
+ /* optional x and y pixel position of animation frame sequence */
+ if (parameter[GFX_ARG_X] != ARG_UNDEFINED_VALUE)
+ g->src_x = parameter[GFX_ARG_X];
+ if (parameter[GFX_ARG_Y] != ARG_UNDEFINED_VALUE)
+ g->src_y = parameter[GFX_ARG_Y];
+
+ /* optional width and height of each animation frame */
+ if (parameter[GFX_ARG_WIDTH] != ARG_UNDEFINED_VALUE)
+ g->width = parameter[GFX_ARG_WIDTH];
+ if (parameter[GFX_ARG_HEIGHT] != ARG_UNDEFINED_VALUE)
+ g->height = parameter[GFX_ARG_HEIGHT];
+
+#if 0
+ /* optional zoom factor for scaling up the image to a larger size */
+ if (parameter[GFX_ARG_SCALE_UP_FACTOR] != ARG_UNDEFINED_VALUE)
+ g->scale_up_factor = parameter[GFX_ARG_SCALE_UP_FACTOR];
+ if (g->scale_up_factor < 1)
+ g->scale_up_factor = 1; /* no scaling */
+#endif
+
+ if (src_bitmap)
+ {
+ /* get final bitmap size (with scaling, but without small images) */
+ int src_image_width = get_scaled_graphic_width(graphic);
+ int src_image_height = get_scaled_graphic_height(graphic);
+
+ if (src_image_width == 0 || src_image_height == 0)
+ {
+ /* only happens when loaded outside artwork system (like "global.busy") */
+ src_image_width = src_bitmap->width;
+ src_image_height = src_bitmap->height;
+ }
+
+ anim_frames_per_row = src_image_width / g->width;
+ anim_frames_per_col = src_image_height / g->height;
+
+ g->src_image_width = src_image_width;
+ g->src_image_height = src_image_height;
+ }
+
+ /* correct x or y offset dependent of vertical or horizontal frame order */
+ if (parameter[GFX_ARG_VERTICAL]) /* frames are ordered vertically */
+ {
+ g->offset_y = (parameter[GFX_ARG_OFFSET] != ARG_UNDEFINED_VALUE ?
+ parameter[GFX_ARG_OFFSET] : g->height);
+ anim_frames_per_line = anim_frames_per_col;
+ }
+ else /* frames are ordered horizontally */
+ {
+ g->offset_x = (parameter[GFX_ARG_OFFSET] != ARG_UNDEFINED_VALUE ?
+ parameter[GFX_ARG_OFFSET] : g->width);
+ anim_frames_per_line = anim_frames_per_row;