refactoring

This commit is contained in:
4am 2019-10-25 22:06:13 -04:00
parent 80972ebe88
commit aabebeaa55
9 changed files with 59 additions and 98 deletions

View File

@ -12,9 +12,6 @@ counter = $ff
!source "src/fx/macros.a"
+INIT_MASKS sourcemasks1, copymasks1
+INIT_MASKS sourcemasks4, copymasks4
lda #(40+12)
sta counter
@ -33,12 +30,12 @@ RowLoop
bcs @skip1
; do top half of arrow
+SWITCH_TO_MASKS sourcemasks1, copymasks1
+SWITCH_TO_MASKS copymasks1
lda row
jsr HGRBlockCopyWithMask
; do bottom half of arrow (opposing row, same col)
+SWITCH_TO_MASKS sourcemasks4, copymasks4
+SWITCH_TO_MASKS copymasks4
lda #23
sec
sbc row
@ -69,10 +66,6 @@ RowLoop
+LBNE ColLoop
@exit rts
sourcemasks1
!byte 0,0,0,0,0,0,0,0 ; SMC
sourcemasks4
!byte 0,0,0,0,0,0,0,0 ; SMC
copymasks1
!byte %11111111
!byte %11111110

View File

@ -16,8 +16,6 @@ hgr1hi = $80C0
!source "src/fx/macros.a"
+BUILD_HGR_LOOKUP_TABLES hgrlo, hgr1hi
+INIT_MASKS sourcemasks1, copymasks1
+INIT_MASKS sourcemasks4, copymasks4
lda #(40+12+1)
sta counter
@ -51,15 +49,13 @@ RowLoop
+IS_Y_OFFSCREEN
bcs TopSkip1
ldx #7
- lda ($26),y
and sourcemasks1,x
sta $00
lda #$FF
and copymasks1,x
ora $00
sta ($26),y
clc
ldx #7
- lda #$FF
eor ($26),y
and copymasks1,x
eor ($26),y
sta ($26),y
+HGR_INC_WITHIN_BLOCK
dex
bpl -
@ -69,15 +65,13 @@ TopSkip1
+IS_Y_OFFSCREEN
bcs TopSkip2
clc
ldx #7
- lda #$FF
and sourcemasks1,x
sta $00
lda ($3c),y
and copymasks1,x
ora $00
eor ($3c),y
and copymasks3,x
eor ($3c),y
sta ($26),y
clc
+HGR_INC_WITHIN_BLOCK
dex
bpl -
@ -110,15 +104,13 @@ BottomHalf
+IS_Y_OFFSCREEN
bcs BottomSkip1
ldx #7
- lda ($26),y
and sourcemasks4,x
sta $00
lda #$FF
and copymasks4,x
ora $00
sta ($26),y
clc
ldx #7
- lda #$FF
eor ($26),y
and copymasks4,x
eor ($26),y
sta ($26),y
+HGR_INC_WITHIN_BLOCK
dex
bpl -
@ -129,15 +121,13 @@ BottomSkip1
+IS_Y_OFFSCREEN
bcs BottomSkip2
clc
ldx #7
- lda #$FF
and sourcemasks4,x
sta $00
lda ($3c),y
and copymasks4,x
ora $00
eor ($3c),y
and copymasks2,x
eor ($3c),y
sta ($26),y
clc
+HGR_INC_WITHIN_BLOCK
dex
bpl -
@ -165,10 +155,6 @@ NextRow
+LBNE ColLoop
@exit rts
sourcemasks1
!byte 0,0,0,0,0,0,0,0 ; SMC
sourcemasks4
!byte 0,0,0,0,0,0,0,0 ; SMC
copymasks1
!byte %11111111
!byte %11111110
@ -178,6 +164,24 @@ copymasks1
!byte %11100000
!byte %11000000
!byte %10000000
copymasks2
!byte %11111111
!byte %10111111
!byte %10011111
!byte %10001111
!byte %10000111
!byte %10000011
!byte %10000001
!byte %10000000
copymasks3
!byte %10000000
!byte %10000001
!byte %10000011
!byte %10000111
!byte %10001111
!byte %10011111
!byte %10111111
!byte %11111111
copymasks4
!byte %10000000
!byte %11000000

View File

@ -98,19 +98,11 @@ HGRStaggerToWhite
bne @loop
rts
SetSourceMask
; NOOP- to be removed
rts
SetCopyMask
; in: A/Y points to 8-byte array of bit masks used by HGRBlockCopyWithMask
+STAY CopyMaskAddr
rts
BuildSourceMaskFromCopyMask
; NOOP- to be removed
rts
HGRBlockCopyWithMask
; in: A = HGR row / 8 (0x00..0x17)
; Y = HGR column (0x00..0x27)
@ -126,7 +118,7 @@ HGRBlockCopyWithMasksLoop
eor ($3c),y
CopyMaskAddr=*+1
and $FDFD,x ; call SetCopyMask to set
eor ($3c),y
eor ($26),y
sta ($26),y
clc
+HGR_INC_WITHIN_BLOCK

