Code: Select all
; src - tilemap source
DrawTilemap:
ldy #$0
lda #$20
sta scratch1+1
lda #$00
sta scratch1
sta scratch1+3
lda #$C0
sta scratch1+2
lda #$04
sta scratch1+4
tya
tax
@loop:
lda (src),y
cmp #$FF
beq @ret
tax
lda scratch1+1
sta $2006
lda scratch1
sta $2006
lda Metatiles1_TL,x
sta $2007
lda Metatiles1_TR,x
sta $2007
lda scratch1+1
sta $2006
lda scratch1
clc
adc #$20
sta $2006
lda Metatiles1_BL,x
sta $2007
lda Metatiles1_BR,x
sta $2007
lda Metatiles1_Pal,x
and #%11
clc
adc scratch1+3
rol a
rol a
adc #0
sta scratch1+3
dec scratch1+4
bne :+
lda #4
sta scratch1+4
lda #$23
sta $2006
lda scratch1+2
sta $2006
lda scratch1+3
sta $2007
lda #0
sta scratch1+3
inc scratch1+2
:
inc scratch1
inc scratch1
lda scratch1
and #$1F
bne @cont
lda scratch1
clc
adc #$20
sta scratch1
bcc @cont
inc scratch1+1
@cont:
iny
bne @loop
@ret:
rts
I can attach my whole codebase, if necessary. thank you for your help!