OpenTTD Source: src/video/allegro_v.cpp Source File

OpenTTD Source 14.0-beta1

allegro_v.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
7
15 #ifdef WITH_ALLEGRO
16
17 #include "../stdafx.h"
18 #include "../openttd.h"
19 #include "../error_func.h"
20 #include "../gfx_func.h"
21 #include "../blitter/factory.hpp"
22 #include "../core/random_func.hpp"
23 #include "../core/math_func.hpp"
24 #include "../framerate_type.h"
25 #include "../progress.h"
26 #include "../thread.h"
27 #include "../window_func.h"
28 #include "allegro_v.h"
29 #include <allegro.h>
30
31 #include "../safeguards.h"
32
33 #ifdef _DEBUG
34 /* Allegro replaces SEGV/ABRT signals meaning that the debugger will never
35 * be triggered, so rereplace the signals and make the debugger useful. */
36 #include <signal.h>
37 #endif
38
39 static FVideoDriver_Allegro iFVideoDriver_Allegro;
40
41 static BITMAP *_allegro_screen;
42
43 #define MAX_DIRTY_RECTS 100
44 static PointDimension _dirty_rects[MAX_DIRTY_RECTS];
45 static int _num_dirty_rects;
46 static Palette _local_palette;
47
48 void VideoDriver_Allegro::MakeDirty(int left, int top, int width, int height)
49 {
50 if (_num_dirty_rects < MAX_DIRTY_RECTS) {
51 _dirty_rects[_num_dirty_rects].x = left;
52 _dirty_rects[_num_dirty_rects].y = top;
53 _dirty_rects[_num_dirty_rects].width = width;
54 _dirty_rects[_num_dirty_rects].height = height;
55 }
56 _num_dirty_rects++;
57 }
58
59 void VideoDriver_Allegro::Paint()
60 {
61 PerformanceMeasurer framerate(PFE_VIDEO);
62
63 int n = _num_dirty_rects;
64 if (n == 0) return;
65
66 _num_dirty_rects = 0;
67 if (n > MAX_DIRTY_RECTS) {
68 blit(_allegro_screen, screen, 0, 0, 0, 0, _allegro_screen->w, _allegro_screen->h);
69 return;
70 }
71
72 for (int i = 0; i < n; i++) {
73 blit(_allegro_screen, screen, _dirty_rects[i].x, _dirty_rects[i].y, _dirty_rects[i].x, _dirty_rects[i].y, _dirty_rects[i].width, _dirty_rects[i].height);
74 }
75 }
76
77
78 static void UpdatePalette(uint start, uint count)
79 {
80 static PALETTE pal;
81
82 uint end = start + count;
83 for (uint i = start; i != end; i++) {
84 pal[i].r = _local_palette.palette[i].r / 4;
85 pal[i].g = _local_palette.palette[i].g / 4;
86 pal[i].b = _local_palette.palette[i].b / 4;
87 pal[i].filler = 0;
88 }
89
90 set_palette_range(pal, start, end - 1, 1);
91 }
92
93 static void InitPalette()
94 {
95 UpdatePalette(0, 256);
96 }
97
98 void VideoDriver_Allegro::CheckPaletteAnim()
99 {
100 if (!CopyPalette(_local_palette)) return;
101
102 Blitter *blitter = BlitterFactory::GetCurrentBlitter();
103
104 switch (blitter->UsePaletteAnimation()) {
105 case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND:
106 UpdatePalette(_local_palette.first_dirty, _local_palette.count_dirty);
107 break;
108
109 case Blitter::PALETTE_ANIMATION_BLITTER:
110 blitter->PaletteAnimate(_local_palette);
111 break;
112
113 case Blitter::PALETTE_ANIMATION_NONE:
114 break;
115
116 default:
117 NOT_REACHED();
118 }
119 }
120
121 static const Dimension default_resolutions[] = {
122 { 640, 480},
123 { 800, 600},
124 {1024, 768},
125 {1152, 864},
126 {1280, 800},
127 {1280, 960},
128 {1280, 1024},
129 {1400, 1050},
130 {1600, 1200},
131 {1680, 1050},
132 {1920, 1200}
133 };
134
135 static void GetVideoModes()
136 {
137 /* Need to set a gfx_mode as there is NO other way to autodetect for
138 * cards ourselves... and we need a card to get the modes. */
139 set_gfx_mode(_fullscreen ? GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
140
141 _resolutions.clear();
142
143 GFX_MODE_LIST *mode_list = get_gfx_mode_list(gfx_driver->id);
144 if (mode_list == nullptr) {
145 _resolutions.assign(std::begin(default_resolutions), std::end(default_resolutions));
146 return;
147 }
148
149 GFX_MODE *modes = mode_list->mode;
150
151 for (int i = 0; modes[i].bpp != 0; i++) {
152 uint w = modes[i].width;
153 uint h = modes[i].height;
154 if (w < 640 || h < 480) continue;
155 if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(w, h)) != _resolutions.end()) continue;
156 _resolutions.emplace_back(w, h);
157 }
158
159 SortResolutions();
160
161 destroy_gfx_mode_list(mode_list);
162 }
163
164 static void GetAvailableVideoMode(uint *w, uint *h)
165 {
166 /* No video modes, so just try it and see where it ends */
167 if (_resolutions.empty()) return;
168
169 /* is the wanted mode among the available modes? */
170 if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(*w, *h)) != _resolutions.end()) return;
171
172 /* use the closest possible resolution */
173 uint best = 0;
174 uint delta = Delta(_resolutions[0].width, *w) * Delta(_resolutions[0].height, *h);
175 for (uint i = 1; i != _resolutions.size(); ++i) {
176 uint newdelta = Delta(_resolutions[i].width, *w) * Delta(_resolutions[i].height, *h);
177 if (newdelta < delta) {
178 best = i;
179 delta = newdelta;
180 }
181 }
182 *w = _resolutions[best].width;
183 *h = _resolutions[best].height;
184 }
185
186 static bool CreateMainSurface(uint w, uint h)
187 {
188 int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
189 if (bpp == 0) UserError("Can't use a blitter that blits 0 bpp for normal visuals");
190 set_color_depth(bpp);
191
192 GetAvailableVideoMode(&w, &h);
193 if (set_gfx_mode(_fullscreen ? GFX_AUTODETECT_FULLSCREEN : GFX_AUTODETECT_WINDOWED, w, h, 0, 0) != 0) {
194 Debug(driver, 0, "Allegro: Couldn't allocate a window to draw on '{}'", allegro_error);
195 return false;
196 }
197
198 /* The size of the screen might be bigger than the part we can actually draw on!
199 * So calculate the size based on the top, bottom, left and right */
200 _allegro_screen = create_bitmap_ex(bpp, screen->cr - screen->cl, screen->cb - screen->ct);
201 _screen.width = _allegro_screen->w;
202 _screen.height = _allegro_screen->h;
203 _screen.pitch = ((byte*)screen->line[1] - (byte*)screen->line[0]) / (bpp / 8);
204 _screen.dst_ptr = _allegro_screen->line[0];
205
206 /* Initialise the screen so we don't blit garbage to the screen */
207 memset(_screen.dst_ptr, 0, static_cast<size_t>(_screen.height) * _screen.pitch);
208
209 /* Set the mouse at the place where we expect it */
210 poll_mouse();
211 _cursor.pos.x = mouse_x;
212 _cursor.pos.y = mouse_y;
213
214 BlitterFactory::GetCurrentBlitter()->PostResize();
215
216 InitPalette();
217
218 std::string caption = VideoDriver::GetCaption();
219 set_window_title(caption.c_str());
220
221 enable_hardware_cursor();
222 select_mouse_cursor(MOUSE_CURSOR_ARROW);
223 show_mouse(_allegro_screen);
224
225 GameSizeChanged();
226
227 return true;
228 }
229
230 bool VideoDriver_Allegro::ClaimMousePointer()
231 {
232 select_mouse_cursor(MOUSE_CURSOR_NONE);
233 show_mouse(nullptr);
234 disable_hardware_cursor();
235 return true;
236 }
237
238 std::vector<int> VideoDriver_Allegro::GetListOfMonitorRefreshRates()
239 {
240 std::vector<int> rates = {};
241
242 int refresh_rate = get_refresh_rate();
243 if (refresh_rate != 0) rates.push_back(refresh_rate);
244
245 return rates;
246 }
247
248 struct AllegroVkMapping {
249 uint16_t vk_from;
250 byte vk_count;
251 byte map_to;
252 };
253
254 #define AS(x, z) {x, 0, z}
255 #define AM(x, y, z, w) {x, y - x, z}
256
257 static const AllegroVkMapping _vk_mapping[] = {
258 /* Pageup stuff + up/down */
259 AM(KEY_PGUP, KEY_PGDN, WKC_PAGEUP, WKC_PAGEDOWN),
260 AS(KEY_UP, WKC_UP),
261 AS(KEY_DOWN, WKC_DOWN),
262 AS(KEY_LEFT, WKC_LEFT),
263 AS(KEY_RIGHT, WKC_RIGHT),
264
265 AS(KEY_HOME, WKC_HOME),
266 AS(KEY_END, WKC_END),
267
268 AS(KEY_INSERT, WKC_INSERT),
269 AS(KEY_DEL, WKC_DELETE),
270
271 /* Map letters & digits */
272 AM(KEY_A, KEY_Z, 'A', 'Z'),
273 AM(KEY_0, KEY_9, '0', '9'),
274
275 AS(KEY_ESC, WKC_ESC),
276 AS(KEY_PAUSE, WKC_PAUSE),
277 AS(KEY_BACKSPACE, WKC_BACKSPACE),
278
279 AS(KEY_SPACE, WKC_SPACE),
280 AS(KEY_ENTER, WKC_RETURN),
281 AS(KEY_TAB, WKC_TAB),
282
283 /* Function keys */
284 AM(KEY_F1, KEY_F12, WKC_F1, WKC_F12),
285
286 /* Numeric part. */
287 AM(KEY_0_PAD, KEY_9_PAD, '0', '9'),
288 AS(KEY_SLASH_PAD, WKC_NUM_DIV),
289 AS(KEY_ASTERISK, WKC_NUM_MUL),
290 AS(KEY_MINUS_PAD, WKC_NUM_MINUS),
291 AS(KEY_PLUS_PAD, WKC_NUM_PLUS),
292 AS(KEY_ENTER_PAD, WKC_NUM_ENTER),
293 AS(KEY_DEL_PAD, WKC_DELETE),
294
295 /* Other non-letter keys */
296 AS(KEY_SLASH, WKC_SLASH),
297 AS(KEY_SEMICOLON, WKC_SEMICOLON),
298 AS(KEY_EQUALS, WKC_EQUALS),
299 AS(KEY_OPENBRACE, WKC_L_BRACKET),
300 AS(KEY_BACKSLASH, WKC_BACKSLASH),
301 AS(KEY_CLOSEBRACE, WKC_R_BRACKET),
302
303 AS(KEY_QUOTE, WKC_SINGLEQUOTE),
304 AS(KEY_COMMA, WKC_COMMA),
305 AS(KEY_MINUS, WKC_MINUS),
306 AS(KEY_STOP, WKC_PERIOD),
307 AS(KEY_TILDE, WKC_BACKQUOTE),
308 };
309
310 static uint32_t ConvertAllegroKeyIntoMy(char32_t *character)
311 {
312 int scancode;
313 int unicode = ureadkey(&scancode);
314
315 const AllegroVkMapping *map;
316 uint key = 0;
317
318 for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
319 if ((uint)(scancode - map->vk_from) <= map->vk_count) {
320 key = scancode - map->vk_from + map->map_to;
321 break;
322 }
323 }
324
325 if (key_shifts & KB_SHIFT_FLAG) key |= WKC_SHIFT;
326 if (key_shifts & KB_CTRL_FLAG) key |= WKC_CTRL;
327 if (key_shifts & KB_ALT_FLAG) key |= WKC_ALT;
328 #if 0
329 Debug(driver, 0, "Scancode character pressed {}", scancode);
330 Debug(driver, 0, "Unicode character pressed {}", unicode);
331 #endif
332
333 *character = unicode;
334 return key;
335 }
336
337 static const uint LEFT_BUTTON = 0;
338 static const uint RIGHT_BUTTON = 1;
339
340 bool VideoDriver_Allegro::PollEvent()
341 {
342 poll_mouse();
343
344 bool mouse_action = false;
345
346 /* Mouse buttons */
347 static int prev_button_state;
348 if (prev_button_state != mouse_b) {
349 uint diff = prev_button_state ^ mouse_b;
350 while (diff != 0) {
351 uint button = FindFirstBit(diff);
352 ClrBit(diff, button);
353 if (HasBit(mouse_b, button)) {
354 /* Pressed mouse button */
355 if (_rightclick_emulate && (key_shifts & KB_CTRL_FLAG)) {
356 button = RIGHT_BUTTON;
357 ClrBit(diff, RIGHT_BUTTON);
358 }
359 switch (button) {
360 case LEFT_BUTTON:
361 _left_button_down = true;
362 break;
363
364 case RIGHT_BUTTON:
365 _right_button_down = true;
366 _right_button_clicked = true;
367 break;
368
369 default:
370 /* ignore rest */
371 break;
372 }
373 } else {
374 /* Released mouse button */
375 if (_rightclick_emulate) {
376 _right_button_down = false;
377 _left_button_down = false;
378 _left_button_clicked = false;
379 } else if (button == LEFT_BUTTON) {
380 _left_button_down = false;
381 _left_button_clicked = false;
382 } else if (button == RIGHT_BUTTON) {
383 _right_button_down = false;
384 }
385 }
386 }
387 prev_button_state = mouse_b;
388 mouse_action = true;
389 }
390
391 /* Mouse movement */
392 if (_cursor.UpdateCursorPosition(mouse_x, mouse_y)) {
393 position_mouse(_cursor.pos.x, _cursor.pos.y);
394 }
395 if (_cursor.delta.x != 0 || _cursor.delta.y) mouse_action = true;
396
397 static int prev_mouse_z = 0;
398 if (prev_mouse_z != mouse_z) {
399 _cursor.wheel = (prev_mouse_z - mouse_z) < 0 ? -1 : 1;
400 prev_mouse_z = mouse_z;
401 mouse_action = true;
402 }
403
404 if (mouse_action) HandleMouseEvents();
405
406 poll_keyboard();
407 if ((key_shifts & KB_ALT_FLAG) && (key[KEY_ENTER] || key[KEY_F])) {
408 ToggleFullScreen(!_fullscreen);
409 } else if (keypressed()) {
410 char32_t character;
411 uint keycode = ConvertAllegroKeyIntoMy(&character);
412 HandleKeypress(keycode, character);
413 }
414
415 return false;
416 }
417
422 int _allegro_instance_count = 0;
423
424 const char *VideoDriver_Allegro::Start(const StringList &param)
425 {
426 if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
427 Debug(driver, 0, "allegro: install_allegro failed '{}'", allegro_error);
428 return "Failed to set up Allegro";
429 }
430 _allegro_instance_count++;
431
432 this->UpdateAutoResolution();
433
434 install_timer();
435 install_mouse();
436 install_keyboard();
437
438 #if defined _DEBUG
439 /* Allegro replaces SEGV/ABRT signals meaning that the debugger will never
440 * be triggered, so rereplace the signals and make the debugger useful. */
441 signal(SIGABRT, nullptr);
442 signal(SIGSEGV, nullptr);
443 #endif
444
445 GetVideoModes();
446 if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) {
447 return "Failed to set up Allegro video";
448 }
449 MarkWholeScreenDirty();
450 set_close_button_callback(HandleExitGameRequest);
451
452 this->is_game_threaded = !GetDriverParamBool(param, "no_threads") && !GetDriverParamBool(param, "no_thread");
453
454 return nullptr;
455 }
456
457 void VideoDriver_Allegro::Stop()
458 {
459 if (--_allegro_instance_count == 0) allegro_exit();
460 }
461
462 void VideoDriver_Allegro::InputLoop()
463 {
464 bool old_ctrl_pressed = _ctrl_pressed;
465
466 _ctrl_pressed = !!(key_shifts & KB_CTRL_FLAG);
467 _shift_pressed = !!(key_shifts & KB_SHIFT_FLAG);
468
469 /* Speedup when pressing tab, except when using ALT+TAB
470 * to switch to another application. */
471 this->fast_forward_key_pressed = key[KEY_TAB] && (key_shifts & KB_ALT_FLAG) == 0;
472
473 /* Determine which directional keys are down. */
474 _dirkeys =
475 (key[KEY_LEFT] ? 1 : 0) |
476 (key[KEY_UP] ? 2 : 0) |
477 (key[KEY_RIGHT] ? 4 : 0) |
478 (key[KEY_DOWN] ? 8 : 0);
479
480 if (old_ctrl_pressed != _ctrl_pressed) HandleCtrlChanged();
481 }
482
483 void VideoDriver_Allegro::MainLoop()
484 {
485 this->StartGameThread();
486
487 for (;;) {
488 if (_exit_game) break;
489
490 this->Tick();
491 this->SleepTillNextTick();
492 }
493
494 this->StopGameThread();
495 }
496
497 bool VideoDriver_Allegro::ChangeResolution(int w, int h)
498 {
499 return CreateMainSurface(w, h);
500 }
501
502 bool VideoDriver_Allegro::ToggleFullscreen(bool fullscreen)
503 {
504 _fullscreen = fullscreen;
505 GetVideoModes(); // get the list of available video modes
506 if (_resolutions.empty() || !this->ChangeResolution(_cur_resolution.width, _cur_resolution.height)) {
507 /* switching resolution failed, put back full_screen to original status */
508 _fullscreen ^= true;
509 return false;
510 }
511 return true;
512 }
513
514 bool VideoDriver_Allegro::AfterBlitterChange()
515 {
516 return CreateMainSurface(_screen.width, _screen.height);
517 }
518
519 #endif /* WITH_ALLEGRO */
_dirkeys
byte _dirkeys
1 = left, 2 = up, 4 = right, 8 = down
Definition: gfx.cpp:33
WKC_SINGLEQUOTE
@ WKC_SINGLEQUOTE
' Single quote
Definition: gfx_type.h:101
CursorVars::UpdateCursorPosition
bool UpdateCursorPosition(int x, int y)
Update cursor position on mouse movement.
Definition: gfx.cpp:1749
VideoDriver::Tick
void Tick()
Give the video-driver a tick.
Definition: video_driver.cpp:102
Palette::first_dirty
int first_dirty
The first dirty element.
Definition: gfx_type.h:325
PFE_VIDEO
@ PFE_VIDEO
Speed of painting drawn video buffer.
Definition: framerate_type.h:59
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
_left_button_down
bool _left_button_down
Is left mouse button pressed?
Definition: gfx.cpp:40
Blitter::UsePaletteAnimation
virtual Blitter::PaletteAnimation UsePaletteAnimation()=0
Check if the blitter uses palette animation at all.
HandleKeypress
void HandleKeypress(uint keycode, char32_t key)
Handle keyboard input.
Definition: window.cpp:2563
Blitter
How all blitters should look like.
Definition: base.hpp:29
FVideoDriver_Allegro
Factory for the allegro video driver.
Definition: allegro_v.h:46
VideoDriver_Allegro::AfterBlitterChange
bool AfterBlitterChange() override
Callback invoked after the blitter was changed.
Blitter::GetScreenDepth
virtual uint8_t GetScreenDepth()=0
Get the screen depth this blitter works for.
CopyPalette
bool CopyPalette(Palette &local_palette, bool force_copy)
Copy the current palette if the palette was updated.
Definition: palette.cpp:154
_local_palette
static Palette _local_palette
Current palette to use for drawing.
Definition: win32_v.cpp:50
WKC_SLASH
@ WKC_SLASH
/ Forward slash
Definition: gfx_type.h:95
WKC_BACKSLASH
@ WKC_BACKSLASH
\ Backslash
Definition: gfx_type.h:99
PerformanceMeasurer
RAII class for measuring simple elements of performance.
Definition: framerate_type.h:92
WKC_L_BRACKET
@ WKC_L_BRACKET
[ Left square bracket
Definition: gfx_type.h:98
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:37
VideoDriver::StartGameThread
void StartGameThread()
Start the loop for game-tick.
Definition: video_driver.cpp:86
AS
#define AS(ap_name, size_x, size_y, min_year, max_year, catchment, noise, maint_cost, ttdpatch_type, class_id, name, preview)
AirportSpec definition for airports with at least one depot.
Definition: airport_defaults.h:393
Debug
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
Definition: debug.h:37
VideoDriver_Allegro::Paint
void Paint() override
Paint the window.
VideoDriver_Allegro::ChangeResolution
bool ChangeResolution(int w, int h) override
Change the resolution of the window.
VideoDriver_Allegro::Start
const char * Start(const StringList &param) override
Start this driver.
VideoDriver_Allegro::InputLoop
void InputLoop() override
Handle input logic, is CTRL pressed, should we fast-forward, etc.
VideoDriver_Allegro::GetListOfMonitorRefreshRates
std::vector< int > GetListOfMonitorRefreshRates() override
Get a list of refresh rates of each available monitor.
WKC_EQUALS
@ WKC_EQUALS
= Equals
Definition: gfx_type.h:97
HandleMouseEvents
void HandleMouseEvents()
Handle a mouse event from the video driver.
Definition: window.cpp:2866
Palette::palette
Colour palette[256]
Current palette. Entry 0 has to be always fully transparent!
Definition: gfx_type.h:324
allegro_v.h
Blitter::PostResize
virtual void PostResize()
Post resize event.
Definition: base.hpp:205
VideoDriver_Allegro::CheckPaletteAnim
void CheckPaletteAnim() override
Process any pending palette animation.
BlitterFactory::GetCurrentBlitter
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
Definition: factory.hpp:138
StringList
std::vector< std::string > StringList
Type for a list of strings.
Definition: string_type.h:60
_resolutions
std::vector< Dimension > _resolutions
List of resolutions.
Definition: driver.cpp:31
_shift_pressed
bool _shift_pressed
Is Shift pressed?
Definition: gfx.cpp:38
CursorVars::wheel
int wheel
mouse wheel movement
Definition: gfx_type.h:119
Palette::count_dirty
int count_dirty
The number of dirty elements.
Definition: gfx_type.h:326
VideoDriver_Allegro::MakeDirty
void MakeDirty(int left, int top, int width, int height) override
Mark a particular area dirty.
VideoDriver::StopGameThread
void StopGameThread()
Stop the loop for the game-tick.
Definition: video_driver.cpp:95
WKC_R_BRACKET
@ WKC_R_BRACKET
] Right square bracket
Definition: gfx_type.h:100
_rightclick_emulate
bool _rightclick_emulate
Whether right clicking is emulated.
Definition: driver.cpp:33
WKC_PERIOD
@ WKC_PERIOD
. Period
Definition: gfx_type.h:103
VideoDriver::GetCaption
static std::string GetCaption()
Get the caption to use for the game's title bar.
Definition: video_driver.cpp:189
VideoDriver::UpdateAutoResolution
void UpdateAutoResolution()
Apply resolution auto-detection and clamp to sensible defaults.
Definition: video_driver.hpp:243
endof
#define endof(x)
Get the end element of an fixed size array.
Definition: stdafx.h:308
Blitter::PALETTE_ANIMATION_VIDEO_BACKEND
@ PALETTE_ANIMATION_VIDEO_BACKEND
Palette animation should be done by video backend (8bpp only!)
Definition: base.hpp:52
CursorVars::delta
Point delta
relative mouse movement in this tick
Definition: gfx_type.h:118
WKC_COMMA
@ WKC_COMMA
, Comma
Definition: gfx_type.h:102
Blitter::PALETTE_ANIMATION_NONE
@ PALETTE_ANIMATION_NONE
No palette animation.
Definition: base.hpp:51
WKC_SEMICOLON
@ WKC_SEMICOLON
; Semicolon
Definition: gfx_type.h:96
GameSizeChanged
void GameSizeChanged()
Size of the application screen changed.
Definition: main_gui.cpp:583
VideoDriver_Allegro::MainLoop
void MainLoop() override
Perform the actual drawing.
Delta
constexpr T Delta(const T a, const T b)
Returns the (absolute) difference between two (scalar) variables.
Definition: math_func.hpp:234
Blitter::PaletteAnimate
virtual void PaletteAnimate(const Palette &palette)=0
Called when the 8bpp palette is changed; you should redraw all pixels on the screen that are equal to...
HandleCtrlChanged
void HandleCtrlChanged()
State of CONTROL key has changed.
Definition: window.cpp:2619
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1552
VideoDriver::SleepTillNextTick
void SleepTillNextTick()
Sleep till the next tick is about to happen.
Definition: video_driver.cpp:171
Blitter::PALETTE_ANIMATION_BLITTER
@ PALETTE_ANIMATION_BLITTER
The blitter takes care of the palette animation.
Definition: base.hpp:53
VideoDriver_Allegro::ToggleFullscreen
bool ToggleFullscreen(bool fullscreen) override
Change the full screen setting.
VideoDriver::fast_forward_key_pressed
bool fast_forward_key_pressed
The fast-forward key is being pressed.
Definition: video_driver.hpp:350
PointDimension
Specification of a rectangle with an absolute top-left coordinate and a (relative) width/height.
Definition: geometry_type.hpp:234
VideoDriver_Allegro::Stop
void Stop() override
Stop this driver.
WKC_MINUS
@ WKC_MINUS
Definition: gfx_type.h:104
VideoDriver_Allegro::PollEvent
bool PollEvent() override
Process a single system event.
CursorVars::pos
Point pos
logical mouse position
Definition: gfx_type.h:117
_right_button_clicked
bool _right_button_clicked
Is right mouse button clicked?
Definition: gfx.cpp:43
Palette
Information about the currently used palette.
Definition: gfx_type.h:323
ClrBit
constexpr T ClrBit(T &x, const uint8_t y)
Clears a bit in a variable.
Definition: bitmath_func.hpp:151
GetDriverParamBool
bool GetDriverParamBool(const StringList &parm, const char *name)
Get a boolean parameter the list of parameters.
Definition: driver.cpp:70
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:41
_cur_resolution
Dimension _cur_resolution
The current resolution.
Definition: driver.cpp:32
_right_button_down
bool _right_button_down
Is right mouse button pressed?
Definition: gfx.cpp:42
FindFirstBit
constexpr uint8_t FindFirstBit(T x)
Search the first set bit in a value.
Definition: bitmath_func.hpp:194
HasBit
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103