Silence uninitialised variable warnings in SSE blitters
[openttd/fttd.git] / src / zoom_func.h
blob5f1bf830d9e215f07893cff80cc24cec69c1013c
1 /* $Id$ */
3 /*
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/>.
8 */
10 /** @file zoom_func.h Functions related to zooming. */
12 #ifndef ZOOM_FUNC_H
13 #define ZOOM_FUNC_H
15 #include "zoom_type.h"
17 /**
18 * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
19 * When shifting right, value is rounded up
20 * @param value value to shift
21 * @param zoom zoom level to shift to
22 * @return shifted value
24 static inline int ScaleByZoom(int value, ZoomLevel zoom)
26 assert(zoom >= 0);
27 return value << zoom;
30 /**
31 * Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
32 * When shifting right, value is rounded up
33 * @param value value to shift
34 * @param zoom zoom level to shift to
35 * @return shifted value
37 static inline int UnScaleByZoom(int value, ZoomLevel zoom)
39 assert(zoom >= 0);
40 return (value + (1 << zoom) - 1) >> zoom;
43 /**
44 * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
45 * @param value value to shift
46 * @param zoom zoom level to shift to
47 * @return shifted value
49 static inline int ScaleByZoomLower(int value, ZoomLevel zoom)
51 assert(zoom >= 0);
52 return value << zoom;
55 /**
56 * Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
57 * @param value value to shift
58 * @param zoom zoom level to shift to
59 * @return shifted value
61 static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
63 assert(zoom >= 0);
64 return value >> zoom;
67 #endif /* ZOOM_FUNC_H */