sx -= (full_xsize < SXSIZE ? (SXSIZE - full_xsize) / 2 : 0);
int px = sx - SX;
- int lx = px / TILESIZE_VAR;
+ int lx = (px + TILESIZE_VAR) / TILESIZE_VAR - 1;
return lx;
}
sy -= (full_ysize < SYSIZE ? (SYSIZE - full_ysize) / 2 : 0);
int py = sy - SY;
- int ly = py / TILESIZE_VAR;
+ int ly = (py + TILESIZE_VAR) / TILESIZE_VAR - 1;
return ly;
}
{
int sx = SCREENX(x);
int sy = SCREENY(y);
+ char *token_name;
printf_line("-", 79);
printf("Field Info: SCREEN(%d, %d), LEVEL(%d, %d)\n", sx, sy, x, y);
return;
}
- printf(" Feld: %d\t['%s']\n", Feld[x][y],
- element_info[Feld[x][y]].token_name);
+ token_name = element_info[Feld[x][y]].token_name;
+
+ printf(" Feld: %d\t['%s']\n", Feld[x][y], token_name);
printf(" Back: %s\n", print_if_not_empty(Back[x][y]));
printf(" Store: %s\n", print_if_not_empty(Store[x][y]));
printf(" Store2: %s\n", print_if_not_empty(Store2[x][y]));
}
}
+void DrawTileCursor(int draw_target)
+{
+ Bitmap *fade_bitmap;
+ Bitmap *src_bitmap;
+ int src_x, src_y;
+ int dst_x, dst_y;
+ int graphic = IMG_GLOBAL_TILE_CURSOR;
+ int frame = 0;
+ int tilesize = TILESIZE_VAR;
+ int width = tilesize;
+ int height = tilesize;
+
+ if (game_status != GAME_MODE_PLAYING)
+ return;
+
+ if (!tile_cursor.enabled ||
+ !tile_cursor.active)
+ return;
+
+ if (tile_cursor.moving)
+ {
+ int step = TILESIZE_VAR / 4;
+ int dx = tile_cursor.target_x - tile_cursor.x;
+ int dy = tile_cursor.target_y - tile_cursor.y;
+
+ if (ABS(dx) < step)
+ tile_cursor.x = tile_cursor.target_x;
+ else
+ tile_cursor.x += SIGN(dx) * step;
+
+ if (ABS(dy) < step)
+ tile_cursor.y = tile_cursor.target_y;
+ else
+ tile_cursor.y += SIGN(dy) * step;
+
+ if (tile_cursor.x == tile_cursor.target_x &&
+ tile_cursor.y == tile_cursor.target_y)
+ tile_cursor.moving = FALSE;
+ }
+
+ dst_x = tile_cursor.x;
+ dst_y = tile_cursor.y;
+
+ frame = getGraphicAnimationFrame(graphic, -1);
+
+ getSizedGraphicSource(graphic, frame, tilesize, &src_bitmap, &src_x, &src_y);
+
+ fade_bitmap =
+ (draw_target == DRAW_TO_FADE_SOURCE ? gfx.fade_bitmap_source :
+ draw_target == DRAW_TO_FADE_TARGET ? gfx.fade_bitmap_target : NULL);
+
+ if (draw_target == DRAW_TO_SCREEN)
+ BlitToScreenMasked(src_bitmap, src_x, src_y, width, height, dst_x, dst_y);
+ else
+ BlitBitmapMasked(src_bitmap, fade_bitmap, src_x, src_y, width, height,
+ dst_x, dst_y);
+}
+
void BlitScreenToBitmap_RND(Bitmap *target_bitmap)
{
int fx = getFieldbufferOffsetX_RND();
SetScreenStates_BeforeFadingOut();
+ SetTileCursorActive(FALSE);
SetOverlayActive(FALSE);
#if 0
static int dxsize_last = -1, dysize_last = -1;
static int vx_last = -1, vy_last = -1;
static int vxsize_last = -1, vysize_last = -1;
+static int ex_last = -1, ey_last = -1;
+static int exsize_last = -1, eysize_last = -1;
boolean CheckIfGlobalBorderHasChanged()
{
vxsize_last != VXSIZE || vysize_last != VYSIZE)
return TRUE;
+ // redraw if position or size of editor area has changed
+ if (ex_last != EX || ey_last != EY ||
+ exsize_last != EXSIZE || eysize_last != EYSIZE)
+ return TRUE;
+
return FALSE;
}
redraw_mask = REDRAW_ALL;
}
+#define ONLY_REDRAW_GLOBAL_BORDER_IF_NEEDED 0
+
static void RedrawGlobalBorderIfNeeded()
{
+#if ONLY_REDRAW_GLOBAL_BORDER_IF_NEEDED
if (game_status == game_status_last)
return;
+#endif
// copy current draw buffer to later copy back areas that have not changed
if (game_status_last != GAME_MODE_TITLE)
BlitBitmap(backbuffer, bitmap_db_store_1, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
+#if ONLY_REDRAW_GLOBAL_BORDER_IF_NEEDED
if (CheckIfGlobalBorderRedrawIsNeeded())
+#endif
{
// redraw global screen border (or clear, if defined to be empty)
RedrawGlobalBorderFromBitmap(global_border_bitmap);
+ if (game_status == GAME_MODE_EDITOR)
+ DrawSpecialEditorDoor();
+
// copy previous playfield and door areas, if they are defined on both
// previous and current screen and if they still have the same size
BlitBitmap(bitmap_db_store_1, backbuffer,
dx_last, dy_last, DXSIZE, DYSIZE, DX, DY);
- if (vx_last != -1 && vy_last != -1 &&
- VX != -1 && VY != -1 &&
- vxsize_last == VXSIZE && vysize_last == VYSIZE)
- BlitBitmap(bitmap_db_store_1, backbuffer,
- vx_last, vy_last, VXSIZE, VYSIZE, VX, VY);
+ if (game_status != GAME_MODE_EDITOR)
+ {
+ if (vx_last != -1 && vy_last != -1 &&
+ VX != -1 && VY != -1 &&
+ vxsize_last == VXSIZE && vysize_last == VYSIZE)
+ BlitBitmap(bitmap_db_store_1, backbuffer,
+ vx_last, vy_last, VXSIZE, VYSIZE, VX, VY);
+ }
+ else
+ {
+ if (ex_last != -1 && ey_last != -1 &&
+ EX != -1 && EY != -1 &&
+ exsize_last == EXSIZE && eysize_last == EYSIZE)
+ BlitBitmap(bitmap_db_store_1, backbuffer,
+ ex_last, ey_last, EXSIZE, EYSIZE, EX, EY);
+ }
redraw_mask = REDRAW_ALL;
}
vy_last = VY;
vxsize_last = VXSIZE;
vysize_last = VYSIZE;
+ ex_last = EX;
+ ey_last = EY;
+ exsize_last = EXSIZE;
+ eysize_last = EYSIZE;
}
void ClearField()
BorderElement = EL_EMPTY;
+ /* the MM game engine does not use a visible border element */
+ if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
+ return;
+
for (y = 0; y < lev_fieldy && BorderElement == EL_EMPTY; y++)
{
for (x = 0; x < lev_fieldx; x++)
}
}
-void FloodFillLevel(int from_x, int from_y, int fill_element,
- short field[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
- int max_fieldx, int max_fieldy)
+void FloodFillLevelExt(int from_x, int from_y, int fill_element,
+ int max_array_fieldx, int max_array_fieldy,
+ short field[max_array_fieldx][max_array_fieldy],
+ int max_fieldx, int max_fieldy)
{
int i,x,y;
int old_element;
y = from_y + check[i][1];
if (IN_FIELD(x, y, max_fieldx, max_fieldy) && field[x][y] == old_element)
- FloodFillLevel(x, y, fill_element, field, max_fieldx, max_fieldy);
+ FloodFillLevelExt(x, y, fill_element, max_array_fieldx, max_array_fieldy,
+ field, max_fieldx, max_fieldy);
}
safety--;
}
+void FloodFillLevel(int from_x, int from_y, int fill_element,
+ short field[MAX_LEV_FIELDX][MAX_LEV_FIELDY],
+ int max_fieldx, int max_fieldy)
+{
+ FloodFillLevelExt(from_x, from_y, fill_element,
+ MAX_LEV_FIELDX, MAX_LEV_FIELDY, field,
+ max_fieldx, max_fieldy);
+}
+
void SetRandomAnimationValue(int x, int y)
{
gfx.anim_random_frame = GfxRandom[x][y];
MarkTileDirty(x / tilesize, y / tilesize);
}
+void DrawSizedGraphicThruMask(int x, int y, int graphic, int frame,
+ int tilesize)
+{
+ DrawSizedGraphicThruMaskExt(drawto, SX + x * tilesize, SY + y * tilesize,
+ graphic, frame, tilesize);
+ MarkTileDirty(x / tilesize, y / tilesize);
+}
+
void DrawSizedGraphicExt(DrawBuffer *d, int x, int y, int graphic, int frame,
int tilesize)
{
BlitBitmap(src_bitmap, d, src_x, src_y, tilesize, tilesize, x, y);
}
+void DrawSizedGraphicThruMaskExt(DrawBuffer *d, int x, int y, int graphic,
+ int frame, int tilesize)
+{
+ Bitmap *src_bitmap;
+ int src_x, src_y;
+
+ getSizedGraphicSource(graphic, frame, tilesize, &src_bitmap, &src_x, &src_y);
+ BlitBitmapMasked(src_bitmap, d, src_x, src_y, tilesize, tilesize, x, y);
+}
+
void DrawMiniGraphic(int x, int y, int graphic)
{
DrawMiniGraphicExt(drawto, SX + x * MINI_TILEX,SY + y * MINI_TILEY, graphic);
}
}
-void DrawSizedWall_MM(int dst_x, int dst_y, int element, int tilesize,
- int (*el2img_function)(int))
+static void DrawSizedWallExt_MM(int dst_x, int dst_y, int element, int tilesize,
+ int (*el2img_function)(int), boolean masked,
+ int element_bits_draw)
{
int element_base = map_mm_wall_element(element);
int element_bits = (IS_DF_WALL(element) ?
element - EL_DF_WALL_START :
- element - EL_MM_WALL_START) & 0x000f;
+ IS_MM_WALL(element) ?
+ element - EL_MM_WALL_START : EL_EMPTY) & 0x000f;
int graphic = el2img_function(element_base);
int tilesize_draw = tilesize / 2;
Bitmap *src_bitmap;
int dst_draw_x = dst_x + (i % 2) * tilesize_draw;
int dst_draw_y = dst_y + (i / 2) * tilesize_draw;
+ if (!(element_bits_draw & (1 << i)))
+ continue;
+
if (element_bits & (1 << i))
- BlitBitmap(src_bitmap, drawto, src_x, src_y, tilesize_draw, tilesize_draw,
- dst_draw_x, dst_draw_y);
+ {
+ if (masked)
+ BlitBitmapMasked(src_bitmap, drawto, src_x, src_y,
+ tilesize_draw, tilesize_draw, dst_draw_x, dst_draw_y);
+ else
+ BlitBitmap(src_bitmap, drawto, src_x, src_y,
+ tilesize_draw, tilesize_draw, dst_draw_x, dst_draw_y);
+ }
else
- ClearRectangle(drawto, dst_x, dst_y, tilesize_draw, tilesize_draw);
+ {
+ if (!masked)
+ ClearRectangle(drawto, dst_draw_x, dst_draw_y,
+ tilesize_draw, tilesize_draw);
+ }
}
}
-void DrawSizedElement(int x, int y, int element, int tilesize)
+void DrawSizedWallParts_MM(int x, int y, int element, int tilesize,
+ boolean masked, int element_bits_draw)
+{
+ DrawSizedWallExt_MM(SX + x * tilesize, SY + y * tilesize,
+ element, tilesize, el2edimg, masked, element_bits_draw);
+}
+
+void DrawSizedWall_MM(int dst_x, int dst_y, int element, int tilesize,
+ int (*el2img_function)(int))
+{
+ DrawSizedWallExt_MM(dst_x, dst_y, element, tilesize, el2img_function, FALSE,
+ 0x000f);
+}
+
+void DrawSizedElementExt(int x, int y, int element, int tilesize,
+ boolean masked)
{
if (IS_MM_WALL(element))
{
- DrawSizedWall_MM(SX + x * tilesize, SY + y * tilesize,
- element, tilesize, el2edimg);
+ DrawSizedWallExt_MM(SX + x * tilesize, SY + y * tilesize,
+ element, tilesize, el2edimg, masked, 0x000f);
}
else
{
int graphic = el2edimg(element);
- DrawSizedGraphic(x, y, graphic, 0, tilesize);
+ if (masked)
+ DrawSizedGraphicThruMask(x, y, graphic, 0, tilesize);
+ else
+ DrawSizedGraphic(x, y, graphic, 0, tilesize);
}
}
+void DrawSizedElement(int x, int y, int element, int tilesize)
+{
+ DrawSizedElementExt(x, y, element, tilesize, FALSE);
+}
+
+void DrawSizedElementThruMask(int x, int y, int element, int tilesize)
+{
+ DrawSizedElementExt(x, y, element, tilesize, TRUE);
+}
+
void DrawMiniElement(int x, int y, int element)
{
int graphic;
{
if (level_solved)
{
- SetDrawtoField(DRAW_TO_FIELDBUFFER);
+ /* the MM game engine does not use a special (scrollable) field buffer */
+ if (level.game_engine_type != GAME_ENGINE_TYPE_MM)
+ SetDrawtoField(DRAW_TO_FIELDBUFFER);
HandleGameActions();
break;
case KSYM_Return:
+ case KSYM_y:
+ case KSYM_Y:
#if defined(TARGET_SDL2)
case KSYM_Select:
case KSYM_Menu:
break;
case KSYM_Escape:
+ case KSYM_n:
+ case KSYM_N:
#if defined(TARGET_SDL2)
case KSYM_Back:
#if defined(KSYM_FastForward)
door_state &= ~DOOR_CLOSE_ALL;
}
- if (game_status == GAME_MODE_EDITOR)
+ if (game_status == GAME_MODE_EDITOR && !(door_state & DOOR_FORCE_ANIM))
door_state |= DOOR_NO_DELAY;
if (door_state & DOOR_ACTION)
{
/* opening door sound has priority over simultaneously closing door */
if (door_state & (DOOR_OPEN_1 | DOOR_OPEN_2))
+ {
PlayMenuSoundStereo(SND_DOOR_OPENING, SOUND_MIDDLE);
+
+ if (door_state & DOOR_OPEN_1)
+ PlayMenuSoundStereo(SND_DOOR_1_OPENING, SOUND_MIDDLE);
+ if (door_state & DOOR_OPEN_2)
+ PlayMenuSoundStereo(SND_DOOR_2_OPENING, SOUND_MIDDLE);
+ }
else if (door_state & (DOOR_CLOSE_1 | DOOR_CLOSE_2))
+ {
PlayMenuSoundStereo(SND_DOOR_CLOSING, SOUND_MIDDLE);
+
+ if (door_state & DOOR_CLOSE_1)
+ PlayMenuSoundStereo(SND_DOOR_1_CLOSING, SOUND_MIDDLE);
+ if (door_state & DOOR_CLOSE_2)
+ PlayMenuSoundStereo(SND_DOOR_2_CLOSING, SOUND_MIDDLE);
+ }
}
for (k = start; k < num_move_steps; k++)
if (door_part_done_all)
break;
}
+
+ if (!(door_state & DOOR_NO_DELAY))
+ {
+ /* wait for specified door action post delay */
+ if (door_state & DOOR_ACTION_1 && door_state & DOOR_ACTION_2)
+ Delay(MAX(door_1.post_delay, door_2.post_delay));
+ else if (door_state & DOOR_ACTION_1)
+ Delay(door_1.post_delay);
+ else if (door_state & DOOR_ACTION_2)
+ Delay(door_2.post_delay);
+ }
}
if (door_state & DOOR_ACTION_1)
EL_EMPTY);
}
+int map_action_MM_to_RND(int action_mm)
+{
+ /* all MM actions are defined to exactly match their RND counterparts */
+ return action_mm;
+}
+
+int map_sound_MM_to_RND(int sound_mm)
+{
+ switch (sound_mm)
+ {
+ case SND_MM_GAME_LEVELTIME_CHARGING:
+ return SND_GAME_LEVELTIME_CHARGING;
+
+ case SND_MM_GAME_HEALTH_CHARGING:
+ return SND_GAME_HEALTH_CHARGING;
+
+ default:
+ return SND_UNDEFINED;
+ }
+}
+
int map_mm_wall_element(int element)
{
return (element >= EL_MM_STEEL_WALL_START &&
element);
}
+int map_mm_wall_element_editor(int element)
+{
+ switch (element)
+ {
+ case EL_MM_STEEL_WALL: return EL_MM_STEEL_WALL_START;
+ case EL_MM_WOODEN_WALL: return EL_MM_WOODEN_WALL_START;
+ case EL_MM_ICE_WALL: return EL_MM_ICE_WALL_START;
+ case EL_MM_AMOEBA_WALL: return EL_MM_AMOEBA_WALL_START;
+ case EL_DF_STEEL_WALL: return EL_DF_STEEL_WALL_START;
+ case EL_DF_WOODEN_WALL: return EL_DF_WOODEN_WALL_START;
+
+ default: return element;
+ }
+}
+
int get_next_element(int element)
{
switch (element)
}
}
+void CheckSaveEngineSnapshot_MM(boolean element_clicked,
+ boolean button_released)
+{
+ if (button_released)
+ {
+ if (game.snapshot.mode == SNAPSHOT_MODE_EVERY_MOVE)
+ CheckSaveEngineSnapshotToList();
+ }
+ else if (element_clicked)
+ {
+ if (game.snapshot.mode != SNAPSHOT_MODE_EVERY_MOVE)
+ CheckSaveEngineSnapshotToList();
+
+ game.snapshot.changed_action = TRUE;
+ }
+}
+
void CheckSingleStepMode_EM(byte action[MAX_PLAYERS], int frame,
boolean any_player_moving,
boolean any_player_snapping,
CheckSaveEngineSnapshot_SP(murphy_is_waiting, murphy_is_dropping);
}
+void CheckSingleStepMode_MM(boolean element_clicked,
+ boolean button_released)
+{
+ if (tape.single_step && tape.recording && !tape.pausing)
+ if (button_released)
+ TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+
+ CheckSaveEngineSnapshot_MM(element_clicked, button_released);
+}
+
void getGraphicSource_SP(struct GraphicInfo_SP *g_sp,
int graphic, int sync_frame, int x, int y)
{
SetFontStatus(-1);
}
+boolean CheckIfPlayfieldViewportHasChanged()
+{
+ // if game status has not changed, playfield viewport has not changed either
+ if (game_status == game_status_last)
+ return FALSE;
+
+ // check if playfield viewport has changed with current game status
+ struct RectWithBorder *vp_playfield = &viewport.playfield[game_status];
+ int new_real_sx = vp_playfield->x;
+ int new_real_sy = vp_playfield->y;
+ int new_full_sxsize = vp_playfield->width;
+ int new_full_sysize = vp_playfield->height;
+
+ return (new_real_sx != REAL_SX ||
+ new_real_sy != REAL_SY ||
+ new_full_sxsize != FULL_SXSIZE ||
+ new_full_sysize != FULL_SYSIZE);
+}
+
+boolean CheckIfGlobalBorderOrPlayfieldViewportHasChanged()
+{
+ return (CheckIfGlobalBorderHasChanged() ||
+ CheckIfPlayfieldViewportHasChanged());
+}
+
void ChangeViewportPropertiesIfNeeded()
{
+ boolean use_mini_tilesize = (level.game_engine_type == GAME_ENGINE_TYPE_MM ?
+ FALSE : setup.small_game_graphics);
int gfx_game_mode = game_status;
int gfx_game_mode2 = (game_status == GAME_MODE_EDITOR ? GAME_MODE_DEFAULT :
game_status);
int new_ey = vp_door_3->y;
int new_exsize = vp_door_3->width;
int new_eysize = vp_door_3->height;
- int new_tilesize_var =
- (setup.small_game_graphics ? MINI_TILESIZE : game.tile_size);
-
+ int new_tilesize_var = (use_mini_tilesize ? MINI_TILESIZE : game.tile_size);
int tilesize = (gfx_game_mode == GAME_MODE_PLAYING ? new_tilesize_var :
gfx_game_mode == GAME_MODE_EDITOR ? MINI_TILESIZE : TILESIZE);
int new_scr_fieldx = new_sxsize / tilesize;