diff options
author | Shin-ichiro KAWASAKI <kawasaki@juno.dti.ne.jp> | 2010-01-01 15:59:39 +0900 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2010-01-14 16:15:50 +0100 |
commit | 0a4e7cd2374f1d898a25f4ae7d0fb0321433c197 (patch) | |
tree | d9327bcf2d81760a0105b28b75d77aacf0ef6a88 /hw/sm501_template.h | |
parent | 8b0ee8c576a6f3e107c80f70f6dacb2964feb4a7 (diff) | |
download | qemu-0a4e7cd2374f1d898a25f4ae7d0fb0321433c197.zip |
sh: sm501: Add hardware cursor feature
This patch adds hardware cursor feature to SM501 graphics chip emulation,
to make the graphic console more useful for QEMU SH4 users.
Signed-off-by: Shin-ichiro KAWASAKI <kawasaki@juno.dti.ne.jp>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Diffstat (limited to 'hw/sm501_template.h')
-rw-r--r-- | hw/sm501_template.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/hw/sm501_template.h b/hw/sm501_template.h index 1679df7bfe..d1ceef9cb6 100644 --- a/hw/sm501_template.h +++ b/hw/sm501_template.h @@ -96,6 +96,48 @@ static void glue(draw_line32_, PIXEL_NAME)( } while (-- width != 0); } +/** + * Draw hardware cursor image on the given line. + */ +static void glue(draw_hwc_line_, PIXEL_NAME)(SM501State * s, int crt, + uint8_t * palette, int c_y, uint8_t *d, int width) +{ + int x, i; + uint8_t bitset = 0; + + /* get hardware cursor pattern */ + uint32_t cursor_addr = get_hwc_address(s, crt); + assert(0 <= c_y && c_y < SM501_HWC_HEIGHT); + cursor_addr += 64 * c_y / 4; /* 4 pixels per byte */ + cursor_addr += s->base; + + /* get cursor position */ + x = get_hwc_x(s, crt); + d += x * BPP; + + for (i = 0; i < SM501_HWC_WIDTH && x + i < width; i++) { + uint8_t v; + + /* get pixel value */ + if (i % 4 == 0) { + cpu_physical_memory_rw(cursor_addr, &bitset, 1, 0); + cursor_addr++; + } + v = bitset & 3; + bitset >>= 2; + + /* write pixel */ + if (v) { + v--; + uint8_t r = palette[v * 3 + 0]; + uint8_t g = palette[v * 3 + 1]; + uint8_t b = palette[v * 3 + 2]; + ((PIXEL_TYPE *) d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b); + } + d += BPP; + } +} + #undef DEPTH #undef BPP #undef PIXEL_TYPE |