shave some bytes

This commit is contained in:
4am 2021-12-17 20:14:02 -05:00
parent 02a83651a0
commit d2d638539a
44 changed files with 246 additions and 8150 deletions

View File

@ -116,3 +116,104 @@
+READ_RAM2_WRITE_RAM2
+LOAD_FILE_AT .scratch, .coords
}
!macro SHR_STAGE_1 .shrlo, .shrhi, .mirror_rows, .mirror_cols {
+BUILD_SHR_MIRROR_ROWS_AND_COLS .mirror_rows, .mirror_cols
;X=0
+BUILD_SHR_LOOKUP_TABLES .shrlo, .shrhi
;X=0
+COPY_SCB_AND_PALETTES
;X=0
;WRITEAUXMEM active
+SHR_COPY_TO_STAGE_2
}
!macro SHR_STAGE_3 .coords, .shrlo, .shrhi, .mirror_rows, .mirror_cols {
input ldx .coords ; first value: SHR row (only 0..99 will be in input array)
bmi exit ; if > 127 then we're done
ldy #1
lda (<input+1), y
tay
; main 2x2 block in top-left quadrant
jsr copy_block_from_x
; corresponding 2x2 block in top-right quadrant
lda .mirror_cols, y
tay
jsr copy_block
; corresponding 2x2 block in bottom-right quadrant
lda .mirror_rows, x
tax
jsr copy_block_from_x
; corresponding 2x2 block in bottom-left quadrant
lda .mirror_cols, y
tay
jsr copy_block
inc <input+1
inc <input+1
bne input
inc <input+2
bit $C000
bpl input
copy_block_from_x
lda .shrlo, x
sta <src1+1
lda .shrhi, x
sta <src1+2
lda .shrlo+1, x
sta <src2+1
lda .shrhi+1, x
sta <src2+2
copy_block
src1 lda $FD00, y ; SMC high byte
sta (src1+1), y
src2 lda $FD00, y ; SMC high byte
sta (src2+1), y
exit rts
}
!macro SHR_REVERSE .coords, .endcoords {
ldy #<coords
sty $f0
lda #>coords
sta $f1
lda #<(.endcoords - 2)
sta $f2
lda #>(.endcoords - 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 #>(.coords + (.endcoords-.coords)/2)
bne +
lda $f0
eor #<(.coords + (.endcoords-.coords)/2)
beq ++
+ lda $f2
bne +
dec $f3
+ dec $f2
bcs -
bcc -- ; always
++
}

View File

@ -5,7 +5,41 @@
!to "build/FX.INDEXED/SHR.IRIS",plain
*=$A000
!source "src/fx/fx.shr.precomputed.a"
shrlo = $201 ; $C8 bytes
CoordinatesFileCopy = $2C8; $11 bytes
shrhi = $301 ; $C8 bytes
mirror_cols = $1E29 ; $A0 bytes but clobbers $28 bytes before
mirror_rows = $1F01 ; $C7 bytes
coords = $9F00 ; $1F41 bytes
!source "src/fx/macros.a"
!source "src/fx/fx.shr.common.a"
+SHR_STAGE_1 shrlo, shrhi, mirror_rows, mirror_cols
jmp stage2
!pseudopc *-$300 {
stage2
+LOAD_SHR_COORDINATES_AT coords, CoordinatesFile, CoordinatesFileCopy
;WRITEMAINMEM active
+COPY_TO_0 startzp, endzp
+WRITE_AUX
jsr stage3
+WRITE_MAIN
+SHR_RESTORE_FROM_STAGE_2
+READ_RAM1_WRITE_RAM1
rts
startzp
!pseudopc 0 {
stage3
+SHR_STAGE_3 coords, shrlo, shrhi, mirror_rows, mirror_cols
}
endzp
}
CoordinatesFile
!byte 16

View File

@ -5,8 +5,44 @@
!to "build/FX.INDEXED/SHR.IRIS.IN",plain
*=$A000
!source "src/fx/fx.shr.precomputed.a"
shrlo = $201 ; $C8 bytes
CoordinatesFileCopy = $2C8; $11 bytes
shrhi = $301 ; $C8 bytes
mirror_cols = $1E29 ; $A0 bytes but clobbers $28 bytes before
mirror_rows = $1F01 ; $C7 bytes
coords = $9F00 ; $1F41 bytes
endcoords = $BE40
!source "src/fx/macros.a"
!source "src/fx/fx.shr.common.a"
+SHR_STAGE_1 shrlo, shrhi, mirror_rows, mirror_cols
jmp stage2
!pseudopc *-$300 {
stage2
+LOAD_SHR_COORDINATES_AT coords, CoordinatesFile, CoordinatesFileCopy
;WRITEMAINMEM active
+SHR_REVERSE coords, endcoords
+COPY_TO_0 startzp, endzp
+WRITE_AUX
jsr stage3
+WRITE_MAIN
+SHR_RESTORE_FROM_STAGE_2
+READ_RAM1_WRITE_RAM1
rts
startzp
!pseudopc 0 {
stage3
+SHR_STAGE_3 coords, shrlo, shrhi, mirror_rows, mirror_cols
}
endzp
}
CoordinatesFile
!byte 18
!text "FX/SHR.IRISIN.DATA"
!byte 16
!text "FX/SHR.IRIS.DATA"

File diff suppressed because it is too large Load Diff

View File

