#define NUM_TOOL_BUTTONS 7
/* forward declaration for internal use */
-static int getGraphicAnimationPhase(int, int, int);
static void UnmapToolButtons();
static void HandleToolButtons(struct GadgetInfo *);
redraw_mask |= REDRAW_FIELD;
}
+static int getGraphicAnimationPhase(int frames, int delay, int mode)
+{
+ int phase;
+
+ if (mode & ANIM_PINGPONG)
+ {
+ int max_anim_frames = 2 * frames - 2;
+
+ phase = (FrameCounter % (delay * max_anim_frames)) / delay;
+ phase = (phase < frames ? phase : max_anim_frames - phase);
+ }
+ else
+ phase = (FrameCounter % (delay * frames)) / delay;
+
+ if (mode & ANIM_REVERSE)
+ phase = -phase;
+
+ return phase;
+}
+
+inline int getGraphicAnimationFrame(int graphic, int sync_frame)
+{
+ /* animation synchronized with global frame counter, not move position */
+ if (new_graphic_info[graphic].anim_global_sync || sync_frame < 0)
+ sync_frame = FrameCounter;
+
+ return getAnimationFrame(new_graphic_info[graphic].anim_frames,
+ new_graphic_info[graphic].anim_delay,
+ new_graphic_info[graphic].anim_mode,
+ new_graphic_info[graphic].anim_start_frame,
+ sync_frame);
+}
+
void MarkTileDirty(int x, int y)
{
int xx = redraw_x1 + x;
MarkTileDirty(sx,sy);
}
-static int getGraphicAnimationPhase(int frames, int delay, int mode)
+void DrawGraphicAnimationExt(DrawBuffer *dst_bitmap, int x, int y,
+ int graphic, int mask_mode)
{
- int phase;
-
- if (mode & ANIM_PINGPONG)
- {
- int max_anim_frames = 2 * frames - 2;
+ int frame = getGraphicAnimationFrame(graphic, -1);
- phase = (FrameCounter % (delay * max_anim_frames)) / delay;
- phase = (phase < frames ? phase : max_anim_frames - phase);
- }
+ if (mask_mode == USE_MASKING)
+ DrawGraphicThruMaskExt(dst_bitmap, x, y, graphic, frame);
else
- phase = (FrameCounter % (delay * frames)) / delay;
-
- if (mode & ANIM_REVERSE)
- phase = -phase;
-
- return phase;
-}
-
-int getGraphicAnimationFrame(int graphic, int sync_frame)
-{
- int num_frames = new_graphic_info[graphic].anim_frames;
- int delay = new_graphic_info[graphic].anim_delay;
- int mode = new_graphic_info[graphic].anim_mode;
- int frame = 0;
-
- /* animation synchronized with global frame counter, not move position */
- if (new_graphic_info[graphic].anim_global_sync || sync_frame < 0)
- sync_frame = FrameCounter;
-
- sync_frame += new_graphic_info[graphic].anim_start_frame * delay;
-
- if (mode & ANIM_LOOP) /* normal, looping animation */
- {
- frame = (sync_frame % (delay * num_frames)) / delay;
- }
- else if (mode & ANIM_LINEAR) /* normal, non-looping animation */
- {
- frame = sync_frame / delay;
-
- if (frame > num_frames - 1)
- frame = num_frames - 1;
- }
- else if (mode & ANIM_PINGPONG) /* use border frames once */
- {
- int max_anim_frames = 2 * num_frames - 2;
-
- frame = (sync_frame % (delay * max_anim_frames)) / delay;
- frame = (frame < num_frames ? frame : max_anim_frames - frame);
- }
- else if (mode & ANIM_PINGPONG2) /* use border frames twice */
- {
- int max_anim_frames = 2 * num_frames;
-
- frame = (sync_frame % (delay * max_anim_frames)) / delay;
- frame = (frame < num_frames ? frame : max_anim_frames - frame - 1);
- }
-
- if (mode & ANIM_REVERSE) /* use reverse animation direction */
- frame = num_frames - frame - 1;
-
- return frame;
-}
-
-void DrawGraphicAnimationExt(int x, int y, int graphic, int mask_mode)
-{
- if (IN_SCR_FIELD(x, y))
- {
- int frame = getGraphicAnimationFrame(graphic, -1);
-
- if (mask_mode == USE_MASKING)
- DrawGraphicThruMask(x, y, graphic, frame);
- else
- DrawGraphic(x, y, graphic, frame);
- }
+ DrawGraphicExt(dst_bitmap, x, y, graphic, frame);
}
void DrawGraphicAnimation(int x, int y, int graphic)
{
- DrawGraphicAnimationExt(x, y, graphic, NO_MASKING);
+ if (!IN_SCR_FIELD(x, y) ||
+ (FrameCounter % new_graphic_info[graphic].anim_delay) != 0)
+ return;
+
+ DrawGraphicAnimationExt(drawto_field, FX + x * TILEX, FY + y * TILEY,
+ graphic, NO_MASKING);
+ MarkTileDirty(x, y);
}
-#if 1
+#if 0
void getOldGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y)
{
if (graphic >= 0 && graphic_info[graphic].bitmap != NULL)
MarkTileDirty(x, y);
}
-#if 1
+#if 0
void DrawOldGraphicExt(DrawBuffer *dst_bitmap, int x, int y, int graphic)
{
Bitmap *src_bitmap;
int src_x = mini_startx + new_graphic_info[graphic].src_x / 2;
int src_y = mini_starty + new_graphic_info[graphic].src_y / 2;
+ if (src_x + MINI_TILEX > src_bitmap->width ||
+ src_y + MINI_TILEY > src_bitmap->height)
+ {
+ /* graphic of desired size seems not to be contained in this image;
+ dirty workaround: get it from the middle of the normal sized image */
+
+ getGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y);
+ src_x += (TILEX / 2 - MINI_TILEX / 2);
+ src_y += (TILEY / 2 - MINI_TILEY / 2);
+ }
+
*bitmap = src_bitmap;
*x = src_x;
*y = src_y;
gfx_action = GfxAction[x][y];
#endif
+#if DEBUG
+ if (gfx_action < 0)
+ printf("getGfxAction: THIS SHOULD NEVER HAPPEN: GfxAction[%d][%d] == %d\n",
+ x, y, gfx_action);
+#endif
+
return gfx_action;
}
int cut_mode, int mask_mode)
{
int ux = LEVELX(x), uy = LEVELY(y);
- int move_dir = MovDir[ux][uy];
- int move_pos = getFramePosition(ux, uy);
- int gfx_action = getGfxAction(ux, uy);
- int graphic = el_dir_act2img(element, move_dir, gfx_action);
- int frame = getGraphicAnimationFrame(graphic, move_pos);
+ int graphic;
+ int frame;
+
+ if (IN_LEV_FIELD(ux, uy))
+ {
+ int move_dir = MovDir[ux][uy];
+ int move_pos = getFramePosition(ux, uy);
+ int gfx_action = getGfxAction(ux, uy);
+
+ graphic = el_dir_act2img(element, move_dir, gfx_action);
+ frame = getGraphicAnimationFrame(graphic, move_pos);
+ }
+ else
+ {
+ graphic = el2img(element);
+ frame = getGraphicAnimationFrame(graphic, 0);
+ }
if (element == EL_WALL_GROWING)
{
int src_x = mini_startx + new_graphic_info[graphic].src_x / 8;
int src_y = mini_starty + new_graphic_info[graphic].src_y / 8;
+ if (src_x + MICRO_TILEX > src_bitmap->width ||
+ src_y + MICRO_TILEY > src_bitmap->height)
+ {
+ /* graphic of desired size seems not to be contained in this image;
+ dirty workaround: get it from the middle of the normal sized image */
+
+ getGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y);
+ src_x += (TILEX / 2 - MICRO_TILEX / 2);
+ src_y += (TILEY / 2 - MICRO_TILEY / 2);
+ }
+
*bitmap = src_bitmap;
*x = src_x;
*y = src_y;
{
stepsize = 20;
door_delay_value = 0;
+
StopSound(SND_MENU_DOOR_OPENING);
StopSound(SND_MENU_DOOR_CLOSING);
}
+ if (global.autoplay_leveldir)
+ {
+ door_state |= DOOR_NO_DELAY;
+ door_state &= ~DOOR_CLOSE_ALL;
+ }
+
if (door_state & DOOR_ACTION)
{
if (!(door_state & DOOR_NO_DELAY))
Bitmap *bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap;
GC gc = bitmap->stored_clip_gc;
- WaitUntilDelayReached(&door_delay, door_delay_value);
+ if (!(door_state & DOOR_NO_DELAY))
+ WaitUntilDelayReached(&door_delay, door_delay_value);
if (door_state & DOOR_ACTION_1)
{
{
/* draw bigger toolbox window */
BlitBitmap(new_graphic_info[IMG_MENU_DOOR].bitmap, drawto,
- DOOR_GFX_PAGEX7, 0, 108, 56, EX - 4, EY - 12);
+ DOOR_GFX_PAGEX7, 0, EXSIZE + 8, 8,
+ EX - 4, EY - 12);
+ BlitBitmap(new_graphic_info[IMG_MENU_BACK].bitmap, drawto,
+ EX - 4, VY - 4, EXSIZE + 8, EYSIZE - VYSIZE + 4,
+ EX - 4, EY - 4);
redraw_mask |= REDRAW_ALL;
}
{
/* draw normal tape recorder window */
BlitBitmap(new_graphic_info[IMG_MENU_BACK].bitmap, drawto,
- 562, 344, 108, 56, EX - 4, EY - 12);
+ EX - 4, EY - 12, EXSIZE + 8, EYSIZE - VYSIZE + 12,
+ EX - 4, EY - 12);
redraw_mask |= REDRAW_ALL;
}
}
}
+void FreeToolButtons()
+{
+ int i;
+
+ for (i=0; i<NUM_TOOL_BUTTONS; i++)
+ FreeGadget(tool_gadget[i]);
+}
+
static void UnmapToolButtons()
{
int i;
int el_dir_act2img(int element, int direction, int action)
{
+#if DEBUG
+ if (element < 0)
+ {
+ printf("el_dir_act2img: THIS SHOULD NEVER HAPPEN: element == %d\n",
+ element);
+
+ return IMG_EMPTY;
+ }
+
+ if (action < 0)
+ {
+ printf("el_dir_act2img: THIS SHOULD NEVER HAPPEN: action == %d\n",
+ action);
+
+ return IMG_EMPTY;
+ }
+#endif
+
action = graphics_action_mapping[action];
direction = MV_DIR_BIT(direction);