From fe8512c5f439d73736e085e6c9296dc37ef26a25 Mon Sep 17 00:00:00 2001 From: Miguel <81558772+Miguel-hrvs@users.noreply.github.com> Date: Thu, 11 Jul 2024 12:46:25 +0200 Subject: [PATCH 1/8] fix mouse show sprite 258 pressing esc --- src/studio/studio.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/studio/studio.c b/src/studio/studio.c index 7bea1972a..0509c147a 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -2313,19 +2313,13 @@ static void blitCursor(Studio* studio) if(tic->ram->vram.vars.cursor.system) { bank = &getConfig(studio)->cart->bank0; - hot = (tic_point[]) - { - {0, 0}, - {3, 0}, - {2, 3}, - }[CLAMP(sprite, 0, 2)]; } else if(sprite == 0) return; const tic_palette* pal = &bank->palette.vbank0; - const tic_tile* tile = &bank->sprites.data[sprite]; + const tic_tile* tile = &studio->config->cart->bank0.sprites.data[sprite]; - tic_point s = {m->x - hot.x, m->y - hot.y}; + tic_point s = {m->x, m->y}; u32* dst = tic->product.screen + TIC80_FULLWIDTH * s.y + s.x; for(s32 y = s.y, endy = MIN(y + TIC_SPRITESIZE, TIC80_FULLHEIGHT), i = 0; y != endy; ++y, dst += TIC80_FULLWIDTH - TIC_SPRITESIZE) From cd174d29d04d4f8ed41a970b6710023b88786dc3 Mon Sep 17 00:00:00 2001 From: Miguel <81558772+Miguel-hrvs@users.noreply.github.com> Date: Sun, 4 Aug 2024 15:00:12 +0200 Subject: [PATCH 2/8] clicks centered --- src/studio/studio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/studio/studio.c b/src/studio/studio.c index 0509c147a..24818cb47 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -2319,7 +2319,7 @@ static void blitCursor(Studio* studio) const tic_palette* pal = &bank->palette.vbank0; const tic_tile* tile = &studio->config->cart->bank0.sprites.data[sprite]; - tic_point s = {m->x, m->y}; + tic_point s = {m->x - 4, m->y - 4}; u32* dst = tic->product.screen + TIC80_FULLWIDTH * s.y + s.x; for(s32 y = s.y, endy = MIN(y + TIC_SPRITESIZE, TIC80_FULLHEIGHT), i = 0; y != endy; ++y, dst += TIC80_FULLWIDTH - TIC_SPRITESIZE) From b68992061354e1d945a43365b7c8054600fdb1d7 Mon Sep 17 00:00:00 2001 From: Miguel <81558772+Miguel-hrvs@users.noreply.github.com> Date: Sun, 4 Aug 2024 16:42:01 +0200 Subject: [PATCH 3/8] just ibeam centered --- src/studio/studio.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/studio/studio.c b/src/studio/studio.c index a646279dc..86e50231c 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -2334,16 +2334,22 @@ static void blitCursor(Studio* studio) tic_point hot = {0}; - if(tic->ram->vram.vars.cursor.system) + if(tic->ram->vram.vars.cursor.sprite) { bank = &getConfig(studio)->cart->bank0; + hot = (tic_point[]) + { + {0, 0}, + {3, 0}, + {2, 3}, + }[CLAMP(sprite, 0, 2)]; } else if(sprite == 0) return; const tic_palette* pal = &bank->palette.vbank0; const tic_tile* tile = &studio->config->cart->bank0.sprites.data[sprite]; - tic_point s = {m->x - 4, m->y - 4}; + tic_point s = {m->x - hot.x, m->y - hot.y}; u32* dst = tic->product.screen + TIC80_FULLWIDTH * s.y + s.x; for(s32 y = s.y, endy = MIN(y + TIC_SPRITESIZE, TIC80_FULLHEIGHT), i = 0; y != endy; ++y, dst += TIC80_FULLWIDTH - TIC_SPRITESIZE) From a6e0bb257a3c6bd9f3d84145f08e57dcc0fd4798 Mon Sep 17 00:00:00 2001 From: Miguel <81558772+Miguel-hrvs@users.noreply.github.com> Date: Sun, 4 Aug 2024 23:03:31 +0200 Subject: [PATCH 4/8] fix cursor invisible at the top bar --- src/studio/studio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/studio/studio.c b/src/studio/studio.c index 86e50231c..50ca82436 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -2344,7 +2344,6 @@ static void blitCursor(Studio* studio) {2, 3}, }[CLAMP(sprite, 0, 2)]; } - else if(sprite == 0) return; const tic_palette* pal = &bank->palette.vbank0; const tic_tile* tile = &studio->config->cart->bank0.sprites.data[sprite]; From 4107a50a20009e49cec37bb784830692d3d9ffc3 Mon Sep 17 00:00:00 2001 From: Miguel <81558772+Miguel-hrvs@users.noreply.github.com> Date: Mon, 5 Aug 2024 00:53:48 +0200 Subject: [PATCH 5/8] fix black cursor at start --- src/studio/studio.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/studio/studio.c b/src/studio/studio.c index 50ca82436..126f84c6e 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -2334,16 +2334,13 @@ static void blitCursor(Studio* studio) tic_point hot = {0}; - if(tic->ram->vram.vars.cursor.sprite) + bank = &getConfig(studio)->cart->bank0; + hot = (tic_point[]) { - bank = &getConfig(studio)->cart->bank0; - hot = (tic_point[]) - { - {0, 0}, - {3, 0}, - {2, 3}, - }[CLAMP(sprite, 0, 2)]; - } + {0, 0}, + {3, 0}, + {2, 3}, + }[CLAMP(sprite, 0, 2)]; const tic_palette* pal = &bank->palette.vbank0; const tic_tile* tile = &studio->config->cart->bank0.sprites.data[sprite]; From 6dcf735cc3659bac60dca49932a06ad848f6debc Mon Sep 17 00:00:00 2001 From: Miguel <81558772+Miguel-hrvs@users.noreply.github.com> Date: Wed, 14 Aug 2024 10:45:47 +0200 Subject: [PATCH 6/8] better fix --- src/studio/studio.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/studio/studio.c b/src/studio/studio.c index 126f84c6e..b3a7fe014 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -2333,15 +2333,18 @@ static void blitCursor(Studio* studio) const tic_bank* bank = &tic->cart.bank0; tic_point hot = {0}; - - bank = &getConfig(studio)->cart->bank0; - hot = (tic_point[]) - { - {0, 0}, - {3, 0}, - {2, 3}, - }[CLAMP(sprite, 0, 2)]; - + + if(tic->ram->vram.vars.cursor.system && !tic->ram->vram.vars.cursor.sprite) + { + bank = &getConfig(studio)->cart->bank0; + hot = (tic_point[]) + { + {0, 0}, + {3, 0}, + {2, 3}, + }[CLAMP(sprite, 0, 2)]; + } + const tic_palette* pal = &bank->palette.vbank0; const tic_tile* tile = &studio->config->cart->bank0.sprites.data[sprite]; From 589a5e52e783109b81c3a6aea227b2bb4c3b2107 Mon Sep 17 00:00:00 2001 From: Miguel <81558772+Miguel-hrvs@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:11:49 +0200 Subject: [PATCH 7/8] Final fix --- src/studio/studio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/studio/studio.c b/src/studio/studio.c index b3a7fe014..990545882 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -2332,17 +2332,17 @@ static void blitCursor(Studio* studio) s32 sprite = CLAMP(tic->ram->vram.vars.cursor.sprite, 0, TIC_BANK_SPRITES - 1); const tic_bank* bank = &tic->cart.bank0; - tic_point hot = {0}; - - if(tic->ram->vram.vars.cursor.system && !tic->ram->vram.vars.cursor.sprite) - { - bank = &getConfig(studio)->cart->bank0; - hot = (tic_point[]) + tic_point hot = {0}; + hot = (tic_point[]) { {0, 0}, {3, 0}, {2, 3}, }[CLAMP(sprite, 0, 2)]; + + if(tic->ram->vram.vars.cursor.system) + { + bank = &getConfig(studio)->cart->bank0; } const tic_palette* pal = &bank->palette.vbank0; From 119c7dfd929b1def88bd19ee1bf97b0cc5a1a13c Mon Sep 17 00:00:00 2001 From: Miguel <81558772+Miguel-hrvs@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:36:40 +0200 Subject: [PATCH 8/8] now should be good to go --- src/studio/studio.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/studio/studio.c b/src/studio/studio.c index 990545882..47f4bffce 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -2329,36 +2329,34 @@ static void blitCursor(Studio* studio) if(tic->input.mouse && !m->relative && (s32)m->x < TIC80_FULLWIDTH && (s32)m->y < TIC80_FULLHEIGHT) { - s32 sprite = CLAMP(tic->ram->vram.vars.cursor.sprite, 0, TIC_BANK_SPRITES - 1); + const s32 sprite = CLAMP(tic->ram->vram.vars.cursor.sprite, 0, TIC_BANK_SPRITES - 1); const tic_bank* bank = &tic->cart.bank0; - - tic_point hot = {0}; - hot = (tic_point[]) + + if(tic->ram->vram.vars.cursor.system) + { + bank = &getConfig(studio)->cart->bank0; + const tic_palette* pal = &bank->palette.vbank0; + const tic_tile* tile = &bank->sprites.data[sprite]; + const tic_point hot = (tic_point[]) { {0, 0}, {3, 0}, {2, 3}, }[CLAMP(sprite, 0, 2)]; - - if(tic->ram->vram.vars.cursor.system) - { - bank = &getConfig(studio)->cart->bank0; - } - - const tic_palette* pal = &bank->palette.vbank0; - const tic_tile* tile = &studio->config->cart->bank0.sprites.data[sprite]; - - tic_point s = {m->x - hot.x, m->y - hot.y}; - u32* dst = tic->product.screen + TIC80_FULLWIDTH * s.y + s.x; - for(s32 y = s.y, endy = MIN(y + TIC_SPRITESIZE, TIC80_FULLHEIGHT), i = 0; y != endy; ++y, dst += TIC80_FULLWIDTH - TIC_SPRITESIZE) - for(s32 x = s.x, endx = x + TIC_SPRITESIZE; x != endx; ++x, ++i, ++dst) - if(x < TIC80_FULLWIDTH) - { - u8 c = tic_tool_peek4(tile->data, i); - if(c) - *dst = tic_rgba(&pal->colors[c]); - } + const tic_point s = {m->x - hot.x, m->y - hot.y}; + u32* dst = tic->product.screen + TIC80_FULLWIDTH * s.y + s.x; + + for(s32 y = s.y, endy = MIN(y + TIC_SPRITESIZE, TIC80_FULLHEIGHT), i = 0; y != endy; ++y, dst += TIC80_FULLWIDTH - TIC_SPRITESIZE) + for(s32 x = s.x, endx = x + TIC_SPRITESIZE; x != endx; ++x, ++i, ++dst) + if(x < TIC80_FULLWIDTH) + { + u8 c = tic_tool_peek4(tile->data, i); + if(c) + *dst = tic_rgba(&pal->colors[c]); + } + } + else if(sprite == 0) return; } }