It is currently Tue Dec 11, 2018 5:17 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: PPUADDR ($2006) 2x write
PostPosted: Sun Jul 23, 2006 4:27 pm 
Offline

Joined: Fri Jun 16, 2006 8:48 am
Posts: 13
in the following code:

Code:
; load palette into $3f00
load_palette:
      lda #$3f
      ldx #$00
      sta $2006
      sta $2006
*      lda palette, x
      sta $2007
      inx
      cpx #$20
      bne -
      rts


when writing twice to $2006, on the first write A = #$3f. On the second write does A = #$00? I forgot how this works.

Thank You

matthew


Top
 Profile  
 
 Post subject: answer
PostPosted: Sun Jul 23, 2006 5:35 pm 
Offline
User avatar

Joined: Thu Feb 02, 2006 7:07 am
Posts: 119
Location: Chile (South America), Quilpué
Code:
; load palette into $3f00
load_palette:
      lda #$3f      A=#$3F
      ldx #$00     X=#$00   ; A=#$3F

i imagine that you did read $2002 in order to reset 1st/2nd write latch
for using with $2005 and $2006.

      sta $2006   store #$3F in $2006.

      sta $2006  store #$3F in $2006.

Then you will write to palette starting at $3F3F.
If you want write to $3F00, i recommend changue the last
sta $2006 into stx $2006.

*      lda palette, x
      sta $2007
      inx
      cpx #$20
      bne -
      rts


start address for first entry of palette is $3F00.
registers like A, etc dont changue automatically or reset to 0.
If you lda #$03, it remains in 3 until you changue A.

_________________
Good day to nesdev people. Lord..
Author of nothing =P
UTFSM Sansano programmer.. lord_Chile
Saludos a la Sede JMC de la UTFSM... Viña del Mar, CHILE


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 23, 2006 6:59 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3596
Location: Indianapolis
It looks like the second write was intended to be STX $2006. Since X is zero.

These are the worst kind of typo bugs.. the ones that assemble without error.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 23, 2006 11:06 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Especially because in this case setting VADDR to $3F3F will cause your palette to be shifted by just one entry, making you think the error must be something subtle in your loop.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 24, 2006 12:10 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7601
Location: Chexbres, VD, Switzerland
Oh, yeah, such bugs are terrible to found out, because your code look just like its supposed to look, and it assemble without error.
Other common terrible errors are to put a pha, but no pla later, which assemble without errors, but causing your programm to crash at some point under some circunstences.

Also, writing lda Blahblah,X instead of lda Blahblah,Y or the other way arround is also a common damn error. You figure out that you load the wrong data, but don't know why and your code looks just as it is supposed to.

_________________
Life is complex: it has both real and imaginary components.


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 1 guest


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