Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mouse showing sprite 258 pressing esc #2629

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
55 changes: 26 additions & 29 deletions src/studio/studio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2329,37 +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};

if(tic->ram->vram.vars.cursor.system)
{
bank = &getConfig(studio)->cart->bank0;
hot = (tic_point[])
nesbox marked this conversation as resolved.
Show resolved Hide resolved
{
{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 = &bank->sprites.data[sprite];
const tic_point hot = (tic_point[])
{
{0, 0},
{3, 0},
{2, 3},
}[CLAMP(sprite, 0, 2)];

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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) we don't draw anything if tic->ram->vram.vars.cursor.system == false


const tic_palette* pal = &bank->palette.vbank0;
const tic_tile* tile = &bank->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]);
}
}
}

Expand Down
Loading