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