4cade/src/fx/fx.shr.precomputed.a

124 lines
3.0 KiB
Plaintext

;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/constants.a"
!source "src/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_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 -
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 -
+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 -
+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 -
+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
exit rts
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
rts
}
endzp
}