I'm using the following macro call and macro to make changes to palettes. The issue I'm having is that a significant portion of the time, rather than writing to the CGRAM destination that is given, it writes to CGRAM destination $01 instead. Does anyone with DMA transfer experience know what could cause this discrepancy? Thanks.
%SetPalette(#$B0, #$8000, #$e0, #$0020)
macro SetPalette(bank, source, dest, size)
;---header
php
rep #$30
pha
phx
phy
sep #$20
rep #$10
;---main
ldx <source>
stx $4372
lda <bank>
sta $4374
ldy <size>
sty $4375
lda <dest>
sta $2121
ldx #$2202
stx $4370
lda #$80
sta $420b
;---footer
rep #$30
ply
plx
pla
plp
endmacro
%SetPalette(#$B0, #$8000, #$e0, #$0020)
macro SetPalette(bank, source, dest, size)
;---header
php
rep #$30
pha
phx
phy
sep #$20
rep #$10
;---main
ldx <source>
stx $4372
lda <bank>
sta $4374
ldy <size>
sty $4375
lda <dest>
sta $2121
ldx #$2202
stx $4370
lda #$80
sta $420b
;---footer
rep #$30
ply
plx
pla
plp
endmacro