00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef SPRITE_H
00013 #define SPRITE_H
00014
00015 #include "transparency.h"
00016
00017 #include "table/sprites.h"
00018
00019 #define GENERAL_SPRITE_COLOUR(colour) ((colour) + PALETTE_RECOLOUR_START)
00020 #define COMPANY_SPRITE_COLOUR(owner) (GENERAL_SPRITE_COLOUR(_company_colours[owner]))
00021
00022
00023
00024
00025
00027 struct DrawTileSeqStruct {
00028 int8 delta_x;
00029 int8 delta_y;
00030 int8 delta_z;
00031 byte size_x;
00032 byte size_y;
00033 byte size_z;
00034 PalSpriteID image;
00035 };
00036
00038 struct DrawTileSprites {
00039 PalSpriteID ground;
00040 const DrawTileSeqStruct *seq;
00041 };
00042
00047 struct DrawBuildingsTileStruct {
00048 PalSpriteID ground;
00049 PalSpriteID building;
00050 byte subtile_x;
00051 byte subtile_y;
00052 byte width;
00053 byte height;
00054 byte dz;
00055 byte draw_proc;
00056 };
00057
00059 #define foreach_draw_tile_seq(idx, list) for (idx = list; ((byte) idx->delta_x) != 0x80; idx++)
00060
00061 void DrawCommonTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 orig_offset, uint32 newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned);
00062 void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 orig_offset, uint32 newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned);
00063
00069 static inline void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
00070 {
00071 DrawCommonTileSeq(ti, dts, to, total_offset, newgrf_offset, default_palette, false);
00072 }
00073
00079 static inline void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
00080 {
00081 DrawCommonTileSeqInGUI(x, y, dts, total_offset, newgrf_offset, default_palette, false);
00082 }
00083
00087 static inline void DrawOrigTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, PaletteID default_palette)
00088 {
00089 DrawCommonTileSeq(ti, dts, to, 0, 0, default_palette, false);
00090 }
00091
00095 static inline void DrawOrigTileSeqInGUI(int x, int y, const DrawTileSprites *dts, PaletteID default_palette)
00096 {
00097 DrawCommonTileSeqInGUI(x, y, dts, 0, 0, default_palette, false);
00098 }
00099
00104 static inline void DrawNewGRFTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, uint32 stage, PaletteID default_palette)
00105 {
00106 DrawCommonTileSeq(ti, dts, to, 0, stage, default_palette, true);
00107 }
00108
00113 static inline void DrawNewGRFTileSeqInGUI(int x, int y, const DrawTileSprites *dts, uint32 stage, PaletteID default_palette)
00114 {
00115 DrawCommonTileSeqInGUI(x, y, dts, 0, stage, default_palette, true);
00116 }
00117
00129 static inline PaletteID SpriteLayoutPaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
00130 {
00131 if (HasBit(image, PALETTE_MODIFIER_TRANSPARENT) || HasBit(image, PALETTE_MODIFIER_COLOUR)) {
00132 return (pal != 0 ? pal : default_pal);
00133 } else {
00134 return PAL_NONE;
00135 }
00136 }
00137
00148 static inline PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
00149 {
00150 if (HasBit(image, PALETTE_MODIFIER_COLOUR)) {
00151 return (pal != 0 ? pal : default_pal);
00152 } else {
00153 return PAL_NONE;
00154 }
00155 }
00156
00157 #endif