nesdev.com
http://forums.nesdev.com/

$2007 read help
http://forums.nesdev.com/viewtopic.php?f=3&t=15113
Page 1 of 1

Author:  JSBryan [ Sun Nov 13, 2016 6:18 pm ]
Post subject:  $2007 read help

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 1802 times ]


If increment vram address after read:
Attachment:
increment.png
increment.png [ 38.23 KiB | Viewed 1802 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?

Author:  zzo38 [ Sun Nov 13, 2016 7:28 pm ]
Post subject:  Re: $2007 read help

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.)

Author:  rainwarrior [ Sun Nov 13, 2016 7:55 pm ]
Post subject:  Re: $2007 read help

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

Author:  Zepper [ Mon Nov 14, 2016 5:15 am ]
Post subject:  Re: $2007 read help

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.

Author:  tokumaru [ Mon Nov 14, 2016 5:56 am ]
Post subject:  Re: $2007 read help

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.

Author:  thefox [ Mon Nov 14, 2016 4:21 pm ]
Post subject:  Re: $2007 read help

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.

Author:  JSBryan [ Sat Nov 19, 2016 4:51 pm ]
Post subject:  Re: $2007 read help

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 1621 times ]

Author:  rainwarrior [ Sat Nov 19, 2016 4:54 pm ]
Post subject:  Re: $2007 read help

Some instructions (e.g. STA (ptr), Y) do cause two increments.

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

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/