aboutsummaryrefslogtreecommitdiff
path: root/src
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
parent2ce319014758bd3d6248635ab3f62594b77cc462 (diff)
downloadgold-mine-run-4c1f33184f1cba5006b4da8bbe2a161cd971aabc.tar.gz
gold-mine-run-4c1f33184f1cba5006b4da8bbe2a161cd971aabc.zip
Function to read from the back buffer
Diffstat (limited to 'src')
-rw-r--r--src/vga.c17
-rw-r--r--src/vga.h2
2 files changed, 19 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;
+ }
+}
diff --git a/src/vga.h b/src/vga.h
index 40dbcdf..e6642f7 100644
--- a/src/vga.h
+++ b/src/vga.h
@@ -26,4 +26,6 @@ void blitrc(const uint8_t *sprite, const Rect *src, const Rect *dst);
void blit_erase(uint8_t c);
void blit_update();
+/* read from back buffer into memory */
+void read_buffer(uint8_t *dst, const Rect *src);
#endif /* _VGA_H */