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

96 lines
1.8 KiB
Plaintext
Raw Normal View History

2019-01-13 23:55:40 +00:00
;license:MIT
;(c) 2019 by qkumba
!cpu 6502
!to "build/FX/SHR.FIZZLE",plain
*=$a000
;init RNG
ldy #1
sty @rnd1+1
dey
sty @rnd2+1
;copy SCB and palette
lda #$9d
sta $3d
sty $3c
ldx #$23 ; copy SCB+palette+this code to auxmem
sta $c005
@copystuff
lda ($3c),y
sta ($3c),y
iny
bne @copystuff
inc $3d
dex
bne @copystuff
;force write offset 0 otherwise it will be missed
lda $2000
sta $2000
sta $c004
;iterate
@loop
ldy @rnd1+1
ldx @rnd2+1
lsr @rnd2+1
ror @rnd1+1
bcc +
;feedback polynomial forms #$4001 for period of 32767
lda @rnd1+1
eor #1
sta @rnd1+1
lda @rnd2+1
eor #$40
sta @rnd2+1
;don't rewrite SCB or palette
;it will make the fizzle take longer than obviously needed
+ cpx #$7d
bcs +
sty $26
sty $3c
txa
;select address
clc
adc #$20
sta $27
sta $3d
;copy pixel from other page to this page
ldy #0
lda ($3c),y
sta $c005
sta ($26),y
sta $c004
;wait while checking for keypress
+ ldx #2
@wait lda $c000
bmi @exit
dex
bne @wait
;and exit condition
@rnd2 lda #0
bne @loop
@rnd1 lda #0
cmp #1
bne @loop
@exit rts