mirror of
https://github.com/a2-4am/4cade.git
synced 2024-06-27 03:29:30 +00:00
72 lines
2.2 KiB
Plaintext
72 lines
2.2 KiB
Plaintext
;license:MIT
|
|
;(c) 2017-2020 by qkumba/4am/John Brooks
|
|
|
|
!cpu 6502
|
|
!to "build/FX.INDEXED/BIT2.FIZZLE",plain
|
|
*=$6000
|
|
|
|
addrs = $6100 ; [256 bytes, page-aligned]
|
|
copymasks = $80 ; [128 bytes, should not cross page boundary]
|
|
|
|
!source "src/fx/macros.a"
|
|
|
|
+COPY_TO_0 start, end
|
|
;X=0
|
|
-- ldy #$20 ; create copymask table
|
|
ora #%10000000
|
|
- sta copymasks, x
|
|
inx
|
|
dey
|
|
bne -
|
|
asl
|
|
asl
|
|
bne --
|
|
pha
|
|
pha
|
|
tax
|
|
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 %00000011
|
|
loop txa
|
|
loop1 eor #$60 ; LFSR form 0x6000 with period 32767
|
|
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
|