Sprite size limitations
Moderator: Stef
Sprite size limitations
What are the limitations of sprite size? I am trying to make a title screen but my sprite is not showing up. I have tried several combinations of spr_init and spr_init ex, but i am not sure of the supported parameters and if I am hitting a limit.
either of the 2 sprites dont show up completely
title.png is 29x12 and i can convert to background if it helps, pilot.png is 15x17 and I wanted to place after everything (so I think SPRITE is the best way to do that?
either of the 2 sprites dont show up completely
title.png is 29x12 and i can convert to background if it helps, pilot.png is 15x17 and I wanted to place after everything (so I think SPRITE is the best way to do that?
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Sprite size limitations
Megadrive doesn't support having more than 320 pixels of sprite on a same scanline, if your title and your character overlap then sprites may be clipped as you reach the pixel limit (232 pixels wide for the title and 120 pixels wide for the character).
Also the sprite engine also has some limit about the maximum number of hardware sprite used by 1 software sprite (16 hardware sprite maximum for 1 software sprite), and here the title alone already eat 24 hardware sprite so you're above this limit too.
Definitely for some large sprites like that (specially the title) you have to use the background, even the character is just above the limit for the number of internal hard sprites (it would work if you can limit its size to 128x128 max).
Also the sprite engine also has some limit about the maximum number of hardware sprite used by 1 software sprite (16 hardware sprite maximum for 1 software sprite), and here the title alone already eat 24 hardware sprite so you're above this limit too.
Definitely for some large sprites like that (specially the title) you have to use the background, even the character is just above the limit for the number of internal hard sprites (it would work if you can limit its size to 128x128 max).
Re: Sprite size limitations
thanks Stef, as you said I had problems even when they are drawn alone, so it should be hitting the sprite engine limit.
I was planning to have a parallax for the backgrounds, thats why i didnt want to waste much space with it right now, but as I see now the title is way to big
I will try to design around this limitations.
edit: now that I think about it is that even though pilot is 17x15 i was thinking rescomp would remove most of these tiles since they don't have anything drawn on it.
I was planning to have a parallax for the backgrounds, thats why i didnt want to waste much space with it right now, but as I see now the title is way to big
I will try to design around this limitations.
edit: now that I think about it is that even though pilot is 17x15 i was thinking rescomp would remove most of these tiles since they don't have anything drawn on it.
Re: Sprite size limitations
I don't understand why I am hitting the limit so early. I divided title in 2 sprites to avoid the software limit
now I have:
But I can't show both in the screen, even though there is 80 32x32 sprites available? Aparently only 25 hardware sprites were used in gens as in the screenshot (plus a couple black 8x8 that i am unsure where they are from)
Here is a small code that reproduces the problem
displays only the title:
even if i draw only part of the title I cant get the pilot to show, like this:
now I have:
Code: Select all
SPRITE title1x1 "gfx/title/foreground/1x1title.png" 16 12 FAST 0
SPRITE title2x1 "gfx/title/foreground/2x1title.png" 13 12 FAST 0
SPRITE title_pilot1x1 "gfx/title/foreground/1x1pilot.png" 15 16 FAST 0
Here is a small code that reproduces the problem
Code: Select all
#include <genesis.h>
#include "sprite.h"
Sprite *titleScreenSprites[3];
void SetupSystem()
{
u16 palette[64];
SYS_disableInts();
VDP_setScreenWidth320();
SPR_init();
VDP_setPaletteColors(0, (u16 *)palette_black, 64);
SYS_enableInts();
titleScreenSprites[0] = SPR_addSprite(&title1x1, 0, 0, TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
titleScreenSprites[1] = SPR_addSprite(&title2x1, 128, 0, TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
titleScreenSprites[2] = SPR_addSprite(&title_pilot1x1, 320 - 120, 240 - 128, TILE_ATTR(PAL3, TRUE, FALSE, FALSE));
memcpy(&palette[32], title1x1.palette->data, 16 * 2);
memcpy(&palette[48], title2x1.palette->data, 16 * 2);
VDP_fadeIn(0, (4 * 16) - 1, palette, 20, FALSE);
}
int main()
{
SetupSystem();
while (TRUE)
{
SPR_update();
VDP_waitVSync();
}
return 0;
}
even if i draw only part of the title I cant get the pilot to show, like this:
Code: Select all
titleScreenSprites[0] = SPR_addSprite(&title1x1, 0, 0, TILE_ATTR(PAL2, TRUE, FALSE, FALSE));
titleScreenSprites[2] = SPR_addSprite(&title_pilot1x1, 320 - 120, 240 - 128, TILE_ATTR(PAL3, TRUE, FALSE, FALSE));
memcpy(&palette[32], title1x1.palette->data, 16 * 2);
memcpy(&palette[48], title2x1.palette->data, 16 * 2);
- Attachments
-
- 1x1title.png (1.58 KiB) Viewed 9886 times
-
- 1x1pilot.png (1.95 KiB) Viewed 9886 times
Re: Sprite size limitations
i ran out of attachments
here is what is displayd
and the other part of title for the reproduction
here is what is displayd
and the other part of title for the reproduction
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Sprite size limitations
So you only have the character missing ? what is weird is that it's completely missing, shouldn't be the case...
Normally you should have 12+12 (logo) + 16 used sprites (character), here we can see you only have 24 used sprites (logo only) so there is definitely something wrong.
Edit: Oh i see you are using the default SPR_init() method, by default the sprite engine only allocate 384 tiles in VRAM, because you're using very large sprites you need much more here, so use SPR_initEx(80, 640, 640) instead (should be enough).
Normally you should have 12+12 (logo) + 16 used sprites (character), here we can see you only have 24 used sprites (logo only) so there is definitely something wrong.
Edit: Oh i see you are using the default SPR_init() method, by default the sprite engine only allocate 384 tiles in VRAM, because you're using very large sprites you need much more here, so use SPR_initEx(80, 640, 640) instead (should be enough).
Re: Sprite size limitations
Yes. It is probably me doing something stupid. But couldnt figure it out yet. 24 (30 or so if you count another black linked sprites) is way below 80. I tried offsetting down the character and no luck too.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Sprite size limitations
I edited my message
Re: Sprite size limitations
hi Stef! yes that did the trick, spot on as always
256x224 resolution
is there anything i should worry for upping those parameters? like any major drawbacks
256x224 resolution
is there anything i should worry for upping those parameters? like any major drawbacks
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Sprite size limitations
In fact you just allocate more VRAM for the sprite engine (640 tiles on the ~1400 tiles available), also allocating more RAM to unpack the sprite data (consume more RAM but definitely not a issue on MD as you have plenty of RAM).
Having more VRAM allocated for sprites means less VRAM available for the background. But of course you can change the setting when you are in game condition.. So you can shutdown the sprite engine (by calling SPR_end()) then re-init it with SPR_initEx(80, 384, 256) for instance for in-game condition if you need less VRAM for sprites.
Having more VRAM allocated for sprites means less VRAM available for the background. But of course you can change the setting when you are in game condition.. So you can shutdown the sprite engine (by calling SPR_end()) then re-init it with SPR_initEx(80, 384, 256) for instance for in-game condition if you need less VRAM for sprites.
Re: Sprite size limitations
Yes thanks for the heads up, turns out i needed righ in the next screen eheh.
I still have a non related problem, if I set the plan_A to scroll, the text is being scrolled together. If i change the text plan to the plan_b i lose text transparency. Plan b does not have transparency?
I still have a non related problem, if I set the plan_A to scroll, the text is being scrolled together. If i change the text plan to the plan_b i lose text transparency. Plan b does not have transparency?
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Sprite size limitations
Of course it has, color 0 always let background color to appear. But you need to have plan B behind plan A i guess for what you want ?
Re: Sprite size limitations
How to make sure that plan b is behind? Just the drawing order or some flag?
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Sprite size limitations
The priority flag in the TILE_ATTR(..) macro you can use with the 'basetile' parameter of VDP_setMapEx(..) or VDP_drawImageEx(..) so you can change priority of the plan (on a tile basis) to HIGH or LOW.
Re: Sprite size limitations
Code: Select all
VDP_drawImageEx(PLAN_B, &title_background, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind), 0, 0, FALSE, TRUE);
ind += title_background.tileset->numTile;
VDP_drawImageEx(PLAN_A, &title_background2, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind), 0, 0, FALSE, TRUE);
this is how I draw the test right below:
Code: Select all
VDP_setTextPalette(PAL1);
VDP_setTextPlan(PLAN_B);
VDP_drawText("Start Game", 7, 15);
VDP_setTextPalette(PAL0);
VDP_drawText("Options", 7, 17);
VDP_drawText("Credits", 7, 19);