diff options
-rw-r--r-- | src/vga.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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; } } |