It is currently Fri Mar 24, 2017 9:01 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Fri Dec 23, 2016 4:14 pm 
Offline

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 229
So this is a strange one...

I'm using horizontal mirroring. Originally, I'd used my main nametable (at $2000) pretty much exclusively. I've since decided to use the nametable at $2800 to handle my sub-menu so that I can easily preserve things like destructable terrain on a screen (don't have to reload the screen now, just shift to the other nametable).

Works fine for the most part except for one glaring thing.

So when the menu loads, game does a quick check to see what inventory items have been attained and either draws them or draws a *blank square* in their space. While the screen is turned off, if the inventory item bit is checked, it might originally have loaded the blank tile to $20A4, $20A5, $20C4 and $20C5. This worked fine.

Now, I'm transitioning to write it at $28A4, $28A5, $28C4 and $28C5. I know these are the correct addresses. However, when doing this, it draws this with a weird offset and not where it should. I've also tried in place making sure that the scroll is set to 0, but that didn't fix it.

Code is pretty simple - looks like:

Code:

LDA #$28
STA $2006
LDA #$a4
STA $2006
LDA #$f5 ;; the tile
STA $2007



Should this essentially do the exact same as $20 and $a4 respectively when that other nametable is showing? Anyone think of why this might not yield the same visual result?


Top
 Profile  
 
PostPosted: Fri Dec 23, 2016 4:18 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 5410
Location: Seattle
Use a debugging emulator with a nametable viewer, set a breakpoint on the write, and see what exact address it ends up at?


Top
 Profile  
 
PostPosted: Fri Dec 23, 2016 4:44 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1415
Location: DIGDUG
Some possibilities...

Typo...LDA #$a4 could be LDA $a4

Flip flop on the 'latch' wrong, one too many or too few 2005 and/or 2006 writes somewhere.

Wrong timing...trying to write during rendering.

Should be easy to spot in FCEUXs debugger. Set a breakpoint for writes to PPU in the range you want, look at the code around the write....look at the current PPU address set....look at the current scanline.

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


Top
 Profile  
 
PostPosted: Fri Dec 23, 2016 5:20 pm 
Offline

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 229
Huh - thanks for the suggestions. Oddly enough, it was the matter of rendering not being turned off...strange. Tracing it through, it SHOULD be off at this point, but sure enough when I sandwiched a write between a render off - on, worked fine.

This problem didn't manifest when using the first nametable, which is equally curious. But this seems to have fixed it.

Thanks!


Top
 Profile  
 
PostPosted: Fri Dec 23, 2016 8:58 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 9412
Location: Rio de Janeiro - Brazil
The fact that you're having to turn rendering off and on to perform this update can be an indication that something else is wrong though.

Normally, if you're only using the regular amount of vblank time, you shouldn't *need* to turn rendering off. Some people choose to turn referring off during vblank just to be safe, but it's not mandatory. If your update only works this way, it could mean you're consistently using more time than available during vblank (in which case updates performed before the problematic one would succeed just fine), or that you're simply picking the wrong time (i.e. during rendering) to do this update.

This is definitely something you should look into, and not assume everything is fine because forcing the PPU off apparently fixes it.

Can you show us a little more code to contextualize those $2006/7 writes? Are you doing this in the NMI handler? What other takes are being performed in this handler?


Top
 Profile  
 
PostPosted: Fri Dec 23, 2016 10:24 pm 
Offline

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 229
I'll keep an eye, but this is happening when screen is off - fade out -> screen off -> new screen load (including this function) -> screen on -> fade up.


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: Bing [Bot] 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