aboutsummaryrefslogtreecommitdiff
path: root/src/vga.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-07-08 23:07:33 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-07-08 23:07:33 +0100
commit231362ca6e7a292c350b98fcc144a844919aea41 (patch)
treecb9e347b0797d124d9b9d3f42680aad1ec1d8671 /src/vga.c
parent0ab23e049877ef66963a85e622db4d9c728f6d64 (diff)
downloadgold-mine-run-231362ca6e7a292c350b98fcc144a844919aea41.tar.gz
gold-mine-run-231362ca6e7a292c350b98fcc144a844919aea41.zip
Marginally faster
Diffstat (limited to 'src/vga.c')
-rw-r--r--src/vga.c13
1 files 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;
}
}