4cade/src/fx/fx.hgr.1bit.fizzle.a

87 lines
1.7 KiB
Plaintext
Executable File

;license:MIT
;(c) 2017-2019 by qkumba
!cpu 6502
!to "build/FX/BIT.FIZZLE",plain
*=$6000
tmp=$fd
copymask=$ff
;init RNG
ldx #1
stx @rnd1+1
dex
stx @rnd2+1
;iterate
@loop
ldy @rnd1+1
ldx @rnd2+1
lsr @rnd2+1
ror @rnd1+1
bcc +
;feedback polynomial forms #$8016 for period of 65535
lda @rnd1+1
eor #$16
sta @rnd1+1
lda @rnd2+1
eor #$80
sta @rnd2+1
;little hack to avoid missing offset zero
;screen hole at $xxFF is missed instead
+ tya
eor #$ff
sta $26
sta $3c
lda #%00000001
sta copymask
txa
and #$e0
beq +
- asl copymask
adc #$e0
bne -
+ txa
and #$1f
;target page 1
ora #$20
sta $27
eor #$60
sta $3d
;copy pixel from other page to this page
ldy #0
lda ($26),y
eor ($3c),y ; merge source and destination bits
and copymask ; isolate the bits to replace, zero the rest
eor ($26),y ; unmerge source and destination bits, leaves "to keep" destination bits intact
sta ($26),y ; write the result
;wait while checking for keypress
@wait lda $c000
bmi @exit
;and exit condition
@rnd2 lda #0
bne @loop
@rnd1 lda #0
cmp #1
bne @loop
@exit rts