From 915a82587d16334cd65a187659315b077364e3c8 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Tue, 22 Oct 2019 22:15:33 -0700 Subject: [PATCH] a bit faster --- src/fx/fx.hgr.precomputed.1bit.a | 46 ++++++----------- src/fx/fx.hgr.ripple.a | 3 ++ src/fx/macros.a | 84 +++++++++++++++++++++++++++++++- 3 files changed, 101 insertions(+), 32 deletions(-) diff --git a/src/fx/fx.hgr.precomputed.1bit.a b/src/fx/fx.hgr.precomputed.1bit.a index 9bc2a7c6d..94768ce43 100644 --- a/src/fx/fx.hgr.precomputed.1bit.a +++ b/src/fx/fx.hgr.precomputed.1bit.a @@ -16,9 +16,10 @@ sourcemasks = $0201 ; same as copymasks mirror_copymasks = $0202 mirror_sourcemasks = $0203 hgrlo = $0300 ; $C0 bytes -mirror_cols = $BD58 ; $28 bytes -mirror_rows = $BD80 ; $C0 bytes +hgrlomirror = $BD40 ; $C0 bytes +mirror_cols = $BE00 ; $28 bytes hgr1hi = $BE40 ; $C0 bytes +hgr1himirror = $BF40 ; $C0 bytes !source "src/fx/macros.a" @@ -35,6 +36,7 @@ hgr1hi = $BE40 ; $C0 bytes !macro FX_PRECOMPUTED_1BIT .coords { ; build lookup tables for base address of HGR rows +BUILD_HGR_LOOKUP_TABLES hgrlo, hgr1hi + +BUILD_HGR_MIRROR_LOOKUP_TABLES hgrlomirror, hgr1himirror ; build lookup table to get $27-y for y in $00..$27 ldx #$27 @@ -45,16 +47,6 @@ hgr1hi = $BE40 ; $C0 bytes dex bpl - - ; build lookup table to get $BF-x for x in $00..$BF - ldx #$BF - ldy #$00 -- tya - sta mirror_rows,x - dex - iny - cpy #$C0 - bne - - ; build sparse lookup tables for bitmasks lda #%10000001 sta copymasks @@ -111,9 +103,6 @@ hgr1hi = $BE40 ; $C0 bytes lda #>.coords sta input+1 - jmp InputLoop -Exit1 rts - InputLoop ldy #0 lda (input),y ; first value: HGR row (only 0..95 will be in input array) @@ -124,7 +113,8 @@ InputLoop sta src1 lda hgr1hi,x sta dest1+1 - eor #$60 +Exit1 = * + 1 + eor #$60 ; ahem. doubles as RTS sta src1+1 lda hgrlo+1,x sta dest2 @@ -134,19 +124,17 @@ InputLoop eor #$60 sta src2+1 - lda mirror_rows,x - tax - lda hgrlo,x + lda hgrlomirror,x sta dest3 sta src3 - lda hgr1hi,x + lda hgr1himirror,x sta dest3+1 eor #$60 sta src3+1 - lda hgrlo-1,x + lda hgrlomirror+1,x sta dest4 sta src4 - lda hgr1hi-1,x + lda hgr1himirror+1,x sta dest4+1 eor #$60 sta src4+1 @@ -182,15 +170,13 @@ InputLoop +COPY_BIT src3, dest3, sourcemasks, copymasks +COPY_BIT src4, dest4, sourcemasks, copymasks - bit $c000 - bmi Exit2 - inc input - bne + + inc input + beq + + jmp InputLoop ++ bit $c000 + bmi Exit2 inc input+1 -+ inc input - +LBNE InputLoop - inc input+1 - +LBNE InputLoop + jmp InputLoop Exit2 } diff --git a/src/fx/fx.hgr.ripple.a b/src/fx/fx.hgr.ripple.a index 3c19e4007..186f47139 100644 --- a/src/fx/fx.hgr.ripple.a +++ b/src/fx/fx.hgr.ripple.a @@ -11,6 +11,9 @@ rts +!if * and $fff { + !fill $1000 - (* and $fff) ;align 4096 +} Coordinates !source "src/fx/fx.hgr.ripple.data.a" !byte $80 diff --git a/src/fx/macros.a b/src/fx/macros.a index b32662774..277e35b5f 100644 --- a/src/fx/macros.a +++ b/src/fx/macros.a @@ -22,14 +22,94 @@ rol asl .hgrlo,x rol - clc - adc #$20 + ora #$20 sta .hgr1hi,x inx cpx #$C0 bne - } +; .hgrlo, .hgr1hi, .hgr2hi will each be filled with $C0 bytes +!macro BUILD_HGR12_LOOKUP_TABLES .hgrlo, .hgr1hi, .hgr2hi { + ldx #0 +- txa + and #$F8 + bpl + + ora #5 ++ asl + bpl + + ora #5 ++ asl + asl + sta .hgrlo,x + txa + and #7 + rol + asl .hgrlo,x + rol + ora #$20 + sta .hgr1hi,x + eor #$60 + sta .hgr2hi,x + inx + cpx #$C0 + bne - +} + +; .hgrlomirror, .hgr1himirror will each be filled with $C0 bytes +!macro BUILD_HGR_MIRROR_LOOKUP_TABLES .hgrlomirror, .hgr1himirror { + ldx #$C0 + ldy #0 +- tya + and #$F8 + bpl + + ora #5 ++ asl + bpl + + ora #5 ++ asl + asl + sta .hgrlomirror-1,x + tya + and #7 + rol + asl .hgrlomirror-1,x + rol + ora #$20 + sta .hgr1himirror-1,x + iny + dex + bne - +} + +; .hgrlomirror, .hgr1himirror, .hgr2himirror will each be filled with $C0 bytes +!macro BUILD_HGR_MIRROR_LOOKUP_TABLES .hgrlomirror, .hgr1himirror, .hgr2mirror { + ldx #$C0 + ldy #0 +- tya + and #$F8 + bpl + + ora #5 ++ asl + bpl + + ora #5 ++ asl + asl + sta .hgrlomirror-1,x + tya + and #7 + rol + asl .hgrlomirror-1,x + rol + ora #$20 + sta .hgr1himirror-1,x + eor #$60 + sta .hgr2himirror-1,x + iny + dex + bne - +} + !macro HGR_CALC { asl tax