4cade/src/fx/fx.hgr.palette.fizzle.a

101 lines
1.9 KiB
Plaintext
Raw Normal View History

2019-10-20 15:05:00 +00:00
;license:MIT
;(c) 2017-2019 by qkumba and 4am
!cpu 6502
!to "build/FX.INDEXED/PALETTE.FIZZLE",plain
2019-10-20 15:05:00 +00:00
*=$6000
2019-10-24 19:41:08 +00:00
copymask_even = $f0
copymask_odd = $f1
counter = $f2
2019-10-20 18:13:32 +00:00
2019-10-20 15:05:00 +00:00
!source "src/fx/macros.a"
;init masks
lda #%11010101
sta copymask_even
lda #%10101010
sta copymask_odd
2019-10-24 19:41:08 +00:00
lda #2
sta counter
2019-10-20 15:05:00 +00:00
@outerloop
;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 #$100D for period of 8191
lda @rnd1+1
eor #$0d
sta @rnd1+1
lda @rnd2+1
eor #$10
sta @rnd2+1
;little hack to avoid missing offset zero
;screen hole at $xxFF is missed instead
+ tya
eor #$ff
sta $26
sta $3c
txa
;target page 1
ora #$20
sta $27
eor #$60
sta $3d
;copy pixel from other page to this page
ldy #0
lda $26
ror
bcs @odd
lda ($26),y
2019-10-24 19:41:08 +00:00
eor ($3c),y
2019-10-20 15:05:00 +00:00
and copymask_even
2019-10-24 19:41:08 +00:00
eor ($26),y
2019-10-20 15:05:00 +00:00
sta ($26),y
jmp @next
@odd
lda ($26),y
2019-10-24 19:41:08 +00:00
eor ($3c),y
2019-10-20 15:05:00 +00:00
and copymask_odd
2019-10-24 19:41:08 +00:00
eor ($26),y
2019-10-20 15:05:00 +00:00
sta ($26),y
@next
lda $c000
bmi @exit
;and exit condition
@rnd2 lda #0
bne @loop
@rnd1 lda #0
cmp #1
bne @loop
lda #$FF
sta copymask_even
sta copymask_odd
2019-10-24 19:41:08 +00:00
dec counter
2019-10-20 15:05:00 +00:00
+LBNE @outerloop
@exit rts