From aabebeaa55f9554aecee64f349077b1ee0b9a8b4 Mon Sep 17 00:00:00 2001 From: 4am Date: Fri, 25 Oct 2019 22:06:13 -0400 Subject: [PATCH] refactoring --- src/fx/fx.hgr.arrow.a | 11 ++---- src/fx/fx.hgr.arrow.white.a | 72 +++++++++++++++++++------------------ src/fx/fx.hgr.common.a | 10 +----- src/fx/fx.hgr.diagonal.a | 4 +-- src/fx/fx.hgr.diagonal2.a | 4 +-- src/fx/fx.hgr.diagonal3.a | 4 +-- src/fx/fx.hgr.diagonal4.a | 4 +-- src/fx/fx.hgr.diamond.a | 21 +++-------- src/fx/macros.a | 27 ++++++-------- 9 files changed, 59 insertions(+), 98 deletions(-) diff --git a/src/fx/fx.hgr.arrow.a b/src/fx/fx.hgr.arrow.a index 17a65b6f6..23a51198c 100644 --- a/src/fx/fx.hgr.arrow.a +++ b/src/fx/fx.hgr.arrow.a @@ -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 diff --git a/src/fx/fx.hgr.arrow.white.a b/src/fx/fx.hgr.arrow.white.a index 42d2a3f3b..8a5bf2725 100644 --- a/src/fx/fx.hgr.arrow.white.a +++ b/src/fx/fx.hgr.arrow.white.a @@ -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 diff --git a/src/fx/fx.hgr.common.a b/src/fx/fx.hgr.common.a index 226fc433c..9b6dc11cc 100644 --- a/src/fx/fx.hgr.common.a +++ b/src/fx/fx.hgr.common.a @@ -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 diff --git a/src/fx/fx.hgr.diagonal.a b/src/fx/fx.hgr.diagonal.a index aaa416a5d..cd7970108 100644 --- a/src/fx/fx.hgr.diagonal.a +++ b/src/fx/fx.hgr.diagonal.a @@ -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 diff --git a/src/fx/fx.hgr.diagonal2.a b/src/fx/fx.hgr.diagonal2.a index ab9365e2b..ca9d85617 100644 --- a/src/fx/fx.hgr.diagonal2.a +++ b/src/fx/fx.hgr.diagonal2.a @@ -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 diff --git a/src/fx/fx.hgr.diagonal3.a b/src/fx/fx.hgr.diagonal3.a index a13221f32..a303c5ffc 100644 --- a/src/fx/fx.hgr.diagonal3.a +++ b/src/fx/fx.hgr.diagonal3.a @@ -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 diff --git a/src/fx/fx.hgr.diagonal4.a b/src/fx/fx.hgr.diagonal4.a index 4e2eba51a..f3a9a671a 100644 --- a/src/fx/fx.hgr.diagonal4.a +++ b/src/fx/fx.hgr.diagonal4.a @@ -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 diff --git a/src/fx/fx.hgr.diamond.a b/src/fx/fx.hgr.diamond.a index 76da654cb..84987b623 100644 --- a/src/fx/fx.hgr.diamond.a +++ b/src/fx/fx.hgr.diamond.a @@ -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 diff --git a/src/fx/macros.a b/src/fx/macros.a index cb5fd82a6..ccceb6925 100644 --- a/src/fx/macros.a +++ b/src/fx/macros.a @@ -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