MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DrawSpriteViewport

Function DrawSpriteViewport

src/gfx.cpp:1006–1023  ·  view source on GitHub ↗

* Draw a sprite in a viewport. * @param img Image number to draw * @param pal Palette to use. * @param x Left coordinate of image in viewport, scaled by zoom * @param y Top coordinate of image in viewport, scaled by zoom * @param sub If available, draw only specified part of the sprite */

Source from the content-addressed store, hash-verified

1004 * @param sub If available, draw only specified part of the sprite
1005 */
1006void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub)
1007{
1008 SpriteID real_sprite = GB(img, 0, SPRITE_WIDTH);
1009 if (HasBit(img, PALETTE_MODIFIER_TRANSPARENT)) {
1010 pal = GB(pal, 0, PALETTE_WIDTH);
1011 _colour_remap_ptr = GetNonSprite(pal, SpriteType::Recolour) + 1;
1012 GfxMainBlitterViewport(GetSprite(real_sprite, SpriteType::Normal), x, y, pal == PALETTE_TO_TRANSPARENT ? BlitterMode::Transparent : BlitterMode::TransparentRemap, sub, real_sprite);
1013 } else if (pal != PAL_NONE) {
1014 if (HasBit(pal, PALETTE_TEXT_RECOLOUR)) {
1015 SetColourRemap((TextColour)GB(pal, 0, PALETTE_WIDTH));
1016 } else {
1017 _colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1;
1018 }
1019 GfxMainBlitterViewport(GetSprite(real_sprite, SpriteType::Normal), x, y, GetBlitterMode(pal), sub, real_sprite);
1020 } else {
1021 GfxMainBlitterViewport(GetSprite(real_sprite, SpriteType::Normal), x, y, BlitterMode::Normal, sub, real_sprite);
1022 }
1023}
1024
1025/**
1026 * Draw a sprite, not in a viewport

Callers 2

ViewportDrawTileSpritesFunction · 0.85

Calls 7

GBFunction · 0.85
HasBitFunction · 0.85
GetNonSpriteFunction · 0.85
GfxMainBlitterViewportFunction · 0.85
GetSpriteFunction · 0.85
SetColourRemapFunction · 0.85
GetBlitterModeFunction · 0.85

Tested by

no test coverage detected