shave some cycles (manage Y register better, simplify branch macro)

This commit is contained in:
4am 2020-11-21 18:26:19 -05:00
parent b4d4fcfb2b
commit 41cdf65542
2 changed files with 79 additions and 83 deletions

View File

@ -7,8 +7,7 @@
src = $F0 src = $F0
dst = $F2 dst = $F2
row = $FC row = $FD
y = $FD
col = $FE col = $FE
counter = $FF counter = $FF
@ -68,7 +67,6 @@ ColLoop
lda #23 lda #23
sta row sta row
ldy col ldy col
sty y
RowLoop RowLoop
ldx row ldx row
lda hgrrowlo, x lda hgrrowlo, x
@ -80,7 +78,6 @@ RowLoop
eor #$60 eor #$60
sta src+1 sta src+1
ldy y
+BRANCH_IF_Y_IS_OFFSCREEN @block2 +BRANCH_IF_Y_IS_OFFSCREEN @block2
; +COPY_WITH_MASK_IMM_AND_INC %00000000 ; +COPY_WITH_MASK_IMM_AND_INC %00000000
; +COPY_WITH_MASK_IMM_AND_INC %00000000 ; +COPY_WITH_MASK_IMM_AND_INC %00000000
@ -115,12 +112,12 @@ RowLoop
+COPY_WITH_MASK_IMM_AND_INC %10000111 +COPY_WITH_MASK_IMM_AND_INC %10000111
+COPY_WITH_MASK_IMM_AND_INC %10000111 +COPY_WITH_MASK_IMM_AND_INC %10000111
+COPY_WITH_MASK_IMM %10000111 +COPY_WITH_MASK_IMM %10000111
; +COPY_WITH_MASK_IMM_AND_INC %10000000 ; +COPY_WITH_MASK_IMM_AND_INC %00000000
; +COPY_WITH_MASK_IMM %10000000 ; +COPY_WITH_MASK_IMM %00000000
+RESET_HGR_HI +RESET_HGR_HI
@block4 @block4
iny iny
+LONG_BRANCH_IF_Y_IS_OFFSCREEN @block5 +BRANCH_IF_Y_IS_OFFSCREEN @block5
; +COPY_WITH_MASK_IMM_AND_INC %00000000 ; +COPY_WITH_MASK_IMM_AND_INC %00000000
+INC_HGR_HI +INC_HGR_HI
+COPY_WITH_MASK_IMM_AND_INC %10011001 +COPY_WITH_MASK_IMM_AND_INC %10011001
@ -133,7 +130,7 @@ RowLoop
+RESET_HGR_HI +RESET_HGR_HI
@block5 @block5
iny iny
+LONG_BRANCH_IF_Y_IS_OFFSCREEN @block6 +BRANCH_IF_Y_IS_OFFSCREEN @block6
; +COPY_WITH_MASK_IMM_AND_INC %00000000 ; +COPY_WITH_MASK_IMM_AND_INC %00000000
+INC_HGR_HI +INC_HGR_HI
+COPY_WITH_MASK_IMM_AND_INC %10011111 +COPY_WITH_MASK_IMM_AND_INC %10011111
@ -171,60 +168,32 @@ RowLoop
@switchtoaux @switchtoaux
sta $C003 sta $C003
sta $C005 sta $C005
ldy y tya
+BRANCH_IF_Y_IS_OFFSCREEN @block2_aux +BRANCH_IF_Y_IS_OFFSCREEN @block6_aux
; +COPY_WITH_MASK_IMM_AND_INC %00000000 +COPY_BYTE_AND_INC
; +COPY_WITH_MASK_IMM_AND_INC %00000000 +COPY_BYTE_AND_INC
; +COPY_WITH_MASK_IMM_AND_INC %00000000 +COPY_BYTE_AND_INC
+INC_HGR_HI_BY 3 +COPY_BYTE_AND_INC
+COPY_WITH_MASK_IMM_AND_INC %11000000 +COPY_BYTE_AND_INC
+COPY_WITH_MASK_IMM %11000000 +COPY_BYTE_AND_INC
; +COPY_WITH_MASK_IMM_AND_INC %00000000 +COPY_BYTE_AND_INC
; +COPY_WITH_MASK_IMM_AND_INC %00000000 +COPY_BYTE
; +COPY_WITH_MASK_IMM %00000000
+RESET_HGR_HI +RESET_HGR_HI
@block2_aux @block6_aux
iny dey
+BRANCH_IF_Y_IS_OFFSCREEN @block3_aux
; +COPY_WITH_MASK_IMM_AND_INC %00000000
; +COPY_WITH_MASK_IMM_AND_INC %00000000
+INC_HGR_HI_BY 2
+COPY_WITH_MASK_IMM_AND_INC %10110000
+COPY_WITH_MASK_IMM_AND_INC %11000000
+COPY_WITH_MASK_IMM_AND_INC %11000000
+COPY_WITH_MASK_IMM %10110000
; +COPY_WITH_MASK_IMM_AND_INC %00000000
; +COPY_WITH_MASK_IMM %00000000
+RESET_HGR_HI
@block3_aux
iny
+BRANCH_IF_Y_IS_OFFSCREEN @block4_aux
; +COPY_WITH_MASK_IMM_AND_INC %00000000
; +COPY_WITH_MASK_IMM_AND_INC %00000000
+INC_HGR_HI_BY 2
+COPY_WITH_MASK_IMM_AND_INC %11110000
+COPY_WITH_MASK_IMM_AND_INC %11110000
+COPY_WITH_MASK_IMM_AND_INC %11110000
+COPY_WITH_MASK_IMM %11110000
; +COPY_WITH_MASK_IMM_AND_INC %00000000
; +COPY_WITH_MASK_IMM %00000000
+RESET_HGR_HI
@block4_aux
iny
+LONG_BRANCH_IF_Y_IS_OFFSCREEN @block5_aux +LONG_BRANCH_IF_Y_IS_OFFSCREEN @block5_aux
; +COPY_WITH_MASK_IMM_AND_INC %00000000 +COPY_WITH_MASK_IMM_AND_INC %10110011
+INC_HGR_HI
+COPY_WITH_MASK_IMM_AND_INC %11001100
+COPY_WITH_MASK_IMM_AND_INC %11110000
+COPY_WITH_MASK_IMM_AND_INC %11111100 +COPY_WITH_MASK_IMM_AND_INC %11111100
+COPY_WITH_MASK_IMM_AND_INC %11110000 +COPY_BYTE_AND_INC
+COPY_WITH_MASK_IMM_AND_INC %11110000 +COPY_WITH_MASK_IMM_AND_INC %11111100
+COPY_WITH_MASK_IMM %11001100 +COPY_BYTE_AND_INC
; +COPY_WITH_MASK_IMM %00000000 +COPY_WITH_MASK_IMM_AND_INC %11111100
+COPY_WITH_MASK_IMM_AND_INC %11111100
+COPY_WITH_MASK_IMM %10110011
+RESET_HGR_HI +RESET_HGR_HI
@block5_aux @block5_aux
iny dey
+LONG_BRANCH_IF_Y_IS_OFFSCREEN @block6_aux +BRANCH_IF_Y_IS_OFFSCREEN @block4_aux
; +COPY_WITH_MASK_IMM_AND_INC %00000000 ; +COPY_WITH_MASK_IMM_AND_INC %00000000
+INC_HGR_HI +INC_HGR_HI
+COPY_WITH_MASK_IMM_AND_INC %11111100 +COPY_WITH_MASK_IMM_AND_INC %11111100
@ -235,33 +204,61 @@ RowLoop
+COPY_WITH_MASK_IMM %11111100 +COPY_WITH_MASK_IMM %11111100
; +COPY_WITH_MASK_IMM %00000000 ; +COPY_WITH_MASK_IMM %00000000
+RESET_HGR_HI +RESET_HGR_HI
@block6_aux @block4_aux
iny dey
+LONG_BRANCH_IF_Y_IS_OFFSCREEN @block7_aux +BRANCH_IF_Y_IS_OFFSCREEN @block3_aux
+COPY_WITH_MASK_IMM_AND_INC %10110011 ; +COPY_WITH_MASK_IMM_AND_INC %00000000
+INC_HGR_HI
+COPY_WITH_MASK_IMM_AND_INC %11001100
+COPY_WITH_MASK_IMM_AND_INC %11110000
+COPY_WITH_MASK_IMM_AND_INC %11111100 +COPY_WITH_MASK_IMM_AND_INC %11111100
+COPY_BYTE_AND_INC +COPY_WITH_MASK_IMM_AND_INC %11110000
+COPY_WITH_MASK_IMM_AND_INC %11111100 +COPY_WITH_MASK_IMM_AND_INC %11110000
+COPY_BYTE_AND_INC +COPY_WITH_MASK_IMM %11001100
+COPY_WITH_MASK_IMM_AND_INC %11111100 ; +COPY_WITH_MASK_IMM %00000000
+COPY_WITH_MASK_IMM_AND_INC %11111100
+COPY_WITH_MASK_IMM %10110011
+RESET_HGR_HI +RESET_HGR_HI
@block7_aux @block3_aux
iny dey
+BRANCH_IF_Y_IS_OFFSCREEN @block2_aux
; +COPY_WITH_MASK_IMM_AND_INC %00000000
; +COPY_WITH_MASK_IMM_AND_INC %00000000
+INC_HGR_HI_BY 2
+COPY_WITH_MASK_IMM_AND_INC %11110000
+COPY_WITH_MASK_IMM_AND_INC %11110000
+COPY_WITH_MASK_IMM_AND_INC %11110000
+COPY_WITH_MASK_IMM %11110000
; +COPY_WITH_MASK_IMM_AND_INC %00000000
; +COPY_WITH_MASK_IMM %00000000
+RESET_HGR_HI
@block2_aux
dey
+BRANCH_IF_Y_IS_OFFSCREEN @block1_aux
; +COPY_WITH_MASK_IMM_AND_INC %00000000
; +COPY_WITH_MASK_IMM_AND_INC %00000000
+INC_HGR_HI_BY 2
+COPY_WITH_MASK_IMM_AND_INC %10110000
+COPY_WITH_MASK_IMM_AND_INC %11000000
+COPY_WITH_MASK_IMM_AND_INC %11000000
+COPY_WITH_MASK_IMM %10110000
; +COPY_WITH_MASK_IMM_AND_INC %00000000
; +COPY_WITH_MASK_IMM %00000000
+RESET_HGR_HI
@block1_aux
dey
+BRANCH_IF_Y_IS_OFFSCREEN @switchtomain +BRANCH_IF_Y_IS_OFFSCREEN @switchtomain
+COPY_BYTE_AND_INC ; +COPY_WITH_MASK_IMM_AND_INC %00000000
+COPY_BYTE_AND_INC ; +COPY_WITH_MASK_IMM_AND_INC %00000000
+COPY_BYTE_AND_INC ; +COPY_WITH_MASK_IMM_AND_INC %00000000
+COPY_BYTE_AND_INC +INC_HGR_HI_BY 3
+COPY_BYTE_AND_INC +COPY_WITH_MASK_IMM_AND_INC %11000000
+COPY_BYTE_AND_INC +COPY_WITH_MASK_IMM %11000000
+COPY_BYTE_AND_INC ; +COPY_WITH_MASK_IMM_AND_INC %00000000
+COPY_BYTE ; +COPY_WITH_MASK_IMM_AND_INC %00000000
; +COPY_WITH_MASK_IMM %00000000
@switchtomain @switchtomain
sta $C002 sta $C002
sta $C004 sta $C004
inc y iny
dec row dec row
+LBPL RowLoop +LBPL RowLoop
lda $c000 lda $c000

View File

@ -141,15 +141,14 @@
++ ++
} }
!macro BRANCH_IF_Y_IS_OFFSCREEN .target { !macro BRANCH_IF_Y_IS_OFFSCREEN .target {
bmi .target
cpy #40 cpy #40
bcs .target bcs .target
} }
!macro LONG_BRANCH_IF_Y_IS_OFFSCREEN .target { !macro LONG_BRANCH_IF_Y_IS_OFFSCREEN .target {
bpl + cpy #40
- jmp .target bcc +
+ cpy #40 jmp .target
bcs - +
} }
_FX_MACROS_=* _FX_MACROS_=*