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]
copymasks = $6200 ; [256 bytes, page-aligned]
jsr swapzp ; copy LFSR code to zero page
inx ; X=0
ldx #(end-start) ; copy LFSR code to zero page
- lda start-1, x
sta $0, x
dex
bne -
lda #%00000001 ; create copymask lookup table
-- ldy #$20
ora #%10000000
@ -20,7 +22,8 @@ copymasks = $6200 ; [256 bytes, page-aligned]
bne -
asl
bne --
; X=0
pha
pha
clc
-- ldy #$20 ; create address lookup table
tya
@ -31,38 +34,23 @@ copymasks = $6200 ; [256 bytes, page-aligned]
bne -
txa
bne --
; X,Y=0
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
rts ; exit via LFSR code on zero page
start
!pseudopc 0 {
!pseudopc 1 {
; in: X,Y=0
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
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
@ -75,6 +63,8 @@ dst sta $FD00, y ; write the result
bmi exit
txa
bne loop1
exit rts
exit lda $4000 ; last lousy byte (because LFSR never hits 0)
sta $2000
rts
}
end

View File

@ -8,9 +8,11 @@
addrs = $6100 ; [256 bytes, page-aligned]
copymasks = $6200 ; [128 bytes, should not cross page boundary]
jsr swapzp ; copy LFSR code to zero page
inx ; X=0
ldx #(end-start) ; copy LFSR code to zero page
- lda start-1, x
sta $0, x
dex
bne -
lda #%00000011 ; create copymask lookup table
-- ldy #$20
ora #%10000000
@ -21,7 +23,8 @@ copymasks = $6200 ; [128 bytes, should not cross page boundar
asl
asl
bne --
pha
pha
tax ; X=0
clc
-- ldy #$20 ; create address lookup table
@ -33,23 +36,10 @@ copymasks = $6200 ; [128 bytes, should not cross page boundar
bne -
txa
bne --
; X,Y=0
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
rts ; exit via LFSR code on zero page
start
!pseudopc 0 {
!pseudopc 1 {
; in: X,Y=0
loop txa
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
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
@ -77,6 +65,8 @@ dst sta $FD00, y ; write the result
bmi exit
txa
bne loop1
exit rts
exit lda $4000 ; last lousy byte (because LFSR never hits 0)
sta $2000
rts
}
end

View File

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