It is currently Thu Aug 16, 2018 3:17 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: 2003 register
PostPosted: Mon Jul 30, 2018 1:00 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2197
Location: DIGDUG
I was looking at some source code that only writes to $2003 (zero) once during init, and never again.

All the other source code I've seen, writes zero just before OAM DMA.

Does anyone think this will cause problems?

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
 Post subject: Re: 2003 register
PostPosted: Mon Jul 30, 2018 1:09 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6588
Location: Canada
As long as the OAM DMA completes properly there shouldn't be a problem because it leaves the address back at 0 after cycling through them all. I think it's needed at init in case a reset happens in the middle of a DMA.

Though I would kind of wonder about badly done OAM DMA, like if you had it hanging out of vblank or something? Dunno what'd happen then, but that probably would cause other problems too.


Top
 Profile  
 
 Post subject: Re: 2003 register
PostPosted: Mon Jul 30, 2018 2:42 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10713
Location: Rio de Janeiro - Brazil
I'm pretty sure the PPU itself resets $2003 periodically (once per scanline or something) as part of the sprite evaluation process, so you aren't really required to, but you can do it just to be safe.


Top
 Profile  
 
 Post subject: Re: 2003 register
PostPosted: Mon Jul 30, 2018 3:57 pm 
Online
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3476
Location: Mountain View, CA
tokumaru wrote:
I'm pretty sure the PPU itself resets $2003 periodically (once per scanline or something) as part of the sprite evaluation process, so you aren't really required to, but you can do it just to be safe.

https://wiki.nesdev.com/w/index.php/PPU ... evaluation

Quote:
If the sprite address (OAMADDR, $2003) is not zero at the beginning of the pre-render scanline, on the 2C02 an OAM hardware refresh bug will cause the first 8 bytes of OAM to be overwritten by the 8 bytes beginning at OAMADDR & $F8 before sprite evaluation begins.


Top
 Profile  
 
 Post subject: Re: 2003 register
PostPosted: Mon Jul 30, 2018 5:15 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10713
Location: Rio de Janeiro - Brazil
https://wiki.nesdev.com/w/index.php/PPU ... _.3E_write

Quote:
OAMADDR is set to 0 during each of ticks 257-320 (the sprite tile loading interval) of the pre-render and visible scanlines.

If you don't initialize $2003 at all, you might get a frame with corrupted sprites when you first enable rendering, but since OAMADDR is consistently reset to 0 at the end of every scanline, you can count on it being 0 before doing an OAM DMA during vblank, which means it will roll back to 0 once the DMA is done, and everything will be fine for the next frame.


Top
 Profile  
 
 Post subject: Re: 2003 register
PostPosted: Mon Jul 30, 2018 7:02 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2197
Location: DIGDUG
Ok. That helps.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: FrankenGraphics, Google [Bot], koitsu, lidnariq, Nicole and 5 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