4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 /** @file smallmap_colours.h Colours used by smallmap. */
12 #ifndef SMALLMAP_COLOURS_H
13 #define SMALLMAP_COLOURS_H
15 #include "core/endian_func.hpp"
17 static const uint8 PC_ROUGH_LAND
= 0x52; ///< Dark green palette colour for rough land.
18 static const uint8 PC_GRASS_LAND
= 0x54; ///< Dark green palette colour for grass land.
19 static const uint8 PC_BARE_LAND
= 0x37; ///< Brown palette colour for bare land.
20 static const uint8 PC_FIELDS
= 0x25; ///< Light brown palette colour for fields.
21 static const uint8 PC_TREES
= 0x57; ///< Green palette colour for trees.
22 static const uint8 PC_WATER
= 0xCA; ///< Dark blue palette colour for water.
24 #define MKCOLOUR(x) TO_LE32X(x)
26 #define MKCOLOUR_XXXX(x) (MKCOLOUR(0x01010101) * (uint)(x))
27 #define MKCOLOUR_X0X0(x) (MKCOLOUR(0x01000100) * (uint)(x))
28 #define MKCOLOUR_0X0X(x) (MKCOLOUR(0x00010001) * (uint)(x))
29 #define MKCOLOUR_0XX0(x) (MKCOLOUR(0x00010100) * (uint)(x))
30 #define MKCOLOUR_X00X(x) (MKCOLOUR(0x01000001) * (uint)(x))
32 #define MKCOLOUR_XYXY(x, y) (MKCOLOUR_X0X0(x) | MKCOLOUR_0X0X(y))
33 #define MKCOLOUR_XYYX(x, y) (MKCOLOUR_X00X(x) | MKCOLOUR_0XX0(y))
35 #define MKCOLOUR_0000 MKCOLOUR_XXXX(0x00)
36 #define MKCOLOUR_0FF0 MKCOLOUR_0XX0(0xFF)
37 #define MKCOLOUR_F00F MKCOLOUR_X00X(0xFF)
38 #define MKCOLOUR_FFFF MKCOLOUR_XXXX(0xFF)
40 #include "table/heightmap_colours.h"
41 #include "table/darklight_colours.h"
43 /** Colour scheme of the smallmap. */
44 struct SmallMapColourScheme
{
45 uint32
*height_colours
; ///< Cached colours for each level in a map.
46 const uint32
*height_colours_base
; ///< Base table for determining the colours
47 size_t colour_count
; ///< The number of colours.
48 uint32 default_colour
; ///< Default colour of the land.
51 extern SmallMapColourScheme _heightmap_schemes
[];
58 static inline uint32
ApplyMask(uint32 colour
, const AndOr
*mask
)
60 return (colour
& mask
->mand
) | mask
->mor
;
63 /** Colour masks for "Contour" and "Routes" modes. */
64 static const AndOr _smallmap_contours_andor
[] = {
65 { MKCOLOUR_0000
, MKCOLOUR_FFFF
}, // MP_CLEAR
66 { MKCOLOUR_0XX0(PC_GREY
), MKCOLOUR_F00F
}, // MP_RAILWAY
67 { MKCOLOUR_0XX0(PC_BLACK
), MKCOLOUR_F00F
}, // MP_ROAD
68 { MKCOLOUR_0XX0(PC_DARK_RED
), MKCOLOUR_F00F
}, // MP_HOUSE
69 { MKCOLOUR_0000
, MKCOLOUR_FFFF
}, // MP_TREES
70 { MKCOLOUR_XXXX(PC_LIGHT_BLUE
), MKCOLOUR_0000
}, // MP_STATION
71 { MKCOLOUR_XXXX(PC_WATER
), MKCOLOUR_0000
}, // MP_WATER
72 { MKCOLOUR_0000
, MKCOLOUR_FFFF
}, // MP_VOID
73 { MKCOLOUR_XXXX(PC_DARK_RED
), MKCOLOUR_0000
}, // MP_INDUSTRY
74 { MKCOLOUR_0000
, MKCOLOUR_FFFF
}, // MP_TUNNELBRIDGE
75 { MKCOLOUR_0XX0(PC_DARK_RED
), MKCOLOUR_F00F
}, // MP_OBJECT
76 { MKCOLOUR_0XX0(PC_GREY
), MKCOLOUR_F00F
},
79 /** Colour masks for "Vehicles", "Industry", and "Vegetation" modes. */
80 static const AndOr _smallmap_vehicles_andor
[] = {
81 { MKCOLOUR_0000
, MKCOLOUR_FFFF
}, // MP_CLEAR
82 { MKCOLOUR_0XX0(PC_BLACK
), MKCOLOUR_F00F
}, // MP_RAILWAY
83 { MKCOLOUR_0XX0(PC_BLACK
), MKCOLOUR_F00F
}, // MP_ROAD
84 { MKCOLOUR_0XX0(PC_DARK_RED
), MKCOLOUR_F00F
}, // MP_HOUSE
85 { MKCOLOUR_0000
, MKCOLOUR_FFFF
}, // MP_TREES
86 { MKCOLOUR_0XX0(PC_BLACK
), MKCOLOUR_F00F
}, // MP_STATION
87 { MKCOLOUR_XXXX(PC_WATER
), MKCOLOUR_0000
}, // MP_WATER
88 { MKCOLOUR_0000
, MKCOLOUR_FFFF
}, // MP_VOID
89 { MKCOLOUR_XXXX(PC_DARK_RED
), MKCOLOUR_0000
}, // MP_INDUSTRY
90 { MKCOLOUR_0000
, MKCOLOUR_FFFF
}, // MP_TUNNELBRIDGE
91 { MKCOLOUR_0XX0(PC_DARK_RED
), MKCOLOUR_F00F
}, // MP_OBJECT
92 { MKCOLOUR_0XX0(PC_BLACK
), MKCOLOUR_F00F
},
95 static const uint32 _vegetation_clear_bits
[] = {
96 MKCOLOUR_XXXX(PC_GRASS_LAND
), ///< full grass
97 MKCOLOUR_XXXX(PC_ROUGH_LAND
), ///< rough land
98 MKCOLOUR_XXXX(PC_GREY
), ///< rocks
99 MKCOLOUR_XXXX(PC_FIELDS
), ///< fields
100 MKCOLOUR_XXXX(PC_LIGHT_BLUE
), ///< snow
101 MKCOLOUR_XXXX(PC_ORANGE
), ///< desert
102 MKCOLOUR_XXXX(PC_GRASS_LAND
), ///< unused
103 MKCOLOUR_XXXX(PC_GRASS_LAND
), ///< unused
106 #endif /* SMALLMAP_COLOURS_H */