void SetDrawtoField(int mode)
{
- if (mode == DRAW_BUFFERED && setup.soft_scrolling)
+ if (mode == DRAW_FIELDBUFFER)
{
FX = 2 * TILEX_VAR;
FY = 2 * TILEY_VAR;
{
Bitmap *bitmap = graphic_info[IMG_GLOBAL_BORDER].bitmap;
- SetClipOrigin(bitmap, bitmap->stored_clip_gc, 0, 0);
BlitBitmapMasked(bitmap, backbuffer, x, y, width, height, x, y);
}
this could mean that we have to wait for the graphics to complete,
although we could go on doing calculations for the next frame */
- SyncDisplay();
+ /* SyncDisplay(); */
/* never draw masked border to backbuffer when using playfield buffer */
if (game_status != GAME_MODE_PLAYING ||
DrawTextExt(window, SX + SXSIZE + SX, 0, text, FONT_TEXT_2, BLIT_OPAQUE);
}
- FlushDisplay();
-
for (x = 0; x < MAX_BUF_XSIZE; x++)
for (y = 0; y < MAX_BUF_YSIZE; y++)
redraw[x][y] = 0;
DrawBackground(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
/* !!! maybe this should be done before clearing the background !!! */
- if (setup.soft_scrolling && game_status == GAME_MODE_PLAYING)
+ if (game_status == GAME_MODE_PLAYING)
{
ClearRectangle(fieldbuffer, 0, 0, FXSIZE, FYSIZE);
- SetDrawtoField(DRAW_BUFFERED);
+ SetDrawtoField(DRAW_FIELDBUFFER);
}
else
SetDrawtoField(DRAW_BACKBUFFER);
int src_y = g->src_y + (get_backside ? g->offset2_y : 0);
int tilesize_capped = MIN(MAX(1, tilesize), TILESIZE);
+ // if no in-game graphics defined, always use standard graphic size
+ if (g->bitmaps[IMG_BITMAP_GAME] == NULL)
+ tilesize = TILESIZE;
+
if (tilesize == gfx.standard_tile_size)
src_bitmap = g->bitmaps[IMG_BITMAP_STANDARD];
else if (tilesize == game.tile_size)
getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y);
- SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc,
- dst_x - src_x, dst_y - src_y);
-
BlitBitmapMasked(src_bitmap, d, src_x, src_y, TILEX_VAR, TILEY_VAR,
dst_x, dst_y);
}
void DrawFixedGraphicThruMaskExt(DrawBuffer *d, int dst_x, int dst_y,
int graphic, int frame)
{
+ struct GraphicInfo *g = &graphic_info[graphic];
Bitmap *src_bitmap;
int src_x, src_y;
getFixedGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y);
- SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc,
- dst_x - src_x, dst_y - src_y);
- BlitBitmapMasked(src_bitmap, d, src_x, src_y, TILEX, TILEY, dst_x, dst_y);
+ BlitBitmapMasked(src_bitmap, d, src_x, src_y, g->width, g->height,
+ dst_x, dst_y);
}
void DrawSizedGraphic(int x, int y, int graphic, int frame, int tilesize)
dst_y = FY + y * TILEY_VAR + dy;
if (mask_mode == USE_MASKING)
- {
- SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc,
- dst_x - src_x, dst_y - src_y);
BlitBitmapMasked(src_bitmap, drawto_field, src_x, src_y, width, height,
dst_x, dst_y);
- }
else
BlitBitmap(src_bitmap, drawto_field, src_x, src_y, width, height,
dst_x, dst_y);
dst_y = FY + y1 * TILEY_VAR;
if (mask_mode == USE_MASKING)
- {
- SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc,
- dst_x - src_x, dst_y - src_y);
BlitBitmapMasked(src_bitmap, drawto_field, src_x, src_y, width, height,
dst_x, dst_y);
- }
else
BlitBitmap(src_bitmap, drawto_field, src_x, src_y, width, height,
dst_x, dst_y);
dst_y = FY + y2 * TILEY_VAR;
if (mask_mode == USE_MASKING)
- {
- SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc,
- dst_x - src_x, dst_y - src_y);
BlitBitmapMasked(src_bitmap, drawto_field, src_x, src_y, width, height,
dst_x, dst_y);
- }
else
BlitBitmap(src_bitmap, drawto_field, src_x, src_y, width, height,
dst_x, dst_y);
}
}
+void DrawSizedElement(int x, int y, int element, int tilesize)
+{
+ int graphic;
+
+ graphic = el2edimg(element);
+ DrawSizedGraphic(x, y, graphic, 0, tilesize);
+}
+
void DrawMiniElement(int x, int y, int element)
{
int graphic;
DrawMiniGraphic(x, y, graphic);
}
+void DrawSizedElementOrWall(int sx, int sy, int scroll_x, int scroll_y,
+ int tilesize)
+{
+ int x = sx + scroll_x, y = sy + scroll_y;
+
+ if (x < -1 || x > lev_fieldx || y < -1 || y > lev_fieldy)
+ DrawSizedElement(sx, sy, EL_EMPTY, tilesize);
+ else if (x > -1 && x < lev_fieldx && y > -1 && y < lev_fieldy)
+ DrawSizedElement(sx, sy, Feld[x][y], tilesize);
+ else
+ DrawSizedGraphic(sx, sy, el2edimg(getBorderElement(x, y)), 0, tilesize);
+}
+
void DrawMiniElementOrWall(int sx, int sy, int scroll_x, int scroll_y)
{
int x = sx + scroll_x, y = sy + scroll_y;
inner_sy + (y - 1) * tile_height % inner_height);
if (draw_masked)
- {
- SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc,
- dst_x - src_x, dst_y - src_y);
BlitBitmapMasked(src_bitmap, drawto, src_x, src_y, tile_width, tile_height,
dst_x, dst_y);
- }
else
BlitBitmap(src_bitmap, drawto, src_x, src_y, tile_width, tile_height,
dst_x, dst_y);
boolean no_delay = (tape.warp_forward);
unsigned int anim_delay = 0;
int frame_delay_value = (ffwd_delay ? FfwdFrameDelay : GameFrameDelay);
- int anim_delay_value = (no_delay ? 0 : frame_delay_value);
+ int anim_delay_value = (no_delay ? 0 : frame_delay_value) / 2;
int font_nr = FONT_ENVELOPE_1 + envelope_nr;
int font_width = getFontWidth(font_nr);
int font_height = getFontHeight(font_nr);
int yend = (anim_mode != ANIM_DEFAULT ? max_ysize : 0);
int xstep = (xstart < xend ? 1 : 0);
int ystep = (ystart < yend || xstep == 0 ? 1 : 0);
- int x, y;
+ int start = 0;
+ int end = MAX(xend - xstart, yend - ystart);
+ int i;
- for (x = xstart, y = ystart; x <= xend && y <= yend; x += xstep, y += ystep)
+ for (i = start; i <= end; i++)
{
+ int last_frame = end; // last frame of this "for" loop
+ int x = xstart + i * xstep;
+ int y = ystart + i * ystep;
int xsize = (action == ACTION_CLOSING ? xend - (x - xstart) : x) + 2;
int ysize = (action == ACTION_CLOSING ? yend - (y - ystart) : y) + 2;
int sx = SX + (SXSIZE - xsize * font_width) / 2;
int sy = SY + (SYSIZE - ysize * font_height) / 2;
int xx, yy;
- SetDrawtoField(DRAW_BUFFERED);
+ SetDrawtoField(DRAW_FIELDBUFFER);
BlitScreenToBitmap(backbuffer);
redraw_mask |= REDRAW_FIELD | REDRAW_FROM_BACKBUFFER;
BackToFront();
- WaitUntilDelayReached(&anim_delay, anim_delay_value / 2);
+ SkipUntilDelayReached(&anim_delay, anim_delay_value, &i, last_frame);
}
}
game.envelope_active = FALSE;
- SetDrawtoField(DRAW_BUFFERED);
+ SetDrawtoField(DRAW_FIELDBUFFER);
redraw_mask |= REDRAW_FIELD;
BackToFront();
boolean ffwd_delay = (tape.playing && tape.fast_forward);
boolean no_delay = (tape.warp_forward);
int delay_value = (ffwd_delay ? delay_value_fast : delay_value_normal);
- int anim_delay_value = (no_delay ? 0 : delay_value + 500 * 0);
+ int anim_delay_value = (no_delay ? 0 : delay_value + 500 * 0) / 2;
unsigned int anim_delay = 0;
int width = request.width;
int yend = (anim_mode != ANIM_DEFAULT ? max_ysize_inner : 0);
int xstep = (xstart < xend ? 1 : 0);
int ystep = (ystart < yend || xstep == 0 ? 1 : 0);
- int x, y;
+ int start = 0;
+ int end = MAX(xend - xstart, yend - ystart);
+ int i;
if (setup.quick_doors)
{
xstart = xend;
ystart = yend;
+ end = 0;
}
else
{
PlayMenuSoundStereo(SND_DOOR_CLOSING, SOUND_MIDDLE);
}
- for (x = xstart, y = ystart; x <= xend && y <= yend; x += xstep, y += ystep)
+ for (i = start; i <= end; i++)
{
+ int last_frame = end; // last frame of this "for" loop
+ int x = xstart + i * xstep;
+ int y = ystart + i * ystep;
int xsize = (action == ACTION_CLOSING ? xend - (x - xstart) : x) + 2;
int ysize = (action == ACTION_CLOSING ? yend - (y - ystart) : y) + 2;
int sx_center = (request.x != -1 ? request.x : SX + SXSIZE / 2);
DoAnimation();
BackToFront();
- WaitUntilDelayReached(&anim_delay, anim_delay_value / 2);
+ SkipUntilDelayReached(&anim_delay, anim_delay_value, &i, last_frame);
}
}
AnimateEnvelopeRequest(ANIM_DEFAULT, ACTION_OPENING);
AnimateEnvelopeRequest(main_anim_mode, ACTION_OPENING);
-
}
else
{
if (action == ACTION_CLOSING &&
game_status == GAME_MODE_PLAYING &&
level.game_engine_type == GAME_ENGINE_TYPE_RND)
- SetDrawtoField(DRAW_BUFFERED);
+ SetDrawtoField(DRAW_FIELDBUFFER);
}
void DrawPreviewElement(int dst_x, int dst_y, int element, int tilesize)
redraw_mask |= REDRAW_FIELD;
}
+void DrawSizedLevel(int size_x, int size_y, int scroll_x, int scroll_y,
+ int tilesize)
+{
+ int x,y;
+
+ for (x = 0; x < size_x; x++)
+ for (y = 0; y < size_y; y++)
+ DrawSizedElementOrWall(x, y, scroll_x, scroll_y, tilesize);
+
+ redraw_mask |= REDRAW_FIELD;
+}
+
void DrawMiniLevel(int size_x, int size_y, int scroll_x, int scroll_y)
{
int x,y;
syy = player->GfxPos;
}
- if (!setup.soft_scrolling && ScreenMovPos)
- sxx = syy = 0;
-
if (player_is_opaque)
DrawGraphicShifted(sx, sy, sxx, syy, graphic, frame,NO_CUTTING,NO_MASKING);
else
syy = player->GfxPos;
}
- if (!setup.soft_scrolling && ScreenMovPos)
- sxx = syy = 0;
-
if (player_is_opaque)
DrawGraphicShifted(sx, sy, sxx, syy, graphic, frame,NO_CUTTING,NO_MASKING);
else
{
Event event;
- NextEvent(&event);
-
- switch (event.type)
+ while (NextValidEvent(&event))
{
- case EVENT_BUTTONPRESS:
- case EVENT_BUTTONRELEASE:
- case EVENT_MOTIONNOTIFY:
+ switch (event.type)
{
- if (event.type == EVENT_MOTIONNOTIFY)
- {
- if (!PointerInWindow(window))
- continue; /* window and pointer are on different screens */
-
- if (!button_status)
- continue;
-
- motion_status = TRUE;
- mx = ((MotionEvent *) &event)->x;
- my = ((MotionEvent *) &event)->y;
- }
- else
+ case EVENT_BUTTONPRESS:
+ case EVENT_BUTTONRELEASE:
+ case EVENT_MOTIONNOTIFY:
{
- motion_status = FALSE;
- mx = ((ButtonEvent *) &event)->x;
- my = ((ButtonEvent *) &event)->y;
- if (event.type == EVENT_BUTTONPRESS)
- button_status = ((ButtonEvent *) &event)->button;
+ if (event.type == EVENT_MOTIONNOTIFY)
+ {
+ if (!PointerInWindow(window))
+ continue; /* window and pointer on different screens */
+
+ if (!button_status)
+ continue;
+
+ motion_status = TRUE;
+ mx = ((MotionEvent *) &event)->x;
+ my = ((MotionEvent *) &event)->y;
+ }
else
- button_status = MB_RELEASED;
+ {
+ motion_status = FALSE;
+ mx = ((ButtonEvent *) &event)->x;
+ my = ((ButtonEvent *) &event)->y;
+ if (event.type == EVENT_BUTTONPRESS)
+ button_status = ((ButtonEvent *) &event)->button;
+ else
+ button_status = MB_RELEASED;
+ }
+
+ /* this sets 'request_gadget_id' */
+ HandleGadgets(mx, my, button_status);
+
+ switch (request_gadget_id)
+ {
+ case TOOL_CTRL_ID_YES:
+ result = TRUE;
+ break;
+ case TOOL_CTRL_ID_NO:
+ result = FALSE;
+ break;
+ case TOOL_CTRL_ID_CONFIRM:
+ result = TRUE | FALSE;
+ break;
+
+ case TOOL_CTRL_ID_PLAYER_1:
+ result = 1;
+ break;
+ case TOOL_CTRL_ID_PLAYER_2:
+ result = 2;
+ break;
+ case TOOL_CTRL_ID_PLAYER_3:
+ result = 3;
+ break;
+ case TOOL_CTRL_ID_PLAYER_4:
+ result = 4;
+ break;
+
+ default:
+ break;
+ }
+
+ break;
}
- /* this sets 'request_gadget_id' */
- HandleGadgets(mx, my, button_status);
+ case EVENT_KEYPRESS:
+ switch (GetEventKey((KeyEvent *)&event, TRUE))
+ {
+ case KSYM_space:
+ if (req_state & REQ_CONFIRM)
+ result = 1;
+ break;
- switch (request_gadget_id)
- {
- case TOOL_CTRL_ID_YES:
- result = TRUE;
- break;
- case TOOL_CTRL_ID_NO:
- result = FALSE;
- break;
- case TOOL_CTRL_ID_CONFIRM:
- result = TRUE | FALSE;
- break;
-
- case TOOL_CTRL_ID_PLAYER_1:
- result = 1;
- break;
- case TOOL_CTRL_ID_PLAYER_2:
- result = 2;
- break;
- case TOOL_CTRL_ID_PLAYER_3:
- result = 3;
- break;
- case TOOL_CTRL_ID_PLAYER_4:
- result = 4;
- break;
-
- default:
- break;
- }
-
- break;
- }
-
- case EVENT_KEYPRESS:
- switch (GetEventKey((KeyEvent *)&event, TRUE))
- {
- case KSYM_space:
- if (req_state & REQ_CONFIRM)
- result = 1;
- break;
-
- case KSYM_Return:
+ case KSYM_Return:
#if defined(TARGET_SDL2)
- case KSYM_Menu:
+ case KSYM_Menu:
#endif
- result = 1;
- break;
+ result = 1;
+ break;
- case KSYM_Escape:
+ case KSYM_Escape:
#if defined(TARGET_SDL2)
- case KSYM_Back:
+ case KSYM_Back:
#endif
- result = 0;
- break;
+ result = 0;
+ break;
- default:
- break;
- }
+ default:
+ break;
+ }
- if (req_state & REQ_PLAYER)
- result = 0;
- break;
+ if (req_state & REQ_PLAYER)
+ result = 0;
+ break;
- case EVENT_KEYRELEASE:
- ClearPlayerAction();
- break;
+ case EVENT_KEYRELEASE:
+ ClearPlayerAction();
+ break;
- default:
- HandleOtherEvents(&event);
- break;
+ default:
+ HandleOtherEvents(&event);
+ break;
+ }
}
}
else if (AnyJoystickButton() == JOY_BUTTON_NEW_PRESSED)
{
num_panel_steps = 2 * door_rect->height / door->step_offset;
door->panel.start_step = num_panel_steps - num_door_steps;
+ door->panel.start_step_closing = door->panel.start_step;
}
else
{
num_panel_steps = door_rect->height / door->step_offset;
door->panel.start_step = num_panel_steps - num_door_steps / 2;
+ door->panel.start_step_closing = door->panel.start_step;
door->panel.step_delay *= 2;
}
}
unsigned int door_delay_value;
int i;
- if (door_1.width < 0 || door_1.width > DXSIZE)
- door_1.width = DXSIZE;
- if (door_1.height < 0 || door_1.height > DYSIZE)
- door_1.height = DYSIZE;
- if (door_2.width < 0 || door_2.width > VXSIZE)
- door_2.width = VXSIZE;
- if (door_2.height < 0 || door_2.height > VYSIZE)
- door_2.height = VYSIZE;
-
if (door_state == DOOR_GET_STATE)
return (door1 | door2);
}
}
+ max_step_delay = MAX(1, max_step_delay); // prevent division by zero
+
num_move_steps = max_move_delay / max_step_delay;
num_move_steps_doors_only = max_move_delay_doors_only / max_step_delay;
for (k = start; k < num_move_steps; k++)
{
+ int last_frame = num_move_steps - 1; // last frame of this "for" loop
+
door_part_done_all = TRUE;
for (i = 0; i < NUM_DOORS; i++)
if (game_status == GAME_MODE_MAIN)
DoAnimation();
- WaitUntilDelayReached(&door_delay, door_delay_value);
+ SkipUntilDelayReached(&door_delay, door_delay_value, &k, last_frame);
current_move_delay += max_step_delay;
}
int vy = VY - outer_border;
int exsize = EXSIZE + 2 * outer_border;
- CloseDoor(DOOR_CLOSE_2);
-
/* draw bigger level editor toolbox window */
BlitBitmap(gfx1->bitmap, drawto, gfx1->src_x, gfx1->src_y,
top_border_width, top_border_height, ex, ey - top_border_height);
#endif
}
+void CheckSaveEngineSnapshot_EM(byte action[MAX_PLAYERS], int frame,
+ boolean any_player_moving,
+ boolean any_player_snapping,
+ boolean any_player_dropping)
+{
+ static boolean player_was_waiting = TRUE;
+
+ if (frame == 0 && !any_player_dropping)
+ {
+ if (!player_was_waiting)
+ {
+ if (!SaveEngineSnapshotToList())
+ return;
+
+ player_was_waiting = TRUE;
+ }
+ }
+ else if (any_player_moving || any_player_snapping || any_player_dropping)
+ {
+ player_was_waiting = FALSE;
+ }
+}
+
+void CheckSaveEngineSnapshot_SP(boolean murphy_is_waiting,
+ boolean murphy_is_dropping)
+{
+ static boolean player_was_waiting = TRUE;
+
+ if (murphy_is_waiting)
+ {
+ if (!player_was_waiting)
+ {
+ if (!SaveEngineSnapshotToList())
+ return;
+
+ player_was_waiting = TRUE;
+ }
+ }
+ else
+ {
+ player_was_waiting = FALSE;
+ }
+}
+
void CheckSingleStepMode_EM(byte action[MAX_PLAYERS], int frame,
boolean any_player_moving,
- boolean player_is_dropping)
+ boolean any_player_snapping,
+ boolean any_player_dropping)
{
if (tape.single_step && tape.recording && !tape.pausing)
- if (frame == 0 && !player_is_dropping)
+ if (frame == 0 && !any_player_dropping)
TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+
+ CheckSaveEngineSnapshot_EM(action, frame, any_player_moving,
+ any_player_snapping, any_player_dropping);
}
void CheckSingleStepMode_SP(boolean murphy_is_waiting,
if (tape.single_step && tape.recording && !tape.pausing)
if (murphy_is_waiting)
TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+
+ CheckSaveEngineSnapshot_SP(murphy_is_waiting, murphy_is_dropping);
}
void getGraphicSource_SP(struct GraphicInfo_SP *g_sp,
boolean init_video_buffer = FALSE;
boolean init_gadgets_and_toons = FALSE;
boolean init_em_graphics = FALSE;
+ boolean drawing_area_changed = FALSE;
if (viewport.window.width != WIN_XSIZE ||
viewport.window.height != WIN_YSIZE)
// printf("::: new_tilesize_var != TILESIZE_VAR\n");
// changing tile size invalidates scroll values of engine snapshots
- FreeEngineSnapshot();
+ FreeEngineSnapshotSingle();
// changing tile size requires update of graphic mapping for EM engine
init_em_graphics = TRUE;
}
+ if (new_sx != SX ||
+ new_sy != SY ||
+ new_sxsize != SXSIZE ||
+ new_sysize != SYSIZE ||
+ new_real_sx != REAL_SX ||
+ new_real_sy != REAL_SY ||
+ new_full_sxsize != FULL_SXSIZE ||
+ new_full_sysize != FULL_SYSIZE)
+ {
+ if (!init_video_buffer)
+ drawing_area_changed = TRUE;
+ }
+
SX = new_sx;
SY = new_sy;
DX = new_dx;
SCR_FIELDX = new_scr_fieldx;
SCR_FIELDY = new_scr_fieldy;
+
+ gfx.drawing_area_changed = drawing_area_changed;
+
+ SetDrawDeactivationMask(REDRAW_NONE);
+ SetDrawBackgroundMask(REDRAW_FIELD);
}
if (init_video_buffer)
// printf("::: init_video_buffer\n");
InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen);
-
- SetDrawDeactivationMask(REDRAW_NONE);
- SetDrawBackgroundMask(REDRAW_FIELD);
}
if (init_gadgets_and_toons)