shave some cycles (skip if copymask=0, fake bit 3)

This commit is contained in:
4am 2020-11-23 12:46:25 -05:00
parent d0745e7941
commit 63870a0bc8
2 changed files with 34 additions and 22 deletions

View File

@ -15,19 +15,15 @@
inx
bne -
lda #%10000001
sta .copymasks+$60
sta .mirror_copymasks+$60
lda #%10000110
lda #%00000111
sta .copymasks+$80
sta .mirror_copymasks+$40
lda #%10011000
lda #%00011000
sta .copymasks+$A0
sta .mirror_copymasks+$20
lda #%11100000
lda #%01100000
sta .copymasks+$C0
sta .mirror_copymasks
@ -81,50 +77,58 @@ input=*+1
sty <y
clc
bankloop
lda copymasks, x
beq +
sta <copymask
; main 1x2 block in top-left quadrant
src1=*+1
lda $FDFD, y
eor (<dest1), y
and copymasks, x
copymask=*+1
and #$FD ; SMC
eor (<dest1), y
dest1=*+1
sta $FDFD, y
src2=*+1
lda $FDFD, y
eor (<dest2), y
and copymasks, x
and <copymask
eor (<dest2), y
dest2=*+1
sta $FDFD, y
; corresponding 1x2 block in top-right quadrant (same row, opposite column)
; corresponding 1x2 block in bottom-left quadrant (opposite row, original column)
+COPY_BIT_ZP mirror_src1, mirror_dest1, copymask
+COPY_BIT_ZP mirror_src2, mirror_dest2, copymask
+
lda mirror_copymasks, x
beq +
sta <mirror_copymask
; corresponding 1x2 block in bottom-right quadrant (opposite row, opposite column)
lda mirror_cols, y
tay
+COPY_BIT src1, dest1, mirror_copymasks
+COPY_BIT src2, dest2, mirror_copymasks
; corresponding 1x2 block in bottom-right quadrant (opposite row, opposite column)
mirror_src1=*+1
lda $FDFD, y
eor (<mirror_dest1), y
and mirror_copymasks, x
mirror_copymask=*+1
and #$FD ; SMC
eor (<mirror_dest1), y
mirror_dest1=*+1
sta $FDFD, y
mirror_src2=*+1
lda $FDFD, y
eor (<mirror_dest2), y
and mirror_copymasks, x
and <mirror_copymask
eor (<mirror_dest2), y
mirror_dest2=*+1
sta $FDFD, y
; corresponding 1x2 block in bottom-left quadrant (opposite row, original column)
lda mirror_cols, y
tay
+COPY_BIT mirror_src1, mirror_dest1, copymasks
+COPY_BIT mirror_src2, mirror_dest2, copymasks
; corresponding 1x2 block in top-right quadrant (same row, opposite column)
+COPY_BIT_ZP src1, dest1, mirror_copymask
+COPY_BIT_ZP src2, dest2, mirror_copymask
+
bcs +
sta $C003
sta $C005

View File

@ -124,6 +124,14 @@
sta (.dest1),y ; write the result
}
!macro COPY_BIT_ZP .src1, .dest1, .zpcopymask {
lda (.src1),y
eor (.dest1),y ; merge source and destination bits
and <.zpcopymask ; isolate the bits to replace, zero the rest
eor (.dest1),y ; unmerge source and destination bits, leaves 'to keep' destination bits intact
sta (.dest1),y ; write the result
}
!macro SWITCH_TO_MASKS .copy {
lda #<.copy
sta CopyMaskAddr