projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added single step support for BD engine
[rocksndiamonds.git]
/
src
/
game_bd
/
bd_graphics.c
diff --git
a/src/game_bd/bd_graphics.c
b/src/game_bd/bd_graphics.c
index aa091ba131b44404613d50aebcdde97ce18ee4d6..5da166f2f5bed8aaf28db0990fa03b181acf4782 100644
(file)
--- a/
src/game_bd/bd_graphics.c
+++ b/
src/game_bd/bd_graphics.c
@@
-363,6
+363,11
@@
static boolean surface_has_c64_colors(SDL_Surface *surface)
return has_c64_colors;
}
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)
{
// 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)
{
@@
-466,8
+471,14
@@
static Bitmap *get_tile_bitmap_c64(GdCave *cave, SDL_Surface *surface)
set_surface_palette_color(surface, 7, 0);
set_surface_palette_color(surface, 8, 0);
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
// 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 tile_bitmap_c64;
}
@@
-532,6
+543,12
@@
static inline boolean el_player(const int element)
return (gd_elements[element & O_MASK].properties & P_PLAYER) != 0;
}
return (gd_elements[element & O_MASK].properties & P_PLAYER) != 0;
}
+// returns true if the element is walkable
+static inline boolean el_walkable(const int element)
+{
+ return (gd_elements[element & O_MASK].properties & P_WALKABLE) != 0;
+}
+
// returns true if the element is diggable
static inline boolean el_diggable(const int element)
{
// returns true if the element is diggable
static inline boolean el_diggable(const int element)
{
@@
-625,6
+642,10
@@
static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d
if (cave->player_state == GD_PL_EXITED)
use_smooth_movements = FALSE;
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)
{
#if DO_GFX_SANITY_CHECK
if (use_native_bd_graphics_engine() && !setup.small_game_graphics && !program.headless)
{
@@
-675,6
+696,7
@@
static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d
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 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 = el_player(tile_from);
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 = el_player(tile_from);
@@
-683,6
+705,11
@@
static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d
old_x <= cave->x2 &&
old_y >= cave->y1 &&
old_y <= cave->y2);
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)
if (old_is_visible)
{
if (!old_is_moving && !old_is_player)
@@
-706,6
+733,11
@@
static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d
int itercycle = MIN(MAX(0, game->itermax - game->itercycle - 1), game->itermax);
int shift = cell_size * itercycle / game->itermax;
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);
blit_bitmap(tile_bitmap, dest, g->src_x, g->src_y, cell_size, cell_size,
sx + dx * shift, sy + dy * shift);