From 231362ca6e7a292c350b98fcc144a844919aea41 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sat, 8 Jul 2023 23:07:33 +0100 Subject: Marginally faster --- src/vga.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/vga.c b/src/vga.c index 13013b2..70a9a67 100644 --- a/src/vga.c +++ b/src/vga.c @@ -99,6 +99,7 @@ void blit(const uint8_t *sprite, const Rect *dst) { uint8_t b; uint8_t *dtarget = target + dst->x + dst->y * 320; + const uint16_t inc = 320 - dst->w; for (uint16_t j = dst->h; j > 0; j--) { @@ -115,7 +116,7 @@ void blit(const uint8_t *sprite, const Rect *dst) *dtarget++ = b; } - dtarget += 320 - dst->w; + dtarget += inc; } } @@ -123,6 +124,7 @@ void blit_c(const uint8_t *sprite, const Rect *dst, uint8_t c) { uint8_t b; uint8_t *dtarget = target + dst->x + dst->y * 320; + const uint16_t inc = 320 - dst->w; for (uint16_t j = dst->h; j > 0; j--) { @@ -139,7 +141,7 @@ void blit_c(const uint8_t *sprite, const Rect *dst, uint8_t c) *dtarget++ = b ? c : b; } - dtarget += 320 - dst->w; + dtarget += inc; } } @@ -147,6 +149,9 @@ void blitrc(const uint8_t *sprite, const Rect *src, const Rect *dst) { uint8_t b; uint8_t *dtarget = target + dst->x + dst->y * 320; + const uint16_t inc1 = src->w - dst->w; + const uint16_t inc2 = 320 - dst->w; + sprite += src->x + src->y * src->w; for (uint16_t j = dst->h; j > 0; j--) @@ -164,8 +169,8 @@ void blitrc(const uint8_t *sprite, const Rect *src, const Rect *dst) *dtarget++ = b; } - sprite += src->w - dst->w; - dtarget += 320 - dst->w; + sprite += inc1; + dtarget += inc2; } } -- cgit v1.2.3