It is currently Fri Feb 15, 2019 10:46 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sun Feb 22, 2009 6:46 pm 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 1107
Location: Pennsylvania, USA
I am attempting to play around with writing the VRAM address and tile offsets using $2006. From documentation, it looks like bits 12-14 in the VRAM address are the tile y offset. That means the first time we write to $2006, the upper nibble of the byte is essentially the tile y offset, correct? (with the 15th bit ignored) When I try this out and check out the scrolling with FCEUXD, I am able to increment the tile y offset from 0 to 3, but when I set it to 4, it appears to wrap to 0, as though the 14th bit is being ignored when I write.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 22, 2009 7:09 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1849
This is because the first write to $2006 only uses bits 0-5 (high 2 bits are forced to zero). This makes fully specifying the fine Y scroll impossible with $2006 alone.

To do this (assuming you can't just use $2005 -- like if you want to change V scroll mid frame or something), you need to alternate $2006 and $2005 writes. Do the writes in the following order:

$2006 - write NT scroll (NT scroll in bits 2,3)
$2005 - fine Y scroll
$2005 - fine X scroll
$2006 - write low byte of PPU address (coarse X scroll + 3 bits of coarse Y scroll)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 22, 2009 7:19 pm 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 1107
Location: Pennsylvania, USA
Thanks. Now I understand skinny.txt! I didn't quite understand Loopy's shorthand until I read your response.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 22, 2009 7:38 pm 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 1107
Location: Pennsylvania, USA
Will writing in this order have the same effect?

;$2006 - write NT scroll (NT scroll in bits 2,3)
;$2006 - write low byte of PPU address (coarse X scroll + 3 bits of coarse Y scroll)
;$2005 - fine X scroll
;$2005 - fine Y scroll

We switch the writes to $2005 since $2006 and $2005 share the toggle for high/low byte.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 22, 2009 7:45 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1849
The thing is that these writes only affect the temporary PPU address (loopy_t) and not the real PPU address (loopy_v). The only way the real PPU address can be changed is automatically by the PPU at frame start (provided rendering is enabled) -- or on the second $2006 write. $2005 writes never update the real address.

This is why the second $2006 write must be the last in the series. Doing it your way would work for setting the temp address, but the $2005 writes would have no effect on the real PPU address.

And if you're using $2005 this way, you might as well just ditch $2006 completely and use the NT scroll bits from $2000 instead.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 22, 2009 8:19 pm 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 1107
Location: Pennsylvania, USA
Ah! Now I understand the v=t under the second write to $2006 in skinny.txt. That is when the real address gets written. Thank you, this has been very helpful!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2009 8:38 am 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 1107
Location: Pennsylvania, USA
I notice in skinny.txt that v=t also on frame start. That would seem to imply that one could set the scrolling with $2006, and then $2005 as the last thing you do in your vblank, so it is ready for the next vblank. Is this common also?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2009 9:12 am 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1849
Not really, because if you're doing this in VBlank, there's no reason to use $2006 at all. You can use the low 2 bits of $2000 to set the NT scroll, and use $2005 to set the remaining scroll bits normally. $2000+$2005 do it all... the only thing they don't do is explicitly change loopy_v.

The only time you need to use $2006 to change the scroll is if you're changing the Y scroll mid-frame (like for a status bar or something -- or if you're turning rendering on late and miss the PPU's automatic v=t)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2009 3:00 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3855
Location: A world gone mad
This is probably the best "summarised" explanation (for programmers) I've ever seen. For years I've wondered why games I'd disassembled wrote to $2005/2006 in the order they did, figuring it wasn't important...

Maybe I'll have to go back and fix my FF2e intro for Demiforce.

Thanks a ton, Disch. You have no idea how much I appreciate what you've posted. :-)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 2:40 pm 
Offline

Joined: Thu Jul 13, 2006 3:15 pm
Posts: 177
I second that.
Al


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 6:32 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1849
glad I could help ^^


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 8:43 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11165
Location: Rio de Janeiro - Brazil
koitsu wrote:
This is probably the best "summarised" explanation (for programmers) I've ever seen. For years I've wondered why games I'd disassembled wrote to $2005/2006 in the order they did, figuring it wasn't important...

I guess this serves as one more evidence that loopy's doc just isn't clear enough. A few years back I came here for explanations because I simply couldn't understand his document. I finally did though, with a little help.

If someone decides to present that information in a more friendly way (with a wiki entry maybe, instead of just a link to the original doc), they should also make clear that tricky $2005/$2006 writes are only necessary for messing with the scroll *after* the start of the frame. Many people seem to think that using $2006 for scrolling is required, while $2000 and $2005 were designed for manipulating the scroll under normal circunstances (during VBlank).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 9:12 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2157
Location: Minneapolis, Minnesota, United States
tokumaru wrote:
I guess this serves as one more evidence that loopy's doc just isn't clear enough.


I think that's kind of an understatement. It's not really as unclear as much as it's like a riddle or something. Basically the document gives you obscure clues or hints rather than answers.

I still have to go through this thread to fully understand the relationship between $2005/$2006 for changing the scroll mid frame. But I can already tell just by skimming through it that it's a nicely condensed explanation of this.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2009 4:19 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
I cleaned up a summary of $2000/$2005/$2006 behavior I wrote for myself.


Last edited by blargg on Sun Mar 01, 2009 4:15 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2009 9:22 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7664
Location: Chexbres, VD, Switzerland
Well I always had trouble understanding loopy's docs and also wrote some kind of summary, tough it's really on the practical side and not on the theorical side (it does covers all regs, but a long paragraph is about $2005, $2006 and $2000 updates).

You can get a html version and a txt version.

_________________
Life is complex: it has both real and imaginary components.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 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