4sports/src/fx/fx.shr.radial2.a
2022-08-25 21:56:29 -04:00

100 lines
2.4 KiB
Plaintext

;license:MIT
;(c) 2021 by 4am
;
!cpu 6502
!to "build/FX.INDEXED/SHR.RADIAL2",plain
*=$A000
mirror_rows = $106 ; $C8 bytes
shrlo = $200 ; $C8 bytes
shrhi = $300 ; $C8 bytes
coords = $9F00 ; $1F41 bytes
last_coords = coords+$1F3E
CoordinatesFileCopy = $BE42; $11 bytes
mirror_cols = $BE60 ; $A0 bytes but clobbers $27 previous bytes during construction
!source "src/fx/macros.a"
+SHR_STAGE_1 shrlo, shrhi, mirror_rows, mirror_cols
jmp stage2
!pseudopc *-$300 {
stage2
+LOAD_SHR_COORDINATES_AT coords, CoordinatesFile, CoordinatesFileCopy
;WRITEMAINMEM active
lda #$80
sta coords-2
+SHR_STAGE_2 startzp, endzp
rts
startzp
!pseudopc 0 {
; top-left quadrant (original row, original column, original input order)
input ldx coords ; SMC
bmi exit
ldy #1
lda (input+1), y
tay
jsr copy
; bottom-right quadrant (opposite row, opposite column, original input order)
lda mirror_rows, x
tax
lda mirror_cols, y
tay
jsr copy
; bottom-left quadrant (opposite row, original column, reverse input order)
reverse_input
ldx last_coords ; SMC
lda mirror_rows, x
tax
ldy #1
lda (reverse_input+1), y
tay
jsr copy
; top-right quadrant (original row, opposite column, reverse input order)
lda mirror_rows, x ; mirror of the mirror
tax
lda mirror_cols, y
tay
jsr copy
inc <input+1
inc <input+1
bne +
inc <input+2
+ lda <reverse_input+1
php
dec <reverse_input+1
dec <reverse_input+1
plp
bne +
dec <reverse_input+2
+ bit $C000
bpl input
copy
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
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
}
CoordinatesFile
!byte 18
!text "FX/SHR.RADIAL.DATA"