aboutsummaryrefslogtreecommitdiff
path: root/src/vga.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-06-17 22:19:40 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-06-17 22:19:40 +0100
commit4c1f33184f1cba5006b4da8bbe2a161cd971aabc (patch)
tree4a1be3da598efec7431227632f83d3b32dd2032a /src/vga.c
parent2ce319014758bd3d6248635ab3f62594b77cc462 (diff)
downloadgold-mine-run-4c1f33184f1cba5006b4da8bbe2a161cd971aabc.tar.gz
gold-mine-run-4c1f33184f1cba5006b4da8bbe2a161cd971aabc.zip
Function to read from the back buffer
Diffstat (limited to 'src/vga.c')
-rw-r--r--src/vga.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/vga.c b/src/vga.c
index 0df25f8..cb2c5a8 100644
--- a/src/vga.c
+++ b/src/vga.c
@@ -129,3 +129,20 @@ void blit_update()
{
memcpy(screen, buffer, 320 * 200);
}
+
+void read_buffer(uint8_t *dst, const Rect *src)
+{
+ for (int32_t j = src->y * 320; j < (src->y + src->h) * 320; j += 320)
+ for (int16_t i = src->x; i < src->x + src->w; i++)
+ {
+ uint8_t b;
+
+ /* clipping */
+ if (i < 0 || i >= 320 || j < 0 || j >= 200 * 320)
+ b = TRANSPARENT;
+ else
+ b = buffer[i + j];
+
+ *dst++ = b;
+ }
+}