don't need to restore zero page

which simplifies things somewhat
This commit is contained in:
4am 2020-09-05 00:51:07 -04:00
parent 86d3dc4b72
commit 9446d5b10e
3 changed files with 45 additions and 72 deletions

View File

@ -8,9 +8,11 @@
addrs = $6100 ; [256 bytes, page-aligned] addrs = $6100 ; [256 bytes, page-aligned]
copymasks = $6200 ; [256 bytes, page-aligned] copymasks = $6200 ; [256 bytes, page-aligned]
jsr swapzp ; copy LFSR code to zero page ldx #(end-start) ; copy LFSR code to zero page
- lda start-1, x
inx ; X=0 sta $0, x
dex
bne -
lda #%00000001 ; create copymask lookup table lda #%00000001 ; create copymask lookup table
-- ldy #$20 -- ldy #$20
ora #%10000000 ora #%10000000
@ -20,7 +22,8 @@ copymasks = $6200 ; [256 bytes, page-aligned]
bne - bne -
asl asl
bne -- bne --
; X=0 pha
pha
clc clc
-- ldy #$20 ; create address lookup table -- ldy #$20 ; create address lookup table
tya tya
@ -31,38 +34,23 @@ copymasks = $6200 ; [256 bytes, page-aligned]
bne - bne -
txa txa
bne -- bne --
; X,Y=0 rts ; exit via LFSR code on zero page
jsr $0 ; call LFSR code on zero page
lda $4000 ; last lousy byte (because LFSR never hits 0)
sta $2000
; fall through to restore and exit
swapzp ldx #(end-start-1)
- ldy start, x
lda $0, x
sta start, x
sty $0, x
dex
bpl -
rts ; X=#$FF
start start
!pseudopc 0 { !pseudopc 1 {
; in: X,Y=0 ; in: X,Y=0
loop txa loop txa
loop1 eor #$B4 ; LFSR form 0xB400 for period 65535 loop1 eor #$B4 ; LFSR form 0xB400 with period 65535
tax ; X is LFSR high byte, Y is LFSR low byte 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 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 sta <dst+2 ; and Y is the offset from the base address
eor #$60 ; which works out well with the available addressing modes eor #$60 ; which works out well with the available addressing modes
sta <src+2 sta <src+2
lda (<dst+1), y lda (<dst+1), y
src eor $FD00, y ; merge source and destination bits src eor $FD00, y ; merge source and destination bits
and copymasks, x ; isolate the bits to replace, zero the rest 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 eor (<dst+1), y ; unmerge source and destination bits, leaves 'to keep' destination bits intact
dst sta $FD00, y ; write the result dst sta $FD00, y ; write the result
txa txa
lsr lsr
tax tax
@ -75,6 +63,8 @@ dst sta $FD00, y ; write the result
bmi exit bmi exit
txa txa
bne loop1 bne loop1
exit rts exit lda $4000 ; last lousy byte (because LFSR never hits 0)
sta $2000
rts
} }
end end

View File

