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

Function DrawSprite

src/gfx.cpp:1034–1051  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1032 * @param zoom Zoom level of sprite
1033 */
1034void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
1035{
1036 SpriteID real_sprite = GB(img, 0, SPRITE_WIDTH);
1037 if (HasBit(img, PALETTE_MODIFIER_TRANSPARENT)) {
1038 pal = GB(pal, 0, PALETTE_WIDTH);
1039 _colour_remap_ptr = GetNonSprite(pal, SpriteType::Recolour) + 1;
1040 GfxMainBlitter(GetSprite(real_sprite, SpriteType::Normal), x, y, pal == PALETTE_TO_TRANSPARENT ? BlitterMode::Transparent : BlitterMode::TransparentRemap, sub, real_sprite, zoom);
1041 } else if (pal != PAL_NONE) {
1042 if (HasBit(pal, PALETTE_TEXT_RECOLOUR)) {
1043 SetColourRemap((TextColour)GB(pal, 0, PALETTE_WIDTH));
1044 } else {
1045 _colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), SpriteType::Recolour) + 1;
1046 }
1047 GfxMainBlitter(GetSprite(real_sprite, SpriteType::Normal), x, y, GetBlitterMode(pal), sub, real_sprite, zoom);
1048 } else {
1049 GfxMainBlitter(GetSprite(real_sprite, SpriteType::Normal), x, y, BlitterMode::Normal, sub, real_sprite, zoom);
1050 }
1051}
1052
1053/**
1054 * The code for setting up the blitter mode and sprite information before finally drawing the sprite.

Callers 15

DrawCargoIconMethod · 0.85
DrawSettingMethod · 0.85
DrawWidgetMethod · 0.85
DrawMouseCursorFunction · 0.85
DrawShipDepotSpriteFunction · 0.85
DrawWidgetMethod · 0.85
DrawTrainDepotSpriteFunction · 0.85
DrawRoadStopTileFunction · 0.85
DrawWidgetMethod · 0.85
DrawMethod · 0.85
DrawStationTileFunction · 0.85
DrawWidgetMethod · 0.85

Calls 7

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

Tested by

no test coverage detected