Changes in uspace/app/tetris/screen.c [28a5ebd:e116461] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tetris/screen.c
r28a5ebd re116461 54 54 */ 55 55 56 #include <errno.h> 56 57 #include <stdio.h> 57 58 #include <stdlib.h> … … 71 72 static int isset; /* true => terminal is in game mode */ 72 73 73 static bool use_color; /* true => use colors */ 74 static bool use_rgb; /* true => use RGB colors */ 75 static bool use_color; /* true => use indexed colors */ 74 76 75 77 static const struct shape *lastshape; … … 91 93 static void start_standout(uint32_t color) 92 94 { 95 uint8_t bg; 96 uint8_t attr; 97 93 98 console_flush(console); 94 console_set_rgb_color(console, use_color ? color : 0x000000, 95 0xffffff); 99 if (use_rgb) { 100 console_set_rgb_color(console, color, 0xffffff); 101 } else if (use_color) { 102 bg = 0x00; 103 attr = 0; 104 if ((color & 0xff0000) != 0) 105 bg |= 0x4; 106 if ((color & 0x00ff00) != 0) 107 bg |= 0x2; 108 if ((color & 0x0000ff) != 0) 109 bg |= 0x1; 110 console_set_color(console, bg, 0x00, attr); 111 } 96 112 } 97 113 … … 142 158 } 143 159 144 static bool get_display_color_sup(void)160 static void get_display_color_sup(bool *rgb, bool *color) 145 161 { 146 162 sysarg_t ccap; 147 163 errno_t rc = console_get_color_cap(console, &ccap); 148 164 149 if (rc != EOK) 150 return false; 151 152 return ((ccap & CONSOLE_CAP_RGB) == CONSOLE_CAP_RGB); 165 if (rc != EOK) { 166 *rgb = false; 167 *color = false; 168 return; 169 } 170 171 *rgb = ((ccap & CONSOLE_CAP_RGB) == CONSOLE_CAP_RGB); 172 *color = ((ccap & CONSOLE_CAP_INDEXED) == CONSOLE_CAP_INDEXED); 153 173 } 154 174 … … 168 188 } 169 189 170 use_color = get_display_color_sup();190 get_display_color_sup(&use_rgb, &use_color); 171 191 172 192 if ((Rows < MINROWS) || (Cols < MINCOLS)) { … … 340 360 { 341 361 usec_t timeout = fallrate; 362 errno_t rc; 342 363 343 364 while (timeout > 0) { 344 365 cons_event_t event; 345 366 346 if (!console_get_event_timeout(console, &event, &timeout)) 367 rc = console_get_event_timeout(console, &event, &timeout); 368 if (rc == ETIMEOUT) 347 369 break; 370 if (rc != EOK) 371 exit(1); 348 372 } 349 373 } … … 354 378 int tgetchar(void) 355 379 { 380 errno_t rc; 381 356 382 /* 357 383 * Reset timeleft to fallrate whenever it is not positive … … 376 402 cons_event_t event; 377 403 378 if (!console_get_event_timeout(console, &event, &timeleft)) { 404 rc = console_get_event_timeout(console, &event, &timeleft); 405 if (rc == ETIMEOUT) { 379 406 timeleft = 0; 380 407 return -1; 381 408 } 409 if (rc != EOK) 410 exit(1); 382 411 383 412 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS) … … 394 423 { 395 424 char32_t c = 0; 425 errno_t rc; 396 426 397 427 while (c == 0) { 398 428 cons_event_t event; 399 429 400 if (!console_get_event(console, &event)) 430 rc = console_get_event(console, &event); 431 if (rc == ETIMEOUT) 401 432 return -1; 433 if (rc != EOK) 434 exit(1); 402 435 403 436 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
Note:
See TracChangeset
for help on using the changeset viewer.