@ -1,90 +0,0 @@
;license:MIT
;(c) 2021 by 4am
;
shrlo = $201 ; $C8 bytes
CoordinatesFileCopy = $2C8; $11 bytes
shrhi = $301 ; $C8 bytes
mirror_cols = $1E29 ; $A0 bytes but clobbers $28 bytes before
mirror_rows = $1F01 ; $C7 bytes
coords = $9F00 ; $1F41 bytes
!source "src/fx/macros.a"
!source "src/fx/fx.shr.common.a"
+BUILD_SHR_MIRROR_ROWS_AND_COLS mirror_rows, mirror_cols
;X=0
+BUILD_SHR_LOOKUP_TABLES shrlo, shrhi
;X=0
+COPY_SCB_AND_PALETTES
;X=0
;WRITEAUXMEM active
+SHR_COPY_TO_STAGE_2
jmp stage2
!pseudopc *-$300 {
stage2
+LOAD_SHR_COORDINATES_AT coords, CoordinatesFile, CoordinatesFileCopy
;WRITEMAINMEM active
+COPY_TO_0 startzp, endzp
+WRITE_AUX
jsr InputLoop
+WRITE_MAIN
+SHR_RESTORE_FROM_STAGE_2
+READ_RAM1_WRITE_RAM1
rts
startzp
!pseudopc 0 {
InputLoop
input ldx coords ; first value: SHR row (only 0..99 will be in input array)
bmi exit ; if > 127 then we're done
ldy #1
lda (<input+1), y
tay
; main 2x2 block in top-left quadrant
jsr copy_block_from_x
; corresponding 2x2 block in top-right quadrant
lda mirror_cols, y
tay
jsr copy_block
; corresponding 2x2 block in bottom-right quadrant
lda mirror_rows, x
tax
jsr copy_block_from_x
; corresponding 2x2 block in bottom-left quadrant
lda mirror_cols, y
tay
jsr copy_block
inc <input+1
inc <input+1
bne InputLoop
inc <input+2
bit $C000
bpl InputLoop
copy_block_from_x
lda shrlo, x
sta <src1+1
lda shrhi, x
sta <src1+2
lda shrlo+1, x
sta <src2+1
lda shrhi+1, x
sta <src2+2
copy_block
src1 lda $FD00, y ; SMC high byte
sta (src1+1), y
src2 lda $FD00, y ; SMC high byte
sta (src2+1), y
exit rts
}
endzp
}

View File

@ -5,7 +5,41 @@
!to "build/FX.INDEXED/SHR.RIPPLE",plain
*=$A000
!source "src/fx/fx.shr.precomputed.a"
shrlo = $201 ; $C8 bytes
CoordinatesFileCopy = $2C8; $11 bytes
shrhi = $301 ; $C8 bytes
mirror_cols = $1E29 ; $A0 bytes but clobbers $28 bytes before
mirror_rows = $1F01 ; $C7 bytes
coords = $9F00 ; $1F41 bytes
!source "src/fx/macros.a"
!source "src/fx/fx.shr.common.a"
+SHR_STAGE_1 shrlo, shrhi, mirror_rows, mirror_cols
jmp stage2
!pseudopc *-$300 {
stage2
+LOAD_SHR_COORDINATES_AT coords, CoordinatesFile, CoordinatesFileCopy
;WRITEMAINMEM active
+COPY_TO_0 startzp, endzp
+WRITE_AUX
jsr stage3
+WRITE_MAIN
+SHR_RESTORE_FROM_STAGE_2
+READ_RAM1_WRITE_RAM1
rts
startzp
!pseudopc 0 {
stage3
+SHR_STAGE_3 coords, shrlo, shrhi, mirror_rows, mirror_cols
}
endzp
}
CoordinatesFile
!byte 18

View File

@ -1,12 +0,0 @@
;license:MIT
;(c) 2021 by 4am
;
!cpu 6502
;!to "build/FX.INDEXED/SHR.SNOWFLAKE",plain
*=$A000
!source "src/fx/fx.shr.precomputed.a"
CoordinatesFile
!byte 17
!text "FX/SHR.FLAKE.DATA"

File diff suppressed because it is too large Load Diff

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10962975
!be24 10963039
!le16 4281

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10915676
!be24 10915740
!le16 5239

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10858535
!be24 10858599
!le16 3586

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10870905
!be24 10870969
!le16 3946

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10886304
!be24 10886368
!le16 4998

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10903956
!be24 10904020
!le16 5571

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10967256
!be24 10967320
!le16 410

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10968010
!be24 10968074
!le16 448

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10968458
!be24 10968522
!le16 303

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10923061
!be24 10923125
!le16 1242

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10967742
!be24 10967806
!le16 67

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10962916
!be24 10962980
!le16 59

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10961586
!be24 10961650
!le16 1249

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10947576
!be24 10947640
!le16 464

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10920915
!be24 10920979
!le16 2146

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10924619
!be24 10924683
!le16 6149

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10967666
!be24 10967730
!le16 76

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10962835
!be24 10962899
!le16 81

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10967809
!be24 10967873
!le16 201

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10948040
!be24 10948104
!le16 4407

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10952447
!be24 10952511
!le16 1533

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10953980
!be24 10954044
!le16 1040

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10955020
!be24 10955084
!le16 3237

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10958257
!be24 10958321
!le16 2764

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10961021
!be24 10961085
!le16 460

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10961481
!be24 10961545
!le16 105

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10968761
!be24 10968825
!le16 2370

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10935681
!be24 10935745
!le16 6149

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10909527
!be24 10909591
!le16 6149

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10850503
!be24 10850567
!le16 8032

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10862121
!be24 10862185
!le16 8784

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10874851
!be24 10874915
!le16 11453

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10891302
!be24 10891366
!le16 12654

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10924303
!be24 10924367
!le16 316

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10930768
!be24 10930832
!le16 4913

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10941830
!be24 10941894
!le16 5746