From 7cc1505b153bf0892a231685a1ebbe824d8e58e3 Mon Sep 17 00:00:00 2001 From: 4am Date: Fri, 17 Dec 2021 18:29:35 -0500 Subject: [PATCH] shave some cycles --- src/fx/fx.dgr.fizzle.a | 10 +++--- src/fx/fx.dhgr.2bit.fizzle.a | 8 ++--- src/fx/fx.dhgr.2pass.lr.a | 6 +--- src/fx/fx.dhgr.bar.dissolve.a | 6 +--- src/fx/fx.dhgr.diagonal.a | 6 +--- src/fx/fx.dhgr.fizzle.a | 9 +++-- src/fx/fx.dhgr.precomputed.1bit.a | 8 ++--- src/fx/fx.dhgr.precomputed.2bit.a | 8 ++--- src/fx/fx.dhgr.r.by.pixel.a | 8 ++--- src/fx/fx.dhgr.redlines.a | 7 ++-- src/fx/fx.gr.fizzle.a | 10 +++--- src/fx/fx.hgr.1bit.fizzle.a | 8 ++--- src/fx/fx.hgr.2bit.fizzle.a | 9 +++-- src/fx/fx.hgr.checkerboard.fizzle.a | 9 +++-- src/fx/fx.hgr.fizzle.a | 10 +++--- src/fx/fx.hgr.palette.fizzle.a | 9 +++-- src/fx/fx.hgr.precomputed.1bit.a | 8 ++--- src/fx/fx.hgr.precomputed.2bit.a | 8 ++--- src/fx/fx.hgr.precomputed.3bit.a | 8 ++--- src/fx/fx.shr.2pass.lr.a | 8 ++--- src/fx/fx.shr.common.a | 52 +++++++++++++++++++++++++++++ src/fx/fx.shr.diagonal.a | 10 ++---- src/fx/fx.shr.fizzle.a | 7 ++-- src/fx/fx.shr.lr.a | 9 ++--- src/fx/fx.shr.lr2.a | 10 ++---- src/fx/fx.shr.precomputed.a | 49 +++++---------------------- src/fx/fx.shr.radial.a | 48 +++++--------------------- src/fx/fx.shr.ud.a | 10 ++---- src/fx/macros.a | 22 ++++++++++++ 29 files changed, 161 insertions(+), 219 deletions(-) diff --git a/src/fx/fx.dgr.fizzle.a b/src/fx/fx.dgr.fizzle.a index 4be43781e..03a774b4b 100644 --- a/src/fx/fx.dgr.fizzle.a +++ b/src/fx/fx.dgr.fizzle.a @@ -5,11 +5,11 @@ !to "build/DGR.FIZZLE",plain *=$6000 - ldx #(end-start+1) ; copy LFSR code to zero page -- ldy start-2, x - sty $FE, x - dex - bne - + !source "src/fx/macros.a" + + +OVERCOPY_TO_0 start, end + ;X=0 + ;Y=0 jmp loop start diff --git a/src/fx/fx.dhgr.2bit.fizzle.a b/src/fx/fx.dhgr.2bit.fizzle.a index aec88a694..0f653a439 100644 --- a/src/fx/fx.dhgr.2bit.fizzle.a +++ b/src/fx/fx.dhgr.2bit.fizzle.a @@ -8,11 +8,9 @@ addrs = $6100 ; [256 bytes, page-aligned, duplicated in auxmem] copymasks = $6200 ; [256 bytes, page-aligned, duplicated in auxmem] - ldx #(end-start) ; copy LFSR code to zero page -- lda start-1, x - sta $FF, x - dex - bne - + !source "src/fx/macros.a" + + +COPY_TO_0 start, end ;X=0 ;A=3 -- ldy #$40 ; create identical copymask tables in main and aux memory diff --git a/src/fx/fx.dhgr.2pass.lr.a b/src/fx/fx.dhgr.2pass.lr.a index 9a32d7f3e..fe75e766d 100644 --- a/src/fx/fx.dhgr.2pass.lr.a +++ b/src/fx/fx.dhgr.2pass.lr.a @@ -10,11 +10,7 @@ hgr1hi = $0300 ; [$C0 bytes, main memory only] !source "src/fx/macros.a" - ldx #(end-start) ; copy code to zero page -- lda start-1, x - sta $FF, x - dex - bne - + +COPY_TO_0 start, end ;X=0 +BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 hgrlo, hgr1hi jmp loop diff --git a/src/fx/fx.dhgr.bar.dissolve.a b/src/fx/fx.dhgr.bar.dissolve.a index e1d43d503..93a0763db 100644 --- a/src/fx/fx.dhgr.bar.dissolve.a +++ b/src/fx/fx.dhgr.bar.dissolve.a @@ -10,11 +10,7 @@ hgr1hi = $0300 ; [$C0 bytes, main memory only] !source "src/fx/macros.a" - ldx #(end-start) ; copy code to zero page -- lda start-1, x - sta $FF, x - dex - bne - + +COPY_TO_0 start, end ;X=0 +BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 hgrlo, hgr1hi jmp loop diff --git a/src/fx/fx.dhgr.diagonal.a b/src/fx/fx.dhgr.diagonal.a index 1a763b05b..c5805c135 100644 --- a/src/fx/fx.dhgr.diagonal.a +++ b/src/fx/fx.dhgr.diagonal.a @@ -11,11 +11,7 @@ copymasks= $02C0 ; [$08 bytes, different values in main and !source "src/fx/macros.a" - ldx #(end-start) ; copy code to zero page -- lda start-1, x - sta $FF, x - dex - bne - + +COPY_TO_0 start, end ;X=0 +BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 hgrlo, hgr1hi diff --git a/src/fx/fx.dhgr.fizzle.a b/src/fx/fx.dhgr.fizzle.a index f4f0887b0..14fe3348a 100644 --- a/src/fx/fx.dhgr.fizzle.a +++ b/src/fx/fx.dhgr.fizzle.a @@ -7,6 +7,8 @@ addrs=$BF ; [$40 bytes] + !source "src/fx/macros.a" + ldx #$1F ; build address lookup table - txa eor #$20 @@ -15,11 +17,8 @@ addrs=$BF ; [$40 bytes] sta addrs+$20, x dex bpl - - ldx #(end-start+1) ; copy LFSR code to zero page -- ldy start-2, x - sty $FE, x - dex - bne - + + +OVERCOPY_TO_0 start, end ;X=0 ;Y=0 jmp copyaux diff --git a/src/fx/fx.dhgr.precomputed.1bit.a b/src/fx/fx.dhgr.precomputed.1bit.a index 4e0b89e17..19bd86da5 100644 --- a/src/fx/fx.dhgr.precomputed.1bit.a +++ b/src/fx/fx.dhgr.precomputed.1bit.a @@ -55,11 +55,7 @@ +BUILD_HGR_MIRROR_LOOKUP_TABLES hgrlomirror, hgr1himirror +BUILD_MIRROR_COLS mirror_cols +COPY_SELF_TO_AUXMEM - ldx #(end-start) ; copy InputLoop code to zero page -- lda start-1, x - sta $FF, x - dex - bne - + +COPY_TO_0 start, end jmp InputLoop start !pseudopc 0 { @@ -67,7 +63,7 @@ Exit1Bit rts InputLoop ldy #0 input=*+1 - ldx .coords, y ; first value: HGR row (only 0..95 will be in input array) + ldx .coords ; first value: HGR row (only 0..95 will be in input array) bmi Exit1Bit ; if > 127 then we're done +ROW_X_TO_BASE_ADDRESSES +ROW_X_TO_MIRROR_ADDRESSES diff --git a/src/fx/fx.dhgr.precomputed.2bit.a b/src/fx/fx.dhgr.precomputed.2bit.a index ca45f02c2..c233e5bc5 100644 --- a/src/fx/fx.dhgr.precomputed.2bit.a +++ b/src/fx/fx.dhgr.precomputed.2bit.a @@ -57,11 +57,7 @@ +BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 hgrlo, hgr1hi +BUILD_MIRROR_COLS mirror_cols +COPY_SELF_TO_AUXMEM - ldx #(end-start) ; copy InputLoop code to zero page -- lda start-1, x - sta $FF, x - dex - bne - + +COPY_TO_0 start, end jmp InputLoop start @@ -70,7 +66,7 @@ Exit2Bit rts InputLoop ldy #0 input=*+1 - ldx .coords, y ; first value: HGR row + 1 + ldx .coords ; first value: HGR row + 1 beq Exit2Bit ; if 0 then we're done +ROW_X_TO_2BIT_BASE_ADDRESSES diff --git a/src/fx/fx.dhgr.r.by.pixel.a b/src/fx/fx.dhgr.r.by.pixel.a index 6649c0279..c1c345284 100644 --- a/src/fx/fx.dhgr.r.by.pixel.a +++ b/src/fx/fx.dhgr.r.by.pixel.a @@ -11,12 +11,8 @@ copymasks= $02C1 ; [$07 bytes, different values in main and !source "src/fx/macros.a" - ldx #(end-start) ; copy code to zero page -- lda start-1, x - sta $FF, x - dex - bne - - + +COPY_TO_0 start, end + ;X=0 +BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 hgrlo, hgr1hi ldy #7 ; copy copymask arrays into place in main and auxmem diff --git a/src/fx/fx.dhgr.redlines.a b/src/fx/fx.dhgr.redlines.a index bd345b9d2..4f1810aca 100644 --- a/src/fx/fx.dhgr.redlines.a +++ b/src/fx/fx.dhgr.redlines.a @@ -14,11 +14,8 @@ hgr1hi = $0300 ; [$C0 bytes, main memory only] !source "src/fx/macros.a" - ldx #(end-start) ; copy code to zero page -- lda start-1, x - sta $FF, x - dex - bne - + +COPY_TO_0 start, end + ;X=0 +BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 hgrlo, hgr1hi jmp loop diff --git a/src/fx/fx.gr.fizzle.a b/src/fx/fx.gr.fizzle.a index b184275fc..e016691f1 100644 --- a/src/fx/fx.gr.fizzle.a +++ b/src/fx/fx.gr.fizzle.a @@ -5,11 +5,11 @@ !to "build/GR.FIZZLE",plain *=$6000 - ldx #(end-start+1) ; copy LFSR code to zero page -- ldy start-2, x - sty $FE, x - dex - bne - + !source "src/fx/macros.a" + + +OVERCOPY_TO_0 start, end + ;X=0 + ;Y=0 jmp loop start diff --git a/src/fx/fx.hgr.1bit.fizzle.a b/src/fx/fx.hgr.1bit.fizzle.a index 183d28b80..941e5997d 100755 --- a/src/fx/fx.hgr.1bit.fizzle.a +++ b/src/fx/fx.hgr.1bit.fizzle.a @@ -8,11 +8,9 @@ addrs = $6100 ; [256 bytes, page-aligned] copymasks = $6200 ; [256 bytes, page-aligned] - ldx #(end-start) ; copy LFSR code to zero page -- lda start-1, x - sta $FF, x - dex - bne - + !source "src/fx/macros.a" + + +COPY_TO_0 start, end ;X=0 ;A=1 -- ldy #$20 ; create copymask table diff --git a/src/fx/fx.hgr.2bit.fizzle.a b/src/fx/fx.hgr.2bit.fizzle.a index c64821a34..82c685c98 100644 --- a/src/fx/fx.hgr.2bit.fizzle.a +++ b/src/fx/fx.hgr.2bit.fizzle.a @@ -8,11 +8,10 @@ addrs = $6100 ; [256 bytes, page-aligned] copymasks = $80 ; [128 bytes, should not cross page boundary] - ldx #(end-start) ; copy LFSR code to zero page -- lda start-1, x - sta $FF, x - dex - bne - + !source "src/fx/macros.a" + + +COPY_TO_0 start, end + ;X=0 -- ldy #$20 ; create copymask table ora #%10000000 - sta copymasks, x diff --git a/src/fx/fx.hgr.checkerboard.fizzle.a b/src/fx/fx.hgr.checkerboard.fizzle.a index 985847934..6143249b3 100644 --- a/src/fx/fx.hgr.checkerboard.fizzle.a +++ b/src/fx/fx.hgr.checkerboard.fizzle.a @@ -12,6 +12,8 @@ hgrlo = $6400 ; [$C0 bytes, should not cross page boundar hgrhi = $6500 ; [$C0 bytes, should not cross page boundary] shapemask = $8000 ; [$2000 bytes, page-aligned] + !source "src/fx/macros.a" + ldx #0 ; build an HGR base address lookup table, - txa ; except the first address is |shapemask| instead of $2000 and #$F8 @@ -70,11 +72,8 @@ shapemask = $8000 ; [$2000 bytes, page-aligned] inx cpx #$C0 bne -- - ldx #(end-start) ; copy LFSR code to zero page -- lda start-1, x - sta $FF, x - dex - bne - + +COPY_TO_0 start, end + ;X=0 -- ldy #$20 ; create copymask lookup table ora #%10000000 - sta copymasks, x diff --git a/src/fx/fx.hgr.fizzle.a b/src/fx/fx.hgr.fizzle.a index 8db424b38..2dc528b4d 100644 --- a/src/fx/fx.hgr.fizzle.a +++ b/src/fx/fx.hgr.fizzle.a @@ -5,11 +5,11 @@ !to "build/FX.INDEXED/FIZZLE",plain *=$6000 - ldx #(end-start+1) ; copy LFSR code to zero page -- ldy start-2, x - sty $FE, x - dex - bne - + !source "src/fx/macros.a" + + +OVERCOPY_TO_0 start, end + ;X=0 + ;Y=0 jmp loop start diff --git a/src/fx/fx.hgr.palette.fizzle.a b/src/fx/fx.hgr.palette.fizzle.a index d946f0f5a..6f97fdd54 100644 --- a/src/fx/fx.hgr.palette.fizzle.a +++ b/src/fx/fx.hgr.palette.fizzle.a @@ -7,12 +7,11 @@ !source "src/fx/macros.a" ; no code in here - ldx #(end-start+1) ; copy LFSR code to zero page -- ldy start-2, x - sty $FE, x - dex - bne - + +OVERCOPY_TO_0 start, end + ;X=0 + ;Y=0 bit 127 then we're done +ROW_X_TO_BASE_ADDRESSES +ROW_X_TO_MIRROR_ADDRESSES diff --git a/src/fx/fx.hgr.precomputed.2bit.a b/src/fx/fx.hgr.precomputed.2bit.a index 89fa89127..e097002f0 100644 --- a/src/fx/fx.hgr.precomputed.2bit.a +++ b/src/fx/fx.hgr.precomputed.2bit.a @@ -265,11 +265,7 @@ zerotbl !byte $f0, $f2, $ca, $d2, $d8, $e0, $e2, $e6, $ea, $ee +BUILD_HGR_LOOKUP_TABLES hgrlo, hgr1hi +BUILD_MIRROR_COLS mirror_cols +BUILD_SPARSE_BITMASKS_2BIT copymasks, mirror_copymasks - ldx #(end-start-1) ; copy InputLoop code to zero page -- lda start, x - sta $0, x - dex - bpl - + +COPY_TO_0 start, end jmp InputLoop start !pseudopc 0 { @@ -277,7 +273,7 @@ Exit2Bit rts InputLoop ldy #0 input=*+1 - ldx .coords, y ; first value: HGR row + 1 + ldx .coords ; first value: HGR row + 1 beq Exit2Bit ; if 0 then we're done +ROW_X_TO_2BIT_BASE_ADDRESSES diff --git a/src/fx/fx.hgr.precomputed.3bit.a b/src/fx/fx.hgr.precomputed.3bit.a index 9082695c4..bb42a9cb4 100644 --- a/src/fx/fx.hgr.precomputed.3bit.a +++ b/src/fx/fx.hgr.precomputed.3bit.a @@ -228,11 +228,7 @@ ripplezp +BUILD_3BIT_HGR_LOOKUP_TABLES +BUILD_EXTRA_COLS +BUILD_SPARSE_BITMASKS_3BIT - ldx #(end-start-1) ; copy InputLoop code to zero page -- lda start, x - sta $0, x - dex - bpl - + +COPY_TO_0 start, end jmp InputLoop start !pseudopc 0 { @@ -240,7 +236,7 @@ Exit3Bit rts InputLoop ldy #0 input=*+1 - lda .coords, y + lda .coords bmi Exit3Bit ; if high bit is 1 then we're done cmp #$40 php diff --git a/src/fx/fx.shr.2pass.lr.a b/src/fx/fx.shr.2pass.lr.a index ae9ca1d88..6edefeae7 100644 --- a/src/fx/fx.shr.2pass.lr.a +++ b/src/fx/fx.shr.2pass.lr.a @@ -5,17 +5,13 @@ !to "build/FX.INDEXED/SHR.TWOPASS.LR",plain *=$A000 + !source "src/fx/macros.a" !source "src/fx/fx.shr.common.a" shrlo = $301 ; $C8 bytes shrhi = $38 ; $C8 bytes - ldx #(end-start-1) ; copy loop to zero page -- lda start, x - sta $00, x - dex - bpl - - + +COPY_TO_0 start, end +BUILD_SHR_LOOKUP_TABLES shrlo, shrhi ;X=0 +COPY_SCB_AND_PALETTES diff --git a/src/fx/fx.shr.common.a b/src/fx/fx.shr.common.a index b42d06750..b3ef30c39 100644 --- a/src/fx/fx.shr.common.a +++ b/src/fx/fx.shr.common.a @@ -64,3 +64,55 @@ inx bne - } + +!macro BUILD_SHR_MIRROR_ROWS_AND_COLS .mirror_rows, .mirror_cols { +; out: X=0 +; Z=1 + ldx #$C6 + ldy #$00 +- tya + sta .mirror_cols-$27, x + sta .mirror_rows-1, x + iny + dex + bne - +} + +!macro SHR_COPY_TO_STAGE_2 { +; in: X=0 /!\ +; out: X=0 +; Z=1 +; WRITEMAINMEM active + +WRITE_MAIN +- lda $A000, x + sta $9D00, x + lda $A100, x + sta $9E00, x + inx + bne - +} + +!macro SHR_RESTORE_FROM_STAGE_2 { +; out: X=0 +; Z=1 + ldx #$00 +- lda $9D00, x ; copy main code back to $A000 + sta $A000, x ; so it can be called again if necessary + lda $9E00, x + sta $A100, x + inx + bne - +} + +!macro LOAD_SHR_COORDINATES_AT .coords, .filename, .scratch { +; out: WRITEMAINMEM active +; LC RAM2 active and read/write + ldx .filename ; LOAD_FILE_AT macro destroys pathname +- lda .filename, x ; so we need to make a copy + sta .scratch, x + dex + bpl - + + +READ_RAM2_WRITE_RAM2 + +LOAD_FILE_AT .scratch, .coords +} diff --git a/src/fx/fx.shr.diagonal.a b/src/fx/fx.shr.diagonal.a index 47d619dc6..c96ce1599 100644 --- a/src/fx/fx.shr.diagonal.a +++ b/src/fx/fx.shr.diagonal.a @@ -5,17 +5,13 @@ !to "build/FX.INDEXED/SHR.DIAGONAL",plain *=$A000 - !source "src/fx/fx.shr.common.a" - shrlo = $301 ; $C8 bytes shrhi = $201 ; $C8 bytes - ldx #(end-start-1) ; copy loop to zero page -- lda start, x - sta $00, x - dex - bpl - + !source "src/fx/macros.a" + !source "src/fx/fx.shr.common.a" + +COPY_TO_0 start, end +BUILD_SHR_LOOKUP_TABLES shrlo, shrhi ;X=0 +COPY_SCB_AND_PALETTES diff --git a/src/fx/fx.shr.fizzle.a b/src/fx/fx.shr.fizzle.a index 66f8c26f4..6e2a266c2 100644 --- a/src/fx/fx.shr.fizzle.a +++ b/src/fx/fx.shr.fizzle.a @@ -5,6 +5,7 @@ !to "build/FX.INDEXED/SHR.FIZZLE",plain *=$A000 + !source "src/fx/macros.a" !source "src/fx/fx.shr.common.a" addrs=$7F ; [128 bytes] @@ -17,11 +18,7 @@ addrs=$7F ; [128 bytes] dex bne - - ldx #(end-start+1) ; copy LFSR code to zero page -- ldy start-2, x - sty $FE, x - dex - bne - + +OVERCOPY_TO_0 start, end ;X=0 ;Y=0 diff --git a/src/fx/fx.shr.lr.a b/src/fx/fx.shr.lr.a index cfdd2d77c..795663fad 100644 --- a/src/fx/fx.shr.lr.a +++ b/src/fx/fx.shr.lr.a @@ -5,21 +5,16 @@ !to "build/FX.INDEXED/SHR.LR",plain *=$A000 + !source "src/fx/macros.a" !source "src/fx/fx.shr.common.a" shrlo = $301 ; $C8 bytes shrhi = $37 ; $C8 bytes +BUILD_SHR_LOOKUP_TABLES shrlo, shrhi - - ldx #(end-start+1) ; copy loop to zero page -- ldy start-2, x - sty $FE, x - dex - bne - + +OVERCOPY_TO_0 start, end ;X=0 ;Y=0 - +COPY_SCB_AND_PALETTES ;WRITEAUXMEM active diff --git a/src/fx/fx.shr.lr2.a b/src/fx/fx.shr.lr2.a index 59e1f7871..20628fa52 100644 --- a/src/fx/fx.shr.lr2.a +++ b/src/fx/fx.shr.lr2.a @@ -5,17 +5,13 @@ !to "build/FX.INDEXED/SHR.LR2",plain *=$A000 - !source "src/fx/fx.shr.common.a" - shrlo = $301 ; $C8 bytes shrhi = $38 ; $C8 bytes - ldx #(end-start-1) ; copy loop to zero page -- lda start, x - sta $00, x - dex - bpl - + !source "src/fx/macros.a" + !source "src/fx/fx.shr.common.a" + +COPY_TO_0 start, end +BUILD_SHR_LOOKUP_TABLES shrlo, shrhi ;X=0 +COPY_SCB_AND_PALETTES diff --git a/src/fx/fx.shr.precomputed.a b/src/fx/fx.shr.precomputed.a index 396026504..10bbf6dfa 100644 --- a/src/fx/fx.shr.precomputed.a +++ b/src/fx/fx.shr.precomputed.a @@ -8,63 +8,32 @@ mirror_cols = $1E29 ; $A0 bytes but clobbers $28 bytes before mirror_rows = $1F01 ; $C7 bytes coords = $9F00 ; $1F41 bytes - !source "src/constants.a" - !source "src/macros.a" + !source "src/fx/macros.a" !source "src/fx/fx.shr.common.a" start - ldx #$C6 - ldy #$00 -- tya - sta mirror_cols-$27, x - sta mirror_rows-1, x - iny - dex - bne - - + +BUILD_SHR_MIRROR_ROWS_AND_COLS mirror_rows, mirror_cols + ;X=0 +BUILD_SHR_LOOKUP_TABLES shrlo, shrhi ;X=0 +COPY_SCB_AND_PALETTES - ;WRITEAUXMEM active - +WRITE_MAIN ;X=0 -- lda start, x - sta $9D00, x - lda start+$100, x - sta $9E00, x - inx - bne - + ;WRITEAUXMEM active + +SHR_COPY_TO_STAGE_2 jmp stage2 !pseudopc *-$300 { stage2 - ldx CoordinatesFile ; LOAD_FILE_AT macro destroys pathname -- lda CoordinatesFile, x ; so we need to make a copy - sta CoordinatesFileCopy, x - dex - bpl - + +LOAD_SHR_COORDINATES_AT coords, CoordinatesFile, CoordinatesFileCopy + ;WRITEMAINMEM active - +READ_RAM2_WRITE_RAM2 - +LOAD_FILE_AT CoordinatesFileCopy, coords - ;WRITEMAINMEM active after LOAD_FILE_AT macro - - ldx #(endzp-startzp) ; copy loop code to zero page -- lda startzp-1, x - sta $FF, x - dex - bne - + +COPY_TO_0 startzp, endzp +WRITE_AUX jsr InputLoop +WRITE_MAIN - ldx #$00 -- lda $9D00, x ; copy main code back to $A000 - sta start, x ; so it can be called again if necessary - lda $9E00, x - sta start+$100, x - inx - bne - + +SHR_RESTORE_FROM_STAGE_2 +READ_RAM1_WRITE_RAM1 rts diff --git a/src/fx/fx.shr.radial.a b/src/fx/fx.shr.radial.a index f98b9470e..bea96c1f1 100644 --- a/src/fx/fx.shr.radial.a +++ b/src/fx/fx.shr.radial.a @@ -13,65 +13,35 @@ mirror_rows = $1F01 ; $C7 bytes coords = $9F00 ; $1F41 bytes last_coords = coords+$1F3E - !source "src/constants.a" - !source "src/macros.a" + !source "src/fx/macros.a" !source "src/fx/fx.shr.common.a" start - ldx #$C6 - ldy #$00 -- tya - sta mirror_cols-$27, x - sta mirror_rows-1, x - iny - dex - bne - - + +BUILD_SHR_MIRROR_ROWS_AND_COLS mirror_rows, mirror_cols + ;X=0 +BUILD_SHR_LOOKUP_TABLES shrlo, shrhi ;X=0 +COPY_SCB_AND_PALETTES - ;WRITEAUXMEM active - +WRITE_MAIN ;X=0 -- lda start, x - sta $9D00, x - lda start+$100, x - sta $9E00, x - inx - bne - + ;WRITEAUXMEM active + +SHR_COPY_TO_STAGE_2 jmp stage2 !pseudopc *-$300 { stage2 - ldx CoordinatesFile ; LOAD_FILE_AT macro destroys pathname -- lda CoordinatesFile, x ; so we need to make a copy - sta CoordinatesFileCopy, x - dex - bpl - + +LOAD_SHR_COORDINATES_AT coords, CoordinatesFile, CoordinatesFileCopy + ;WRITEMAINMEM active - +READ_RAM2_WRITE_RAM2 - +LOAD_FILE_AT CoordinatesFileCopy, coords - ;WRITEMAINMEM active after LOAD_FILE_AT macro lda #$80 sta coords-2 - ldx #(endzp-startzp) ; copy loop code to zero page -- lda startzp-1, x - sta $FF, x - dex - bne - + +COPY_TO_0 startzp, endzp +WRITE_AUX jsr LoopBL +WRITE_MAIN - ldx #$00 -- lda $9D00, x ; copy main code back to $A000 - sta start, x ; so it can be called again if necessary - lda $9E00, x - sta start+$100, x - inx - bne - + +SHR_RESTORE_FROM_STAGE_2 +READ_RAM1_WRITE_RAM1 rts diff --git a/src/fx/fx.shr.ud.a b/src/fx/fx.shr.ud.a index 910eae88b..fe467c3ff 100644 --- a/src/fx/fx.shr.ud.a +++ b/src/fx/fx.shr.ud.a @@ -5,19 +5,15 @@ !to "build/FX.INDEXED/SHR.UD",plain *=$A000 - !source "src/fx/fx.shr.common.a" - shrlo = $301 ; $C8 bytes shrhi = $38 ; $C8 bytes reverseshrlo = $BD01 ; $C8 bytes reverseshrhi = $BE01 ; $C8 bytes - ldx #(end-start-1) ; copy loop to zero page -- lda start, x - sta $00, x - dex - bpl - + !source "src/fx/macros.a" + !source "src/fx/fx.shr.common.a" + +COPY_TO_0 start, end +BUILD_SHR_REVERSE_LOOKUP_TABLES reverseshrlo, reverseshrhi +BUILD_SHR_LOOKUP_TABLES shrlo, shrhi ;X=0 diff --git a/src/fx/macros.a b/src/fx/macros.a index b3a76d63e..c60890be9 100644 --- a/src/fx/macros.a +++ b/src/fx/macros.a @@ -161,5 +161,27 @@ + } +!macro COPY_TO_0 .start, .end { +; out: X=0 +; Z=1 + ldx #(.end-.start) +- lda .start-1, x + sta $FF, x + dex + bne - +} + +!macro OVERCOPY_TO_0 .start, .end { +; over-copy region to $00 +; clobbers $FF +; out: X=0 +; Y=last byte before start (e.g. 0 if the last instruction is JMP $0000) + ldx #(.end-.start+1) +- ldy .start-2, x + sty $FE, x + dex + bne - +} + _FX_MACROS_=* }