Scrolling ($2005) two nametables and stop at the last one

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

Post Reply
sdm
Posts: 410
Joined: Tue Apr 11, 2006 4:08 am
Location: Poland

Scrolling ($2005) two nametables and stop at the last one

Post by sdm »

I have a problem with scrolling two screens (two nametable in all 2KB VRAM). I just wish that at the end of the scrolling would ideally stay on the second nametable ($ 2400). Unfortunately, when the XSCROLL value reaches FF, the second screen is uneven (one pixel).

Two test roms, press any button to start scrolling.

Demo1 - inc scroll, when the value reaches FF, they stop scrolling.
Demo2 - inc scroll, when the value reaches FF, it stops scrolling and set a bit0 in $2000 to change the nametable to 2400. Here is everything ok, the screen stops evenly.

I would, however, without changing $2000 bit0, to do the scrolling so that the screen stopped perfectly on the second nametable. XSCROLL #$FF value secont screen is uneven, and once again the value of 00 is the beginning of the first nametable.

EDIT: Ok, thanks for the info, at least I'm sure now.
Attachments
demo1.nes
XSCROLL value FF - stopping at end is uneven
(256.02 KiB) Downloaded 105 times
demo2.nes
Here at the end of the scrolling I switched the nametable address to 2400 (bit0 in $2000)
(256.02 KiB) Downloaded 106 times
Last edited by sdm on Mon Nov 06, 2017 2:15 am, edited 1 time in total.
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: Scrolling ($2005) two nametables and stop at the last on

Post by thefox »

Why?

(It's not possible. This is why the nametable bits in $2000 exist in the first place!)
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: Scrolling ($2005) two nametables and stop at the last on

Post by dougeff »

The scrolling registers are working exactly as they were designed.

With X scroll set to FF, it should be 1 pixel misaligned.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
Kasumi
Posts: 1293
Joined: Wed Apr 02, 2008 2:09 pm

Re: Scrolling ($2005) two nametables and stop at the last on

Post by Kasumi »

To elaborate:

0 shows 256 pixels of nametable 1, 0 pixels of nametable 2.
1 shows 255 pixels of nametable 1, 1 pixel of nametable 2.
2 shows 254 pixels of nametable 1, 2 pixels of nametable 2.
...
255 shows 1 pixel of nametable 1, 255 pixels of nametable 2.

That's the full range of a byte, there's not a value left for 0 pixels of nametable 1, 256 pixels of nametable 2 without changing $2000.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Scrolling ($2005) two nametables and stop at the last on

Post by tokumaru »

The two name tables side by side create a 512-pixel wide area, with pixels numbered 0 through 511, which needs 9 bits to be represented. The scroll registers are only 8 bits, so they can't possibly cover the whole area by themselves. The lower bits of $2000 are effectively the "9th bits" of the scroll values, you absolutely need them if you want total control of the scroll, otherwise you'll run into situations like the one you're in right now, where you can't scroll to certain places.
Post Reply