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

71 lines
2.1 KiB
Plaintext
Executable File

;license:MIT
;(c) 2017-2020 by qkumba/4am/John Brooks
!cpu 6502
!to "build/FX.INDEXED/BIT.FIZZLE",plain
*=$6000
addrs = $6100 ; [256 bytes, page-aligned]
copymasks = $6200 ; [256 bytes, page-aligned]
!source "src/fx/macros.a"
+COPY_TO_0 start, end
;X=0
;A=1
-- ldy #$20 ; create copymask table
ora #%10000000
- sta copymasks, x
inx
dey
bne -
asl
bne --
pha
pha
clc
-- ldy #$20 ; create address lookup table
tya
- sta addrs, x
adc #1
inx
dey
bne -
txa
bne --
rts ; exit via LFSR code on zero page
start
!pseudopc 0 {
; in: X,Y=0
!byte %00000001
loop txa
loop1 eor #$B4 ; LFSR form 0xB400 with period 65535
tax ; X is LFSR high byte, Y is LFSR low byte
loop2 lda addrs, x ; which means X is the index into the base address lookup table
sta <dst+2 ; and Y is the offset from the base address
eor #$60 ; which works out well with the available addressing modes
sta <src+2
lda (<dst+1), y
src eor $FD00, y ; merge source and destination bits
and copymasks, x ; isolate the bits to replace, zero the rest
eor (<dst+1), y ; unmerge source and destination bits, leaves 'to keep' destination bits intact
dst sta $FD00, y ; write the result
txa
lsr
tax
tya
ror
tay
bcc loop2 ; C modified by ror
bne loop ; Z modified by tay
bit $C000
bmi exit
txa
bne loop1
lda (src+1), y ; last lousy byte (because LFSR never hits 0)
sta (dst+1), y
exit rts
}
end