Advice for artifact free 4-way scrolling

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Advice for artifact free 4-way scrolling

Post by NewRisingSun »

And since you HAVE to disable both the left and the top 8 scanlines to ever hope of scrolling sprites smoothly in the NES screen (this is a hardware limitation), this makes 4-screen mirroring almost entierely useless.
Not really. If you have CHR pattern memory to spare, you can keep shifted versions of each sprite to use at the left and upper edges. So if your two-horizontal-sprites object (with anchor point in its top-left corner) is at position X=0, you put sprite A-normal at X=0 and sprite B-normal at X=8, but if the object is at position X=-2, you put sprite A-shift2 at X=0 and sprite B-normal at X=6. Same thing for the upper edge.

Of course, you'd have to prepare each sprite eight by eight times for all possible shift positions in CHR-ROM memory if you want one-pixel granularity, which is why I was wondering how CPU-intensive it would be for a CHR-RAM game to create these shifted sprites on-the-fly as they are needed. I could also imagine a custom mapper hardware monitoring writes to RAM at $0200 to detect sprite data that needs to be shifted (for example, by setting one of the unused bits in OAM Byte 2), and automatically providing shifted CHR pattern data when the PPU requests them.
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Advice for artifact free 4-way scrolling

Post by FrankenGraphics »

Or instead of shifting, if you have chr-ram, and have it organized in dedicated chr space slots for entities (like in solstice) , you can mask individual lines of pixels off the contents in each slot in order to mask out any lines causing a visual wraparound. So, the wraparound is still happening, but the player would never know.

The problem with this approach is you likely have to update the CHR in round-robin/cascadewise. Maybe some clever chr bank cycling can be used depending on mapper to either improve the update rate or what slivers of chr space are masked.

But... it's quite the effort for something as trivial as a little bit of wraparound. It's for those of you who want a mountain to climb. ;)
psycopathicteen
Posts: 3140
Joined: Wed May 19, 2010 6:12 pm

Re: Advice for artifact free 4-way scrolling

Post by psycopathicteen »

I thought sprites disappear off the side, not wrap around.
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Advice for artifact free 4-way scrolling

Post by FrankenGraphics »

Best example i could find in under a minute:

Look at this video: https://www.youtube.com/watch?v=EEtz3g8_kXs
Play it back at 0.25x and pause-play when the enemy wraps around. Note that the leftmost column is disabled though.

sprites wrap around because the sprite xpos is 8 bits (ie 256 positions) which is exactly the width of the screen area. There are no positions off-screen except on the y axis.

Kid Icarus makes frequent use of this as a feature. Vanilla Metroid could have done it in vertical shafts but didn't in practice.


Games that make sprites disappear when going over the left/right edge do so willfully in software by moving them to a non-visible y-position.
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Advice for artifact free 4-way scrolling

Post by NewRisingSun »

sprites wrap around because the sprite xpos is 8 bits (ie 256 positions) which is exactly the width of the screen area. There are no positions off-screen except on the y axis.
That does not explain why a sprite at X=254 would not just be drawn at X=254..255 but also at X=0..5.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Advice for artifact free 4-way scrolling

Post by Bregalad »

psycopathicteen wrote:not wrap around.
You mentionned wrap-arround quite a few times, but actually this does not happen (in hardware) for sprites. It happens for BG on the wrong mirroring axis. Normally any metasprite engine would check individual sprites so that no wrapping arround happens, period.
Not really. If you have CHR pattern memory to spare, you can keep shifted versions of each sprite to use at the left and upper edges. So if your two-horizontal-sprites object (with anchor point in its top-left corner) is at position X=0, you put sprite A-normal at X=0 and sprite B-normal at X=8, but if the object is at position X=-2, you put sprite A-shift2 at X=0 and sprite B-normal at X=6. Same thing for the upper edge.
Technically this is correct but it'd be so complicated to implement that... it's much simpler to disable the top and left pixels.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Advice for artifact free 4-way scrolling

