Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

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

Nix
Posts: 10
Joined: Wed Aug 26, 2020 12:22 pm

Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Nix » Wed Aug 26, 2020 12:41 pm

This is my first post here. I don't know if I'll use this account much.

The title already says all. There's that "Allow more than 8 sprites per scanline" aka "No Sprite Limit" setting present in most NES emulators which helps minimizing sprite fickering. I want to know if it'd be possible to mod/tinker with a real NES to incorporate that feature. Maybe by messing around with the right hardware parts, I dunno.

Thanks in advance.


User avatar
tokumaru
Posts: 11907
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by tokumaru » Wed Aug 26, 2020 12:48 pm

You'd have to replace the PPU for a custom one, which doesn't exist yet. In theory, this replacement PPU could be created, but there are no guarantees that it'd be perfectly accurate in all other regards.

Right now you can buy a RetroUSB AVS clone, which uses original hardware and peripherals, and has an option for increasing the sprite limit to 15 per scanline, IIRC.

Keep in mind that some games rely on sprites beyond the 8th being dropped for achieving certain visual effects. These effects will look wrong if you enable this feature.

EDIT: typo.
Last edited by tokumaru on Wed Aug 26, 2020 2:31 pm, edited 1 time in total.

User avatar
Quietust
Posts: 1634
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Quietust » Wed Aug 26, 2020 1:38 pm

To better understand why this would be impossible, you need to understand that the PPU is only physically capable of tracking 8 sprites on a single scanline - the actual hardware for rendering sprites (horizontal position counters, tile/palette data shift registers, and a priority decoder) only has 8 slots (and takes up nearly 20% of the die - see this overview).
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

Nix
Posts: 10
Joined: Wed Aug 26, 2020 12:22 pm

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Nix » Wed Aug 26, 2020 9:26 pm

Thanks for the replies, guys. Things are more clear to me now.

User avatar
rainwarrior
Posts: 7891
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by rainwarrior » Thu Aug 27, 2020 7:45 am

The Hi-Def NES mod does have an option for more sprites on a scanline, I believe... but it's an HDMI output mod that replaces the PPU.


The original NES PPU has a set of 4 EXT pins, normally grounded, which I believe you could use to inject a second background layer underneath the existing image (with the same palettes as the existing background) from a second PPU, but that doesn't really help you with sprites.
Last edited by rainwarrior on Thu Aug 27, 2020 4:30 pm, edited 1 time in total.

User avatar
Movax12
Posts: 529
Joined: Sun Jan 02, 2011 11:50 am

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Movax12 » Thu Aug 27, 2020 2:53 pm

rainwarrior wrote:
Thu Aug 27, 2020 7:45 am
The Hi-Def NES mod does have an option for more sprites on a scanline, I believe... but it's an HDMI output mod that replaces the PPU.
The Hi-Def mod is a more polished version of the idea posted here: viewtopic.php?t=9561

So it doesn't emulate the PPU, but it does emulate the APU in order to get sound through HDMI.

User avatar
rainwarrior
Posts: 7891
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by rainwarrior » Thu Aug 27, 2020 4:29 pm

Ah, I probably had it wrong then. I thought I had read that it could do this.

Nix
Posts: 10
Joined: Wed Aug 26, 2020 12:22 pm

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Nix » Mon Aug 31, 2020 3:36 pm

If possible, I'd like to know how I can see the sprite overflow flag being set in a game through an emulator. I'm aware of the false positives/negatives issues and how unreliable it is, but I just want to see it being set _at all_.

Is there a way to do that?

User avatar
tokumaru
Posts: 11907
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by tokumaru » Mon Aug 31, 2020 3:50 pm

I'm not aware of any emulator that will explicitly tell you that a sprite overflow has occurred, but you can probably write a Lua script in emulators that support that (FCEUX, Mesen) to get that information from $2002 and present it visually somehow.

Fiskbit
Posts: 200
Joined: Sat Nov 18, 2017 9:15 pm

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Fiskbit » Mon Aug 31, 2020 5:17 pm

With Mesen, you can set a breakpoint of type 'Any' where the condition is 'SpriteOverflow', with 'Mark on Event Viewer' checked and 'Break Execution', 'Read', 'Write', and 'Execute' all unchecked. In the Event Viewer, this will draw events starting where overflow first occurs on the screen. I don't think there's a way to get it to just draw 1 dot where the flag becomes set, though, without using a Lua script as tokumaru suggested.

Nix
Posts: 10
Joined: Wed Aug 26, 2020 12:22 pm

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Nix » Tue Sep 01, 2020 8:36 am

I see. To be more specific, what I really wanted to do is detect when games are using excess sprites for masking effects. But this isn't helping much as the sprite overflow flag is set whenever it happens, regardless if it's for masking purposes.

I have a better idea now. Mesen has a feature called "Automatically re-enable sprite limit as needed to prevent graphical glitches when possible". Is there a way to make a breakpoint for whenever the emulator re-enables it? This way I'd know when it's doing that specifically to render masking effects correctly.

User avatar
Bregalad
Posts: 7988
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Bregalad » Tue Sep 01, 2020 8:47 am

Nix wrote:
Tue Sep 01, 2020 8:36 am
I see. To be more specific, what I really wanted to do is detect when games are using excess sprites for masking effects.
Heuristics could work there, either by detecting the games from a list of known games that does this, or by detecting exactly 8 sprites with the same attributes and positioned at the same Y position (above 240).

It could even be possible to simultaneously allow those sprites to mask sprites from the game, while also allowing other sprites to be more than 8 per line.
Useless, lumbering half-wits don't scare us.

GreyRogue
Posts: 45
Joined: Fri Dec 08, 2017 5:12 pm

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by GreyRogue » Wed Sep 02, 2020 9:15 pm

Nix wrote:
Tue Sep 01, 2020 8:36 am
I see. To be more specific, what I really wanted to do is detect when games are using excess sprites for masking effects. But this isn't helping much as the sprite overflow flag is set whenever it happens, regardless if it's for masking purposes.

I have a better idea now. Mesen has a feature called "Automatically re-enable sprite limit as needed to prevent graphical glitches when possible". Is there a way to make a breakpoint for whenever the emulator re-enables it? This way I'd know when it's doing that specifically to render masking effects correctly.
See Bregalad's description for how to auto-detect. That is what Mesen for example does (and MiSTer FPGA).
http://wiki.nesdev.com/w/index.php/Spri ... ng_effects

Note, though that it isn't fool proof. Check my notes from the Ninja Gaiden games here:
http://wiki.nesdev.com/w/index.php/Talk ... flow_games
Some of the masking that is supposed to happen don't use the same attribute/position and so produce some sprites outside the black bars incorrectly using the heuristic. Most of the time, it works though.

Nix
Posts: 10
Joined: Wed Aug 26, 2020 12:22 pm

Re: Would it be possible to mod a NES to have that "Allow more than 8 sprites per scanline" feature from emulators?

Post by Nix » Thu Sep 03, 2020 10:30 am

All right. Now I know what to do to detect masking effects, but not how to do it. I mean, how can I detect that a game is using "exactly 8 sprites with the same attributes and positioned at the same Y position"? I'm planning to use Mesen for that, and first I'm going to check with the small list of known games that do this: Zelda 1, Simon's Quest, Gimmick, etc. Just need to know what emulator tools to use.

Post Reply