It is currently Wed Jul 18, 2018 5:56 am

 All times are UTC - 7 hours

 Page 2 of 2 [ 22 posts ] Go to page Previous  1, 2
 Print view Previous topic | Next topic
Author Message
 Post subject: Re: Getting right attribute tables with scrollingPosted: Thu Sep 22, 2016 1:24 pm

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10597
Location: Rio de Janeiro - Brazil
The fine X scroll should have no influence on the attributes at all! The AT address can easily be derived from the NT address:

Code:
NN: name table;
JIHGF: coarse Y scroll;
EDCBA: coarse X scroll;

So, if you fetch a tile from %00100101 01111010, simply get its attributes from the byte at %00100111 11010110, and use quadrant %10, while completely ignoring the lowest bit of the coarse X and Y scrolls (attributes are applied to 16x16-pixel areas after all) and the fine scroll. The address of a tile in the name tables is directly linked to the address of the attribute byte it uses.

Top

 Post subject: Re: Getting right attribute tables with scrollingPosted: Tue Sep 27, 2016 6:35 am

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70

So what was happening, I was trying to fetch tiles using the fine x scroll value, in order to draw pixels directly, grabbing attributes the same way, but when I calculated the quadrant using the V register, I would always be off by 0-7, depending on the fine X scroll value (except when there was no scroll).

So, what I did now, is to ignore the fine x scroll, and then move shift all pixels to the left using the fine X scroll value. Using my current logic, that leaves now the right pixels undrawn, since I'm calling the draw pixel function 256 times (and the first times don't draw anything if there's scroll).

Is there a way, to include the fine x scroll into the calculation of the quadrant ?? That would solve everything I think.

Top

 Post subject: Re: Getting right attribute tables with scrollingPosted: Tue Sep 27, 2016 8:36 am

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20258
Location: NE Indiana, USA (NTSC)
DarkMoe wrote:
So, what I did now, is to ignore the fine x scroll, and then move shift all pixels to the left using the fine X scroll value.

It turns out that's exactly what the PPU actually does. Fine X scroll has absolutely nothing to do with how tiles are fetched. The PPU has a set of shift registers used as a variable delay line to move the background 8-1 pixels to the right for fine X scroll values of 0-7.

Top

 Post subject: Re: Getting right attribute tables with scrollingPosted: Tue Sep 27, 2016 10:50 am

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
Excellent, thank you !

Top

 Post subject: Re: Getting right attribute tables with scrollingPosted: Wed Sep 28, 2016 7:00 am

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
One more question though.

If the PPU render a pixel for each PPU cycle, and cycle 0 is idle, it means that each pixel is rendered between cycles 1-256 on each scanline right ?

How does that work when there's a fine X scroll ? if I just discard the 7 first pixels (if fine X is 7), then I'm missing the right 7 pixels (the last pixels of the scanline).

I think I should bring another tile when fine scroll X is not 0, but how does it fit with the PPU timings ?

Top

 Post subject: Re: Getting right attribute tables with scrollingPosted: Wed Sep 28, 2016 7:36 am

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20258
Location: NE Indiana, USA (NTSC)
On each scanline, your PPU should fetch 34 tile columns during the following pixels:

• Fetch 1 is at X=321 to 328.
• Fetch 2 is at X=329 to 336.
• Fetch 3 has a false start at X=337, waits a few microseconds, and restarts at X=1 to 8. The MMC5 depends on this false start to detect a new scanline.
• Fetch 4 is at X=9 to 16.
• ...
• Fetch 33 (used for the partial row of tiles at right) is at X=241 to 248. The PPU uses this data for the partial column at far right whenever fine X scroll is nonzero. Otherwise, the PPU discards this fetched data.
• Fetch 34 (discarded) is at X=249 to 256. The PPU always discards this data, but games using the MMC2 and MMC4 depend on this discarded fetch to reset the bank number to the starting point.

Top

 Post subject: Re: Getting right attribute tables with scrollingPosted: Wed Sep 28, 2016 8:10 am

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
You couldn't make it any clear.

You're awesome, thank you !

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 2 of 2 [ 22 posts ] Go to page Previous  1, 2

 All times are UTC - 7 hours

#### Who is online

Users browsing this forum: No registered users and 6 guests

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

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2018 NESdev Competition       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki