It is currently Sat Oct 21, 2017 11:31 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Background rendering
PostPosted: Sun Jul 17, 2016 4:37 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
Writes to $2005 and $2006 change t in a manner described in the aforementioned wiki article.


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Sun Jul 17, 2016 8:35 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10066
Location: Rio de Janeiro - Brazil
T is usually changed during vblank, when the scroll is set. It might be changed during the frame as well, if the game is doing raster effects.


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Thu Jul 21, 2016 6:25 am 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
thank you all , I have noticed it when I read it again

I have another question now

as stated in nesdev wiki , background buffers are shift registers , and the lower 8 bits are fed to 8x1 mux (for each register of the four registers) and fine_x used as selections for those muxs

my question is how the shift register shifts while the fine_x counts ?! this for sure won't give the right output


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Thu Jul 21, 2016 6:35 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
Fine x doesn't count. Instead, it controls which bits are picked up as they shift past the mux.


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Thu Jul 21, 2016 7:00 am 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
tepples wrote:
Fine x doesn't count.


How ? I didn't understand


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Thu Jul 21, 2016 7:18 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
Fine x does not change during rendering. The only way it can change is if the program changes it by writing to the horizontal scroll value ($2005.first). If I write 105 ($69) as the horizontal scroll value, fine x becomes 1, as the fine scroll is taken from the low 3 bits of the scroll value, and $69 & $07 (that is, the low 3 bits of $69) is equal to 1. It remains 1 throughout the frame until I set a different horizontal scroll value.


What's the first word in this post that you didn't understand?


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Thu Jul 21, 2016 7:58 am 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
till your comment

I was thinking of it as a counter XXXX Xxxx the lower 3 bits are the fine and the upper 5 are the coarse

the are used in rendering such that XXXXX -> the tile number , xxx -> a pixel inside the tile no. XXXXX

while rendering , I believed that the is incrementing rendering from left to right


now you destroyed all this :D

so I am very confused now.


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Thu Jul 21, 2016 9:06 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
The upper 5 bits set the starting address in the nametable. The lower 3 bits set the amount by which pixels are delayed (higher = less delay).

Let's say the first four 8x1 pixel slivers on a particular scanline are as follows:

Code:
01002003 03300330 00112233 30020010


Then, for each X from 0 to 23, I break down how this scroll value is decomposed into a starting position and a delay amount:
Code:
x =   0: 00000 000. Coarse X =  0, fine X = 0. Start at tile  0, delay by 8 - 0 = 8
x =   1: 00000 001. Coarse X =  0, fine X = 1. Start at tile  0, delay by 8 - 1 = 7
x =   2: 00000 010. Coarse X =  0, fine X = 2. Start at tile  0, delay by 8 - 2 = 6
x =   3: 00000 011. Coarse X =  0, fine X = 3. Start at tile  0, delay by 8 - 3 = 5
x =   4: 00000 100. Coarse X =  0, fine X = 4. Start at tile  0, delay by 8 - 4 = 4
x =   5: 00000 101. Coarse X =  0, fine X = 5. Start at tile  0, delay by 8 - 5 = 3
x =   6: 00000 110. Coarse X =  0, fine X = 6. Start at tile  0, delay by 8 - 6 = 2
x =   7: 00000 111. Coarse X =  0, fine X = 7. Start at tile  0, delay by 8 - 7 = 1
x =   8: 00000 000. Coarse X =  1, fine X = 0. Start at tile  1, delay by 8 - 0 = 8
x =   9: 00001 001. Coarse X =  1, fine X = 1. Start at tile  1, delay by 8 - 1 = 7
x =  10: 00001 010. Coarse X =  1, fine X = 2. Start at tile  1, delay by 8 - 2 = 6
x =  11: 00001 011. Coarse X =  1, fine X = 3. Start at tile  1, delay by 8 - 3 = 5
x =  12: 00001 100. Coarse X =  1, fine X = 4. Start at tile  1, delay by 8 - 4 = 4
x =  13: 00001 101. Coarse X =  1, fine X = 5. Start at tile  1, delay by 8 - 5 = 3
x =  14: 00001 110. Coarse X =  1, fine X = 6. Start at tile  1, delay by 8 - 6 = 2
x =  15: 00001 111. Coarse X =  1, fine X = 7. Start at tile  1, delay by 8 - 7 = 1
x =  16: 00010 000. Coarse X =  2, fine X = 0. Start at tile  2, delay by 8 - 0 = 8
x =  17: 00010 001. Coarse X =  2, fine X = 1. Start at tile  2, delay by 8 - 1 = 7
x =  18: 00010 010. Coarse X =  2, fine X = 2. Start at tile  2, delay by 8 - 2 = 6
x =  19: 00010 011. Coarse X =  2, fine X = 3. Start at tile  2, delay by 8 - 3 = 5
x =  20: 00010 100. Coarse X =  2, fine X = 4. Start at tile  2, delay by 8 - 4 = 4
x =  21: 00010 101. Coarse X =  2, fine X = 5. Start at tile  2, delay by 8 - 5 = 3
x =  22: 00010 110. Coarse X =  2, fine X = 6. Start at tile  2, delay by 8 - 6 = 2
x =  23: 00010 111. Coarse X =  2, fine X = 7. Start at tile  2, delay by 8 - 7 = 1

