aboutsummaryrefslogtreecommitdiff
path: root/src/vga.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-07-08 11:50:18 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-07-08 11:50:18 +0100
commit118e8e7db21040ad9e5e94cb824c4f389a8b5dcf (patch)
treed6616e1b936f5d1d8bd0c5dcbb02e255e5c709dc /src/vga.c
parent801f31feba0c52146e7bdc73c4e751c708518564 (diff)
downloadgold-mine-run-118e8e7db21040ad9e5e94cb824c4f389a8b5dcf.tar.gz
gold-mine-run-118e8e7db21040ad9e5e94cb824c4f389a8b5dcf.zip
Faster version with no clipping
Diffstat (limited to 'src/vga.c')
-rw-r--r--src/vga.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/vga.c b/src/vga.c
index 1190b6e..df79c7c 100644
--- a/src/vga.c
+++ b/src/vga.c
@@ -158,17 +158,12 @@ void blit_update()
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];
+ uint8_t *s = buffer + src->y * 320 + src->x;
- *dst++ = b;
- }
+ for (int8_t j = 0; j < src->h; j++)
+ {
+ memcpy(dst, s, src->w);
+ dst += src->w;
+ s += 320;
+ }
}