From 5ae0b6490f5fd138f4cbf5c084680bb03b2fff05 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sat, 8 Jul 2023 15:53:38 +0100 Subject: Perhaps generates better code --- src/vga.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/vga.c') diff --git a/src/vga.c b/src/vga.c index 8230880..ec56b60 100644 --- a/src/vga.c +++ b/src/vga.c @@ -93,9 +93,9 @@ void blit(const uint8_t *sprite, const Rect *dst) { uint8_t *dbuffer = buffer + dst->x + dst->y * 320; - for (int16_t j = 0; j < dst->h; j++) + for (uint16_t j = dst->h; j > 0; j--) { - for (int16_t i = 0; i < dst->w; i++) + for (uint16_t i = dst->w; i > 0; i--) { uint8_t b = *sprite++; @@ -116,9 +116,9 @@ void blit_c(const uint8_t *sprite, const Rect *dst, uint8_t c) { uint8_t *dbuffer = buffer + dst->x + dst->y * 320; - for (int16_t j = 0; j < dst->h; j++) + for (uint16_t j = dst->h; j > 0; j--) { - for (int16_t i = 0; i < dst->w; i++) + for (uint16_t i = dst->w; i > 0; i--) { uint8_t b = *sprite++; @@ -140,9 +140,9 @@ void blitrc(const uint8_t *sprite, const Rect *src, const Rect *dst) uint8_t *dbuffer = buffer + dst->x + dst->y * 320; sprite += src->x + src->y * src->w; - for (int16_t j = 0; j < dst->h; j++) + for (uint16_t j = dst->h; j > 0; j--) { - for (int16_t i = 0; i < dst->w; i++) + for (uint16_t i = dst->w; i > 0; i--) { uint8_t b = *sprite++; @@ -174,9 +174,9 @@ void read_buffer(uint8_t *dst, const Rect *src) { uint8_t *s = buffer + src->y * 320 + src->x; - for (int8_t j = 0; j < src->h; j++) + for (uint16_t j = src->h; j > 0; j--) { - for (int8_t i = 0; i < src->w; i++) + for (uint16_t i = src->w; i > 0; i--) *dst++ = *s++; s += 320 - src->w; -- cgit v1.2.3