Question about 8 sprite per scanline limit

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

User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Question about 8 sprite per scanline limit

Post by FrankenGraphics »

A variation on the "scanline ladder" technique would be to let the letters sine/tri-cycle up and down on the y axis in cascades, with a travel of at least 16px.

So if you want a string like "Well Done!" (9 sprites with a position gap) you can time the cascades so that only up to 8 are intersecting the same line, because at least two sprites will always be at their extreme ends of their respective travel. It would look like a waving flag type of effect. I'm not clear on what the max sprite tolerance without canceling is. There's more variables than my math-resistant brain can handle: travel function, travel length, cascade/delay timing, geometry, the fact that travel is two-way...
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Question about 8 sprite per scanline limit

Post by Bregalad »

That or use a single sprite for both Ls, and it fits in 8 sprites :p
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Question about 8 sprite per scanline limit

Post by FrankenGraphics »

Heh, maybe not the best example then ;) Let's say something different... like "STAGE CLEAR". 9 sprites, and no combining trickery of T and A. Here, it would add the notion of a 'victory flag' waving in the wind.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Question about 8 sprite per scanline limit

Post by tepples »

How would the Doctor handle this?

Code: Select all

| STAGE  |
|  CLEAR |
|        |
| TRY    |
|   NEXT |
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Question about 8 sprite per scanline limit

Post by FrankenGraphics »

English and its short, practical words. Hmpf. :lol:
How about trying demake something like this? That's a challenge.

(the attachment looks glitched on my phone but it is displayed properly if opened in a new tab)
Attachments
IMG_8247.GIF
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Question about 8 sprite per scanline limit

Post by tepples »

Trust this (64x48)
Attachments
otyf.png
otyf.png (965 Bytes) Viewed 3984 times
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Question about 8 sprite per scanline limit

Post by FrankenGraphics »

Nice!

How about... "Oh nein! Das Unabhaengigkeitserklaerung wurde gestohlen!"
"Erfassen Bösewitz der Bösewicht!" :lol:

(sorry for my bad german)
User avatar
toggle switch
Posts: 139
Joined: Fri Sep 30, 2016 8:57 pm

Re: Question about 8 sprite per scanline limit

Post by toggle switch »

wow, i can't believe i missed the anarchist subtext in streets of rage as a kid...
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Question about 8 sprite per scanline limit

Post by FrankenGraphics »

Yeah, it's quite the opposite of Final Fight that way (thinking of Haggar, who is suspiciously fascistoid - i base more on being a mayor who decides taking up a war on street punks in his own hands than his looks, but that moustache is suspicious too - It remains uncertain if he's more a musical fan of Milan of Laibach, orFreddie Mercury of Queen, though). :P
Nix
Posts: 12
Joined: Wed Aug 26, 2020 12:22 pm

Re: Question about 8 sprite per scanline limit

Post by Nix »

tepples wrote: Tue Aug 08, 2017 7:48 am Like the NES, the Game Boy has only one sprite width. But it allows ten 8-pixel-wide sprites on a 160-pixel-wide picture, or 50% coverage. This is twice the effective coverage of the NES, which allows eight 8-pixel-wide sprites on a 256-pixel-wide picture, or 25% coverage.

Like the TurboGrafx-16 (aka PC Engine), the Sega Genesis and Super NES have a sprite coverage limit close to 100 percent of a scanline. But they also limit total sprite count per scanline regardless of size. And because they allow 8-pixel-wide sprites, sprite count can become the limiting factor on a scanline that contains mostly 8-pixel-wide sprites.
  • Genesis in 256px mode: 16 sprites or 32 8-pixel-wide slivers
    Coverage with 8x8 pixel sprites is 50%; coverage with larger sprites is 100%.
  • Genesis in 320px mode: 20 sprites or 40 8-pixel-wide slivers
    Coverage with 8x8 pixel sprites is 50%; coverage with larger sprites is 100%.
  • Super NES: 32 sprites or 34 8-pixel-wide slivers
    Coverage with 8x8 pixel sprites is 100%; coverage with larger sprites is 106%.
    But because all sprites are square, sprites often have to include more blank space at the top or bottom, reducing coverage on adjacent lines. TG16 suffers from this as well because of the 16x16 pixel minimum sprite size.
