It is currently Fri Feb 15, 2019 10:24 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Jul 30, 2009 8:35 am 
Offline
User avatar

Joined: Tue Jul 28, 2009 11:59 pm
Posts: 5
Hello again.

I seem to be getting along quite nicely in my first nesdev adventure. However, I'm having some trouble. I am trying to display some bg characters by writing to $2007. It seems to be working ok, but I can't seem to be able to set the position. I try writing the offsets to $2006 just before but it doesn't seem to have any effect (or not have the right effect at all) on the position of the characters. Is there something special I need to keep in mind while I do this?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 30, 2009 8:55 am 
Offline
User avatar

Joined: Tue Jul 17, 2007 9:04 am
Posts: 316
Location: Somewhere
Where do you want to position them?

If you wanted, say, to draw a tile that we'll number $10 in the middle of the screen twice, you'd want to do this:

LDA #$21 ;PPU will start at $21AF, which is around the center of the screen...
STA $2006
LDA #$AF
STA $2006

LDA #$10 ;Write the tile twice to have 2 $10's appearing
STA $2007
STA $2007

_________________
-Sivak
http://sivak.nintendoage.com/
http://www.youtube.com/user/SivakD


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 30, 2009 9:01 am 
Offline
User avatar

Joined: Tue Jul 28, 2009 11:59 pm
Posts: 5
This is pretty much what I'm doing right now. I'm using Blargg's example from this thread as a basis: http://nesdev.com/bbs/viewtopic.php?t=4860 but when I do the $2006 sets, it doesn't seem to work. It just always displays in the topleft.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 30, 2009 9:08 am 
Offline
User avatar

Joined: Tue Jul 28, 2009 11:59 pm
Posts: 5
Ok, so I added

Code:
   lda #$00
   sta $2005
   sta $2005       


After doing the writes to $2006 and how it's working. What exactly does writing two 0s to $2005 do?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 30, 2009 9:44 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21093
Location: NE Indiana, USA (NTSC)
The writes to $2005 reset the VRAM address such that (0, 0) is scrolled into the top left corner. Ordinarily, you shouldn't write to $2005 until AFTER all writes to $2006 and $2007 for this frame:
Code:
nmi:
  inc retraces
  pha
  txa
  pha
  ; [...]
  lda #$21
  sta PPUADDR
  lda #$AF
  sta PPUADDR
  lda #$01
  sta PPUDATA
  lda #$02
  sta PPUDATA
  ; [...]
  lda #0
  sta PPUSCROLL
  sta PPUSCROLL
  ; [...]
  pla
  tax
  pla
  rti


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: Google Adsense [Bot] and 10 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