Jump to content
  • 0
izb

Question about sprite limitations

Question

I’m seeing a weird glitch with sprites that looks like some sort of sprite limitation. The attached file shows the problem. 


At the start, the shadow of the third alien on the left (top row) looks missing. When the spaceman walks down past the shadows on that row, then all the shadows start to go a bit weird. 
 

There are 45 sprites on the screen, which is under the 128 limit. Are there other limitations affecting sprites that are missing from the docs? I can’t seem to find any more info in the Vera docs, or any open issues in the emulator repo. 
 

The shadow sprites have the higher positions in vmem, and so get drawn first, but perhaps that is pushing them closer to whatever the limit is?

37CA4B86-262F-4678-8DC4-CAF40A72218F.gif

  • Like 1

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 0

In addition to the absolute limit of 128 sprites on screen, there is a per-line sprite limit as well, which is roughly "the total width of the sprites attempting to draw on a line may not exceed 640 pixels", but not exactly.

The exact definition is much more complicated:

  • The VERA will process at most 801 "work units" of sprite data per line, after which it stops trying to draw sprites on that line.
  • Each sprite is 1 work unit.
  • Each time a sprite fetches 32 bits of color data is 1 work unit.
  • Each pixel attempted to draw to the screen is 1 work unit.

From some code inspection of this, the emulator may have a bug that's counting every 4 pixels as "fetching 32 bits" regardless of the sprite's color depth.

  • Like 4
  • Thanks 1

Share this post


Link to post
Share on other sites
  • 0

Aha, that makes sense then. 
 

Sounds like a comfortable limit so long as you’re not lining up pathologically worst case rows of green aliens. 

  • Like 1
  • Haha 2

Share this post


Link to post
Share on other sites
  • 0

Does the number and format of screen layers affect the number of work units available for sprites?

E.g. if I have 1 tile layer active, can I have more sprites on one row than if I have 2 tile layers active?

Also, does colour depth of screen layers have an effect on available work units for sprites?

Share this post


Link to post
Share on other sites
  • 0

I'm about to test this probably this evening. My next project is a "Space Invaders" inspired game - and there are 12 enemies (16x16 4bpp) lined up in each row...

Then I have the "shields" which I want to build from groups of 8x8 4bpp sprites, where there can also be up to 16 sprites in one row. Plus laser sprites from shooting etc.

A total of around 90-100 sprites on screen 🤪...

Background layer 1 will be bitmapped 8bpp and on top of that layer 2 with 1bpp text tiles (UI, score, messages etc.).

That will be quite a lot of stuff and I'm curious if VERA (and the emulator) can handle all this.

 

Share this post


Link to post
Share on other sites
  • 0

As far as I know, the number of active layers makes no difference to the sprites' work units. The bits-per-pixel of the sprites, however, might. The emulator currently doesn't account for bpp and as best as I can remember it never has, but there is a comment in the code that reads "one clock per fetched 32 bits", which suggests 8bpp sprites should cost a work unit per 4 pixels' width, while 4bpp sprites should cost a work unit per 8 pixels' width.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
5 hours ago, AndyMt said:

I'm about to test this probably this evening. My next project is a "Space Invaders" inspired game - and there are 12 enemies (16x16 4bpp) lined up in each row...

Have you thought about putting the aliens in a background layer? The aliens all move in lockstep, so there's no need for them to all be separated (unless you're already using both background layers for something)

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

I want the aliens to move a bit more intelligent as in the original, so at least each row moving in separate formations. Sometimes running an attack over the sides to get closer.

It will maybe be more like a shooter like Xenos, just without the scrolling background. Thats up for the second to next game.

Share this post


Link to post
Share on other sites
  • 0

You may be able to get away with the aliens being part of a tilemap and not becoming sprites until they break formation. That way, only the free-flying aliens need to be sprites, which should drastically cut the number of simultaneous sprites that you need.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use