#137860 - Phantaseur - Thu Aug 16, 2007 8:20 pm
Again I have problems with sprites, now I just cannot display more than 32 sprites. In tutorials next code is used Code: |
for (int i = 0; i < 128; i++){
snspr[i].attribute[0] = ATTR0_DISABLED;
snspr[i].attribute[1] = 0;
snspr[i].attribute[2] = 0;
}
for (int i = 0; i < 32; i++) {
sprot[i].hdx = 256;
sprot[i].hdy = 0;
sprot[i].vdx = 0;
sprot[i].vdy = 256;
} |
So I tought it's possible use 128 sprites on the screen and just 32 of them can be rotated. Now I don't need rotating sprites, but I want see more than 32 sprites on the screen.
I use 8x8 sprites with 256 colors & it takes just two kilobytes (2048 bytes) of vram.
How can I get more than 32 sprites on the screen?
Last edited by Phantaseur on Sun Aug 19, 2007 10:38 pm; edited 1 time in total
#137865 - jenswa - Thu Aug 16, 2007 8:50 pm
You probably should leave out the last for loop which setups the rotating stuff for the 32 sprites. Because I thinks when that's enabled you can only have 32 and not 128.
But I am not sure if I understand this correct, since I've only programmed for the GBA. And there was this situation with rotating backgrounds and the memory space they occupy.
So if you don't need the rotating stuff, just leave out of the code, or disable it by commenting out the code.
_________________
It seems this wasn't lost after all.
#137867 - Phantaseur - Thu Aug 16, 2007 9:03 pm
Commented successfully. Not helped.
I still see just 32 sprites....
#137873 - josath - Thu Aug 16, 2007 10:31 pm
You can have 128 sprites easily. (more if you do some clever tricks)
Please post your code, if you would like us to help find your bug.
#137886 - knight0fdragon - Fri Aug 17, 2007 3:09 am
you can have 128 sprites, but some of the sprites have to share the 32 slots available in the rotating matrix
_________________
http://www.myspace.com/knight0fdragonds
MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206
#137894 - Phantaseur - Fri Aug 17, 2007 6:00 am
What means clever triks?
What means share the slots and how can I do it?
http://rapidshare.com/files/49478109/snake.tar.gz.html
Here is my code, but there is no comments...
When snake grows up to 32, you cannot see part of it.
#137909 - PypeBros - Fri Aug 17, 2007 10:32 am
Phantaseur wrote: |
Again I have problems with sprites, now I just cannot display more than 32 sprites. In tutorials next code is used Quote: |
for (int i = 0; i < 128; i++){
snspr[i].attribute[0] = ATTR0_DISABLED;
snspr[i].attribute[1] = 0;
snspr[i].attribute[2] = 0;
}
for (int i = 0; i < 32; i++) {
sprot[i].hdx = 256;
sprot[i].hdy = 0;
sprot[i].vdx = 0;
sprot[i].vdy = 256;
} |
So I tought it's possible use 128 sprites on the screen and just 32 of them can be rotated. Now I don't need rotating sprites, but I want see more than 32 sprites on the screen.
I use 8x8 sprites with 256 colors & it takes just two kilobytes (2048 bytes) of vram.
How can I get more than 32 sprites on the screen? |
What you show from the tutorial is the part that cleans up the local sprite table (the one that is copied over registers at Vblank). snspr is your sprite attributes table, defining position, size, and misc. stuff of the sprites. If you want to activate sprites, you need to change at least attribute 0[code] to e.g. ATTR0_COLOR_256 | ATTR0_SQUARE
somewhere later in your code.
sprot, as many have pointed out, is the set of matrices used for rotation. You may have 128 rotated sprites, but only using 32 different scaling/rotation transformations.
Pointing us at the exact tutorial you're talking about and looking in that tutorial for other references to the snspr[] array will help. Avoid doing anything application-related setup in that spritetable-cleanup function: you'll just make it messy and your changes my be discarded by functions called later :P
_________________
SEDS: Sprite Edition on DS :: modplayer
#137942 - Phantaseur - Fri Aug 17, 2007 8:42 pm
I've understood, attribute[2] (which is id) is not uniqe for each sprite, it is unique for each image of sprite, I can have same id for different sprites with same images. So I can have up to 128 sprites with just seven images (as I need), problem solved.
#137987 - SaruCoder - Sat Aug 18, 2007 6:06 am
Small little comment even though you solved your problem.
The id that goes into attribute[2] is more like an offset to a tile (8x8 pixels) in SPRITE_GFX or SPRITE_GFX_SUB. And the id has a range of 0 to 1023*
*depending on which mode you're in and if you're using 1D or 2D sprites, so it can be 0 to 255, worst case. http://forum.gbadev.org/viewtopic.php?t=13901
The id can point to a 0.5, 1, 2, 4 tile block size, again depending on if you're using
DISPLAY_SPR_1D_SIZE_32
DISPLAY_SPR_1D_SIZE_64
DISPLAY_SPR_1D_SIZE_128
DISPLAY_SPR_1D_SIZE_256
when you set your videoMode. (Please correct me if I'm wrong in the numbers)
Sooo... I don't why it would hit a 32 sprite limit with 8x8 pixel sprites, but it's very possible for 16x16 pixel sprites under the right conditions (videoMode set to DISPLAY_SPR_2D | DISPLAY_SPR_1D_SIZE_32 | MODE_*_2D)
MODE_*_2D would be either MODE_3_2D, MODE_4_2D, or MODE_5_2D
#138010 - tepples - Sat Aug 18, 2007 12:54 pm
SaruCoder wrote: |
The id can point to a 0.5, 1, 2, 4 tile block size, again depending on if you're using
DISPLAY_SPR_1D_SIZE_32
DISPLAY_SPR_1D_SIZE_64
DISPLAY_SPR_1D_SIZE_128
DISPLAY_SPR_1D_SIZE_256
when you set your videoMode. (Please correct me if I'm wrong in the numbers) |
In fact, that's a 32, 64, 128, or 256 byte offset. True, it's 1/2, 1, 2, or 4 tiles if your sprite cels are 256-color, but it's 1, 2, 4, or 8 if your sprite cels are 16-color.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.