It is currently Wed Oct 18, 2017 8:08 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Tue Jan 24, 2017 5:10 pm 
Offline

Joined: Sun May 03, 2015 8:19 pm
Posts: 89
Not exactly sure what the purpose of this is after reading through various docs. Maybe someone else can help. This is from an MMC3 game after transferring the buffer data to the PPU

Code:
   
        LDA #$00                       ; SET BUFFER LENGTH/TYPE = EMPTY
   STA $037D                  ;
                                                                ; DUMMY WRITES?
        LDA #$3F                  ; SET PPU ADDRESS TO $3F00  = PAL RAM
   STA $2006                  ;
   LDA #$00                  ;
   STA $2006                  ;
   STA $2006                  ; SET PPU ADDRESS TO $0000  = PATTERN TABLE
   STA $2006                  ;



Top
 Profile  
 
PostPosted: Tue Jan 24, 2017 5:14 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5714
Location: Canada
The PPU address is used during rendering to fetch tiles from the nametables. This shares the same bus and register as the one you use to write data to the PPU. Thus, after you're done messing around with it for writing data, it needs to be set back up in the correct position for reading before rendering happens.

This article might help:
http://wiki.nesdev.com/w/index.php/PPU_scrolling

A write to $2000, $2005, $2005 before the end of vblank should normally be sufficient, though. Usually it's easier to set scroll through $2005 than $2006. Some programmers do seem to write extra zeroes to $2006 as an unnecessary measure of protection? (Maybe from bad experiences while learning.)

The oft-maligned Nerdy Nights tutorial does two redundant $2006 writes in its examples, which if you're talking about a homebrew game, they might have learned to do it from that example.


Top
 Profile  
 
PostPosted: Tue Jan 24, 2017 5:34 pm 
Offline

Joined: Sun May 03, 2015 8:19 pm
Posts: 89
I understand why it is/might be necessary do the second write of all zeroes to PPUADDR. The write of $3F00 seems totally unneeded unless I'm misunderstanding something.

This is actually code from a commercial game.


Top
 Profile  
 
PostPosted: Tue Jan 24, 2017 5:37 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5714
Location: Canada
You didn't say what game the code was from, so I couldn't tell if you were talking about contiguous instructions or not.

If there's nothing in between the $3F00 and $0000 then yes, it's completely redundant and pointless, though it's not particularly surprising to hear about vestigial useless code in a commercial game. That happens all the time.


Top
 Profile  
 
PostPosted: Tue Jan 24, 2017 6:43 pm 
Offline

Joined: Sun May 03, 2015 8:19 pm
Posts: 89
Yup my bad. Thanks for the answer. That makes sense.


Top
 Profile  
 
PostPosted: Tue Jan 24, 2017 7:04 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19094
Location: NE Indiana, USA (NTSC)
The game where I first saw this was among the first NES games to have a top status bar. I bet back in 1985, not even Nintendo's programmers were sure exactly how the VRAM address worked.


Top
 Profile  
 
PostPosted: Tue Jan 24, 2017 7:47 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3943
Devil World scrolled vertically and horizontal with two splits, and that was before 1985. But they didn't know how to do both coarse and fine vertical scrolling then.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Tue Jan 24, 2017 7:52 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5714
Location: Canada
hackfresh wrote:
Yup my bad.

I don't think you did anything wrong by hiding the name of the game you're talking about, but it's not normally taboo here to mention games that you're debugging/disassembling. You're not allowed to post pirated ROMs, etc. but we talk about emulating specific games all the time.

I mean, if you have a good reason for it, I don't want to pry. Tepples apparently knows what game it is but has respected your intent to keep it unnamed.


Top
 Profile  
 
PostPosted: Wed Jan 25, 2017 12:05 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7228
Location: Chexbres, VD, Switzerland
Actually it's pretty standard for commercial games to write $3f00 and then $0000 to $2006. So many games does this I don't think it's relevant to mention a specific game.

Setting the adress to $3f00 ensures that color #0 is used for the backdrop. Setting it to $0000 however I don't see the point, perhaps to set the scroll to (0, 0).


Top
 Profile  
 
PostPosted: Wed Jan 25, 2017 12:43 am 
Offline

Joined: Sun May 03, 2015 8:19 pm
Posts: 89
The game in question is Tecmo Super Bowl. I have it basically 95+% commented and reverse engineered at this point. That was one of the few things I wasn't quite sure what the purpose was especially with both writes back to back.


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

All times are UTC - 7 hours


Who is online

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