View File

@ -11,7 +11,7 @@ counter = $ff
!source "src/fx/macros.a"
+INIT_MASKS sourcemasks, copymasks
+SWITCH_TO_MASKS copymasks
lda #64 ; 40 + 24
sta counter
@ -47,8 +47,6 @@ counter = $ff
bne @colloop
@exit rts
sourcemasks
!byte 0,0,0,0,0,0,0,0 ; SMC
copymasks
!byte %11111111
!byte %11111110

View File

@ -11,7 +11,7 @@ counter = $ff
!source "src/fx/macros.a"
+INIT_MASKS sourcemasks, copymasks
+SWITCH_TO_MASKS copymasks
lda #64 ; 40 + 24
sta counter
@ -48,8 +48,6 @@ counter = $ff
bne @colloop
@exit rts
sourcemasks
!byte 0,0,0,0,0,0,0,0 ; SMC
copymasks
!byte %11111111
!byte %10111111

View File

@ -11,7 +11,7 @@ counter = $ff
!source "src/fx/macros.a"
+INIT_MASKS sourcemasks, copymasks
+SWITCH_TO_MASKS copymasks
lda #64 ; 40 + 24
sta counter
@ -50,8 +50,6 @@ counter = $ff
bcc @colloop
@exit rts
sourcemasks
!byte 0,0,0,0,0,0,0,0 ; SMC
copymasks
!byte %10000000
!byte %10000001

View File

@ -11,7 +11,7 @@ counter = $ff
!source "src/fx/macros.a"
+INIT_MASKS sourcemasks, copymasks
+SWITCH_TO_MASKS copymasks
lda #64 ; 40 + 24
sta counter
@ -49,8 +49,6 @@ counter = $ff
bne @colloop
@exit rts
sourcemasks
!byte 0,0,0,0,0,0,0,0 ; SMC
copymasks
!byte %10000000
!byte %11000000

View File

@ -12,11 +12,6 @@ counter = $ff
!source "src/fx/macros.a"
+INIT_MASKS sourcemasks1, copymasks1
+INIT_MASKS sourcemasks2, copymasks2
+INIT_MASKS sourcemasks3, copymasks3
+INIT_MASKS sourcemasks4, copymasks4
lda #32
sta counter
@ -36,11 +31,11 @@ counter = $ff
+ cpy #40
bcs -
; do corner 1
+SWITCH_TO_MASKS sourcemasks1, copymasks1
+SWITCH_TO_MASKS copymasks1
lda row
jsr HGRBlockCopyWithMask
; do corner 2 (same row, opposing col)
+SWITCH_TO_MASKS sourcemasks2, copymasks2
+SWITCH_TO_MASKS copymasks2
lda #39
sec
sbc y
@ -48,7 +43,7 @@ counter = $ff
lda row
jsr HGRBlockCopyWithMask
; do corner 3 (opposing row, opposing col)
+SWITCH_TO_MASKS sourcemasks3, copymasks3
+SWITCH_TO_MASKS copymasks3
lda #39
sec
sbc y
@ -58,7 +53,7 @@ counter = $ff
sbc row
jsr HGRBlockCopyWithMask
; do corner 4 (opposing row, same col)
+SWITCH_TO_MASKS sourcemasks4, copymasks4
+SWITCH_TO_MASKS copymasks4
ldy y
lda #23
sec
@ -111,14 +106,6 @@ counter = $ff
jmp @colloop
@exit rts
sourcemasks1
!byte 0,0,0,0,0,0,0,0 ; SMC
sourcemasks2
!byte 0,0,0,0,0,0,0,0 ; SMC
sourcemasks3
!byte 0,0,0,0,0,0,0,0 ; SMC
sourcemasks4
!byte 0,0,0,0,0,0,0,0 ; SMC
copymasks1
!byte %11111111
!byte %11111110

View File

@ -159,25 +159,18 @@
}
!macro COPY_BIT .src1, .dest1, .copymasks {
lda (.dest1),y
eor (.src1),y ; merge source and destination bits
and .copymasks,x ; 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
lda (.src1),y
eor (.dest1),y ; merge source and destination bits
and .copymasks,x ; 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 .source, .copy {
sty $00
+LDADDR .source
jsr SetSourceMask
+LDADDR .copy
jsr SetCopyMask
ldy $00
}
!macro INIT_MASKS .source, .copy {
+SWITCH_TO_MASKS .source, .copy
jsr BuildSourceMaskFromCopyMask
!macro SWITCH_TO_MASKS .copy {
lda #<.copy
sta CopyMaskAddr
lda #>.copy
sta CopyMaskAddr+1
}
; must set N flag based on Y immediately before using this macro