Skinny on NES scrolling

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

3gengames
Formerly 65024U
Posts: 2281
Joined: Sat Mar 27, 2010 12:57 pm

Post by 3gengames »

Maybe I saw somebody elses breakdowns on loopys site, but the "old one" was always 3 or so pages long, and had no charts like that. Maybe I'm thinking of another scrolling doc.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

Everything above "Examples" is straight out of loopy; everything from "Examples" on down is brand new.
Drag
Posts: 1350
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Post by Drag »

Shiru wrote:Code explaination in this way (do this one time, that two times etc) gives more opportunity to make a mistake.
Any kind of code explanation leaves opportunities for mistakes.
Shiru wrote:It is always said that the last two writes should be done in the h-blank time, but never explained why, what could happen if they aren't, and how to get them into the h-blank properly (not obvious, since the hblank time is short).
If the last two writes are outside of h-blank, then there'll be ugly glitches where you split the screen. There may also be some "shaking" if it's not properly inside h-blank.

The way you delay your code depends on how you're splitting the screen; are you using MMC3? Are you using sprite 0? The absolute worst case scenario is that the programmer guesses how long to wait, and just adjusts until there isn't an ugly glitch in the middle of the screen anymore. :P
Shiru
Posts: 1161
Joined: Sat Jan 23, 2010 11:41 pm

Post by Shiru »

What shaking? I had something that is difficult to call 'shaking' in Lawn Mower. It was not wobbling a scanline up-down, more like two screens with different X offsets alternating every frame (i.e. ghostly doubled picture) - for the whole bottom part of the screen, where the scrolling is applied after split. Unfortunately it seems I don't have the recording of the problem.

I'm personally interested to see code for sprite 0 hit. The problem with the 'guess' way is that it requires to have the hardware, as emulators don't show glitches in this case, at least not the one that was in Lawn Mower.
Drag
Posts: 1350
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Post by Drag »

Bregalad wrote:I'm sorry but what you write to $2006 IS an adress - if you forget about the high 2 bits that is.
At least for me things became MUCH easier to understand that way.

As long as you keep writing coherent things to $2005/6 (that is the name table adress you write to $2006 correspond exactly to the scroll position you write with $2005) then there should be no glitches, and the order in which you write the registers does only matter for fine scrolling. Any order should do as long as you end by a final $2006/2 write.
What you write to $2006 is only an address when you're writing to $2006 in order to use $2007 to access PPU memory. If you're writing to $2006 to change the scrolling, then what you write isn't necessarily going to be an address.

For example, to scroll the screen to the tile at $22A0, you need to write $02A0 to $2006. If you write $22A0 instead, then the screen does start at tile $22A0, but it'll start two pixels down, instead of at the top.

$02A0 scrolls you to the tile at $22A0, but the actual address $02A0 points to the pattern table. Thus, what you write to $2006 may not always correspond exactly to what you think it logically should.

Similarly, writing $12A0 will start 1 row into tile $22A0, and $32A0 will start 3 rows into $22A0. So again, when you're writing to $2006 to set the scrolling, and not to access PPU memory with $2007, then as far as you're concerned, you're not writing an address, you're setting a bunch of counters.

Edit: The only reason I'm so vocal about seeing it this way is because everyone needs to know that the highest nybble of what you write to $2006 has an effect; you cannot just use the address for a nametable tile without subtracting $2000 first.
Last edited by Drag on Sat Jun 02, 2012 8:40 pm, edited 1 time in total.
Shiru
Posts: 1161
Joined: Sat Jan 23, 2010 11:41 pm

Post by Shiru »

No need to answer to my problem. It was an year and many projects ago, so I have no idea what I was writing - something that I was told to in a forum thread, and that worked in all emulators. I guess if I had the hardware, I would find how to do it properly, by trial and error. But I didn't have the hardware, still don't have, and probably won't have - so it would be nice to have proper working code with all explainations how to use it without such problems, and/or emulators that show the same glitches as the HW.
Drag
Posts: 1350
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Post by Drag »

Shiru wrote:What shaking? I had something that is difficult to call 'shaking' in Lawn Mower. It was not wobbling a scanline up-down, more like two screens with different X offsets alternating every frame (i.e. ghostly doubled picture) - for the whole bottom part of the screen, where the scrolling is applied after split. Unfortunately it seems I don't have the recording of the problem.
The shaking would be a scanline up-down wobbling.

What were you splitting the screen for? You weren't scrolling the top half, were you? I saw your code snippet in the other thread, it looked like it should work, so I'm thinking it could be a problem somewhere else in the code. Without seeing the rest of your code, the rom, or a video or anything, I can't do much to help. :P

Finally, I know the 2006/5/5/6 trick works, I've done it myself in a failed homebrew attempt, and I saw it work (scrolling and all) on a PowerPak.
Shiru
Posts: 1161
Joined: Sat Jan 23, 2010 11:41 pm

Post by Shiru »

Top part was fixed (stats), bottom part was scrolled left-right and up-down (rarely).

I doubt that the problem was somewhere else, because vertical scroll worked in all emulators. It didn't work on the hardware only, and was removed.

The ROM and source code are available for an year now. It is not hidden. I lost the video, as I said two posts ago.

Still, no need to solve this particular problem. I'm not going to change a game that was released long ago. I would like to have a working solution in case I'd need it in the future.
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Post by Bregalad »

For example, to scroll the screen to the tile at $22A0, you need to write $02A0 to $2006. If you write $22A0 instead, then the screen does start at tile $22A0, but it'll start two pixels down, instead of at the top.
Yes, and the adress of the corresponding tile is still $22A0.
As I said, it's an address exept for the higher 2 bits. And basically you're explaining me it's not an adress because of those 2 bits... but I already know that.
You're right that in hardware you're setting a bunch of counters, but it's actually totally equivalent, and I think it's much easier to think in therms of adresses. You just take the adress, AND it with $fff, and OR it with the Y fine scroll, and there you are. Much easier than understanding all this crappy counters stuff.

Edit: The only reason I'm so vocal about seeing it this way is because everyone needs to know that the highest nybble of what you write to $2006 has an effect; you cannot just use the address for a nametable tile without subtracting $2000 first.
Of course you can !
It's just it will affect the fine scroll.
Useless, lumbering half-wits don't scare us.
Drag
Posts: 1350
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Post by Drag »

Two different people interpreting things two different ways, I suppose.
Post Reply