Skip to content

Instantly share code, notes, and snippets.

@kirjavascript
Created August 2, 2021 19:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kirjavascript/437e49069326674093876651d8e869a5 to your computer and use it in GitHub Desktop.
rectBuffer := generalCounter
rectX := rectBuffer+0
rectY := rectBuffer+1
rectW := rectBuffer+2
rectH := rectBuffer+3
rectAttr := rectBuffer+4
rectAddr := rectBuffer+5 ; positionValidTmp
; <addr in tmp1 >addr in tmp2
; .byte [x, y, width, height, attr, addr]+ $FF
loadRectIntoOamStaging:
ldy #0
@copyRect:
ldx #0
@copyRectLoop:
lda ($0), y
cmp #$FF
beq @ret
sta rectBuffer, x
iny
inx
cpx #6
bne @copyRectLoop
@writeLine:
lda rectX
sta tmpX
lda rectW
sta tmpY
@writeTile:
; YTAX
ldx oamStagingLength
lda rectY
adc spriteYOffset
sta oamStaging,x
lda rectAddr
sta oamStaging+1,x
lda rectAttr
sta oamStaging+2,x
lda rectX
adc spriteXOffset
sta oamStaging+3,x
; increase OAM index
lda #$4
clc
adc oamStagingLength
sta oamStagingLength
; next rightwards tile
lda #$8
adc rectX
sta rectX
inc rectAddr
dec rectW
lda rectW
bne @writeTile
; start a new line
lda tmpX
sta rectX
lda tmpY
sta rectW
lda rectAddr
sbc rectW
adc #$10
sta rectAddr
lda #$8
adc rectY
sta rectY
dec rectH
lda rectH
bne @writeLine
; do another rect
jmp @copyRect
@ret:
rts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment