14 #include "../stdafx.h" 15 #include "../zoom_func.h" 16 #include "../settings_type.h" 20 #include "../safeguards.h" 23 static FBlitter_32bppSSE2 iFBlitter_32bppSSE2;
41 memset(&sd, 0,
sizeof(sd));
42 uint all_sprites_size = 0;
43 for (
ZoomLevel z = zoom_min; z <= zoom_max; z++) {
45 sd.infos[z].sprite_width = src_sprite->
width;
46 sd.infos[z].sprite_offset = all_sprites_size;
47 sd.infos[z].sprite_line_size =
sizeof(
Colour) * src_sprite->
width +
sizeof(uint32) * META_LENGTH;
49 const uint rgba_size = sd.infos[z].sprite_line_size * src_sprite->
height;
50 sd.infos[z].mv_offset = all_sprites_size + rgba_size;
52 const uint mv_size =
sizeof(MapValue) * src_sprite->
width * src_sprite->
height;
53 all_sprites_size += rgba_size + mv_size;
56 Sprite *dst_sprite = (
Sprite *) allocator(
sizeof(
Sprite) +
sizeof(SpriteData) + all_sprites_size);
61 memcpy(dst_sprite->
data, &sd,
sizeof(SpriteData));
64 bool has_remap =
false;
65 bool has_anim =
false;
66 bool has_translucency =
false;
67 for (
ZoomLevel z = zoom_min; z <= zoom_max; z++) {
70 Colour *dst_rgba_line = (
Colour *) &dst_sprite->
data[
sizeof(SpriteData) + sd.infos[z].sprite_offset];
71 MapValue *dst_mv = (MapValue *) &dst_sprite->
data[
sizeof(SpriteData) + sd.infos[z].mv_offset];
72 for (uint y = src_sprite->
height; y != 0; y--) {
73 Colour *dst_rgba = dst_rgba_line + META_LENGTH;
74 for (uint x = src_sprite->
width; x != 0; x--) {
77 if (src->
a != 0 && src->
a != 255) has_translucency =
true;
85 const uint8 rgb_max =
max(src->
r,
max(src->
g, src->
b));
86 dst_mv->v = (rgb_max == 0) ? Blitter_32bppBase::DEFAULT_BRIGHTNESS : rgb_max;
90 dst_rgba->r = colour.r;
91 dst_rgba->g = colour.g;
92 dst_rgba->b = colour.b;
97 dst_mv->v = Blitter_32bppBase::DEFAULT_BRIGHTNESS;
101 *(uint16*) dst_mv = 0;
109 dst_rgba = dst_rgba_line + META_LENGTH;
110 uint32 nb_pix_transp = 0;
111 for (uint x = src_sprite->
width; x != 0; x--) {
112 if (dst_rgba->
a == 0) nb_pix_transp++;
116 (*dst_rgba_line).
data = nb_pix_transp;
118 Colour *nb_right = dst_rgba_line + 1;
119 dst_rgba_line = (
Colour*) ((byte*) dst_rgba_line + sd.infos[z].sprite_line_size);
122 dst_rgba = dst_rgba_line - 1;
124 for (uint x = src_sprite->
width; x != 0; x--) {
125 if (dst_rgba->
a == 0) nb_pix_transp++;
129 (*nb_right).
data = nb_pix_transp;
135 if (has_translucency) sd.flags |= SF_TRANSLUCENT;
136 if (!has_remap) sd.flags |= SF_NO_REMAP;
137 if (!has_anim) sd.flags |= SF_NO_ANIM;
138 memcpy(dst_sprite->
data, &sd,
sizeof(SpriteData));
ZoomLevelByte zoom_max
maximum zoom out level
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.
Structure for passing information from the sprite loader to the blitter.
uint16 height
Height of the sprite.
ZoomLevelByte zoom_min
minimum zoom out level
uint16 width
Width of the sprite.
ZoomLevel
All zoom levels we know.
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.
Index in the _palettes array from which all animations are taking places (table/palettes.h)