Question about chr to chr-ram!

NES development discussion in English, Español, Français, Português, русский язык, or any language.

Moderator: Moderators

Post Reply
User avatar
byemu
Posts: 297
Joined: Mon Sep 05, 2011 5:56 pm
Contact:

Question about chr to chr-ram!

Post by byemu »

I try to convert a chr to chr-ram!
here is the code:

Code: Select all

 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!
3gengames
Formerly 65024U
Posts: 2284
Joined: Sat Mar 27, 2010 12:57 pm

Re: Question about chr to chr-ram!

Post by 3gengames »

Probably didn't turn off rendering, you can't touch the PPU Data Port during rendering.
User avatar
Kasumi
Posts: 1293
Joined: Wed Apr 02, 2008 2:09 pm

Re: Question about chr to chr-ram!

Post by Kasumi »

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.
User avatar
byemu
Posts: 297
Joined: Mon Sep 05, 2011 5:56 pm
Contact:

Re: Question about chr to chr-ram!

Post by byemu »

3gengames wrote:Probably didn't turn off rendering, you can't touch the PPU Data Port during rendering.
Always wrong :(
3gengames
Formerly 65024U
Posts: 2284
Joined: Sat Mar 27, 2010 12:57 pm

Re: Question about chr to chr-ram!

Post by 3gengames »

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.
Last edited by 3gengames on Mon Nov 26, 2012 8:03 pm, edited 1 time in total.
User avatar
Kasumi
Posts: 1293
Joined: Wed Apr 02, 2008 2:09 pm

Re: Question about chr to chr-ram!

Post by Kasumi »

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: Select all

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.
User avatar
byemu
Posts: 297
Joined: Mon Sep 05, 2011 5:56 pm
Contact:

Re: Question about chr to chr-ram!

Post by byemu »

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!
Post Reply