12 #include "../stdafx.h" 13 #include "../zoom_func.h" 14 #include "../settings_type.h" 18 #include "../safeguards.h" 21 static FBlitter_32bppSSE2 iFBlitter_32bppSSE2;
39 memset(&sd, 0,
sizeof(sd));
40 uint all_sprites_size = 0;
41 for (
ZoomLevel z = zoom_min; z <= zoom_max; z++) {
43 sd.infos[z].sprite_width = src_sprite->
width;
44 sd.infos[z].sprite_offset = all_sprites_size;
45 sd.infos[z].sprite_line_size =
sizeof(
Colour) * src_sprite->
width +
sizeof(uint32) * META_LENGTH;
47 const uint rgba_size = sd.infos[z].sprite_line_size * src_sprite->
height;
48 sd.infos[z].mv_offset = all_sprites_size + rgba_size;
50 const uint mv_size =
sizeof(MapValue) * src_sprite->
width * src_sprite->
height;
51 all_sprites_size += rgba_size + mv_size;
54 Sprite *dst_sprite = (
Sprite *) allocator(
sizeof(
Sprite) +
sizeof(SpriteData) + all_sprites_size);
59 memcpy(dst_sprite->
data, &sd,
sizeof(SpriteData));
62 bool has_remap =
false;
63 bool has_anim =
false;
64 bool has_translucency =
false;
65 for (
ZoomLevel z = zoom_min; z <= zoom_max; z++) {
68 Colour *dst_rgba_line = (
Colour *) &dst_sprite->
data[
sizeof(SpriteData) + sd.infos[z].sprite_offset];
69 MapValue *dst_mv = (MapValue *) &dst_sprite->
data[
sizeof(SpriteData) + sd.infos[z].mv_offset];
70 for (uint y = src_sprite->
height; y != 0; y--) {
71 Colour *dst_rgba = dst_rgba_line + META_LENGTH;
72 for (uint x = src_sprite->
width; x != 0; x--) {
75 if (src->
a != 0 && src->
a != 255) has_translucency =
true;
83 const uint8 rgb_max =
max(src->
r,
max(src->
g, src->
b));
84 dst_mv->v = (rgb_max == 0) ? Blitter_32bppBase::DEFAULT_BRIGHTNESS : rgb_max;
88 dst_rgba->r = colour.r;
89 dst_rgba->g = colour.g;
90 dst_rgba->b = colour.b;
95 dst_mv->v = Blitter_32bppBase::DEFAULT_BRIGHTNESS;
99 *(uint16*) dst_mv = 0;
107 dst_rgba = dst_rgba_line + META_LENGTH;
108 uint32 nb_pix_transp = 0;
109 for (uint x = src_sprite->
width; x != 0; x--) {
110 if (dst_rgba->
a == 0) nb_pix_transp++;
114 (*dst_rgba_line).
data = nb_pix_transp;
116 Colour *nb_right = dst_rgba_line + 1;
117 dst_rgba_line = (
Colour*) ((byte*) dst_rgba_line + sd.infos[z].sprite_line_size);
120 dst_rgba = dst_rgba_line - 1;
122 for (uint x = src_sprite->
width; x != 0; x--) {
123 if (dst_rgba->
a == 0) nb_pix_transp++;
127 (*nb_right).
data = nb_pix_transp;
133 if (has_translucency) sd.flags |= SF_TRANSLUCENT;
134 if (!has_remap) sd.flags |= SF_NO_REMAP;
135 if (!has_anim) sd.flags |= SF_NO_ANIM;
136 memcpy(dst_sprite->
data, &sd,
sizeof(SpriteData));
Data structure describing a sprite.
uint32 data
Conversion of the channel information to a 32 bit number.
uint8 a
colour channels in LE order
static Colour LookupColourInPalette(uint index)
Look up the colour in the current palette.
static T max(const T a, const T b)
Returns the maximum of two values.
Definition of a common pixel in OpenTTD's realm.
SpriteType type
The sprite type.
int16 y_offs
Number of pixels to shift the sprite downwards.
ClientSettings _settings_client
The current settings for this game.
int16 x_offs
The x-offset of where the sprite will be drawn.
SpriteLoader::CommonPixel * data
The sprite itself.
ZoomLevel zoom_max
maximum zoom out level
Structure for passing information from the sprite loader to the blitter.
uint16 height
Height of the sprite.
uint16 width
Width of the sprite.
uint16 width
Width of the sprite.
GUISettings gui
settings related to the GUI
uint16 height
Height of the sprite.
Functions related to SSE 32 bpp blitter.
int16 x_offs
Number of pixels to shift the sprite to the right.
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
int16 y_offs
The y-offset of where the sprite will be drawn.
ZoomLevel
All zoom levels we know.
ZoomLevel zoom_min
minimum zoom out level
Index in the _palettes array from which all animations are taking places (table/palettes.h)