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 surface;
}
-Bitmap *SDLGetBitmapFromSurface(SDL_Surface *surface)
+Bitmap *SDLGetBitmapFromSurface_WithMaskedColor(SDL_Surface *surface, int r, int g, int b)
{
int width = surface->w;
int height = surface->h;
if (!SDLHasAlpha(bitmap->surface_masked) &&
!SDLHasColorKey(bitmap->surface_masked))
SDL_SetColorKey(bitmap->surface_masked, SET_TRANSPARENT_PIXEL,
- SDL_MapRGB(bitmap->surface_masked->format, 0x00, 0x00, 0x00));
+ SDL_MapRGB(bitmap->surface_masked->format, r, g, b));
return bitmap;
}
+Bitmap *SDLGetBitmapFromSurface(SDL_Surface *surface)
+{
+ return SDLGetBitmapFromSurface_WithMaskedColor(surface, 0x00, 0x00, 0x00);
+}
+
static SDL_Texture *SDLCreateTextureFromSurface(SDL_Surface *surface)
{
if (program.headless)
boolean SDLSetNativeSurface(SDL_Surface **);
SDL_Surface *SDLGetNativeSurface(SDL_Surface *);
SDL_Surface *SDLCreateNativeSurface(int, int, int);
+Bitmap *SDLGetBitmapFromSurface_WithMaskedColor(SDL_Surface *, int, int, int);
Bitmap *SDLGetBitmapFromSurface(SDL_Surface *);
void SDLCreateBitmapTextures(Bitmap *);
void SDLFreeBitmapTextures(Bitmap *);