// quit, global variable which is set to true if the application should quit
boolean gd_quit = FALSE;
-const byte *gd_keystate;
-
static int cell_size = 0;
// graphic info for game objects/frames and players/actions/frames
play_area_h = h;
}
-void gd_init_keystate(void)
+void gd_init_play_area(void)
{
set_play_area(SXSIZE, SYSIZE);
-
- gd_keystate = SDL_GetKeyboardState(NULL);
}
/*
return has_c64_colors;
}
+boolean gd_bitmap_has_c64_colors(Bitmap *bitmap)
+{
+ return surface_has_c64_colors(bitmap->surface);
+}
+
// sets one of the colors in the indexed palette of an sdl surface to a GdColor.
static void set_surface_palette_color(SDL_Surface *surface, int index, GdColor col)
{
set_surface_palette_color(surface, 7, 0);
set_surface_palette_color(surface, 8, 0);
+ // set background color to be transparent for masked tile bitmap
+ int bg_color = gd_color_get_rgb(cave->color0);
+ int bg_r = gd_color_get_r(bg_color);
+ int bg_g = gd_color_get_g(bg_color);
+ int bg_b = gd_color_get_b(bg_color);
+
// create bitmap from C64 surface
- tile_bitmap_c64 = SDLGetBitmapFromSurface(surface);
+ tile_bitmap_c64 = SDLGetBitmapFromSurface_WithMaskedColor(surface, bg_r, bg_g, bg_b);
return tile_bitmap_c64;
}
return bitmap;
}
-#if DO_GFX_SANITY_CHECK
-// workaround to prevent variable name scope problem
-static boolean use_native_bd_graphics_engine(void)
+// returns true if the element is a player
+static inline boolean el_player(const int element)
{
- return game.use_native_bd_graphics_engine;
+ return (gd_elements[element & O_MASK].properties & P_PLAYER) != 0;
}
-#endif
-// returns true if the element is a player
-static inline boolean is_player(const int element)
+// returns true if the element is walkable
+static inline boolean el_walkable(const int element)
{
- return (gd_elements[element & O_MASK].properties & P_PLAYER) != 0;
+ return (gd_elements[element & O_MASK].properties & P_WALKABLE) != 0;
}
// returns true if the element is diggable
-static inline boolean is_diggable(const int element)
+static inline boolean el_diggable(const int element)
{
return (gd_elements[element & O_MASK].properties & P_DIGGABLE) != 0;
}
+#if 0
// returns true if the element is collectible
-static inline boolean is_collectible(const int element)
+static inline boolean el_collectible(const int element)
{
return (gd_elements[element & O_MASK].properties & P_COLLECTIBLE) != 0;
}
+#endif
// returns true if the element is pushable
-static inline boolean is_pushable(const int element)
+static inline boolean el_pushable(const int element)
{
return (gd_elements[element & O_MASK].properties & P_PUSHABLE) != 0;
}
// returns true if the element can move
-static inline boolean can_move(const int element)
+static inline boolean el_can_move(const int element)
{
return (gd_elements[element & O_MASK].properties & P_CAN_MOVE) != 0;
}
// returns true if the element can fall
-static inline boolean can_fall(const int element)
+static inline boolean el_falling(const int element)
+{
+ return (gd_elements[element & O_MASK].properties & P_FALLING) != 0;
+}
+
+// returns true if the element is growing
+static inline boolean el_growing(const int element)
{
- return (gd_elements[element & O_MASK].properties & P_CAN_FALL) != 0;
+ return (gd_elements[element & O_MASK].properties & P_GROWING) != 0;
}
// returns true if the element is exploding
-static inline boolean is_explosion(const int element)
+static inline boolean el_explosion(const int element)
{
return (gd_elements[element & O_MASK].properties & P_EXPLOSION) != 0;
}
int frame = game->animcycle;
struct GraphicInfo_BD *g = &graphic_info_bd_object[tile][frame];
Bitmap *tile_bitmap = gd_get_tile_bitmap(g->bitmap);
- boolean is_movable = (can_move(tile) || can_fall(tile) || is_pushable(tile) || is_player(tile));
- boolean is_movable_or_diggable = (is_movable || is_diggable(game->last_element_buffer[y][x]));
+ boolean is_movable = (el_can_move(tile) || el_falling(tile) || el_pushable(tile) ||
+ el_player(tile));
+ boolean is_movable_or_diggable = (is_movable || el_diggable(game->last_element_buffer[y][x]));
boolean is_moving = (is_movable_or_diggable && dir != GD_MV_STILL);
- boolean use_smooth_movements =
- ((setup.bd_smooth_movements == TRUE) ||
- (setup.bd_smooth_movements == AUTO && !use_native_bd_graphics_engine()));
+ boolean use_smooth_movements = use_bd_smooth_movements();
+
+ // do not use smooth movement animation for growing or exploding game elements
+ if ((el_growing(tile) || el_explosion(tile)) && dir != GD_MV_STILL)
+ {
+ int dx = (dir == GD_MV_LEFT ? +1 : dir == GD_MV_RIGHT ? -1 : 0);
+ int dy = (dir == GD_MV_UP ? +1 : dir == GD_MV_DOWN ? -1 : 0);
+ int old_x = cave->getx(cave, x + dx, y + dy);
+ int old_y = cave->gety(cave, x + dx, y + dy);
+ int last_tile_from = game->last_element_buffer[old_y][old_x] & ~SKIPPED;
+ boolean old_is_player = el_player(last_tile_from);
+
+ // check special case of player running into enemy from top or left side
+ if (old_is_player)
+ {
+ game->element_buffer[y][x] = (dir == GD_MV_LEFT ? O_PLAYER_LEFT :
+ dir == GD_MV_RIGHT ? O_PLAYER_RIGHT :
+ dir == GD_MV_UP ? O_PLAYER_UP :
+ dir == GD_MV_DOWN ? O_PLAYER_DOWN : O_PLAYER);
+
+ // draw player running into explosion (else player would disappear immediately)
+ gd_drawcave_tile(dest, game, x, y, draw_masked);
+
+ game->element_buffer[y][x] = tile;
+ }
- // do not use smooth movement animation for exploding game elements (like player)
- if (is_explosion(tile) && dir != GD_MV_STILL)
use_smooth_movements = FALSE;
+ }
// do not use smooth movement animation for player entering exit (engine stopped)
if (cave->player_state == GD_PL_EXITED)
use_smooth_movements = FALSE;
+ // do not use smooth movement animation for player stirring the pot
+ if (tile == O_PLAYER_STIRRING)
+ use_smooth_movements = FALSE;
+
#if DO_GFX_SANITY_CHECK
if (use_native_bd_graphics_engine() && !setup.small_game_graphics && !program.headless)
{
int tile_last = game->last_element_buffer[y][x];
// only redraw previous game element if it is diggable (like dirt etc.)
- if (!is_diggable(tile_last))
+ if (!el_diggable(tile_last))
tile_last = O_SPACE;
struct GraphicInfo_BD *g_old = &graphic_info_bd_object[tile_last][frame];
int old_x = cave->getx(cave, x + dx, y + dy);
int old_y = cave->gety(cave, x + dx, y + dy);
int tile_from = game->element_buffer[old_y][old_x] & ~SKIPPED; // should never be skipped
+ int tile_last = game->last_element_buffer[y][x] & ~SKIPPED;
struct GraphicInfo_BD *g_from = &graphic_info_bd_object[tile_from][frame];
Bitmap *tile_bitmap_from = gd_get_tile_bitmap(g_from->bitmap);
- boolean old_is_player = is_player(tile_from);
+ boolean old_is_player = el_player(tile_from);
boolean old_is_moving = (game->dir_buffer[old_y][old_x] != GD_MV_STILL);
boolean old_is_visible = (old_x >= cave->x1 &&
old_x <= cave->x2 &&
old_y >= cave->y1 &&
old_y <= cave->y2);
+
+ // never treat empty space as "moving" (may happen if player is snap-pushing element)
+ if (tile_from == O_SPACE)
+ old_is_moving = FALSE;
+
if (old_is_visible)
{
if (!old_is_moving && !old_is_player)
int itercycle = MIN(MAX(0, game->itermax - game->itercycle - 1), game->itermax);
int shift = cell_size * itercycle / game->itermax;
+ // when drawing player over walkable elements, always use masked drawing
+ // (does not use masking if moving from walkable to diggable tiles etc.)
+ if (el_player(tile) && el_walkable(tile_from) && el_walkable(tile_last))
+ blit_bitmap = BlitBitmapMasked;
+
blit_bitmap(tile_bitmap, dest, g->src_x, g->src_y, cell_size, cell_size,
sx + dx * shift, sy + dy * shift);