When starting coarse X increases by 1, pixels arrive 8 pixels earlier than they would other have. But most of this being earlier is canceled out by the increased delay from fine X = 7 to fine X = 0 (from 1 to 8 pixels, a difference of 7 pixels). I'll run a few tiles for both x = 7 and x = 8 to show how two adjacent scroll values across a tile boundary changes the fetch pattern and which pixel is used.

With a horizontal scroll value of 7 (coarse X 0, fine X 7), the preroll at dots 321-336 has loaded two slivers from coarse X = 0 and coarse X = 1, leaving coarse X at 2.
Code:
SIPO      PISO      CX  Fetch
01002003  03300330   2  Nametable for X=2
10020030  3300330x   2
00200303  300330xx   2  Attribute for X=2
02003033  00330xxx   2
20030330  0330xxxx   2  Pattern plane 0 for X=2
00303300  330xxxxx   2
03033003  30xxxxxx   2  Pattern plane 1 for X=2
30330033  0xxxxxxx   2  Prepare to load sliver into PISO
03300330  00112233   3  Nametable for X=3
33003300  0112233x   3
30033000  112233xx   3  Attribute for X=3
00330001  12233xxx   3
03300011  2233xxxx   3  Pattern plane 0 for X=3
33000112  233xxxxx   3
30001122  33xxxxxx   3  Pattern plane 1 for X=3
00011223  3xxxxxxx   3  Prepare to load sliver into PISO
       ^
Fine X=7

Result:
30330033 00011223


With a horizontal scroll value of 8 (coarse X 1, fine X 0), the preroll at dots 321-336 has loaded two slivers from coarse X = 1 and coarse X = 2, leaving coarse X at 3.
Code:
SIPO      PISO      CX  Fetch
03300330  00112233   3  Nametable for X=3
33003300  0112233x   3
30033000  112233xx   3  Attribute for X=3
00330001  12233xxx   3
03300011  2233xxxx   3  Pattern plane 0 for X=3
33000112  233xxxxx   3
30001122  33xxxxxx   3  Pattern plane 1 for X=3
00011223  3xxxxxxx   3  Prepare to load sliver into PISO
00112233  30020010   4  Nametable for X=4
01122333  0020010x   4
11223330  020010xx   4  Attribute for X=4
12233300  20010xxx   4
22333002  0010xxxx   4  Pattern plane 0 for X=4
23330020  010xxxxx   4
33300200  10xxxxxx   4  Pattern plane 1 for X=4
33002001  0xxxxxxx   4  Prepare to load sliver into PISO
^
Fine X=0
Result:
03300330 00112233


Result from X = 7 (fine X = 7, starting coarse X = 0): 30330033 00011223
Result from X = 8 (fine X = 0, starting coarse X = 1): 03300330 00112233
These are offset by one pixel from each other.

Which is the first line of this diagram that still confuses you?


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Thu Jul 21, 2016 9:58 am 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
I some how understand some parts of what you said like usage of CX in nametable addressing

I will be really happy if I knew how the fine x changes allover this timing diagram

http://wiki.nesdev.com/w/images/d/d1/Ntsc_timing.png

I think this may solve my problem .


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Thu Jul 21, 2016 10:29 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
Again, the fine X does not change during the scanline.

I want to explain this with a parade analogy. Do they have parades where you live?


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Thu Jul 21, 2016 10:50 am 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
I really appreciate your help and really thank you

you can explain it in any way you want but in details


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Thu Jul 21, 2016 10:57 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
Say you have a band marching down the street row by row. If you sit in one place, you'll see each of the rows of people. Sit closer to the starting point, and they'll appear earlier. Sit farther from the starting point, and they'll appear later. Now say you have eight lawn chairs next to the street. You can change exactly when each row passes you by sitting in one of those chairs. You don't normally move from one chair to the next during the parade, except perhaps to use the restroom.

Now instead of a marching band, you have a pixel stream coming out of the PISO. If you make pixels appear earlier, they'll appear shifted to the left. (Because TV was invented in an English-speaking country, the screen is scanned from left to right, as in English.) Instead of lawn chairs, you have a mux. Fine X is which chair you're sitting in. And instead of a restroom, there's horizontal blanking.


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Thu Jul 21, 2016 11:37 am 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
I understand that if the fine x doesn't change ( fixed chair ) I can see the stream pxl by pxl ( row by row )

but what annoys me is the fine x it self , if it will be fixed on 000 all the time ( selecting the least bits of the shift registers ) this may be good as I finally understood as you said it won't change , but if that , why the mux ? why not taking the bits 0 of the four registers forwarding them out of the back.render unit ?

this means that also fine x can change , so , why may I change it ( the chair ) ?


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Thu Jul 21, 2016 11:39 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
Muhammad_R4 wrote:
but what annoys me is the fine x it self , if it will be fixed on 000 all the time ( selecting the least bits of the shift registers ) this may be good as I finally understood as you said it won't change , but if that , why the mux ? why not taking the bits 0 of the four registers forwarding them out of the back.render unit ?

You can scroll by changing only coarse X, but that allows scrolling only in 8-pixel increments. Several games for ZX Spectrum, ColecoVision, and MSX scrolled in 8-pixel increments due to hardware limits, but it's a lot jumpier.

Quote:
this means that also fine x can change , so , why may I change it ( the chair ) ?

You change which chair you're sitting in to advance or delay the whole band. You change fine X to scroll the whole screen in units smaller than 8 pixels.


Top
 Profile  
 
 Post subject: Re: Background rendering
PostPosted: Thu Jul 21, 2016 11:53 am 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
so fixing the mux selection on "000" will work for most games


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group