2019-10-16 01:51:51 +00:00
|
|
|
;license:MIT
|
2020-09-04 16:22:43 +00:00
|
|
|
;(c) 2017-2020 by qkumba/4am/John Brooks
|
2019-10-16 01:51:51 +00:00
|
|
|
|
|
|
|
!cpu 6502
|
2021-10-16 01:34:39 +00:00
|
|
|
!to "build/FX.INDEXED/BIT.FIZZLE",plain
|
2019-10-16 01:51:51 +00:00
|
|
|
*=$6000
|
|
|
|
|
2020-09-05 03:44:38 +00:00
|
|
|
addrs = $6100 ; [256 bytes, page-aligned]
|
|
|
|
copymasks = $6200 ; [256 bytes, page-aligned]
|
2020-09-04 05:01:32 +00:00
|
|
|
|
2021-12-17 23:29:35 +00:00
|
|
|
!source "src/fx/macros.a"
|
|
|
|
|
|
|
|
+COPY_TO_0 start, end
|
2021-12-14 02:15:26 +00:00
|
|
|
;X=0
|
|
|
|
;A=1
|
2020-09-07 20:56:40 +00:00
|
|
|
-- ldy #$20 ; create copymask table
|
2020-09-05 03:44:38 +00:00
|
|
|
ora #%10000000
|
2020-09-04 14:21:59 +00:00
|
|
|
- sta copymasks, x
|
|
|
|
inx
|
|
|
|
dey
|
|
|
|
bne -
|
|
|
|
asl
|
|
|
|
bne --
|
2020-09-05 04:51:07 +00:00
|
|
|
pha
|
|
|
|
pha
|
2020-09-04 14:21:59 +00:00
|
|
|
clc
|
2020-09-04 23:11:30 +00:00
|
|
|
-- ldy #$20 ; create address lookup table
|
2020-09-04 14:21:59 +00:00
|
|
|
tya
|
|
|
|
- sta addrs, x
|
2020-09-04 16:22:43 +00:00
|
|
|
adc #1
|
2020-09-04 14:21:59 +00:00
|
|
|
inx
|
|
|
|
dey
|
|
|
|
bne -
|
|
|
|
txa
|
|
|
|
bne --
|
2020-09-05 04:51:07 +00:00
|
|
|
rts ; exit via LFSR code on zero page
|
2020-09-04 04:20:56 +00:00
|
|
|
|
2020-09-04 14:21:59 +00:00
|
|
|
start
|
2020-09-07 20:56:40 +00:00
|
|
|
!pseudopc 0 {
|
2020-09-04 16:22:43 +00:00
|
|
|
; in: X,Y=0
|
2020-09-07 20:56:40 +00:00
|
|
|
!byte %00000001
|
2020-09-04 16:22:43 +00:00
|
|
|
loop txa
|
2020-09-05 04:51:07 +00:00
|
|
|
loop1 eor #$B4 ; LFSR form 0xB400 with period 65535
|
2020-09-04 23:11:30 +00:00
|
|
|
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
|
2020-09-04 14:21:59 +00:00
|
|
|
sta <src+2
|
|
|
|
lda (<dst+1), y
|
2020-09-04 23:11:30 +00:00
|
|
|
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
|
2020-09-04 16:22:43 +00:00
|
|
|
txa
|
|
|
|
lsr
|
|
|
|
tax
|
|
|
|
tya
|
|
|
|
ror
|
|
|
|
tay
|
2020-09-04 23:25:05 +00:00
|
|
|
bcc loop2 ; C modified by ror
|
|
|
|
bne loop ; Z modified by tay
|
2020-09-04 16:22:43 +00:00
|
|
|
bit $C000
|
2020-09-04 04:20:56 +00:00
|
|
|
bmi exit
|
2020-09-04 16:22:43 +00:00
|
|
|
txa
|
|
|
|
bne loop1
|
2021-12-14 02:15:26 +00:00
|
|
|
lda (src+1), y ; last lousy byte (because LFSR never hits 0)
|
2021-12-14 00:48:44 +00:00
|
|
|
sta (dst+1), y
|
2021-12-14 02:15:26 +00:00
|
|
|
exit rts
|
2020-09-04 04:20:56 +00:00
|
|
|
}
|
2020-09-04 14:21:59 +00:00
|
|
|
end
|