aboutsummaryrefslogtreecommitdiff
path: root/src/vga.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-06-21 22:42:28 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-06-21 22:42:28 +0100
commitb4c2ff850930cb29da1a331b17fcc8a9e561b5ff (patch)
treee3b5a6c0d4a4454cc13afc8cc72bdc1e476e8569 /src/vga.c
parentd3c44c1472ab23a8ea37cc63f3f9f8678b0a6af5 (diff)
downloadgold-mine-run-b4c2ff850930cb29da1a331b17fcc8a9e561b5ff.tar.gz
gold-mine-run-b4c2ff850930cb29da1a331b17fcc8a9e561b5ff.zip
Add color text
Diffstat (limited to 'src/vga.c')
-rw-r--r--src/vga.c19
1 files changed, 19 insertions, 0 deletions
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)