Changeset bc52b5b in mainline for uspace/app/gfxdemo/gfxdemo.c


Ignore:
Timestamp:
2021-08-15T10:02:32Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
99589a9
Parents:
de0c55a
Message:

Allow the use of EGA attributes/24-bit characters alongside RGB

In a big hack (since we cannot have different pixel formats yet) we
use a pixel format that allows both 24-bit RGB (without character)
or 24-bit character with 8-bit attributes. Thus in GFX we cannot
currently have characters with any RGB color, but we can set
foreground and background individually (and it even works in EGA mode).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/gfxdemo/gfxdemo.c

    rde0c55a rbc52b5b  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    7373static gfx_coord_t vpad;
    7474
     75/** Determine if we are running in text mode.
     76 *
     77 * @param w Screen width
     78 * @param h Screen height
     79 * @return @c true iff we are running in text mode
     80 */
     81static bool demo_is_text(gfx_coord_t w, gfx_coord_t h)
     82{
     83        // XXX Need a proper way to determine text mode
     84        return w <= 80;
     85}
     86
    7587/** Clear screen.
    7688 *
     
    215227
    216228        if (font != NULL) {
    217                 rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
    218                 if (rc != EOK)
    219                         goto error;
     229                if (demo_is_text(w, h)) {
     230                        rc = gfx_color_new_ega(0x1e, &color);
     231                        if (rc != EOK)
     232                                goto error;
     233                } else {
     234                        rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
     235                        if (rc != EOK)
     236                                goto error;
     237                }
    220238
    221239                gfx_text_fmt_init(&fmt);
     
    740758
    741759        for (i = 0; i < 8; i++) {
    742                 rc = gfx_color_new_rgb_i16((i & 4) ? 0xffff : 0,
    743                     (i & 2) ? 0xffff : 0, (i & 1) ? 0xffff : 0, &color);
    744                 if (rc != EOK)
    745                         goto error;
     760                if (demo_is_text(w, h)) {
     761                        rc = gfx_color_new_ega(i, &color);
     762                        if (rc != EOK)
     763                                goto error;
     764                } else {
     765                        rc = gfx_color_new_rgb_i16((i & 4) ? 0xffff : 0,
     766                            (i & 2) ? 0xffff : 0, (i & 1) ? 0xffff : 0, &color);
     767                        if (rc != EOK)
     768                                goto error;
     769                }
    746770
    747771                fmt.color = color;
Note: See TracChangeset for help on using the changeset viewer.