nesdev.com
http://forums.nesdev.com/

Question about chr to chr-ram!
http://forums.nesdev.com/viewtopic.php?f=19&t=9524
Page 1 of 1

Author:  byemu [ Mon Nov 26, 2012 7:33 pm ]
Post subject:  Question about chr to chr-ram!

I try to convert a chr to chr-ram!
here is the code:
Code:
 LDY #$0    ; starting index into the first page
 STY $2001  ; turn off rendering just in case
 STY $2006  ; load the destination address into the PPU
 STY $2006
 
 LDX #$20   ; number of 256-byte pages to copy
 
loop:
  LDA ($0000),Y; $0000 is address at 0x8000
  STA $2007
  INY
  BNE loop  ; repeat until we finish the page
  LDA $1
  ADC #$1
  STA $1  ; go to the next page
  DEX 
  BNE loop  ; repeat until we've copied enough pages


But some time the cram is wrong!
some data is malposed!

Author:  3gengames [ Mon Nov 26, 2012 7:37 pm ]
Post subject:  Re: Question about chr to chr-ram!

Probably didn't turn off rendering, you can't touch the PPU Data Port during rendering.

Author:  Kasumi [ Mon Nov 26, 2012 7:52 pm ]
Post subject:  Re: Question about chr to chr-ram!

His very first two lines shows a 0 write to $2001.

But NMIs might still be firing. Try disabling NMIs as well, if they aren't already disabled in unseen code.

Author:  byemu [ Mon Nov 26, 2012 7:53 pm ]
Post subject:  Re: Question about chr to chr-ram!

3gengames wrote:
Probably didn't turn off rendering, you can't touch the PPU Data Port during rendering.


Always wrong :(

Author:  3gengames [ Mon Nov 26, 2012 7:54 pm ]
Post subject:  Re: Question about chr to chr-ram!

Sorry, I use labels for those ports in my code so I didn't think he wrote to any ports like that just giving it a 5 second look. But yeah, NMI's could fire, you may not be declaring CHR-RAM in the header...hmmm...would it be impossible to get a source?

ETA: You can make the outer loop INC $01,DEX,BNE btw.

Author:  Kasumi [ Mon Nov 26, 2012 8:01 pm ]
Post subject:  Re: Question about chr to chr-ram!

Another issue could be it's incremented by 32 instead of 1. If you end up writing to $2000 to disable NMIs, make sure you also set it to increment by one. Another issue is this:

Code:
LDA $1
  ADC #$1
  STA $1  ; go to the next page

You don't clear the carry flag before this add, so it could be adding 2, not 1 sometimes.

Also, in this case inc $1 in place of the load, add, store would do the same thing.

Author:  byemu [ Mon Nov 26, 2012 8:06 pm ]
Post subject:  Re: Question about chr to chr-ram!

3gengames wrote:
Sorry, I use labels for those ports in my code so I didn't think he wrote to any ports like that just giving it a 5 second look. But yeah, NMI's could fire, you may not be declaring CHR-RAM in the header...hmmm...would it be impossible to get a source?

ETA: You can make the outer loop INC $01,DEX,BNE btw.


It‘s ok now!
Thank you and the same to Kasumi!

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/