shave some bytes

This commit is contained in:
4am 2021-12-14 00:19:32 -05:00
parent 29536bd901
commit 5decadcabc
7 changed files with 53 additions and 83 deletions

View File

@ -1,86 +1,56 @@
;license:MIT
;(c) 2019 by qkumba
;(c) 2017-2021 by qkumba/4am/John Brooks
!cpu 6502
!to "build/GR.FIZZLE",plain
*=$6000
;init RNG
ldx #1
stx @rnd1+1
ldx #(end-start+1) ; copy LFSR code to zero page
- ldy start-2, x
sty $FE, x
dex
stx @rnd2+1
bne -
jmp loop
;iterate
@loop
ldy @rnd1+1
ldx @rnd2+1
lsr @rnd2+1
ror @rnd1+1
bcc +
;feedback polynomial forms #$402 for period of 2047
lda @rnd1+1
eor #2
sta @rnd1+1
lda @rnd2+1
eor #4
sta @rnd2+1
;little hack to avoid missing offset zero
;screen hole at $xxFF is missed instead
+ tya
eor #$ff
sta $26
sta $3c
and #$78
cmp #$78
beq @rnd2
txa
and #3
;target page 1
ora #4
sta $3d
start
!pseudopc 0 {
;X=0
;Y=0
loop txa
loop1 eor #$05 ; LFSR form 0x0500 with period 2047
wait inx
bpl wait
tax
loop2 txa
and #$03
ora #$04
sta <dst+2
eor #$44
sta $27
;set mask according to offset
lda #$0f
cpx #4
bcc @src
lda #$f0
;copy half-pixel from other page to this page
@src sta @mask+1
ldy #0
and ($26),y ; isolate source half
eor ($3c),y ; merge with whole target
@mask and #$d1 ; SMC isolate merged half
eor ($3c),y ; unmerge half of target
sta ($3c),y ; store both halves
;wait while checking for keypress
ldx #$10
@wait lda $c000
bmi @exit
dex
bne @wait
;and exit condition
@rnd2 lda #0
bne @loop
@rnd1 lda #0
cmp #1
bne @loop
@exit rts
sta <src+2
lda #%00001111
cpx #$04
bcc +
lda #%11110000
+ sta <mask+1
src and $FD00, y ; SMC high byte
eor (dst+1), y
mask and #$FD ; SMC
eor (dst+1), y
dst sta $FD00, y ; SMC high byte
txa
lsr
tax
tya
ror
tay
bcc loop2
bne loop
bit $C000
bmi exit
txa
bne loop1
lda (src+1), y
sta (dst+1), y
exit rts
}
end

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10952924
!be24 10952893
!le16 448

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10953372
!be24 10953341
!le16 303

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10952656
!be24 10952625
!le16 67

View File

@ -5,4 +5,4 @@
;
!byte 0
!be24 10952549
!le16 107
!le16 76

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10952723
!be24 10952692
!le16 201

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 10953675
!be24 10953644
!le16 2370