@ -8,9 +8,11 @@
addrs = $6100 ; [256 bytes, page-aligned] addrs = $6100 ; [256 bytes, page-aligned]
copymasks = $6200 ; [128 bytes, should not cross page boundary] copymasks = $6200 ; [128 bytes, should not cross page boundary]
jsr swapzp ; copy LFSR code to zero page ldx #(end-start) ; copy LFSR code to zero page
- lda start-1, x
inx ; X=0 sta $0, x
dex
bne -
lda #%00000011 ; create copymask lookup table lda #%00000011 ; create copymask lookup table
-- ldy #$20 -- ldy #$20
ora #%10000000 ora #%10000000
@ -21,7 +23,8 @@ copymasks = $6200 ; [128 bytes, should not cross page boundar
asl asl
asl asl
bne -- bne --
pha
pha
tax ; X=0 tax ; X=0
clc clc
-- ldy #$20 ; create address lookup table -- ldy #$20 ; create address lookup table
@ -33,23 +36,10 @@ copymasks = $6200 ; [128 bytes, should not cross page boundar
bne - bne -
txa txa
bne -- bne --
; X,Y=0 rts ; exit via LFSR code on zero page
jsr $0 ; call LFSR code on zero page
lda $4000 ; last lousy byte (because LFSR never hits 0)
sta $2000
; fall through to restore and exit
swapzp ldx #(end-start-1)
- ldy start, x
lda $0, x
sta start, x
sty $0, x
dex
bpl -
rts ; X=#$FF
start start
!pseudopc 0 { !pseudopc 1 {
; in: X,Y=0 ; in: X,Y=0
loop txa loop txa
loop1 eor #$60 ; LFSR form 0x6000 with period 32767 loop1 eor #$60 ; LFSR form 0x6000 with period 32767
@ -58,13 +48,11 @@ loop2 lda addrs, x ; which means X is the index into the base
sta <dst+2 ; and Y is the offset from the base address sta <dst+2 ; and Y is the offset from the base address
eor #$60 ; which works out well with the available addressing modes eor #$60 ; which works out well with the available addressing modes
sta <src+2 sta <src+2
lda (<dst+1), y lda (<dst+1), y
src eor $FD00, y ; merge source and destination bits src eor $FD00, y ; merge source and destination bits
and copymasks, x ; isolate the bits to replace, zero the rest 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 eor (<dst+1), y ; unmerge source and destination bits, leaves 'to keep' destination bits intact
dst sta $FD00, y ; write the result dst sta $FD00, y ; write the result
txa txa
lsr lsr
tax tax
@ -77,6 +65,8 @@ dst sta $FD00, y ; write the result
bmi exit bmi exit
txa txa
bne loop1 bne loop1
exit rts exit lda $4000 ; last lousy byte (because LFSR never hits 0)
sta $2000
rts
} }
end end

View File

@ -7,20 +7,24 @@
addrs=$A100 ; [128 bytes, can be anywhere in main memory but don't cross page boundary] addrs=$A100 ; [128 bytes, can be anywhere in main memory but don't cross page boundary]
jsr swapzp ; copy LFSR code to zero page ldx #(end-start) ; copy LFSR code to zero page
- lda start-1, x
ldx #$7F ; create address lookup table sta $0, x
dex
bne -
ldx #$80 ; create address lookup table
lda #$9F lda #$9F
sec sec
- sta addrs, x - sta addrs-1, x
sbc #1 sbc #1
dex dex
bpl - bne -
inx ; X=0 sta $C005
txa
sta $C005 ; pre-copy SHR SCB and palette pha
ldy #0 pha
- lda $9D00, y tay
- lda $9D00, y ; pre-copy SHR SCB and palette
sta $9D00, y sta $9D00, y
lda $9E00, y lda $9E00, y
sta $9E00, y sta $9E00, y
@ -28,24 +32,10 @@ addrs=$A100 ; [128 bytes, can be anywhere in main memor
sta $9F00, y sta $9F00, y
iny iny
bne - bne -
; X,Y=0 rts ; exit via LFSR code on zero page
jsr $0 ; call LFSR code on zero page
lda $2000 ; last lousy byte (because LFSR never hits 0)
sta $2000
sta $C004
; fall through to restore and exit
swapzp ldx #(end-start-1)
- ldy start, x
lda $0, x
sta start, x
sty $0, x
dex
bpl -
rts
start start
!pseudopc 0 { !pseudopc 1 {
; in: X,Y=0 ; in: X,Y=0
loop txa loop txa
loop1 eor #$60 ; LFSR form 0x6000 with period 32767 loop1 eor #$60 ; LFSR form 0x6000 with period 32767
@ -66,6 +56,9 @@ dst sta $FD00, y
bmi exit bmi exit
txa txa
bne loop1 bne loop1
exit rts exit lda $2000 ; last lousy byte (because LFSR never hits 0)
sta $2000
sta $C004
rts
} }
end end