mirror of
https://github.com/a2-4am/4cade.git
synced 2025-01-16 11:30:45 +00:00
refactor common code for SHR precomputed effects
This commit is contained in:
parent
3806a780b5
commit
4ca2e6b57b
@ -5,134 +5,8 @@
|
||||
!to "build/FX.INDEXED/SHR.IRIS",plain
|
||||
*=$A000
|
||||
|
||||
mirror_cols = $126 ; $A0 bytes but clobbers $20 bytes before
|
||||
shrlo = $201 ; $C8 bytes
|
||||
CoordinatesFileCopy = $2C8; $11 bytes
|
||||
shrhi = $301 ; $C8 bytes
|
||||
coords = $9F00 ; $1F40 bytes
|
||||
mirror_rows = $BE40 ; $C0 bytes
|
||||
!source "src/fx/fx.shr.precomputed.a"
|
||||
|
||||
!source "src/constants.a"
|
||||
!source "src/macros.a"
|
||||
!source "src/fx/fx.shr.common.a"
|
||||
|
||||
start
|
||||
ldx #$C0
|
||||
ldy #$00
|
||||
- tya
|
||||
sta mirror_cols-$21, 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 {
|
||||
CoordinatesFile
|
||||
!byte 16
|
||||
!text "FX/SHR.IRIS.DATA"
|
||||
|
||||
stage2
|
||||
ldx #(stage2-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
|
||||
|
||||
startzp
|
||||
!pseudopc 0 {
|
||||
exit rts ; also terminates stage2 code
|
||||
InputLoop
|
||||
ldy #0
|
||||
input ldx coords, y ; first value: SHR row (only 0..99 will be in input array)
|
||||
bmi exit ; if > 127 then we're done
|
||||
inc <input+1 ; (technically the first byte of mirror_rows serves as this EOF delimiter)
|
||||
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
|
||||
dey
|
||||
|
||||
; 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
|
||||
bne InputLoop
|
||||
bit $C000
|
||||
bmi exit
|
||||
inc <input+2
|
||||
bne InputLoop ; always branches
|
||||
|
||||
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
|
||||
iny
|
||||
lda (src1+1), y
|
||||
sta (src1+1), y
|
||||
lda (src2+1), y
|
||||
sta (src2+1), y
|
||||
rts
|
||||
}
|
||||
endzp
|
||||
}
|
||||
end
|
||||
|
129
src/fx/fx.shr.precomputed.a
Normal file
129
src/fx/fx.shr.precomputed.a
Normal file
@ -0,0 +1,129 @@
|
||||
;license:MIT
|
||||
;(c) 2021 by 4am
|
||||
;
|
||||
mirror_cols = $126 ; $A0 bytes but clobbers $20 bytes before
|
||||
shrlo = $201 ; $C8 bytes
|
||||
CoordinatesFileCopy = $2C8; $11 bytes
|
||||
shrhi = $301 ; $C8 bytes
|
||||
coords = $9F00 ; $1F40 bytes
|
||||
mirror_rows = $BE40 ; $C0 bytes
|
||||
|
||||
!source "src/constants.a"
|
||||
!source "src/macros.a"
|
||||
!source "src/fx/fx.shr.common.a"
|
||||
|
||||
start
|
||||
ldx #$C0
|
||||
ldy #$00
|
||||
- tya
|
||||
sta mirror_cols-$21, 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
|
||||
|
||||
startzp
|
||||
!pseudopc 0 {
|
||||
exit rts ; also terminates stage2 code
|
||||
InputLoop
|
||||
ldy #0
|
||||
input ldx coords, y ; first value: SHR row (only 0..99 will be in input array)
|
||||
bmi exit ; if > 127 then we're done
|
||||
inc <input+1 ; (technically the first byte of mirror_rows serves as this EOF delimiter)
|
||||
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
|
||||
dey
|
||||
|
||||
; 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
|
||||
bne InputLoop
|
||||
bit $C000
|
||||
bmi exit
|
||||
inc <input+2
|
||||
bne InputLoop ; always branches
|
||||
|
||||
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
|
||||
iny
|
||||
lda (src1+1), y
|
||||
sta (src1+1), y
|
||||
lda (src2+1), y
|
||||
sta (src2+1), y
|
||||
rts
|
||||
}
|
||||
endzp
|
||||
}
|
@ -5,134 +5,8 @@
|
||||
!to "build/FX.INDEXED/SHR.RIPPLE",plain
|
||||
*=$A000
|
||||
|
||||
mirror_cols = $126 ; $A0 bytes but clobbers $20 bytes before
|
||||
shrlo = $201 ; $C8 bytes
|
||||
CoordinatesFileCopy = $2C8; $11 bytes
|
||||
shrhi = $301 ; $C8 bytes
|
||||
coords = $9F00 ; $1F40 bytes
|
||||
mirror_rows = $BE40 ; $C0 bytes
|
||||
!source "src/fx/fx.shr.precomputed.a"
|
||||
|
||||
!source "src/constants.a"
|
||||
!source "src/macros.a"
|
||||
!source "src/fx/fx.shr.common.a"
|
||||
|
||||
start
|
||||
ldx #$C0
|
||||
ldy #$00
|
||||
- tya
|
||||
sta mirror_cols-$21, 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 {
|
||||
CoordinatesFile
|
||||
!byte 18
|
||||
!text "FX/SHR.RIPPLE.DATA"
|
||||
|
||||
stage2
|
||||
ldx #(stage2-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
|
||||
|
||||
startzp
|
||||
!pseudopc 0 {
|
||||
exit rts ; also terminates stage2 code
|
||||
InputLoop
|
||||
ldy #0
|
||||
input ldx coords, y ; first value: SHR row (only 0..99 will be in input array)
|
||||
bmi exit ; if > 127 then we're done
|
||||
inc <input+1 ; (technically the first byte of mirror_rows serves as this EOF delimiter)
|
||||
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
|
||||
dey
|
||||
|
||||
; 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
|
||||
bne InputLoop
|
||||
bit $C000
|
||||
bmi exit
|
||||
inc <input+2
|
||||
bne InputLoop ; always branches
|
||||
|
||||
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
|
||||
iny
|
||||
lda (src1+1), y
|
||||
sta (src1+1), y
|
||||
lda (src2+1), y
|
||||
sta (src2+1), y
|
||||
rts
|
||||
}
|
||||
endzp
|
||||
}
|
||||
end
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10948420
|
||||
!be24 10948422
|
||||
!le16 4281
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10901174
|
||||
!be24 10901176
|
||||
!le16 5239
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10844033
|
||||
!be24 10844035
|
||||
!le16 3586
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10856403
|
||||
!be24 10856405
|
||||
!le16 3946
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10871802
|
||||
!be24 10871804
|
||||
!le16 4998
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10889454
|
||||
!be24 10889456
|
||||
!le16 5571
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10952701
|
||||
!be24 10952703
|
||||
!le16 410
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10953455
|
||||
!be24 10953457
|
||||
!le16 448
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10953903
|
||||
!be24 10953905
|
||||
!le16 303
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10908559
|
||||
!be24 10908561
|
||||
!le16 1242
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10953187
|
||||
!be24 10953189
|
||||
!le16 67
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10948361
|
||||
!be24 10948363
|
||||
!le16 59
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10947031
|
||||
!be24 10947033
|
||||
!le16 1249
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10933021
|
||||
!be24 10933023
|
||||
!le16 464
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10906413
|
||||
!be24 10906415
|
||||
!le16 2146
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10910064
|
||||
!be24 10910066
|
||||
!le16 6149
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10953111
|
||||
!be24 10953113
|
||||
!le16 76
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10948280
|
||||
!be24 10948282
|
||||
!le16 81
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10953254
|
||||
!be24 10953256
|
||||
!le16 201
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10933485
|
||||
!be24 10933487
|
||||
!le16 4407
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10937892
|
||||
!be24 10937894
|
||||
!le16 1533
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10939425
|
||||
!be24 10939427
|
||||
!le16 1040
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10940465
|
||||
!be24 10940467
|
||||
!le16 3237
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10943702
|
||||
!be24 10943704
|
||||
!le16 2764
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10946466
|
||||
!be24 10946468
|
||||
!le16 460
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10946926
|
||||
!be24 10946928
|
||||
!le16 105
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10954206
|
||||
!be24 10954208
|
||||
!le16 2370
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10921126
|
||||
!be24 10921128
|
||||
!le16 6149
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10895025
|
||||
!be24 10895027
|
||||
!le16 6149
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10836001
|
||||
!be24 10836003
|
||||
!le16 8032
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10847619
|
||||
!be24 10847621
|
||||
!le16 8784
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10860349
|
||||
!be24 10860351
|
||||
!le16 11453
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10876800
|
||||
!be24 10876802
|
||||
!le16 12654
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10909801
|
||||
!be24 10909803
|
||||
!le16 263
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10916213
|
||||
!be24 10916215
|
||||
!le16 4913
|
||||
|
@ -4,5 +4,5 @@
|
||||
; This file is automatically generated
|
||||
;
|
||||
!byte 0
|
||||
!be24 10927275
|
||||
!be24 10927277
|
||||
!le16 5746
|
||||
|
Loading…
x
Reference in New Issue
Block a user