It is currently Thu Dec 14, 2017 3:55 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Thu Sep 22, 2016 1:24 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
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;
NT address: %0010NNJI HGFEDCBA
AT address: %0010NN11 11JIHEDC
Quadrant: %GB

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
 Profile  
 
PostPosted: Tue Sep 27, 2016 6:35 am 
Offline

Joined: Sat Jun 27, 2015 1:09 pm
Posts: 70
Followed all your advise, and got closer to the right behaviour.

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
 Profile  
 
PostPosted: Tue Sep 27, 2016 8:36 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19345
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
 Profile  
 
PostPosted: Tue Sep 27, 2016 10:50 am 
Offline

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


Top
 Profile  
 
PostPosted: Wed Sep 28, 2016 7:00 am 
Offline

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
 Profile  
 
PostPosted: Wed Sep 28, 2016 7:36 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19345
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
 Profile  
 
PostPosted: Wed Sep 28, 2016 8:10 am 
Offline

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

You're awesome, thank you !


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: MLX 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