+ /* optionally, the x and y offset of frames can be specified directly */
+ if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
+ if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
+
+ /* automatically determine correct number of frames, if not defined */
+ if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
+ else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
+ graphic_info[graphic].anim_frames = num_xtiles;
+ else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
+ graphic_info[graphic].anim_frames = num_ytiles;
+ else
+ graphic_info[graphic].anim_frames = 1;
+
+ graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
+ if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
+ graphic_info[graphic].anim_delay = 1;
+
+ /* set mode for animation frame order */
+ if (parameter[GFX_ARG_MODE_LOOP])
+ graphic_info[graphic].anim_mode = ANIM_LOOP;
+ else if (parameter[GFX_ARG_MODE_LINEAR])
+ graphic_info[graphic].anim_mode = ANIM_LINEAR;
+ else if (parameter[GFX_ARG_MODE_PINGPONG])
+ graphic_info[graphic].anim_mode = ANIM_PINGPONG;
+ else if (parameter[GFX_ARG_MODE_PINGPONG2])
+ graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
+ else if (parameter[GFX_ARG_MODE_RANDOM])
+ graphic_info[graphic].anim_mode = ANIM_RANDOM;
+ else if (graphic_info[graphic].anim_frames > 1)
+ graphic_info[graphic].anim_mode = ANIM_LOOP;
+ else
+ graphic_info[graphic].anim_mode = ANIM_NONE;
+
+ /* set additional flag to play animation frames in reverse order */
+ if (parameter[GFX_ARG_MODE_REVERSE])
+ graphic_info[graphic].anim_mode |= ANIM_REVERSE;
+
+ /* automatically determine correct start frame, if not defined */
+ if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].anim_start_frame = 0;
+ else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
+ graphic_info[graphic].anim_start_frame =
+ graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
+ else
+ graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];