It is currently Thu Dec 14, 2017 9:41 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: $2007 read help
PostPosted: Sun Nov 13, 2016 6:18 pm 
Offline

Joined: Sat Oct 08, 2016 4:13 pm
Posts: 3
I am having trouble getting the screen to display right if I increment vram address after a $2007 read.

If not increment vram address after read:
Attachment:
no_increment.png
no_increment.png [ 21.06 KiB | Viewed 1798 times ]


If increment vram address after read:
Attachment:
increment.png
increment.png [ 38.23 KiB | Viewed 1798 times ]


I know both screens are not right but it is worse if I increment vram address. Has anyone run into the same issue before?


Top
 Profile  
 
 Post subject: Re: $2007 read help
PostPosted: Sun Nov 13, 2016 7:28 pm 
Offline
User avatar

Joined: Mon Feb 07, 2011 12:46 pm
Posts: 941
Did you ensure to be incremented by 1 or 32 correctly? (I don't know if that will cause the problem here or not, but that is what I can think of right now.)

_________________
.


Top
 Profile  
 
 Post subject: Re: $2007 read help
PostPosted: Sun Nov 13, 2016 7:55 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5898
Location: Canada
Not directly about incrementing, but do you know that reads from $2007 (except the palette) are buffered? There is one byte of storage between the $2007 read and the result that gets loaded into your register, so you get the byte from the previous PPU address read, not the current one.

Some info here: Wiki: PPU registers


Top
 Profile  
 
 Post subject: Re: $2007 read help
PostPosted: Mon Nov 14, 2016 5:15 am 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3076
Location: Brazil
rainwarrior wrote:
Not directly about incrementing, but do you know that reads from $2007 (except the palette) are buffered? There is one byte of storage between the $2007 read and the result that gets loaded into your register, so you get the byte from the previous PPU address read, not the current one.

Some info here: Wiki: PPU registers

That... and probably wrong palette mirroring.


Top
 Profile  
 
 Post subject: Re: $2007 read help
PostPosted: Mon Nov 14, 2016 5:56 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
JSBryan wrote:
I know both screens are not right but it is worse if I increment vram address.

It may look worse at first glance, but you can at least make out some of the game's title, which is completely absent in the other shot.

SMB is known for reading the title screen data from the CHR-ROM, and people get wrong at first for not implementing the 1-byte delay that exists when reading $2007. When the CPU reads $2007, it gets a buffered value, and the value at the location indicated by the VRAM address register gets loaded into the buffer, so it will be returned to the CPU on the *next* read. The only exception to this is when reading from the palette area, in which case values are returned immediately (the value in the mirrored name table underneath is still loaded into the buffer, though).

Another thing this game is famous for relying on is palette mirroring. If you don't get this right, you get those black boxes around stuff.


Top
 Profile  
 
 Post subject: Re: $2007 read help
PostPosted: Mon Nov 14, 2016 4:21 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2983
Location: Tampere, Finland
The first one is missing the "SUPER MARIO BROS" logo, hinting that the reads are not working correctly.

Second one has a space after each character, hinting that the writes are incrementing the PPU address twice.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
 Post subject: Re: $2007 read help
PostPosted: Sat Nov 19, 2016 4:51 pm 
Offline

Joined: Sat Oct 08, 2016 4:13 pm
Posts: 3
Thank you all for your helps. It turns out and correct me if I am wrong. We are supposed to increment VRAM address only once PER instruction. Before the fix I incremented VRAM address after each read or write. So I actually incremented it twice in one instruction. I also fixed the palette issue and now it looks fine.

Attachment:
title.png
title.png [ 27.55 KiB | Viewed 1617 times ]


Top
 Profile  
 
 Post subject: Re: $2007 read help
PostPosted: Sat Nov 19, 2016 4:54 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5898
Location: Canada
Some instructions (e.g. STA (ptr), Y) do cause two increments.

Info: http://forums.nesdev.com/viewtopic.php?p=101286#p101286


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 7 hours


Who is online

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