Changeset 8a9a41e in mainline for uspace/app/tetris/screen.c


Ignore:
Timestamp:
2021-10-24T08:28:43Z (3 years ago)
Author:
GitHub <noreply@…>
Children:
f628215
Parents:
2ce943a (diff), cd981f2a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Erik Kučák <35500848+Riko196@…> (2021-10-24 08:28:43)
git-committer:
GitHub <noreply@…> (2021-10-24 08:28:43)
Message:

Merge branch 'HelenOS:master' into master

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tetris/screen.c

    r2ce943a r8a9a41e  
    7272static int isset;               /* true => terminal is in game mode */
    7373
    74 static bool use_color;          /* true => use colors */
     74static bool use_rgb;          /* true => use RGB colors */
     75static bool use_color;          /* true => use indexed colors */
    7576
    7677static const struct shape *lastshape;
     
    9293static void start_standout(uint32_t color)
    9394{
     95        uint8_t bg;
     96        uint8_t attr;
     97
    9498        console_flush(console);
    95         console_set_rgb_color(console, use_color ? color : 0x000000,
    96             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        }
    97112}
    98113
     
    143158}
    144159
    145 static bool get_display_color_sup(void)
     160static void get_display_color_sup(bool *rgb, bool *color)
    146161{
    147162        sysarg_t ccap;
    148163        errno_t rc = console_get_color_cap(console, &ccap);
    149164
    150         if (rc != EOK)
    151                 return false;
    152 
    153         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);
    154173}
    155174
     
    169188        }
    170189
    171         use_color = get_display_color_sup();
     190        get_display_color_sup(&use_rgb, &use_color);
    172191
    173192        if ((Rows < MINROWS) || (Cols < MINCOLS)) {
Note: See TracChangeset for help on using the changeset viewer.