yatssd icon indicating copy to clipboard operation
yatssd copied to clipboard

Sprite drawing crash

Open Lion-Lawliet opened this issue 2 years ago • 2 comments

I replaced the display_sprites routine to draw four sprites on the screen, three are static and one moves around based on the Hw32xGetTicks value. However, strangely in the current version, the code crashes whenever the sprite crosses the screen boundaries, either horizontally or vertically.

Using Gens KMod, the horizontal crash seems to happen on address $06000B5C (it also causes the emulator to CTD) and the vertical crash seems to happen on address $06000BCC. Using a decompiler, I figured out that the issue seems to lie on the PIX_LOOP routines, the counter seems to underflow.

Thank you for the attention!

Lion-Lawliet avatar Jun 11 '23 04:06 Lion-Lawliet

I don't think I'll be able to help you without seeing the actual code

viciious avatar Jun 11 '23 16:06 viciious

My bad, friend! Just one thing to add, I thought this crash was happening due to my modifications but I can replicate this on a fresh/clean source by replacing display_sprites with this:

void display_sprites(int l, void *p)
{
    int start = Hw32xGetTicks();

    draw_setScissor(0, 0, 320, 224);

    if (sprmode >= 0)
    {
        int mode = DRAWSPR_OVERWRITE|DRAWSPR_MULTICORE;
        if (sprmode <= 3)
            mode |= sprmode | DRAWSPR_PRECISE;
        else
            mode |= (sprmode - 4);
                draw_sprite(start, 0 + 16, 32, 32, 64, test32x32_trans_smileData, DRAWSPR_OVERWRITE | mode);
	}
}

Lion-Lawliet avatar Jun 11 '23 19:06 Lion-Lawliet