gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > max number of sprites

#29729 - blinky465 - Wed Nov 24, 2004 11:49 am

Sorry if I'm repeating an old query here, but I'm just trying to get my head around best use of my objects/assets.

For each on screen character, I've an object with a number of parameters (x,y,z,objtype etc). Associated with each object is an on-screen sprite.

I've created my animations for the sprites as a big column of images (16wx320h) so I can just add an offset (256*frame number) to draw the appropriate frame on the screen.

What I wanted to know is - is there are limit on the size of a bitmap that can be used as a based for sprites (e.g. could I use a single bitmap of 16x3200 to give me access to 200 separate frames), and is there a limit to the total number of sprites that can be drawn on screen at one time?

Thanks

#29733 - poslundc - Wed Nov 24, 2004 3:21 pm

blinky465 wrote:
What I wanted to know is - is there are limit on the size of a bitmap that can be used as a based for sprites (e.g. could I use a single bitmap of 16x3200 to give me access to 200 separate frames)


You are limited by the amount of Sprite VRAM you have, which is 32K. An 8x8 tile takes 32 bytes in 16-colour mode, or 64 bytes in 256-colour mode. That's enough for 1024 8x8 tiles in 16-colour mode, or 512 in 256-colour mode. (You have only half that memory in Modes 3-5.)

A 16x3200 bitmap will take 25,600 bytes (about 25K) in 16-colour mode, which fits into VRAM (assuming you're in mode 0-2). It will take twice that (about 50K) in 256-colour mode, which won't fit into VRAM, so you would have to swap data in and out of VRAM depending on what's on the screen in a particular frame.

Quote:
and is there a limit to the total number of sprites that can be drawn on screen at one time?


The short answer is 128, which is the number of OAM entries you have. The longer answer is that there's a way around that limitation, but it's an advanced technique that's fraught with other limitations and not necessary for most games.

Dan.

#29741 - tepples - Wed Nov 24, 2004 5:28 pm

But swapping sprite cels into VRAM is teh easy.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#29745 - ScottLininger - Wed Nov 24, 2004 6:14 pm

blinky465 wrote:
What I wanted to know is - is there are limit on the size of a bitmap that can be used as a based for sprites (e.g. could I use a single bitmap of 16x3200 to give me access to 200 separate frames), and is there a limit to the total number of sprites that can be drawn on screen at one time?


Yah, like Tepple said, the way to do it is for you to copy your animation frames from ROM to sprite VRAM as you animate. Otherwise you will run out of sprite tile RAM and be hosed.

Then you're only limited by the size of your ROM. A 16x3200 array on ROM is perfectly fine.

-Scott