4sports/src/fx/fx.cover.fade.a
2022-08-28 12:06:42 -04:00

126 lines
2.4 KiB
Plaintext
Executable File

;license:MIT
;(c) 2022 by 4am
;
; fade-to-black routine via progressive dithering
;
!cpu 6502
!to "build/COVERFADE",plain
*=$6000
page1 = $FC
page2 = $FE
dithermasks = $6200
hgrlo = $6301
hgrhi = $6401
!source "src/fx/macros.a"
!macro ROW_X_TO_COVER_BASE_ADDRESSES {
; X = $01..$C0, mapping to row 0..191
lda hgrlo-1, x
sta page1
sta page2
lda hgrhi-1, x
sta page1+1
eor #$60
sta page2+1
}
+BUILD_DITHER_MASKS dithermasks
+BUILD_HGR_LOOKUP_TABLES hgrlo, hgrhi
ldx #$80
lda #0
- sta dithermasks, x
inx
bne -
sta dithermasks
ldx #$C0
--
+ROW_X_TO_COVER_BASE_ADDRESSES
ldy #$27
- lda (page1), y
dith0 and dithermasks+44, y
sta (page2), y
dey
bpl -
lda dith0+1
eor #44
sta dith0+1
dex
bne --
bit $C055
ldx #$C0
--
+ROW_X_TO_COVER_BASE_ADDRESSES
ldy #$27
- lda (page2), y
dith and dithermasks+2, y
sta (page1), y
dey
bpl -
lda dith+1
eor #2
sta dith+1
dex
bne --
bit $C054
ldx #$C0
--
+ROW_X_TO_COVER_BASE_ADDRESSES
ldy #$27
- lda (page1), y
dith2 and dithermasks, y
sta (page2), y
dey
bpl -
lda dith2+1
eor #44
sta dith2+1
dex
bne --
bit $C055
ldx #$C0
--
+ROW_X_TO_COVER_BASE_ADDRESSES
txa
and #4
beq +
lda #$80
!byte $2C
+ lda #$00
sta dith3+1
ldy #$27
- lda (page2), y
dith3 and dithermasks+$80, y
sta (page1), y
dey
bpl -
dex
bne --
bit $C054
ldx #$C0
--
+ROW_X_TO_COVER_BASE_ADDRESSES
ldy #$27
- lda (page1), y
and dithermasks+$80, y
sta (page2), y
dey
bpl -
dex
bne --
bit $C055
rts