Post by dougeff »

Just repeating what Bregalad said.

Sprites do NOT wrap on the NES.

They do wrap on the SNES. Which makes pushing them offscreen downward potentially more problematic, if sprite sizes are set larger than 16x16.
nesdoug.com -- blog/tutorial on programming for the NES
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Advice for artifact free 4-way scrolling

Post by NewRisingSun »

One thing that I will never understand is why someone would program a vertically-scrolling game to use Vertical Mirroring. I'm looking at you, Star Force, Star Soldier, Legendary Wings...
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Advice for artifact free 4-way scrolling

Post by tepples »

dougeff wrote:They do wrap on the SNES. Which makes pushing them offscreen downward potentially more problematic, if sprite sizes are set larger than 16x16.
Only if 239-line mode is set and the sprite sizes are 32 and 64. In 224-line mode, y=225 should be safe.
NewRisingSun wrote:One thing that I will never understand is why someone would program a vertically-scrolling game to use Vertical Mirroring. I'm looking at you, Star Force
Tecmo's Star Force scrolls in all four directions. Its playfield is slightly wider than 1 screen, with the background moving horizontally in the opposite direction of the player's craft. It loads the nametable straight across for the same reason that Super Mario Bros. 3 loads the nametable straight down: not having to manage the complexity of both vertical and horizontal scroll seams.
User avatar
gauauu
Posts: 779
Joined: Sat Jan 09, 2016 9:21 pm
Location: Central Illinois, USA
Contact:

Re: Advice for artifact free 4-way scrolling

Post by gauauu »

NewRisingSun wrote:One thing that I will never understand is why someone would program a vertically-scrolling game to use Vertical Mirroring. I'm looking at you, Star Force, Star Soldier, Legendary Wings...
Because it makes it easy to use the other screen and a sprite-0 split for a status bar or some other non-scrolling element. My nesdev competition games were both vertically-scrolling, and used vertical mirroring (so I could put a status bar at the top of Spacey McRacey, and put spikes at the bottom of Robo-Ninja Climb) But why games like Legendary Wings used it and DIDN'T have a status bar, I don't know.
User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2064
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Advice for artifact free 4-way scrolling

Post by FrankenGraphics »

bregalad wrote:but actually this does not happen (in hardware) for sprites.[...] Normally any metasprite engine would check individual sprites so that no wrapping arround happens, period.
Ah! Thanks for correcting. Then the problem is even less of a problem.. since you can display the background in the leftmost column while hiding sprites.
gauauu wrote:But why games like Legendary Wings used it and DIDN'T have a status bar, I don't know.
The code might've been copied directly from another project in their repository to save a bit of time.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Advice for artifact free 4-way scrolling

Post by Bregalad »

FrankenGraphics wrote: Ah! Thanks for correcting. Then the problem is even less of a problem.. since you can display the background in the leftmost column while hiding sprites.
You can, but this is not what I'd call scrolling properly. Many games do not write to $2001 during gameplay so I invite you to use some cheat code to write $1a to $2001 (instead of the normal $1e or $18) during gameplay and see what happens. This looks super weird and is not what I'd call "proper scrolling". $18 is the canonical way to get 100% "proper" scrite scrolling, but in many cases using $1e and having sprites pop-up is acceptable.
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Advice for artifact free 4-way scrolling

Post by NewRisingSun »

I must say I find occasional sprite pop-up less annoying than constantly-black left 8 columns, especially if the graphics obviously weren't designed for it. A Boy and His Blob is the perfect example: thanks to the black bar on the left, the entire red border becomes assymetric. Ugly.
psycopathicteen
Posts: 3140
Joined: Wed May 19, 2010 6:12 pm

Re: Advice for artifact free 4-way scrolling

Post by psycopathicteen »

If people don't notice any popping on Kid Icarus, then it's not a big problem.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Advice for artifact free 4-way scrolling

Post by tokumaru »

I don't mind a little sprite popping, but it's annoying when games make entire characters pop.
Post Reply