summaryrefslogtreecommitdiff
path: root/src/gfx.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-10-06 18:45:51 +0000
committerrubidium <rubidium@openttd.org>2014-10-06 18:45:51 +0000
commit9c31ffd893efd0310e1276d179150ba2e9c2c4aa (patch)
tree9a71a2e1445452b4d96fbfc548a535d94c83c30f /src/gfx.cpp
parente5a92d7093ff354cac1101354e5e89e584b24bb4 (diff)
downloadopenttd-9c31ffd893efd0310e1276d179150ba2e9c2c4aa.tar.xz
(svn r26969) -Fix (r26869): black palette didn't work very well with unmasked 32bpp sprites
Diffstat (limited to 'src/gfx.cpp')
-rw-r--r--src/gfx.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 5a1f75abc..f6d9e0b98 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -783,6 +783,21 @@ Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
}
/**
+ * Helper function to get the blitter mode for different types of palettes.
+ * @param pal The palette to get the blitter mode for.
+ * @return The blitter mode associated with the palette.
+ */
+static BlitterMode GetBlitterMode(PaletteID pal)
+{
+ switch (pal) {
+ case PAL_NONE: return BM_NORMAL;
+ case PALETTE_CRASH: return BM_CRASH_REMAP;
+ case PALETTE_ALL_BLACK: return BM_BLACK_REMAP;
+ default: return BM_COLOUR_REMAP;
+ }
+}
+
+/**
* Draw a sprite in a viewport.
* @param img Image number to draw
* @param pal Palette to use.
@@ -802,7 +817,7 @@ void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSpri
} else {
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
}
- GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, pal == PALETTE_CRASH ? BM_CRASH_REMAP : BM_COLOUR_REMAP, sub, real_sprite);
+ GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, GetBlitterMode(pal), sub, real_sprite);
} else {
GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, BM_NORMAL, sub, real_sprite);
}
@@ -829,7 +844,7 @@ void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub,
} else {
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
}
- GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, pal == PALETTE_CRASH ? BM_CRASH_REMAP : BM_COLOUR_REMAP, sub, real_sprite, zoom);
+ GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, GetBlitterMode(pal), sub, real_sprite, zoom);
} else {
GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, BM_NORMAL, sub, real_sprite, zoom);
}