How can one waste gazillions of cycles to mirror one sprite? Quite easily, just forget speed and concentrate on compact code.
MirrorSprite
ldy #0
sty src
sty .5+1
; src = A<<6 | $4000
sec
ror
ror src
lsr
ror src
sta src+1
; ptr = X<<6 | $4000
txa
sec
ror
ror .5+1
lsr
ror .5+1
sta .5+2
; get sprite multicolor flag
ldy #$3F
lda (src),y
sta tmp2 ; b7=1 if multicolor
lda #60
.1 tax ; x=60,61,62, 57,58,59, ... 3,4,5, 0,1,2
lda #3
sta bytesLeft
.2 dey ; y=62,61,60, 59,58,57, ... 5,4,3, 2,1,0
lda (src),y
sta tmp1
lda #$01
.3 lsr tmp1 ; 5
bit tmp2 ; 8
bpl .4 ;10 hires, 8 loops 1 bit each
php ;13 else multicolor, 4 loops 2 bits each
lsr tmp1 ;18
rol ;20
plp ;24
.4 rol ;26
bcc .3 ;29 8*16=128 / 4*29=116
.5 sta $8000,x ; 63*128=8064
inx
dec bytesLeft
bne .2
txa
; sec ; asserted with "bcc .3"
sbc #6
bpl .1
rts
Hey, I just realized I can make it at least one byte sorter! ;)
Update: cycle counts were way off...
No comments:
Post a Comment