ridiculously fast DHGR fizzle fade

This commit is contained in:
4am 2020-09-06 14:44:37 -04:00
parent 735d057736
commit 9dafce5ae8

View File

@ -1,84 +1,58 @@
;license:MIT
;(c) 2017-2020 by qkumba/4am
;(c) 2017-2020 by qkumba/4am/John Brooks
;
!cpu 6502
!to "build/FX/DHGR.FIZZLE",plain
*=$6000
rnd1=$fe
rnd2=$ff
ldx #(end-start) ; copy LFSR code to zero page
- lda start-1, x
sta $0, x
dex
bne -
txa
tay
pha
pha
rts
; performance notes:
; old: 10657266..12247971 = 1590705
; new: 10196445..11493278 = 1296833
jsr CopySelfToAuxmem
;init RNG
ldy #1
sty rnd1
dey
sty rnd2
;iterate
ldx rnd2
@loop
lda rnd1
@loop2
eor #$ff
sta $26
sta $3c
lsr rnd2
ror rnd1
bcc +
;feedback polynomial forms #$2015 for period of 16383
lda rnd1
eor #$15
sta rnd1
lda rnd2
eor #$20
sta rnd2
;little hack to avoid missing offset zero
;screen hole at $xxFF is missed instead
+ txa
and #$1f
;target page 1
ora #$20
sta $27
start
!pseudopc 1 {
; in: X,Y=0
loop txa
loop1 eor #$35 ; LFSR form 0x3500 with period 16383
tax
loop2 lda addrs, x
bpl +
and #$7F
sta $C003
sta $C005
+ sta <dst+2
eor #$60
sta $3d
;copy pixel from other page to this page
cpx #$20
bcc +
sta $c003
sta $c005
+ lda ($3c),y
sta ($26),y
sta $c002
sta $c004
;exit conditions
ldx rnd2
bne @loop
lda $c000
bmi @exit
lda rnd1
cmp #1
bne @loop2
@exit rts
!source "src/fx/fx.dhgr.common.a"
sta <src+2
src lda $FD00, y
dst sta $FD00, y
sta $C002
sta $C004
txa
lsr
tax
tya
ror
tay
bcc loop2
bne loop
bit $C000
bmi exit
txa
bne loop1
exit lda $4000 ; last lousy byte (because LFSR never hits 0)
sta $2000
rts
}
end
addrs
!byte $20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$2A,$2B,$2C,$2D,$2E,$2F
!byte $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$3F
!byte $A0,$A1,$A2,$A3,$A4,$A5,$A6,$A7,$A8,$A9,$AA,$AB,$AC,$AD,$AE,$AF
!byte $B0,$B1,$B2,$B3,$B4,$B5,$B6,$B7,$B8,$B9,$BA,$BB,$BC,$BD,$BE,$BF