max sprite per line

SGDK only sub forum

Moderator: Stef

Post Reply
dub
Very interested
Posts: 101
Joined: Thu Mar 19, 2015 1:26 pm

max sprite per line

Post by dub » Mon Jun 29, 2015 12:16 pm

Hello, I have already done tests and read some posts but I found no solutions.

I want to display 20 sprites per line on each other. When I display all sprites, I have piece of spites disappear. I checked in the debugger of genskmod and all my sprites are on the screen and with the right number of tiles.

You can see from the image, the blue sprites are squares of 32 * 32 pixels but them does not appear under all the red sprites.

I have certainly misunderstanding something.

And I have a compilation warning like you'll see on the second screen. With the pointer of SPR_initSprite.

Image

Image

Code: Select all


// sprites structure
Sprite sprites[20];

int main()
{
    u16 palette[64];
    u16 ind;

// initialization
    VDP_setScreenWidth320();
// init sprites engine
    SPR_init(256);


    camposx = -1;
    camposy = -1;
    posx = FIX32(48);
    posy = MAX_POSY;
    movx = FIX32(0);
    movy = FIX32(0);
    xorder = 0;
    yorder = 0;
 
 sprposx = 10;
 sprposy = MAX_POSY;
 
    // init scrolling
    updateCamera(FIX32(0), FIX32(0));

    // init sonic sprite
    SPR_initSprite(&sprites[0], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[1], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy ), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[2], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy ), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[3], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy ), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(20);
 SPR_initSprite(&sprites[4], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy ), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(25);
 SPR_initSprite(&sprites[5], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy ), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[6], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy ), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[7], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy + sprposy), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[8], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy + sprposy), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[9], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy + sprposy), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 
 
 
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[10], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy + sprposy), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
  SPR_initSprite(&sprites[11], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 SPR_initSprite(&sprites[12], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy ), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[13], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy ), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[14], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy ), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[15], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy ), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[16], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy ), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[17], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy ), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[18], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy + sprposy), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 sprposx += FIX32(15);
 SPR_initSprite(&sprites[19], &sonic_sprite, fix32ToInt(posx - camposx + sprposx), fix32ToInt(posy - camposy + sprposy), TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
 
    SPR_update(sprites, 20);

    while(TRUE)
    {
        handleInput();

// update sprites (only one to update here)
        SPR_update(sprites, 20);

        VDP_waitVSync();
    }
If someone can help me!
regards.

dub
Very interested
Posts: 101
Joined: Thu Mar 19, 2015 1:26 pm

Post by dub » Mon Jun 29, 2015 1:23 pm

I find the answer after 6 hours :roll:

In the specification : On a
scan line you can have 10 32 pixel wide sprites or 20 16 pixel wide
sprites. Each sprite can only have 16 colors but they are out of the
4 different color tables. Color 0=transparent.


So for 32 pix wide sprites. Only 10 sprites. OMG, I'm a looser.

But I have always my compil error with the initsprite pointeur.

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

Post by Stef » Mon Jun 29, 2015 1:40 pm

You indeed found the problem by yourself, you can only display a maximum of 320 pixels of sprite per line.
For the warning, you can safely ignore them. This is just because the method declare the second parameter as "const" and that is not necessary your case.

dub
Very interested
Posts: 101
Joined: Thu Mar 19, 2015 1:26 pm

Post by dub » Mon Jun 29, 2015 5:37 pm

Thanks, I'll be a little less stupid today. 8)

Post Reply