Changes in uspace/app/tetris/screen.c [09f41d3:87822ce] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tetris/screen.c
r09f41d3 r87822ce 1 1 /* 2 * Copyright (c) 2024 Jiri Svoboda3 2 * Copyright (c) 2011 Martin Decky 4 3 * All rights reserved. … … 73 72 static int isset; /* true => terminal is in game mode */ 74 73 75 static bool use_rgb; /* true => use RGB colors */ 76 static bool use_color; /* true => use indexed colors */ 74 static bool use_color; /* true => use colors */ 77 75 78 76 static const struct shape *lastshape; … … 80 78 static usec_t timeleft = 0; 81 79 82 bool size_changed;83 80 console_ctrl_t *console; 84 81 … … 95 92 static void start_standout(uint32_t color) 96 93 { 97 uint8_t bg;98 uint8_t attr;99 100 94 console_flush(console); 101 if (use_rgb) { 102 console_set_rgb_color(console, color, 0xffffff); 103 } else if (use_color) { 104 bg = 0x00; 105 attr = 0; 106 if ((color & 0xff0000) != 0) 107 bg |= 0x4; 108 if ((color & 0x00ff00) != 0) 109 bg |= 0x2; 110 if ((color & 0x0000ff) != 0) 111 bg |= 0x1; 112 console_set_color(console, bg, 0x00, attr); 113 } 95 console_set_rgb_color(console, use_color ? color : 0x000000, 96 0xffffff); 114 97 } 115 98 … … 144 127 console_cursor_visibility(console, 0); 145 128 resume_normal(); 146 scr_ set();129 scr_clear(); 147 130 } 148 131 … … 160 143 } 161 144 162 static void get_display_color_sup(bool *rgb, bool *color)145 static bool get_display_color_sup(void) 163 146 { 164 147 sysarg_t ccap; 165 148 errno_t rc = console_get_color_cap(console, &ccap); 166 149 167 if (rc != EOK) { 168 *rgb = false; 169 *color = false; 170 return; 171 } 172 173 if ((ccap & CONSOLE_CAP_CURSORCTL) == 0) { 174 stop("Your screen does not support cursor control.\n"); 175 return; 176 } 177 *rgb = ((ccap & CONSOLE_CAP_RGB) == CONSOLE_CAP_RGB); 178 *color = ((ccap & CONSOLE_CAP_INDEXED) == CONSOLE_CAP_INDEXED); 150 if (rc != EOK) 151 return false; 152 153 return ((ccap & CONSOLE_CAP_RGB) == CONSOLE_CAP_RGB); 179 154 } 180 155 … … 194 169 } 195 170 196 get_display_color_sup(&use_rgb, &use_color);171 use_color = get_display_color_sup(); 197 172 198 173 if ((Rows < MINROWS) || (Cols < MINCOLS)) { … … 200 175 201 176 snprintf(smallscr, sizeof(smallscr), 202 "the screen is too small (must be at least %dx%d) \n",177 "the screen is too small (must be at least %dx%d)", 203 178 MINROWS, MINCOLS); 204 179 stop(smallscr); … … 223 198 224 199 fprintf(stderr, "aborting: %s", why); 225 exit(1);200 abort(); 226 201 } 227 202 … … 416 391 exit(1); 417 392 418 if (event.type == CEV_RESIZE)419 size_changed = true;420 421 393 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS) 422 394 c = event.ev.key.c;
Note:
See TracChangeset
for help on using the changeset viewer.