18% faster DHGR fizzle fade

This commit is contained in:
4am 2020-09-03 18:54:54 -04:00
parent 5a90ba8555
commit a48216f841

View File

@ -1,45 +1,52 @@
;license:MIT ;license:MIT
;(c) 2017-2018 by qkumba ;(c) 2017-2020 by qkumba/4am
; ;
!cpu 6502 !cpu 6502
!to "build/FX/DHGR.FIZZLE",plain !to "build/FX/DHGR.FIZZLE",plain
*=$6000 *=$6000
rnd1=$fe
rnd2=$ff
; performance notes:
; old: 10657266..12247971 = 1590705
; new: 10196445..11493278 = 1296833
jsr CopySelfToAuxmem jsr CopySelfToAuxmem
;init RNG ;init RNG
ldx #1 ldy #1
stx @rnd1+1 sty rnd1
dex dey
stx @rnd2+1 sty rnd2
;iterate ;iterate
ldx rnd2
@loop @loop
ldy @rnd1+1 lda rnd1
ldx @rnd2+1 @loop2
lsr @rnd2+1 eor #$ff
ror @rnd1+1 sta $26
sta $3c
lsr rnd2
ror rnd1
bcc + bcc +
;feedback polynomial forms #$2015 for period of 16383 ;feedback polynomial forms #$2015 for period of 16383
lda @rnd1+1 lda rnd1
eor #$15 eor #$15
sta @rnd1+1 sta rnd1
lda @rnd2+1 lda rnd2
eor #$20 eor #$20
sta @rnd2+1 sta rnd2
;little hack to avoid missing offset zero ;little hack to avoid missing offset zero
;screen hole at $xxFF is missed instead ;screen hole at $xxFF is missed instead
+ tya + txa
eor #$ff
sta $26
sta $3c
txa
and #$1f and #$1f
;target page 1 ;target page 1
@ -51,7 +58,6 @@
;copy pixel from other page to this page ;copy pixel from other page to this page
ldy #0
cpx #$20 cpx #$20
bcc + bcc +
sta $c003 sta $c003
@ -61,18 +67,17 @@
sta $c002 sta $c002
sta $c004 sta $c004
;check for keypress ;exit conditions
ldx rnd2
bne @loop
lda $c000 lda $c000
bmi @exit bmi @exit
;and exit condition lda rnd1
@rnd2 lda #0
bne @loop
@rnd1 lda #0
cmp #1 cmp #1
bne @loop bne @loop2
@exit rts @exit rts