Slowdown and crash

SGDK only sub forum

Moderator: Stef

Post Reply
vnsbr
Interested
Posts: 48
Joined: Sun Dec 17, 2017 4:13 pm

Slowdown and crash

Post by vnsbr » Sun Feb 03, 2019 10:40 pm

edit:
I post whole code as attachment

With 2 enemies and the player on screen there is already an noticeable slowdown, I am just using the usual spr_setanim, spr_setframe.. nothing very fancy. And if I put 4 enemies on screen + explosions the game freezes :/. 3 or less enemies work just fine.

video crash:
https://www.youtube.com/watch?v=4jyqMKbeMg0

Here is how I am initializing the engine:

Code: Select all

    SYS_disableInts();
    VDP_setScreenHeight224();
    VDP_setScreenWidth320();
    SPR_initEx(16, 256, 256);
    SYS_enableInts();
main():

Code: Select all

    SetupSystem();
    LevelManagerInit();
    while (TRUE)
    {
        JoypadManager_UpdateJoypad();
        LevelManagerUpdate();
        SPR_update();
        VDP_waitVSync();
    }
    return 0;
I will try and separate a small reproduction case.

I also have some other questions regarding best practices width SGDK:

1) I add sprites (via SPR_addSprite) and release(SPR_releaseSprite) everytime an object bounding box gets inside/outside of the screen. I noticed there is an AUTO_VISIBILITY flag, but that didnt seem to work for me, is there anything especial you have to do?

2) I am using VDP_setMapEx, is this the best to do the scrolling? I saw other topics that there other methods, but not sure if there is a difference perfomance wise?
Attachments
ninjaMD.zip
(61.26 KiB) Downloaded 169 times

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Slowdown and crash

Post by Stef » Mon Feb 04, 2019 6:20 pm

using VDP_setMapEx(..) ou VDP_drawImageEx(..) (i saw you're using both) may be very slow if your image / map resource are compressed (which is the case here) so don't forget to unpack resource first (with unpackMap(..) or unpackImage(..)) if you plan to call these method at each frame.
If you call it only on level loading (i think that is the case) then no problem (it can be slow as it happen only once).
Something weird : i was you're calling VDP_updateSprites(..) in the object manager unit, why are you doing that ??
You should never mix SPr_xxx methods (sprite engine) with VDP_updateSprites(..) as internally the Sprite engine is using low level sprite API and you can probably completely mess it.

vnsbr
Interested
Posts: 48
Joined: Sun Dec 17, 2017 4:13 pm

Re: Slowdown and crash

Post by vnsbr » Mon Feb 04, 2019 6:28 pm

Thanks Stef! Ill remove that method, but unfortunatelly it is not being called.

Im calling unpack only in the start. It is realy strange I am having this slowdown with these few sprites. I have seen other games lime tanzer have multiple enemies and particles at once and I am struggling with a couple:/

Is it possible to trace down the error from that error screen?
Thanks again.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Slowdown and crash

Post by Stef » Mon Feb 04, 2019 9:33 pm

I should have seen it before.. you are using compressed sprites (with BEST compression which is very slow). Sprite engine will unpack and upload them on live so you'd better use FAST or NONE ;-) FAST compression has been developed for sprites :)

vnsbr
Interested
Posts: 48
Joined: Sun Dec 17, 2017 4:13 pm

Re: Slowdown and crash

Post by vnsbr » Mon Feb 04, 2019 9:44 pm

Thanks, I am not on PC right now but ill try asap.

I think i had misunderstood the compression it seems :lol:

vnsbr
Interested
Posts: 48
Joined: Sun Dec 17, 2017 4:13 pm

Re: Slowdown and crash

Post by vnsbr » Tue Feb 05, 2019 12:03 am

thanks Stef, that was it!

nemezes
Very interested
Posts: 69
Joined: Sat Mar 31, 2018 1:09 pm

Re: Slowdown and crash

Post by nemezes » Tue Feb 05, 2019 12:29 am

Stef wrote:
Mon Feb 04, 2019 9:33 pm
I should have seen it before.. you are using compressed sprites (with BEST compression which is very slow). Sprite engine will unpack and upload them on live so you'd better use FAST or NONE ;-) FAST compression has been developed for sprites :)
I was going to talk about it.

This was the same "problem" I got. :)

Post Reply