From 871062265cdfb565ba64834cfd85f079f387317e Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Thu, 11 May 2023 18:55:06 +0100 Subject: Make address unsigned Convert x, y coord to signed when we do the clipping. --- tr8vm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tr8vm.c b/tr8vm.c index ca2452e..5af21fe 100644 --- a/tr8vm.c +++ b/tr8vm.c @@ -159,7 +159,7 @@ static void update_ctl(SDL_Event *ev) uint8_t blt_set = 0; uint8_t blt_paramc = 0; -int8_t blt_param[6] = { 0 }; +uint8_t blt_param[6] = { 0 }; uint8_t port(uint8_t p, uint8_t v) { @@ -192,8 +192,8 @@ uint8_t port(uint8_t p, uint8_t v) { uint16_t src = blt_param[0] | (blt_param[1] << 8); - for (int16_t y = blt_param[3]; y < blt_param[3] + blt_param[5]; y++) - for (int16_t x = blt_param[2]; x < blt_param[2] + blt_param[4]; x++) + for (int16_t y = (int8_t)blt_param[3]; y < (int8_t)blt_param[3] + blt_param[5]; y++) + for (int16_t x = (int8_t)blt_param[2]; x < (int8_t)blt_param[2] + blt_param[4]; x++) { uint8_t b = read_m(src++); @@ -213,8 +213,8 @@ uint8_t port(uint8_t p, uint8_t v) { uint16_t dst = blt_param[0] | (blt_param[1] << 8); - for (int16_t y = blt_param[3]; y < blt_param[3] + blt_param[5]; y++) - for (int16_t x = blt_param[2]; x < blt_param[2] + blt_param[4]; x++) + for (int16_t y = (int8_t)blt_param[3]; y < (int8_t)blt_param[3] + blt_param[5]; y++) + for (int16_t x = (int8_t)blt_param[2]; x < (int8_t)blt_param[2] + blt_param[4]; x++) { uint8_t b = 0; -- cgit v1.2.3