mode7_demo: fade in / fade out

could stand to be optimized
This commit is contained in:
Vince Weaver 2017-12-17 22:18:24 -05:00
parent ca61c86a63
commit 29468ccdcf

View File

@ -23,7 +23,29 @@
jsr load_rle_gr jsr load_rle_gr
loop_forever: demo_loop:
jsr fade_in
lda #255
jsr WAIT
jsr fade_out
jmp demo_loop
;============================================
; gr, "fade" out. Badly fake a pallette fade
;============================================
; Image to fade out should be in $C00
fade_out:
lda #<fade_lookup lda #<fade_lookup
sta GBASL sta GBASL
@ -69,48 +91,98 @@ loop_forever:
lda #200 lda #200
jsr WAIT jsr WAIT
rts
;===========================================
; gr, "fade" in. Badly fake a pallette fade
;===========================================
; Image to fade in should be in $C00
fade_in:
jmp loop_forever lda #<(fade_lookup+48)
sta GBASL
lda #>(fade_lookup+48)
sta GBASH
jsr gr_fade
jsr page_flip
;================================================ lda #200
; Fade in/out lowres graphics jsr WAIT
; GR image should be in $C00
lda #<(fade_lookup+32)
sta GBASL
lda #>(fade_lookup+32)
sta GBASH
jsr gr_fade
jsr page_flip
lda #200
jsr WAIT
lda #<(fade_lookup+16)
sta GBASL
lda #>(fade_lookup+16)
sta GBASH
jsr gr_fade
jsr page_flip
lda #200
jsr WAIT
lda #<(fade_lookup+0)
sta GBASL
lda #>(fade_lookup+0)
sta GBASH
jsr gr_fade
jsr page_flip
lda #200
jsr WAIT
rts
;================================================
; Fade in/out lowres graphics
; GR image should be in $C00
; pointer to fade table in GBASL/GBASH
gr_fade: gr_fade:
ldx #0 ; set ypos to zero ; 2 ldx #0 ; set ypos to zero ; 2
gr_copy_loop: gr_fade_loop:
lda gr_offsets,X ; lookup low byte for line addr ; 4+ lda gr_offsets,X ; lookup low byte for line addr ; 4+
sta gr_copy_line1+1 ; out and in are the same ; 4 sta gr_fade_line1+1 ; out and in are the same ; 4
sta gr_copy_line2+1 ; 4 sta gr_fade_line2+1 ; 4
lda gr_offsets+1,X ; lookup high byte for line addr ; 4+ lda gr_offsets+1,X ; lookup high byte for line addr ; 4+
clc ; 2 clc ; 2
adc DRAW_PAGE ; 3 adc DRAW_PAGE ; 3
sta gr_copy_line2+2 ; 4 sta gr_fade_line2+2 ; 4
lda gr_offsets+1,X ; lookup high byte for line addr ; 4+ lda gr_offsets+1,X ; lookup high byte for line addr ; 4+
adc #$8 ; for now, fixed 0xc ; 2 adc #$8 ; for now, fixed 0xc ; 2
sta gr_copy_line1+2 ; 4 sta gr_fade_line1+2 ; 4
ldy #0 ; set xpos counter to 0 ; 2 ldy #0 ; set xpos counter to 0 ; 2
cpx #$8 ; don't want to copy bottom 4*40 ; 2 cpx #$8 ; don't want to copy bottom 4*40 ; 2
bcs gr_copy_above4 ; 2nt/3 bcs gr_fade_above4 ; 2nt/3
gr_copy_below4: gr_fade_below4:
ldy #119 ; for early ones, copy 120 bytes ; 2 ldy #119 ; for early ones, copy 120 bytes ; 2
bcc gr_copy_line1 ; ; 3 bcc gr_fade_line1 ; ; 3
gr_copy_above4: ; for last four, just copy 80 bytes gr_fade_above4: ; for last four, just copy 80 bytes
ldy #79 ; 2 ldy #79 ; 2
gr_copy_line1: gr_fade_line1:
lda $ffff,Y ; load a byte (self modified) ; 4+ lda $ffff,Y ; load a byte (self modified) ; 4+
pha pha
@ -139,16 +211,16 @@ gr_copy_line1:
ldy TEMPY ; restore Y ldy TEMPY ; restore Y
gr_copy_line2: gr_fade_line2:
sta $ffff,Y ; store a byte (self modified) ; 5 sta $ffff,Y ; store a byte (self modified) ; 5
dey ; decrement pointer ; 2 dey ; decrement pointer ; 2
bpl gr_copy_line1 ; ; 2nt/3 bpl gr_fade_line1 ; ; 2nt/3
gr_copy_line_done: gr_fade_line_done:
inx ; increment ypos value ; 2 inx ; increment ypos value ; 2
inx ; twice, as address is 2 bytes ; 2 inx ; twice, as address is 2 bytes ; 2
cpx #16 ; there are 8*2 of them ; 2 cpx #16 ; there are 8*2 of them ; 2
bne gr_copy_loop ; if not, loop ; 3 bne gr_fade_loop ; if not, loop ; 3
rts ; 6 rts ; 6