It is currently Sun Aug 18, 2019 8:08 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Jul 05, 2019 12:53 am 
Offline
User avatar

Joined: Fri Mar 16, 2018 1:52 pm
Posts: 93
Location: Finland
I saw this loop in Rockman 3's reset code (not sure if Mega Man 3 has it, but it probably will). As far as I know only the first two writes to $2006 after reading $2002 have any significant results. The EOR in the loop is also a bit odd. It would write #$00 every other loop and #$10 on the others, but it still doesn't have any significant meaning what the loop is supposed to achieve.

Code:
 LDA $2002
 LDA #$10
 TAY
 
Loop:
 STA $2006
 STA $2006
 EOR #$10
 DEY
 BNE Loop


I'm not sure if the second write to $2006 resets the latch similar to reading $2002, but according to FCEUX it does since the PPU address changes between $0000 and $1010.

EDIT: I should also add that there are no writes to $2007 anywhere near this loop


Last edited by SusiKette on Fri Jul 05, 2019 1:45 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Jul 05, 2019 1:20 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 8531
Location: Seattle
SusiKette wrote:
As far as I know only the first two writes to $2006
If rendering is disabled, only the last two writes will have any significant results. (nesdevwiki:PPU scrolling)
Quote:
after reading $2005
$2005 is a write-only register. They might have meant to type $2002...
Quote:
it still doesn't have any significant meaning what the loop is supposed to achieve.
It doesn't obviously do anything useful.

Even if rendering were enabled, the main loop there is only 15 cycles long, or 45 pixels: far too fast to be anything interesting graphically.


Top
 Profile  
 
PostPosted: Fri Jul 05, 2019 1:48 am 
Offline
User avatar

Joined: Fri Mar 16, 2018 1:52 pm
Posts: 93
Location: Finland
It was supposed to be $2002. That was my mistake. Still there is no reason I know of to write useless code.


Top
 Profile  
 
PostPosted: Fri Jul 05, 2019 4:14 am 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11397
Location: Rio de Janeiro - Brazil
We have a far better understanding of the intricacies of the PPU today than developers back in the day had. It's not unusual to find useless PPU accesses in commercial games.


Top
 Profile  
 
PostPosted: Fri Jul 05, 2019 5:12 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1473
This logic is actually quite common in games which used the MMC3. Its actual function is to manually clock the IRQ counter 8 times (by toggling the VRAM address between $0000 and $1010), though we don't actually know why this was done - perhaps it was for compatibility with older chip revisions, to make sure the counter was initialized properly.

Interestingly, there are also quite a few games (including Super Mario Bros. 3) which used a broken version of that code, performing EOR #$00 instead of EOR #$10 - given that these games seemed to work just fine, this would be consistent with the idea of the code being used for compatibility with older (perhaps pre-production) chips.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


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

All times are UTC - 7 hours


Who is online

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