Question about chr to chr-ram!

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Question about chr to chr-ram!
by on (#103527)
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!
Re: Question about chr to chr-ram!
by on (#103528)
Probably didn't turn off rendering, you can't touch the PPU Data Port during rendering.
Re: Question about chr to chr-ram!
by on (#103529)
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.
Re: Question about chr to chr-ram!
by on (#103530)
3gengames wrote:
Probably didn't turn off rendering, you can't touch the PPU Data Port during rendering.


Always wrong :(
Re: Question about chr to chr-ram!
by on (#103531)
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.
Re: Question about chr to chr-ram!
by on (#103532)
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.
Re: Question about chr to chr-ram!
by on (#103533)
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!