Sprite Info?

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
User avatar
nineTENdo
Posts: 223
Joined: Sun Mar 19, 2006 12:37 am
Location: San ANto, TX
Contact:

Sprite Info?

Post by nineTENdo »

Up to how many sprites can i have on a screen at one time?
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

There are always 64 sprites. If you want to use less than that, the unused ones must be placed outside of the visible area (below the bottom of the screen).

Sprite size is selectable between 8x8 pixels or 8x16 pixels. Many games use the 8x16 mode, since you can effectivelly draw more stuff with them (they have twice the area of the 8x8 ones).

If more than 8 are placed on the same scanline, only the 8 with higher priorities will be displayed. If the game needs more than 8 sprites in a scanline, some cycling of the priorities has to be performed, so that diferent sets of sprites are shown each frame. That introduces flickering, wich is still better than no sprite at all.

A full character (Mario, for example) is made of several sprites, it is not a single sprite.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Post by Bregalad »

Great sumarry, tokumaru.
I'd add something, tough.
tokumaru wrote: Sprite size is selectable between 8x8 pixels or 8x16 pixels. Many games use the 8x16 mode, since you can effectivelly draw more stuff with them (they have twice the area of the 8x8 ones).
I prefer myself use the 8x8 mode, because 8x16 mean that each sprite is two consecutive tiles. The tile index is AND-ed with #$fe, clipping the lowest bit, and the even tile (lowest bit to 0) is at the top, and the tile just after it (lowest bit to 1) is at the bottom. The actual lowest bit is the pattern table index instead, so you can adress both pattern table. This will often waste a lot of pattern table, even if you can use both, it often is a huge waste and do nothing but reduce BG tiles space available.
Useless, lumbering half-wits don't scare us.
User avatar
nineTENdo
Posts: 223
Joined: Sun Mar 19, 2006 12:37 am
Location: San ANto, TX
Contact:

Post by nineTENdo »

is it better to use sprites as numbers to scroll up and down the number to find a value. i want to do a simple addition of numbers program (2+2=4) . Ive seen code that uses ascii font tables.
User avatar
never-obsolete
Posts: 411
Joined: Wed Sep 07, 2005 9:55 am
Location: Phoenix, AZ
Contact:

Post by never-obsolete »

you would have to draw a font in chr and set the sprite tile number equal to the tile number of the character you want to display. then position it on the screen where you want it.
. That's just like, your opinion, man .
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

Bregalad wrote:I prefer myself use the 8x8 mode, because 8x16 mean that each sprite is two consecutive tiles. The tile index is AND-ed with #$fe, clipping the lowest bit, and the even tile (lowest bit to 0) is at the top, and the tile just after it (lowest bit to 1) is at the bottom. The actual lowest bit is the pattern table index instead, so you can adress both pattern table. This will often waste a lot of pattern table, even if you can use both, it often is a huge waste and do nothing but reduce BG tiles space available.
Yeah, I did not get into much detail about the 8x16 sprites. You pretty much summed it up.

I can see when 8x8 sprites are more usefull. I know you like RPG's, where characters are usually 16x16 pixels, right? When they walk, you can animate just the legs (bottom 8 pixels) and keep the head, something not posible with 8x16 sprites, where you'd have to draw the same head twice, wasting CHR space.

I prefer 8x16, however, and I'll also explain why. I enjoy platform games, such as Sonic The Hedgehog. Characters and enemies tend to be larger, so using 8x16 sprites allows you to effectivelly put more stuff on the screen. Also, there are usually many items in the level (in Sonic's case, spinning rings). On the NES, A big row of rings can only be represented with the background, or it would all flicker a lot. BUT, it is desirable that the same ring graphics be used as sprites, when Sonic looses his rings, for example, or to place a ring where it would not be aligned to the background. In that case, drawing the same ring twice would be a waste of space. I many times want to use the bg graphics as sprites, and that is only possible with 8x16 sprites.

Also, in the case of the spinning rings, if their animation is achieved through CHR bankswitching, it would make much sense to use the ring that's already there, spinning and all, but in the bg side of the patterns. Repeating the animation on the sprite side would also be a big waste of space.

Well, that's why I like 8x16 sprites. Both have advantages and disadvantages, depending on what you're doing.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Post by Bregalad »

I think you're right, if 8x8 or 8x16 the best really depends of the game.
However, in some case, 8x8 can be better even for a platform game, such as MegaMan, that is always made of 8x8 sprites. His head is another color than his armor, and his head is just a 8x8 sprite. If Capcom would have coosen 8x16 sprites for their MegaMan games, they would be forced to make the head sprite 8x16, and that would be 4 sprites on the same line below the head (there is 3 normally), so it would involve more useless flickering in the game.
What I hate with 8x16 sprites is that even if you're drawing a small ball or something that is only 4 pixels large and 4 pixels whide, you still have to waste 2 full tiles for it. Your pattern talbe is going to be mostly blank if you use a lot of small bullets and items, such as in Contra.
Even for platformers, I think 8x8 really helps to animate characters while keeping the pattern table not too big.
8x16 is really usefull only to merge BG and Sprite tiles, as you explained.
Bah, you could still have two copies of the ring tiles in both pattern tables, that would be 2 tiles or so in each pattern table. To annimate them, you could use CHR-RAM and write the data to them periodically. Of course that works fine as long as you annimate *only* them. If you're doing other background annimation, then you're fine as you said. Exept that if you're using an MMC3, you cannot use it's IRQ, because the lines that have sprites in the first pattern table will false the counter and the IRQ will happen too early randomly.
Useless, lumbering half-wits don't scare us.
Post Reply