;license:MIT ;(c) 2020 by 4am !cpu 6502 !to "build/FX.INDEXED/CHECKERB.FIZZLE",plain *=$6000 addrs = $6100 ; [256 bytes, page-aligned] copymasks = $6200 ; [128 bytes, should not cross page boundary] shapemaskaddrs = $6300 ; [256 bytes, page-aligned] hgrlo = $6400 ; [$C0 bytes, should not cross page boundary] hgrhi = $6500 ; [$C0 bytes, should not cross page boundary] shapemask = $8000 ; [$2000 bytes, page-aligned] ldx #0 ; build an HGR base address lookup table, - txa ; except the first address is |shapemask| instead of $2000 and #$F8 bpl + ora #5 + asl bpl + ora #5 + asl asl sta hgrlo,x txa and #7 rol asl hgrlo,x rol ora #>shapemask sta hgrhi,x inx cpx #$C0 bne - ldx #0 ; create shapemask table -- lda hgrlo, x sta $FE lda hgrhi, x sta $FF txa lsr lsr lsr lsr lsr lsr lda #%00000000 bcc + eor #%11111111 + ldy #$27 - eor #%11111111 sta ($FE), y dey sta ($FE), y dey sta ($FE), y dey sta ($FE), y dey sta ($FE), y dey sta ($FE), y dey sta ($FE), y dey sta ($FE), y dey bpl - inx cpx #$C0 bne -- ldx #(end-start) ; copy LFSR code to zero page - lda start-1, x sta $FF, x dex bne - -- ldy #$20 ; create copymask lookup table ora #%10000000 - sta copymasks, x inx dey bne - asl asl bne -- tax clc -- ldy #$20 ; create address lookup table tya - sta addrs, x adc #1 inx dey bne - txa bne -- clc ; create shapemaskaddrs lookup table -- ldy #$20 lda #>shapemask - sta shapemaskaddrs, x adc #1 inx dey bne - txa bne -- jsr $1 lda $4000 ; last lousy byte (because LFSR never hits 0) sta $2000 lda #$2C ; BIT sta