;license:MIT ;(c) 2019 by 4am ; copymasks = $0200 ; $100 bytes but sparse, index is 0..6 but in high 3 bits, so $00, $20, $40, $60, $80, $A0, $C0 mirror_copymasks = $0201 hgrlo = $0300 ; $C0 bytes hgrlomirror = $BD40 ; $C0 bytes mirror_cols = $BE00 ; $28 bytes hgr1hi = $BE40 ; $C0 bytes hgr1himirror = $BF40 ; $C0 bytes Coordinates1Bit= $8800 ; $3481 bytes ($3480 on disk + 1 byte EOF marker) !source "src/fx/macros.a" !macro BUILD_MIRROR_COLS .mirror_cols { ; build lookup table to get $27-y for y in $00..$27 ldx #$27 ldy #$00 - tya sta .mirror_cols, x iny dex bpl - } !macro BUILD_SPARSE_BITMASKS .copymasks, .mirror_copymasks { ; build sparse lookup tables for bitmasks lda #%10000001 sta .copymasks sta .mirror_copymasks+$C0 lda #%10000010 sta .copymasks+$20 sta .mirror_copymasks+$A0 lda #%10000100 sta .copymasks+$40 sta .mirror_copymasks+$80 lda #%10001000 sta .copymasks+$60 sta .mirror_copymasks+$60 lda #%10010000 sta .copymasks+$80 sta .mirror_copymasks+$40 lda #%10100000 sta .copymasks+$A0 sta .mirror_copymasks+$20 lda #%11000000 sta .copymasks+$C0 sta .mirror_copymasks } !macro ROW_X_TO_BASE_ADDRESSES { lda hgrlo, x sta Coordinates1Bit sta $f1 lda #<(Coordinates1Bit + $3480 - 2) sta $f2 lda #>(Coordinates1Bit + $3480 - 2) sta $f3 clc !byte $24 - sec -- lda ($f0), y pha lda ($f2), y sta ($f0), y pla sta ($f2), y iny bcc - ldy #0 !byte $24 - clc inc $f0 bne + inc $f1 + lda $f1 eor #>(Coordinates1Bit + $1A40) bne + lda $f0 eor #<(Coordinates1Bit + $1A40) beq ++ + lda $f2 bne + dec $f3 + dec $f2 bcs - bcc -- ; always ++ } !macro FX_RIPPLE_1BIT { lda #2 ; <(Coordinates1Bit + 2) sta $f0 ldy #0 sty $f1 lda #$16 ; <(Coordinates1Bit + 22) sta $f2 sty $f3 lda #$1f sta $ee lda #$0d sta $ef lda Coordinates1Bit + 2 sta $e0 lda Coordinates1Bit + 3 sta $e1 lda Coordinates1Bit + 22 sta $e2 lda Coordinates1Bit + 23 sta $e3 --- ldx #4 -- ldy $ee, x lda $ef, x jsr aslmod sty $ee, x sta $ef, x sty $ec clc adc #>Coordinates1Bit sta $ed ldy #0 !byte $24 - sec lda ($ec), y pha lda $de, x sta ($ec), y pla sta $de, x inx iny bcc - dex dex dex dex bne -- dec $ee bne --- dec $ef bpl --- bmi +++ ; always branches aslmod jsr + + cmp #$1A bcc + bne ++ cpy #$40 bcc + ++ iny + pha tya asl tay pla rol cmp #$34 bcc + bne ++ cpy #$80 bcc + ++ pha tya sbc #$80 tay pla sbc #$34 + rts +++ } !macro FX_PRECOMPUTED_1BIT .coords { +BUILD_HGR_LOOKUP_TABLES hgrlo, hgr1hi +BUILD_HGR_MIRROR_LOOKUP_TABLES hgrlomirror, hgr1himirror +BUILD_MIRROR_COLS mirror_cols +BUILD_SPARSE_BITMASKS copymasks, mirror_copymasks ldx #(end-start) ; copy InputLoop code to zero page - lda start-1, x sta $FF, x dex bne - jmp InputLoop start !pseudopc 0 { Exit1Bit rts InputLoop ldy #0 input=*+1 lda .coords, y ; first value: HGR row (only 0..95 will be in input array) bmi Exit1Bit ; if > 127 then we're done tax +ROW_X_TO_BASE_ADDRESSES +ROW_X_TO_MIRROR_ADDRESSES inc input lda (input), y +HIGH_3_LOW_5 input ; main 1x2 block in top-left quadrant src1=*+1 lda $FDFD, y eor (