From b4c2ff850930cb29da1a331b17fcc8a9e561b5ff Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Wed, 21 Jun 2023 22:42:28 +0100 Subject: Add color text --- src/vga.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/vga.c') diff --git a/src/vga.c b/src/vga.c index cb2c5a8..83ee2c7 100644 --- a/src/vga.c +++ b/src/vga.c @@ -101,6 +101,25 @@ void blit(const uint8_t *sprite, const Rect *dst) } } +void blit_c(const uint8_t *sprite, const Rect *dst, uint8_t c) +{ + for (int32_t j = dst->y * 320; j < (dst->y + dst->h) * 320; j += 320) + for (int16_t i = dst->x; i < dst->x + dst->w; i++) + { + uint8_t b = *sprite++; + + /* transparent */ + if (b == TRANSPARENT) + continue; + + /* clipping */ + if (i < 0 || i >= 320 || j < 0 || j >= 200 * 320) + continue; + + buffer[i + j] = b ? c : b; + } +} + void blitrc(const uint8_t *sprite, const Rect *src, const Rect *dst) { for (int32_t j = dst->y * 320, sy = src->y * src->w; j < (dst->y + dst->h) * 320; j += 320, sy += src->w) -- cgit v1.2.3