Sorry for replying to such an old thread, but I had to do it since I don't quite understand this explanation and couldn't find similar info anywhere else.

I'm confused about the "coverage" info specifically. I get the NES and GB formula. For the former it's 8x8=64, 64/256=0.25 (25% coverage), for the latter it's 8x10=80, 80/160=0.5 (50% coverage). But things start to get confusing on Genesis and SNES.

I'm guessing for Genesis in 256px and 320px it's 16x8=128, 128/256=0.5 / 20x8=160, 160/320=0.5 respectively. But there's that "32 8-pixel wide slivers" and "40 pixel-wide slivers" part, then it says "coverage with 8x8 pixels is 50%". Assuming the math is 32x8=256 / 40x8=320, wouldn't that make it 100% coverage for those?

Also, if SNES has 100% or higher coverage in both modes, does that imply flickery from too many sprites placed in the same scanline can never happen?
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Question about 8 sprite per scanline limit

Post by tepples »

I'm guessing for Genesis in 256px and 320px it's 16x8=128, 128/256=0.5 / 20x8=160, 160/320=0.5 respectively. But there's that "32 8-pixel wide slivers" and "40 pixel-wide slivers" part, then it says "coverage with 8x8 pixels is 50%".
On the Genesis in 256-pixel mode, only the frontmost 16 sprites on a line can show regardless of size. If all 16 of those sprites are 8 pixels wide, the coverage can be up to 128 pixels or 50 percent. If enough of those sprites are 16 pixels, 24 pixels, or 32 pixels wide, the coverage can be up to 256 pixels or 100 percent.

On the Genesis in 320-pixel mode, only the frontmost 20 sprites on a line can show regardless of size. If all 20 of those sprites are 8 pixels wide, the coverage can be up to 160 pixels or 50 percent. If enough of those sprites are 16 pixels, 24 pixels, or 32 pixels wide, the coverage can be up to 320 pixels or 100 percent.

On the Super NES, whose only sprite display mode is 256-pixel mode, only the frontmost 32 sprites on a line can show regardless of size. If all 32 of those sprites are 8 pixels wide, the coverage can be up to 256 pixels or 100 percent. If enough of those sprites are 16 pixels, 32 pixels, or 64 pixels wide, the coverage can be up to 272 pixels or 106 percent.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Question about 8 sprite per scanline limit

Post by lidnariq »

Nix wrote: Tue Mar 07, 2023 10:02 am Also, if SNES has 100% or higher coverage in both modes, does that imply flickery from too many sprites placed in the same scanline can never happen?
Flickering is a software workaround. Games on the NES only flicker because the programmers decided that was better then sprites disappearing.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Question about 8 sprite per scanline limit

Post by tokumaru »

And having 100% coverage doesn't mean that sprites will never flicker or drop out - if you have several sprites on screen, it's very likely they'll overlap or be partially off-screen, meaning that even if you're using the full coverage, you're not necessarily covering the entire scanline with sprite pixels.
Nix
Posts: 12
Joined: Wed Aug 26, 2020 12:22 pm

Re: Question about 8 sprite per scanline limit

Post by Nix »

Thanks for the answers, everyone.

Also, I have a request if anyone is willing/have the free time to take it. Can anyone make a few lua scripts to be used in BizHawk for PC Engine, Genesis and SNES that would tell how many sprites are present in a scanline at a given time? Ideally the number would also display as white or green by default and change to red when the limit is being exceeded.

This would be for research purposes to see what games are more prone to do it. On 8-Bit systems like NES, SMS or MSX it's pretty easy to know when it's happening, but on 16 bit ones it's less frequent. I'd code it myself if I could, but I'm lua (and coding in general) illiterate so don't even know how to start.
SNES AYE
Posts: 201
Joined: Mon Nov 07, 2022 11:28 am

Re: Question about 8 sprite per scanline limit

Post by SNES AYE »

Pokun wrote: Tue Aug 08, 2017 7:25 am The PC Engine's sprite system (which allows for 16 sprites on a scanline) counts sprites with double width as two sprites when it comes to the scanline limit. On the other hand sprite size is set per individual sprite, so you can mix and match sprite sizes however you want.
So, I don't quite understands this, when/why would you use double width sprites rather than just a larger sprite size?
Post Reply