Revert "don't clear incremental palettes before stepping"

This reverts commit 215a11fb3d.
This commit is contained in:
4am 2021-11-30 21:28:10 -05:00
parent 215a11fb3d
commit 7f96f96132

View File

@ -1,159 +1,60 @@
;license:MIT ;license:MIT
;(c) 2021 by 4am ;(c) 2019-2020 by qkumba/4am/John Brooks
!cpu 6502 !cpu 6502
!to "build/FX/SHR.FIZZLE",plain !to "build/SHR.FIZZLE",plain
*=$A000 *=$A000
color = $F8 ; byte !source "src/fx/fx.shr.common.a"
fracv = $F9 ; byte
incv = $FA ; byte
src = $FC ; word
dst = $FE ; word
!source "src/fx/macros.a" addrs=$80 ; [128 bytes]
sta $C005 ldx #(end-start) ; copy LFSR code to zero page
ldy #0 ; copy pixel data - lda start-1, x
sty src sta $FF, x
sty dst
lda #$20
sta src+1
ldx #$7D
- lda (src), y
sta (src), y
iny
bne -
inc src+1
dex dex
bne - bne -
lda #$A0 ; create address lookup table
tax
tay
- dey
sty addrs-$21, x
dex
bne -
;X=0
+COPY_SCB_AND_PALETTES
;Y=0 ;Y=0
- lda $9D00, y ; copy SCB
sta $9D00, y
lda #0
sta $9E00, y ; clear palettes
sta $9F00, y
iny
bne -
sta $C004 jmp loop
lda #$9E
sta src+1
ldx #$0F ; palette counter ($0F -> $00, not used as index)
rb_palette_loop
ldy #$00 ; byte offset within palette (00 -> 1F, used as index)
rb_color_loop
lda #$00
sta fracv
sta color
lda src
sta dst
lda src+1
sec
sbc #$3E
sta dst+1
lda (src), y ; get final Red or Blue value for this color in this palette
asl ; Red or Blue value is bits 0-3, shift them into bits 4-7
asl
asl
asl
sta incv
rb_step_loop
lda fracv
clc
adc incv
sta fracv
bcc +
inc color
+ lda color
sta (dst), y
inc dst+1
inc dst+1
bpl rb_step_loop
iny
cpy #$20
bcc rb_color_loop
lda src
clc
adc #$20
sta src
bcc +
inc src+1
+ dex
bpl rb_palette_loop
lda #$9E start
sta src+1 !pseudopc 0 {
ldx #$0F ; palette counter ($0F -> $00, not used as index) ;X=0
g_palette_loop ;Y=0
ldy #$00 ; byte offset within palette (00 -> 1E by 2, used as index) loop txa
g_color_loop loop1 eor #$60 ; LFSR form 0x6000 with period 32767
lda #$00 tax
sta fracv loop2 lda addrs, x
sta color sta <src+1
lda src src=*+1
sta dst lda $FD00, y ; SMC high byte
lda src+1 sta (<src), y
sec txa
sbc #$3E lsr
sta dst+1 tax
lda (src), y ; get final Green value for this color in this palette tya
and #$F0 ; Green value is bits 4-7, mask out other bits ror
sta incv tay
g_step_loop bcc loop2
lda fracv bne loop
clc bit $C000
adc incv
sta fracv
lda color
bcc +
clc
adc #$10
sta color
+ ora (dst), y ; keep existing Blue value in bits 0-3
sta (dst), y
inc dst+1
inc dst+1
bpl g_step_loop
iny
iny ; high nibble of second color byte is always 0 so skip it
cpy #$20
bcc g_color_loop
lda src
clc
adc #$20
sta src
bcc +
inc src+1
+ dex
bpl g_palette_loop
ldx #$62
stx copy1+2
inx
stx copy2+2
ldx #$0E
ldy #$00
copyloop jsr WaitForVBL
sta $C005
copy1 lda $6200, y ; SMC
sta $9E00, y
copy2 lda $6300, y ; SMC
sta $9F00, y
iny
bne copy1
sta $C004
inc copy1+2
inc copy1+2
inc copy2+2
inc copy2+2
lda #$40
jsr WaitForKeyWithTimeout
bmi exit bmi exit
dex txa
bpl copyloop bne loop1
exit sta $C004 exit lda $2000 ; last lousy byte (because LFSR never hits 0)
jmp UnwaitForVBL sta $2000
sta $C004
!source "src/wait.a" rts
}
end