mirror of
https://github.com/a2-4am/4cade.git
synced 2024-12-26 20:30:29 +00:00
slightly faster swapzp, and some comments
This commit is contained in:
parent
39b643de50
commit
3dfc71a25a
@ -8,7 +8,7 @@
|
||||
copymasks = $6100 ; [256 bytes, page-aligned]
|
||||
addrs = $6200 ; [256 bytes, page-aligned]
|
||||
|
||||
jsr swapzp ; copy LFSR code to zerp page
|
||||
jsr swapzp ; copy LFSR code to zero page
|
||||
|
||||
inx
|
||||
lda #1 ; create copymask lookup table
|
||||
@ -62,14 +62,15 @@ 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 set by ror
|
||||
bne loop ; Z set by tay
|
||||
bcc loop2 ; C modified by ror
|
||||
bne loop ; Z modified by tay
|
||||
bit $C000
|
||||
bmi exit
|
||||
txa
|
||||
|
@ -5,12 +5,13 @@
|
||||
!to "build/FX/BIT2.FIZZLE",plain
|
||||
*=$6000
|
||||
|
||||
addrs = $6100 ; [256 bytes]
|
||||
copymasks = $6200 ; [128 bytes]
|
||||
addrs = $6100 ; [256 bytes, page-aligned]
|
||||
copymasks = $6200 ; [128 bytes, should not cross page boundary]
|
||||
|
||||
jsr swapzp ; copy LFSR code to zero page
|
||||
|
||||
jsr swapzp
|
||||
ldx #0
|
||||
lda #%00000011
|
||||
lda #%00000011 ; create copymask lookup table
|
||||
-- ldy #$20
|
||||
ora #%10000000
|
||||
- sta copymasks, x
|
||||
@ -22,7 +23,7 @@ copymasks = $6200 ; [128 bytes]
|
||||
bne --
|
||||
clc
|
||||
ldx #0
|
||||
-- ldy #$20
|
||||
-- ldy #$20 ; create address lookup table
|
||||
tya
|
||||
- sta addrs, x
|
||||
adc #1
|
||||
@ -31,14 +32,17 @@ copymasks = $6200 ; [128 bytes]
|
||||
bne -
|
||||
txa
|
||||
bne --
|
||||
jsr $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)
|
||||
- lda $0, x
|
||||
pha
|
||||
lda start, x
|
||||
sta $0, x
|
||||
pla
|
||||
- ldy start, x
|
||||
lda $0, x
|
||||
sta start, x
|
||||
sty $0, x
|
||||
dex
|
||||
bpl -
|
||||
rts
|
||||
@ -47,31 +51,31 @@ start
|
||||
!pseudopc 0 {
|
||||
; in: X,Y=0
|
||||
loop txa
|
||||
loop1 eor #$60
|
||||
tax
|
||||
loop2 lda addrs, x
|
||||
sta <dst+2
|
||||
eor #$60
|
||||
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
|
||||
and copymasks, x
|
||||
eor (<dst+1), y
|
||||
dst sta $FD00, 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
|
||||
bne loop
|
||||
bcc loop2 ; C modified by ror
|
||||
bne loop ; Z modified by tay
|
||||
bit $C000
|
||||
bmi exit
|
||||
txa
|
||||
bne loop1
|
||||
exit lda $4000
|
||||
sta $2000
|
||||
rts
|
||||
exit rts
|
||||
}
|
||||
end
|
||||
|
@ -36,12 +36,10 @@ addrs=$A100 ; [128 bytes, can be anywhere in main memory but don't
|
||||
|
||||
sta $C004 ; restore and exit
|
||||
swapzp ldx #(end-start-1)
|
||||
- lda $0, x
|
||||
pha
|
||||
lda start, x
|
||||
sta $0, x
|
||||
pla
|
||||
- ldy start, x
|
||||
lda $0, x
|
||||
sta start, x
|
||||
sty $0, x
|
||||
dex
|
||||
bpl -
|
||||
rts
|
||||
|
Loading…
Reference in New Issue
Block a user