diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-06-17 22:19:40 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-06-17 22:19:40 +0100 |
commit | 4c1f33184f1cba5006b4da8bbe2a161cd971aabc (patch) | |
tree | 4a1be3da598efec7431227632f83d3b32dd2032a /src | |
parent | 2ce319014758bd3d6248635ab3f62594b77cc462 (diff) | |
download | gold-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.c | 17 | ||||
-rw-r--r-- | src/vga.h | 2 |
2 files changed, 19 insertions, 0 deletions
@@ -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; + } +} @@ -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 */ |