aboutsummaryrefslogtreecommitdiff
path: root/src/vga.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-06-08 22:27:52 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-06-08 22:27:52 +0100
commit71fba1c1de9509ed8e7a4db712f6b535fa1f1514 (patch)
treef5ae9c4f8b9feb46e1b20af45e84184a41a7d8c8 /src/vga.c
parentcb6d24b838632e1269a5e4bb4e83425061f5d853 (diff)
downloadgold-mine-run-71fba1c1de9509ed8e7a4db712f6b535fa1f1514.tar.gz
gold-mine-run-71fba1c1de9509ed8e7a4db712f6b535fa1f1514.zip
Add blit rectangle
Allows blitting a section of a larger sprite.
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 6b093c0..0df25f8 100644
--- a/src/vga.c
+++ b/src/vga.c
@@ -101,6 +101,25 @@ void blit(const uint8_t *sprite, const Rect *dst)
}
}
+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)
+ for (int16_t i = dst->x, sx = src->x; i < dst->x + dst->w; i++, sx++)
+ {
+ uint8_t b = sprite[sx + sy];
+
+ /* transparent */
+ if (b == TRANSPARENT)
+ continue;
+
+ /* clipping */
+ if (i < 0 || i >= 320 || j < 0 || j >= 200 * 320)
+ continue;
+
+ buffer[i + j] = b;
+ }
+}
+
void blit_erase(uint8_t c)
{
memset(buffer, c, 320 * 200);